命令系统重做

This commit is contained in:
坏黑 2018-05-10 00:44:57 +08:00
parent b14164fbbd
commit 41e53b9165
100 changed files with 1765 additions and 707 deletions

View File

@ -1,13 +1,9 @@
package com.ilummc.tlib.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ilummc.tlib.dependency.TDependency;
import java.lang.annotation.*;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Dependencies.class)

View File

@ -1,12 +1,12 @@
package com.ilummc.tlib.bean;
import java.lang.reflect.Type;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;
public class PropertyTypeAdaptor implements JsonDeserializer<Property> {
@Override

View File

@ -5,7 +5,7 @@
package com.ilummc.tlib.bungee.api.chat;
import com.ilummc.tlib.bungee.api.*;
import com.ilummc.tlib.bungee.api.ChatColor;
import java.beans.ConstructorProperties;
import java.util.ArrayList;

View File

@ -5,14 +5,9 @@
package com.ilummc.tlib.bungee.chat;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.ilummc.tlib.bungee.api.chat.*;
import com.google.gson.*;
import com.ilummc.tlib.bungee.api.chat.BaseComponent;
import com.ilummc.tlib.bungee.api.chat.TextComponent;
import java.lang.reflect.Type;
import java.util.List;

View File

@ -1,11 +1,10 @@
package com.ilummc.tlib.compat;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import me.clip.placeholderapi.PlaceholderAPI;
public abstract class PlaceholderHook {
private static PlaceholderHook impl;

View File

@ -27,9 +27,6 @@ public class TLoggerFilter implements Filter {
}
return false;
}
else if (e.getMessage().contains("Enabled plugin with unregistered PluginClassLoader")) {
return false;
}
return true;
}
else return !e.getMessage().contains("Enabled plugin with unregistered PluginClassLoader");
}
}

View File

@ -11,7 +11,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;

View File

@ -1,12 +1,12 @@
package com.ilummc.tlib.util.asm;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import java.util.ArrayList;
import java.util.List;
public class AsmAnalyser extends ClassVisitor implements Opcodes {
private final List<String> fields = new ArrayList<>();

View File

@ -3,13 +3,13 @@ package me.skymc.taboolib;
import com.ilummc.tlib.TLib;
import me.skymc.taboolib.anvil.AnvilContainerAPI;
import me.skymc.taboolib.bstats.Metrics;
import me.skymc.taboolib.commands.MainCommands;
import me.skymc.taboolib.commands.internal.InternalCommandExecutor;
import me.skymc.taboolib.commands.TabooLibMainCommand;
import me.skymc.taboolib.commands.internal.BaseMainCommand;
import me.skymc.taboolib.commands.language.Language2Command;
import me.skymc.taboolib.commands.locale.TabooLibLocaleCommand;
import me.skymc.taboolib.commands.plugin.TabooLibPluginCommand;
import me.skymc.taboolib.commands.sub.itemlist.listener.ItemLibraryPatch;
import me.skymc.taboolib.commands.sub.sounds.listener.SoundsLibraryPatch;
import me.skymc.taboolib.commands.plugin.TabooLibPluginMainCommand;
import me.skymc.taboolib.commands.taboolib.listener.ListenerItemListCommand;
import me.skymc.taboolib.commands.taboolib.listener.ListenerSoundsCommand;
import me.skymc.taboolib.database.GlobalDataManager;
import me.skymc.taboolib.database.PlayerDataManager;
import me.skymc.taboolib.economy.EcoUtils;
@ -31,6 +31,7 @@ import me.skymc.taboolib.skript.SkriptHandler;
import me.skymc.taboolib.string.StringUtils;
import me.skymc.taboolib.string.language2.Language2;
import me.skymc.taboolib.support.SupportPlaceholder;
import me.skymc.taboolib.team.TagAPI;
import me.skymc.taboolib.team.TagUtils;
import me.skymc.taboolib.timecycle.TimeCycleManager;
import me.skymc.taboolib.update.UpdateTask;
@ -201,11 +202,11 @@ public class Main extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// 注册指令
getCommand("taboolib").setExecutor(new MainCommands());
getCommand("language2").setExecutor(new Language2Command());
getCommand("taboolibrarymodule").setExecutor(new TLMCommands());
getCommand("tabooliblocale").setExecutor(new TabooLibLocaleCommand());
InternalCommandExecutor.createCommandExecutor("taboolibplugin", new TabooLibPluginCommand());
BaseMainCommand.createCommandExecutor("taboolib", new TabooLibMainCommand());
BaseMainCommand.createCommandExecutor("taboolibplugin", new TabooLibPluginMainCommand());
// 注册监听
registerListener();
@ -225,6 +226,8 @@ public class Main extends JavaPlugin implements Listener {
exampleLanguage2 = new Language2("Language2", this);
// 注册脚本
SkriptHandler.getInst();
// 注册昵称
TagAPI.inst();
// 启动数据库储存方法
if (getStorageType() == StorageType.SQL) {
@ -344,8 +347,8 @@ public class Main extends JavaPlugin implements Listener {
getServer().getPluginManager().registerEvents(new AnvilContainerAPI(), this);
getServer().getPluginManager().registerEvents(new ListenerPluginDisable(), this);
getServer().getPluginManager().registerEvents(new PlayerDataManager(), this);
getServer().getPluginManager().registerEvents(new ItemLibraryPatch(), this);
getServer().getPluginManager().registerEvents(new SoundsLibraryPatch(), this);
getServer().getPluginManager().registerEvents(new ListenerItemListCommand(), this);
getServer().getPluginManager().registerEvents(new ListenerSoundsCommand(), this);
if (TabooLib.getVerint() > 10700) {
getServer().getPluginManager().registerEvents(new EntityUtils(), this);

View File

@ -1,13 +1,12 @@
package me.skymc.taboolib.bookformatter;
import me.skymc.taboolib.bookformatter.builder.BookBuilder;
import me.skymc.taboolib.events.CustomBookOpenEvent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import me.skymc.taboolib.bookformatter.builder.BookBuilder;
import me.skymc.taboolib.events.CustomBookOpenEvent;
@SuppressWarnings("deprecation")
public final class BookFormatter {

View File

@ -1,12 +1,11 @@
package me.skymc.taboolib.bookformatter.builder;
import java.util.List;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import me.skymc.taboolib.bookformatter.BookReflection;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import java.util.List;
/**
* @author sky

View File

@ -1,13 +1,13 @@
package me.skymc.taboolib.bookformatter.builder;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
/**
* @author sky
* @since 2018-03-08 22:36:58

View File

@ -1,14 +1,9 @@
package me.skymc.taboolib.client;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.text.SimpleDateFormat;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import java.awt.*;
import java.text.SimpleDateFormat;
@Deprecated
public class LogClient extends JFrame {

View File

@ -1,65 +0,0 @@
package me.skymc.taboolib.commands;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.sub.*;
import me.skymc.taboolib.commands.sub.cycle.CycleCommand;
import me.skymc.taboolib.commands.sub.itemlist.ItemListCommand;
import me.skymc.taboolib.commands.sub.shell.ShellCommand;
import me.skymc.taboolib.commands.sub.sounds.SoundsCommand;
import me.skymc.taboolib.inventory.ItemUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class MainCommands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 0 || "help".equalsIgnoreCase(args[0])) {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.HELP", label);
} else if ("save".equalsIgnoreCase(args[0])) {
new SaveCommand(sender, args);
} else if ("enchants".equalsIgnoreCase(args[0])) {
new EnchantCommand(sender, args);
} else if ("potions".equalsIgnoreCase(args[0])) {
new PotionCommand(sender, args);
} else if ("flags".equalsIgnoreCase(args[0])) {
new FlagCommand(sender, args);
} else if ("attributes".equalsIgnoreCase(args[0])) {
new AttributesCommand(sender, args);
} else if ("slots".equalsIgnoreCase(args[0])) {
new SlotCommand(sender, args);
} else if ("importdata".equalsIgnoreCase(args[0])) {
new ImportCommand(sender, args);
} else if ("iteminfo".equalsIgnoreCase(args[0])) {
new InfoCommand(sender, args);
} else if ("itemlist".equalsIgnoreCase(args[0])) {
new ItemListCommand(sender, args);
} else if ("item".equalsIgnoreCase(args[0]) || "i".equalsIgnoreCase(args[0])) {
new ItemCommand(sender, args);
} else if ("setvariable".equalsIgnoreCase(args[0])) {
new VariableSetCommand(sender, args);
} else if ("getvariable".equalsIgnoreCase(args[0])) {
new VariableGetCommand(sender, args);
} else if ("shell".equalsIgnoreCase(args[0]) || "s".equalsIgnoreCase(args[0])) {
new ShellCommand(sender, args);
} else if ("cycle".equalsIgnoreCase(args[0]) || "c".equalsIgnoreCase(args[0])) {
new CycleCommand(sender, args);
} else if ("sounds".equalsIgnoreCase(args[0])) {
new SoundsCommand(sender, args);
} else if ("tagprefix".equalsIgnoreCase(args[0])) {
new TagPrefixCommand(sender, args);
} else if ("tagsuffix".equalsIgnoreCase(args[0])) {
new TagSuffixCommand(sender, args);
} else if ("tagdelete".equalsIgnoreCase(args[0])) {
new TagDeleteCommand(sender, args);
} else if ("itemreload".equalsIgnoreCase(args[0]) || "ireload".equalsIgnoreCase(args[0])) {
ItemUtils.reloadItemCache();
ItemUtils.reloadItemName();
TLocale.sendTo(sender, "COMMANDS.RELOAD.SUCCESS-NORMAL");
} else {
TLocale.sendTo(sender, "COMMANDS.PARAMETER.UNKNOWN");
}
return true;
}
}

View File

@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@Deprecated
public abstract class SubCommand {
public CommandSender sender;

View File

@ -0,0 +1,755 @@
package me.skymc.taboolib.commands;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.internal.BaseMainCommand;
import me.skymc.taboolib.commands.internal.BaseSubCommand;
import me.skymc.taboolib.commands.internal.type.CommandArgument;
import me.skymc.taboolib.commands.internal.type.CommandRegister;
import me.skymc.taboolib.commands.taboolib.*;
import me.skymc.taboolib.inventory.ItemUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
/**
* @Author sky
* @Since 2018-05-09 21:38
*/
public class TabooLibMainCommand extends BaseMainCommand {
@Override
public String getCommandTitle() {
return TLocale.asString("COMMANDS.TABOOLIB.COMMAND-TITLE");
}
@CommandRegister(priority = 1)
void save() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "save";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.SAVE.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.SAVE.ARGUMENTS.0"))};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new SaveCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 2)
void item() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "item";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.ITEM.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.ITEM.ARGUMENTS.0")),
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.ITEM.ARGUMENTS.1"), false),
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.ITEM.ARGUMENTS.2"), false)
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new ItemCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 3)
void itemInfo() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "itemInfo";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.ITEMLIST.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new ItemListCommand(sender, args);
}
});
}
@CommandRegister(priority = 4)
void itemReload() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "itemReload";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.ITEMRELOAD.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
ItemUtils.reloadItemCache();
ItemUtils.reloadItemName();
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.ITEMRELOAD.SUCCESS-RELOAD");
}
});
}
@CommandRegister(priority = 5)
void emptyLine1() {
registerSubCommand(null);
}
@CommandRegister(priority = 6)
void attributes() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "attributes";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.ATTRIBUTES.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new AttributesCommand(sender, args);
}
});
}
@CommandRegister(priority = 7)
void enchants() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "enchants";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.ENCHANTS.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new EnchantCommand(sender, args);
}
});
}
@CommandRegister(priority = 8)
void potions() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "potions";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.POTIONS.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new PotionCommand(sender, args);
}
});
}
@CommandRegister(priority = 9)
void flags() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "flags";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.FLAGS.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new FlagCommand(sender, args);
}
});
}
@CommandRegister(priority = 10)
void slots() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "slots";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.SLOTS.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new AttributesCommand(sender, args);
}
});
}
@CommandRegister(priority = 11)
void sounds() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "sounds";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.SOUNDS.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new SoundsCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 12)
void emptyLine2() {
registerSubCommand(null);
}
@CommandRegister(priority = 13)
void getVariable() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "getVariable";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.VARIABLE.DESCRIPTION.GET");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.VARIABLE.ARGUMENTS.GET.0")),
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.VARIABLE.ARGUMENTS.GET.1"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new VariableGetCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 13.1)
void setVariable() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "setVariable";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.VARIABLE.DESCRIPTION.SET");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.VARIABLE.ARGUMENTS.SET.0")),
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.VARIABLE.ARGUMENTS.SET.1")),
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.VARIABLE.ARGUMENTS.SET.2"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new VariableSetCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 13.2)
void emptyLine3() {
registerSubCommand(null);
}
@CommandRegister(priority = 13.3)
void cycleList() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "cycleList";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.TIMECYCLE.DESCRIPTION.LIST");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new CycleListCommand(sender, args);
}
});
}
@CommandRegister(priority = 14)
void cycleInfo() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "cycleInfo";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.TIMECYCLE.DESCRIPTION.INFO");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.TIMECYCLE.ARGUMENTS.INFO.0"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new CycleInfoCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 15)
void cycleReset() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "cycleReset";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.TIMECYCLE.DESCRIPTION.RESET");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.TIMECYCLE.ARGUMENTS.RESET.0"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new CycleResetCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 16)
void cycleUpdate() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "cycleUpdate";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.TIMECYCLE.DESCRIPTION.UPDATE");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.TIMECYCLE.ARGUMENTS.UPDATE.0"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new CycleUpdateCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 17)
void emptyLine4() {
registerSubCommand(null);
}
@CommandRegister(priority = 18)
void shellLoad() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "shellLoad";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.JAVASHELL.DESCRIPTION.LOAD");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.JAVASHELL.ARGUMENTS.LOAD.0"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new ShellLoadCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 19)
void shellUnload() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "shellUnload";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.JAVASHELL.DESCRIPTION.UNLOAD");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.JAVASHELL.ARGUMENTS.UNLOAD.0"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new ShellUnloadCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 20)
void emptyLine5() {
registerSubCommand(null);
}
@CommandRegister(priority = 20.5)
void tagDisplay() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "tagDisplay";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.DESCRIPTION.DISPLAY");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.ARGUMENTS.DISPLAY.0")),
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.ARGUMENTS.DISPLAY.1"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new TagDisplayCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 21)
void tagPrefix() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "tagPrefix";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.DESCRIPTION.PREFIX");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.ARGUMENTS.PREFIX.0")),
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.ARGUMENTS.PREFIX.1"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new TagPrefixCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 22)
void tagSuffix() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "tagSuffix";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.DESCRIPTION.SUFFIX");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.ARGUMENTS.SUFFIX.0")),
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.ARGUMENTS.SUFFIX.1"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new TagSuffixCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 23)
void tagDelete() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "tagDelete";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.DESCRIPTION.DELETE");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[]{
new CommandArgument(TLocale.asString("COMMANDS.TABOOLIB.PLAYERTAG.ARGUMENTS.DELETE.0"))
};
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new TagDeleteCommand(sender, args);
}
@Override
public boolean ignoredLabel() {
return false;
}
});
}
@CommandRegister(priority = 24)
void emptyLine6() {
registerSubCommand(null);
}
@CommandRegister(priority = 25)
void importData() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
return "importData";
}
@Override
public String getDescription() {
return TLocale.asString("COMMANDS.TABOOLIB.IMPORTDATA.DESCRIPTION");
}
@Override
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new ImportCommand(sender, args);
}
});
}
}

