Update 5.14

This commit is contained in:
sky 2020-01-14 00:54:32 +08:00
parent e7b6828c9c
commit c02973fe1b
9 changed files with 2840 additions and 996 deletions

View File

@ -6,7 +6,7 @@ plugins {
}
group = 'me.skymc'
version = '5.13'
version = '5.14'
sourceCompatibility = 1.8
targetCompatibility = 1.8

View File

@ -13,26 +13,26 @@ MISC:
FIELD-COPY-ERROR: 'Error when copy {0}{1}'
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个插件使用, 无法注销!'
CREATE-SUCCESS: '&7Plugin &f{0} &7registered connection: &f{1}'
CREATE-EXISTS: '&7Plugin &f{0} &7reference the connection registered by plugin: &f{1}'
CLOSE-SUCCESS: '&7Plugin &f{0} &7deregistered connection &f{1}'
CLOSE-FAIL: '&7Plugin &f{0} &7Try to deregister connection used by &f{1} &7plugins.'
COMMANDS:
GLOBAL:
ONLY-PLAYER: '&8[&3&lTabooLib&8] &4This is only for player.'
ONLY-STORAGE-SQL: '&8[&3&lTabooLib&8] &4只有启用数据库储存时才能这么做'
ONLY-STORAGE-SQL: '&8[&3&lTabooLib&8] &4Can only be done when SQL-Mode is enabled.'
INTERNAL:
TYPE-ERROR: '&8[&3&lTabooLib&8] &7Command &f{0} &7can only be executed by &f{1} &7.'
TYPE-PLAYER: 'Player'
TYPE-CONSOLE: 'Console'
ERROR-USAGE:
- '&8[&3&lTabooLib&8] &7Command &f{0} &7'
- '&8[&3&lTabooLib&8] &7正确用法:'
- '&8[&3&lTabooLib&8] &7Usage:'
- '&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] &7Command &f{0} &7not found'
- '&8[&3&lTabooLib&8] &7Maybe:'
- '&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}'
@ -40,8 +40,8 @@ COMMANDS:
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参数不足'
UNKNOWN: '&8[&3&lTabooLib&8] &4Invalid command.'
INSUFFICIENT: '&8[&3&lTabooLib&8] &4Invalid arguments.'
COMMUNICATION:
FAILED-LOAD-SETTINGS: '§8[§3§lTabooLibClient§8] &4配置载入失败: {0}'

View File

