mirror of
https://github.com/ddaodan/minechatgpt.git
synced 2025-02-18 15:54:13 +08:00
删除自动更新配置文件功能
This commit is contained in:
parent
fa5d79e252
commit
f021715cec
@ -25,121 +25,90 @@ public class ConfigManager {
|
||||
private String translateColorCodes(String message) {
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
|
||||
public String getCurrentModel() {
|
||||
return currentModel;
|
||||
}
|
||||
|
||||
public void setCurrentModel(String model) {
|
||||
currentModel = model;
|
||||
}
|
||||
public String getConfigVersion() {
|
||||
return config.getString("version", "1.0");
|
||||
}
|
||||
public String getApiKey() {
|
||||
return config.getString("api.key");
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return config.getString("api.base_url");
|
||||
}
|
||||
|
||||
public String getDefaultModel() {
|
||||
return config.getString("default_model");
|
||||
}
|
||||
|
||||
public String getReloadMessage() {
|
||||
return translateColorCodes(config.getString("messages.reload"));
|
||||
}
|
||||
|
||||
public List<String> getModels() {
|
||||
return config.getStringList("models");
|
||||
}
|
||||
|
||||
public String getCustomPrompt() {
|
||||
return config.getString("prompt", "You are a helpful assistant.");
|
||||
}
|
||||
|
||||
public String getHelpMessage() {
|
||||
return translateColorCodes(config.getString("messages.help"));
|
||||
}
|
||||
|
||||
public String getHelpAskMessage() {
|
||||
return translateColorCodes(config.getString("messages.help_ask"));
|
||||
}
|
||||
|
||||
public String getHelpReloadMessage() {
|
||||
return translateColorCodes(config.getString("messages.help_reload"));
|
||||
}
|
||||
|
||||
public String getHelpModelMessage() {
|
||||
return translateColorCodes(config.getString("messages.help_model"));
|
||||
}
|
||||
|
||||
public String getHelpModelListMessage() {
|
||||
return translateColorCodes(config.getString("messages.help_modellist"));
|
||||
}
|
||||
|
||||
|
||||
public String getHelpContextMessage() {
|
||||
return translateColorCodes(config.getString("messages.help_context", "/chatgpt context - Toggle context mode."));
|
||||
}
|
||||
|
||||
public String getHelpClearMessage() {
|
||||
return translateColorCodes(config.getString("messages.help_clear", "/chatgpt clear - Clear conversation history."));
|
||||
}
|
||||
|
||||
public String getModelSwitchMessage() {
|
||||
return translateColorCodes(config.getString("messages.model_switch"));
|
||||
}
|
||||
|
||||
public String getChatGPTErrorMessage() {
|
||||
return translateColorCodes(config.getString("messages.chatgpt_error"));
|
||||
}
|
||||
|
||||
public String getChatGPTResponseMessage() {
|
||||
return translateColorCodes(config.getString("messages.chatgpt_response"));
|
||||
}
|
||||
|
||||
public String getQuestionMessage() {
|
||||
return translateColorCodes(config.getString("messages.question"));
|
||||
}
|
||||
|
||||
public String getInvalidModelMessage() {
|
||||
return translateColorCodes(config.getString("messages.invalid_model"));
|
||||
}
|
||||
|
||||
public String getAvailableModelsMessage() {
|
||||
return translateColorCodes(config.getString("messages.available_models"));
|
||||
}
|
||||
|
||||
public String getNoPermissionMessage() {
|
||||
return translateColorCodes(config.getString("messages.no_permission"));
|
||||
}
|
||||
|
||||
public String getCurrentModelInfoMessage() {
|
||||
return translateColorCodes(config.getString("messages.current_model_info"));
|
||||
}
|
||||
|
||||
public int getMaxHistorySize() {
|
||||
return config.getInt("conversation.max_history_size", 10);
|
||||
}
|
||||
|
||||
public boolean isContextEnabled() {
|
||||
return config.getBoolean("conversation.context_enabled", false);
|
||||
}
|
||||
|
||||
public String getContextToggleMessage() {
|
||||
return translateColorCodes(config.getString("messages.context_toggle", "Context is now %s."));
|
||||
}
|
||||
public String getContextToggleEnabledMessage() {
|
||||
return translateColorCodes(config.getString("messages.context_toggle_enabled", "enabled"));
|
||||
}
|
||||
|
||||
public String getContextToggleDisabledMessage() {
|
||||
return translateColorCodes(config.getString("messages.context_toggle_disabled", "disabled"));
|
||||
}
|
||||
|
||||
public String getClearMessage() {
|
||||
return translateColorCodes(config.getString("messages.clear", "Conversation history has been cleared."));
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.ddaodan.MineChatGPT;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
|
||||
@ -19,7 +18,6 @@ public final class Main extends JavaPlugin {
|
||||
tabCompleter = new MineChatGPTTabCompleter(configManager);
|
||||
Objects.requireNonNull(getCommand("chatgpt")).setExecutor(commandHandler);
|
||||
Objects.requireNonNull(getCommand("chatgpt")).setTabCompleter(tabCompleter);
|
||||
checkAndUpdateConfig();
|
||||
if (configManager.isDebugMode()) {
|
||||
getLogger().info( "DEBUG MODE IS TRUE!!!!!");
|
||||
}
|
||||
@ -32,27 +30,4 @@ public final class Main extends JavaPlugin {
|
||||
public void onDisable() {
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
private void checkAndUpdateConfig() {
|
||||
String currentVersion = getConfig().getString("version", "1.0");
|
||||
String pluginVersion = getDescription().getVersion();
|
||||
|
||||
if (!currentVersion.equals(pluginVersion)) {
|
||||
// 加载默认配置文件
|
||||
FileConfiguration defaultConfig = getConfig();
|
||||
reloadConfig();
|
||||
FileConfiguration newConfig = getConfig();
|
||||
|
||||
// 合并配置文件
|
||||
for (String key : defaultConfig.getKeys(true)) {
|
||||
if (!newConfig.contains(key)) {
|
||||
newConfig.set(key, defaultConfig.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
// 更新版本号
|
||||
newConfig.set("version", pluginVersion);
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user