View File

@ -0,0 +1,162 @@
package me.skymc.taboolib.commands.internal;
import com.google.common.base.Preconditions;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.commands.internal.type.CommandRegister;
import me.skymc.taboolib.commands.internal.type.CommandType;
import me.skymc.taboolib.string.ArrayUtils;
import me.skymc.taboolib.string.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.*;
import org.bukkit.scheduler.BukkitRunnable;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
/**
* @Author sky
* @Since 2018-05-07 21:38
*/
public abstract class BaseMainCommand implements IMainCommand, CommandExecutor, TabExecutor {
private PluginCommand registerCommand;
private List<Class<?>> linkClasses = new CopyOnWriteArrayList<>();
private List<BaseSubCommand> subCommands = new CopyOnWriteArrayList<>();
public static BaseMainCommand createCommandExecutor(String command, BaseMainCommand baseMainCommand) {
Preconditions.checkArgument(Bukkit.getPluginCommand(command) != null, "PluginCommand \"" + command + "\"not found");
Preconditions.checkArgument(baseMainCommand != null, "Executor cannot be null");
Preconditions.checkArgument(baseMainCommand.getClass() != BaseMainCommand.class, "Executor can not be \"BaseMainCommand.class\"");
baseMainCommand.setRegisterCommand(Bukkit.getPluginCommand(command));
baseMainCommand.getRegisterCommand().setExecutor(baseMainCommand);
baseMainCommand.getRegisterCommand().setTabCompleter(baseMainCommand);
baseMainCommand.getLinkClasses().add(baseMainCommand.getClass());
loadCommandRegister(baseMainCommand);
return baseMainCommand;
}
public static void loadCommandRegister(BaseMainCommand baseMainCommand) {
List<Method> methods = new ArrayList<>();
baseMainCommand.getLinkClasses().forEach(clazz -> Arrays.stream(clazz.getDeclaredMethods()).filter(method -> method.getAnnotation(CommandRegister.class) != null).forEach(methods::add));
if (methods.size() > 0) {
methods.sort(Comparator.comparingDouble(a -> a.getAnnotation(CommandRegister.class).priority()));
methods.forEach(x -> {
try {
x.setAccessible(true);
x.invoke(baseMainCommand);
} catch (Exception ignored) {
}
});
}
if (methods.size() > 0) {
TLocale.Logger.info("COMMANDS.INTERNAL.COMMAND-REGISTER", baseMainCommand.getRegisterCommand().getPlugin().getName(), baseMainCommand.getRegisterCommand().getName(), String.valueOf(methods.size()));
}
}
public void setRegisterCommand(PluginCommand registerCommand) {
this.registerCommand = registerCommand;
}
public PluginCommand getRegisterCommand() {
return registerCommand;
}
public List<Class<?>> getLinkClasses() {
return linkClasses;
}
public List<BaseSubCommand> getSubCommands() {
return subCommands;
}
public void registerSubCommand(BaseSubCommand subCommand) {
if (subCommand != null) {
Preconditions.checkArgument(subCommand.getLabel() != null, "Command label can not be null");
Preconditions.checkArgument(subCommand.getDescription() != null, "Command description can not be null");
Preconditions.checkArgument(subCommand.getArguments() != null, "Command arguments can not be null");
}
subCommands.add(subCommand);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
helpCommand(sender, label);
} else {
for (BaseSubCommand subCommand : subCommands) {
if (subCommand == null || !args[0].equalsIgnoreCase(subCommand.getLabel())) {
continue;
}
if (!isConfirmType(sender, subCommand.getType())) {
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ONLY-PLAYER", args[0], TLocale.asString("COMMANDS.INTERNAL.TYPE-" + subCommand.getType()));
return true;
}
String[] subCommandArgs = ArrayUtils.removeFirst(args);
if (subCommand.isParameterConform(subCommandArgs)) {
subCommand.onCommand(sender, command, label, subCommand.ignoredLabel() ? subCommandArgs : args);
} else {
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ERROR-USAGE", args[0], subCommand.getCommandString(label));
}
return true;
}
new BukkitRunnable() {
@Override
public void run() {
List<BaseSubCommand> commandCompute = subCommands.stream().filter(Objects::nonNull).sorted((b, a) -> Double.compare(StringUtils.similarDegree(args[0], a.getLabel()), StringUtils.similarDegree(args[0], b.getLabel()))).collect(Collectors.toList());
if (commandCompute.size() > 0) {
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ERROR-COMMAND", args[0], commandCompute.get(0).getCommandString(label).trim());
}
}
}.runTaskAsynchronously(Main.getInst());
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
return args.length == 1 ? subCommands.stream().filter(internalCommandExecutor -> internalCommandExecutor != null && (args[0].isEmpty() || internalCommandExecutor.getLabel().startsWith(args[0]))).map(ISubCommand::getLabel).collect(Collectors.toList()) : null;
}
@Override
public String toString() {
return "registerCommand=" + "BaseMainCommand{" + registerCommand + ", linkClasses=" + linkClasses + ", subCommands=" + subCommands + '}';
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof BaseMainCommand)) {
return false;
}
BaseMainCommand that = (BaseMainCommand) o;
return Objects.equals(getLinkClasses(), that.getLinkClasses()) && Objects.equals(getRegisterCommand(), that.getRegisterCommand()) && Objects.equals(getSubCommands(), that.getSubCommands());
}
@Override
public int hashCode() {
return Objects.hash(getRegisterCommand(), getLinkClasses(), getSubCommands());
}
private String getEmptyLine() {
return TabooLib.getVerint() < 10800 ? "~" : "";
}
private boolean isConfirmType(CommandSender sender, CommandType commandType) {
return commandType == CommandType.ALL || sender instanceof ConsoleCommandSender && commandType == CommandType.CONSOLE;
}
private void helpCommand(CommandSender sender, String label) {
sender.sendMessage(getEmptyLine());
sender.sendMessage(getCommandTitle());
sender.sendMessage(getEmptyLine());
subCommands.stream().map(subCommand -> subCommand == null ? getEmptyLine() : subCommand.getCommandString(label)).forEach(sender::sendMessage);
sender.sendMessage(getEmptyLine());
}
}