@ -1,5 +1,6 @@
package io.izzel.taboolib.module.config;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.izzel.taboolib.TabooLib;
import io.izzel.taboolib.TabooLibAPI;
@ -16,7 +17,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* @Author sky
@ -26,7 +26,7 @@ public class TConfig extends YamlConfiguration {
private static Map<String, List<File>> files = Maps.newHashMap();
private File file;
private Runnable runnable;
private List<Runnable> runnable = Lists.newArrayList();
private TConfig(File file, Plugin plugin) {
files.computeIfAbsent(plugin.getName(), name -> new ArrayList<>()).add(file);
@ -100,19 +100,25 @@ public class TConfig extends YamlConfiguration {
}
public Runnable getListener() {
return runnable.get(0);
}
public List<Runnable> getListeners() {
return runnable;
}
public TConfig listener(Runnable runnable) {
this.runnable = runnable;
this.runnable.add(runnable);
return this;
}
public void runListener() {
try {
Optional.ofNullable(runnable).ifPresent(Runnable::run);
} catch (Exception e) {
e.printStackTrace();
for (Runnable listener : runnable) {
try {
listener.run();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}

View File

@ -27,6 +27,8 @@ public @interface TInject {
String reload() default "";
String locale() default "";
State state() default State.NONE;
enum State {

View File

@ -1,14 +1,17 @@
package io.izzel.taboolib.module.inject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.izzel.taboolib.TabooLibAPI;
import io.izzel.taboolib.TabooLibLoader;
import io.izzel.taboolib.module.command.lite.CommandBuilder;
import io.izzel.taboolib.module.config.TConfig;
import io.izzel.taboolib.module.locale.TLocaleLoader;
import io.izzel.taboolib.module.locale.logger.TLogger;
import io.izzel.taboolib.module.packet.TPacketHandler;
import io.izzel.taboolib.module.packet.TPacketListener;
import io.izzel.taboolib.util.Ref;
import io.izzel.taboolib.util.Strings;
import io.izzel.taboolib.util.lite.cooldown.Cooldown;
import io.izzel.taboolib.util.lite.cooldown.Cooldowns;
import org.bukkit.Bukkit;
@ -16,6 +19,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
/**
@ -56,7 +60,22 @@ public class TInjectLoader implements TabooLibLoader.Loader {
try {
TConfig config = TConfig.create(plugin, args.value().length == 0 ? "config.yml" : args.value()[0]);
field.set(instance, config);
if (!args.reload().isEmpty()) {
if (Strings.nonEmpty(args.locale())) {
config.listener(() -> {
List<String> localePriority = Lists.newArrayList();
if (config.isList(args.locale())) {
localePriority.addAll(config.getStringList(args.locale()));
} else {
localePriority.add(String.valueOf(config.get(args.locale())));
}
if (TLocaleLoader.getLocalePriority(plugin).equals(localePriority)) {
return;
}
TLocaleLoader.setLocalePriority(plugin, localePriority);
TLocaleLoader.load(plugin, true, true);
});
}
if (Strings.nonEmpty(args.reload())) {
try {
Ref.getDeclaredMethods(pluginClass).forEach(method -> {
if (method.getName().equals(args.reload())) {
@ -68,13 +87,13 @@ public class TInjectLoader implements TabooLibLoader.Loader {
t.printStackTrace();
}
});
TabooLibLoader.runTask(config::runListener);
}
});
} catch (Throwable t) {
t.printStackTrace();
}
}
TabooLibLoader.runTask(config::runListener);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -13,7 +13,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.plugin.Plugin;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -76,14 +75,12 @@ public class TLocaleLoader {
}
public static void load(Plugin plugin, boolean isCover) {
load(plugin, isCover, false);
}
public static void load(Plugin plugin, boolean isCover, boolean hideMessage) {
try {
if (isLoadLocale(plugin, isCover)) {
// 启用插件指定的独立语言加载顺序
File settings = new File("plugins/" + plugin.getName() + "/settings.yml");
List<String> priority = settings.exists() ? YamlConfiguration.loadConfiguration(settings).getStringList("LOCALE-PRIORITY") : plugin.getResource("settings.yml") != null ? YamlConfiguration.loadConfiguration(new BufferedReader(new InputStreamReader(plugin.getResource("settings.yml")))).getStringList("LOCALE-PRIORITY") : new ArrayList<>();
if (!priority.isEmpty()) {
setLocalePriority(plugin, priority);
}
// 获取文件
File localeFile = getLocaleFile(plugin);
if (localeFile == null) {
@ -93,10 +90,10 @@ public class TLocaleLoader {
YamlConfiguration localeConfiguration = Files.loadYaml(localeFile);
YamlConfiguration localeConfigurationAtStream = getLocaleAsPlugin(plugin, localeFile);
// 载入配置
loadPluginLocale(plugin, localeFile, localeConfiguration, localeConfigurationAtStream);
loadPluginLocale(plugin, localeFile, localeConfiguration, localeConfigurationAtStream, hideMessage);
// 注册监听
TConfigWatcher.getInst().removeListener(localeFile);
TConfigWatcher.getInst().addListener(localeFile, null, obj -> loadPluginLocale(plugin, localeFile, Files.loadYaml(localeFile), getLocaleAsPlugin(plugin, localeFile)));
TConfigWatcher.getInst().addListener(localeFile, null, obj -> loadPluginLocale(plugin, localeFile, Files.loadYaml(localeFile), getLocaleAsPlugin(plugin, localeFile), false));
}
} catch (Exception e) {
errorLogger("ERROR-LOADING-LANG", plugin.getName(), e.toString() + "\n" + e.getStackTrace()[0].toString());
@ -159,12 +156,15 @@ public class TLocaleLoader {
return new YamlConfiguration();
}
private static void loadPluginLocale(Plugin plugin, File localeFile, YamlConfiguration localeConfiguration, YamlConfiguration localeConfigurationAtStream) {
private static void loadPluginLocale(Plugin plugin, File localeFile, YamlConfiguration localeConfiguration, YamlConfiguration localeConfigurationAtStream, boolean hideMessage) {
TLocaleInstance localeInstance = getLocaleInstance(plugin);
if (localeConfigurationAtStream != null) {
localeInstance.load(localeConfigurationAtStream);
}
localeInstance.load(localeConfiguration);
if (hideMessage) {
return;
}
if (localeInstance.getLatestUpdateNodes().get() <= 0) {
infoLogger("SUCCESS-LOADING-LANG-NORMAL", plugin.getName(), localeFile.getName().split("\\.")[0], String.valueOf(localeInstance.size()));
} else {

View File

@ -5,6 +5,7 @@ import io.izzel.taboolib.util.item.inventory.ClickEvent;
import io.izzel.taboolib.util.item.inventory.ClickType;
import io.izzel.taboolib.util.item.inventory.MenuBuilder;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@ -62,6 +63,11 @@ public abstract class MenuStored {
}
// 手动装填
else {
// todo 合并物品
if (e.castClick().getAction() == InventoryAction.COLLECT_TO_CURSOR) {
e.setCancelled(true);
return;
}
Action action;
if (e.castClick().getClick().isShiftClick() && e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize()) {
action = new ActionQuickTake();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff