Supported TabooLib 4.x & Delete internal commands
This commit is contained in:
parent
077b09f5ac
commit
0f55e50417
66
src/main/resources/__resources__/lang/zh_CN.yml
Normal file
66
src/main/resources/__resources__/lang/zh_CN.yml
Normal file
@ -0,0 +1,66 @@
|
||||
DEPENDENCY:
|
||||
DOWNLOAD-START: ' 正在下载 {0} 库文件'
|
||||
LIBRARY-LOAD-FAIL: ' {0} 请求的库文件 {1} 加载失败'
|
||||
|
||||
LOCALE:
|
||||
TITLE-SEND-TO-NON-PLAYER: '该语言类型只能发送给玩家:{0}'
|
||||
PLUGIN-NOT-FOUND: '无效的语言文件发送形式: &4{0}'
|
||||
BOOK-ARGUMENTS-IDENTIFICATION-FAILED: 'TlocaleBook 的变量识别失败: {0}'
|
||||
BAR-COLOR-IDENTIFICATION-FAILED: 'TLocaleBossBar 的颜色识别失败: {0}'
|
||||
BAR-STYLE-IDENTIFICATION-FAILED: 'TLocaleBossBar 的类型识别失败: {0}'
|
||||
BAR-PLUGIN-NOT-FOUND: 'TLocaleBossBar 的依赖插件 BossBarAPI 不存在'
|
||||
CALLER-PLUGIN-NOT-FOUND: '{0} 不是一个由插件加载的类'
|
||||
STATIC-CLASS-LOADER: '{0} 由静态类加载器初始化,无法获得其从属的插件'
|
||||
|
||||
MISC:
|
||||
FIELD-COPY-FAILED: '拷贝 {0} 对象失败'
|
||||
FIELD-COPY-ERROR: '拷贝 {0} 对象出错:{1}'
|
||||
|
||||
ITEM-UTILS:
|
||||
FAIL-LOAD-ATTRIBUTE: '&c{0} &4不是一个有效的属性名称, 输入 &c/tlib attributes&4 查看所有属性'
|
||||
FAIL-LOAD-ENCHANT: '&c{0} &4不是一个有效的附魔名称, 输入 &c/tlib enchants&4 查看所有附魔'
|
||||
FAIL-LOAD-POTION: '&c{0} &4不是一个有效的药水名称, 输入 &c/tlib potions&4 查看所有药水'
|
||||
FAIL-LOAD-FLAG: '&c{0} &4不是一个有效的标签名称, 输入 &c/tlib flags&4 查看所有标签'
|
||||
FAIL-SAVE-EXISTS: '无法载入载入物品 &4{0}&c, 因为它已经存在了'
|
||||
|
||||
MYSQL-HIKARI:
|
||||
CREATE-SUCCESS: '&7插件 &f{0}&7 注册新的数据库连接: &f{1}'
|
||||
CREATE-EXISTS: '&7插件 &f{0}&7 引用插件 &f{1}&7 注册的数据库连接'
|
||||
CLOSE-SUCCESS: '&7插件 &f{0} &7注册的数据库连接 &f{1} &7已被注销!'
|
||||
CLOSE-FAIL: '&7插件 &f{0} &7注册的数据库连接正在被 &f{1} &7个插件使用, 无法注销!'
|
||||
|
||||
COMMANDS:
|
||||
GLOBAL:
|
||||
ONLY-PLAYER: '&8[&3&lTabooLib&8] &4控制台无法这么做'
|
||||
ONLY-STORAGE-SQL: '&8[&3&lTabooLib&8] &4只有启用数据库储存时才能这么做'
|
||||
INTERNAL:
|
||||
TYPE-ERROR: '&8[&3&lTabooLib&8] &7指令 &f{0} &7只能由 &f{1} &7执行'
|
||||
TYPE-PLAYER: '玩家'
|
||||
TYPE-CONSOLE: '控制台'
|
||||
ERROR-USAGE:
|
||||
- '&8[&3&lTabooLib&8] &7指令 &f{0} &7参数不足'
|
||||
- '&8[&3&lTabooLib&8] &7正确用法:'
|
||||
- '&8[&3&lTabooLib&8] &7{1}'
|
||||
ERROR-COMMAND:
|
||||
- '&8[&3&lTabooLib&8] &7指令 &f{0} &7不存在'
|
||||
- '&8[&3&lTabooLib&8] &7你可能想要:'
|
||||
- '&8[&3&lTabooLib&8] &7{1}'
|
||||
COMMAND-CREATE-FAILED: '&c插件 &7{0} &c的 &7{1} &c命令注册失败: &7{2}'
|
||||
COMMAND-HELP: ' §f/{0} {1} {2}§6- §e{3}'
|
||||
COMMAND-HELP-EMPTY: ' §f/{0} {1} {2}'
|
||||
COMMAND-ARGUMENT: '§7<§8{0}§7>'
|
||||
COMMAND-ARGUMENT-REQUIRE: '§7[§8{0}§7]'
|
||||
PARAMETER:
|
||||
UNKNOWN: '&8[&3&lTabooLib&8] &4指令错误'
|
||||
INSUFFICIENT: '&8[&3&lTabooLib&8] &4参数不足'
|
||||
|
||||
COMMUNICATION:
|
||||
FAILED-LOAD-SETTINGS: '§8[§3§lTabooLibClient§8] &4配置载入失败: {0}'
|
||||
FAILED-CONNECT-SERVER: '§8[§3§lTabooLibClient§8] &4本地通讯网络连接失败.'
|
||||
FAILED-CONNECT-CLIENT: '§8[§3§lTabooLibClient§8] &4本地通讯网络连接出错: {0}'
|
||||
FAILED-READING-PACKET: '§8[§3§lTabooLibClient§8] &4本地通讯网络数据包读取失败: {0}'
|
||||
SUCCESS-CONNECTED: '§8[§3§lTabooLibClient§8] &7本地通讯网络连接成功.'
|
||||
CLIENT-JOINED: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7加入本地通讯网络.'
|
||||
CLIENT-QUITED: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7退出本地通讯网络.'
|
||||
PACKET-MESSAGE: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7发送信息: &f{1}'
|
||||
PACKET-COMMAND: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7运行命令: &f{1}'
|
@ -1,181 +0,0 @@
|
||||
DEPENDENCY:
|
||||
DOWNLOAD-START: ' 正在下载 {0} 库文件'
|
||||
LIBRARY-LOAD-FAIL: ' {0} 请求的库文件 {1} 加载失败'
|
||||
|
||||
LOCALE:
|
||||
TITLE-SEND-TO-NON-PLAYER: '该语言类型只能发送给玩家:{0}'
|
||||
PLUGIN-NOT-FOUND: '无效的语言文件发送形式: &4{0}'
|
||||
BOOK-ARGUMENTS-IDENTIFICATION-FAILED: 'TlocaleBook 的变量识别失败: {0}'
|
||||
BAR-COLOR-IDENTIFICATION-FAILED: 'TLocaleBossBar 的颜色识别失败: {0}'
|
||||
BAR-STYLE-IDENTIFICATION-FAILED: 'TLocaleBossBar 的类型识别失败: {0}'
|
||||
BAR-PLUGIN-NOT-FOUND: 'TLocaleBossBar 的依赖插件 BossBarAPI 不存在'
|
||||
CALLER-PLUGIN-NOT-FOUND: '{0} 不是一个由插件加载的类'
|
||||
STATIC-CLASS-LOADER: '{0} 由静态类加载器初始化,无法获得其从属的插件'
|
||||
|
||||
MISC:
|
||||
FIELD-COPY-FAILED: '拷贝 {0} 对象失败'
|
||||
FIELD-COPY-ERROR: '拷贝 {0} 对象出错:{1}'
|
||||
|
||||
PLAYER-DATAMANAGER:
|
||||
ERROR-PLAYER-DATA: '&4玩家 &c{0} &4的数据载入出现异常: &c{1}'
|
||||
SUCCESS-SAVE-DATA: '&7保存 &f{0} &7条玩家数据, 耗时: &f{1} &7(ms)'
|
||||
|
||||
DATA-UTILS:
|
||||
SUCCESS-SAVE-DATA: '&7保存 &f{0} &7条插件数据, 耗时: &f{1} &7(ms)'
|
||||
FAIL-SAVE-FILE: '&4文件 &c{0}&4 保存失败, 原因: &c{1}'
|
||||
|
||||
ITEM-UTILS:
|
||||
FAIL-LOAD-ITEMS: '物品库载入失败: &4{0}'
|
||||
FAIL-LOAD-ATTRIBUTE: '&c{0} &4不是一个有效的属性名称, 输入 &c/tlib attributes&4 查看所有属性'
|
||||
FAIL-LOAD-ENCHANT: '&c{0} &4不是一个有效的附魔名称, 输入 &c/tlib enchants&4 查看所有附魔'
|
||||
FAIL-LOAD-POTION: '&c{0} &4不是一个有效的药水名称, 输入 &c/tlib potions&4 查看所有药水'
|
||||
FAIL-LOAD-FLAG: '&c{0} &4不是一个有效的标签名称, 输入 &c/tlib flags&4 查看所有标签'
|
||||
FAIL-SAVE-EXISTS: '无法载入载入物品 &4{0}&c, 因为它已经存在了'
|
||||
EMPTY-ITEM: '空'
|
||||
|
||||
MYSQL-HIKARI:
|
||||
CREATE-SUCCESS: '&7插件 &f{0}&7 注册新的数据库连接: &f{1}'
|
||||
CREATE-EXISTS: '&7插件 &f{0}&7 引用插件 &f{1}&7 注册的数据库连接'
|
||||
CLOSE-SUCCESS: '&7插件 &f{0} &7注册的数据库连接 &f{1} &7已被注销!'
|
||||
CLOSE-FAIL: '&7插件 &f{0} &7注册的数据库连接正在被 &f{1} &7个插件使用, 无法注销!'
|
||||
|
||||
COMMANDS:
|
||||
GLOBAL:
|
||||
ONLY-PLAYER: '&8[&3&lTabooLib&8] &4控制台无法这么做'
|
||||
ONLY-STORAGE-SQL: '&8[&3&lTabooLib&8] &4只有启用数据库储存时才能这么做'
|
||||
INTERNAL:
|
||||
TYPE-ERROR: '&8[&3&lTabooLib&8] &7指令 &f{0} &7只能由 &f{1} &7执行'
|
||||
TYPE-PLAYER: '玩家'
|
||||
TYPE-CONSOLE: '控制台'
|
||||
ERROR-USAGE:
|
||||
- '&8[&3&lTabooLib&8] &7指令 &f{0} &7参数不足'
|
||||
- '&8[&3&lTabooLib&8] &7正确用法:'
|
||||
- '&8[&3&lTabooLib&8] &7{1}'
|
||||
ERROR-COMMAND:
|
||||
- '&8[&3&lTabooLib&8] &7指令 &f{0} &7不存在'
|
||||
- '&8[&3&lTabooLib&8] &7你可能想要:'
|
||||
- '&8[&3&lTabooLib&8] &7{1}'
|
||||
COMMAND-CREATE-FAILED: '&c插件 &7{0} &c的 &7{1} &c命令注册失败: &7{2}'
|
||||
COMMAND-HELP: ' §f/{0} {1} {2}§6- §e{3}'
|
||||
COMMAND-HELP-EMPTY: ' §f/{0} {1} {2}'
|
||||
COMMAND-ARGUMENT: '§7<§8{0}§7>'
|
||||
COMMAND-ARGUMENT-REQUIRE: '§7[§8{0}§7]'
|
||||
PARAMETER:
|
||||
UNKNOWN: '&8[&3&lTabooLib&8] &4指令错误'
|
||||
INSUFFICIENT: '&8[&3&lTabooLib&8] &4参数不足'
|
||||
TLOCALE:
|
||||
COMMAND-TITLE: '&e&l----- &6&lTabooLibLoacle Commands &e&l-----'
|
||||
SEND:
|
||||
DESCRIPTION: '发送语言提示'
|
||||
ARGUMENTS:
|
||||
0: '目标'
|
||||
1: '地址'
|
||||
2: '变量'
|
||||
INVALID-PLAYER: '&8[&3&lTabooLib&8] &4玩家 &c{0} &4不在线'
|
||||
INVALID-PLUGIN: '&8[&3&lTabooLib&8] &4插件 &c{0} &4不存在或没有使用 Tlocale 语言文件.'
|
||||
INVALID-PATH: '&8[&3&lTabooLib&8] &4错误的语言文件地址:&c {0}'
|
||||
SUCCESS-RELOAD: '&8[&3&lTabooLib&8] &7重载完成'
|
||||
SUCCESS-SEND: '&8[&3&lTabooLib&8] &7信息已发送, 耗时&f: {0}'
|
||||
TPLUGIN:
|
||||
COMMAND-TITLE: '&e&l----- &6&lTabooLibPlugin Commands &e&l-----'
|
||||
LIST:
|
||||
DESCRIPTION: '列出插件'
|
||||
LIST-PLUGIN:
|
||||
- '&8[&3&lTabooLib&8] &7插件总数: &f{0}'
|
||||
- '&8[&3&lTabooLib&8] &7插件列表: &f{1}'
|
||||
INFO:
|
||||
DESCRIPTION: '查询插件'
|
||||
ARGUMENTS:
|
||||
0: '名称'
|
||||
INVALID-PLUGIN: '&8[&3&lTabooLib&8] &4插件 &c{0} &4不存在'
|
||||
INVALID-DESCRIPTION: '&8[&3&lTabooLib&8] &4获取插件 &c{0} &4信息失败: &c{1}'
|
||||
INFO-PLUGIN:
|
||||
- '&8[&3&lTabooLib&8] &7插件名称: &f{0}'
|
||||
- '&8[&3&lTabooLib&8] &7描述: &f{1}'
|
||||
- '&8[&3&lTabooLib&8] &7作者: &f{2}'
|
||||
- '&8[&3&lTabooLib&8] &7依赖: &f{3}'
|
||||
- '&8[&3&lTabooLib&8] &7兼容: &f{4}'
|
||||
- '&8[&3&lTabooLib&8] &7主类: &f{5}'
|
||||
- '&8[&3&lTabooLib&8] &7版本: &f{6}'
|
||||
- '&8[&3&lTabooLib&8] &7网站: &f{7}'
|
||||
- '&8[&3&lTabooLib&8] &7命令: &f{8}'
|
||||
LOAD:
|
||||
DESCRIPTION: '载入插件'
|
||||
ARGUMENTS:
|
||||
0: '名称'
|
||||
INVALID-DESCRIPTION: '&8[&3&lTabooLib&8] &4插件目录不存在'
|
||||
INVALID-PLUGIN: '&8[&3&lTabooLib&8] &4插件 &c{0} &4载入失败: &c{1}'
|
||||
FILE-NOT-FOUND: '&8[&3&lTabooLib&8] &4插件 &c{0} &4文件不存在'
|
||||
LOAD-SUCCESS: '&8[&3&lTabooLib&8] &7插件已载入'
|
||||
UNLOAD:
|
||||
DESCRIPTION: '卸载插件'
|
||||
ARGUMENTS:
|
||||
0: '名称'
|
||||
INVALID-PLUGIN: '&8[&3&lTabooLib&8] &4插件 &c{0} &4不存在'
|
||||
INVALID-PLUGIN-IGNORED: '&8[&3&lTabooLib&8] &4插件 &c{0} &4无法操作'
|
||||
UNLOAD-SUCCESS: '&8[&3&lTabooLib&8] &7插件已卸载'
|
||||
UNLOAD-FAIL: '&8[&3&lTabooLib&8] &4插件 &c{0} &e卸载失败: &c{1}'
|
||||
RELOAD:
|
||||
DESCRIPTION: '重载插件'
|
||||
ARGUMENTS:
|
||||
0: '名称'
|
||||
INVALID-PLUGIN: '&8[&3&lTabooLib&8] &4插件 &c{0} &4不存在'
|
||||
INVALID-PLUGIN-IGNORED: '&8[&3&lTabooLib&8] &4插件 &c{0} &4无法操作'
|
||||
TRY-RELOAD: '&8[&3&lTabooLib&8] &7尝试重载插件...'
|
||||
TEXECUTE:
|
||||
COMMAND-TITLE: '&e&l----- &6&lTabooLibExecute Commands &e&l-----'
|
||||
CHAT:
|
||||
DESCRIPTION: '使玩家输入聊天内容'
|
||||
ARGUMENTS:
|
||||
0: '玩家'
|
||||
1: '内容'
|
||||
INVALID-PLAYER-OFFLINE: '&8[&3&lTabooLib&8] &4玩家 &c{0} &4不在线.'
|
||||
COMMAND:
|
||||
DESCRIPTION: '使目标执行指令'
|
||||
ARGUMENTS:
|
||||
0: '目标'
|
||||
1: '内容'
|
||||
INVALID-TARGET-NOT-FOUND: '&8[&3&lTabooLib&8] &4目标 &c{0} &4不存在.'
|
||||
COMMAND-AS-OP:
|
||||
DESCRIPTION: '使目标以管理员身份执行指令'
|
||||
ARGUMENTS:
|
||||
0: '目标'
|
||||
1: '内容'
|
||||
INVALID-TARGET-NOT-FOUND: '&8[&3&lTabooLib&8] &4目标 &c{0} &4不存在.'
|
||||
TLOGS:
|
||||
COMMAND-TITLE: '&e&l----- &6&lTabooLibLogs Commands &e&l-----'
|
||||
INFO:
|
||||
DESCRIPTION: '写入一般记录'
|
||||
ARGUMENTS:
|
||||
0: '目录'
|
||||
1: '内容'
|
||||
SUCCESS: '&8[&3&lTabooLib&8] &7写入完成.'
|
||||
ERROR:
|
||||
DESCRIPTION: '写入错误记录'
|
||||
ARGUMENTS:
|
||||
0: '目录'
|
||||
1: '内容'
|
||||
SUCCESS: '&8[&3&lTabooLib&8] &7写入完成.'
|
||||
WARNING:
|
||||
DESCRIPTION: '写入警告记录'
|
||||
ARGUMENTS:
|
||||
0: '目录'
|
||||
1: '内容'
|
||||
SUCCESS: '&8[&3&lTabooLib&8] &7写入完成.'
|
||||
|
||||
COMMUNICATION:
|
||||
FAILED-LOAD-SETTINGS: '§8[§3§lTabooLibClient§8] &4配置载入失败: {0}'
|
||||
FAILED-CONNECT-SERVER: '§8[§3§lTabooLibClient§8] &4本地通讯网络连接失败.'
|
||||
FAILED-CONNECT-CLIENT: '§8[§3§lTabooLibClient§8] &4本地通讯网络连接出错: {0}'
|
||||
FAILED-READING-PACKET: '§8[§3§lTabooLibClient§8] &4本地通讯网络数据包读取失败: {0}'
|
||||
SUCCESS-CONNECTED: '§8[§3§lTabooLibClient§8] &7本地通讯网络连接成功.'
|
||||
CLIENT-JOINED: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7加入本地通讯网络.'
|
||||
CLIENT-QUITED: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7退出本地通讯网络.'
|
||||
PACKET-MESSAGE: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7发送信息: &f{1}'
|
||||
PACKET-COMMAND: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7运行命令: &f{1}'
|
||||
|
||||
UTIL:
|
||||
DOWNLOAD-CONNECTED: '开始下载文件 {0} 大小 {1}'
|
||||
DOWNLOAD-PROGRESS: ' 下载速度 {0} 进度 {1}'
|
||||
DOWNLOAD-SUCCESS: '下载 {0} 完成!'
|
||||
DOWNLOAD-FAILED: '下载 {0} 失败!'
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -47,13 +47,13 @@ public class TabooLib {
|
||||
config = TConfig.create(getPlugin(), "settings.yml");
|
||||
// 加载版本号
|
||||
try {
|
||||
version = NumberConversions.toDouble(IO.readFully(Files.getResource("version"), Charset.forName("utf-8")));
|
||||
version = NumberConversions.toDouble(IO.readFully(Files.getResource("__resources__/version"), Charset.forName("utf-8")));
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
// 加载内部语言文件
|
||||
try {
|
||||
internal.loadFromString(IO.readFully(Files.getResource("lang/internal.yml"), Charset.forName("utf-8")));
|
||||
internal.loadFromString(IO.readFully(Files.getResource("__resources__/lang/internal.yml"), Charset.forName("utf-8")));
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class TabooLibSettings {
|
||||
|
||||
public static InputStream getSettingsInputStream() {
|
||||
try {
|
||||
URL url = TabooLibServer.class.getClassLoader().getResource("settings.properties");
|
||||
URL url = TabooLibServer.class.getClassLoader().getResource("__resources__/settings.properties");
|
||||
if (url == null) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -1,149 +0,0 @@
|
||||
package io.izzel.taboolib.common.command;
|
||||
|
||||
import io.izzel.taboolib.TabooLibAPI;
|
||||
import io.izzel.taboolib.module.locale.TLocale;
|
||||
import io.izzel.taboolib.module.command.base.BaseMainCommand;
|
||||
import io.izzel.taboolib.module.command.base.BaseSubCommand;
|
||||
import io.izzel.taboolib.module.command.base.BaseCommand;
|
||||
import io.izzel.taboolib.module.command.base.Argument;
|
||||
import io.izzel.taboolib.module.command.base.SubCommand;
|
||||
import io.izzel.taboolib.util.ArrayUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
* @Since 2018-07-04 21:32
|
||||
*/
|
||||
@BaseCommand(
|
||||
name = "tExecute",
|
||||
permission = "taboolib.admin"
|
||||
)
|
||||
public class TabooLibExecuteCommand extends BaseMainCommand {
|
||||
|
||||
@Override
|
||||
public String getCommandTitle() {
|
||||
return TLocale.asString("COMMANDS.TEXECUTE.COMMAND-TITLE");
|
||||
}
|
||||
|
||||
@SubCommand(priority = 1)
|
||||
BaseSubCommand chat = new BaseSubCommand() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "chat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TEXECUTE.CHAT.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {
|
||||
new Argument(TLocale.asString("COMMANDS.TEXECUTE.CHAT.ARGUMENTS.0")),
|
||||
new Argument(TLocale.asString("COMMANDS.TEXECUTE.CHAT.ARGUMENTS.1"))
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = Bukkit.getPlayerExact(args[0]);
|
||||
if (player == null) {
|
||||
TLocale.sendTo(sender, "INVALID-PLAYER-OFFLINE", args[0]);
|
||||
return;
|
||||
}
|
||||
player.chat(ArrayUtil.arrayJoin(args, 1));
|
||||
}
|
||||
};
|
||||
|
||||
@SubCommand(priority = 1)
|
||||
BaseSubCommand command = new BaseSubCommand() {
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "command";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[] {"cmd"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TEXECUTE.COMMAND.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {
|
||||
new Argument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND.ARGUMENTS.0")),
|
||||
new Argument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND.ARGUMENTS.1"))
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args[0].equalsIgnoreCase("console")) {
|
||||
TabooLibAPI.dispatchCommand(Bukkit.getConsoleSender(), ArrayUtil.arrayJoin(args, 1));
|
||||
return;
|
||||
}
|
||||
Player player = Bukkit.getPlayerExact(args[0]);
|
||||
if (player == null) {
|
||||
TLocale.sendTo(sender, "INVALID-TARGET-NOT-FOUND", args[0]);
|
||||
return;
|
||||
}
|
||||
TabooLibAPI.dispatchCommand(player, ArrayUtil.arrayJoin(args, 1));
|
||||
}
|
||||
};
|
||||
|
||||
@SubCommand(priority = 2)
|
||||
BaseSubCommand commandAsOp = new BaseSubCommand() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "commandAsOp";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[] {"op"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TEXECUTE.COMMAND-AS-OP.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {
|
||||
new Argument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND-AS-OP.ARGUMENTS.0")),
|
||||
new Argument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND-AS-OP.ARGUMENTS.1"))
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args[0].equalsIgnoreCase("console")) {
|
||||
TabooLibAPI.dispatchCommand(Bukkit.getConsoleSender(), ArrayUtil.arrayJoin(args, 1));
|
||||
return;
|
||||
}
|
||||
Player player = Bukkit.getPlayerExact(args[0]);
|
||||
if (player == null) {
|
||||
TLocale.sendTo(sender, "INVALID-TARGET-NOT-FOUND", args[0]);
|
||||
return;
|
||||
}
|
||||
boolean isOp = player.isOp();
|
||||
player.setOp(true);
|
||||
try {
|
||||
TabooLibAPI.dispatchCommand(player, ArrayUtil.arrayJoin(args, 1));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
player.setOp(isOp);
|
||||
}
|
||||
};
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package io.izzel.taboolib.common.command;
|
||||
|
||||
import io.izzel.taboolib.module.locale.TLocale;
|
||||
import io.izzel.taboolib.module.locale.TLocaleLoader;
|
||||
import io.izzel.taboolib.module.command.base.BaseMainCommand;
|
||||
import io.izzel.taboolib.module.command.base.BaseSubCommand;
|
||||
import io.izzel.taboolib.module.command.base.BaseCommand;
|
||||
import io.izzel.taboolib.module.command.base.Argument;
|
||||
import io.izzel.taboolib.module.command.base.SubCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018-04-22 14:36:28
|
||||
*/
|
||||
@BaseCommand(
|
||||
name = "tLocale",
|
||||
permission = "taboolib.admin"
|
||||
)
|
||||
public class TabooLibLocaleCommand extends BaseMainCommand {
|
||||
|
||||
@Override
|
||||
public String getCommandTitle() {
|
||||
return TLocale.asString("COMMANDS.TLOCALE.COMMAND-TITLE");
|
||||
}
|
||||
|
||||
@SubCommand
|
||||
BaseSubCommand send = new BaseSubCommand() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "send";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TLOCALE.SEND.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {
|
||||
new Argument(TLocale.asString("COMMANDS.TLOCALE.SEND.ARGUMENTS.0")),
|
||||
new Argument(TLocale.asString("COMMANDS.TLOCALE.SEND.ARGUMENTS.1")),
|
||||
new Argument(TLocale.asString("COMMANDS.TLOCALE.SEND.ARGUMENTS.2"), false)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
List<CommandSender> target = new ArrayList<>();
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
target.add(Bukkit.getConsoleSender());
|
||||
target.addAll(Bukkit.getOnlinePlayers());
|
||||
} else if (args[0].equalsIgnoreCase("players")) {
|
||||
target.addAll(Bukkit.getOnlinePlayers());
|
||||
} else if (args[0].equalsIgnoreCase("console")) {
|
||||
target.add(Bukkit.getConsoleSender());
|
||||
} else {
|
||||
Player player = Bukkit.getPlayerExact(args[0]);
|
||||
if (player == null) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TLOCALE.SEND.INVALID-PLAYER", args[0]);
|
||||
return;
|
||||
}
|
||||
target.add(player);
|
||||
}
|
||||
|
||||
String[] arguments;
|
||||
if (args.length > 2) {
|
||||
arguments = new String[args.length - 2];
|
||||
IntStream.range(2, args.length).forEach(i -> arguments[i - 2] = args[i]);
|
||||
} else {
|
||||
arguments = new String[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* 使用命令发送其他插件文本
|
||||
* /tlocale send BlackSKY testPlugin:message
|
||||
*/
|
||||
if (args[1].contains(":")) {
|
||||
String[] path = args[1].split(":");
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(path[0]);
|
||||
if (plugin == null || !TLocaleLoader.isLocaleLoaded(plugin)) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TLOCALE.SEND.INVALID-PLUGIN", path[0]);
|
||||
return;
|
||||
}
|
||||
if (path.length == 1) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TLOCALE.SEND.INVALID-PATH", args[1]);
|
||||
return;
|
||||
}
|
||||
target.forEach(x -> TLocaleLoader.sendTo(plugin, path[1], x, arguments));
|
||||
} else {
|
||||
target.forEach(x -> TLocale.sendTo(x, args[1], arguments));
|
||||
}
|
||||
|
||||
if (sender instanceof Player && ((Player) sender).getItemInHand().getType().name().contains("COMMAND")) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TLOCALE.SEND.SUCCESS-SEND", String.valueOf(System.currentTimeMillis() - time));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
@ -1,248 +0,0 @@
|
||||
package io.izzel.taboolib.common.command;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import io.izzel.taboolib.TabooLibAPI;
|
||||
import io.izzel.taboolib.module.locale.TLocale;
|
||||
import io.izzel.taboolib.module.command.base.BaseCommand;
|
||||
import io.izzel.taboolib.module.command.base.BaseMainCommand;
|
||||
import io.izzel.taboolib.module.command.base.BaseSubCommand;
|
||||
import io.izzel.taboolib.module.command.base.Argument;
|
||||
import io.izzel.taboolib.module.command.base.SubCommand;
|
||||
import io.izzel.taboolib.util.plugin.PluginLoadState;
|
||||
import io.izzel.taboolib.util.plugin.PluginLoadStateType;
|
||||
import io.izzel.taboolib.util.plugin.PluginUnloadState;
|
||||
import io.izzel.taboolib.util.plugin.PluginUtils;
|
||||
import io.izzel.taboolib.util.ArrayUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
* @Since 2018-05-07 20:14
|
||||
*/
|
||||
@BaseCommand(
|
||||
name = "tPlugin",
|
||||
permission = "taboolib.admin"
|
||||
)
|
||||
public class TabooLibPluginCommand extends BaseMainCommand {
|
||||
|
||||
@Override
|
||||
public String getCommandTitle() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.COMMAND-TITLE");
|
||||
}
|
||||
|
||||
@SubCommand(priority = 1)
|
||||
BaseSubCommand load = new BaseSubCommand() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "load";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.LOAD.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {new Argument(TLocale.asString("COMMANDS.TPLUGIN.LOAD.ARGUMENTS.0"), true)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String name = ArrayUtil.arrayJoin(args, 0);
|
||||
if (PluginUtils.getPluginByName(name) != null) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.INVALID-PLUGIN", name, name + " already loaded!");
|
||||
} else {
|
||||
PluginLoadState loadState;
|
||||
try {
|
||||
loadState = PluginUtils.load(name);
|
||||
} catch (Exception e) {
|
||||
loadState = new PluginLoadState(PluginLoadStateType.INVALID_PLUGIN, e.toString());
|
||||
}
|
||||
switch (loadState.getStateType()) {
|
||||
case INVALID_DESCRIPTION: {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.INVALID-DESCRIPTION");
|
||||
break;
|
||||
}
|
||||
case INVALID_PLUGIN: {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.INVALID-PLUGIN", name, loadState.getMessage());
|
||||
break;
|
||||
}
|
||||
case FILE_NOT_FOUND: {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.FILE-NOT-FOUND", name);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.LOAD-SUCCESS", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@SubCommand(priority = 2)
|
||||
BaseSubCommand unload = new BaseSubCommand() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "unload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.UNLOAD.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {new Argument(TLocale.asString("COMMANDS.TPLUGIN.UNLOAD.ARGUMENTS.0"), true, () -> {
|
||||
return java.util.Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList());
|
||||
})};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String name = ArrayUtil.arrayJoin(args, 0);
|
||||
Plugin plugin = PluginUtils.getPluginByName(name);
|
||||
if (plugin == null) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.INVALID-PLUGIN", name);
|
||||
} else if (PluginUtils.isIgnored(plugin)) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.INVALID-PLUGIN-IGNORED", name);
|
||||
} else {
|
||||
PluginUnloadState unloadState;
|
||||
try {
|
||||
unloadState = PluginUtils.unload(plugin);
|
||||
} catch (Exception e) {
|
||||
unloadState = new PluginUnloadState(true, e.toString());
|
||||
}
|
||||
if (unloadState.isFailed()) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.UNLOAD-FAIL", name, unloadState.getMessage());
|
||||
} else {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.UNLOAD-SUCCESS", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@SubCommand(priority = 3)
|
||||
BaseSubCommand reload = new BaseSubCommand() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.RELOAD.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {new Argument(TLocale.asString("COMMANDS.TPLUGIN.RELOAD.ARGUMENTS.0"), true, () -> {
|
||||
return Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList());
|
||||
})};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String name = ArrayUtil.arrayJoin(args, 0);
|
||||
Plugin plugin = PluginUtils.getPluginByName(name);
|
||||
if (plugin == null) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.RELOAD.INVALID-PLUGIN", name);
|
||||
} else if (PluginUtils.isIgnored(plugin)) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.RELOAD.INVALID-PLUGIN-IGNORED", name);
|
||||
} else {
|
||||
TabooLibAPI.dispatchCommand(sender, "tPlugin unload " + plugin.getName());
|
||||
TabooLibAPI.dispatchCommand(sender, "tPlugin load " + plugin.getName());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@SubCommand(priority = 4)
|
||||
BaseSubCommand info = new BaseSubCommand() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.INFO.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {new Argument(TLocale.asString("COMMANDS.TPLUGIN.INFO.ARGUMENTS.0"), true, () -> {
|
||||
return Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList());
|
||||
})};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String name = ArrayUtil.arrayJoin(args, 0);
|
||||
Plugin plugin = PluginUtils.getPluginByName(name);
|
||||
if (plugin == null) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.INFO.INVALID-PLUGIN", name);
|
||||
} else {
|
||||
try {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.INFO.INFO-PLUGIN",
|
||||
plugin.getName(),
|
||||
String.valueOf(plugin.getDescription().getDescription()),
|
||||
String.valueOf(plugin.getDescription().getAuthors()),
|
||||
String.valueOf(plugin.getDescription().getDepend()),
|
||||
String.valueOf(plugin.getDescription().getSoftDepend()),
|
||||
String.valueOf(plugin.getDescription().getMain()),
|
||||
String.valueOf(plugin.getDescription().getVersion()),
|
||||
String.valueOf(plugin.getDescription().getWebsite()),
|
||||
String.valueOf(plugin.getDescription().getCommands() == null ? "" : plugin.getDescription().getCommands().keySet()));
|
||||
} catch (Exception e) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.INFO.INVALID-DESCRIPTION", name, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@SubCommand(priority = 5)
|
||||
BaseSubCommand list = new BaseSubCommand() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.LIST.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
List<String> pluginList = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(PluginUtils::getFormattedName).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList());
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LIST.LIST-PLUGIN", String.valueOf(Bukkit.getPluginManager().getPlugins().length), Joiner.on(", ").join(pluginList));
|
||||
}
|
||||
};
|
||||
|
||||
// *********************************
|
||||
//
|
||||
// Private Methods
|
||||
//
|
||||
// *********************************
|
||||
|
||||
private boolean isPluginCommand(String label) {
|
||||
return "info".equalsIgnoreCase(label) || "load".equalsIgnoreCase(label) || "unload".equalsIgnoreCase(label) || "reload".equalsIgnoreCase(label);
|
||||
}
|
||||
}
|
@ -86,12 +86,8 @@ public class SimpleI18n {
|
||||
return lang.getString(NMS.handle().getName(item).replace(".", "_"), item.getType().name().toLowerCase().replace("_", ""));
|
||||
}
|
||||
|
||||
private static void releaseLocales(Plugin plugin) {
|
||||
TLocaleLoader.getLocalePriority().stream().filter(localeName -> !new File("plugins/TabooLib/simpleI18n/" + getVersion() + "/" + localeName + ".yml").exists() && plugin.getResource("simpleI18n/" + getVersion() + "/" + localeName + ".yml") != null).forEach(localeName -> plugin.saveResource("simpleI18n/" + getVersion() + "/" + localeName + ".yml", true));
|
||||
}
|
||||
|
||||
private static File getLocaleFile(Plugin plugin) {
|
||||
releaseLocales(plugin);
|
||||
TLocaleLoader.getLocalePriority().forEach(localeName -> Files.releaseResource(plugin, "simpleI18n/" + getVersion() + "/" + localeName + ".yml", false));
|
||||
return TLocaleLoader.getLocalePriority().stream().map(localeName -> new File("plugins/TabooLib/simpleI18n/" + getVersion() + "/" + localeName + ".yml")).filter(File::exists).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class Files {
|
||||
public static void releaseResource(Plugin plugin, String path, boolean replace) {
|
||||
File file = new File(plugin.getDataFolder(), path);
|
||||
if (!file.exists() || replace) {
|
||||
try (InputStream inputStream = getCanonicalResource(plugin, path)) {
|
||||
try (InputStream inputStream = getCanonicalResource(plugin, (plugin instanceof InternalPlugin ? "__resources__/" : "") + path)) {
|
||||
if (inputStream != null) {
|
||||
toFile(inputStream, Files.file(file));
|
||||
}
|
||||
|
@ -1,156 +0,0 @@
|
||||
package io.izzel.taboolib.util.lite;
|
||||
|
||||
import io.izzel.taboolib.TabooLib;
|
||||
import io.izzel.taboolib.module.locale.TLocale;
|
||||
import io.izzel.taboolib.module.command.base.BaseCommand;
|
||||
import io.izzel.taboolib.module.command.base.BaseMainCommand;
|
||||
import io.izzel.taboolib.module.command.base.BaseSubCommand;
|
||||
import io.izzel.taboolib.module.command.base.Argument;
|
||||
import io.izzel.taboolib.module.command.base.SubCommand;
|
||||
import io.izzel.taboolib.util.Files;
|
||||
import io.izzel.taboolib.util.Strings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
*/
|
||||
@BaseCommand(
|
||||
name = "tLogs",
|
||||
permission = "taboolib.admin"
|
||||
)
|
||||
public class Logs extends BaseMainCommand {
|
||||
|
||||
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public String getCommandTitle() {
|
||||
return TLocale.asString("COMMANDS.TLOGS.COMMAND-TITLE");
|
||||
}
|
||||
|
||||
@SubCommand(priority = 0)
|
||||
BaseSubCommand info = new BaseSubCommand() {
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TLOGS.INFO.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {
|
||||
new Argument(TLocale.asString("COMMANDS.TLOGS.INFO.ARGUMENTS.0")),
|
||||
new Argument(TLocale.asString("COMMANDS.TLOGS.INFO.ARGUMENTS.1"))
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
info(args[0], args[1]);
|
||||
if (sender instanceof Player) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TLOGS.INFO.SUCCESS");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@SubCommand(priority = 1)
|
||||
BaseSubCommand error = new BaseSubCommand() {
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "error";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TLOGS.ERROR.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {
|
||||
new Argument(TLocale.asString("COMMANDS.TLOGS.ERROR.ARGUMENTS.0")),
|
||||
new Argument(TLocale.asString("COMMANDS.TLOGS.ERROR.ARGUMENTS.1"))
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
info(args[0], args[1]);
|
||||
if (sender instanceof Player) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TLOGS.ERROR.SUCCESS");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@SubCommand(priority = 2)
|
||||
BaseSubCommand warning = new BaseSubCommand() {
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "warning";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TLOGS.WARNING.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Argument[] getArguments() {
|
||||
return new Argument[] {
|
||||
new Argument(TLocale.asString("COMMANDS.TLOGS.WARNING.ARGUMENTS.0")),
|
||||
new Argument(TLocale.asString("COMMANDS.TLOGS.WARNING.ARGUMENTS.1"))
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
info(args[0], args[1]);
|
||||
if (sender instanceof Player) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TLOGS.WARNING.SUCCESS");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void info(String filePath, String text) {
|
||||
info(new File(!filePath.contains(".") ? filePath + ".txt" : filePath), text);
|
||||
}
|
||||
|
||||
public static void info(File file, String text) {
|
||||
write(file, "[{0} INFO]: {1}\n", text);
|
||||
}
|
||||
|
||||
public static void error(String filePath, String text) {
|
||||
info(new File(!filePath.contains(".") ? filePath + ".txt" : filePath), text);
|
||||
}
|
||||
|
||||
public static void error(File file, String text) {
|
||||
write(file, "[{0} ERROR]: {1}\n", text);
|
||||
}
|
||||
|
||||
public static void warning(String filePath, String text) {
|
||||
info(new File(!filePath.contains(".") ? filePath + ".txt" : filePath), text);
|
||||
}
|
||||
|
||||
public static void warning(File file, String text) {
|
||||
write(file, "[{0} WARNING]: {1}\n", text);
|
||||
}
|
||||
|
||||
public static void write(File file, String format, String text) {
|
||||
Bukkit.getScheduler().runTask(TabooLib.getPlugin(), () -> {
|
||||
try (FileWriter writer = new FileWriter(Files.file(file), true)) {
|
||||
writer.write(Strings.replaceWithOrder(format, dateFormat.format(System.currentTimeMillis()), text));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user