View File

@ -1,15 +1,22 @@
package me.skymc.taboolib.commands.internal;
import me.skymc.taboolib.commands.internal.type.CommandArgument;
import me.skymc.taboolib.commands.internal.type.CommandType;
import java.util.stream.IntStream;
/**
* @author Bkm016
* @since 2018-04-17
*/
public abstract class InternalSubCommandExecutor implements InternalSubCommand {
public abstract class BaseSubCommand implements ISubCommand {
public InternalSubCommandType getType() {
return InternalSubCommandType.ALL;
public CommandType getType() {
return CommandType.ALL;
}
public boolean ignoredLabel() {
return true;
}
public boolean requiredPlayer() {
@ -27,7 +34,7 @@ public abstract class InternalSubCommandExecutor implements InternalSubCommand {
stringBuilder.append(" ");
stringBuilder.append(getLabel());
stringBuilder.append(" ");
for (InternalArgument parameter : getArguments()) {
for (CommandArgument parameter : getArguments()) {
stringBuilder.append(parameter.toString());
stringBuilder.append(" ");
}

View File

@ -4,8 +4,13 @@ package me.skymc.taboolib.commands.internal;
* @Author sky
* @Since 2018-05-07 21:36
*/
public interface InternalCommand {
public interface IMainCommand {
/**
* 指令标题
*
* @return 文本
*/
String getCommandTitle();
}

View File

@ -0,0 +1,44 @@
package me.skymc.taboolib.commands.internal;
import me.skymc.taboolib.commands.internal.type.CommandArgument;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
/**
* @author Bkm016
* @since 2018-04-17
*/
public interface ISubCommand {
/**
* 指令名
*
* @return 文本
*/
String getLabel();
/**
* 指令描述
*
* @return 文本
*/
String getDescription();
/**
* 指令参数
*
* @return {@link CommandArgument}
*/
CommandArgument[] getArguments();
/**
* 指令执行方法
*
* @param sender 指令使用者
* @param command 指令对象
* @param label 主命令
* @param args 参数不含主命令及子命令
*/
void onCommand(CommandSender sender, Command command, String label, String[] args);
}

View File

@ -1,29 +0,0 @@
package me.skymc.taboolib.commands.internal;
/**
* @author Bkm016
* @since 2018-04-17
*/
public class InternalArgument {
private String name;
private boolean required;
public String getName() {
return name;
}
public boolean isRequired() {
return required;
}
public InternalArgument(String name, boolean required) {
this.name = name;
this.required = required;
}
@Override
public String toString() {
return required ? "§7[§8" + name + "§7]" : "§7<§8" + name + "§7>";
}
}

View File

@ -1,111 +0,0 @@
package me.skymc.taboolib.commands.internal;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.string.ArrayUtils;
import me.skymc.taboolib.string.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.*;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @Author sky
* @Since 2018-05-07 21:38
*/
public abstract class InternalCommandExecutor implements InternalCommand, CommandExecutor, TabExecutor {
private InternalCommandExecutor subExecutor;
private List<InternalSubCommandExecutor> subCommandExecutors = new ArrayList<>();
public static InternalCommandExecutor createCommandExecutor(String command, InternalCommandExecutor internalCommandExecutor) {
assert Bukkit.getPluginCommand(command) == null : "PluginCommand \"" + command + "\"not found";
assert internalCommandExecutor != null : "Executor can not be null";
assert internalCommandExecutor.getCommandTitle() != null : "Executor title can not be null";
assert internalCommandExecutor.getClass() != InternalCommandExecutor.class : "SubExecutor can not be \"InternalCommandExecutor.class\"";
internalCommandExecutor.setSubExecutor(internalCommandExecutor);
Bukkit.getPluginCommand(command).setExecutor(internalCommandExecutor);
Bukkit.getPluginCommand(command).setTabCompleter(internalCommandExecutor);
return internalCommandExecutor;
}
public void setSubExecutor(InternalCommandExecutor subExecutor) {
this.subExecutor = subExecutor;
}
public InternalCommandExecutor getSubExecutor() {
return subExecutor;
}
public List<InternalSubCommandExecutor> getSubCommandExecutors() {
return subCommandExecutors;
}
public void registerSubCommandExecutor(InternalSubCommandExecutor subCommandExecutor) {
assert subCommandExecutor.getLabel() != null : "Command label can not be null";
assert subCommandExecutor.getDescription() != null : "Command description can not be null";
assert subCommandExecutor.getArguments() != null : "Command arguments can not be null";
subCommandExecutors.add(subCommandExecutor);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
helpCommand(sender, label);
} else {
for (InternalSubCommandExecutor subCommand : subCommandExecutors) {
if (subCommand == null || !args[0].equalsIgnoreCase(subCommand.getLabel())) {
continue;
}
if (!isConfirmType(sender, subCommand.getType())) {
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ONLY-PLAYER", args[0], TLocale.asString("COMMANDS.INTERNAL.TYPE-" + subCommand.getType()));
return true;
}
String[] subCommandArgs = ArrayUtils.removeFirst(args);
if (subCommand.isParameterConform(subCommandArgs)) {
subCommand.onCommand(sender, command, label, subCommandArgs);
} else {
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ERROR-USAGE", args[0], subCommand.getCommandString(label));
}
return true;
}
new BukkitRunnable() {
@Override
public void run() {
List<InternalSubCommandExecutor> commandCompute = subCommandExecutors.stream().filter(Objects::nonNull).sorted((b, a) -> Double.compare(StringUtils.similarDegree(args[0], a.getLabel()), StringUtils.similarDegree(args[0], b.getLabel()))).collect(Collectors.toList());
if (commandCompute.size() > 0) {
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ERROR-COMMAND", args[0], commandCompute.get(0).getCommandString(label).trim());
}
}
}.runTaskAsynchronously(Main.getInst());
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
return args.length == 1 ? subCommandExecutors.stream().filter(internalCommandExecutor -> internalCommandExecutor != null && (args[0].isEmpty() || internalCommandExecutor.getLabel().startsWith(args[0]))).map(InternalSubCommand::getLabel).collect(Collectors.toList()) : null;
}
private String getEmptyLine() {
return TabooLib.getVerint() < 10800 ? "~" : "";
}
private void helpCommand(CommandSender sender, String label) {
sender.sendMessage(getEmptyLine());
sender.sendMessage(subExecutor.getCommandTitle());
sender.sendMessage(getEmptyLine());
subCommandExecutors.stream().map(subCommand -> subCommand == null ? getEmptyLine() : subCommand.getCommandString(label)).forEach(sender::sendMessage);
sender.sendMessage(getEmptyLine());
}
private boolean isConfirmType(CommandSender sender, InternalSubCommandType commandType) {
return commandType == InternalSubCommandType.ALL || sender instanceof ConsoleCommandSender && commandType == InternalSubCommandType.CONSOLE;
}
}

View File

@ -1,20 +0,0 @@
package me.skymc.taboolib.commands.internal;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
/**
* @author Bkm016
* @since 2018-04-17
*/
public interface InternalSubCommand {
String getLabel();
String getDescription();
InternalArgument[] getArguments();
void onCommand(CommandSender sender, Command command, String label, String[] args);
}

View File

@ -1,11 +0,0 @@
package me.skymc.taboolib.commands.internal;
/**
* @author Bkm016
* @since 2018-04-17
*/
public enum InternalSubCommandType {
CONSOLE, PLAYER, ALL
}

View File

@ -0,0 +1,52 @@
package me.skymc.taboolib.commands.internal.type;
import java.util.Objects;
/**
* @author Bkm016
* @since 2018-04-17
*/
public class CommandArgument {
private String name;
private boolean required;
public String getName() {
return name;
}
public boolean isRequired() {
return required;
}
public CommandArgument(String name) {
this(name, true);
}
public CommandArgument(String name, boolean required) {
this.name = name;
this.required = required;
}
@Override
public String toString() {
return required ? "§7[§8" + name + "§7]" : "§7<§8" + name + "§7>";
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CommandArgument)) {
return false;
}
CommandArgument that = (CommandArgument) o;
return Objects.equals(getName(), that.getName()) && isRequired() == that.isRequired();
}
@Override
public int hashCode() {
return Objects.hash(getName(), isRequired());
}
}

View File

@ -0,0 +1,18 @@
package me.skymc.taboolib.commands.internal.type;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @Author sky
* @Since 2018-05-09 22:38
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandRegister {
double priority() default 0;
}

View File

@ -0,0 +1,11 @@
package me.skymc.taboolib.commands.internal.type;
/**
* @author Bkm016
* @since 2018-04-17
*/
public enum CommandType {
CONSOLE, PLAYER, ALL
}

View File

@ -2,9 +2,9 @@ package me.skymc.taboolib.commands.plugin;
import com.google.common.base.Joiner;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.internal.InternalArgument;
import me.skymc.taboolib.commands.internal.InternalCommandExecutor;
import me.skymc.taboolib.commands.internal.InternalSubCommandExecutor;
import me.skymc.taboolib.commands.internal.BaseMainCommand;
import me.skymc.taboolib.commands.internal.BaseSubCommand;
import me.skymc.taboolib.commands.internal.type.CommandArgument;
import me.skymc.taboolib.plugin.PluginUtils;
import me.skymc.taboolib.string.ArrayUtils;
import org.bukkit.Bukkit;
@ -20,9 +20,9 @@ import java.util.stream.Collectors;
* @Author sky
* @Since 2018-05-07 20:14
*/
public class TabooLibPluginCommand extends InternalCommandExecutor {
public class TabooLibPluginMainCommand extends BaseMainCommand {
public TabooLibPluginCommand() {
public TabooLibPluginMainCommand() {
listCommand();
infoCommand();
loadCommand();
@ -36,7 +36,7 @@ public class TabooLibPluginCommand extends InternalCommandExecutor {
}
void loadCommand() {
registerSubCommandExecutor(new InternalSubCommandExecutor() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
@ -49,8 +49,8 @@ public class TabooLibPluginCommand extends InternalCommandExecutor {
}
@Override
public InternalArgument[] getArguments() {
return new InternalArgument[]{new InternalArgument(TLocale.asString("COMMANDS.TPLUGIN.LOAD.ARGUMENTS.0"), true)};
public CommandArgument[] getArguments() {
return new CommandArgument[]{new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.LOAD.ARGUMENTS.0"), true)};
}
@Override
@ -74,7 +74,7 @@ public class TabooLibPluginCommand extends InternalCommandExecutor {
}
void unloadCommand() {
registerSubCommandExecutor(new InternalSubCommandExecutor() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
@ -87,8 +87,8 @@ public class TabooLibPluginCommand extends InternalCommandExecutor {
}
@Override
public InternalArgument[] getArguments() {
return new InternalArgument[]{new InternalArgument(TLocale.asString("COMMANDS.TPLUGIN.UNLOAD.ARGUMENTS.0"), true)};
public CommandArgument[] getArguments() {
return new CommandArgument[]{new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.UNLOAD.ARGUMENTS.0"), true)};
}
@Override
@ -115,7 +115,7 @@ public class TabooLibPluginCommand extends InternalCommandExecutor {
}
void reloadCommand() {
registerSubCommandExecutor(new InternalSubCommandExecutor() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
@ -128,8 +128,8 @@ public class TabooLibPluginCommand extends InternalCommandExecutor {
}
@Override
public InternalArgument[] getArguments() {
return new InternalArgument[]{new InternalArgument(TLocale.asString("COMMANDS.TPLUGIN.RELOAD.ARGUMENTS.0"), true)};
public CommandArgument[] getArguments() {
return new CommandArgument[]{new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.RELOAD.ARGUMENTS.0"), true)};
}
@Override
@ -149,7 +149,7 @@ public class TabooLibPluginCommand extends InternalCommandExecutor {
}
void infoCommand() {
registerSubCommandExecutor(new InternalSubCommandExecutor() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
@ -162,8 +162,8 @@ public class TabooLibPluginCommand extends InternalCommandExecutor {
}
@Override
public InternalArgument[] getArguments() {
return new InternalArgument[]{new InternalArgument(TLocale.asString("COMMANDS.TPLUGIN.INFO.ARGUMENTS.0"), true)};
public CommandArgument[] getArguments() {
return new CommandArgument[]{new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.INFO.ARGUMENTS.0"), true)};
}
@Override
@ -189,7 +189,7 @@ public class TabooLibPluginCommand extends InternalCommandExecutor {
}
void listCommand() {
registerSubCommandExecutor(new InternalSubCommandExecutor() {
registerSubCommand(new BaseSubCommand() {
@Override
public String getLabel() {
@ -202,8 +202,8 @@ public class TabooLibPluginCommand extends InternalCommandExecutor {
}
@Override
public InternalArgument[] getArguments() {
return new InternalArgument[0];
public CommandArgument[] getArguments() {
return new CommandArgument[0];
}
@Override

View File

@ -1,50 +0,0 @@
package me.skymc.taboolib.commands.sub;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.Main.StorageType;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.fileutils.ConfigUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.Objects;
public class ImportCommand extends SubCommand {
public ImportCommand(CommandSender sender, String[] args) {
super(sender, args);
if (isPlayer()) {
TLocale.sendTo(sender, "COMMANDS.GLOBAL.ONLY-PLAYER");
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");
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 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");
}
}

View File

@ -1,31 +0,0 @@
package me.skymc.taboolib.commands.sub.cycle;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;
import org.bukkit.command.CommandSender;
public class CycleCommand extends SubCommand {
public CycleCommand(CommandSender sender, String[] args) {
super(sender, args);
if (args.length > 1) {
if ("list".equalsIgnoreCase(args[1])) {
new CycleListCommand(sender, args);
} else if ("info".equalsIgnoreCase(args[1])) {
new CycleInfoCommand(sender, args);
} else if ("reset".equalsIgnoreCase(args[1])) {
new CycleResetCommand(sender, args);
} else if ("update".equalsIgnoreCase(args[1])) {
new CycleUpdateCommand(sender, args);
}
} else {
TLocale.sendTo(sender, "COMMANDS.PARAMETER.UNKNOWN");
}
}
@Override
public boolean command() {
return true;
}
}

View File

@ -1,27 +0,0 @@
package me.skymc.taboolib.commands.sub.shell;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;
import org.bukkit.command.CommandSender;
public class ShellCommand extends SubCommand {
public ShellCommand(CommandSender sender, String[] args) {
super(sender, args);
if (args.length > 1) {
if ("load".equalsIgnoreCase(args[1])) {
new ShellLoadCommand(sender, args);
} else if ("unload".equalsIgnoreCase(args[1])) {
new ShellUnloadCommand(sender, args);
}
} else {
TLocale.sendTo(sender, "COMMANDS.PARAMETER.UNKNOWN");
}
}
@Override
public boolean command() {
return true;
}
}

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;

View File

@ -1,15 +1,13 @@
package me.skymc.taboolib.commands.sub.cycle;
import java.util.concurrent.TimeUnit;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import org.bukkit.command.CommandSender;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.other.DateUtils;
import me.skymc.taboolib.timecycle.TimeCycle;
import me.skymc.taboolib.timecycle.TimeCycleManager;
import org.bukkit.command.CommandSender;
import java.util.concurrent.TimeUnit;
public class CycleInfoCommand extends SubCommand {

View File

@ -1,18 +1,9 @@
package me.skymc.taboolib.commands.sub.cycle;
package me.skymc.taboolib.commands.taboolib;
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 me.skymc.taboolib.timecycle.TimeCycle;
import me.skymc.taboolib.timecycle.TimeCycleManager;
import org.bukkit.inventory.ItemFlag;
import java.util.Arrays;
import org.bukkit.command.CommandSender;
public class CycleListCommand extends SubCommand {

View File

@ -1,18 +1,16 @@
package me.skymc.taboolib.commands.sub.cycle;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.database.GlobalDataManager;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.timecycle.TimeCycle;
import me.skymc.taboolib.timecycle.TimeCycleEvent;
import me.skymc.taboolib.timecycle.TimeCycleInitializeEvent;
import me.skymc.taboolib.timecycle.TimeCycleManager;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
public class CycleResetCommand extends SubCommand {

View File

@ -1,17 +1,15 @@
package me.skymc.taboolib.commands.sub.cycle;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.database.GlobalDataManager;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.timecycle.TimeCycle;
import me.skymc.taboolib.timecycle.TimeCycleEvent;
import me.skymc.taboolib.timecycle.TimeCycleManager;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
public class CycleUpdateCommand extends SubCommand {

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;

View File

@ -0,0 +1,50 @@
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.Main.StorageType;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.fileutils.ConfigUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.Objects;
public class ImportCommand extends SubCommand {
public ImportCommand(CommandSender sender, String[] args) {
super(sender, args);
if (isPlayer()) {
TLocale.sendTo(sender, "COMMANDS.GLOBAL.ONLY-PLAYER");
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");
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 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");
}
}

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;

View File

@ -1,7 +1,7 @@
package me.skymc.taboolib.commands.sub.itemlist;
package me.skymc.taboolib.commands.taboolib;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.commands.sub.itemlist.listener.ItemLibraryPatch;
import me.skymc.taboolib.commands.taboolib.listener.ListenerItemListCommand;
import me.skymc.taboolib.other.NumberUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -16,9 +16,9 @@ public class ItemListCommand extends SubCommand {
super(sender, args);
if (isPlayer()) {
if (args.length == 1) {
ItemLibraryPatch.openInventory((Player) sender, 1);
ListenerItemListCommand.openInventory((Player) sender, 1);
} else {
ItemLibraryPatch.openInventory((Player) sender, NumberUtils.getInteger(args[1]));
ListenerItemListCommand.openInventory((Player) sender, NumberUtils.getInteger(args[1]));
}
}
}

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
@ -15,6 +15,9 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
* @author sky
*/
public class SaveCommand extends SubCommand {
public SaveCommand(CommandSender sender, String[] args) {

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub.shell;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;
@ -12,13 +12,13 @@ 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;
}

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub.shell;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;

View File

@ -1,7 +1,7 @@
package me.skymc.taboolib.commands.sub.sounds;
package me.skymc.taboolib.commands.taboolib;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.commands.sub.sounds.listener.SoundsLibraryPatch;
import me.skymc.taboolib.commands.taboolib.listener.ListenerSoundsCommand;
import me.skymc.taboolib.other.NumberUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -16,11 +16,11 @@ public class SoundsCommand extends SubCommand {
super(sender, args);
if (isPlayer()) {
if (args.length == 1) {
SoundsLibraryPatch.openInventory((Player) sender, 1, null);
ListenerSoundsCommand.openInventory((Player) sender, 1, null);
} else if (args.length == 2) {
SoundsLibraryPatch.openInventory((Player) sender, NumberUtils.getInteger(args[1]), null);
ListenerSoundsCommand.openInventory((Player) sender, NumberUtils.getInteger(args[1]), null);
} else {
SoundsLibraryPatch.openInventory((Player) sender, NumberUtils.getInteger(args[1]), args[2]);
ListenerSoundsCommand.openInventory((Player) sender, NumberUtils.getInteger(args[1]), args[2]);
}
}
}

View File

@ -1,8 +1,8 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.team.TagAPI;
import me.skymc.taboolib.team.TagManager;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@ -28,6 +28,8 @@ public class TagDeleteCommand extends SubCommand {
}
TagManager.getInst().removeData(player);
TagAPI.removePlayerDisplayName(player);
if (sender instanceof Player) {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.PLAYERTAG.SUCCESS-DELETE", args[1]);
}

View File

@ -0,0 +1,41 @@
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.clip.placeholderapi.PlaceholderAPI;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.team.TagAPI;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* @author sky
* @since 2018-03-19 23:13:35
*/
public class TagDisplayCommand extends SubCommand {
public TagDisplayCommand(CommandSender sender, String[] args) {
super(sender, args);
if (args.length < 3) {
TLocale.sendTo(sender, "COMMANDS.PARAMETER.UNKNOWN");
return;
}
Player player = Bukkit.getPlayerExact(args[1]);
if (player == null) {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.PLAYERTAG.INVALID-PLAYER", args[1]);
return;
}
String value = getArgs(2).replace("&", "§");
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
value = PlaceholderAPI.setPlaceholders(player, value);
}
TagAPI.setPlayerDisplayName(player, value);
if (sender instanceof Player) {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.PLAYERTAG.SUCCESS-DISPLAY-SET", args[1], value);
}
}
}

View File

@ -1,15 +1,13 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.clip.placeholderapi.PlaceholderAPI;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.team.TagManager;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import me.clip.placeholderapi.PlaceholderAPI;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.team.TagManager;
/**
* @author sky
* @since 2018-03-19 23:13:35

View File

@ -1,9 +1,8 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.clip.placeholderapi.PlaceholderAPI;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.team.TagManager;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub;
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub.itemlist.listener;
package me.skymc.taboolib.commands.taboolib.listener;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.inventory.InventoryUtil;
@ -23,7 +23,7 @@ import java.util.List;
* @author sky
* @since 2018年2月4日 下午4:35:00
*/
public class ItemLibraryPatch implements Listener {
public class ListenerItemListCommand implements Listener {
/**
* 打开物品库界面

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.sub.sounds.listener;
package me.skymc.taboolib.commands.taboolib.listener;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.inventory.InventoryUtil;
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
* @author sky
* @since 2018年2月4日 下午4:35:00
*/
public class SoundsLibraryPatch implements Listener {
public class ListenerSoundsCommand implements Listener {
public static void openInventory(Player player, int page, String search) {
if (page < 1) {

View File

@ -1,7 +1,5 @@
package me.skymc.taboolib.cooldown.seconds;
import java.util.concurrent.ConcurrentHashMap;
import com.ilummc.tlib.resources.TLocale;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -9,6 +7,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.plugin.Plugin;
import java.util.concurrent.ConcurrentHashMap;
public class CooldownUtils2 implements Listener {
private static ConcurrentHashMap<String, CooldownPack2> packlist = new ConcurrentHashMap<>();

View File

@ -121,27 +121,6 @@ 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();
@ -202,6 +181,10 @@ 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();
@ -215,6 +198,23 @@ 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, 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);
}

View File

@ -1,20 +1,18 @@
package me.skymc.taboolib.database;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.Main.StorageType;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.playerdata.DataUtils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.concurrent.ConcurrentHashMap;
import com.ilummc.tlib.resources.TLocale;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.scheduler.BukkitRunnable;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.Main.StorageType;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.playerdata.DataUtils;
public class GlobalDataManager {
public static FileConfiguration data = DataUtils.addPluginData("TabooLibrary-Variable.yml", null);

View File

@ -7,7 +7,6 @@ import me.skymc.taboolib.events.PlayerLoadedEvent;
import me.skymc.taboolib.exception.PlayerOfflineException;
import me.skymc.taboolib.fileutils.ConfigUtils;
import me.skymc.taboolib.fileutils.FileUtils;
import me.skymc.taboolib.message.MsgUtils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;

View File

@ -1,9 +1,9 @@
package me.skymc.taboolib.enchantment;
import java.lang.reflect.Field;
import org.bukkit.enchantments.Enchantment;
import java.lang.reflect.Field;
public class EnchantmentUtils {
public static void setAcceptingNew(boolean value) {

View File

@ -0,0 +1,85 @@
package me.skymc.taboolib.events.itag;
import com.google.common.base.Preconditions;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import java.util.UUID;
/**
* @author md_5
*/
public class AsyncPlayerReceiveNameTagEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private final Player player;
private final Player namedPlayer;
private String tag;
private UUID UUID;
private boolean tagModified;
private boolean UUIDModified;
public Player getPlayer() {
return player;
}
public Player getNamedPlayer() {
return namedPlayer;
}
public String getTag() {
return tag;
}
public java.util.UUID getUUID() {
return UUID;
}
public boolean isTagModified() {
return tagModified;
}
public boolean isUUIDModified() {
return UUIDModified;
}
public AsyncPlayerReceiveNameTagEvent(Player who, Player namedPlayer, String initialName, UUID uuid) {
Preconditions.checkNotNull(who, "who");
Preconditions.checkNotNull(namedPlayer, "namedPlayer");
Preconditions.checkNotNull(initialName, "initialName");
Preconditions.checkNotNull(uuid, "uuid");
this.player = who;
this.namedPlayer = namedPlayer;
this.tag = initialName;
this.tagModified = namedPlayer.getName().equals(initialName);
this.UUID = uuid;
}
public boolean setTag(String tag) {
Preconditions.checkNotNull(tag, "tag");
this.tag = tag;
this.tagModified = true;
return tag.length() < 16;
}
public void setUUID(UUID uuid) {
Preconditions.checkNotNull(uuid, "uuid");
this.UUID = uuid;
this.UUIDModified = true;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,57 @@
package me.skymc.taboolib.events.itag;
import com.google.common.base.Preconditions;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
* @author md_5
*/
public class PlayerReceiveNameTagEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final Player namedPlayer;
private String tag;
private boolean modified;
public Player getNamedPlayer() {
return namedPlayer;
}
public String getTag() {
return tag;
}
public boolean isModified() {
return modified;
}
public PlayerReceiveNameTagEvent(Player who, Player namedPlayer, String initialName) {
super(who);
Preconditions.checkNotNull(who, "who");
Preconditions.checkNotNull(namedPlayer, "namedPlayer");
Preconditions.checkNotNull(initialName, "initialName");
this.namedPlayer = namedPlayer;
this.tag = initialName;
}
public boolean setTag(String tag) {
Preconditions.checkNotNull(tag, "tag");
this.tag = tag;
this.modified = true;
return tag.length() < 16;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -2,7 +2,6 @@ package me.skymc.taboolib.fileutils;
import com.google.common.collect.Maps;
import com.google.common.io.Files;
import com.ilummc.tlib.TLib;
import com.ilummc.tlib.bean.Property;
import com.ilummc.tlib.resources.TLocale;
import com.ilummc.tlib.util.Ref;

View File

@ -1,7 +1,6 @@
package me.skymc.taboolib.fileutils;
import ch.njol.util.Closeable;
import me.skymc.taboolib.message.MsgUtils;
import org.apache.commons.io.IOUtils;
import java.io.*;

View File

@ -9,7 +9,6 @@ import me.skymc.taboolib.itemnbtapi.NBTItem;
import me.skymc.taboolib.itemnbtapi.NBTList;
import me.skymc.taboolib.itemnbtapi.NBTListCompound;
import me.skymc.taboolib.itemnbtapi.NBTType;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.other.NumberUtils;
import me.skymc.taboolib.string.Language;
import org.bukkit.Color;
@ -29,10 +28,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.IntStream;
public class ItemUtils {
@ -128,7 +127,7 @@ public class ItemUtils {
finalItemsFolder.mkdir();
}
// 检查固定物品库中的物品
Arrays.stream(Objects.requireNonNull(finalItemsFolder.listFiles())).forEach(file -> loadItemsFile(file, true));
Arrays.stream(finalItemsFolder.listFiles()).forEach(file -> loadItemsFile(file, true));
TLocale.Logger.info("ITEM-UTILS.SUCCESS-LOAD-CACHES", String.valueOf(itemCaches.size() + itemCachesFinal.size()));
}
@ -274,8 +273,9 @@ public class ItemUtils {
return "generic.armor";
case "luck":
return "generic.luck";
default:
return null;
}
return null;
}
/**

View File

@ -1,9 +1,9 @@
package me.skymc.taboolib.itemnbtapi;
import java.util.Set;
import me.skymc.taboolib.TabooLib;
import java.util.Set;
public class NBTCompound {
private String compundName;

View File

@ -356,7 +356,7 @@ public class JSONFormatter {
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() {

View File

@ -1,18 +1,17 @@
package me.skymc.taboolib.jsonformatter.hover;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.inventory.ItemUtils;
import me.skymc.taboolib.json.JSONObject;
import me.skymc.taboolib.nms.item.DabItemUtils;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class ShowItemEvent extends HoverEvent{

View File

@ -1,11 +1,10 @@
package me.skymc.taboolib.listener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.message.MsgUtils;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import pw.yumc.Yum.events.PluginNetworkEvent;
/**

View File

@ -1,11 +1,5 @@
package me.skymc.taboolib.listener;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.ServerCommandEvent;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.database.PlayerDataManager;
@ -13,6 +7,11 @@ import me.skymc.taboolib.itemnbtapi.NBTItem;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.permission.PermissionUtils;
import me.skymc.taboolib.playerdata.DataUtils;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.ServerCommandEvent;
public class ListenerPlayerCommand implements Listener {

View File

@ -1,12 +1,11 @@
package me.skymc.taboolib.listener;
import me.skymc.taboolib.playerdata.DataUtils;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import me.skymc.taboolib.playerdata.DataUtils;
public class ListenerPlayerQuit implements Listener{
@EventHandler (priority = EventPriority.MONITOR)

View File

@ -1,5 +1,7 @@
package me.skymc.taboolib.methods;
import org.bukkit.Bukkit;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@ -7,8 +9,6 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
/**
* <b>ReflectionUtils</b>
* <p>

View File

@ -3,7 +3,7 @@ package me.skymc.taboolib.mysql;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.Executors;
@Deprecated
public class MysqlConnection {
@ -103,7 +103,7 @@ public class MysqlConnection {
return;
}
StringBuilder stringBuilder = new StringBuilder("");
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < list.length; i++) {
if (i + 1 < list.length) {
@ -130,8 +130,8 @@ public class MysqlConnection {
return;
}
StringBuilder listbuilder = new StringBuilder("");
StringBuilder valuebuilder = new StringBuilder("");
StringBuilder listbuilder = new StringBuilder();
StringBuilder valuebuilder = new StringBuilder();
for (int i = 0; i < list.length; i++) {
if (i + 1 < list.length) {

View File

@ -5,11 +5,7 @@ import com.ilummc.tlib.util.Strings;
import me.skymc.taboolib.Main;
import org.bukkit.plugin.Plugin;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.*;
import java.util.*;
/**

View File

@ -1,24 +1,7 @@
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.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemorySection;
@ -32,6 +15,13 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
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.*;
import java.util.logging.Level;
@SuppressWarnings({ "rawtypes", "unchecked" })
@Deprecated
public class NMSUtil19 {

View File

@ -1,15 +1,5 @@
package me.skymc.taboolib.nms.item;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.json.JSONArray;
import me.skymc.taboolib.json.JSONObject;
@ -17,6 +7,15 @@ import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.nms.item.impl._164ItemUtils;
import me.skymc.taboolib.nms.item.impl._1710ItemUtils;
import me.skymc.taboolib.nms.item.impl._194ItemUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
public class DabItemUtils {

View File

@ -1,14 +1,13 @@
package me.skymc.taboolib.nms.item;
import me.skymc.taboolib.json.JSONArray;
import me.skymc.taboolib.json.JSONObject;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import org.bukkit.inventory.ItemStack;
import me.skymc.taboolib.json.JSONArray;
import me.skymc.taboolib.json.JSONObject;
public interface IDabItemUtils{
//@formatter:off

View File

@ -1,5 +1,14 @@
package me.skymc.taboolib.particle;
import me.skymc.taboolib.methods.ReflectionUtils;
import me.skymc.taboolib.methods.ReflectionUtils.PackageType;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@ -9,16 +18,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import me.skymc.taboolib.methods.ReflectionUtils;
import me.skymc.taboolib.methods.ReflectionUtils.PackageType;
/**
* <b>ParticleEffect Library</b>
* <p>

View File

@ -1,8 +1,7 @@
package me.skymc.taboolib.particle;
import org.bukkit.Location;
import me.skymc.taboolib.TabooLib;
import org.bukkit.Location;
public class ParticlePack {

View File

@ -1,10 +1,9 @@
package me.skymc.taboolib.permission;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import me.skymc.taboolib.Main;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
public class PermissionUtils {

View File

@ -1,13 +1,13 @@
package me.skymc.taboolib.player;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
@SuppressWarnings("deprecation")
public class PlayerUtils {

View File

@ -5,7 +5,6 @@ import me.skymc.taboolib.Main;
import me.skymc.taboolib.database.PlayerDataManager;
import me.skymc.taboolib.exception.PlayerOfflineException;
import me.skymc.taboolib.fileutils.FileUtils;
import me.skymc.taboolib.message.MsgUtils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;

View File

@ -265,11 +265,11 @@ 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);
}

View File

@ -1,11 +1,10 @@
package me.skymc.taboolib.regen;
import java.util.Map;
import org.bukkit.Location;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import org.bukkit.Location;
import java.util.Map;
@Deprecated
public class WorldGuardUtils {

View File

@ -1,12 +1,11 @@
package me.skymc.taboolib.skript;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
import ch.njol.skript.Skript;
import ch.njol.skript.lang.ExpressionType;
import me.skymc.taboolib.skript.expression.ExpressionItemCache;
import me.skymc.taboolib.skript.expression.ExpressionTabooCodeItem;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
/**
* @author sky

View File

@ -1,13 +1,12 @@
package me.skymc.taboolib.skript.expression;
import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import me.skymc.taboolib.inventory.ItemUtils;
import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
/**
* @author sky

View File

@ -1,13 +1,12 @@
package me.skymc.taboolib.skript.expression;
import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import me.skymc.taboocode.TabooCodeItem;
import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
/**
* @author sky

View File

@ -1,17 +1,16 @@
package me.skymc.taboolib.string;
import me.skymc.taboolib.message.MsgUtils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import me.skymc.taboolib.message.MsgUtils;
@Deprecated
public class LanguagePack {

View File

@ -1,13 +1,12 @@
package me.skymc.taboolib.string;
import me.skymc.taboolib.message.MsgUtils;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.util.Collections;
import java.util.List;
import org.bukkit.plugin.Plugin;
import me.skymc.taboolib.message.MsgUtils;
@Deprecated
public class LanguageUtils {

View File

@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.FileNotFoundException;
/**
* @author sky

View File

@ -4,7 +4,7 @@ package me.skymc.taboolib.string.obfuscated;
public class FZ {
public static String toByte(final String string) {
final StringBuilder sb = new StringBuilder("");
final StringBuilder sb = new StringBuilder();
final byte[] bs = string.getBytes();
byte[] array;
for (int length = (array = bs).length, i = 0; i < length; ++i) {
@ -33,7 +33,7 @@ public class FZ {
}
public static String load(final String string, final int power) {
final StringBuilder sb = new StringBuilder("");
final StringBuilder sb = new StringBuilder();
char[] charArray;
for (int length = (charArray = string.toCharArray()).length, j = 0; j < length; ++j) {
int i;
@ -46,7 +46,7 @@ public class FZ {
public static String load2(final String string, final int power) {
final String[] value = string.split("#");
final StringBuilder sb = new StringBuilder("");
final StringBuilder sb = new StringBuilder();
String[] array;
for (int length = (array = value).length, j = 0; j < length; ++j) {
final String c = array[j];

View File

@ -0,0 +1,150 @@
package me.skymc.taboolib.team;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.google.common.base.Preconditions;
import com.ilummc.tlib.bungee.api.ChatColor;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.events.itag.AsyncPlayerReceiveNameTagEvent;
import me.skymc.taboolib.events.itag.PlayerReceiveNameTagEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.*;
import java.util.stream.IntStream;
/**
* @Author sky
* @Since 2018-05-09 21:03
*/
public class TagAPI implements Listener {
private static final int[] uuidSplit = new int[]{0, 8, 12, 16, 20, 32};
private static boolean loaded = false;
private static HashMap<Integer, Player> entityIdMap = new HashMap<>();
private static HashMap<UUID, String> playerData = new HashMap<>();
TagAPI() {
}
public static void inst() {
assert !loaded : "TagAPI is already instanced!";
loaded = true;
Bukkit.getServer().getOnlinePlayers().forEach(player -> entityIdMap.put(player.getEntityId(), player));
Bukkit.getPluginManager().registerEvents(new TagAPI(), Main.getInst());
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(Main.getInst(), PacketType.Play.Server.PLAYER_INFO) {
@Override
public void onPacketSending(PacketEvent event) {
if (event.getPacket().getPlayerInfoAction().read(0) != EnumWrappers.PlayerInfoAction.ADD_PLAYER) {
return;
}
List<PlayerInfoData> newPlayerInfo = new ArrayList<>();
for (PlayerInfoData playerInfo : event.getPacket().getPlayerInfoDataLists().read(0)) {
Player player;
if (playerInfo == null || playerInfo.getProfile() == null || (player = Bukkit.getServer().getPlayer(playerInfo.getProfile().getUUID())) == null) {
// Unknown Player
newPlayerInfo.add(playerInfo);
continue;
}
newPlayerInfo.add(new PlayerInfoData(getSentName(player.getEntityId(), playerInfo.getProfile(), event.getPlayer()), playerInfo.getPing(), playerInfo.getGameMode(), playerInfo.getDisplayName()));
}
event.getPacket().getPlayerInfoDataLists().write(0, newPlayerInfo);
}
});
}
public static String getPlayerDisplayName(Player player) {
return playerData.getOrDefault(player.getUniqueId(), player.getName());
}
public static void setPlayerDisplayName(Player player, String name) {
String nameColored = ChatColor.translateAlternateColorCodes('&', name);
player.setDisplayName(nameColored);
player.setPlayerListName(nameColored);
playerData.put(player.getUniqueId(), nameColored);
Bukkit.getScheduler().runTask(Main.getInst(), () -> refreshPlayer(player));
}
public static void removePlayerDisplayName(Player player) {
player.setDisplayName(null);
player.setPlayerListName(null);
playerData.remove(player.getUniqueId());
Bukkit.getScheduler().runTask(Main.getInst(), () -> refreshPlayer(player));
}
public static void refreshPlayer(Player player) {
Preconditions.checkState(Main.getInst().isEnabled(), "Not Enabled!");
Preconditions.checkNotNull(player, "player");
player.getWorld().getPlayers().forEach(playerFor -> refreshPlayer(player, playerFor));
}
public static void refreshPlayer(final Player player, final Player forWhom) {
Preconditions.checkState(Main.getInst().isEnabled(), "Not Enabled!");
Preconditions.checkNotNull(player, "player");
Preconditions.checkNotNull(forWhom, "forWhom");
if (player != forWhom && player.getWorld() == forWhom.getWorld() && forWhom.canSee(player)) {
forWhom.hidePlayer(player);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getInst(), () -> forWhom.showPlayer(player), 2);
}
}
public static void refreshPlayer(Player player, Set<Player> forWhom) {
Preconditions.checkState(Main.getInst().isEnabled(), "Not Enabled!");
Preconditions.checkNotNull(player, "player");
Preconditions.checkNotNull(forWhom, "forWhom");
forWhom.forEach(playerFor -> refreshPlayer(player, playerFor));
}
private static WrappedGameProfile getSentName(int sentEntityId, WrappedGameProfile sent, Player destinationPlayer) {
Preconditions.checkState(Bukkit.getServer().isPrimaryThread(), "Can only process events on main thread.");
Player namedPlayer = entityIdMap.get(sentEntityId);
if (namedPlayer == null) {
// They probably were dead when we reloaded
return sent;
}
PlayerReceiveNameTagEvent oldEvent = new PlayerReceiveNameTagEvent(destinationPlayer, namedPlayer, sent.getName());
Bukkit.getServer().getPluginManager().callEvent(oldEvent);
StringBuilder builtUUID = new StringBuilder();
if (!sent.getId().contains("-")) {
IntStream.range(0, uuidSplit.length - 1).forEach(i -> builtUUID.append(sent.getId(), uuidSplit[i], uuidSplit[i + 1]).append("-"));
} else {
builtUUID.append(sent.getId());
}
AsyncPlayerReceiveNameTagEvent newEvent = new AsyncPlayerReceiveNameTagEvent(destinationPlayer, namedPlayer, oldEvent.getTag(), UUID.fromString(builtUUID.toString()));
Bukkit.getServer().getPluginManager().callEvent(newEvent);
return new WrappedGameProfile(newEvent.getUUID(), newEvent.getTag().substring(0, Math.min(newEvent.getTag().length(), 16)));
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
entityIdMap.put(event.getPlayer().getEntityId(), event.getPlayer());
}
@EventHandler
public void onQuit(PlayerQuitEvent event) {
entityIdMap.remove(event.getPlayer().getEntityId());
}
}

View File

@ -6,7 +6,6 @@ import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.fileutils.FileUtils;
import me.skymc.taboolib.message.MsgUtils;
import org.bukkit.scheduler.BukkitRunnable;
/**

View File

@ -1,21 +1,20 @@
package me.skymc.tlm.command.sub;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.inventory.ItemUtils;
import me.skymc.tlm.TLM;
import me.skymc.tlm.inventory.TLMInventoryHolder;
import me.skymc.tlm.module.TabooLibraryModule;
import me.skymc.tlm.module.sub.ModuleInventorySave;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.List;
/**
* @author sky

View File

@ -1,17 +1,16 @@
package me.skymc.tlm.command.sub;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.tlm.TLM;
import me.skymc.tlm.module.TabooLibraryModule;
import me.skymc.tlm.module.sub.ModuleKits;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.List;
/**
* @author sky

View File

@ -1,10 +1,9 @@
package me.skymc.tlm.command.sub;
import org.bukkit.command.CommandSender;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.tlm.module.ITabooLibraryModule;
import me.skymc.tlm.module.TabooLibraryModule;
import org.bukkit.command.CommandSender;
/**
* @author sky

View File

@ -1,12 +1,11 @@
package me.skymc.tlm.command.sub;
import org.bukkit.command.CommandSender;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.tlm.TLM;
import me.skymc.tlm.module.ITabooLibraryModule;
import me.skymc.tlm.module.TabooLibraryModule;
import org.bukkit.command.CommandSender;
/**
* @author sky

View File

@ -1,12 +1,11 @@
package me.skymc.tlm.module.sub;
import me.skymc.tlm.module.ITabooLibraryModule;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.ServerCommandEvent;
import me.skymc.tlm.module.ITabooLibraryModule;
/**
* @author sky
* @since 2018年2月22日 下午1:32:29

View File

@ -121,6 +121,7 @@ COMMANDS:
- '&8[&3&lTabooLib&8] §7指令 §f{0} §7不存在'
- '&8[&3&lTabooLib&8] §7你可能想要:'
- '&8[&3&lTabooLib&8] §7{1}'
COMMAND-REGISTER: '&7自动为插件 &f{0} &7的命令 &f{1} &7注册 &f{2} &7条子命令'
PARAMETER:
UNKNOWN: '&8[&3&lTabooLib&8] &4指令错误'
INSUFFICIENT: '&8[&3&lTabooLib&8] &4参数不足'
@ -129,41 +130,11 @@ COMMANDS:
SUCCESS-NORMAL: '&8[&3&lTabooLib&8] &7重载成功'
SUCCESS-ELAPSED-TIME: '&8[&3&lTabooLib&8] &7重载成功, 耗时: &f{0} ms'
TABOOLIB:
HELP:
- ''
- '§b§l----- §3§lTaooLib Commands §b§l-----'
- ''
- '&f /{0} save §8[§7名称§8] &6- §e保存手中物品'
- '&f /{0} item §8[§7名称§8] §8<§7玩家§8> §8<§7数量§8> &6- §e给予玩家物品'
- '&f /{0} iteminfo &6- §e查看物品信息'
- '&f /{0} itemlist &6- §e查看所有物品'
- '&f /{0} itemreload &6- §e重载物品缓存'
- ''
- '&f /{0} attributes &6- §e查看所有属性'
- '&f /{0} enchants &6- §e查看所有附魔'
- '&f /{0} potions &6- §e查看所有药水'
- '&f /{0} flags &6- §e查看所有标签'
- '&f /{0} slots &6- §e查看所有部位'
- '&f /{0} sounds &6- §e查看所有音效'
- ''
- '&f /{0} getvariable §8[§7-s|a§8] §8[§7键§8] &6- §e查看变量'
- '&f /{0} setvariable §8[§7-s|a§8] §8[§7键§8] §8[§7值§8] &6- §e更改变量'
- ''
- '&f /{0} cycle list &6- §e列出所有时间检查器'
- '&f /{0} cycle info §8[§7名称§8] &6- §e查询检查器信息'
- '&f /{0} cycle reset §8[§7名称§8] &6- §e初始化时间检查器'
- '&f /{0} cycle update §8[§7名称§8] &6- §e更新时间检查器'
- ''
- '&f /{0} shell load §8[§7名称§8] &6- §e载入某个脚本'
- '&f /{0} shell unload §8[§7名称§8] &6- §e卸载某个脚本'
- ''
- '&f /{0} tagprefix §8[§7名称§8] §8[§7文本§8] &6- §e设置玩家头顶前缀'
- '&f /{0} tagsuffix §8[§7名称§8] §8[§7文本§8] &6- §e设置玩家头顶后缀'
- '&f /{0} tagdelete §8[§7名称§8] &6- §e删除玩家称号数据'
- ''
- '&f /{0} importdata &6- §4向数据库导入本地数据 §8(该操作将会清空数据库)'
- ''
COMMAND-TITLE: '§b§l----- §3§lTabooLib Commands §b§l-----'
SAVE:
DESCRIPTION: '载入插件'
ARGUMENTS:
0: '名称'
INVALID-NAME: '&8[&3&lTabooLib&8] &4请输入正确的名称'
INVALID-ITEM: '&8[&3&lTabooLib&8] &4请手持正确的物品'
INVALID-ITEM-FINAL-EXISTS: '&8[&3&lTabooLib&8] &4该名称所对应的物品保存于固定物品库中, 无法覆盖'
@ -172,34 +143,81 @@ COMMANDS:
GUIDE-QUIT: '&8[&3&lTabooLib&8] &7退出引导'
SUCCESS: '&8[&3&lTabooLib&8] &7物品 &f{0} &7已替换'
ITEM:
DESCRIPTION: '给予玩家物品'
ARGUMENTS:
0: '名称'
1: '玩家'
2: '数量'
INVALID-NAME: '&8[&3&lTabooLib&8] &4请输入正确的名称'
INVALID-ITEM: '&8[&3&lTabooLib&8] &4物品 &c{0} &4不存在'
INVALID-PLAYER: '&8[&3&lTabooLib&8] &4玩家 &c{0} &4不在线'
INVALID-NUMBER: '&8[&3&lTabooLib&8] &4数量必须大于0'
SUCCESS: '&8[&3&lTabooLib&8] &7物品已发送至玩家 &f{0} &7的背包中'
ITEMRELOAD:
DESCRIPTION: '重载物品缓存'
SUCCESS-RELOAD: '&8[&3&lTabooLib&8] &7重载成功'
VARIABLE:
DESCRIPTION:
GET: '查看变量'
SET: '设置变量'
ARGUMENTS:
GET:
0: '-s|-a'
1: '键'
SET:
0: '-s|-a'
1: '键'
2: '值'
WRITE-ERROR-TYPE: '&8[&3&lTabooLib&8] &4请输入正确的写入方式: &c-s&4、&c-a'
WRITE-SUCCESS: '&8[&3&lTabooLib&8] &7写入完成, 耗时: &f{0} &7(ms)'
READ-ERROR-TYPE: '&8[&3&lTabooLib&8] &4请输入正确的写入方式: &c-s&4、&c-a'
READ-RESULT: '&8[&3&lTabooLib&8] &7变量 &f{0} &7的值为: &f{1}'
READ-SUCCESS: '&8[&3&lTabooLib&8] &7写入完成, 耗时: &f{0} &7(ms)'
IMPORTDATA:
DESCRIPTION: '§4向数据库导入本地数据 §8(该操作将会清空数据库)'
CLEARING: '&8[&3&lTabooLib&8] &7正在清空数据库...'
EMPTYDATA: '&8[&3&lTabooLib&8] &4没有玩家数据可以导入'
IMPORTING-START: '&8[&3&lTabooLib&8] &7开始导入 &f{0} &7项玩家数据'
IMPORTING-PROGRESS: '&8[&3&lTabooLib&8] &7导入玩家数据: &f{0} &7进度: &f{1}/{2}'
SUCCESS: '&8[&3&lTabooLib&8] &7导入完成'
JAVASHELL:
DESCRIPTION:
LOAD: '载入脚本'
UNLOAD: '卸载脚本'
ARGUMENTS:
LOAD:
0: '名称'
UNLOAD:
0: '名称'
INVALID-NAME: '&8[&3&lTabooLib&8] &4请输入正确的名称'
INVALID-SHELL: '&8[&3&lTabooLib&8] &4脚本 &c{0} &4不存在'
SUCCESS-LOAD: '&8[&3&lTabooLib&8] &7脚本 &f{0} &7已载入'
SUCCESS-UNLOAD: '&8[&3&lTabooLib&8] &7脚本 &f{0} &7已卸载'
PLAYERTAG:
DESCRIPTION:
DISPLAY: '设置玩家展示名称'
PREFIX: '设置玩家头顶前缀'
SUFFIX: '设置玩家头顶后缀'
DELETE: '删除玩家称号数据'
ARGUMENTS:
DISPLAY:
0: '玩家'
1: '文本'
PREFIX:
0: '玩家'
1: '文本'
SUFFIX:
0: '玩家'
1: '文本'
DELETE:
0: '玩家'
INVALID-PLAYER: '&8[&3&lTabooLib&8] &4玩家 &c{0} &4不在线'
SUCCESS-DISPLAY-SET: '&8[&3&lTabooLib&8] &7设置玩家 &f{0} &7的名称为 &f{1}'
SUCCESS-PREFIX-SET: '&8[&3&lTabooLib&8] &7设置玩家 &f{0} &7的前缀为 &f{1}'
SUCCESS-SUFFIX-SET: '&8[&3&lTabooLib&8] &7设置玩家 &f{0} &7的后缀为 &f{1}'
SUCCESS-DELETE: '&8[&3&lTabooLib&8] &7删除玩家 &f{0} &7的称号数据'
INFO:
DESCRIPTION: '查看物品信息'
INVALID-ITEM: '&8[&3&lTabooLib&8] &4请手持正确的物品'
ITEM-INFO:
- ==: JSON
@ -225,6 +243,7 @@ COMMANDS:
nbt:
hover: '{3}'
ITEMLIST:
DESCRIPTION: '查看所有物品'
MENU:
TITLE: '物品库 {0}'
NEXT: '§f上一页'
@ -234,6 +253,7 @@ COMMANDS:
- '§f§m '
- '§f序列号: §8{0}'
SOUNDS:
DESCRIPTION: '查看所有音效'
MENU:
TITLE: '音效库 {0}'
NEXT: '§f上一页'
@ -255,6 +275,18 @@ COMMANDS:
hover: 点击复制音效
suggest: '{0}'
TIMECYCLE:
DESCRIPTION:
LIST: '列出所有时间检查器'
INFO: '查询检查器信息'
RESET: '初始化时间检查器'
UPDATE: '更新时间检查器'
ARGUMENTS:
INFO:
0: '名称'
RESET:
0: '名称'
UPDATE:
0: '名称'
INVALID-CYCLE: '&8[&3&lTabooLib&8] &4检查器 &c{0} &4不存在'
CYCLE-UPDATE: '&8[&3&lTabooLib&8] &7检查器 &f{0} &7已更新'
CYCLE-RESET: '&8[&3&lTabooLib&8] &7检查器 &f{0} &7初始化完成'
@ -281,6 +313,7 @@ COMMANDS:
FOOT:
- ''
ATTRIBUTES:
DESCRIPTION: '查看所有属性'
HEAD:
- ''
- '§b§l----- §3§lItemStack Attributes §b§l-----'
@ -295,6 +328,7 @@ COMMANDS:
FOOT:
- ''
ENCHANTS:
DESCRIPTION: '查看所有附魔'
HEAD:
- ''
- '§b§l----- §3§lItemStack Enchantments §b§l-----'
@ -309,6 +343,7 @@ COMMANDS:
FOOT:
- ''
POTIONS:
DESCRIPTION: '查看所有药水'
HEAD:
- ''
- '§b§l----- §3§lItemStack PotionEffects §b§l-----'
@ -323,6 +358,7 @@ COMMANDS:
FOOT:
- ''
FLAGS:
DESCRIPTION: '查看所有标签'
HEAD:
- ''
- '§b§l----- §3§lItemStack Flags §b§l-----'
@ -337,6 +373,7 @@ COMMANDS:
FOOT:
- ''
SLOTS:
DESCRIPTION: '查看所有部位'
HEAD:
- ''
- '§b§l----- §3§lItemStack Slots §b§l-----'