.
This commit is contained in:
@@ -3,7 +3,6 @@ package com.ilummc.tlib;
|
||||
import com.ilummc.tlib.annotations.Dependency;
|
||||
import com.ilummc.tlib.compat.PlaceholderHook;
|
||||
import com.ilummc.tlib.config.TLibConfig;
|
||||
import com.ilummc.tlib.db.Pool;
|
||||
import com.ilummc.tlib.filter.TLoggerFilter;
|
||||
import com.ilummc.tlib.inject.TConfigWatcher;
|
||||
import com.ilummc.tlib.inject.TDependencyInjector;
|
||||
@@ -22,7 +21,6 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
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.javalite:activejdbc:2.0")
|
||||
@@ -74,17 +72,18 @@ public class TLib {
|
||||
TLocaleLoader.load(Main.getInst(), false);
|
||||
TDependencyInjector.inject(Main.getInst(), tLib);
|
||||
|
||||
// init database
|
||||
// init database 暫不啟用
|
||||
/*
|
||||
try {
|
||||
Pool.init();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
public static void unload() {
|
||||
Pool.unload();
|
||||
/* Pool.unload(); */
|
||||
tLib.getConfigWatcher().unregisterAll();
|
||||
TDependencyInjector.eject(Main.getInst(), tLib);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.ilummc.tlib.annotations;
|
||||
|
||||
import com.ilummc.tlib.util.Ref;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import com.ilummc.tlib.util.Ref;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TConfig {
|
||||
|
||||
@@ -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,25 +12,46 @@ 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
|
||||
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;
|
||||
}
|
||||
|
||||
private String password = "";
|
||||
|
||||
@Getter
|
||||
private int maximumPoolSize = 4;
|
||||
|
||||
@Getter
|
||||
private Map<String, Object> settings = new HashMap<String, Object>() {{
|
||||
put("cachePrepStmts", true);
|
||||
put("useServerPrepStmts", true);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ilummc.tlib.dependency;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -7,9 +9,6 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TDependencyLoader {
|
||||
|
||||
public static synchronized void addToPath(Plugin plugin, URL url) {
|
||||
|
||||
@@ -47,8 +47,8 @@ public class TLocale {
|
||||
try {
|
||||
return asString(path, Ref.getCallerClassNotOptional(3), args);
|
||||
} catch (Exception e) {
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getTLib().getInternalLanguage().getString("FETCH-LOCALE-ERROR"), path));
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getTLib().getInternalLanguage().getString("LOCALE-ERROR-REASON"), e.getMessage()));
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("FETCH-LOCALE-ERROR"), path));
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("LOCALE-ERROR-REASON"), e.getMessage()));
|
||||
return "§4<" + path + "§4>";
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,8 @@ public class TLocale {
|
||||
try {
|
||||
return asStringList(path, Ref.getCallerClassNotOptional(3), args);
|
||||
} catch (Exception e) {
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getTLib().getInternalLanguage().getString("FETCH-LOCALE-ERROR"), path));
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getTLib().getInternalLanguage().getString("LOCALE-ERROR-REASON"), e.getMessage()));
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("FETCH-LOCALE-ERROR"), path));
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("LOCALE-ERROR-REASON"), e.getMessage()));
|
||||
return Collections.singletonList("§4<" + path + "§4>");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.ilummc.tlib.resources;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.logger.TLogger;
|
||||
import com.ilummc.tlib.resources.type.TLocaleText;
|
||||
import com.ilummc.tlib.util.Strings;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -62,8 +61,8 @@ class TLocaleInstance {
|
||||
}
|
||||
});
|
||||
} catch (Exception | Error e) {
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getTLib().getInternalLanguage().getString("SEND-LOCALE-ERROR"), path));
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getTLib().getInternalLanguage().getString("LOCALE-ERROR-REASON"), e.toString()));
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("SEND-LOCALE-ERROR"), path));
|
||||
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("LOCALE-ERROR-REASON"), e.toString()));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class TLocaleJson implements TLocaleSendable, ConfigurationSerializable {
|
||||
builder.addAll(Arrays.asList(component));
|
||||
} else {
|
||||
builder.addAll(Arrays.asList(TextComponent.fromLegacyText(text)));
|
||||
TLib.getTLib().getLogger().warn(Strings.replaceWithOrder(TLib.getTLib().getInternalLanguage().getString("MISSING-ARGUMENT"), node));
|
||||
TLib.getTLib().getLogger().warn(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("MISSING-ARGUMENT"), node));
|
||||
}
|
||||
if (index < template.length) {
|
||||
builder.addAll(Arrays.asList(TextComponent.fromLegacyText(template[index++])));
|
||||
|
||||
@@ -28,6 +28,17 @@ public class TLocaleSound implements TLocaleSendable, ConfigurationSerializable
|
||||
this.soundPacks = soundPacks;
|
||||
}
|
||||
|
||||
public static TLocaleSound valueOf(Map<String, Object> map) {
|
||||
List<SoundPack> soundPacks = new ArrayList<>();
|
||||
Object sounds = map.containsKey("sounds") ? map.get("sounds") : map.getOrDefault("sound", "");
|
||||
if (sounds instanceof List) {
|
||||
soundPacks = ((List<String>) sounds).stream().map(SoundPack::new).collect(Collectors.toList());
|
||||
} else {
|
||||
soundPacks.add(new SoundPack(sounds.toString()));
|
||||
}
|
||||
return new TLocaleSound(soundPacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTo(CommandSender sender, String... args) {
|
||||
if (sender instanceof Player) {
|
||||
@@ -55,15 +66,4 @@ public class TLocaleSound implements TLocaleSendable, ConfigurationSerializable
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static TLocaleSound valueOf(Map<String, Object> map) {
|
||||
List<SoundPack> soundPacks = new ArrayList<>();
|
||||
Object sounds = map.containsKey("sounds") ? map.get("sounds") : map.getOrDefault("sound", "");
|
||||
if (sounds instanceof List) {
|
||||
soundPacks = ((List<String>) sounds).stream().map(SoundPack::new).collect(Collectors.toList());
|
||||
} else {
|
||||
soundPacks.add(new SoundPack(sounds.toString()));
|
||||
}
|
||||
return new TLocaleSound(soundPacks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ public class AnvilContainerAPIEvent extends Event {
|
||||
type = t;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,6 @@ public class AnvilContainer_V1_11_R1 extends ContainerAnvil {
|
||||
super(player.inventory, player.world, new BlockPosition(0, 0, 0), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
*/
|
||||
@@ -29,4 +24,9 @@ public class AnvilContainer_V1_11_R1 extends ContainerAnvil {
|
||||
player.activeContainer.addSlotListener(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,11 +10,6 @@ public class AnvilContainer_V1_8_R3 extends ContainerAnvil {
|
||||
super(player.inventory, player.world, new BlockPosition(0, 0, 0), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
*/
|
||||
@@ -29,4 +24,9 @@ public class AnvilContainer_V1_8_R3 extends ContainerAnvil {
|
||||
player.activeContainer.addSlotListener(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,11 +10,6 @@ public class AnvilContainer_V1_9_4 extends ContainerAnvil {
|
||||
super(player.inventory, player.world, new BlockPosition(0, 0, 0), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
*/
|
||||
@@ -29,4 +24,9 @@ public class AnvilContainer_V1_9_4 extends ContainerAnvil {
|
||||
player.activeContainer.addSlotListener(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,10 @@ public final class BookAchievement {
|
||||
achievements.put(OVERPOWERED, "overpowered");
|
||||
}
|
||||
|
||||
private BookAchievement() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the json id from the bukkit achievement passed as argument
|
||||
*
|
||||
@@ -56,8 +60,4 @@ public final class BookAchievement {
|
||||
public static String toId(Achievement achievement) {
|
||||
return achievements.get(achievement);
|
||||
}
|
||||
|
||||
private BookAchievement() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,30 +233,6 @@ public final class BookReflection {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An error thrown when this NMS-helper class doesn't support the running MC version
|
||||
*/
|
||||
public static class UnsupportedVersionException extends RuntimeException {
|
||||
/**
|
||||
* serialVersionUID
|
||||
*/
|
||||
private static final long serialVersionUID = 6835583513394319946L;
|
||||
|
||||
/**
|
||||
* The current running version
|
||||
*/
|
||||
private final String version = BookReflection.version;
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public UnsupportedVersionException(Exception e) {
|
||||
super("Error while executing reflections, submit to developers the following log (version: " + BookReflection.version + ")", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the EntityPlayer handled by the argument
|
||||
*
|
||||
@@ -291,11 +267,6 @@ public final class BookReflection {
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getNmsClass(String className) {
|
||||
return getNmsClass(className, true);
|
||||
}
|
||||
|
||||
|
||||
private static Class<?> getCraftClass(String path) {
|
||||
try {
|
||||
return Class.forName("org.bukkit.craftbukkit." + version + "." + path);
|
||||
@@ -304,4 +275,31 @@ public final class BookReflection {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getNmsClass(String className) {
|
||||
return getNmsClass(className, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* An error thrown when this NMS-helper class doesn't support the running MC version
|
||||
*/
|
||||
public static class UnsupportedVersionException extends RuntimeException {
|
||||
/**
|
||||
* serialVersionUID
|
||||
*/
|
||||
private static final long serialVersionUID = 6835583513394319946L;
|
||||
|
||||
/**
|
||||
* The current running version
|
||||
*/
|
||||
private final String version = BookReflection.version;
|
||||
|
||||
public UnsupportedVersionException(Exception e) {
|
||||
super("Error while executing reflections, submit to developers the following log (version: " + BookReflection.version + ")", e);
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,6 @@ import net.md_5.bungee.api.chat.ClickEvent;
|
||||
*/
|
||||
public interface ClickAction {
|
||||
|
||||
/**
|
||||
* Get the Chat-Component action
|
||||
*
|
||||
* @return the Chat-Component action
|
||||
*/
|
||||
ClickEvent.Action action();
|
||||
|
||||
/**
|
||||
* The value paired to the action
|
||||
*
|
||||
* @return the value paired tot the action
|
||||
*/
|
||||
String value();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a command action: when the player clicks, the command passed as parameter gets executed with the clicker as sender
|
||||
*
|
||||
@@ -66,6 +51,20 @@ public interface ClickAction {
|
||||
return new SimpleClickAction(ClickEvent.Action.CHANGE_PAGE, Integer.toString(page));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Chat-Component action
|
||||
*
|
||||
* @return the Chat-Component action
|
||||
*/
|
||||
ClickEvent.Action action();
|
||||
|
||||
/**
|
||||
* The value paired to the action
|
||||
*
|
||||
* @return the value paired tot the action
|
||||
*/
|
||||
String value();
|
||||
|
||||
class SimpleClickAction implements ClickAction {
|
||||
|
||||
private final ClickEvent.Action action;
|
||||
|
||||
@@ -18,21 +18,6 @@ import java.util.UUID;
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface HoverAction {
|
||||
|
||||
/**
|
||||
* Get the Chat-Component action
|
||||
*
|
||||
* @return the Chat-Component action
|
||||
*/
|
||||
HoverEvent.Action action();
|
||||
|
||||
/**
|
||||
* The value paired to the action
|
||||
*
|
||||
* @return the value paired tot the action
|
||||
*/
|
||||
BaseComponent[] value();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a show_text action: when the component is hovered the text used as parameter will be displayed
|
||||
*
|
||||
@@ -139,6 +124,20 @@ public interface HoverAction {
|
||||
return new SimpleHoverAction(HoverEvent.Action.SHOW_ACHIEVEMENT, new TextComponent("statistic." + statisticId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Chat-Component action
|
||||
*
|
||||
* @return the Chat-Component action
|
||||
*/
|
||||
HoverEvent.Action action();
|
||||
|
||||
/**
|
||||
* The value paired to the action
|
||||
*
|
||||
* @return the value paired tot the action
|
||||
*/
|
||||
BaseComponent[] value();
|
||||
|
||||
class SimpleHoverAction implements HoverAction {
|
||||
private final HoverEvent.Action action;
|
||||
private final BaseComponent[] value;
|
||||
|
||||
@@ -17,6 +17,23 @@ public class TextBuilder {
|
||||
private ClickAction onClick = null;
|
||||
private HoverAction onHover = null;
|
||||
|
||||
public TextBuilder() {
|
||||
}
|
||||
|
||||
public TextBuilder(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TextBuilder with the parameter as his initial text
|
||||
*
|
||||
* @param text initial text
|
||||
* @return a new TextBuilder with the parameter as his initial text
|
||||
*/
|
||||
public static TextBuilder of(String text) {
|
||||
return new TextBuilder(text);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
@@ -41,13 +58,6 @@ public class TextBuilder {
|
||||
this.onHover = onHover;
|
||||
}
|
||||
|
||||
public TextBuilder() {
|
||||
}
|
||||
|
||||
public TextBuilder(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the component representing the built text
|
||||
*
|
||||
@@ -63,14 +73,4 @@ public class TextBuilder {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TextBuilder with the parameter as his initial text
|
||||
*
|
||||
* @param text initial text
|
||||
* @return a new TextBuilder with the parameter as his initial text
|
||||
*/
|
||||
public static TextBuilder of(String text) {
|
||||
return new TextBuilder(text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.lang.reflect.Parameter;
|
||||
|
||||
public class MainCommands implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package me.skymc.taboolib.commands.language;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.string.language2.Language2Value;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -7,10 +10,6 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.string.language2.Language2Value;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月13日 下午5:11:01
|
||||
@@ -30,7 +29,7 @@ public class Language2Command implements CommandExecutor {
|
||||
else if (args[0].equalsIgnoreCase("reload")) {
|
||||
MsgUtils.send(sender, "§7重载中..");
|
||||
long time = System.currentTimeMillis();
|
||||
Main.getExampleLanguage2().reload();
|
||||
Main.getExampleLanguage2().reload();
|
||||
MsgUtils.send(sender, "§7重载完成! 耗时: &f" + (System.currentTimeMillis() - time) + "ms");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("send")) {
|
||||
@@ -42,7 +41,7 @@ public class Language2Command implements CommandExecutor {
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
// 获取语言文件
|
||||
Language2Value value = Main.getExampleLanguage2().get(args[2]);
|
||||
Language2Value value = Main.getExampleLanguage2().get(args[2]);
|
||||
// 如果有变量参数
|
||||
if (args.length > 3) {
|
||||
int i = 0;
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.jsonformatter.JSONFormatter;
|
||||
import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -17,10 +11,10 @@ public class AttributesCommand extends SubCommand {
|
||||
public AttributesCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.ATTRIBUTES.HEAD");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.ATTRIBUTES.HEAD");
|
||||
|
||||
Arrays.stream(new String[] { "damage", "speed", "attackspeed", "health", "knockback", "armor", "luck" }).forEach(attribute -> TLocale.sendTo(sender, "COMMANDS.TABOOLIB.ATTRIBUTES.BODY", attribute));
|
||||
Arrays.stream(new String[]{"damage", "speed", "attackspeed", "health", "knockback", "armor", "luck"}).forEach(attribute -> TLocale.sendTo(sender, "COMMANDS.TABOOLIB.ATTRIBUTES.BODY", attribute));
|
||||
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.ATTRIBUTES.FOOT");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.ATTRIBUTES.FOOT");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.jsonformatter.JSONFormatter;
|
||||
import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -18,10 +12,10 @@ public class FlagCommand extends SubCommand {
|
||||
public FlagCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.FLAGS.HEAD");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.FLAGS.HEAD");
|
||||
|
||||
Arrays.stream(ItemFlag.values()).forEach(itemFlag -> TLocale.sendTo(sender, "COMMANDS.TABOOLIB.ENCHANTS.BODY", itemFlag.name()));
|
||||
Arrays.stream(ItemFlag.values()).forEach(itemFlag -> TLocale.sendTo(sender, "COMMANDS.TABOOLIB.ENCHANTS.BODY", itemFlag.name()));
|
||||
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.FLAGS.FOOT");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.FLAGS.FOOT");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.Main.StorageType;
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ImportCommand extends SubCommand {
|
||||
|
||||
@@ -20,34 +17,34 @@ public class ImportCommand extends SubCommand {
|
||||
super(sender, args);
|
||||
|
||||
if (isPlayer()) {
|
||||
TLocale.sendTo(sender, "COMMANDS.GLOBAL.ONLY-PLAYER");
|
||||
return;
|
||||
}
|
||||
TLocale.sendTo(sender, "COMMANDS.GLOBAL.ONLY-PLAYER");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Main.getStorageType() == StorageType.LOCAL) {
|
||||
TLocale.Logger.warn("COMMANDS.GLOBAL.ONLY-STORAGE-SQL");
|
||||
return;
|
||||
}
|
||||
if (Main.getStorageType() == StorageType.LOCAL) {
|
||||
TLocale.Logger.warn("COMMANDS.GLOBAL.ONLY-STORAGE-SQL");
|
||||
return;
|
||||
}
|
||||
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.IMPORTDATA.CLEARING");
|
||||
Main.getConnection().truncateTable(Main.getTablePrefix() + "_playerdata");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.IMPORTDATA.CLEARING");
|
||||
Main.getConnection().truncateTable(Main.getTablePrefix() + "_playerdata");
|
||||
|
||||
if (!Main.getPlayerDataFolder().exists()) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.IMPORTDATA.EMPTYDATA");
|
||||
return;
|
||||
}
|
||||
if (!Main.getPlayerDataFolder().exists()) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.IMPORTDATA.EMPTYDATA");
|
||||
return;
|
||||
}
|
||||
|
||||
int size = Objects.requireNonNull(Main.getPlayerDataFolder().listFiles()).length;
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.IMPORTDATA.IMPORTING-START", String.valueOf(size));
|
||||
int size = Objects.requireNonNull(Main.getPlayerDataFolder().listFiles()).length;
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.IMPORTDATA.IMPORTING-START", String.valueOf(size));
|
||||
|
||||
int loop = 1;
|
||||
for (File file : Objects.requireNonNull(Main.getPlayerDataFolder().listFiles())) {
|
||||
Main.getConnection().intoValue(Main.getTablePrefix() + "_playerdata", file.getName().replace(".yml", ""), ConfigUtils.encodeYAML(YamlConfiguration.loadConfiguration(file)));
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.IMPORTDATA.IMPORTING-PROGRESS", file.getName().replace(".yml", ""), String.valueOf(loop), String.valueOf(size));
|
||||
loop++;
|
||||
}
|
||||
int loop = 1;
|
||||
for (File file : Objects.requireNonNull(Main.getPlayerDataFolder().listFiles())) {
|
||||
Main.getConnection().intoValue(Main.getTablePrefix() + "_playerdata", file.getName().replace(".yml", ""), ConfigUtils.encodeYAML(YamlConfiguration.loadConfiguration(file)));
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.IMPORTDATA.IMPORTING-PROGRESS", file.getName().replace(".yml", ""), String.valueOf(loop), String.valueOf(size));
|
||||
loop++;
|
||||
}
|
||||
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.IMPORTDATA.SUCCESS");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.IMPORTDATA.SUCCESS");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package me.skymc.taboolib.commands.sub;
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.other.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.jsonformatter.JSONFormatter;
|
||||
import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class PotionCommand extends SubCommand {
|
||||
|
||||
@@ -19,7 +11,7 @@ public class PotionCommand extends SubCommand {
|
||||
public PotionCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.POTIONS.HEAD");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.POTIONS.HEAD");
|
||||
|
||||
for (PotionEffectType potionEffectType : PotionEffectType.values()) {
|
||||
if (potionEffectType != null) {
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.jsonformatter.JSONFormatter;
|
||||
import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent;
|
||||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -16,10 +11,10 @@ public class SlotCommand extends SubCommand {
|
||||
public SlotCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.SLOTS.HEAD");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.SLOTS.HEAD");
|
||||
|
||||
Arrays.stream(new String[] { "mainhand", "offhand", "feet", "legs", "chest", "head", "all" }).forEach(slots -> TLocale.sendTo(sender, "COMMANDS.TABOOLIB.SLOTS.BODY", slots));
|
||||
Arrays.stream(new String[]{"mainhand", "offhand", "feet", "legs", "chest", "head", "all"}).forEach(slots -> TLocale.sendTo(sender, "COMMANDS.TABOOLIB.SLOTS.BODY", slots));
|
||||
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.SLOTS.FOOT");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.SLOTS.FOOT");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.database.GlobalDataManager;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class VariableGetCommand extends SubCommand {
|
||||
|
||||
@@ -13,13 +11,13 @@ public class VariableGetCommand extends SubCommand {
|
||||
super(sender, args);
|
||||
|
||||
if (args.length < 3) {
|
||||
TLocale.sendTo(sender, "COAMMNDS.PARAMETER.INSUFFICIENT");
|
||||
return;
|
||||
}
|
||||
TLocale.sendTo(sender, "COAMMNDS.PARAMETER.INSUFFICIENT");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(args[1].equals("-a") || args[1].equals("-s"))) {
|
||||
TLocale.sendTo(sender, "COAMMNDS.TABOOLIB.VARIABLE.READ-ERROR-TYPE");
|
||||
return;
|
||||
if (!(args[1].equals("-a") || args[1].equals("-s"))) {
|
||||
TLocale.sendTo(sender, "COAMMNDS.TABOOLIB.VARIABLE.READ-ERROR-TYPE");
|
||||
return;
|
||||
}
|
||||
|
||||
Long time = System.currentTimeMillis();
|
||||
@@ -32,7 +30,7 @@ public class VariableGetCommand extends SubCommand {
|
||||
value = GlobalDataManager.getVariableAsynchronous(args[2], null);
|
||||
}
|
||||
|
||||
TLocale.sendTo(sender, "COAMMNDS.TABOOLIB.VARIABLE.READ-SUCCESS", String.valueOf(System.currentTimeMillis() - time));
|
||||
TLocale.sendTo(sender, "COAMMNDS.TABOOLIB.VARIABLE.READ-RESULT", value == null ? "null" : value);
|
||||
TLocale.sendTo(sender, "COAMMNDS.TABOOLIB.VARIABLE.READ-SUCCESS", String.valueOf(System.currentTimeMillis() - time));
|
||||
TLocale.sendTo(sender, "COAMMNDS.TABOOLIB.VARIABLE.READ-RESULT", value == null ? "null" : value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.database.GlobalDataManager;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class VariableSetCommand extends SubCommand {
|
||||
|
||||
@@ -13,13 +11,13 @@ public class VariableSetCommand extends SubCommand {
|
||||
super(sender, args);
|
||||
|
||||
if (args.length < 4) {
|
||||
TLocale.sendTo(sender, "COAMMNDS.PARAMETER.INSUFFICIENT");
|
||||
return;
|
||||
}
|
||||
TLocale.sendTo(sender, "COAMMNDS.PARAMETER.INSUFFICIENT");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(args[1].equals("-a") || args[1].equals("-s"))) {
|
||||
if (!(args[1].equals("-a") || args[1].equals("-s"))) {
|
||||
TLocale.sendTo(sender, "COAMMNDS.TABOOLIB.VARIABLE.WRITE-ERROR-TYPE");
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
Long time = System.currentTimeMillis();
|
||||
|
||||
@@ -62,6 +62,16 @@ public class ItemLibraryPatch implements Listener {
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
private static ItemStack getItem(HashMap<String, ItemStack> map, String name) {
|
||||
ItemStack item = map.get(name).clone();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
||||
lore.addAll(TLocale.asStringList("COMMANDS.TABOOLIB.ITEMLIST.MENU.LORE", name));
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inventoryClick(InventoryClickEvent e) {
|
||||
if (e.getInventory().getHolder() instanceof ItemLibraryHolder) {
|
||||
@@ -82,16 +92,6 @@ public class ItemLibraryPatch implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private static ItemStack getItem(HashMap<String, ItemStack> map, String name) {
|
||||
ItemStack item = map.get(name).clone();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
||||
lore.addAll(TLocale.asStringList("COMMANDS.TABOOLIB.ITEMLIST.MENU.LORE", name));
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static class ItemLibraryHolder implements InventoryHolder {
|
||||
|
||||
public final int PAGE;
|
||||
|
||||
@@ -2,7 +2,6 @@ package me.skymc.taboolib.commands.sub.shell;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class ShellCommand extends SubCommand {
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
package me.skymc.taboolib.commands.sub.shell;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.javashell.JavaShell;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ShellLoadCommand extends SubCommand {
|
||||
|
||||
public ShellLoadCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
if (args.length < 3) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.JAVASHELL.INVALID-NAME");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.JAVASHELL.INVALID-NAME");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(JavaShell.getScriptFolder(), args[2].contains(".java") ? args[2] : args[2] + ".java");
|
||||
if (!file.exists()) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.JAVASHELL.INVALID-SHELL", args[2]);
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.JAVASHELL.INVALID-SHELL", args[2]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
package me.skymc.taboolib.commands.sub.shell;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.javashell.JavaShell;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ShellUnloadCommand extends SubCommand {
|
||||
|
||||
public ShellUnloadCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
if (args.length < 3) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.JAVASHELL.INVALID-NAME");
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.JAVASHELL.INVALID-NAME");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(JavaShell.getScriptFolder(), args[2].contains(".java") ? args[2] : args[2] + ".java");
|
||||
if (!file.exists()) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.JAVASHELL.INVALID-SHELL", args[2]);
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.JAVASHELL.INVALID-SHELL", args[2]);
|
||||
return;
|
||||
}
|
||||
|
||||
JavaShell.unloadShell(args[2]);
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.JAVASHELL.SUCCESS-UNLOAD", args[2]);
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.JAVASHELL.SUCCESS-UNLOAD", args[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package me.skymc.taboolib.commands.sub.sounds.listener;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import com.ilummc.tlib.resources.type.TLocaleJson;
|
||||
import me.skymc.taboolib.inventory.InventoryUtil;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.jsonformatter.JSONFormatter;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@@ -18,7 +15,6 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -66,6 +62,15 @@ public class SoundsLibraryPatch implements Listener {
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
private static ItemStack getSoundItem(String sound) {
|
||||
ItemStack item = new ItemStack(Material.MAP);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("§f§n" + sound);
|
||||
meta.setLore(TLocale.asStringList("COMMANDS.TABOOLIB.SOUNDS.MENU.LORE"));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inventoryClick(InventoryClickEvent e) {
|
||||
if (e.getInventory().getHolder() instanceof SoundLibraryHolder) {
|
||||
@@ -94,15 +99,6 @@ public class SoundsLibraryPatch implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private static ItemStack getSoundItem(String sound) {
|
||||
ItemStack item = new ItemStack(Material.MAP);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("§f§n" + sound);
|
||||
meta.setLore(TLocale.asStringList("COMMANDS.TABOOLIB.SOUNDS.MENU.LORE"));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static class SoundLibraryHolder implements InventoryHolder {
|
||||
|
||||
public final int PAGE;
|
||||
|
||||
@@ -242,17 +242,16 @@ public class CsvReader {
|
||||
return array;
|
||||
}
|
||||
|
||||
public void setHeaders(final String[] headers) {
|
||||
this.headersHolder.Headers = headers;
|
||||
this.headersHolder.IndexByName.clear();
|
||||
if (headers != null) {
|
||||
this.headersHolder.Length = headers.length;
|
||||
private static char hexToDec(final char c) {
|
||||
char c2;
|
||||
if (c >= 'a') {
|
||||
c2 = (char) (c - 'a' + '\n');
|
||||
} else if (c >= 'A') {
|
||||
c2 = (char) (c - 'A' + '\n');
|
||||
} else {
|
||||
this.headersHolder.Length = 0;
|
||||
}
|
||||
for (int i = 0; i < this.headersHolder.Length; ++i) {
|
||||
this.headersHolder.IndexByName.put(headers[i], i);
|
||||
c2 = (char) (c - '0');
|
||||
}
|
||||
return c2;
|
||||
}
|
||||
|
||||
public String[] getValues() throws IOException {
|
||||
@@ -282,6 +281,19 @@ public class CsvReader {
|
||||
return new CsvReader(new StringReader(s));
|
||||
}
|
||||
|
||||
public void setHeaders(final String[] headers) {
|
||||
this.headersHolder.Headers = headers;
|
||||
this.headersHolder.IndexByName.clear();
|
||||
if (headers != null) {
|
||||
this.headersHolder.Length = headers.length;
|
||||
} else {
|
||||
this.headersHolder.Length = 0;
|
||||
}
|
||||
for (int i = 0; i < this.headersHolder.Length; ++i) {
|
||||
this.headersHolder.IndexByName.put(headers[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean readRecord() throws IOException {
|
||||
this.checkClosed();
|
||||
this.columnsCount = 0;
|
||||
@@ -716,6 +728,35 @@ public class CsvReader {
|
||||
return this.hasReadNextLine;
|
||||
}
|
||||
|
||||
public boolean readHeaders() throws IOException {
|
||||
final boolean record = this.readRecord();
|
||||
this.headersHolder.Length = this.columnsCount;
|
||||
this.headersHolder.Headers = new String[this.columnsCount];
|
||||
for (int i = 0; i < this.headersHolder.Length; ++i) {
|
||||
final String value = this.get(i);
|
||||
this.headersHolder.Headers[i] = value;
|
||||
this.headersHolder.IndexByName.put(value, i);
|
||||
}
|
||||
if (record) {
|
||||
--this.currentRecord;
|
||||
}
|
||||
this.columnsCount = 0;
|
||||
return record;
|
||||
}
|
||||
|
||||
public String getHeader(final int n) throws IOException {
|
||||
this.checkClosed();
|
||||
if (n > -1 && n < this.headersHolder.Length) {
|
||||
return this.headersHolder.Headers[n];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean isQualified(final int n) throws IOException {
|
||||
this.checkClosed();
|
||||
return n < this.columnsCount && n > -1 && this.isQualified[n];
|
||||
}
|
||||
|
||||
private void checkDataLength() throws IOException {
|
||||
if (!this.initialized) {
|
||||
if (this.fileName != null) {
|
||||
@@ -749,79 +790,6 @@ public class CsvReader {
|
||||
this.dataBuffer.ColumnStart = 0;
|
||||
}
|
||||
|
||||
public boolean readHeaders() throws IOException {
|
||||
final boolean record = this.readRecord();
|
||||
this.headersHolder.Length = this.columnsCount;
|
||||
this.headersHolder.Headers = new String[this.columnsCount];
|
||||
for (int i = 0; i < this.headersHolder.Length; ++i) {
|
||||
final String value = this.get(i);
|
||||
this.headersHolder.Headers[i] = value;
|
||||
this.headersHolder.IndexByName.put(value, i);
|
||||
}
|
||||
if (record) {
|
||||
--this.currentRecord;
|
||||
}
|
||||
this.columnsCount = 0;
|
||||
return record;
|
||||
}
|
||||
|
||||
public String getHeader(final int n) throws IOException {
|
||||
this.checkClosed();
|
||||
if (n > -1 && n < this.headersHolder.Length) {
|
||||
return this.headersHolder.Headers[n];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean isQualified(final int n) throws IOException {
|
||||
this.checkClosed();
|
||||
return n < this.columnsCount && n > -1 && this.isQualified[n];
|
||||
}
|
||||
|
||||
public void endColumn() throws IOException {
|
||||
String s = "";
|
||||
if (this.startedColumn) {
|
||||
if (this.columnBuffer.Position == 0) {
|
||||
if (this.dataBuffer.ColumnStart < this.dataBuffer.Position) {
|
||||
int n = this.dataBuffer.Position - 1;
|
||||
if (this.userSettings.TrimWhitespace && !this.startedWithQualifier) {
|
||||
while (n >= this.dataBuffer.ColumnStart && (this.dataBuffer.Buffer[n] == ' ' || this.dataBuffer.Buffer[n] == '\t')) {
|
||||
--n;
|
||||
}
|
||||
}
|
||||
s = new String(this.dataBuffer.Buffer, this.dataBuffer.ColumnStart, n - this.dataBuffer.ColumnStart + 1);
|
||||
}
|
||||
} else {
|
||||
this.updateCurrentValue();
|
||||
int n2 = this.columnBuffer.Position - 1;
|
||||
if (this.userSettings.TrimWhitespace && !this.startedWithQualifier) {
|
||||
while (n2 >= 0 && (this.columnBuffer.Buffer[n2] == ' ' || this.columnBuffer.Buffer[n2] == ' ')) {
|
||||
--n2;
|
||||
}
|
||||
}
|
||||
s = new String(this.columnBuffer.Buffer, 0, n2 + 1);
|
||||
}
|
||||
}
|
||||
this.columnBuffer.Position = 0;
|
||||
this.startedColumn = false;
|
||||
if (this.columnsCount >= 100000 && this.userSettings.SafetySwitch) {
|
||||
this.close();
|
||||
throw new IOException("Maximum column count of 100,000 exceeded in record " + NumberFormat.getIntegerInstance().format(this.currentRecord) + ". Set the SafetySwitch property to false" + " if you're expecting more than 100,000 columns per record to" + " avoid this error.");
|
||||
}
|
||||
if (this.columnsCount == this.values.length) {
|
||||
final int n3 = this.values.length * 2;
|
||||
final String[] values = new String[n3];
|
||||
System.arraycopy(this.values, 0, values, 0, this.values.length);
|
||||
this.values = values;
|
||||
final boolean[] isQualified = new boolean[n3];
|
||||
System.arraycopy(this.isQualified, 0, isQualified, 0, this.isQualified.length);
|
||||
this.isQualified = isQualified;
|
||||
}
|
||||
this.values[this.columnsCount] = s;
|
||||
this.isQualified[this.columnsCount] = this.startedWithQualifier;
|
||||
++this.columnsCount;
|
||||
}
|
||||
|
||||
private void appendLetter(final char c) {
|
||||
if (this.columnBuffer.Position == this.columnBuffer.Buffer.length) {
|
||||
final char[] buffer = new char[this.columnBuffer.Buffer.length * 2];
|
||||
@@ -872,35 +840,48 @@ public class CsvReader {
|
||||
return record;
|
||||
}
|
||||
|
||||
public boolean skipLine() throws IOException {
|
||||
this.checkClosed();
|
||||
this.columnsCount = 0;
|
||||
boolean b = false;
|
||||
if (this.hasMoreData) {
|
||||
boolean b2 = false;
|
||||
do {
|
||||
if (this.dataBuffer.Position == this.dataBuffer.Count) {
|
||||
this.checkDataLength();
|
||||
} else {
|
||||
b = true;
|
||||
final char lastLetter = this.dataBuffer.Buffer[this.dataBuffer.Position];
|
||||
if (lastLetter == '\r' || lastLetter == '\n') {
|
||||
b2 = true;
|
||||
public void endColumn() throws IOException {
|
||||
String s = "";
|
||||
if (this.startedColumn) {
|
||||
if (this.columnBuffer.Position == 0) {
|
||||
if (this.dataBuffer.ColumnStart < this.dataBuffer.Position) {
|
||||
int n = this.dataBuffer.Position - 1;
|
||||
if (this.userSettings.TrimWhitespace && !this.startedWithQualifier) {
|
||||
while (n >= this.dataBuffer.ColumnStart && (this.dataBuffer.Buffer[n] == ' ' || this.dataBuffer.Buffer[n] == '\t')) {
|
||||
--n;
|
||||
}
|
||||
}
|
||||
this.lastLetter = lastLetter;
|
||||
if (b2) {
|
||||
continue;
|
||||
}
|
||||
final DataBuffer dataBuffer = this.dataBuffer;
|
||||
++dataBuffer.Position;
|
||||
s = new String(this.dataBuffer.Buffer, this.dataBuffer.ColumnStart, n - this.dataBuffer.ColumnStart + 1);
|
||||
}
|
||||
} while (this.hasMoreData && !b2);
|
||||
this.columnBuffer.Position = 0;
|
||||
this.dataBuffer.LineStart = this.dataBuffer.Position + 1;
|
||||
} else {
|
||||
this.updateCurrentValue();
|
||||
int n2 = this.columnBuffer.Position - 1;
|
||||
if (this.userSettings.TrimWhitespace && !this.startedWithQualifier) {
|
||||
while (n2 >= 0 && (this.columnBuffer.Buffer[n2] == ' ' || this.columnBuffer.Buffer[n2] == ' ')) {
|
||||
--n2;
|
||||
}
|
||||
}
|
||||
s = new String(this.columnBuffer.Buffer, 0, n2 + 1);
|
||||
}
|
||||
}
|
||||
this.rawBuffer.Position = 0;
|
||||
this.rawRecord = "";
|
||||
return b;
|
||||
this.columnBuffer.Position = 0;
|
||||
this.startedColumn = false;
|
||||
if (this.columnsCount >= 100000 && this.userSettings.SafetySwitch) {
|
||||
this.close();
|
||||
throw new IOException("Maximum column count of 100,000 exceeded in record " + NumberFormat.getIntegerInstance().format(this.currentRecord) + ". Set the SafetySwitch property to false" + " if you're expecting more than 100,000 columns per record to" + " avoid this error.");
|
||||
}
|
||||
if (this.columnsCount == this.values.length) {
|
||||
final int n3 = this.values.length * 2;
|
||||
final String[] values = new String[n3];
|
||||
System.arraycopy(this.values, 0, values, 0, this.values.length);
|
||||
this.values = values;
|
||||
final boolean[] isQualified = new boolean[n3];
|
||||
System.arraycopy(this.isQualified, 0, isQualified, 0, this.isQualified.length);
|
||||
this.isQualified = isQualified;
|
||||
}
|
||||
this.values[this.columnsCount] = s;
|
||||
this.isQualified[this.columnsCount] = this.startedWithQualifier;
|
||||
++this.columnsCount;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
@@ -937,23 +918,42 @@ public class CsvReader {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean skipLine() throws IOException {
|
||||
this.checkClosed();
|
||||
this.columnsCount = 0;
|
||||
boolean b = false;
|
||||
if (this.hasMoreData) {
|
||||
boolean b2 = false;
|
||||
do {
|
||||
if (this.dataBuffer.Position == this.dataBuffer.Count) {
|
||||
this.checkDataLength();
|
||||
} else {
|
||||
b = true;
|
||||
final char lastLetter = this.dataBuffer.Buffer[this.dataBuffer.Position];
|
||||
if (lastLetter == '\r' || lastLetter == '\n') {
|
||||
b2 = true;
|
||||
}
|
||||
this.lastLetter = lastLetter;
|
||||
if (b2) {
|
||||
continue;
|
||||
}
|
||||
final DataBuffer dataBuffer = this.dataBuffer;
|
||||
++dataBuffer.Position;
|
||||
}
|
||||
} while (this.hasMoreData && !b2);
|
||||
this.columnBuffer.Position = 0;
|
||||
this.dataBuffer.LineStart = this.dataBuffer.Position + 1;
|
||||
}
|
||||
this.rawBuffer.Position = 0;
|
||||
this.rawRecord = "";
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
this.close(false);
|
||||
}
|
||||
|
||||
private static char hexToDec(final char c) {
|
||||
char c2;
|
||||
if (c >= 'a') {
|
||||
c2 = (char) (c - 'a' + '\n');
|
||||
} else if (c >= 'A') {
|
||||
c2 = (char) (c - 'A' + '\n');
|
||||
} else {
|
||||
c2 = (char) (c - '0');
|
||||
}
|
||||
return c2;
|
||||
}
|
||||
|
||||
private class StaticSettings {
|
||||
public static final int MAX_BUFFER_SIZE = 1024;
|
||||
public static final int MAX_FILE_BUFFER_SIZE = 4096;
|
||||
|
||||
@@ -121,6 +121,27 @@ public class CsvWriter {
|
||||
this.userSettings.ForceQualifier = forceQualifier;
|
||||
}
|
||||
|
||||
public static String replace(final String s, final String s2, final String s3) {
|
||||
final int length = s2.length();
|
||||
int i = s.indexOf(s2);
|
||||
if (i > -1) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
int n;
|
||||
for (n = 0; i != -1; i = s.indexOf(s2, n)) {
|
||||
sb.append(s, n, i);
|
||||
sb.append(s3);
|
||||
n = i + length;
|
||||
}
|
||||
sb.append(s.substring(n));
|
||||
return sb.toString();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public void write(final String s) throws IOException {
|
||||
this.write(s, false);
|
||||
}
|
||||
|
||||
public void write(String s, final boolean b) throws IOException {
|
||||
this.checkClosed();
|
||||
this.checkInit();
|
||||
@@ -181,10 +202,6 @@ public class CsvWriter {
|
||||
this.firstColumn = false;
|
||||
}
|
||||
|
||||
public void write(final String s) throws IOException {
|
||||
this.write(s, false);
|
||||
}
|
||||
|
||||
public void writeComment(final String s) throws IOException {
|
||||
this.checkClosed();
|
||||
this.checkInit();
|
||||
@@ -198,23 +215,6 @@ public class CsvWriter {
|
||||
this.firstColumn = true;
|
||||
}
|
||||
|
||||
public static String replace(final String s, final String s2, final String s3) {
|
||||
final int length = s2.length();
|
||||
int i = s.indexOf(s2);
|
||||
if (i > -1) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
int n;
|
||||
for (n = 0; i != -1; i = s.indexOf(s2, n)) {
|
||||
sb.append(s.substring(n, i));
|
||||
sb.append(s3);
|
||||
n = i + length;
|
||||
}
|
||||
sb.append(s.substring(n));
|
||||
return sb.toString();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public void writeRecord(final String[] array) throws IOException {
|
||||
this.writeRecord(array, false);
|
||||
}
|
||||
|
||||
@@ -26,10 +26,6 @@ public class PlayerDataManager implements Listener {
|
||||
|
||||
private static final ConcurrentHashMap<String, FileConfiguration> PLAYER_DATA = new ConcurrentHashMap<>();
|
||||
|
||||
public enum UsernameType {
|
||||
UUID, USERNAME
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户储存方式
|
||||
*
|
||||
@@ -257,4 +253,8 @@ public class PlayerDataManager implements Listener {
|
||||
}.runTaskAsynchronously(Main.getInst());
|
||||
}
|
||||
}
|
||||
|
||||
public enum UsernameType {
|
||||
UUID, USERNAME
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,6 @@ public class EntityUtils implements Listener {
|
||||
return lastSpawnedEntity;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void spawn(EntitySpawnEvent e) {
|
||||
lastSpawnedEntity = e.getEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 UUID 获取生物
|
||||
*
|
||||
@@ -118,4 +113,9 @@ public class EntityUtils implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void spawn(EntitySpawnEvent e) {
|
||||
lastSpawnedEntity = e.getEntity();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ public class CustomBookOpenEvent extends Event implements Cancellable {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public ItemStack getBook() {
|
||||
return book;
|
||||
}
|
||||
|
||||
public void setHand(Hand hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public ItemStack getBook() {
|
||||
return book;
|
||||
}
|
||||
|
||||
public void setBook(ItemStack book) {
|
||||
this.book = book;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ public class PlayerJumpEvent extends Event implements Cancellable {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
@@ -34,8 +38,4 @@ public class PlayerJumpEvent extends Event implements Cancellable {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ public class PlayerLoadedEvent extends Event {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
@@ -22,8 +26,4 @@ public class PlayerLoadedEvent extends Event {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,87 +71,6 @@ public class FileUtils {
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件夹
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
public void deleteAllFile(File file) {
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
if (file.isFile()) {
|
||||
file.delete();
|
||||
return;
|
||||
}
|
||||
File[] files = file.listFiles();
|
||||
for (File file1 : files) {
|
||||
deleteAllFile(file1);
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制文件夹
|
||||
*
|
||||
* @param file1 文件1
|
||||
* @param file2 文件2
|
||||
* @throws Exception
|
||||
*/
|
||||
public void copyAllFile(String file1, String file2) throws Exception {
|
||||
File _file1 = new File(file1);
|
||||
File _file2 = new File(file2);
|
||||
if (!_file2.exists()) {
|
||||
if (!_file1.isDirectory()) {
|
||||
_file2.createNewFile();
|
||||
} else {
|
||||
_file2.mkdirs();
|
||||
}
|
||||
}
|
||||
if (_file1.isDirectory()) {
|
||||
for (File file : _file1.listFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
copyAllFile(file.getAbsolutePath(), file2 + "/" + file.getName());
|
||||
} else {
|
||||
fileChannelCopy(file, new File(file2 + "/" + file.getName()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fileChannelCopy(_file1, _file2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制文件(通道)
|
||||
*
|
||||
* @param file1 文件1
|
||||
* @param file2 文件2
|
||||
*/
|
||||
public void fileChannelCopy(File file1, File file2) {
|
||||
FileInputStream fileIn = null;
|
||||
FileOutputStream fileOut = null;
|
||||
FileChannel channelIn = null;
|
||||
FileChannel channelOut = null;
|
||||
try {
|
||||
fileIn = new FileInputStream(file1);
|
||||
fileOut = new FileOutputStream(file2);
|
||||
channelIn = fileIn.getChannel();
|
||||
channelOut = fileOut.getChannel();
|
||||
channelIn.transferTo(0, channelIn.size(), channelOut);
|
||||
} catch (Exception e) {
|
||||
//
|
||||
} finally {
|
||||
try {
|
||||
fileIn.close();
|
||||
channelIn.close();
|
||||
fileOut.close();
|
||||
channelOut.close();
|
||||
} catch (Exception e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过输入流读取文本
|
||||
*
|
||||
@@ -307,4 +226,85 @@ public class FileUtils {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件夹
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
public void deleteAllFile(File file) {
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
if (file.isFile()) {
|
||||
file.delete();
|
||||
return;
|
||||
}
|
||||
File[] files = file.listFiles();
|
||||
for (File file1 : files) {
|
||||
deleteAllFile(file1);
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制文件夹
|
||||
*
|
||||
* @param file1 文件1
|
||||
* @param file2 文件2
|
||||
* @throws Exception
|
||||
*/
|
||||
public void copyAllFile(String file1, String file2) throws Exception {
|
||||
File _file1 = new File(file1);
|
||||
File _file2 = new File(file2);
|
||||
if (!_file2.exists()) {
|
||||
if (!_file1.isDirectory()) {
|
||||
_file2.createNewFile();
|
||||
} else {
|
||||
_file2.mkdirs();
|
||||
}
|
||||
}
|
||||
if (_file1.isDirectory()) {
|
||||
for (File file : _file1.listFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
copyAllFile(file.getAbsolutePath(), file2 + "/" + file.getName());
|
||||
} else {
|
||||
fileChannelCopy(file, new File(file2 + "/" + file.getName()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fileChannelCopy(_file1, _file2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制文件(通道)
|
||||
*
|
||||
* @param file1 文件1
|
||||
* @param file2 文件2
|
||||
*/
|
||||
public void fileChannelCopy(File file1, File file2) {
|
||||
FileInputStream fileIn = null;
|
||||
FileOutputStream fileOut = null;
|
||||
FileChannel channelIn = null;
|
||||
FileChannel channelOut = null;
|
||||
try {
|
||||
fileIn = new FileInputStream(file1);
|
||||
fileOut = new FileOutputStream(file2);
|
||||
channelIn = fileIn.getChannel();
|
||||
channelOut = fileOut.getChannel();
|
||||
channelIn.transferTo(0, channelIn.size(), channelOut);
|
||||
} catch (Exception e) {
|
||||
//
|
||||
} finally {
|
||||
try {
|
||||
fileIn.close();
|
||||
channelIn.close();
|
||||
fileOut.close();
|
||||
channelOut.close();
|
||||
} catch (Exception e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,10 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class ItemUtils {
|
||||
|
||||
@@ -27,10 +27,6 @@ public class SpecialItem implements Listener {
|
||||
|
||||
private boolean isLoaded;
|
||||
|
||||
public boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
@@ -56,6 +52,10 @@ public class SpecialItem implements Listener {
|
||||
return specialItem;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册接口
|
||||
*
|
||||
|
||||
@@ -11,14 +11,12 @@ public class NBTItem extends NBTCompound {
|
||||
bukkitItem = item.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getCompound() {
|
||||
return NBTReflectionUtil.getItemRootNBTTagCompound(NBTReflectionUtil.getNMSItemStack(bukkitItem));
|
||||
public static NBTContainer convertItemtoNBT(ItemStack item) {
|
||||
return NBTReflectionUtil.convertNMSItemtoNBTCompound(NBTReflectionUtil.getNMSItemStack(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setCompound(Object compound) {
|
||||
bukkitItem = NBTReflectionUtil.getBukkitItemStack(NBTReflectionUtil.setNBTTag(compound, NBTReflectionUtil.getNMSItemStack(bukkitItem)));
|
||||
public static ItemStack convertNBTtoItem(NBTCompound comp) {
|
||||
return NBTReflectionUtil.getBukkitItemStack(NBTReflectionUtil.convertNBTCompoundtoNMSItem(comp));
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
@@ -29,12 +27,14 @@ public class NBTItem extends NBTCompound {
|
||||
bukkitItem = item;
|
||||
}
|
||||
|
||||
public static NBTContainer convertItemtoNBT(ItemStack item) {
|
||||
return NBTReflectionUtil.convertNMSItemtoNBTCompound(NBTReflectionUtil.getNMSItemStack(item));
|
||||
@Override
|
||||
protected Object getCompound() {
|
||||
return NBTReflectionUtil.getItemRootNBTTagCompound(NBTReflectionUtil.getNMSItemStack(bukkitItem));
|
||||
}
|
||||
|
||||
public static ItemStack convertNBTtoItem(NBTCompound comp) {
|
||||
return NBTReflectionUtil.getBukkitItemStack(NBTReflectionUtil.convertNBTCompoundtoNMSItem(comp));
|
||||
@Override
|
||||
protected void setCompound(Object compound) {
|
||||
bukkitItem = NBTReflectionUtil.getBukkitItemStack(NBTReflectionUtil.setNBTTag(compound, NBTReflectionUtil.getNMSItemStack(bukkitItem)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,41 +11,8 @@ import java.util.*;
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public class JSONObject {
|
||||
|
||||
private static final class Null {
|
||||
|
||||
@Override
|
||||
protected final Object clone() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object == null || object == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
private final Map map;
|
||||
|
||||
public static final Object NULL = new Null();
|
||||
|
||||
public JSONObject() {
|
||||
this.map = new HashMap();
|
||||
}
|
||||
|
||||
public JSONObject(JSONObject jo, String[] names) {
|
||||
this();
|
||||
for (String name : names) {
|
||||
try {
|
||||
this.putOnce(name, jo.opt(name));
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
private final Map map;
|
||||
|
||||
public JSONObject(JSONTokener x) throws JSONException {
|
||||
this();
|
||||
@@ -91,6 +58,45 @@ public class JSONObject {
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject() {
|
||||
this.map = new HashMap();
|
||||
}
|
||||
|
||||
public JSONObject(JSONObject jo, String[] names) {
|
||||
this();
|
||||
for (String name : names) {
|
||||
try {
|
||||
this.putOnce(name, jo.opt(name));
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject(String baseName, Locale locale) throws JSONException {
|
||||
this();
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale,
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
Enumeration keys = bundle.getKeys();
|
||||
while (keys.hasMoreElements()) {
|
||||
Object key = keys.nextElement();
|
||||
if (key instanceof String) {
|
||||
String[] path = ((String) key).split("\\.");
|
||||
int last = path.length - 1;
|
||||
JSONObject target = this;
|
||||
for (int i = 0; i < last; i += 1) {
|
||||
String segment = path[i];
|
||||
JSONObject nextTarget = target.optJSONObject(segment);
|
||||
if (nextTarget == null) {
|
||||
nextTarget = new JSONObject();
|
||||
target.put(segment, nextTarget);
|
||||
}
|
||||
target = nextTarget;
|
||||
}
|
||||
target.put(path[last], bundle.getString((String) key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject(Map map) {
|
||||
this.map = new HashMap();
|
||||
if (map != null) {
|
||||
@@ -124,29 +130,228 @@ public class JSONObject {
|
||||
this(new JSONTokener(source));
|
||||
}
|
||||
|
||||
public JSONObject(String baseName, Locale locale) throws JSONException {
|
||||
this();
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale,
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
Enumeration keys = bundle.getKeys();
|
||||
while (keys.hasMoreElements()) {
|
||||
Object key = keys.nextElement();
|
||||
if (key instanceof String) {
|
||||
String[] path = ((String) key).split("\\.");
|
||||
int last = path.length - 1;
|
||||
JSONObject target = this;
|
||||
for (int i = 0; i < last; i += 1) {
|
||||
String segment = path[i];
|
||||
JSONObject nextTarget = target.optJSONObject(segment);
|
||||
if (nextTarget == null) {
|
||||
nextTarget = new JSONObject();
|
||||
target.put(segment, nextTarget);
|
||||
public static String[] getNames(JSONObject jo) {
|
||||
int length = jo.length();
|
||||
if (length == 0) {
|
||||
return null;
|
||||
}
|
||||
Iterator iterator = jo.keys();
|
||||
String[] names = new String[length];
|
||||
int i = 0;
|
||||
while (iterator.hasNext()) {
|
||||
names[i] = (String) iterator.next();
|
||||
i += 1;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static String valueToString(Object value) throws JSONException {
|
||||
if (value == null || value == null) {
|
||||
return "null";
|
||||
}
|
||||
if (value instanceof JSONString) {
|
||||
Object object;
|
||||
try {
|
||||
object = ((JSONString) value).toJSONString();
|
||||
} catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
if (object != null) {
|
||||
return (String) object;
|
||||
}
|
||||
throw new JSONException("Bad value from toJSONString: " + object);
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return numberToString((Number) value);
|
||||
}
|
||||
if (value instanceof Boolean || value instanceof JSONObject ||
|
||||
value instanceof JSONArray) {
|
||||
return value.toString();
|
||||
}
|
||||
if (value instanceof Map) {
|
||||
return new JSONObject((Map) value).toString();
|
||||
}
|
||||
if (value instanceof Collection) {
|
||||
return new JSONArray((Collection) value).toString();
|
||||
}
|
||||
if (value.getClass().isArray()) {
|
||||
return new JSONArray(value).toString();
|
||||
}
|
||||
return quote(value.toString());
|
||||
}
|
||||
|
||||
public static Writer quote(String string, Writer w) throws IOException {
|
||||
if (string == null || string.length() == 0) {
|
||||
w.write("\"\"");
|
||||
return w;
|
||||
}
|
||||
|
||||
char b;
|
||||
char c = 0;
|
||||
String hhhh;
|
||||
int i;
|
||||
int len = string.length();
|
||||
|
||||
w.write('"');
|
||||
for (i = 0; i < len; i += 1) {
|
||||
b = c;
|
||||
c = string.charAt(i);
|
||||
switch (c) {
|
||||
case '\\':
|
||||
case '"':
|
||||
w.write('\\');
|
||||
w.write(c);
|
||||
break;
|
||||
case '/':
|
||||
if (b == '<') {
|
||||
w.write('\\');
|
||||
}
|
||||
w.write(c);
|
||||
break;
|
||||
case '\b':
|
||||
w.write("\\b");
|
||||
break;
|
||||
case '\t':
|
||||
w.write("\\t");
|
||||
break;
|
||||
case '\n':
|
||||
w.write("\\n");
|
||||
break;
|
||||
case '\f':
|
||||
w.write("\\f");
|
||||
break;
|
||||
case '\r':
|
||||
w.write("\\r");
|
||||
break;
|
||||
default:
|
||||
if (c < ' ' || (c >= '\u0080' && c < '\u00a0')
|
||||
|| (c >= '\u2000' && c < '\u2100')) {
|
||||
hhhh = "000" + Integer.toHexString(c);
|
||||
w.write("\\u" + hhhh.substring(hhhh.length() - 4));
|
||||
} else {
|
||||
w.write(c);
|
||||
}
|
||||
target = nextTarget;
|
||||
}
|
||||
target.put(path[last], bundle.getString((String) key));
|
||||
}
|
||||
}
|
||||
w.write('"');
|
||||
return w;
|
||||
}
|
||||
|
||||
public static String doubleToString(double d) {
|
||||
if (Double.isInfinite(d) || Double.isNaN(d)) {
|
||||
return "null";
|
||||
}
|
||||
String string = Double.toString(d);
|
||||
if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
|
||||
string.indexOf('E') < 0) {
|
||||
while (string.endsWith("0")) {
|
||||
string = string.substring(0, string.length() - 1);
|
||||
}
|
||||
if (string.endsWith(".")) {
|
||||
string = string.substring(0, string.length() - 1);
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
static void writeValue(Writer writer, Object value, int indentFactor, int indent) throws JSONException, IOException {
|
||||
if (value == null) {
|
||||
writer.write("null");
|
||||
} else if (value instanceof JSONObject) {
|
||||
((JSONObject) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof JSONArray) {
|
||||
((JSONArray) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Map) {
|
||||
new JSONObject((Map) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Collection) {
|
||||
new JSONArray((Collection) value).write(writer, indentFactor,
|
||||
indent);
|
||||
} else if (value.getClass().isArray()) {
|
||||
new JSONArray(value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Number) {
|
||||
writer.write(numberToString((Number) value));
|
||||
} else if (value instanceof Boolean) {
|
||||
writer.write(value.toString());
|
||||
} else if (value instanceof JSONString) {
|
||||
Object o;
|
||||
try {
|
||||
o = ((JSONString) value).toJSONString();
|
||||
} catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
writer.write(o != null ? o.toString() : quote(value.toString()));
|
||||
} else {
|
||||
quote(value.toString(), writer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void testValidity(Object o) throws JSONException {
|
||||
if (o != null) {
|
||||
if (o instanceof Double) {
|
||||
if (((Double) o).isInfinite() || ((Double) o).isNaN()) {
|
||||
throw new JSONException(
|
||||
"JSON does not allow non-finite numbers.");
|
||||
}
|
||||
} else if (o instanceof Float) {
|
||||
if (((Float) o).isInfinite() || ((Float) o).isNaN()) {
|
||||
throw new JSONException(
|
||||
"JSON does not allow non-finite numbers.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Object wrap(Object object) {
|
||||
try {
|
||||
if (object == null) {
|
||||
return NULL;
|
||||
}
|
||||
if (object instanceof JSONObject || object instanceof JSONArray ||
|
||||
NULL.equals(object) || object instanceof JSONString ||
|
||||
object instanceof Byte || object instanceof Character ||
|
||||
object instanceof Short || object instanceof Integer ||
|
||||
object instanceof Long || object instanceof Boolean ||
|
||||
object instanceof Float || object instanceof Double ||
|
||||
object instanceof String || object instanceof Enum) {
|
||||
return object;
|
||||
}
|
||||
|
||||
if (object instanceof Collection) {
|
||||
return new JSONArray((Collection) object);
|
||||
}
|
||||
if (object.getClass().isArray()) {
|
||||
return new JSONArray(object);
|
||||
}
|
||||
if (object instanceof Map) {
|
||||
return new JSONObject((Map) object);
|
||||
}
|
||||
Package objectPackage = object.getClass().getPackage();
|
||||
String objectPackageName = objectPackage != null
|
||||
? objectPackage.getName()
|
||||
: "";
|
||||
if (
|
||||
objectPackageName.startsWith("java.") ||
|
||||
objectPackageName.startsWith("javax.") ||
|
||||
object.getClass().getClassLoader() == null
|
||||
) {
|
||||
return object.toString();
|
||||
}
|
||||
return new JSONObject(object);
|
||||
} catch (Exception exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object get(String key) throws JSONException {
|
||||
if (key == null) {
|
||||
throw new JSONException("Null key.");
|
||||
}
|
||||
Object object = this.opt(key);
|
||||
if (object == null) {
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] not found.");
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public void accumulate(String key, Object value) throws JSONException {
|
||||
@@ -177,35 +382,6 @@ public class JSONObject {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static String doubleToString(double d) {
|
||||
if (Double.isInfinite(d) || Double.isNaN(d)) {
|
||||
return "null";
|
||||
}
|
||||
String string = Double.toString(d);
|
||||
if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
|
||||
string.indexOf('E') < 0) {
|
||||
while (string.endsWith("0")) {
|
||||
string = string.substring(0, string.length() - 1);
|
||||
}
|
||||
if (string.endsWith(".")) {
|
||||
string = string.substring(0, string.length() - 1);
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public Object get(String key) throws JSONException {
|
||||
if (key == null) {
|
||||
throw new JSONException("Null key.");
|
||||
}
|
||||
Object object = this.opt(key);
|
||||
if (object == null) {
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] not found.");
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public boolean getBoolean(String key) throws JSONException {
|
||||
Object object = this.get(key);
|
||||
if (object.equals(Boolean.FALSE) ||
|
||||
@@ -233,63 +409,6 @@ public class JSONObject {
|
||||
}
|
||||
}
|
||||
|
||||
public int getInt(String key) throws JSONException {
|
||||
Object object = this.get(key);
|
||||
try {
|
||||
return object instanceof Number
|
||||
? ((Number) object).intValue()
|
||||
: Integer.parseInt((String) object);
|
||||
} catch (Exception e) {
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] is not an int.");
|
||||
}
|
||||
}
|
||||
|
||||
public JSONArray getJSONArray(String key) throws JSONException {
|
||||
Object object = this.get(key);
|
||||
if (object instanceof JSONArray) {
|
||||
return (JSONArray) object;
|
||||
}
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] is not a JSONArray.");
|
||||
}
|
||||
|
||||
public JSONObject getJSONObject(String key) throws JSONException {
|
||||
Object object = this.get(key);
|
||||
if (object instanceof JSONObject) {
|
||||
return (JSONObject) object;
|
||||
}
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] is not a JSONObject.");
|
||||
}
|
||||
|
||||
public long getLong(String key) throws JSONException {
|
||||
Object object = this.get(key);
|
||||
try {
|
||||
return object instanceof Number
|
||||
? ((Number) object).longValue()
|
||||
: Long.parseLong((String) object);
|
||||
} catch (Exception e) {
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] is not a long.");
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] getNames(JSONObject jo) {
|
||||
int length = jo.length();
|
||||
if (length == 0) {
|
||||
return null;
|
||||
}
|
||||
Iterator iterator = jo.keys();
|
||||
String[] names = new String[length];
|
||||
int i = 0;
|
||||
while (iterator.hasNext()) {
|
||||
names[i] = (String) iterator.next();
|
||||
i += 1;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static String[] getNames(Object object) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
@@ -307,13 +426,16 @@ public class JSONObject {
|
||||
return names;
|
||||
}
|
||||
|
||||
public String getString(String key) throws JSONException {
|
||||
public int getInt(String key) throws JSONException {
|
||||
Object object = this.get(key);
|
||||
if (object instanceof String) {
|
||||
return (String) object;
|
||||
try {
|
||||
return object instanceof Number
|
||||
? ((Number) object).intValue()
|
||||
: Integer.parseInt((String) object);
|
||||
} catch (Exception e) {
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] is not an int.");
|
||||
}
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] not a string.");
|
||||
}
|
||||
|
||||
public boolean has(String key) {
|
||||
@@ -369,13 +491,13 @@ public class JSONObject {
|
||||
return this.map.size();
|
||||
}
|
||||
|
||||
public JSONArray names() {
|
||||
JSONArray ja = new JSONArray();
|
||||
Iterator keys = this.keys();
|
||||
while (keys.hasNext()) {
|
||||
ja.put(keys.next());
|
||||
public JSONArray getJSONArray(String key) throws JSONException {
|
||||
Object object = this.get(key);
|
||||
if (object instanceof JSONArray) {
|
||||
return (JSONArray) object;
|
||||
}
|
||||
return ja.length() == 0 ? null : ja;
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] is not a JSONArray.");
|
||||
}
|
||||
|
||||
public static String numberToString(Number number)
|
||||
@@ -437,14 +559,25 @@ public class JSONObject {
|
||||
}
|
||||
}
|
||||
|
||||
public JSONArray optJSONArray(String key) {
|
||||
Object o = this.opt(key);
|
||||
return o instanceof JSONArray ? (JSONArray) o : null;
|
||||
public JSONObject getJSONObject(String key) throws JSONException {
|
||||
Object object = this.get(key);
|
||||
if (object instanceof JSONObject) {
|
||||
return (JSONObject) object;
|
||||
}
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] is not a JSONObject.");
|
||||
}
|
||||
|
||||
public JSONObject optJSONObject(String key) {
|
||||
Object object = this.opt(key);
|
||||
return object instanceof JSONObject ? (JSONObject) object : null;
|
||||
public long getLong(String key) throws JSONException {
|
||||
Object object = this.get(key);
|
||||
try {
|
||||
return object instanceof Number
|
||||
? ((Number) object).longValue()
|
||||
: Long.parseLong((String) object);
|
||||
} catch (Exception e) {
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] is not a long.");
|
||||
}
|
||||
}
|
||||
|
||||
public long optLong(String key) {
|
||||
@@ -468,39 +601,13 @@ public class JSONObject {
|
||||
return NULL.equals(object) ? defaultValue : object.toString();
|
||||
}
|
||||
|
||||
public static String valueToString(Object value) throws JSONException {
|
||||
if (value == null || value == null) {
|
||||
return "null";
|
||||
public String getString(String key) throws JSONException {
|
||||
Object object = this.get(key);
|
||||
if (object instanceof String) {
|
||||
return (String) object;
|
||||
}
|
||||
if (value instanceof JSONString) {
|
||||
Object object;
|
||||
try {
|
||||
object = ((JSONString) value).toJSONString();
|
||||
} catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
if (object != null) {
|
||||
return (String) object;
|
||||
}
|
||||
throw new JSONException("Bad value from toJSONString: " + object);
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return numberToString((Number) value);
|
||||
}
|
||||
if (value instanceof Boolean || value instanceof JSONObject ||
|
||||
value instanceof JSONArray) {
|
||||
return value.toString();
|
||||
}
|
||||
if (value instanceof Map) {
|
||||
return new JSONObject((Map) value).toString();
|
||||
}
|
||||
if (value instanceof Collection) {
|
||||
return new JSONArray((Collection) value).toString();
|
||||
}
|
||||
if (value.getClass().isArray()) {
|
||||
return new JSONArray(value).toString();
|
||||
}
|
||||
return quote(value.toString());
|
||||
throw new JSONException("JSONObject[" + quote(key) +
|
||||
"] not a string.");
|
||||
}
|
||||
|
||||
public JSONObject put(String key, boolean value) throws JSONException {
|
||||
@@ -574,112 +681,27 @@ public class JSONObject {
|
||||
}
|
||||
}
|
||||
|
||||
public static Writer quote(String string, Writer w) throws IOException {
|
||||
if (string == null || string.length() == 0) {
|
||||
w.write("\"\"");
|
||||
return w;
|
||||
public JSONArray names() {
|
||||
JSONArray ja = new JSONArray();
|
||||
Iterator keys = this.keys();
|
||||
while (keys.hasNext()) {
|
||||
ja.put(keys.next());
|
||||
}
|
||||
|
||||
char b;
|
||||
char c = 0;
|
||||
String hhhh;
|
||||
int i;
|
||||
int len = string.length();
|
||||
|
||||
w.write('"');
|
||||
for (i = 0; i < len; i += 1) {
|
||||
b = c;
|
||||
c = string.charAt(i);
|
||||
switch (c) {
|
||||
case '\\':
|
||||
case '"':
|
||||
w.write('\\');
|
||||
w.write(c);
|
||||
break;
|
||||
case '/':
|
||||
if (b == '<') {
|
||||
w.write('\\');
|
||||
}
|
||||
w.write(c);
|
||||
break;
|
||||
case '\b':
|
||||
w.write("\\b");
|
||||
break;
|
||||
case '\t':
|
||||
w.write("\\t");
|
||||
break;
|
||||
case '\n':
|
||||
w.write("\\n");
|
||||
break;
|
||||
case '\f':
|
||||
w.write("\\f");
|
||||
break;
|
||||
case '\r':
|
||||
w.write("\\r");
|
||||
break;
|
||||
default:
|
||||
if (c < ' ' || (c >= '\u0080' && c < '\u00a0')
|
||||
|| (c >= '\u2000' && c < '\u2100')) {
|
||||
hhhh = "000" + Integer.toHexString(c);
|
||||
w.write("\\u" + hhhh.substring(hhhh.length() - 4));
|
||||
} else {
|
||||
w.write(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
w.write('"');
|
||||
return w;
|
||||
return ja.length() == 0 ? null : ja;
|
||||
}
|
||||
|
||||
public Object remove(String key) {
|
||||
return this.map.remove(key);
|
||||
}
|
||||
|
||||
static void writeValue(Writer writer, Object value, int indentFactor, int indent) throws JSONException, IOException {
|
||||
if (value == null) {
|
||||
writer.write("null");
|
||||
} else if (value instanceof JSONObject) {
|
||||
((JSONObject) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof JSONArray) {
|
||||
((JSONArray) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Map) {
|
||||
new JSONObject((Map) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Collection) {
|
||||
new JSONArray((Collection) value).write(writer, indentFactor,
|
||||
indent);
|
||||
} else if (value.getClass().isArray()) {
|
||||
new JSONArray(value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Number) {
|
||||
writer.write(numberToString((Number) value));
|
||||
} else if (value instanceof Boolean) {
|
||||
writer.write(value.toString());
|
||||
} else if (value instanceof JSONString) {
|
||||
Object o;
|
||||
try {
|
||||
o = ((JSONString) value).toJSONString();
|
||||
} catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
writer.write(o != null ? o.toString() : quote(value.toString()));
|
||||
} else {
|
||||
quote(value.toString(), writer);
|
||||
}
|
||||
public JSONArray optJSONArray(String key) {
|
||||
Object o = this.opt(key);
|
||||
return o instanceof JSONArray ? (JSONArray) o : null;
|
||||
}
|
||||
|
||||
public static void testValidity(Object o) throws JSONException {
|
||||
if (o != null) {
|
||||
if (o instanceof Double) {
|
||||
if (((Double) o).isInfinite() || ((Double) o).isNaN()) {
|
||||
throw new JSONException(
|
||||
"JSON does not allow non-finite numbers.");
|
||||
}
|
||||
} else if (o instanceof Float) {
|
||||
if (((Float) o).isInfinite() || ((Float) o).isNaN()) {
|
||||
throw new JSONException(
|
||||
"JSON does not allow non-finite numbers.");
|
||||
}
|
||||
}
|
||||
}
|
||||
public JSONObject optJSONObject(String key) {
|
||||
Object object = this.opt(key);
|
||||
return object instanceof JSONObject ? (JSONObject) object : null;
|
||||
}
|
||||
|
||||
public JSONArray toJSONArray(JSONArray names) throws JSONException {
|
||||
@@ -715,51 +737,58 @@ public class JSONObject {
|
||||
}
|
||||
}
|
||||
|
||||
public static Object wrap(Object object) {
|
||||
try {
|
||||
if (object == null) {
|
||||
return NULL;
|
||||
}
|
||||
if (object instanceof JSONObject || object instanceof JSONArray ||
|
||||
NULL.equals(object) || object instanceof JSONString ||
|
||||
object instanceof Byte || object instanceof Character ||
|
||||
object instanceof Short || object instanceof Integer ||
|
||||
object instanceof Long || object instanceof Boolean ||
|
||||
object instanceof Float || object instanceof Double ||
|
||||
object instanceof String || object instanceof Enum) {
|
||||
return object;
|
||||
}
|
||||
|
||||
if (object instanceof Collection) {
|
||||
return new JSONArray((Collection) object);
|
||||
}
|
||||
if (object.getClass().isArray()) {
|
||||
return new JSONArray(object);
|
||||
}
|
||||
if (object instanceof Map) {
|
||||
return new JSONObject((Map) object);
|
||||
}
|
||||
Package objectPackage = object.getClass().getPackage();
|
||||
String objectPackageName = objectPackage != null
|
||||
? objectPackage.getName()
|
||||
: "";
|
||||
if (
|
||||
objectPackageName.startsWith("java.") ||
|
||||
objectPackageName.startsWith("javax.") ||
|
||||
object.getClass().getClassLoader() == null
|
||||
) {
|
||||
return object.toString();
|
||||
}
|
||||
return new JSONObject(object);
|
||||
} catch (Exception exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Writer write(Writer writer) throws JSONException {
|
||||
return this.write(writer, 0, 0);
|
||||
}
|
||||
|
||||
Writer write(Writer writer, int indentFactor, int indent)
|
||||
throws JSONException {
|
||||
try {
|
||||
boolean commanate = false;
|
||||
final int length = this.length();
|
||||
Iterator keys = this.keys();
|
||||
writer.write('{');
|
||||
|
||||
if (length == 1) {
|
||||
Object key = keys.next();
|
||||
writer.write(quote(key.toString()));
|
||||
writer.write(':');
|
||||
if (indentFactor > 0) {
|
||||
writer.write(' ');
|
||||
}
|
||||
writeValue(writer, this.map.get(key), indentFactor, indent);
|
||||
} else if (length != 0) {
|
||||
final int newindent = indent + indentFactor;
|
||||
while (keys.hasNext()) {
|
||||
Object key = keys.next();
|
||||
if (commanate) {
|
||||
writer.write(',');
|
||||
}
|
||||
if (indentFactor > 0) {
|
||||
writer.write('\n');
|
||||
}
|
||||
indent(writer, newindent);
|
||||
writer.write(quote(key.toString()));
|
||||
writer.write(':');
|
||||
if (indentFactor > 0) {
|
||||
writer.write(' ');
|
||||
}
|
||||
writeValue(writer, this.map.get(key), indentFactor,
|
||||
newindent);
|
||||
commanate = true;
|
||||
}
|
||||
if (indentFactor > 0) {
|
||||
writer.write('\n');
|
||||
}
|
||||
indent(writer, indent);
|
||||
}
|
||||
writer.write('}');
|
||||
return writer;
|
||||
} catch (IOException exception) {
|
||||
throw new JSONException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject increment(String key) throws JSONException {
|
||||
Object value = this.opt(key);
|
||||
if (value == null) {
|
||||
@@ -822,51 +851,21 @@ public class JSONObject {
|
||||
}
|
||||
}
|
||||
|
||||
Writer write(Writer writer, int indentFactor, int indent)
|
||||
throws JSONException {
|
||||
try {
|
||||
boolean commanate = false;
|
||||
final int length = this.length();
|
||||
Iterator keys = this.keys();
|
||||
writer.write('{');
|
||||
private static final class Null {
|
||||
|
||||
if (length == 1) {
|
||||
Object key = keys.next();
|
||||
writer.write(quote(key.toString()));
|
||||
writer.write(':');
|
||||
if (indentFactor > 0) {
|
||||
writer.write(' ');
|
||||
}
|
||||
writeValue(writer, this.map.get(key), indentFactor, indent);
|
||||
} else if (length != 0) {
|
||||
final int newindent = indent + indentFactor;
|
||||
while (keys.hasNext()) {
|
||||
Object key = keys.next();
|
||||
if (commanate) {
|
||||
writer.write(',');
|
||||
}
|
||||
if (indentFactor > 0) {
|
||||
writer.write('\n');
|
||||
}
|
||||
indent(writer, newindent);
|
||||
writer.write(quote(key.toString()));
|
||||
writer.write(':');
|
||||
if (indentFactor > 0) {
|
||||
writer.write(' ');
|
||||
}
|
||||
writeValue(writer, this.map.get(key), indentFactor,
|
||||
newindent);
|
||||
commanate = true;
|
||||
}
|
||||
if (indentFactor > 0) {
|
||||
writer.write('\n');
|
||||
}
|
||||
indent(writer, indent);
|
||||
}
|
||||
writer.write('}');
|
||||
return writer;
|
||||
} catch (IOException exception) {
|
||||
throw new JSONException(exception);
|
||||
@Override
|
||||
protected final Object clone() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object == null || object == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,29 @@ import java.util.List;
|
||||
|
||||
public class JSONFormatter {
|
||||
|
||||
private static Class<?> cs = NMSUtils.getNMSClassSilent("ChatSerializer", "IChatBaseComponent");
|
||||
private static Class<?> icbc = NMSUtils.getNMSClassSilent("IChatBaseComponent");
|
||||
private static Class<?> ppoc = NMSUtils.getNMSClassSilent("PacketPlayOutChat");
|
||||
private static Class<?> pc = NMSUtils.getNMSClassSilent("PlayerConnection");
|
||||
private static Class<?> p = NMSUtils.getNMSClassSilent("Packet");
|
||||
private static Class<?> ep = NMSUtils.getNMSClassSilent("EntityPlayer");
|
||||
private static Method a = NMSUtils.getMethodSilent(cs, "a", String.class), sp = NMSUtils.getMethodSilent(pc, "sendPacket", p);
|
||||
private static Field ppc = NMSUtils.getFieldSilent(ep, "playerConnection");
|
||||
private static Constructor<?> ppocc = NMSUtils.getConstructorSilent(ppoc, icbc);
|
||||
private static boolean b = check(cs, icbc, ppoc, pc, p, ep, a, sp, ppc, ppocc);
|
||||
private List<JSONArray> all = new ArrayList<>();
|
||||
private JSONArray ja = new JSONArray();
|
||||
private Builder builder = new Builder();
|
||||
private String color = "";
|
||||
private boolean newline = true;
|
||||
|
||||
public JSONFormatter() {
|
||||
}
|
||||
|
||||
public JSONFormatter(boolean newline) {
|
||||
this.newline = newline;
|
||||
}
|
||||
|
||||
public static void sendRawMessage(Player player, String message) {
|
||||
try {
|
||||
Object entityplayer = NMSUtils.getHandle(player);
|
||||
@@ -28,17 +51,55 @@ public class JSONFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
private JSONArray ja = new JSONArray();
|
||||
private Builder builder = new Builder();
|
||||
private String color = "";
|
||||
private List<JSONArray> all = new ArrayList<>();
|
||||
private boolean newline = true;
|
||||
|
||||
public JSONFormatter() {
|
||||
private static boolean check(Object... o) {
|
||||
for (Object a : o) {
|
||||
if (a == null)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public JSONFormatter(boolean newline) {
|
||||
this.newline = newline;
|
||||
private static void send(Player player, JSONFormatter jf) {
|
||||
if (!jf.newline) {
|
||||
send1(player, jf);
|
||||
} else if (b) {
|
||||
try {
|
||||
Object entityplayer = NMSUtils.getHandle(player);
|
||||
Object ppco = ppc.get(entityplayer);
|
||||
sp.invoke(ppco, jf.getPacket());
|
||||
} catch (Exception e) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + jf.toJSON());
|
||||
}
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + jf.toJSON());
|
||||
}
|
||||
}
|
||||
|
||||
private static void send1(Player player, JSONFormatter jf) {
|
||||
if (b) {
|
||||
try {
|
||||
Object entityplayer = NMSUtils.getHandle(player);
|
||||
Object ppco = ppc.get(entityplayer);
|
||||
List<Object> packets = jf.getPacketList();
|
||||
List<String> jsons = null;
|
||||
for (int i = 0; i < packets.size(); i++) {
|
||||
try {
|
||||
sp.invoke(ppco, packets.get(i));
|
||||
} catch (Exception e) {
|
||||
if (jsons == null) {
|
||||
jsons = jf.toJSONList();
|
||||
}
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + jsons.get(i));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
for (String json : jf.toJSONList()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JSONFormatter append(JSONFormatter json) {
|
||||
@@ -284,71 +345,9 @@ public class JSONFormatter {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Class<?> cs = NMSUtils.getNMSClassSilent("ChatSerializer", "IChatBaseComponent");
|
||||
private static Class<?> icbc = NMSUtils.getNMSClassSilent("IChatBaseComponent");
|
||||
private static Class<?> ppoc = NMSUtils.getNMSClassSilent("PacketPlayOutChat");
|
||||
private static Class<?> pc = NMSUtils.getNMSClassSilent("PlayerConnection");
|
||||
private static Class<?> p = NMSUtils.getNMSClassSilent("Packet");
|
||||
private static Class<?> ep = NMSUtils.getNMSClassSilent("EntityPlayer");
|
||||
private static Method a = NMSUtils.getMethodSilent(cs, "a", String.class), sp = NMSUtils.getMethodSilent(pc, "sendPacket", p);
|
||||
private static Field ppc = NMSUtils.getFieldSilent(ep, "playerConnection");
|
||||
private static Constructor<?> ppocc = NMSUtils.getConstructorSilent(ppoc, icbc);
|
||||
private static boolean b = check(cs, icbc, ppoc, pc, p, ep, a, sp, ppc, ppocc);
|
||||
|
||||
private static boolean check(Object... o) {
|
||||
for (Object a : o) {
|
||||
if (a == null)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void send(Player player, JSONFormatter jf) {
|
||||
if (!jf.newline) {
|
||||
send1(player, jf);
|
||||
} else if (b) {
|
||||
try {
|
||||
Object entityplayer = NMSUtils.getHandle(player);
|
||||
Object ppco = ppc.get(entityplayer);
|
||||
sp.invoke(ppco, jf.getPacket());
|
||||
} catch (Exception e) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + jf.toJSON());
|
||||
}
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + jf.toJSON());
|
||||
}
|
||||
}
|
||||
|
||||
private static void send1(Player player, JSONFormatter jf) {
|
||||
if (b) {
|
||||
try {
|
||||
Object entityplayer = NMSUtils.getHandle(player);
|
||||
Object ppco = ppc.get(entityplayer);
|
||||
List<Object> packets = jf.getPacketList();
|
||||
List<String> jsons = null;
|
||||
for (int i = 0; i < packets.size(); i++) {
|
||||
try {
|
||||
sp.invoke(ppco, packets.get(i));
|
||||
} catch (Exception e) {
|
||||
if (jsons == null) {
|
||||
jsons = jf.toJSONList();
|
||||
}
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + jsons.get(i));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
for (String json : jf.toJSONList()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class Builder {
|
||||
|
||||
private StringBuilder sb = new StringBuilder("");
|
||||
private StringBuilder sb = new StringBuilder();
|
||||
private boolean bold = false, italic = false, magic = false, strikethrough = false, underline = false, changed = false;
|
||||
|
||||
public Builder() {
|
||||
|
||||
@@ -23,58 +23,6 @@ public class MySQLConnection {
|
||||
private int recheck = 10;
|
||||
private Thread recheckThread;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public String getConnectionUrl() {
|
||||
return connectionUrl;
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public boolean isFallReconnection() {
|
||||
return fallReconnection;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void setFallReconnection(boolean fallReconnection) {
|
||||
this.fallReconnection = fallReconnection;
|
||||
}
|
||||
|
||||
public int getRecheck() {
|
||||
return recheck;
|
||||
}
|
||||
|
||||
public Thread getRecheckThread() {
|
||||
return recheckThread;
|
||||
}
|
||||
|
||||
public MySQLConnection(String url, String user, String port, String password, String database) {
|
||||
this(url, user, port, password, database, 10, Main.getInst());
|
||||
}
|
||||
@@ -126,14 +74,66 @@ public class MySQLConnection {
|
||||
}
|
||||
}
|
||||
|
||||
public void setReCheckSeconds(int s) {
|
||||
this.recheck = s;
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public String getConnectionUrl() {
|
||||
return connectionUrl;
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean isFallReconnection() {
|
||||
return fallReconnection;
|
||||
}
|
||||
|
||||
public void setFallReconnection(boolean fallReconnection) {
|
||||
this.fallReconnection = fallReconnection;
|
||||
}
|
||||
|
||||
public int getRecheck() {
|
||||
return recheck;
|
||||
}
|
||||
|
||||
public Thread getRecheckThread() {
|
||||
return recheckThread;
|
||||
}
|
||||
|
||||
public int getReCheckSeconds() {
|
||||
return recheck;
|
||||
}
|
||||
|
||||
public void setReCheckSeconds(int s) {
|
||||
this.recheck = s;
|
||||
}
|
||||
|
||||
public boolean isConnection() {
|
||||
try {
|
||||
if (connection == null || connection.isClosed()) {
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
package me.skymc.taboolib.nms;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@@ -24,6 +11,15 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Deprecated
|
||||
public class NMSUtil18 {
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
package me.skymc.taboolib.nms.item.impl;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
import me.skymc.taboolib.nms.item.IDabItemUtils;
|
||||
import me.skymc.taboolib.nms.nbt.NBTConstants;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class _164ItemUtils implements IDabItemUtils{
|
||||
|
||||
@@ -30,8 +22,8 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
public boolean getBanner(){
|
||||
try{
|
||||
Material m = Material.valueOf("BANNER");
|
||||
return true;
|
||||
} catch (Exception ignored) {
|
||||
return true;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
package me.skymc.taboolib.nms.item.impl;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
import me.skymc.taboolib.nms.item.IDabItemUtils;
|
||||
import me.skymc.taboolib.nms.nbt.NBTConstants;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class _1710ItemUtils implements IDabItemUtils{
|
||||
|
||||
@@ -30,8 +22,8 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
public boolean getBanner(){
|
||||
try{
|
||||
Material m = Material.valueOf("BANNER");
|
||||
return true;
|
||||
} catch (Exception ignored) {
|
||||
return true;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,19 @@
|
||||
package me.skymc.taboolib.nms.item.impl;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.json.JSONArray;
|
||||
import me.skymc.taboolib.json.JSONObject;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
import me.skymc.taboolib.nms.item.IDabItemUtils;
|
||||
import me.skymc.taboolib.nms.nbt.NBTConstants;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class _194ItemUtils implements IDabItemUtils{
|
||||
|
||||
@@ -29,7 +22,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
public boolean getBanner(){
|
||||
try{
|
||||
Material m = Material.valueOf("BANNER");
|
||||
return true;
|
||||
return true;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -5,12 +5,7 @@ import java.nio.charset.Charset;
|
||||
@Deprecated
|
||||
public final class NBTConstants {
|
||||
|
||||
private NBTConstants() {
|
||||
throw new AssertionError("Not instantiable");
|
||||
}
|
||||
|
||||
public static final Charset CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
public static final int TYPE_END = 0;
|
||||
public static final int TYPE_BYTE = 1;
|
||||
public static final int TYPE_SHORT = 2;
|
||||
@@ -23,4 +18,8 @@ public final class NBTConstants {
|
||||
public static final int TYPE_LIST = 9;
|
||||
public static final int TYPE_COMPOUND = 10;
|
||||
public static final int TYPE_INT_ARRAY = 11;
|
||||
|
||||
private NBTConstants() {
|
||||
throw new AssertionError("Not instantiable");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class PacketUtils {
|
||||
|
||||
public enum EntityStatus {
|
||||
FIRE, CROUCHED, UNUSED1, UNUSED2, SPRINTING, INVISIBLE, GLOWING, ELYTRA
|
||||
}
|
||||
|
||||
public static void sendPacketEntityStatus(Entity entity, EntityStatus status, Player... players) {
|
||||
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA);
|
||||
packet.getIntegers().write(0, entity.getEntityId());
|
||||
@@ -72,4 +68,8 @@ public class PacketUtils {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public enum EntityStatus {
|
||||
FIRE, CROUCHED, UNUSED1, UNUSED2, SPRINTING, INVISIBLE, GLOWING, ELYTRA
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,16 +93,6 @@ public class DataUtils implements Listener {
|
||||
return conf;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disable(PluginDisableEvent e) {
|
||||
if (e.getPlugin().equals(Main.getInst())) {
|
||||
return;
|
||||
}
|
||||
if (CACHE_DATA_PLUGIN.containsKey(e.getPlugin().getName())) {
|
||||
saveAllCaches(e.getPlugin(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FileConfiguration getPlayerData(String name) {
|
||||
try {
|
||||
@@ -149,4 +139,14 @@ public class DataUtils implements Listener {
|
||||
public static void saveOnline(String p) {
|
||||
getPlayerData(p).set("TabooLib.Offline", System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disable(PluginDisableEvent e) {
|
||||
if (e.getPlugin().equals(Main.getInst())) {
|
||||
return;
|
||||
}
|
||||
if (CACHE_DATA_PLUGIN.containsKey(e.getPlugin().getName())) {
|
||||
saveAllCaches(e.getPlugin(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,10 +250,10 @@ public class PluginUtils {
|
||||
}
|
||||
}
|
||||
pluginManager.disablePlugin(plugin);
|
||||
if (plugins != null && plugins.contains(plugin)) {
|
||||
if (plugins != null) {
|
||||
plugins.remove(plugin);
|
||||
}
|
||||
if (names != null && names.containsKey(name)) {
|
||||
if (names != null) {
|
||||
names.remove(name);
|
||||
}
|
||||
if (listeners != null && reloadlisteners) {
|
||||
|
||||
@@ -22,6 +22,16 @@ public class Language2 {
|
||||
private Plugin plugin;
|
||||
private String languageName;
|
||||
|
||||
public Language2(Plugin plugin) {
|
||||
this("zh_CN", plugin);
|
||||
}
|
||||
|
||||
public Language2(String languageName, Plugin plugin) {
|
||||
this.languageName = languageName;
|
||||
this.plugin = plugin;
|
||||
reload(languageName);
|
||||
}
|
||||
|
||||
public FileConfiguration getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
@@ -42,16 +52,6 @@ public class Language2 {
|
||||
return languageName;
|
||||
}
|
||||
|
||||
public Language2(Plugin plugin) {
|
||||
this("zh_CN", plugin);
|
||||
}
|
||||
|
||||
public Language2(String languageName, Plugin plugin) {
|
||||
this.languageName = languageName;
|
||||
this.plugin = plugin;
|
||||
reload(languageName);
|
||||
}
|
||||
|
||||
public Language2Value get(String key) {
|
||||
return new Language2Value(this, key);
|
||||
}
|
||||
|
||||
@@ -16,14 +16,6 @@ public class Language2Format implements Language2Line {
|
||||
private Language2Value language2Value;
|
||||
private List<Language2Line> language2Lines = new ArrayList<>();
|
||||
|
||||
public Language2Value getLanguage2Value() {
|
||||
return language2Value;
|
||||
}
|
||||
|
||||
public List<Language2Line> getLanguage2Lines() {
|
||||
return language2Lines;
|
||||
}
|
||||
|
||||
public Language2Format(Player player, Language2Value value) {
|
||||
language2Value = value;
|
||||
// 语言类型
|
||||
@@ -93,6 +85,14 @@ public class Language2Format implements Language2Line {
|
||||
}
|
||||
}
|
||||
|
||||
public Language2Value getLanguage2Value() {
|
||||
return language2Value;
|
||||
}
|
||||
|
||||
public List<Language2Line> getLanguage2Lines() {
|
||||
return language2Lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别内容
|
||||
*
|
||||
|
||||
@@ -25,26 +25,6 @@ public class Language2Value {
|
||||
|
||||
private boolean enablePlaceholderAPI = false;
|
||||
|
||||
public Language2 getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public String getLanguageKey() {
|
||||
return languageKey;
|
||||
}
|
||||
|
||||
public List<String> getLanguageValue() {
|
||||
return languageValue;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, String> getPlaceholder() {
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
public boolean isEnablePlaceholderAPI() {
|
||||
return enablePlaceholderAPI;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
@@ -81,6 +61,26 @@ public class Language2Value {
|
||||
this.languageKey = languageKey;
|
||||
}
|
||||
|
||||
public Language2 getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public String getLanguageKey() {
|
||||
return languageKey;
|
||||
}
|
||||
|
||||
public List<String> getLanguageValue() {
|
||||
return languageValue;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, String> getPlaceholder() {
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
public boolean isEnablePlaceholderAPI() {
|
||||
return enablePlaceholderAPI;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向玩家发送信息
|
||||
*
|
||||
|
||||
@@ -29,18 +29,6 @@ public class Language2Action implements Language2Line {
|
||||
|
||||
private Language2Value value;
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public int getRepeat() {
|
||||
return repeat;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Language2Action(Language2Format format, List<String> list) {
|
||||
// 变量初始化
|
||||
this.value = format.getLanguage2Value();
|
||||
@@ -68,6 +56,18 @@ public class Language2Action implements Language2Line {
|
||||
}
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public int getRepeat() {
|
||||
return repeat;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送给玩家
|
||||
*
|
||||
|
||||
@@ -48,26 +48,6 @@ public class Language2Book implements Language2Line {
|
||||
|
||||
private BookBuilder book;
|
||||
|
||||
public static Pattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public HashMap<String, TextBuilder> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public BookBuilder getBook() {
|
||||
return book;
|
||||
}
|
||||
|
||||
public Language2Book(Language2Format format, List<String> list, Player player) {
|
||||
// 变量
|
||||
this.player = player;
|
||||
@@ -141,6 +121,26 @@ public class Language2Book implements Language2Line {
|
||||
book.addPages(page.build());
|
||||
}
|
||||
|
||||
public static Pattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public HashMap<String, TextBuilder> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public BookBuilder getBook() {
|
||||
return book;
|
||||
}
|
||||
|
||||
private void formatOptions(List<String> list) {
|
||||
// 获取书本设置
|
||||
HashMap<String, List<String>> _options = getOptions(list);
|
||||
|
||||
@@ -40,22 +40,6 @@ public class Language2Json implements Language2Line {
|
||||
|
||||
private StringBuffer text = new StringBuffer();
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public JSONFormatter getJson() {
|
||||
return json;
|
||||
}
|
||||
|
||||
public StringBuffer getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public Language2Json(Language2Format format, List<String> list, Player player) {
|
||||
// 首次检测
|
||||
boolean isFirst = true;
|
||||
@@ -133,6 +117,22 @@ public class Language2Json implements Language2Line {
|
||||
append(current, clickEvent, hoverEvent);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public JSONFormatter getJson() {
|
||||
return json;
|
||||
}
|
||||
|
||||
public StringBuffer getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送给玩家
|
||||
*
|
||||
|
||||
@@ -48,22 +48,6 @@ public class Language2Json2 implements Language2Line {
|
||||
|
||||
private JSONFormatter json = new JSONFormatter();
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public HashMap<String, JSONFormatter> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public JSONFormatter getJson() {
|
||||
return json;
|
||||
}
|
||||
|
||||
public Language2Json2(Language2Format format, List<String> list, Player player) {
|
||||
// 变量
|
||||
this.player = player;
|
||||
@@ -128,6 +112,22 @@ public class Language2Json2 implements Language2Line {
|
||||
}
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public HashMap<String, JSONFormatter> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public JSONFormatter getJson() {
|
||||
return json;
|
||||
}
|
||||
|
||||
private int getLineNumberEnd(List<String> list) {
|
||||
int line = list.size();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
|
||||
@@ -21,14 +21,6 @@ public class Language2Sound implements Language2Line {
|
||||
|
||||
private Language2Value value;
|
||||
|
||||
public List<SoundPack> getSounds() {
|
||||
return sounds;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Language2Sound(Language2Format format, List<String> list) {
|
||||
this.value = format.getLanguage2Value();
|
||||
// 遍历文本
|
||||
@@ -37,6 +29,14 @@ public class Language2Sound implements Language2Line {
|
||||
}
|
||||
}
|
||||
|
||||
public List<SoundPack> getSounds() {
|
||||
return sounds;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Player player) {
|
||||
for (SoundPack sound : sounds) {
|
||||
|
||||
@@ -19,6 +19,12 @@ public class Language2Text implements Language2Line {
|
||||
|
||||
private Language2Value value;
|
||||
|
||||
public Language2Text(Language2Format format, List<String> list) {
|
||||
this.value = format.getLanguage2Value();
|
||||
// 遍历文本
|
||||
text.addAll(list);
|
||||
}
|
||||
|
||||
public List<String> getText() {
|
||||
return text;
|
||||
}
|
||||
@@ -27,12 +33,6 @@ public class Language2Text implements Language2Line {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Language2Text(Language2Format format, List<String> list) {
|
||||
this.value = format.getLanguage2Value();
|
||||
// 遍历文本
|
||||
text.addAll(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Player player) {
|
||||
for (String line : text) {
|
||||
|
||||
@@ -33,30 +33,6 @@ public class Language2Title implements Language2Line {
|
||||
|
||||
private Language2Value value;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getSubtitle() {
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
public int getFade1() {
|
||||
return fade1;
|
||||
}
|
||||
|
||||
public int getFade2() {
|
||||
return fade2;
|
||||
}
|
||||
|
||||
public int getStay() {
|
||||
return stay;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Language2Title(Language2Format format, List<String> list) {
|
||||
// 变量初始化
|
||||
this.value = format.getLanguage2Value();
|
||||
@@ -86,6 +62,30 @@ public class Language2Title implements Language2Line {
|
||||
}
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getSubtitle() {
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
public int getFade1() {
|
||||
return fade1;
|
||||
}
|
||||
|
||||
public int getFade2() {
|
||||
return fade2;
|
||||
}
|
||||
|
||||
public int getStay() {
|
||||
return stay;
|
||||
}
|
||||
|
||||
public Language2Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Player player) {
|
||||
// 检查版本
|
||||
|
||||
@@ -22,10 +22,6 @@ public class TagManager implements Listener {
|
||||
|
||||
private HashMap<String, PlayerData> playerdata = new HashMap<>();
|
||||
|
||||
public HashMap<String, PlayerData> getPlayerdata() {
|
||||
return playerdata;
|
||||
}
|
||||
|
||||
private TagManager() {
|
||||
Bukkit.getPluginManager().registerEvents(this, Main.getInst());
|
||||
}
|
||||
@@ -39,6 +35,10 @@ public class TagManager implements Listener {
|
||||
return inst;
|
||||
}
|
||||
|
||||
public HashMap<String, PlayerData> getPlayerdata() {
|
||||
return playerdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置玩家前缀
|
||||
*
|
||||
@@ -184,6 +184,12 @@ public class TagManager implements Listener {
|
||||
private String prefix;
|
||||
private String suffix;
|
||||
|
||||
public PlayerData(String name) {
|
||||
this.name = name;
|
||||
this.prefix = "";
|
||||
this.suffix = "";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -192,22 +198,16 @@ public class TagManager implements Listener {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public void setSuffix(String suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public PlayerData(String name) {
|
||||
this.name = name;
|
||||
this.prefix = "";
|
||||
this.suffix = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.util.LinkedList;
|
||||
|
||||
public class ThreadUtils {
|
||||
|
||||
private static PoolWorker[] threads;
|
||||
private static final LinkedList<Runnable> queue = new LinkedList<>();
|
||||
private static PoolWorker[] threads;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
|
||||
@@ -20,7 +20,7 @@ public class TimeCycle {
|
||||
|
||||
long time = System.currentTimeMillis() - millisHour - millisMinute;
|
||||
}
|
||||
|
||||
|
||||
public Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,14 @@ public class TimeFormatter {
|
||||
private long seconds;
|
||||
private long milliseconds;
|
||||
|
||||
public TimeFormatter(long millisecond) {
|
||||
days = TimeUnit.MILLISECONDS.toDays(millisecond);
|
||||
hours = TimeUnit.MILLISECONDS.toHours(millisecond) - days * 24L;
|
||||
minutes = TimeUnit.MILLISECONDS.toMinutes(millisecond) - TimeUnit.MILLISECONDS.toHours(millisecond) * 60L;
|
||||
seconds = TimeUnit.MILLISECONDS.toSeconds(millisecond) - TimeUnit.MILLISECONDS.toMinutes(millisecond) * 60L;
|
||||
milliseconds = TimeUnit.MILLISECONDS.toMillis(millisecond) - TimeUnit.MILLISECONDS.toSeconds(millisecond) * 1000L;
|
||||
}
|
||||
|
||||
public long getDays() {
|
||||
return days;
|
||||
}
|
||||
@@ -54,14 +62,6 @@ public class TimeFormatter {
|
||||
this.milliseconds = milliseconds;
|
||||
}
|
||||
|
||||
public TimeFormatter(long millisecond) {
|
||||
days = TimeUnit.MILLISECONDS.toDays(millisecond);
|
||||
hours = TimeUnit.MILLISECONDS.toHours(millisecond) - days * 24L;
|
||||
minutes = TimeUnit.MILLISECONDS.toMinutes(millisecond) - TimeUnit.MILLISECONDS.toHours(millisecond) * 60L;
|
||||
seconds = TimeUnit.MILLISECONDS.toSeconds(millisecond) - TimeUnit.MILLISECONDS.toMinutes(millisecond) * 60L;
|
||||
milliseconds = TimeUnit.MILLISECONDS.toMillis(millisecond) - TimeUnit.MILLISECONDS.toSeconds(millisecond) * 1000L;
|
||||
}
|
||||
|
||||
public long toMilliseconds() {
|
||||
return milliseconds + (seconds * 1000L) + (minutes * 1000L * 60L) + (hours * 1000L * 60L * 60L) + (days * 1000L * 60L * 60L * 24L);
|
||||
}
|
||||
|
||||
@@ -23,14 +23,6 @@ public class TLM {
|
||||
|
||||
private Language2 language;
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public Language2 getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
@@ -75,6 +67,14 @@ public class TLM {
|
||||
return inst;
|
||||
}
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public Language2 getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* 载入配置文件
|
||||
*/
|
||||
|
||||
@@ -15,14 +15,6 @@ public class TLMInventoryHolder implements InventoryHolder {
|
||||
|
||||
private HashMap<String, Object> holderData = new HashMap<>();
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getHolderData() {
|
||||
return holderData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
@@ -32,6 +24,14 @@ public class TLMInventoryHolder implements InventoryHolder {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getHolderData() {
|
||||
return holderData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return null;
|
||||
|
||||
@@ -39,6 +39,10 @@ MISC:
|
||||
FIELD-COPY-FAILED: '拷贝 {0} 对象失败'
|
||||
FIELD-COPY-ERROR: '拷贝 {0} 对象出错:{1}'
|
||||
|
||||
DATABASE:
|
||||
CONNECTION-ESTABLISHED: '成功连接到 {0} 数据库,连接池大小 {1}'
|
||||
CONNECTION-ERROR: '连接到数据库错误:{0}'
|
||||
|
||||
COMMANDS:
|
||||
GLOBAL:
|
||||
ONLY-PLAYER: '&8[&3&lTabooLib&8] &4控制台无法这么做'
|
||||
@@ -248,7 +252,4 @@ COMMANDS:
|
||||
- ''
|
||||
- '§f /language2 send §8[§7玩家/ALL§8] §8[§7语言§8] §8<§7变量§8> §6- §e发送语言提示'
|
||||
- '§f /language2 reload §6- §e重载语言库'
|
||||
- ''
|
||||
DATABASE:
|
||||
CONNECTION-ESTABLISHED: '成功连接到 {0} 数据库,连接池大小 {1}'
|
||||
CONNECTION-ERROR: '连接到数据库错误:{0}'
|
||||
- ''
|
||||
Reference in New Issue
Block a user