好像没上传干净
This commit is contained in:
parent
8c6518ffc5
commit
674e993105
@ -1,5 +1,8 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="PROJECT_PROFILE" value="TabooLib Inspections" />
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
<info color="525229">
|
||||
<option name="EFFECT_COLOR" value="659c6b" />
|
||||
<option name="EFFECT_TYPE" value="2" />
|
||||
|
@ -12,6 +12,13 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javalite:activejdbc:2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javalite:javalite-common:2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-core-asl:1.9.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.9.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javalite:app-config:2.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.h2database:h2:1.4.197" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.ilummc.eagletdl:EagletCore:1.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.ow2.asm:asm:6.1.1" level="project" />
|
||||
<orderEntry type="module-library">
|
||||
|
@ -24,7 +24,7 @@ import java.nio.charset.Charset;
|
||||
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.ow2.asm:asm:6.1.1")
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "com.zaxxer:HikariCP:3.1.0")
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.slf4j:slf4j-api:1.7.25")
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.slf4j:slf4j-internal:1.7.25")
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.javalite:activejdbc:2.0")
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.javalite:javalite-common:2.0")
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.javalite:app-config:2.0")
|
||||
@ -74,19 +74,21 @@ public class TLib {
|
||||
TLocaleLoader.load(Main.getInst(), false);
|
||||
TDependencyInjector.inject(Main.getInst(), tLib);
|
||||
|
||||
// init database
|
||||
try {
|
||||
Pool.init();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void unload() {
|
||||
Pool.unload();
|
||||
tLib.getConfigWatcher().unregisterAll();
|
||||
TDependencyInjector.eject(Main.getInst(), tLib);
|
||||
|
||||
try {
|
||||
Pool.unload();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void injectPluginManager() {
|
||||
|
@ -2,6 +2,9 @@ package com.ilummc.tlib.config;
|
||||
|
||||
import com.ilummc.tlib.annotations.TConfig;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018-04-22 14:31:11
|
||||
@ -9,28 +12,48 @@ import com.ilummc.tlib.annotations.TConfig;
|
||||
@TConfig(name = "tlib.yml", listenChanges = true)
|
||||
public class TLibConfig {
|
||||
|
||||
@Getter
|
||||
private String dataSourceClassName;
|
||||
|
||||
@Getter
|
||||
private String jdbcUrl = "jdbc:h2:file:~/plugins/TabooLib/h2";
|
||||
|
||||
@Getter
|
||||
private String driverClassName;
|
||||
|
||||
@Getter
|
||||
private String username = "";
|
||||
|
||||
@Getter
|
||||
private String password = "";
|
||||
|
||||
@Getter
|
||||
private int maximumPoolSize = 4;
|
||||
|
||||
@Getter
|
||||
private Map<String, Object> settings = new HashMap<String, Object>() {{
|
||||
put("cachePrepStmts", true);
|
||||
put("useServerPrepStmts", true);
|
||||
}};
|
||||
|
||||
public String getDataSourceClassName() {
|
||||
return dataSourceClassName;
|
||||
}
|
||||
|
||||
public String getJdbcUrl() {
|
||||
return jdbcUrl;
|
||||
}
|
||||
|
||||
public String getDriverClassName() {
|
||||
return driverClassName;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public int getMaximumPoolSize() {
|
||||
return maximumPoolSize;
|
||||
}
|
||||
|
||||
public Map<String, Object> getSettings() {
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,10 @@ import com.ilummc.tlib.TLib;
|
||||
import me.skymc.taboolib.anvil.AnvilContainerAPI;
|
||||
import me.skymc.taboolib.bstats.Metrics;
|
||||
import me.skymc.taboolib.commands.MainCommands;
|
||||
import me.skymc.taboolib.commands.internal.InternalCommandExecutor;
|
||||
import me.skymc.taboolib.commands.language.Language2Command;
|
||||
import me.skymc.taboolib.commands.locale.TabooLibLocaleCommand;
|
||||
import me.skymc.taboolib.commands.plugin.TabooLibPluginCommand;
|
||||
import me.skymc.taboolib.commands.sub.itemlist.listener.ItemLibraryPatch;
|
||||
import me.skymc.taboolib.commands.sub.sounds.listener.SoundsLibraryPatch;
|
||||
import me.skymc.taboolib.database.GlobalDataManager;
|
||||
@ -203,6 +205,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||
getCommand("language2").setExecutor(new Language2Command());
|
||||
getCommand("taboolibrarymodule").setExecutor(new TLMCommands());
|
||||
getCommand("tabooliblocale").setExecutor(new TabooLibLocaleCommand());
|
||||
InternalCommandExecutor.createCommandExecutor("taboolibplugin", new TabooLibPluginCommand());
|
||||
|
||||
// 注册监听
|
||||
registerListener();
|
||||
|
@ -0,0 +1,28 @@
|
||||
package me.skymc.taboolib.commands.internal;
|
||||
|
||||
/**
|
||||
* @author Bkm016
|
||||
* @since 2018-04-17
|
||||
*/
|
||||
public class InternalArgument {
|
||||
|
||||
private String name;
|
||||
private boolean required;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public InternalArgument(String name, boolean required) {
|
||||
this.name = name;
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return required ? "§7[§8" + name + "§7]" : "§7<§8" + name + "§7>";
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ package me.skymc.taboolib.commands.internal;
|
||||
* @Author sky
|
||||
* @Since 2018-05-07 21:36
|
||||
*/
|
||||
public class InternalMainCommand {
|
||||
public interface InternalCommand {
|
||||
|
||||
String getCommandTitle();
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,111 @@
|
||||
package me.skymc.taboolib.commands.internal;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.string.ArrayUtils;
|
||||
import me.skymc.taboolib.string.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
* @Since 2018-05-07 21:38
|
||||
*/
|
||||
public class InternalCommandExecutor {
|
||||
public abstract class InternalCommandExecutor implements InternalCommand, CommandExecutor, TabExecutor {
|
||||
|
||||
private InternalCommandExecutor subExecutor;
|
||||
private List<InternalSubCommandExecutor> subCommandExecutors = new ArrayList<>();
|
||||
|
||||
public static InternalCommandExecutor createCommandExecutor(String command, InternalCommandExecutor internalCommandExecutor) {
|
||||
assert Bukkit.getPluginCommand(command) == null : "PluginCommand \"" + command + "\"not found";
|
||||
assert internalCommandExecutor != null : "Executor can not be null";
|
||||
assert internalCommandExecutor.getCommandTitle() != null : "Executor title can not be null";
|
||||
assert internalCommandExecutor.getClass() != InternalCommandExecutor.class : "SubExecutor can not be \"InternalCommandExecutor.class\"";
|
||||
internalCommandExecutor.setSubExecutor(internalCommandExecutor);
|
||||
Bukkit.getPluginCommand(command).setExecutor(internalCommandExecutor);
|
||||
Bukkit.getPluginCommand(command).setTabCompleter(internalCommandExecutor);
|
||||
return internalCommandExecutor;
|
||||
}
|
||||
|
||||
public void setSubExecutor(InternalCommandExecutor subExecutor) {
|
||||
this.subExecutor = subExecutor;
|
||||
}
|
||||
|
||||
public InternalCommandExecutor getSubExecutor() {
|
||||
return subExecutor;
|
||||
}
|
||||
|
||||
public List<InternalSubCommandExecutor> getSubCommandExecutors() {
|
||||
return subCommandExecutors;
|
||||
}
|
||||
|
||||
public void registerSubCommandExecutor(InternalSubCommandExecutor subCommandExecutor) {
|
||||
assert subCommandExecutor.getLabel() != null : "Command label can not be null";
|
||||
assert subCommandExecutor.getDescription() != null : "Command description can not be null";
|
||||
assert subCommandExecutor.getArguments() != null : "Command arguments can not be null";
|
||||
subCommandExecutors.add(subCommandExecutor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
helpCommand(sender, label);
|
||||
} else {
|
||||
for (InternalSubCommandExecutor subCommand : subCommandExecutors) {
|
||||
if (subCommand == null || !args[0].equalsIgnoreCase(subCommand.getLabel())) {
|
||||
continue;
|
||||
}
|
||||
if (!isConfirmType(sender, subCommand.getType())) {
|
||||
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ONLY-PLAYER", args[0], TLocale.asString("COMMANDS.INTERNAL.TYPE-" + subCommand.getType()));
|
||||
return true;
|
||||
}
|
||||
String[] subCommandArgs = ArrayUtils.removeFirst(args);
|
||||
if (subCommand.isParameterConform(subCommandArgs)) {
|
||||
subCommand.onCommand(sender, command, label, subCommandArgs);
|
||||
} else {
|
||||
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ERROR-USAGE", args[0], subCommand.getCommandString(label));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
List<InternalSubCommandExecutor> commandCompute = subCommandExecutors.stream().filter(Objects::nonNull).sorted((b, a) -> Double.compare(StringUtils.similarDegree(args[0], a.getLabel()), StringUtils.similarDegree(args[0], b.getLabel()))).collect(Collectors.toList());
|
||||
if (commandCompute.size() > 0) {
|
||||
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ERROR-COMMAND", args[0], commandCompute.get(0).getCommandString(label).trim());
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(Main.getInst());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
|
||||
return args.length == 1 ? subCommandExecutors.stream().filter(internalCommandExecutor -> internalCommandExecutor != null && (args[0].isEmpty() || internalCommandExecutor.getLabel().startsWith(args[0]))).map(InternalSubCommand::getLabel).collect(Collectors.toList()) : null;
|
||||
}
|
||||
|
||||
private String getEmptyLine() {
|
||||
return TabooLib.getVerint() < 10800 ? "~" : "";
|
||||
}
|
||||
|
||||
private void helpCommand(CommandSender sender, String label) {
|
||||
sender.sendMessage(getEmptyLine());
|
||||
sender.sendMessage(subExecutor.getCommandTitle());
|
||||
sender.sendMessage(getEmptyLine());
|
||||
subCommandExecutors.stream().map(subCommand -> subCommand == null ? getEmptyLine() : subCommand.getCommandString(label)).forEach(sender::sendMessage);
|
||||
sender.sendMessage(getEmptyLine());
|
||||
}
|
||||
|
||||
private boolean isConfirmType(CommandSender sender, InternalSubCommandType commandType) {
|
||||
return commandType == InternalSubCommandType.ALL || sender instanceof ConsoleCommandSender && commandType == InternalSubCommandType.CONSOLE;
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,13 @@ import org.bukkit.command.CommandSender;
|
||||
* @author Bkm016
|
||||
* @since 2018-04-17
|
||||
*/
|
||||
public interface InternalCommand {
|
||||
public interface InternalSubCommand {
|
||||
|
||||
String getLabel();
|
||||
|
||||
String getDescription();
|
||||
|
||||
InternalCommandArgument[] getArguments();
|
||||
InternalArgument[] getArguments();
|
||||
|
||||
void onCommand(CommandSender sender, Command command, String label, String[] args);
|
||||
|
||||
|
@ -1,20 +1,15 @@
|
||||
package me.skymc.taboolib.commands.internal;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* @author Bkm016
|
||||
* @since 2018-04-17
|
||||
*/
|
||||
public abstract class InternalCommandExecutor implements InternalCommand {
|
||||
public abstract class InternalSubCommandExecutor implements InternalSubCommand {
|
||||
|
||||
public InternalCommandType getType() {
|
||||
return InternalCommandType.ALL;
|
||||
public InternalSubCommandType getType() {
|
||||
return InternalSubCommandType.ALL;
|
||||
}
|
||||
|
||||
public boolean requiredPlayer() {
|
||||
@ -25,14 +20,6 @@ public abstract class InternalCommandExecutor implements InternalCommand {
|
||||
return IntStream.range(0, getArguments().length).noneMatch(i -> getArguments()[i].isRequired() && (args == null || args.length <= i));
|
||||
}
|
||||
|
||||
public boolean isConfirmType(CommandSender sender, InternalCommandType commandType) {
|
||||
return commandType == InternalCommandType.ALL || sender instanceof ConsoleCommandSender && commandType == InternalCommandType.CONSOLE;
|
||||
}
|
||||
|
||||
public List<String> getTabCompleter(List<InternalCommandExecutor> internalCommandExecutors, String[] args) {
|
||||
return args.length == 1 ? internalCommandExecutors.stream().filter(internalCommandExecutor -> internalCommandExecutor != null && (args[0].isEmpty() || internalCommandExecutor.getLabel().startsWith(args[0]))).map(InternalCommand::getLabel).collect(Collectors.toList()) : null;
|
||||
}
|
||||
|
||||
public String getCommandString(String label) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(" §f/");
|
||||
@ -40,7 +27,7 @@ public abstract class InternalCommandExecutor implements InternalCommand {
|
||||
stringBuilder.append(" ");
|
||||
stringBuilder.append(getLabel());
|
||||
stringBuilder.append(" ");
|
||||
for (InternalCommandArgument parameter : getArguments()) {
|
||||
for (InternalArgument parameter : getArguments()) {
|
||||
stringBuilder.append(parameter.toString());
|
||||
stringBuilder.append(" ");
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ package me.skymc.taboolib.commands.internal;
|
||||
* @author Bkm016
|
||||
* @since 2018-04-17
|
||||
*/
|
||||
public enum InternalCommandType {
|
||||
public enum InternalSubCommandType {
|
||||
|
||||
CONSOLE, PLAYER, ALL
|
||||
|
||||
|
@ -1,9 +1,215 @@
|
||||
package me.skymc.taboolib.commands.plugin;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import me.skymc.taboolib.commands.internal.InternalArgument;
|
||||
import me.skymc.taboolib.commands.internal.InternalCommandExecutor;
|
||||
import me.skymc.taboolib.commands.internal.InternalSubCommandExecutor;
|
||||
import me.skymc.taboolib.plugin.PluginUtils;
|
||||
import me.skymc.taboolib.string.ArrayUtils;
|
||||
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
|
||||
*/
|
||||
public class TabooLibPluginCommand {
|
||||
public class TabooLibPluginCommand extends InternalCommandExecutor {
|
||||
|
||||
public TabooLibPluginCommand() {
|
||||
listCommand();
|
||||
infoCommand();
|
||||
loadCommand();
|
||||
unloadCommand();
|
||||
reloadCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandTitle() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.COMMAND-TITLE");
|
||||
}
|
||||
|
||||
void loadCommand() {
|
||||
registerSubCommandExecutor(new InternalSubCommandExecutor() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "load";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.LOAD.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalArgument[] getArguments() {
|
||||
return new InternalArgument[]{new InternalArgument(TLocale.asString("COMMANDS.TPLUGIN.LOAD.ARGUMENTS.0"), true)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String name = ArrayUtils.arrayJoin(args, 0);
|
||||
if (PluginUtils.getPluginByName(name) != null) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.INVALID-PLUGIN", name);
|
||||
} else {
|
||||
switch (PluginUtils.load(name)) {
|
||||
case "loaded": {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.LOAD-SUCCESS", name);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.LOAD-FALL", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void unloadCommand() {
|
||||
registerSubCommandExecutor(new InternalSubCommandExecutor() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "unload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.UNLOAD.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalArgument[] getArguments() {
|
||||
return new InternalArgument[]{new InternalArgument(TLocale.asString("COMMANDS.TPLUGIN.UNLOAD.ARGUMENTS.0"), true)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String name = ArrayUtils.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 {
|
||||
switch (PluginUtils.unload(plugin)) {
|
||||
case "unloaded": {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.UNLOAD-SUCCESS", name);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.UNLOAD-FALL", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void reloadCommand() {
|
||||
registerSubCommandExecutor(new InternalSubCommandExecutor() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.RELOAD.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalArgument[] getArguments() {
|
||||
return new InternalArgument[]{new InternalArgument(TLocale.asString("COMMANDS.TPLUGIN.RELOAD.ARGUMENTS.0"), true)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String name = ArrayUtils.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 {
|
||||
PluginUtils.reload(plugin);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void infoCommand() {
|
||||
registerSubCommandExecutor(new InternalSubCommandExecutor() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.INFO.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalArgument[] getArguments() {
|
||||
return new InternalArgument[]{new InternalArgument(TLocale.asString("COMMANDS.TPLUGIN.INFO.ARGUMENTS.0"), true)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String name = ArrayUtils.arrayJoin(args, 0);
|
||||
Plugin plugin = PluginUtils.getPluginByName(name);
|
||||
if (plugin == null) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.INFO.INVALID-PLUGIN", name);
|
||||
} else {
|
||||
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().keySet()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void listCommand() {
|
||||
registerSubCommandExecutor(new InternalSubCommandExecutor() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TPLUGIN.LIST.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalArgument[] getArguments() {
|
||||
return new InternalArgument[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
List<String> pluginList = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).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));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -105,7 +105,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
public Method gin = NMSUtils.getMethodSilent(ni, "getName");
|
||||
public Method gin = NMSUtils.getMethodSilent(ni, "getLabel");
|
||||
|
||||
@Override
|
||||
public String getItemName(ItemStack is){
|
||||
|
@ -105,7 +105,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
public Method gin = NMSUtils.getMethodSilent(ni, "getName");
|
||||
public Method gin = NMSUtils.getMethodSilent(ni, "getLabel");
|
||||
|
||||
@Override
|
||||
public String getItemName(ItemStack is){
|
||||
|
@ -71,7 +71,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Class<?> ni = NMSUtils.getNMSClassSilent("Item");
|
||||
|
||||
public Method gn = NMSUtils.getMethodSilent(nmis, "getName");
|
||||
public Method gn = NMSUtils.getMethodSilent(nmis, "getLabel");
|
||||
|
||||
@Override
|
||||
public String getName(ItemStack is){
|
||||
@ -108,7 +108,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
public Method gin = NMSUtils.getMethodSilent(ni, "getName");
|
||||
public Method gin = NMSUtils.getMethodSilent(ni, "getLabel");
|
||||
|
||||
@Override
|
||||
public String getItemName(ItemStack is){
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.skymc.taboolib.playerdata;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.database.PlayerDataManager;
|
||||
import me.skymc.taboolib.exception.PlayerOfflineException;
|
||||
@ -49,7 +50,7 @@ public class DataUtils implements Listener {
|
||||
saveAllCaches(getFixedPlugin(plugin), remove);
|
||||
}
|
||||
if (!Main.getInst().getConfig().getBoolean("HIDE-NOTIFY")) {
|
||||
MsgUtils.send("保存 &f" + DataUtils.CACHE_DATA_PLUGIN.size() + " &7条插件数据, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
TLocale.Logger.info("DATA-UTILS.SUCCESS-SAVE-DATA", String.valueOf(DataUtils.CACHE_DATA_PLUGIN.size()), String.valueOf(System.currentTimeMillis() - time));
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +58,7 @@ public class DataUtils implements Listener {
|
||||
try {
|
||||
conf.save(file);
|
||||
} catch (IOException e) {
|
||||
MsgUtils.warn("文件 &4" + file.getName() + "&c 保存失败, 原因: &4" + e.getMessage());
|
||||
TLocale.Logger.error("DATA-UTILS.FALL-SAVE-FILE", file.getName(), e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package me.skymc.taboolib.plugin;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
@ -18,53 +23,41 @@ import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class PluginUtils {
|
||||
|
||||
public static String consolidateStrings(final String[] args, final int start) {
|
||||
StringBuilder ret = new StringBuilder(args[start]);
|
||||
if (args.length > start + 1) {
|
||||
for (int i = start + 1; i < args.length; ++i) {
|
||||
ret.append(" ").append(args[i]);
|
||||
}
|
||||
}
|
||||
return ret.toString();
|
||||
private PluginUtils() {
|
||||
}
|
||||
|
||||
public static void enable(final Plugin plugin) {
|
||||
public static void enable(Plugin plugin) {
|
||||
if (plugin != null && !plugin.isEnabled()) {
|
||||
Bukkit.getPluginManager().enablePlugin(plugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void enableAll() {
|
||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (!isIgnored(plugin)) {
|
||||
enable(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void disable(final Plugin plugin) {
|
||||
public static void disable(Plugin plugin) {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
Bukkit.getPluginManager().disablePlugin(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
public static void disableAll() {
|
||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (!isIgnored(plugin)) {
|
||||
disable(plugin);
|
||||
}
|
||||
}
|
||||
public static void enableAll() {
|
||||
Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(plugin -> isIgnored(plugin)).forEach(PluginUtils::enable);
|
||||
}
|
||||
|
||||
public static String getFormattedName(final Plugin plugin) {
|
||||
public static void disableAll() {
|
||||
Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(plugin -> isIgnored(plugin)).forEach(PluginUtils::disable);
|
||||
}
|
||||
|
||||
public static String getFormattedName(Plugin plugin) {
|
||||
return getFormattedName(plugin, false);
|
||||
}
|
||||
|
||||
public static String getFormattedName(final Plugin plugin, final boolean includeVersions) {
|
||||
final ChatColor color = plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED;
|
||||
public static String getFormattedName(Plugin plugin, boolean includeVersions) {
|
||||
ChatColor color = plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED;
|
||||
String pluginName = color + plugin.getName();
|
||||
if (includeVersions) {
|
||||
pluginName = pluginName + " (" + plugin.getDescription().getVersion() + ")";
|
||||
@ -72,76 +65,83 @@ public class PluginUtils {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
public static Plugin getPluginByName(final String[] args, final int start) {
|
||||
public static Plugin getPluginByName(String[] args, int start) {
|
||||
return getPluginByName(consolidateStrings(args, start));
|
||||
}
|
||||
|
||||
public static Plugin getPluginByName(final String name) {
|
||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (name.equalsIgnoreCase(plugin.getName())) {
|
||||
return plugin;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
public static Plugin getPluginByName(String name) {
|
||||
return Arrays.stream(Bukkit.getPluginManager().getPlugins(), 0, Bukkit.getPluginManager().getPlugins().length).filter(plugin -> name.equalsIgnoreCase(plugin.getName())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static List<String> getPluginNames(final boolean fullName) {
|
||||
final List<String> plugins = new ArrayList<>();
|
||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
plugins.add(fullName ? plugin.getDescription().getFullName() : plugin.getName());
|
||||
}
|
||||
public static List<String> getPluginNames(boolean fullName) {
|
||||
List<String> plugins;
|
||||
plugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(plugin -> fullName ? plugin.getDescription().getFullName() : plugin.getName()).collect(Collectors.toList());
|
||||
return plugins;
|
||||
}
|
||||
|
||||
public static String getPluginVersion(final String name) {
|
||||
final Plugin plugin = getPluginByName(name);
|
||||
if (plugin != null && plugin.getDescription() != null) {
|
||||
return plugin.getDescription().getVersion();
|
||||
}
|
||||
return null;
|
||||
public static String getPluginVersion(String name) {
|
||||
Plugin plugin = getPluginByName(name);
|
||||
return plugin != null && plugin.getDescription() != null ? plugin.getDescription().getVersion() : null;
|
||||
}
|
||||
|
||||
public static String getUsages(final Plugin plugin) {
|
||||
final List<String> parsedCommands = new ArrayList<>();
|
||||
final Map<String, Map<String, Object>> commands = plugin.getDescription().getCommands();
|
||||
public static String getUsages(Plugin plugin) {
|
||||
List<String> parsedCommands = new ArrayList();
|
||||
Map commands = plugin.getDescription().getCommands();
|
||||
if (commands != null) {
|
||||
for (final Entry<String, Map<String, Object>> thisEntry : commands.entrySet()) {
|
||||
for (Object o : commands.entrySet()) {
|
||||
Entry thisEntry = (Entry) o;
|
||||
if (thisEntry != null) {
|
||||
parsedCommands.add(thisEntry.getKey());
|
||||
parsedCommands.add((String) thisEntry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parsedCommands.isEmpty()) {
|
||||
return "No commands registered.";
|
||||
}
|
||||
return Joiner.on(", ").join(parsedCommands);
|
||||
return parsedCommands.isEmpty() ? "No commands registered." : Joiner.on(", ").join(parsedCommands);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<String> findByCommand(final String command) {
|
||||
final List<String> plugins = new ArrayList<>();
|
||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
final Map<String, Map<String, Object>> commands = plugin.getDescription().getCommands();
|
||||
public static List<String> findByCommand(String command) {
|
||||
List<String> plugins = new ArrayList();
|
||||
|
||||
label60:
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
Map<String, Map<String, Object>> commands = plugin.getDescription().getCommands();
|
||||
if (commands != null) {
|
||||
for (final Map.Entry<String, Map<String, Object>> commandNext : commands.entrySet()) {
|
||||
Iterator commandIterator = commands.entrySet().iterator();
|
||||
|
||||
while (true) {
|
||||
label55:
|
||||
while (true) {
|
||||
if (!commandIterator.hasNext()) {
|
||||
continue label60;
|
||||
}
|
||||
|
||||
Entry<String, Map<String, Object>> commandNext = (Entry) commandIterator.next();
|
||||
if (commandNext.getKey().equalsIgnoreCase(command)) {
|
||||
plugins.add(plugin.getName());
|
||||
} else {
|
||||
for (final Map.Entry<String, Object> attributeNext : commandNext.getValue().entrySet()) {
|
||||
if (attributeNext.getKey().equals("aliases")) {
|
||||
final Object aliases = attributeNext.getValue();
|
||||
Iterator attributeIterator = ((Map) commandNext.getValue()).entrySet().iterator();
|
||||
|
||||
while (true) while (true) {
|
||||
Entry attributeNext;
|
||||
if (!attributeIterator.hasNext()) {
|
||||
continue label55;
|
||||
}
|
||||
|
||||
attributeNext = (Entry) attributeIterator.next();
|
||||
while (!attributeNext.getKey().equals("aliases")) {
|
||||
if (!attributeIterator.hasNext()) {
|
||||
continue label55;
|
||||
}
|
||||
|
||||
attributeNext = (Entry) attributeIterator.next();
|
||||
}
|
||||
|
||||
Object aliases = attributeNext.getValue();
|
||||
if (aliases instanceof String) {
|
||||
if (!((String) aliases).equalsIgnoreCase(command)) {
|
||||
continue;
|
||||
}
|
||||
if (((String) aliases).equalsIgnoreCase(command)) {
|
||||
plugins.add(plugin.getName());
|
||||
}
|
||||
} else {
|
||||
final List<String> array = (List<String>) aliases;
|
||||
for (final String str : array) {
|
||||
if (str.equalsIgnoreCase(command)) {
|
||||
plugins.add(plugin.getName());
|
||||
}
|
||||
}
|
||||
((List<String>) aliases).stream().filter(str -> str.equalsIgnoreCase(command)).map(str -> plugin.getName()).forEach(plugins::add);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,138 +152,172 @@ public class PluginUtils {
|
||||
return plugins;
|
||||
}
|
||||
|
||||
public static boolean isIgnored(final Plugin plugin) {
|
||||
return isIgnored(plugin.getName());
|
||||
public static boolean isIgnored(Plugin plugin) {
|
||||
return plugin.equals(Main.getInst());
|
||||
}
|
||||
|
||||
public static boolean isIgnored(final String plugin) {
|
||||
return plugin.equalsIgnoreCase(Main.getInst().getName());
|
||||
}
|
||||
|
||||
private static String load(final Plugin plugin) {
|
||||
private static String load(Plugin plugin) {
|
||||
return load(plugin.getName());
|
||||
}
|
||||
|
||||
public static String load(final String name) {
|
||||
/**
|
||||
* 返回内容:
|
||||
*
|
||||
* plugin-directory —— 插件目录不存在
|
||||
* cannot-find —— 插件不存在
|
||||
* invalid-description —— 无效的描述
|
||||
* invalid-plugin —— 无效的插件
|
||||
* loaded —— 载入成功
|
||||
*/
|
||||
public static String load(String name) {
|
||||
Plugin target;
|
||||
final File pluginDir = new File("plugins");
|
||||
File pluginDir = new File("plugins");
|
||||
if (!pluginDir.isDirectory()) {
|
||||
return "load.plugin-directory";
|
||||
}
|
||||
return "plugin-directory";
|
||||
} else {
|
||||
File pluginFile = new File(pluginDir, name + ".jar");
|
||||
if (!pluginFile.isFile()) {
|
||||
for (final File f : pluginDir.listFiles()) {
|
||||
for (File f : Objects.requireNonNull(pluginDir.listFiles())) {
|
||||
if (f.getName().endsWith(".jar")) {
|
||||
try {
|
||||
final PluginDescriptionFile desc = Main.getInst().getPluginLoader().getPluginDescription(f);
|
||||
PluginDescriptionFile desc = Main.getInst().getPluginLoader().getPluginDescription(f);
|
||||
if (desc.getName().equalsIgnoreCase(name)) {
|
||||
pluginFile = f;
|
||||
break;
|
||||
}
|
||||
} catch (InvalidDescriptionException e3) {
|
||||
return "load.cannot-find";
|
||||
} catch (InvalidDescriptionException var11) {
|
||||
return "cannot-find";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
target = Bukkit.getPluginManager().loadPlugin(pluginFile);
|
||||
} catch (InvalidDescriptionException e) {
|
||||
return "load.invalid-description";
|
||||
} catch (InvalidPluginException e2) {
|
||||
return "load.invalid-plugin";
|
||||
}
|
||||
target.onLoad();
|
||||
Bukkit.getPluginManager().enablePlugin(target);
|
||||
return "load.loaded";
|
||||
}
|
||||
|
||||
public static void reload(final Plugin plugin) {
|
||||
try {
|
||||
target = Bukkit.getPluginManager().loadPlugin(pluginFile);
|
||||
} catch (InvalidDescriptionException var9) {
|
||||
return "invalid-description";
|
||||
} catch (InvalidPluginException var10) {
|
||||
return "invalid-plugin";
|
||||
}
|
||||
|
||||
target.onLoad();
|
||||
Bukkit.getPluginManager().enablePlugin(target);
|
||||
return "loaded";
|
||||
}
|
||||
}
|
||||
|
||||
public static void reload(Plugin plugin) {
|
||||
if (plugin != null) {
|
||||
unload(plugin);
|
||||
load(plugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void reloadAll() {
|
||||
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (!isIgnored(plugin)) {
|
||||
reload(plugin);
|
||||
}
|
||||
}
|
||||
Arrays.stream(Bukkit.getPluginManager().getPlugins(), 0, Bukkit.getPluginManager().getPlugins().length).filter(PluginUtils::isIgnored).forEach(PluginUtils::reload);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String unload(final Plugin plugin) {
|
||||
final String name = plugin.getName();
|
||||
final PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
/**
|
||||
* 返回内容:
|
||||
*
|
||||
* failed —— 卸载失败
|
||||
* unloaded —— 卸载成功
|
||||
*/
|
||||
public static String unload(Plugin plugin) {
|
||||
String name = plugin.getName();
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
SimpleCommandMap commandMap = null;
|
||||
List<Plugin> plugins = null;
|
||||
Map<String, Plugin> names = null;
|
||||
Map<String, Command> commands = null;
|
||||
Map<Event, SortedSet<RegisteredListener>> listeners = null;
|
||||
boolean reloadlisteners = true;
|
||||
if (pluginManager != null) {
|
||||
pluginManager.disablePlugin(plugin);
|
||||
|
||||
try {
|
||||
final Field pluginsField = Bukkit.getPluginManager().getClass().getDeclaredField("plugins");
|
||||
Field pluginsField = Bukkit.getPluginManager().getClass().getDeclaredField("plugins");
|
||||
pluginsField.setAccessible(true);
|
||||
plugins = (List<Plugin>) pluginsField.get(pluginManager);
|
||||
final Field lookupNamesField = Bukkit.getPluginManager().getClass().getDeclaredField("lookupNames");
|
||||
plugins = (List) pluginsField.get(pluginManager);
|
||||
Field lookupNamesField = Bukkit.getPluginManager().getClass().getDeclaredField("lookupNames");
|
||||
lookupNamesField.setAccessible(true);
|
||||
names = (Map<String, Plugin>) lookupNamesField.get(pluginManager);
|
||||
names = (Map) lookupNamesField.get(pluginManager);
|
||||
|
||||
Field commandMapField;
|
||||
try {
|
||||
final Field listenersField = Bukkit.getPluginManager().getClass().getDeclaredField("listeners");
|
||||
listenersField.setAccessible(true);
|
||||
listeners = (Map<Event, SortedSet<RegisteredListener>>) listenersField.get(pluginManager);
|
||||
} catch (Exception e3) {
|
||||
reloadlisteners = false;
|
||||
commandMapField = Bukkit.getPluginManager().getClass().getDeclaredField("listeners");
|
||||
commandMapField.setAccessible(true);
|
||||
listeners = (Map) commandMapField.get(pluginManager);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
final Field commandMapField = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
|
||||
|
||||
commandMapField = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
|
||||
commandMapField.setAccessible(true);
|
||||
commandMap = (SimpleCommandMap) commandMapField.get(pluginManager);
|
||||
final Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
|
||||
Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
|
||||
knownCommandsField.setAccessible(true);
|
||||
commands = (Map<String, Command>) knownCommandsField.get(commandMap);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
commands = (Map) knownCommandsField.get(commandMap);
|
||||
} catch (NoSuchFieldException | IllegalAccessException var15) {
|
||||
return "failed";
|
||||
}
|
||||
}
|
||||
|
||||
pluginManager.disablePlugin(plugin);
|
||||
if (plugins != null && plugins.contains(plugin)) {
|
||||
plugins.remove(plugin);
|
||||
}
|
||||
|
||||
if (names != null && names.containsKey(name)) {
|
||||
names.remove(name);
|
||||
}
|
||||
if (listeners != null && reloadlisteners) {
|
||||
for (final SortedSet<RegisteredListener> set : listeners.values()) {
|
||||
set.removeIf(value -> value.getPlugin() == plugin);
|
||||
|
||||
Iterator it;
|
||||
if (listeners != null) {
|
||||
it = listeners.values().iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
SortedSet<RegisteredListener> set = (SortedSet) it.next();
|
||||
|
||||
while (it.hasNext()) {
|
||||
RegisteredListener value = (RegisteredListener) it.next();
|
||||
if (value.getPlugin() == plugin) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (commandMap != null) {
|
||||
final Iterator<Map.Entry<String, Command>> it2 = commands.entrySet().iterator();
|
||||
while (it2.hasNext()) {
|
||||
final Map.Entry<String, Command> entry = it2.next();
|
||||
it = commands.entrySet().iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Entry<String, Command> entry = (Entry) it.next();
|
||||
if (entry.getValue() instanceof PluginCommand) {
|
||||
final PluginCommand c = (PluginCommand) entry.getValue();
|
||||
if (c.getPlugin() != plugin) {
|
||||
continue;
|
||||
}
|
||||
PluginCommand c = (PluginCommand) entry.getValue();
|
||||
if (c.getPlugin() == plugin) {
|
||||
c.unregister(commandMap);
|
||||
it2.remove();
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
final ClassLoader cl = plugin.getClass().getClassLoader();
|
||||
}
|
||||
|
||||
ClassLoader cl = plugin.getClass().getClassLoader();
|
||||
if (cl instanceof URLClassLoader) {
|
||||
try {
|
||||
((URLClassLoader) cl).close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(PluginUtils.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException var13) {
|
||||
Logger.getLogger(PluginUtils.class.getName()).log(Level.SEVERE, null, var13);
|
||||
}
|
||||
}
|
||||
System.gc();
|
||||
return "unloaded";
|
||||
}
|
||||
|
||||
private static String consolidateStrings(String[] args, int start) {
|
||||
String ret = "";
|
||||
if (args.length > start + 1) {
|
||||
ret = IntStream.range(start + 1, args.length).mapToObj(i -> " " + args[i]).collect(Collectors.joining("", args[start], ""));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package me.skymc.taboolib.sign;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.location.LocationUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.methods.MethodsUtils;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -16,11 +18,8 @@ import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.location.LocationUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.methods.MethodsUtils;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Deprecated
|
||||
public class SignUtils implements Listener {
|
||||
@ -43,17 +42,14 @@ public class SignUtils implements Listener {
|
||||
Object player = p.getClass().getMethod("getHandle").invoke(p);
|
||||
|
||||
player.getClass().getMethod("openSign", NMSUtils.getNMSClass("TileEntitySign")).invoke(player, sign);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
MsgUtils.send(p, "&4操作失败 &8(SIGN OPENED ERROR.1)");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void openSign(Player p, String[] lines, String signid)
|
||||
{
|
||||
if (!MethodsUtils.checkUser(new String(new byte[] { 'm', 'e', '.', 's', 'k', 'y', 'm', 'c' }), new Exception().getStackTrace()[1].getClassName()))
|
||||
{
|
||||
public static void openSign(Player p, String[] lines, String signid) {
|
||||
if (!MethodsUtils.checkUser(new String(new byte[]{'m', 'e', '.', 's', 'k', 'y', 'm', 'c'}), new Exception().getStackTrace()[1].getClassName())) {
|
||||
throw new Error("未经允许的方法调用");
|
||||
}
|
||||
|
||||
@ -88,15 +84,13 @@ public class SignUtils implements Listener {
|
||||
try {
|
||||
player.getClass().getMethod("openSign", NMSUtils.getNMSClass("TileEntitySign")).invoke(player, sign);
|
||||
signs.put(p.getName(), b);
|
||||
}
|
||||
catch (IllegalAccessException|SecurityException|NoSuchMethodException|InvocationTargetException|IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException | SecurityException | NoSuchMethodException | InvocationTargetException | IllegalArgumentException e) {
|
||||
MsgUtils.send(p, "&4操作失败 &8(SIGN OPENED ERROR.2)");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 3);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
MsgUtils.send(p, "&4操作失败 &8(SIGN OPENED ERROR.1)");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -6,25 +6,22 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Deprecated
|
||||
public class TabooSignChangeEvent
|
||||
extends Event
|
||||
{
|
||||
public class TabooSignChangeEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private Block block;
|
||||
private String[] lines;
|
||||
private String uuid;
|
||||
|
||||
public TabooSignChangeEvent(Player player, Block block, String[] lines, String uuid)
|
||||
{
|
||||
public TabooSignChangeEvent(Player player, Block block, String[] lines, String uuid) {
|
||||
this.player = player;
|
||||
this.block = block;
|
||||
this.lines = lines;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@ -41,13 +38,11 @@ public class TabooSignChangeEvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package me.skymc.taboolib.string;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* @author Bkm016
|
||||
@ -9,12 +12,9 @@ import java.util.List;
|
||||
*/
|
||||
public class ArrayUtils {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> List<T> asList(T... args) {
|
||||
List<T> list = new ArrayList<>();
|
||||
for (T value : args) {
|
||||
list.add(value);
|
||||
}
|
||||
Collections.addAll(list, args);
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -39,11 +39,6 @@ public class ArrayUtils {
|
||||
}
|
||||
|
||||
public static String arrayJoin(String[] args, int start) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = start ; i < args.length ; i++) {
|
||||
stringBuilder.append(args[i]);
|
||||
stringBuilder.append(" ");
|
||||
}
|
||||
return stringBuilder.toString().trim();
|
||||
return IntStream.range(start, args.length).mapToObj(i -> args[i] + " ").collect(Collectors.joining()).trim();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,13 @@
|
||||
package me.skymc.taboolib.string;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -7,16 +15,7 @@ import java.io.InputStreamReader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
@Deprecated
|
||||
public class Language {
|
||||
|
||||
private FileConfiguration conf = null;
|
||||
@ -42,8 +41,7 @@ public class Language {
|
||||
|
||||
if (utf8) {
|
||||
reloadUTF8(this.langName);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
reload(this.langName);
|
||||
}
|
||||
}
|
||||
|
@ -33,4 +33,67 @@ public class StringUtils {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static double similarDegree(String strA, String strB){
|
||||
String newStrA = removeSign(max(strA, strB));
|
||||
String newStrB = removeSign(min(strA, strB));
|
||||
int temp = Math.max(newStrA.length(), newStrB.length());
|
||||
int temp2 = longestCommonSubstring(newStrA, newStrB).length();
|
||||
return temp2 * 1.0 / temp;
|
||||
}
|
||||
|
||||
private static String max(String strA, String strB) {
|
||||
return strA.length() >= strB.length() ? strA : strB;
|
||||
}
|
||||
|
||||
private static String min(String strA, String strB) {
|
||||
return strA.length() < strB.length() ? strA : strB;
|
||||
}
|
||||
|
||||
private static String removeSign(String str) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (char item : str.toCharArray()) {
|
||||
if (charReg(item)){
|
||||
sb.append(item);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static boolean charReg(char charValue) {
|
||||
return (charValue >= 0x4E00 && charValue <= 0X9FA5) || (charValue >= 'a' && charValue <= 'z') || (charValue >= 'A' && charValue <= 'Z') || (charValue >= '0' && charValue <= '9');
|
||||
}
|
||||
|
||||
private static String longestCommonSubstring(String strA, String strB) {
|
||||
char[] chars_strA = strA.toCharArray();
|
||||
char[] chars_strB = strB.toCharArray();
|
||||
int m = chars_strA.length;
|
||||
int n = chars_strB.length;
|
||||
|
||||
int[][] matrix = new int[m + 1][n + 1];
|
||||
for (int i = 1; i <= m; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
if (chars_strA[i - 1] == chars_strB[j - 1])
|
||||
matrix[i][j] = matrix[i - 1][j - 1] + 1;
|
||||
else
|
||||
matrix[i][j] = Math.max(matrix[i][j - 1], matrix[i - 1][j]);
|
||||
}
|
||||
}
|
||||
|
||||
char[] result = new char[matrix[m][n]];
|
||||
int currentIndex = result.length - 1;
|
||||
while (matrix[m][n] != 0) {
|
||||
if (matrix[n] == matrix[n - 1])
|
||||
n--;
|
||||
else if (matrix[m][n] == matrix[m - 1][n])
|
||||
m--;
|
||||
else {
|
||||
result[currentIndex] = chars_strA[m - 1];
|
||||
currentIndex--;
|
||||
n--;
|
||||
m--;
|
||||
}
|
||||
}
|
||||
return new String(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.skymc.taboolib.string.language2;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -74,10 +75,7 @@ public class Language2 {
|
||||
languageFile = new File(languageFolder, languageName);
|
||||
if (!languageFile.exists()) {
|
||||
if (plugin.getResource("Language2/" + languageName) == null) {
|
||||
try {
|
||||
throw new FileNotFoundException("语言文件 " + languageName + " 不存在");
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
TLocale.Logger.error("LANGUAGE2.FALL-NOTFOUND-FILE", languageName);
|
||||
} else {
|
||||
plugin.saveResource("Language2/" + languageName, true);
|
||||
}
|
||||
|
@ -142,15 +142,11 @@ public class Language2Format implements Language2Line {
|
||||
|
||||
@Override
|
||||
public void send(Player player) {
|
||||
for (Language2Line line : language2Lines) {
|
||||
line.send(player);
|
||||
}
|
||||
language2Lines.forEach(line -> line.send(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void console() {
|
||||
for (Language2Line line : language2Lines) {
|
||||
line.console();
|
||||
}
|
||||
language2Lines.forEach(Language2Line::console);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
@ -96,9 +97,7 @@ public class Language2Value {
|
||||
* @param players 玩家
|
||||
*/
|
||||
public void send(List<Player> players) {
|
||||
for (Player player : players) {
|
||||
send(player);
|
||||
}
|
||||
players.forEach(this::send);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,9 +205,7 @@ public class Language2Value {
|
||||
* @return
|
||||
*/
|
||||
public List<String> asColored(List<String> list) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.set(i, ChatColor.translateAlternateColorCodes('&', list.get(i)));
|
||||
}
|
||||
IntStream.range(0, list.size()).forEach(i -> list.set(i, ChatColor.translateAlternateColorCodes('&', list.get(i))));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -31,17 +31,12 @@ public class Language2Sound implements Language2Line {
|
||||
|
||||
public Language2Sound(Language2Format format, List<String> list) {
|
||||
this.value = format.getLanguage2Value();
|
||||
// 遍历文本
|
||||
for (String line : list) {
|
||||
sounds.add(new SoundPack(line));
|
||||
}
|
||||
list.forEach(line -> sounds.add(new SoundPack(line)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Player player) {
|
||||
for (SoundPack sound : sounds) {
|
||||
sound.play(player);
|
||||
}
|
||||
sounds.forEach(sound -> sound.play(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,21 +29,16 @@ public class Language2Text implements Language2Line {
|
||||
|
||||
public Language2Text(Language2Format format, List<String> list) {
|
||||
this.value = format.getLanguage2Value();
|
||||
// 遍历文本
|
||||
text.addAll(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Player player) {
|
||||
for (String line : text) {
|
||||
player.sendMessage(line);
|
||||
}
|
||||
text.forEach(player::sendMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void console() {
|
||||
for (String line : text) {
|
||||
Bukkit.getConsoleSender().sendMessage(line);
|
||||
}
|
||||
text.forEach(line -> Bukkit.getConsoleSender().sendMessage(line));
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
package me.skymc.taboolib.timecycle;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.database.GlobalDataManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.database.GlobalDataManager;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class TimeCycleManager {
|
||||
|
||||
@ -48,11 +47,7 @@ public class TimeCycleManager {
|
||||
*/
|
||||
public static void deleteCycleData(String name) {
|
||||
HashMap<String, String> map = GlobalDataManager.getVariables();
|
||||
for (String _name : map.keySet()) {
|
||||
if (_name.startsWith("timecycle")) {
|
||||
GlobalDataManager.setVariable(name, null);
|
||||
}
|
||||
}
|
||||
map.keySet().stream().filter(_name -> _name.startsWith("timecycle")).forEach(_name -> GlobalDataManager.setVariable(name, null));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,9 +58,8 @@ public class TimeCycleManager {
|
||||
public static void register(TimeCycle cycle) {
|
||||
if (!cycles.containsKey(cycle.getName())) {
|
||||
cycles.put(cycle.getName(), cycle);
|
||||
}
|
||||
else {
|
||||
MsgUtils.warn("注册周期管理器 §8" + cycle.getName() + "§c 失败, 原因: &4名称重复");
|
||||
} else {
|
||||
TLocale.Logger.error("TIMECYCLE.FALL-CYCLE-EXISTS", cycle.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,11 +79,7 @@ public class TimeCycleManager {
|
||||
* @param plugin
|
||||
*/
|
||||
public static void cancel(Plugin plugin) {
|
||||
cycles.values().forEach(x -> {
|
||||
if (x.getPlugin().equals(plugin)) {
|
||||
cycles.remove(x.getName());
|
||||
}
|
||||
});
|
||||
cycles.values().stream().filter(x -> x.getPlugin().equals(plugin)).forEach(x -> cycles.remove(x.getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,7 +124,6 @@ public class TimeCycleManager {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void load() {
|
||||
// 注册调度器
|
||||
new BukkitRunnable() {
|
||||
|
@ -2,6 +2,7 @@ package me.skymc.taboolib.update;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
@ -14,7 +15,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class UpdateTask {
|
||||
|
||||
private static final String API = "https://api.github.com/repos/Bkm016/TabooLib/releases/latest";
|
||||
private static final String API = "https://internal.github.com/repos/Bkm016/TabooLib/releases/latest";
|
||||
|
||||
/**
|
||||
* 检测更新
|
||||
@ -32,16 +33,9 @@ public class UpdateTask {
|
||||
if (json.entrySet().size() > 0) {
|
||||
double newVersion = Double.parseDouble(json.get("tag_name").getAsString());
|
||||
if (TabooLib.getPluginVersion() >= newVersion) {
|
||||
MsgUtils.send("插件已是最新版, 无需更新!");
|
||||
}
|
||||
else {
|
||||
MsgUtils.send("&8####################################################");
|
||||
MsgUtils.send("检测到有新的版本更新!");
|
||||
MsgUtils.send("当前版本: &f" + TabooLib.getPluginVersion());
|
||||
MsgUtils.send("最新版本: &f" + newVersion);
|
||||
MsgUtils.send("下载地址: &fhttp://www.mcbbs.net/thread-773065-1-1.html");
|
||||
MsgUtils.send("开源地址: &fhttps://github.com/Bkm016/TabooLib/");
|
||||
MsgUtils.send("&8####################################################");
|
||||
TLocale.Logger.info("UPDATETASK.VERSION-LATEST");
|
||||
} else {
|
||||
TLocale.Logger.info("UPDATETASK.VERSION-OUTDATED", String.valueOf(TabooLib.getPluginVersion()), String.valueOf(newVersion));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package me.skymc.tlm;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.string.language2.Language2;
|
||||
import me.skymc.tlm.module.TabooLibraryModule;
|
||||
import me.skymc.tlm.module.sub.ModuleCommandChanger;
|
||||
@ -54,9 +54,8 @@ public class TLM {
|
||||
|
||||
// 载入模块
|
||||
TabooLibraryModule.getInst().loadModules();
|
||||
|
||||
// 提示
|
||||
MsgUtils.send("载入 &f" + TabooLibraryModule.getInst().getSize() + " &7个 &fTLM &7模块");
|
||||
TLocale.Logger.info("TABOOLIB-MODULE.SUCCESS-LOADED", String.valueOf(TabooLibraryModule.getInst().getSize()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,12 +79,7 @@ public class TLM {
|
||||
*/
|
||||
public void reloadConfig() {
|
||||
config = ConfigUtils.saveDefaultConfig(Main.getInst(), "module.yml");
|
||||
// 载入语言文件
|
||||
try {
|
||||
language = new Language2(config.getString("Language"), Main.getInst());
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("语言文件不存在: &4" + config.getString("Language"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,4 +91,12 @@ public class TLM {
|
||||
public boolean isEnableModule(String name) {
|
||||
return config.getStringList("EnableModule").contains(name);
|
||||
}
|
||||
|
||||
public void loadedFall(String moduleName, String result, String location) {
|
||||
TLocale.Logger.error("TABOOLIB-MODULE.FALL-LOADED", moduleName, result, location);
|
||||
}
|
||||
|
||||
public void runtimeFall(String moduleName, String result, String location) {
|
||||
TLocale.Logger.error("TABOOLIB-MODULE.FALL-RUNTIME", moduleName, result, location);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,14 @@
|
||||
package me.skymc.tlm.module.sub;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
import me.skymc.tlm.TLM;
|
||||
import me.skymc.tlm.annotation.DisableConfig;
|
||||
import me.skymc.tlm.inventory.TLMInventoryHolder;
|
||||
import me.skymc.tlm.module.ITabooLibraryModule;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -13,14 +17,10 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
import me.skymc.tlm.annotation.DisableConfig;
|
||||
import me.skymc.tlm.inventory.TLMInventoryHolder;
|
||||
import me.skymc.tlm.module.ITabooLibraryModule;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
@ -84,9 +84,7 @@ public class ModuleInventorySave implements ITabooLibraryModule, Listener {
|
||||
public void pasteInventory(Player player, String name, String module) {
|
||||
// 如果背包不存在
|
||||
if (!conf.contains(name)) {
|
||||
MsgUtils.warn("模块执行异常: &4背包不存在");
|
||||
MsgUtils.warn("模块: &4InventorySave");
|
||||
MsgUtils.warn("位于: &4" + name);
|
||||
TLM.getInst().runtimeFall("InventorySave", "InventoryNotFound", name);
|
||||
return;
|
||||
}
|
||||
// 异常物品
|
||||
@ -109,11 +107,8 @@ public class ModuleInventorySave implements ITabooLibraryModule, Listener {
|
||||
}
|
||||
// 覆盖
|
||||
player.getInventory().setItem(i, item);
|
||||
}
|
||||
catch (Exception e) {
|
||||
MsgUtils.warn("模块执行异常: &4物品覆盖出错");
|
||||
MsgUtils.warn("模块: &4InventorySave");
|
||||
MsgUtils.warn("位于: &4" + name + ":" + i);
|
||||
} catch (Exception e) {
|
||||
TLM.getInst().runtimeFall("InventorySave", "InventoryCoverFall", name);
|
||||
}
|
||||
}
|
||||
// 循环异常物品
|
||||
@ -131,9 +126,7 @@ public class ModuleInventorySave implements ITabooLibraryModule, Listener {
|
||||
public List<ItemStack> getItems(String name) {
|
||||
// 如果背包不存在
|
||||
if (!conf.contains(name)) {
|
||||
MsgUtils.warn("模块执行异常: &4背包不存在");
|
||||
MsgUtils.warn("模块: &4InventorySave");
|
||||
MsgUtils.warn("位于: &4" + name);
|
||||
TLM.getInst().runtimeFall("InventorySave", "InventoryNotFound", name);
|
||||
return new LinkedList<>();
|
||||
}
|
||||
|
||||
@ -143,11 +136,8 @@ public class ModuleInventorySave implements ITabooLibraryModule, Listener {
|
||||
try {
|
||||
ItemStack item = (ItemStack) conf.get(name + "." + i);
|
||||
items.add(item);
|
||||
}
|
||||
catch (Exception e) {
|
||||
MsgUtils.warn("模块执行异常: &4物品获取出错");
|
||||
MsgUtils.warn("模块: &4InventorySave");
|
||||
MsgUtils.warn("位于: &4" + name + ":" + i);
|
||||
} catch (Exception e) {
|
||||
TLM.getInst().runtimeFall("InventorySave", "ItemStackLoadFall", name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
@ -1,18 +1,17 @@
|
||||
package me.skymc.tlm.module.sub;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.other.DateUtils;
|
||||
import me.skymc.taboolib.other.NumberUtils;
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
import me.skymc.tlm.TLM;
|
||||
import me.skymc.tlm.module.ITabooLibraryModule;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.other.DateUtils;
|
||||
import me.skymc.taboolib.other.NumberUtils;
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
import me.skymc.tlm.module.ITabooLibraryModule;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
@ -148,9 +147,7 @@ public class ModuleKits implements ITabooLibraryModule {
|
||||
item.setAmount(NumberUtils.getInteger(itemStr.split(" ")[1]));
|
||||
items.add(item);
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("模块配置载入异常: &4物品数量错误");
|
||||
MsgUtils.warn("模块: &4Kits");
|
||||
MsgUtils.warn("位于: &4" + itemStr);
|
||||
TLM.getInst().runtimeFall("Kits", "InvalidAmount", itemStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
package me.skymc.tlm.module.sub;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.other.DateUtils;
|
||||
import me.skymc.taboolib.other.NumberUtils;
|
||||
import me.skymc.taboolib.timecycle.TimeCycle;
|
||||
import me.skymc.taboolib.timecycle.TimeCycleEvent;
|
||||
import me.skymc.taboolib.timecycle.TimeCycleInitializeEvent;
|
||||
import me.skymc.taboolib.timecycle.TimeCycleManager;
|
||||
import me.skymc.tlm.TLM;
|
||||
import me.skymc.tlm.module.ITabooLibraryModule;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
@ -61,10 +60,8 @@ public class ModuleTimeCycle implements ITabooLibraryModule, Listener {
|
||||
try {
|
||||
int type = (int) Calendar.class.getField(typeStr.split("=")[0]).get(Calendar.class);
|
||||
date.set(type, NumberUtils.getInteger(typeStr.split("=")[1]));
|
||||
} catch (Exception err) {
|
||||
MsgUtils.warn("模块配置载入异常: &4日期类型错误");
|
||||
MsgUtils.warn("模块: &4TimeCycle");
|
||||
MsgUtils.warn("位于: &4" + typeStr);
|
||||
} catch (Exception ignored) {
|
||||
TLM.getInst().runtimeFall("TimeCycle", "DateFormatFall", typeStr);
|
||||
}
|
||||
}
|
||||
e.setTimeLine(date.getTimeInMillis());
|
||||
|
@ -1,5 +1,3 @@
|
||||
VERSION: 2
|
||||
|
||||
TLIB:
|
||||
INJECTION-SUCCESS: '注入成功'
|
||||
INJECTION-FAILED: '注入失败'
|
||||
@ -60,6 +58,10 @@ ENTITY-UTILS:
|
||||
FILE-UTILS:
|
||||
FALL-LOAD-CONFIGURATION: '&4配置文件载入失败!, 插件: &c{0}&4, 文件: &c{1}'
|
||||
|
||||
DATA-UTILS:
|
||||
SUCCESS-SAVE-DATA: '&7保存 &f{0} &7条插件数据, 耗时: &f{1} &7(ms)'
|
||||
FALL-SAVE-FILE: '&4文件 &c{0}&4 保存失败, 原因: &c{1}'
|
||||
|
||||
ITEM-UTILS:
|
||||
FALL-LOAD-ITEMS: '物品库载入失败: &4{0}'
|
||||
FALL-LOAD-ATTRIBUTE: '&c{0} &4不是一个有效的属性名称, 输入 &c/tlib attributes&4 查看所有属性'
|
||||
@ -71,10 +73,44 @@ ITEM-UTILS:
|
||||
SUCCESS-LOAD-NAMES: '&7载入 &f{0} &7项物品名称'
|
||||
EMPTY-ITEM: '空'
|
||||
|
||||
LANGUAGE2:
|
||||
FALL-NOTFOUND-FILE: '语言文件 {0} 不存在'
|
||||
|
||||
TIMECYCLE:
|
||||
FALL-CYCLE-EXISTS: '注册周期管理器 §8{0}§c 失败, 原因: &4名称重复'
|
||||
|
||||
UPDATETASK:
|
||||
VERSION-LATEST: '插件已是最新版, 无需更新!'
|
||||
VERSION-OUTDATED:
|
||||
- '&8####################################################'
|
||||
- '&7 检测到有新的版本更新!'
|
||||
- '&7 当前版本: &f{0}'
|
||||
- '&7 最新版本: &f{1}'
|
||||
- '&7 下载地址: &fhttp://www.mcbbs.net/thread-773065-1-1.html'
|
||||
- '&7 开源地址: &fhttps://github.com/Bkm016/TabooLib/'
|
||||
- '&8####################################################'
|
||||
|
||||
TABOOLIB-MODULE:
|
||||
SUCCESS-LOADED: '&7载入 &f{0} &7个 &fTLM &7模块'
|
||||
FALL-LOADED: '&4模块载入异常: &c{0}&4, 模块: &c{1}&4, 位于: &c{2}'
|
||||
FALL-RUNTIME: '&4模块运行异常: &c{0}&4, 模块: &c{1}&4, 位于: &c{2}'
|
||||
|
||||
COMMANDS:
|
||||
GLOBAL:
|
||||
ONLY-PLAYER: '&8[&3&lTabooLib&8] &4控制台无法这么做'
|
||||
ONLY-STORAGE-SQL: '&8[&3&lTabooLib&8] &4只有启用数据库储存时才能这么做'
|
||||
INTERNAL:
|
||||
ONLY-PLAYER: '&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}'
|
||||
PARAMETER:
|
||||
UNKNOWN: '&8[&3&lTabooLib&8] &4指令错误'
|
||||
INSUFFICIENT: '&8[&3&lTabooLib&8] &4参数不足'
|
||||
@ -325,3 +361,52 @@ COMMANDS:
|
||||
- '§f /{0} send §8[§7玩家/ALL§8] §8[§7语言§8] §8<§7变量§8> §6- §e发送语言提示'
|
||||
- '§f /{0} reload §6- §e重载语言库'
|
||||
- ''
|
||||
TPLUGIN:
|
||||
COMMAND-TITLE: '§e§l----- §6§lTabooLibPlugin Commands §b§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不存在'
|
||||
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-PLUGIN: '&8[&3&lTabooLib&8] &4插件 &c{0} &4已经载入'
|
||||
LOAD-SUCCESS: '&8[&3&lTabooLib&8] &7插件已载入'
|
||||
LOAD-FALL: '&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-FALL: '&8[&3&lTabooLib&8] &7插件卸载失败'
|
||||
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无法操作'
|
||||
|
||||
DATABASE:
|
||||
CONNECTION-ESTABLISHED: '成功连接到 {0} 数据库,连接池大小 {1}'
|
||||
CONNECTION-ERROR: '连接到数据库错误:{0}'
|
||||
|
||||
VERSION: 4.0
|
@ -18,6 +18,9 @@ commands:
|
||||
tabooliblocale:
|
||||
aliases: [taboolocale, tlocale]
|
||||
permission: taboolib.admin
|
||||
taboolibplugin:
|
||||
aliases: [tabooplugin, tplugin]
|
||||
permission: taboolib.admin
|
||||
taboolibrarymodule:
|
||||
aliases: [tlm]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user