2.5:Folia支持,fix #4

This commit is contained in:
2024-08-16 00:08:39 +08:00
parent 478a1077a6
commit c753d51e6b
6 changed files with 30 additions and 23 deletions

View File

@@ -166,7 +166,8 @@ public class CommandHandler implements CommandExecutor {
}
if (response.statusCode() == 200) {
String responseBody = response.bodyText();
JSONObject jsonResponse = new JSONObject(responseBody);
String utf8ResponseBody = new String(responseBody.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
JSONObject jsonResponse = new JSONObject(utf8ResponseBody);
String answer = jsonResponse.getJSONArray("choices").getJSONObject(0).getJSONObject("message").getString("content");
sender.sendMessage(configManager.getChatGPTResponseMessage().replace("%s", answer));
if (contextEnabled) {

View File

@@ -14,9 +14,9 @@ public class ConversationContext {
public void addMessage(String message) {
if (conversationHistory.size() >= maxHistorySize) {
conversationHistory.poll(); // Remove the oldest message
conversationHistory.poll();
}
conversationHistory.offer(message); // Add the new message
conversationHistory.offer(message);
}
public String getConversationHistory() {

View File

@@ -25,6 +25,6 @@ permissions:
minechatgpt.context:
description: Allows toggling context mode
default: true
chatgpt.clear:
minechatgpt.clear:
description: Allows clearing conversation history
default: true