forked from Upstream/Ollama-Chat
feat(update_lang)
This commit is contained in:
parent
a32a14c178
commit
22f072f738
@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'com'
|
||||
version = '1.0.2'
|
||||
version = '1.0.2-rc2'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -44,6 +44,8 @@ public class Ollamachat extends JavaPlugin implements Listener {
|
||||
String language = getConfig().getString("language", "en");
|
||||
loadLanguageFile(language);
|
||||
|
||||
updateCommandUsages();
|
||||
|
||||
databaseManager = new DatabaseManager();
|
||||
maxHistory = getConfig().getInt("max-history", 5);
|
||||
chatHistoryManager = new ChatHistoryManager(databaseManager, maxHistory);
|
||||
@ -56,6 +58,14 @@ public class Ollamachat extends JavaPlugin implements Listener {
|
||||
getCommand("aichat").setExecutor(this);
|
||||
}
|
||||
|
||||
private void updateCommandUsages() {
|
||||
String usageOllamachat = getMessage("usage-ollamachat", null);
|
||||
String usageAichat = getMessage("usage-aichat", null);
|
||||
|
||||
getCommand("ollamachat").setUsage(usageOllamachat);
|
||||
getCommand("aichat").setUsage(usageAichat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
databaseManager.close();
|
||||
@ -81,6 +91,24 @@ public class Ollamachat extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
private void reloadConfigValues() {
|
||||
File configFile = new File(getDataFolder(), "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
saveDefaultConfig(); // 如果配置文件不存在,保存默认配置
|
||||
} else {
|
||||
try {
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
if (!config.contains("ollama-api-url") || !config.contains("model")) {
|
||||
getLogger().warning(getMessage("config-invalid", null));
|
||||
configFile.delete();
|
||||
saveDefaultConfig();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().severe(getMessage("config-load-failed", Map.of("error", e.getMessage())));
|
||||
configFile.delete();
|
||||
saveDefaultConfig();
|
||||
}
|
||||
}
|
||||
|
||||
reloadConfig();
|
||||
updateConfig();
|
||||
|
||||
|
@ -4,10 +4,15 @@ toggle-enabled: "§a{ai-name} is now enabled."
|
||||
toggle-disabled: "§a{ai-name} is now disabled."
|
||||
invalid-ai-name: "§cInvalid AI name. Available AIs: {ai-list}."
|
||||
usage-aichat: "§cUsage: /aichat <ai-name> <prompt>"
|
||||
usage-ollamachat: "§cUsage: /ollamachat <reload|toggle <ai-name>>"
|
||||
player-only: "§cThis command can only be used by players."
|
||||
ollama-enabled: "§aOllama is now enabled."
|
||||
ollama-disabled: "§aOllama is now disabled."
|
||||
|
||||
# Chat interaction
|
||||
response-prefix: "§b[AI] §r"
|
||||
error-prefix: "§c[Error] §r"
|
||||
error-prefix: "§c[Error] §r"
|
||||
|
||||
# Log messages
|
||||
config-invalid: "§cConfig file is invalid or incomplete. Regenerating default config..."
|
||||
config-load-failed: "§cFailed to load config file: {error}. Regenerating default config..."
|
@ -4,10 +4,15 @@ toggle-enabled: "§a{ai-name} 已启用。"
|
||||
toggle-disabled: "§a{ai-name} 已禁用。"
|
||||
invalid-ai-name: "§c无效的 AI 名称。可用的 AI: {ai-list}。"
|
||||
usage-aichat: "§c用法: /aichat <ai名称> <提示>"
|
||||
usage-ollamachat: "§c用法: /ollamachat <reload|toggle <ai名称>>"
|
||||
player-only: "§c该命令只能由玩家使用。"
|
||||
ollama-enabled: "§aOllama 已启用。"
|
||||
ollama-disabled: "§aOllama 已禁用。"
|
||||
|
||||
# 聊天交互
|
||||
response-prefix: "§b[AI] §r"
|
||||
error-prefix: "§c[错误] §r"
|
||||
error-prefix: "§c[错误] §r"
|
||||
|
||||
# 日志消息
|
||||
config-invalid: "§c配置文件无效或不完整,正在重新生成默认配置..."
|
||||
config-load-failed: "§c加载配置文件失败: {error},正在重新生成默认配置..."
|
@ -1,5 +1,5 @@
|
||||
name: ollamachat
|
||||
version: '1.0.2-rc1'
|
||||
version: '1.0.2-rc2'
|
||||
main: com.ollamachat.Ollamachat
|
||||
api-version: '1.21'
|
||||
authors: [xwwsdd]
|
||||
@ -9,13 +9,11 @@ website: https://chat.sarskin.cn/invite/iHgI6LTX
|
||||
commands:
|
||||
ollamachat:
|
||||
description: Manage OllamaChat plugin (reload configuration or toggle AI)
|
||||
usage: |
|
||||
/ollamachat reload - Reload the plugin configuration
|
||||
/ollamachat toggle <ai-name> - Enable or disable an AI service
|
||||
usage: "{usage-ollamachat}"
|
||||
permission: ollamachat.admin
|
||||
aichat:
|
||||
description: Interact with other AI services
|
||||
usage: /aichat <ai-name> <prompt>
|
||||
usage: "{usage-aichat}"
|
||||
permission: ollamachat.use
|
||||
|
||||
permissions:
|
||||
|
Loading…
Reference in New Issue
Block a user