版本更新至:3.76
调整:开发框架改为 Gradle 新增:Language2 工具新增 [book] 类型
This commit is contained in:
@@ -1,26 +1,14 @@
|
||||
package me.skymc.taboolib;
|
||||
package me.skymc.taboolib;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -12,7 +12,7 @@ import net.md_5.bungee.api.ChatColor;
|
||||
public class TabooLib {
|
||||
|
||||
/**
|
||||
* 获取插件版本
|
||||
* 获取插件版本
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -26,7 +26,7 @@ public class TabooLib {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 NMS 版本
|
||||
* 获取 NMS 版本
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -35,7 +35,7 @@ public class TabooLib {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器 UID
|
||||
* 获取服务器 UID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -47,14 +47,14 @@ public class TabooLib {
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置服务器 UID
|
||||
* 重置服务器 UID
|
||||
*/
|
||||
public static void resetServerUID() {
|
||||
DataUtils.getPluginData("TabooLibrary", null).set("serverUID", UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 向后台发送 DEBUG 信息
|
||||
* 向后台发送 DEBUG 信息
|
||||
*
|
||||
* @param plugin
|
||||
* @param ss
|
||||
@@ -69,7 +69,7 @@ public class TabooLib {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 NMS 版本(数字)
|
||||
* 获取 NMS 版本(数字)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -40,8 +40,8 @@ public class AnvilContainerAPI implements Listener{
|
||||
if (lorelist == null)
|
||||
{
|
||||
list.add("");
|
||||
list.add("§7在上方文本框内输入信息");
|
||||
list.add("§7随后点击右侧输出物品");
|
||||
list.add("§7在上方文本框内输入信息");
|
||||
list.add("§7随后点击右侧输出物品");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -109,7 +109,7 @@ public class AnvilContainerAPI implements Listener{
|
||||
if (e.getPlayer().hasPermission("taboolib.admin"))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
AnvilContainerAPI.send(e.getPlayer(), "EXAMPLE", "在这里输入文本", null);
|
||||
AnvilContainerAPI.send(e.getPlayer(), "EXAMPLE", "在这里输入文本", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class AnvilContainer_V1_11_R1 extends ContainerAnvil {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
*/
|
||||
public static void openAnvil(Player p)
|
||||
{
|
||||
@@ -24,7 +24,7 @@ public class AnvilContainer_V1_8_R3 extends ContainerAnvil {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
*/
|
||||
public static void openAnvil(Player p)
|
||||
{
|
||||
@@ -24,7 +24,7 @@ public class AnvilContainer_V1_9_4 extends ContainerAnvil {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
*/
|
||||
public static void openAnvil(Player p)
|
||||
{
|
||||
@@ -6,7 +6,6 @@ import java.util.HashMap;
|
||||
|
||||
import static org.bukkit.Achievement.*;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public final class BookAchievement {
|
||||
|
||||
private static final HashMap<Achievement, String> achievements = new HashMap<>();
|
||||
@@ -10,6 +10,7 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.border.BevelBorder;
|
||||
|
||||
@Deprecated
|
||||
public class LogClient extends JFrame {
|
||||
|
||||
/**
|
||||
@@ -36,7 +37,7 @@ public class LogClient extends JFrame {
|
||||
|
||||
// CON'T EDIT
|
||||
textArea.setEditable(false);
|
||||
textArea.setFont(new Font("ºÚÌå", 0, 18));
|
||||
textArea.setFont(new Font("黑体", 0, 18));
|
||||
|
||||
textArea.setBackground(Color.black);
|
||||
textArea.setForeground(Color.LIGHT_GRAY);
|
||||
@@ -40,7 +40,7 @@ public class MainCommands implements CommandExecutor{
|
||||
else if (args[0].equalsIgnoreCase("itemreload") || args[0].equalsIgnoreCase("ireload")) {
|
||||
ItemUtils.reloadItemCache();
|
||||
ItemUtils.reloadItemName();
|
||||
MsgUtils.send(sender, "重载成功");
|
||||
MsgUtils.send(sender, "重载成功");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("save")) {
|
||||
new SaveCommand(sender, args);
|
||||
@@ -85,7 +85,7 @@ public class MainCommands implements CommandExecutor{
|
||||
new CycleCommand(sender, args);
|
||||
}
|
||||
else {
|
||||
MsgUtils.send(sender, "&4指令错误");
|
||||
MsgUtils.send(sender, "&4指令错误");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -13,37 +13,37 @@ import me.skymc.taboolib.string.language2.Language2Value;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月13日 下午5:11:01
|
||||
* @since 2018年2月13日 下午5:11:01
|
||||
*/
|
||||
public class Language2Command implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lLanguage2 Commands §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f /language2 send §8[§7玩家/ALL§8] §8[§7语言§8] §8<§7变量§8> §6- §e发送语言提示");
|
||||
sender.sendMessage("§f /language2 reload §6- §e重载语言库");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lLanguage2 Commands §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f /language2 send §8[§7玩家/ALL§8] §8[§7语言§8] §8<§7变量§8> §6- §e发送语言提示");
|
||||
sender.sendMessage("§f /language2 reload §6- §e重载语言库");
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("reload")) {
|
||||
MsgUtils.send(sender, "§7重载中..");
|
||||
MsgUtils.send(sender, "§7重载中..");
|
||||
long time = System.currentTimeMillis();
|
||||
Main.getExampleLangauge2().reload();
|
||||
MsgUtils.send(sender, "§7重载完成! 耗时: &f" + (System.currentTimeMillis() - time) + "ms");
|
||||
MsgUtils.send(sender, "§7重载完成! 耗时: &f" + (System.currentTimeMillis() - time) + "ms");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("send")) {
|
||||
if (args.length < 3) {
|
||||
MsgUtils.send(sender, "§4参数错误");
|
||||
MsgUtils.send(sender, "§4参数错误");
|
||||
}
|
||||
else {
|
||||
// 时间
|
||||
// 时间
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
// 获取语言文件
|
||||
// 获取语言文件
|
||||
Language2Value value = Main.getExampleLangauge2().get(args[2]);
|
||||
// 如果有变量参数
|
||||
// 如果有变量参数
|
||||
if (args.length > 3) {
|
||||
int i = 0;
|
||||
for (String variable : args[3].split("\\|")) {
|
||||
@@ -52,26 +52,26 @@ public class Language2Command implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是公告
|
||||
// 如果是公告
|
||||
if (args[1].equals("ALL")) {
|
||||
// 发送信息
|
||||
// 发送信息
|
||||
value.broadcast();
|
||||
}
|
||||
else {
|
||||
// 获取玩家
|
||||
// 获取玩家
|
||||
Player player = Bukkit.getPlayerExact(args[1]);
|
||||
if (player == null) {
|
||||
MsgUtils.send(sender, "§4玩家不在线");
|
||||
MsgUtils.send(sender, "§4玩家不在线");
|
||||
}
|
||||
else {
|
||||
// 发送信息
|
||||
// 发送信息
|
||||
value.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果发送者是玩家
|
||||
// 如果发送者是玩家
|
||||
if (sender instanceof Player && ((Player) sender).getItemInHand().getType().equals(Material.COMMAND)) {
|
||||
MsgUtils.send(sender, "§7信息已发送, 本次计算耗时: &f" + (System.currentTimeMillis() - time) + "ms");
|
||||
MsgUtils.send(sender, "§7信息已发送, 本次计算耗时: &f" + (System.currentTimeMillis() - time) + "ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,23 +14,23 @@ public class AttributesCommand extends SubCommand {
|
||||
public AttributesCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lItemStack Attributes §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lItemStack Attributes §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
|
||||
String[] attributes = new String[] { "damage", "speed", "attackspeed", "health", "knockback", "armor", "luck" };
|
||||
|
||||
for (String name : attributes) {
|
||||
if (isPlayer()) {
|
||||
JSONFormatter json = new JSONFormatter();
|
||||
json.append(" §7- §f" + name);
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(name));
|
||||
json.append(" §7- §f" + name);
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(name));
|
||||
json.send((Player) sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(" §7- §f" + name);
|
||||
sender.sendMessage(" §7- §f" + name);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
}
|
||||
@@ -15,21 +15,21 @@ public class EnchantCommand extends SubCommand {
|
||||
public EnchantCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lItemStack Enchantments §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lItemStack Enchantments §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
|
||||
for (Enchantment enchant : Enchantment.values()) {
|
||||
if (isPlayer()) {
|
||||
JSONFormatter json = new JSONFormatter();
|
||||
json.append(" §7- §f" + enchant.getId() + ". " + enchant.getName());
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(enchant.getName()));
|
||||
json.append(" §7- §f" + enchant.getId() + ". " + enchant.getName());
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(enchant.getName()));
|
||||
json.send((Player) sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(" §7- §f" + enchant.getId() + ". " + enchant.getName());
|
||||
sender.sendMessage(" §7- §f" + enchant.getId() + ". " + enchant.getName());
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
}
|
||||
@@ -14,21 +14,21 @@ public class FlagCommand extends SubCommand {
|
||||
public FlagCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lItemStack Flags §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lItemStack Flags §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
|
||||
for (ItemFlag flag : ItemFlag.values()) {
|
||||
if (isPlayer()) {
|
||||
JSONFormatter json = new JSONFormatter();
|
||||
json.append(" §7- §f" + flag.name());
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(flag.name()));
|
||||
json.append(" §7- §f" + flag.name());
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(flag.name()));
|
||||
json.send((Player) sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(" §7- §f" + flag.name());
|
||||
sender.sendMessage(" §7- §f" + flag.name());
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package me.skymc.taboolib.commands.sub;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
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;
|
||||
|
||||
public class HelpCommand extends SubCommand {
|
||||
|
||||
public HelpCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
HashMap<String, String> helps = new LinkedHashMap<>();
|
||||
helps.put("/taboolib save §8[§7名称§8]", "§e保存手中物品");
|
||||
helps.put("/taboolib item §8[§7名称§8] §8<§7玩家§8> §8<§7数量§8>", "§e给予玩家物品");
|
||||
helps.put("/taboolib iteminfo", "§e查看物品信息");
|
||||
helps.put("/taboolib itemlist", "§e查看所有物品");
|
||||
helps.put("/taboolib itemreload", "§e重载物品缓存");
|
||||
helps.put("§a", null);
|
||||
helps.put("/taboolib attributes", "§e查看所有属性");
|
||||
helps.put("/taboolib enchants", "§e查看所有附魔");
|
||||
helps.put("/taboolib potions", "§e查看所有药水");
|
||||
helps.put("/taboolib flags", "§e查看所有标签");
|
||||
helps.put("/taboolib slots", "§e查看所有部位");
|
||||
helps.put("§b", null);
|
||||
helps.put("/taboolib getvariable §8[§7-s|a§8] §8[§7键§8]", "§e查看变量");
|
||||
helps.put("/taboolib setvariable §8[§7-s|a§8] §8[§7键§8] §8[§7值§8]", "§e更改变量");
|
||||
helps.put("§c", null);
|
||||
helps.put("/taboolib cycle list", "§e列出所有时间检查器");
|
||||
helps.put("/taboolib cycle info §8[§7名称§8]", "§e查询检查器信息");
|
||||
helps.put("/taboolib cycle reset §8[§7名称§8]", "§e初始化时间检查器");
|
||||
helps.put("/taboolib cycle update §8[§7名称§8]", "§e更新时间检查器");
|
||||
helps.put("§f", null);
|
||||
helps.put("/taboolib shell load §8[§7名称§8]", "§e载入某个脚本");
|
||||
helps.put("/taboolib shell unload §8[§7名称§8]", "§e卸载某个脚本");
|
||||
helps.put("§e", null);
|
||||
helps.put("/taboolib importdata", "§4向数据库导入本地数据 §8(该操作将会清空数据库)");
|
||||
|
||||
if (sender instanceof ConsoleCommandSender || TabooLib.getVerint() < 10900) {
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lTaooLib Commands §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
// 遍历命令
|
||||
for (Entry<String, String> entry : helps.entrySet()) {
|
||||
if (entry.getValue() == null) {
|
||||
sender.sendMessage("§f");
|
||||
} else {
|
||||
sender.sendMessage("§f " + entry.getKey() + " §6- " + entry.getValue());
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
else if (sender instanceof Player) {
|
||||
JSONFormatter json = new JSONFormatter();
|
||||
json.append("§f"); json.newLine();
|
||||
json.append("§b§l----- §3§lTaooLib Commands §b§l-----"); json.newLine();
|
||||
json.append("§f"); json.newLine();
|
||||
// 遍历命令
|
||||
for (Entry<String, String> entry : helps.entrySet()) {
|
||||
if (entry.getValue() == null) {
|
||||
json.append("§f"); json.newLine();
|
||||
} else {
|
||||
json.appendHoverClick("§f " + entry.getKey() + " §6- " + entry.getValue(), new ShowTextEvent("§f点击复制指令"), new SuggestCommandEvent(entry.getKey().split("§")[0])); json.newLine();
|
||||
}
|
||||
}
|
||||
json.append("§f");
|
||||
json.send((Player) sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,16 @@ public class ImportCommand extends SubCommand {
|
||||
super(sender, args);
|
||||
|
||||
if (isPlayer()) {
|
||||
MsgUtils.warn("改命令只能由控制台输入");
|
||||
MsgUtils.warn("改命令只能由控制台输入");
|
||||
}
|
||||
else if (Main.getStorageType() == StorageType.LOCAL) {
|
||||
MsgUtils.warn("只有启用数据库储存时才能这么做");
|
||||
MsgUtils.warn("只有启用数据库储存时才能这么做");
|
||||
}
|
||||
else {
|
||||
MsgUtils.send("正在清空数据库...");
|
||||
MsgUtils.send("正在清空数据库...");
|
||||
Main.getConnection().truncateTable(Main.getTablePrefix() + "_playerdata");
|
||||
|
||||
MsgUtils.send("开始导入玩家数据...");
|
||||
MsgUtils.send("开始导入玩家数据...");
|
||||
int size = Main.getPlayerDataFolder().listFiles().length;
|
||||
int loop = 1;
|
||||
|
||||
@@ -35,10 +35,10 @@ public class ImportCommand extends SubCommand {
|
||||
FileConfiguration conf = YamlConfiguration.loadConfiguration(file);
|
||||
Main.getConnection().intoValue(Main.getTablePrefix() + "_playerdata", file.getName().replace(".yml", ""), ConfigUtils.encodeYAML(conf));
|
||||
|
||||
MsgUtils.send("导入玩家: &f" + file.getName().replace(".yml", "") + " &7进度: &f" + loop + "/" + size);
|
||||
MsgUtils.send("导入玩家: &f" + file.getName().replace(".yml", "") + " &7进度: &f" + loop + "/" + size);
|
||||
loop++;
|
||||
}
|
||||
MsgUtils.send("导入完成!");
|
||||
MsgUtils.send("导入完成!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,29 +24,29 @@ public class InfoCommand extends SubCommand {
|
||||
if (isPlayer()) {
|
||||
Player player = (Player) sender;
|
||||
if (player.getItemInHand().getType().equals(Material.AIR)) {
|
||||
MsgUtils.send(player, "&7请手持正确物品");
|
||||
MsgUtils.send(player, "&7请手持正确物品");
|
||||
}
|
||||
else {
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lItemStack Info §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lItemStack Info §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
|
||||
JSONFormatter json = new JSONFormatter();
|
||||
json.append("§7 - 物品材质: §f"); json.appendHoverClick("§f" + player.getItemInHand().getType().name(), new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(player.getItemInHand().getType().name()));
|
||||
json.append("§7 - 物品材质: §f"); json.appendHoverClick("§f" + player.getItemInHand().getType().name(), new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(player.getItemInHand().getType().name()));
|
||||
json.newLine();
|
||||
json.append("§7 - 物品名称: §f"); json.appendHoverClick("§f" + ItemUtils.getCustomName(player.getItemInHand()), new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(ItemUtils.getCustomName(player.getItemInHand()).replace("§", "&")));
|
||||
json.append("§7 - 物品名称: §f"); json.appendHoverClick("§f" + ItemUtils.getCustomName(player.getItemInHand()), new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(ItemUtils.getCustomName(player.getItemInHand()).replace("§", "&")));
|
||||
json.newLine();
|
||||
json.append("§7 - 物品序号: §f" + player.getItemInHand().getTypeId() + ":" + player.getItemInHand().getDurability());
|
||||
json.append("§7 - 物品序号: §f" + player.getItemInHand().getTypeId() + ":" + player.getItemInHand().getDurability());
|
||||
json.newLine();
|
||||
json.append("§7 - 物品展示: §f"); json.appendHover(ItemUtils.getCustomName(player.getItemInHand()), new ShowItemEvent(player.getItemInHand()));
|
||||
json.append("§7 - 物品展示: §f"); json.appendHover(ItemUtils.getCustomName(player.getItemInHand()), new ShowItemEvent(player.getItemInHand()));
|
||||
json.send(player);
|
||||
|
||||
NBTItem nbt = new NBTItem(((Player) sender).getItemInHand());
|
||||
sender.sendMessage("§7 - 物品 NBT: §f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§7 - 物品 NBT: §f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage(nbt.toString());
|
||||
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import me.skymc.taboolib.other.NumberUtils;
|
||||
public class ItemCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* /TabooLib item 物品 玩家 数量
|
||||
* /TabooLib item 物品 玩家 数量
|
||||
*
|
||||
* @param sender
|
||||
* @param args
|
||||
@@ -24,12 +24,12 @@ public class ItemCommand extends SubCommand {
|
||||
super(sender, args);
|
||||
|
||||
if (args.length < 2) {
|
||||
MsgUtils.send(sender, "请输入正确的物品名称");
|
||||
MsgUtils.send(sender, "请输入正确的物品名称");
|
||||
setReturn(false);
|
||||
}
|
||||
else {
|
||||
if (ItemUtils.getCacheItem(args[1]) == null) {
|
||||
MsgUtils.send(sender, "物品 &f" + args[1] + "&7 不存在");
|
||||
MsgUtils.send(sender, "物品 &f" + args[1] + "&7 不存在");
|
||||
setReturn(false);
|
||||
return;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class ItemCommand extends SubCommand {
|
||||
if (args.length > 2) {
|
||||
player = Bukkit.getPlayerExact(args[2]);
|
||||
if (player == null) {
|
||||
MsgUtils.send(sender, "玩家 &f" + args[2] + "&7 不在线");
|
||||
MsgUtils.send(sender, "玩家 &f" + args[2] + "&7 不在线");
|
||||
setReturn(false);
|
||||
return;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class ItemCommand extends SubCommand {
|
||||
player = (Player) sender;
|
||||
}
|
||||
else {
|
||||
MsgUtils.send(sender, "后台不允许这么做");
|
||||
MsgUtils.send(sender, "后台不允许这么做");
|
||||
setReturn(false);
|
||||
return;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class ItemCommand extends SubCommand {
|
||||
if (args.length > 3) {
|
||||
amount = NumberUtils.getInteger(args[3]);
|
||||
if (amount < 1) {
|
||||
MsgUtils.send(sender, "数量必须大于0");
|
||||
MsgUtils.send(sender, "数量必须大于0");
|
||||
setReturn(false);
|
||||
return;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class ItemCommand extends SubCommand {
|
||||
player.getWorld().dropItem(player.getLocation(), item);
|
||||
}
|
||||
|
||||
MsgUtils.send(sender, "物品已发送至玩家 &f" + player.getName() + " &7的背包中");
|
||||
MsgUtils.send(sender, "物品已发送至玩家 &f" + player.getName() + " &7的背包中");
|
||||
setReturn(true);
|
||||
}
|
||||
}
|
||||
@@ -15,23 +15,23 @@ public class PotionCommand extends SubCommand {
|
||||
public PotionCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lPotionEffect Types §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lPotionEffect Types §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
|
||||
for (PotionEffectType type : PotionEffectType.values()) {
|
||||
if (type != null) {
|
||||
if (isPlayer()) {
|
||||
JSONFormatter json = new JSONFormatter();
|
||||
json.append(" §7- §f" + type.getId() + ". " + type.getName());
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(type.getName()));
|
||||
json.append(" §7- §f" + type.getId() + ". " + type.getName());
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(type.getName()));
|
||||
json.send((Player) sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(" §7- §f" + type.getId() + ". " + type.getName() + "");
|
||||
sender.sendMessage(" §7- §f" + type.getId() + ". " + type.getName() + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
}
|
||||
@@ -20,29 +20,29 @@ public class SaveCommand extends SubCommand {
|
||||
public SaveCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
if (!(sender instanceof Player)) {
|
||||
MsgUtils.send(sender, "&4后台无法这么做");
|
||||
MsgUtils.send(sender, "&4后台无法这么做");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
MsgUtils.send(sender, "&4请输入正确的名称");
|
||||
MsgUtils.send(sender, "&4请输入正确的名称");
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).getItemInHand().getType().equals(Material.AIR)) {
|
||||
MsgUtils.send(sender, "&4你不能保存空气");
|
||||
MsgUtils.send(sender, "&4你不能保存空气");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemUtils.getItemCachesFinal().containsKey(args[1])) {
|
||||
MsgUtils.send(sender, "&4该名称所对应的物品保存于固定物品库中, 无法覆盖");
|
||||
MsgUtils.send(sender, "&4该名称所对应的物品保存于固定物品库中, 无法覆盖");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemUtils.getItemCaches().containsKey(args[1])) {
|
||||
// 检查聊天引导
|
||||
// 检查聊天引导
|
||||
if (ChatCatcher.contains((Player) sender)) {
|
||||
MsgUtils.send(sender, "&4你有一个正在进行的聊天引导, 请完成后在这么做");
|
||||
MsgUtils.send(sender, "&4你有一个正在进行的聊天引导, 请完成后在这么做");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,24 +50,24 @@ public class SaveCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
MsgUtils.send(sender, "&7退出引导");
|
||||
MsgUtils.send(sender, "&7退出引导");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Catcher before() {
|
||||
MsgUtils.send(sender, "物品 &f" + args[1] + "&7 已存在, 如果你想要覆盖它, 请在聊天框中输入 \"&f是&7\"");
|
||||
MsgUtils.send(sender, "物品 &f" + args[1] + "&7 已存在, 如果你想要覆盖它, 请在聊天框中输入 \"&f是&7\"");
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean after(String message) {
|
||||
if (message.equals("是")) {
|
||||
if (message.equals("是")) {
|
||||
saveItem(args[1], ((Player) sender).getItemInHand());
|
||||
MsgUtils.send(sender, "物品 &f" + args[1] + " &7已替换");
|
||||
MsgUtils.send(sender, "物品 &f" + args[1] + " &7已替换");
|
||||
}
|
||||
else {
|
||||
MsgUtils.send(sender, "&7退出引导");
|
||||
MsgUtils.send(sender, "&7退出引导");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class SaveCommand extends SubCommand {
|
||||
}
|
||||
else {
|
||||
saveItem(args[1], ((Player) sender).getItemInHand());
|
||||
MsgUtils.send(sender, "物品 &f" + args[1] + " &7已保存");
|
||||
MsgUtils.send(sender, "物品 &f" + args[1] + " &7已保存");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,23 +14,23 @@ public class SlotCommand extends SubCommand {
|
||||
public SlotCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lAttribute Slots §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lAttribute Slots §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
|
||||
String[] attributes = new String[] { "mainhand", "offhand", "feet", "legs", "chest", "head", "all" };
|
||||
|
||||
for (String name : attributes) {
|
||||
if (isPlayer()) {
|
||||
JSONFormatter json = new JSONFormatter();
|
||||
json.append(" §7- §f" + name);
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(name));
|
||||
json.append(" §7- §f" + name);
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(name));
|
||||
json.send((Player) sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(" §7- §f" + name);
|
||||
sender.sendMessage(" §7- §f" + name);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,10 @@ public class VariableGetCommand extends SubCommand {
|
||||
super(sender, args);
|
||||
|
||||
if (args.length < 3) {
|
||||
MsgUtils.send(sender, "&4请输入正确的指令 ");
|
||||
MsgUtils.send(sender, "&4请输入正确的指令 ");
|
||||
}
|
||||
else if (!(args[1].equals("-a") || args[1].equals("-s"))) {
|
||||
MsgUtils.send(sender, "&4请输入正确的读取方式");
|
||||
MsgUtils.send(sender, "&4请输入正确的读取方式");
|
||||
}
|
||||
|
||||
Long time = System.currentTimeMillis();
|
||||
@@ -29,12 +29,12 @@ public class VariableGetCommand extends SubCommand {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
MsgUtils.send(sender, "读取完成, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
MsgUtils.send(sender, "变量 &f" + args[2] + " &7不存在");
|
||||
MsgUtils.send(sender, "读取完成, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
MsgUtils.send(sender, "变量 &f" + args[2] + " &7不存在");
|
||||
}
|
||||
else {
|
||||
MsgUtils.send(sender, "读取完成, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
MsgUtils.send(sender, "变量 &f" + args[2] + " &7的值为 &f" + value);
|
||||
MsgUtils.send(sender, "读取完成, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
MsgUtils.send(sender, "变量 &f" + args[2] + " &7的值为 &f" + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,10 @@ public class VariableSetCommand extends SubCommand {
|
||||
super(sender, args);
|
||||
|
||||
if (args.length < 4) {
|
||||
MsgUtils.send(sender, "&4请输入正确的指令 ");
|
||||
MsgUtils.send(sender, "&4请输入正确的指令 ");
|
||||
}
|
||||
else if (!(args[1].equals("-a") || args[1].equals("-s"))) {
|
||||
MsgUtils.send(sender, "&4请输入正确的写入方式");
|
||||
MsgUtils.send(sender, "&4请输入正确的写入方式");
|
||||
}
|
||||
|
||||
Long time = System.currentTimeMillis();
|
||||
@@ -28,7 +28,7 @@ public class VariableSetCommand extends SubCommand {
|
||||
GlobalDataManager.setVariableAsynchronous(args[2], value);
|
||||
}
|
||||
|
||||
MsgUtils.send(sender, "写入完成, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
MsgUtils.send(sender, "写入完成, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
setReturn(true);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class CycleCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
else {
|
||||
MsgUtils.send(sender, "&4Ö¸Áî´íÎó");
|
||||
MsgUtils.send(sender, "&4指令错误");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,25 +21,25 @@ public class CycleInfoCommand extends SubCommand {
|
||||
public CycleInfoCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
if (args.length < 3) {
|
||||
MsgUtils.send(sender, "&c请输入正确的检查器名称");
|
||||
MsgUtils.send(sender, "&c请输入正确的检查器名称");
|
||||
return;
|
||||
}
|
||||
|
||||
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]);
|
||||
if (cycle == null) {
|
||||
MsgUtils.send(sender, "&c检查器 &4" + args[2] + " &c不存在");
|
||||
MsgUtils.send(sender, "&c检查器 &4" + args[2] + " &c不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lTimeCycle Info §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage(" §f- §7注册周期: §f" + asString(cycle.getCycle() / 1000L));
|
||||
sender.sendMessage(" §f- §7注册插件: §f" + cycle.getPlugin().getName());
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage(" §f- §7上次刷新时间: §f" + DateUtils.CH_ALL.format(TimeCycleManager.getBeforeTimeline(cycle.getName())));
|
||||
sender.sendMessage(" §f- §7下次刷新时间: §f" + DateUtils.CH_ALL.format(TimeCycleManager.getAfterTimeline(cycle.getName())));
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lTimeCycle Info §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage(" §f- §7注册周期: §f" + asString(cycle.getCycle() / 1000L));
|
||||
sender.sendMessage(" §f- §7注册插件: §f" + cycle.getPlugin().getName());
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage(" §f- §7上次刷新时间: §f" + DateUtils.CH_ALL.format(TimeCycleManager.getBeforeTimeline(cycle.getName())));
|
||||
sender.sendMessage(" §f- §7下次刷新时间: §f" + DateUtils.CH_ALL.format(TimeCycleManager.getAfterTimeline(cycle.getName())));
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
|
||||
public String asString(long seconds) {
|
||||
@@ -47,7 +47,7 @@ public class CycleInfoCommand extends SubCommand {
|
||||
long hours = TimeUnit.SECONDS.toHours(seconds) - day * 24;
|
||||
long minute = TimeUnit.SECONDS.toMinutes(seconds) - TimeUnit.SECONDS.toHours(seconds) * 60L;
|
||||
long second = TimeUnit.SECONDS.toSeconds(seconds) - TimeUnit.SECONDS.toMinutes(seconds) * 60L;
|
||||
return "§f" + day + "§7 天, §f" + hours + "§7 小时, §f" + minute + "§7 分钟, §f" + second + "§7 秒";
|
||||
return "§f" + day + "§7 天, §f" + hours + "§7 小时, §f" + minute + "§7 分钟, §f" + second + "§7 秒";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,23 +20,23 @@ public class CycleListCommand extends SubCommand {
|
||||
public CycleListCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lTimeCycle List §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§b§l----- §3§lTimeCycle List §b§l-----");
|
||||
sender.sendMessage("§f");
|
||||
|
||||
for (TimeCycle cycle : TimeCycleManager.getTimeCycles()) {
|
||||
if (isPlayer()) {
|
||||
JSONFormatter json = new JSONFormatter();
|
||||
json.append(" §7- §f" + cycle.getName());
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(cycle.getName()));
|
||||
json.append(" §7- §f" + cycle.getName());
|
||||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(cycle.getName()));
|
||||
json.send((Player) sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(" §7- §f" + cycle.getName());
|
||||
sender.sendMessage(" §7- §f" + cycle.getName());
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage("§f");
|
||||
sender.sendMessage("§f");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -18,13 +18,13 @@ public class CycleResetCommand extends SubCommand {
|
||||
public CycleResetCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
if (args.length < 3) {
|
||||
MsgUtils.send(sender, "&c请输入正确的检查器名称");
|
||||
MsgUtils.send(sender, "&c请输入正确的检查器名称");
|
||||
return;
|
||||
}
|
||||
|
||||
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]);
|
||||
if (cycle == null) {
|
||||
MsgUtils.send(sender, "&c检查器 &4" + args[2] + " &c不存在");
|
||||
MsgUtils.send(sender, "&c检查器 &4" + args[2] + " &c不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ public class CycleResetCommand extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
long time = new TimeCycleInitializeEvent(cycle, System.currentTimeMillis()).call().getTimeline();
|
||||
// 初始化
|
||||
// 初始化
|
||||
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(time));
|
||||
// 触发器
|
||||
// 触发器
|
||||
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
|
||||
// 提示
|
||||
MsgUtils.send(sender, "检查器 &f" + args[2] + " &7初始化完成");
|
||||
// 提示
|
||||
MsgUtils.send(sender, "检查器 &f" + args[2] + " &7初始化完成");
|
||||
}
|
||||
}.runTaskAsynchronously(Main.getInst());
|
||||
}
|
||||
@@ -18,13 +18,13 @@ public class CycleUpdateCommand extends SubCommand {
|
||||
public CycleUpdateCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
if (args.length < 3) {
|
||||
MsgUtils.send(sender, "&c请输入正确的检查器名称");
|
||||
MsgUtils.send(sender, "&c请输入正确的检查器名称");
|
||||
return;
|
||||
}
|
||||
|
||||
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]);
|
||||
if (cycle == null) {
|
||||
MsgUtils.send(sender, "&c检查器 &4" + args[2] + " &c不存在");
|
||||
MsgUtils.send(sender, "&c检查器 &4" + args[2] + " &c不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ public class CycleUpdateCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// 重置
|
||||
// 重置
|
||||
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(System.currentTimeMillis()));
|
||||
// 触发器
|
||||
// 触发器
|
||||
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
|
||||
// 提示
|
||||
MsgUtils.send(sender, "检查器 &f" + args[2] + " &7已更新");
|
||||
// 提示
|
||||
MsgUtils.send(sender, "检查器 &f" + args[2] + " &7已更新");
|
||||
}
|
||||
}.runTaskAsynchronously(Main.getInst());
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import me.skymc.taboolib.other.NumberUtils;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月4日 下午8:08:22
|
||||
* @since 2018年2月4日 下午8:08:22
|
||||
*/
|
||||
public class ItemListCommand extends SubCommand {
|
||||
|
||||
@@ -22,7 +22,7 @@ import me.skymc.taboolib.inventory.ItemUtils;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月4日 下午4:35:00
|
||||
* @since 2018年2月4日 下午4:35:00
|
||||
*/
|
||||
public class ItemLibraryPatch implements Listener {
|
||||
|
||||
@@ -48,14 +48,14 @@ public class ItemLibraryPatch implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开物品库界面
|
||||
* 打开物品库界面
|
||||
*
|
||||
* @param player
|
||||
* @param page
|
||||
*/
|
||||
public static void openInventory(Player player, int page) {
|
||||
ItemLibraryHolder holder = new ItemLibraryHolder(page);
|
||||
Inventory inventory = Bukkit.createInventory(holder, 54, "物品库");
|
||||
Inventory inventory = Bukkit.createInventory(holder, 54, "物品库");
|
||||
|
||||
LinkedHashMap<String, ItemStack> map = new LinkedHashMap<>();
|
||||
map.putAll(ItemUtils.getItemCachesFinal());
|
||||
@@ -71,9 +71,9 @@ public class ItemLibraryPatch implements Listener {
|
||||
ItemStack item = map.get(name).clone(); {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
||||
lore.add("§f");
|
||||
lore.add("§f§m ");
|
||||
lore.add("§f序列号: §8" + name);
|
||||
lore.add("§f");
|
||||
lore.add("§f§m ");
|
||||
lore.add("§f序列号: §8" + name);
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
inventory.setItem(slot, item);
|
||||
@@ -88,10 +88,10 @@ public class ItemLibraryPatch implements Listener {
|
||||
}
|
||||
|
||||
if (page > 1) {
|
||||
inventory.setItem(47, ItemUtils.setName(new ItemStack(Material.ARROW), "§f上一页"));
|
||||
inventory.setItem(47, ItemUtils.setName(new ItemStack(Material.ARROW), "§f上一页"));
|
||||
}
|
||||
if (((int) Math.ceil(ItemUtils.getItemCaches().size() / 28D)) > page) {
|
||||
inventory.setItem(51, ItemUtils.setName(new ItemStack(Material.ARROW), "§f下一页"));
|
||||
inventory.setItem(51, ItemUtils.setName(new ItemStack(Material.ARROW), "§f下一页"));
|
||||
}
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class ShellCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
else {
|
||||
MsgUtils.send(sender, "&4Ö¸Áî´íÎó");
|
||||
MsgUtils.send(sender, "&4指令错误");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,18 @@ public class ShellLoadCommand extends SubCommand {
|
||||
public ShellLoadCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
if (args.length < 3) {
|
||||
MsgUtils.send(sender, "&c请输入正确的脚本名称");
|
||||
MsgUtils.send(sender, "&c请输入正确的脚本名称");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(JavaShell.getScriptFolder(), args[2].contains(".java") ? args[2] : args[2] + ".java");
|
||||
if (!file.exists()) {
|
||||
MsgUtils.send(sender, "&c脚本 &4" + args[2] + "&c 不存在");
|
||||
MsgUtils.send(sender, "&c脚本 &4" + args[2] + "&c 不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
if (JavaShell.reloadShell(args[2])) {
|
||||
MsgUtils.send(sender, "脚本 " + args[2] + " 已载入");
|
||||
MsgUtils.send(sender, "脚本 " + args[2] + " 已载入");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,18 @@ public class ShellUnloadCommand extends SubCommand {
|
||||
public ShellUnloadCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
if (args.length < 3) {
|
||||
MsgUtils.send(sender, "&c请输入正确的脚本名称");
|
||||
MsgUtils.send(sender, "&c请输入正确的脚本名称");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(JavaShell.getScriptFolder(), args[2].contains(".java") ? args[2] : args[2] + ".java");
|
||||
if (!file.exists()) {
|
||||
MsgUtils.send(sender, "&c脚本 &4" + args[2] + "&c 不存在");
|
||||
MsgUtils.send(sender, "&c脚本 &4" + args[2] + "&c 不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
JavaShell.unloadShell(args[2]);
|
||||
MsgUtils.send(sender, "脚本 " + args[2] + " 已卸载");
|
||||
MsgUtils.send(sender, "脚本 " + args[2] + " 已卸载");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,20 +22,20 @@ public class CooldownUtils implements Listener {
|
||||
|
||||
public static void register(CooldownPack pack) {
|
||||
packlist.put(pack.getPackName(), pack);
|
||||
MsgUtils.send("注册冷却包: " + pack.getPackName() + ", 时间: " + pack.getPackSeconds() + " 秒 (匿名注册)");
|
||||
MsgUtils.send("注册冷却包: " + pack.getPackName() + ", 时间: " + pack.getPackSeconds() + " 秒 (匿名注册)");
|
||||
}
|
||||
|
||||
public static void register(CooldownPack pack, Plugin plugin) {
|
||||
pack.setPlugin(plugin.getName());
|
||||
|
||||
packlist.put(pack.getPackName(), pack);
|
||||
MsgUtils.send("注册冷却包: " + pack.getPackName() + ", 时间: " + pack.getPackSeconds() + " 秒 (" + plugin.getName() + ")");
|
||||
MsgUtils.send("注册冷却包: " + pack.getPackName() + ", 时间: " + pack.getPackSeconds() + " 秒 (" + plugin.getName() + ")");
|
||||
}
|
||||
|
||||
public static void unregister(String name) {
|
||||
packlist.remove(name);
|
||||
|
||||
MsgUtils.send("注销冷却包: " + name + " (主动注销)");
|
||||
MsgUtils.send("注销冷却包: " + name + " (主动注销)");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -53,7 +53,7 @@ public class CooldownUtils implements Listener {
|
||||
if (pack.getPlugin().equals(e.getPlugin().getName())) {
|
||||
packlist.remove(pack.getPackName());
|
||||
|
||||
MsgUtils.send("注销冷却包: " + pack.getPackName() + " (自动注销)");
|
||||
MsgUtils.send("注销冷却包: " + pack.getPackName() + " (自动注销)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,20 +25,20 @@ public class CooldownUtils2 implements Listener {
|
||||
|
||||
public static void register(CooldownPack2 pack) {
|
||||
packlist.put(pack.getPackName(), pack);
|
||||
// MsgUtils.send("注册冷却包: " + pack.getPackName() + ", 时间: " + pack.getPackSeconds() + " 秒 (匿名注册)");
|
||||
// MsgUtils.send("注册冷却包: " + pack.getPackName() + ", 时间: " + pack.getPackSeconds() + " 秒 (匿名注册)");
|
||||
}
|
||||
|
||||
public static void register(CooldownPack2 pack, Plugin plugin) {
|
||||
pack.setPlugin(plugin.getName());
|
||||
|
||||
packlist.put(pack.getPackName(), pack);
|
||||
// MsgUtils.send("注册冷却包: " + pack.getPackName() + ", 时间: " + pack.getPackSeconds() + " 秒 (" + plugin.getName() + ")");
|
||||
// MsgUtils.send("注册冷却包: " + pack.getPackName() + ", 时间: " + pack.getPackSeconds() + " 秒 (" + plugin.getName() + ")");
|
||||
}
|
||||
|
||||
public static void unregister(String name) {
|
||||
packlist.remove(name);
|
||||
|
||||
// MsgUtils.send("注销冷却包: " + name + " (主动注销)");
|
||||
// MsgUtils.send("注销冷却包: " + name + " (主动注销)");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -56,7 +56,7 @@ public class CooldownUtils2 implements Listener {
|
||||
if (pack.getPlugin().equals(e.getPlugin().getName())) {
|
||||
packlist.remove(pack.getPackName());
|
||||
|
||||
// MsgUtils.send("注销冷却包: " + pack.getPackName() + " (自动注销)");
|
||||
// MsgUtils.send("注销冷却包: " + pack.getPackName() + " (自动注销)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,10 @@ public class GlobalDataManager {
|
||||
public static FileConfiguration data = DataUtils.addPluginData("TabooLibrary-Variable.yml", null);
|
||||
|
||||
/**
|
||||
* 获取变量
|
||||
* 获取变量
|
||||
*
|
||||
* @param name 名称
|
||||
* @param defaultVariable 默认值
|
||||
* @param name 名称
|
||||
* @param defaultVariable 默认值
|
||||
* @return
|
||||
*/
|
||||
public static String getVariable(String name, String defaultVariable) {
|
||||
@@ -37,10 +37,10 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存变量(该方法仅限数据库储存方式)
|
||||
* 获取缓存变量(该方法仅限数据库储存方式)
|
||||
*
|
||||
* @param name 名称
|
||||
* @param defaultVariable 默认值
|
||||
* @param name 名称
|
||||
* @param defaultVariable 默认值
|
||||
* @return
|
||||
*/
|
||||
public static String getVariableAsynchronous(String name, String defaultVariable) {
|
||||
@@ -54,10 +54,10 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置变量
|
||||
* 设置变量
|
||||
*
|
||||
* @param name 名称
|
||||
* @param variable 变量
|
||||
* @param name 名称
|
||||
* @param variable 变量
|
||||
*/
|
||||
public static void setVariable(String name, String variable) {
|
||||
if (Main.getStorageType() == StorageType.SQL) {
|
||||
@@ -69,7 +69,7 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置缓存变量(该方法仅限数据库储存方式)
|
||||
* 设置缓存变量(该方法仅限数据库储存方式)
|
||||
*
|
||||
* @param name
|
||||
* @param variable
|
||||
@@ -77,7 +77,7 @@ public class GlobalDataManager {
|
||||
public static void setVariableAsynchronous(String name, String variable) {
|
||||
if (Main.getStorageType() == StorageType.SQL) {
|
||||
SQLVariable _variable = SQLMethod.contains(name) ? SQLMethod.getSQLVariable(name).setVariable(variable == null ? "null" : variable) : SQLMethod.addSQLVariable(name, variable == null ? "null" : variable);
|
||||
// 更新数据
|
||||
// 更新数据
|
||||
SQLMethod.uploadVariable(_variable, true);
|
||||
}
|
||||
else {
|
||||
@@ -86,9 +86,9 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查变量是否存在
|
||||
* 检查变量是否存在
|
||||
*
|
||||
* @param name 名称
|
||||
* @param name 名称
|
||||
*/
|
||||
public static boolean contains(String name) {
|
||||
if (Main.getStorageType() == StorageType.SQL) {
|
||||
@@ -100,9 +100,9 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查变量是否被缓存(该方法仅限数据库储存方式)
|
||||
* 检查变量是否被缓存(该方法仅限数据库储存方式)
|
||||
*
|
||||
* @param name 名称
|
||||
* @param name 名称
|
||||
* @return
|
||||
*/
|
||||
public static boolean containsAsynchronous(String name) {
|
||||
@@ -115,8 +115,8 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理所有失效的变量
|
||||
* 该方法仅限数据库储存时有效
|
||||
* 清理所有失效的变量
|
||||
* 该方法仅限数据库储存时有效
|
||||
*/
|
||||
public static void clearInvalidVariables() {
|
||||
if (Main.getStorageType() == StorageType.SQL) {
|
||||
@@ -129,7 +129,7 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有有效变量
|
||||
* 获取所有有效变量
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -152,7 +152,7 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存变量(该方法仅限数据库储存方式)
|
||||
* 获取缓存变量(该方法仅限数据库储存方式)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -172,7 +172,7 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库变量
|
||||
* 数据库变量
|
||||
*
|
||||
* @author sky
|
||||
*
|
||||
@@ -208,7 +208,7 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库方法
|
||||
* 数据库方法
|
||||
*
|
||||
* @author sky
|
||||
*
|
||||
@@ -218,16 +218,16 @@ public class GlobalDataManager {
|
||||
private static ConcurrentHashMap<String, SQLVariable> variables = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 获取数据
|
||||
* 获取数据
|
||||
*
|
||||
* @param name 名字
|
||||
* @param name 名字
|
||||
*/
|
||||
public static SQLVariable getSQLVariable(String name) {
|
||||
return variables.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有变量
|
||||
* 获取所有变量
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -236,10 +236,10 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个变量
|
||||
* 添加一个变量
|
||||
*
|
||||
* @param name 名字
|
||||
* @param value 值
|
||||
* @param name 名字
|
||||
* @param value 值
|
||||
* @return
|
||||
*/
|
||||
public static SQLVariable addSQLVariable(String name, String value) {
|
||||
@@ -249,9 +249,9 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除一个变量
|
||||
* 移除一个变量
|
||||
*
|
||||
* @param name 名字
|
||||
* @param name 名字
|
||||
* @return
|
||||
*/
|
||||
public static SQLVariable removeSQLVariable(String name) {
|
||||
@@ -262,9 +262,9 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含变量
|
||||
* 是否包含变量
|
||||
*
|
||||
* @param name 名字
|
||||
* @param name 名字
|
||||
* @return
|
||||
*/
|
||||
public static boolean contains(String name) {
|
||||
@@ -272,9 +272,9 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 载入数据库中的所有变量缓存
|
||||
* 载入数据库中的所有变量缓存
|
||||
*
|
||||
* @param sync 是否异步
|
||||
* @param sync 是否异步
|
||||
*/
|
||||
public static void loadVariables(boolean sync) {
|
||||
if (Main.getStorageType() == StorageType.LOCAL) {
|
||||
@@ -303,9 +303,9 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前变量是否被其他服务器更新
|
||||
* 检查当前变量是否被其他服务器更新
|
||||
*
|
||||
* @param sync 是否异步
|
||||
* @param sync 是否异步
|
||||
*/
|
||||
public static void checkVariable(boolean sync) {
|
||||
if (Main.getStorageType() == StorageType.LOCAL) {
|
||||
@@ -317,40 +317,40 @@ public class GlobalDataManager {
|
||||
@Override
|
||||
public void run() {
|
||||
/**
|
||||
* 根据正序排列获取所有变量
|
||||
* 新的变量会覆盖旧的变量
|
||||
* 根据正序排列获取所有变量
|
||||
* 新的变量会覆盖旧的变量
|
||||
*/
|
||||
LinkedList<HashMap<String, Object>> list = Main.getConnection().getValues(Main.getTablePrefix() + "_plugindata", "id", -1, false, "name", "variable", "upgrade");
|
||||
// 循环变量
|
||||
// 循环变量
|
||||
for (HashMap<String, Object> value : list) {
|
||||
Object name = value.get("name");
|
||||
try {
|
||||
// 如果变量存在
|
||||
// 如果变量存在
|
||||
if (variables.containsKey(name)) {
|
||||
// 如果变量不是由本服更新
|
||||
// 如果变量不是由本服更新
|
||||
if (!value.get("upgrade").equals(variables.get(name).getUpgradeUID())) {
|
||||
// 如果变量是空
|
||||
// 如果变量是空
|
||||
if (value.get("variable").equals("null")) {
|
||||
// 删除变量
|
||||
// 删除变量
|
||||
variables.remove(name);
|
||||
}
|
||||
else {
|
||||
// 更新变量
|
||||
// 更新变量
|
||||
variables.get(name).setVariable(value.get("variable").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果变量存在则下载到本地
|
||||
// 如果变量存在则下载到本地
|
||||
else if (!value.get("variable").equals("null")) {
|
||||
variables.put(value.get("name").toString(), new SQLVariable(value.get("name").toString(), value.get("variable").toString(), value.get("upgrade").toString()));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
// 移除
|
||||
// 移除
|
||||
variables.remove(name);
|
||||
// 提示
|
||||
MsgUtils.warn("变量出现异常: &4" + name);
|
||||
MsgUtils.warn("原因: &4" + e.getMessage());
|
||||
// 提示
|
||||
MsgUtils.warn("变量出现异常: &4" + name);
|
||||
MsgUtils.warn("原因: &4" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,9 +365,9 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 向数据库上传所有数据
|
||||
* 向数据库上传所有数据
|
||||
*
|
||||
* @param sync 是否异步
|
||||
* @param sync 是否异步
|
||||
*/
|
||||
public static void uploadVariables(boolean sync) {
|
||||
if (Main.getStorageType() == StorageType.LOCAL) {
|
||||
@@ -380,10 +380,10 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 向数据库上传当前数据
|
||||
* 向数据库上传当前数据
|
||||
*
|
||||
* @param variable 数据
|
||||
* @param sync 是否异步
|
||||
* @param variable 数据
|
||||
* @param sync 是否异步
|
||||
*/
|
||||
public static void uploadVariable(SQLVariable variable, boolean sync) {
|
||||
if (Main.getStorageType() == StorageType.LOCAL) {
|
||||
@@ -407,17 +407,17 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动数据库储存方法
|
||||
* 启动数据库储存方法
|
||||
*
|
||||
*/
|
||||
public static void startSQLMethod() {
|
||||
long time = System.currentTimeMillis();
|
||||
// 载入数据
|
||||
// 载入数据
|
||||
loadVariables(false);
|
||||
// 提示信息
|
||||
MsgUtils.send("从数据库中获取 &f" + variables.size() + " &7个变量, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
// 提示信息
|
||||
MsgUtils.send("从数据库中获取 &f" + variables.size() + " &7个变量, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
|
||||
// 检查更新
|
||||
// 检查更新
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
@@ -428,11 +428,11 @@ public class GlobalDataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束数据库储存方法
|
||||
* 结束数据库储存方法
|
||||
*
|
||||
*/
|
||||
public static void cancelSQLMethod() {
|
||||
// 上传数据
|
||||
// 上传数据
|
||||
uploadVariables(false);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.Main.StorageType;
|
||||
@@ -33,7 +32,7 @@ public class PlayerDataManager implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户储存方式
|
||||
* 获取用户储存方式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -42,9 +41,9 @@ public class PlayerDataManager implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取玩家数据
|
||||
* 获取玩家数据
|
||||
*
|
||||
* @param player 玩家
|
||||
* @param player 玩家
|
||||
* @return
|
||||
* @throws PlayerOfflineException
|
||||
*/
|
||||
@@ -58,7 +57,7 @@ public class PlayerDataManager implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取玩家数据
|
||||
* 获取玩家数据
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
@@ -76,9 +75,9 @@ public class PlayerDataManager implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取玩家数据
|
||||
* 读取玩家数据
|
||||
*
|
||||
* @param username 玩家
|
||||
* @param username 玩家
|
||||
* @return
|
||||
* @throws PlayerOfflineException
|
||||
*/
|
||||
@@ -88,7 +87,7 @@ public class PlayerDataManager implements Listener {
|
||||
}
|
||||
else if (offline) {
|
||||
if (Main.getStorageType() == StorageType.SQL) {
|
||||
throw new PlayerOfflineException("不允许在储存模式为数据库的情况下获取离线玩家数据");
|
||||
throw new PlayerOfflineException("不允许在储存模式为数据库的情况下获取离线玩家数据");
|
||||
}
|
||||
return loadPlayerData(username);
|
||||
}
|
||||
@@ -96,37 +95,37 @@ public class PlayerDataManager implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 载入玩家数据
|
||||
* 载入玩家数据
|
||||
*
|
||||
* @param username 玩家
|
||||
* @param username 玩家
|
||||
* @return
|
||||
*/
|
||||
public static FileConfiguration loadPlayerData(String username) {
|
||||
// 本地储存
|
||||
// 本地储存
|
||||
if (Main.getStorageType() == StorageType.LOCAL) {
|
||||
// 读取文件
|
||||
// 读取文件
|
||||
File file = FileUtils.file(Main.getPlayerDataFolder(), username + ".yml");
|
||||
// 载入配置
|
||||
// 载入配置
|
||||
PLAYER_DATA.put(username, YamlConfiguration.loadConfiguration(file));
|
||||
}
|
||||
else {
|
||||
// 数据是否存在
|
||||
// 数据是否存在
|
||||
if (Main.getConnection().isExists(Main.getTablePrefix() + "_playerdata", "username", username)) {
|
||||
// 获取数据
|
||||
// 获取数据
|
||||
String code = Main.getConnection().getValue(Main.getTablePrefix() + "_playerdata", "username", username, "configuration").toString();
|
||||
try {
|
||||
// 载入配置
|
||||
// 载入配置
|
||||
PLAYER_DATA.put(username, ConfigUtils.decodeYAML(code));
|
||||
}
|
||||
catch (Exception e) {
|
||||
// 创建空数据
|
||||
// 创建空数据
|
||||
PLAYER_DATA.put(username, new YamlConfiguration());
|
||||
// 反馈信息
|
||||
MsgUtils.warn("玩家 &4" + username + " &c的数据载入出现异常: &4" + e.getMessage());
|
||||
// 反馈信息
|
||||
MsgUtils.warn("玩家 &4" + username + " &c的数据载入出现异常: &4" + e.getMessage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 创建空数据
|
||||
// 创建空数据
|
||||
PLAYER_DATA.put(username, new YamlConfiguration());
|
||||
}
|
||||
}
|
||||
@@ -134,21 +133,21 @@ public class PlayerDataManager implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存玩家数据
|
||||
* 保存玩家数据
|
||||
*
|
||||
* @param username 玩家
|
||||
* @param remove 是否移除缓存
|
||||
* @param username 玩家
|
||||
* @param remove 是否移除缓存
|
||||
*/
|
||||
public static void savePlayerData(String username, boolean remove) {
|
||||
// 没有数据
|
||||
// 没有数据
|
||||
if (!PLAYER_DATA.containsKey(username)) {
|
||||
return;
|
||||
}
|
||||
// 本地储存
|
||||
// 本地储存
|
||||
if (Main.getStorageType() == StorageType.LOCAL) {
|
||||
// 读取文件
|
||||
// 读取文件
|
||||
File file = FileUtils.file(Main.getPlayerDataFolder(), username + ".yml");
|
||||
// 保存配置
|
||||
// 保存配置
|
||||
try {
|
||||
PLAYER_DATA.get(username).save(file);
|
||||
}
|
||||
@@ -156,19 +155,19 @@ public class PlayerDataManager implements Listener {
|
||||
// TODO: handle exception
|
||||
}
|
||||
}
|
||||
// 如果是数据库储存且有数据
|
||||
// 如果是数据库储存且有数据
|
||||
else if (PLAYER_DATA.get(username).getConfigurationSection("").getKeys(false).size() > 0) {
|
||||
// 数据是否存在
|
||||
// 数据是否存在
|
||||
if (Main.getConnection().isExists(Main.getTablePrefix() + "_playerdata", "username", username)) {
|
||||
// 写入数据
|
||||
// 写入数据
|
||||
Main.getConnection().setValue(Main.getTablePrefix() + "_playerdata", "username", username, "configuration", ConfigUtils.encodeYAML(PLAYER_DATA.get(username)));
|
||||
}
|
||||
else {
|
||||
// 插入数据
|
||||
// 插入数据
|
||||
Main.getConnection().intoValue(Main.getTablePrefix() + "_playerdata", username, ConfigUtils.encodeYAML(PLAYER_DATA.get(username)));
|
||||
}
|
||||
}
|
||||
// 获取这个属性对应的玩家
|
||||
// 获取这个属性对应的玩家
|
||||
Player player;
|
||||
if (getUsernameType() == UsernameType.UUID) {
|
||||
player = Bukkit.getPlayer(UUID.fromString(username));
|
||||
@@ -176,17 +175,17 @@ public class PlayerDataManager implements Listener {
|
||||
else {
|
||||
player = Bukkit.getPlayerExact(username);
|
||||
}
|
||||
// 如果移除数据 或 玩家不在线
|
||||
// 如果移除数据 或 玩家不在线
|
||||
if (remove || player == null) {
|
||||
PLAYER_DATA.remove(username);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存所有玩家的缓存
|
||||
* 保存所有玩家的缓存
|
||||
*
|
||||
* @param sync 是否异步进行
|
||||
* @param remove 是否移除数据
|
||||
* @param sync 是否异步进行
|
||||
* @param remove 是否移除数据
|
||||
*/
|
||||
public static void saveAllCaches(boolean sync, boolean remove) {
|
||||
BukkitRunnable runnable = new BukkitRunnable() {
|
||||
@@ -194,34 +193,34 @@ public class PlayerDataManager implements Listener {
|
||||
@Override
|
||||
public void run() {
|
||||
long time = System.currentTimeMillis();
|
||||
// 保存
|
||||
// 保存
|
||||
for (String name : PLAYER_DATA.keySet()) {
|
||||
savePlayerData(name, false);
|
||||
}
|
||||
// 提示
|
||||
// 提示
|
||||
if (!Main.getInst().getConfig().getBoolean("HIDE-NOTIFY")) {
|
||||
MsgUtils.send("保存 &f" + PLAYER_DATA.size() + " &7条玩家数据, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
MsgUtils.send("保存 &f" + PLAYER_DATA.size() + " &7条玩家数据, 耗时: &f" + (System.currentTimeMillis() - time) + " &7(ms)");
|
||||
}
|
||||
}
|
||||
};
|
||||
// 如果异步
|
||||
// 如果异步
|
||||
if (sync) {
|
||||
runnable.runTaskAsynchronously(Main.getInst());
|
||||
}
|
||||
// 如果同步
|
||||
// 如果同步
|
||||
else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存所有玩家的数据
|
||||
* 保存所有玩家的数据
|
||||
*
|
||||
* @param sync 是否异步进行
|
||||
* @param remove 是否移除数据
|
||||
* @param sync 是否异步进行
|
||||
* @param remove 是否移除数据
|
||||
*/
|
||||
public static void saveAllPlayers(boolean sync, boolean remove) {
|
||||
// 创建任务
|
||||
// 创建任务
|
||||
BukkitRunnable runnable = new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
@@ -231,11 +230,11 @@ public class PlayerDataManager implements Listener {
|
||||
}
|
||||
}
|
||||
};
|
||||
// 如果异步
|
||||
// 如果异步
|
||||
if (sync) {
|
||||
runnable.runTaskAsynchronously(Main.getInst());
|
||||
}
|
||||
// 如果同步
|
||||
// 如果同步
|
||||
else {
|
||||
runnable.run();
|
||||
}
|
||||
@@ -247,9 +246,9 @@ public class PlayerDataManager implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// 载入数据
|
||||
// 载入数据
|
||||
loadPlayerData(Main.getInst().getConfig().getBoolean("ENABLE-UUID") ? e.getPlayer().getUniqueId().toString() : e.getPlayer().getName());
|
||||
// 载入完成
|
||||
// 载入完成
|
||||
Bukkit.getPluginManager().callEvent(new PlayerLoadedEvent(e.getPlayer()));
|
||||
}
|
||||
}.runTaskAsynchronously(Main.getInst());
|
||||
@@ -262,7 +261,7 @@ public class PlayerDataManager implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// 保存数据
|
||||
// 保存数据
|
||||
savePlayerData(Main.getInst().getConfig().getBoolean("ENABLE-UUID") ? e.getPlayer().getUniqueId().toString() : e.getPlayer().getName(), true);
|
||||
}
|
||||
}.runTaskAsynchronously(Main.getInst());
|
||||
@@ -5,8 +5,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.methods.MethodsUtils;
|
||||
import net.minecraft.server.v1_12_R1.ChatMessageType;
|
||||
|
||||
public class ActionUtils {
|
||||
|
||||
@@ -48,7 +46,7 @@ public class ActionUtils {
|
||||
Object ab = getNMSClass("ChatComponentText").getConstructor(new Class[] { String.class }).newInstance(new Object[] { msg });
|
||||
Constructor<?> ac = null;
|
||||
Object abPacket = null;
|
||||
// 如果版本大于 1.11.0
|
||||
// 如果版本大于 1.11.0
|
||||
if (TabooLib.getVerint() > 11100) {
|
||||
Class<?> chatMessageType = getNMSClass("ChatMessageType");
|
||||
ac = getNMSClass("PacketPlayOutChat").getConstructor(getNMSClass("IChatBaseComponent"), chatMessageType);
|
||||
@@ -48,7 +48,7 @@ public class EntityUtils implements Listener{
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置生物发光(ProcotolLib)
|
||||
* 设置生物发光(ProcotolLib)
|
||||
*
|
||||
* @param player
|
||||
* @param entity
|
||||
@@ -69,7 +69,7 @@ public class EntityUtils implements Listener{
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消生物发光(ProcotolLib)
|
||||
* 取消生物发光(ProcotolLib)
|
||||
*
|
||||
* @param player
|
||||
* @param entity
|
||||
@@ -28,10 +28,10 @@ public class ConfigUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 UTF-8 的格式释放配置文件并载入
|
||||
* 以 UTF-8 的格式释放配置文件并载入
|
||||
*
|
||||
* 录入时间:2018年2月10日21:28:30
|
||||
* 录入版本:3.49
|
||||
* 录入时间:2018年2月10日21:28:30
|
||||
* 录入版本:3.49
|
||||
*
|
||||
* @param plugin
|
||||
* @return
|
||||
@@ -45,7 +45,7 @@ public class ConfigUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 UTF-8 的格式载入配置文件
|
||||
* 以 UTF-8 的格式载入配置文件
|
||||
*
|
||||
* @param main
|
||||
* @param filename
|
||||
@@ -56,9 +56,9 @@ public class ConfigUtils {
|
||||
try {
|
||||
yaml = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8));
|
||||
} catch (FileNotFoundException e) {
|
||||
MsgUtils.warn("配置文件载入失败!");
|
||||
MsgUtils.warn("插件: &4" + plugin.getName());
|
||||
MsgUtils.warn("文件: &4" + file.getName());
|
||||
MsgUtils.warn("配置文件载入失败!");
|
||||
MsgUtils.warn("插件: &4" + plugin.getName());
|
||||
MsgUtils.warn("文件: &4" + file.getName());
|
||||
}
|
||||
return yaml;
|
||||
}
|
||||
@@ -14,11 +14,11 @@ import java.nio.charset.UnsupportedCharsetException;
|
||||
public class EncodeUtils {
|
||||
|
||||
/**
|
||||
* 把指定文件或目录转换成指定的编码
|
||||
* 把指定文件或目录转换成指定的编码
|
||||
*
|
||||
* @param fileName 要转换的文件
|
||||
* @param fromCharsetName 源文件的编码
|
||||
* @param toCharsetName 要转换的编码
|
||||
* @param fileName 要转换的文件
|
||||
* @param fromCharsetName 源文件的编码
|
||||
* @param toCharsetName 要转换的编码
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void convert(String fileName, String fromCharsetName, String toCharsetName) throws Exception {
|
||||
@@ -26,11 +26,11 @@ public class EncodeUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 把指定文件或目录转换成指定的编码
|
||||
* 把指定文件或目录转换成指定的编码
|
||||
*
|
||||
* @param file 要转换的文件或目录
|
||||
* @param fromCharsetName 源文件的编码
|
||||
* @param toCharsetName 要转换的编码
|
||||
* @param file 要转换的文件或目录
|
||||
* @param fromCharsetName 源文件的编码
|
||||
* @param toCharsetName 要转换的编码
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void convert(File file, String fromCharsetName, String toCharsetName) throws Exception {
|
||||
@@ -38,12 +38,12 @@ public class EncodeUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 把指定文件或目录转换成指定的编码
|
||||
* 把指定文件或目录转换成指定的编码
|
||||
*
|
||||
* @param file 要转换的文件或目录
|
||||
* @param fromCharsetName 源文件的编码
|
||||
* @param toCharsetName 转换的编码
|
||||
* @param filter 文件名过滤器
|
||||
* @param file 要转换的文件或目录
|
||||
* @param fromCharsetName 源文件的编码
|
||||
* @param toCharsetName 转换的编码
|
||||
* @param filter 文件名过滤器
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void convert(String fileName, String fromCharsetName, String toCharsetName, FilenameFilter filter) throws Exception {
|
||||
@@ -51,12 +51,12 @@ public class EncodeUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 把指定文件或目录转换成指定的编码
|
||||
* 把指定文件或目录转换成指定的编码
|
||||
*
|
||||
* @param file 要转换的文件或目录
|
||||
* @param fromCharsetName 源文件的编码
|
||||
* @param toCharsetName 要转换的编码
|
||||
* @param filter 文件名过滤器
|
||||
* @param file 要转换的文件或目录
|
||||
* @param fromCharsetName 源文件的编码
|
||||
* @param toCharsetName 要转换的编码
|
||||
* @param filter 文件名过滤器
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void convert(File file, String fromCharsetName, String toCharsetName, FilenameFilter filter) throws Exception {
|
||||
@@ -81,10 +81,10 @@ public class EncodeUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 以指定编码方式读取文件,返回文件内容
|
||||
* 以指定编码方式读取文件,返回文件内容
|
||||
*
|
||||
* @param file 要转换的文件
|
||||
* @param fromCharsetName 源文件的编码
|
||||
* @param file 要转换的文件
|
||||
* @param fromCharsetName 源文件的编码
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -103,11 +103,11 @@ public class EncodeUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 以指定编码方式写文本文件,存在会覆盖
|
||||
* 以指定编码方式写文本文件,存在会覆盖
|
||||
*
|
||||
* @param file 要写入的文件
|
||||
* @param toCharsetName 要转换的编码
|
||||
* @param content 文件内容
|
||||
* @param file 要写入的文件
|
||||
* @param toCharsetName 要转换的编码
|
||||
* @param content 文件内容
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void saveFile2Charset(File file, String toCharsetName, String content) throws Exception {
|
||||
@@ -119,6 +119,6 @@ public class EncodeUtils {
|
||||
outWrite.write(content);
|
||||
outWrite.close();
|
||||
|
||||
System.out.println("[Encodeing...] 更改文件: " + file.getPath());
|
||||
System.out.println("[Encodeing...] 更改文件: " + file.getPath());
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,9 @@ import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import me.skymc.taboolib.client.LogClient;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.methods.MethodsUtils;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
@@ -79,7 +72,7 @@ public class FileUtils {
|
||||
bos.close();
|
||||
return new String(bos.toByteArray(), encode);
|
||||
} catch (IOException e) {
|
||||
MsgUtils.warn("输入流读取出错: &4" + e.getMessage());
|
||||
MsgUtils.warn("输入流读取出错: &4" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -102,7 +95,7 @@ public class FileUtils {
|
||||
fin.close();
|
||||
return new String(bos.toByteArray(), encode);
|
||||
} catch (IOException e) {
|
||||
MsgUtils.warn("文件读取出错: &4" + e.getMessage());
|
||||
MsgUtils.warn("文件读取出错: &4" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -124,7 +117,7 @@ public class FileUtils {
|
||||
bin.close();
|
||||
return new String(bos.toByteArray(), conn.getContentEncoding() == null ? "UTF-8" : conn.getContentEncoding());
|
||||
} catch (IOException e) {
|
||||
MsgUtils.warn("网络访问出错: &4" + e.getMessage());
|
||||
MsgUtils.warn("网络访问出错: &4" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -161,29 +154,29 @@ public class FileUtils {
|
||||
URL url = new URL(urlStr);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
|
||||
// 超时时间
|
||||
// 超时时间
|
||||
conn.setConnectTimeout(5 * 1000);
|
||||
// 防止屏蔽程序抓取而返回 403 错误
|
||||
// 防止屏蔽程序抓取而返回 403 错误
|
||||
conn.setRequestProperty("User-Agent", "Mozilla/31.0 (compatible; MSIE 10.0; Windows NT; DigExt)");
|
||||
|
||||
// 得到输入流
|
||||
// 得到输入流
|
||||
InputStream inputStream = conn.getInputStream();
|
||||
// 获取数组
|
||||
// 获取数组
|
||||
byte[] data = read(inputStream);
|
||||
|
||||
// 创建文件夹
|
||||
// 创建文件夹
|
||||
if (!saveDir.exists()) {
|
||||
saveDir.mkdirs();
|
||||
}
|
||||
|
||||
// 保存文件
|
||||
// 保存文件
|
||||
File file = new File(saveDir, filename);
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
|
||||
// 写入文件
|
||||
// 写入文件
|
||||
fos.write(data);
|
||||
|
||||
// 结束
|
||||
// 结束
|
||||
fos.close();
|
||||
inputStream.close();
|
||||
}
|
||||
@@ -25,10 +25,10 @@ public class InventoryUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查背包是否有空位
|
||||
* 检查背包是否有空位
|
||||
*
|
||||
* @param p 玩家
|
||||
* @param i 起始位置
|
||||
* @param p 玩家
|
||||
* @param i 起始位置
|
||||
*/
|
||||
public static boolean isEmpty(Player p, int i) {
|
||||
while (i < 35) {
|
||||
@@ -41,12 +41,12 @@ public class InventoryUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测玩家是否有指定物品
|
||||
* 检测玩家是否有指定物品
|
||||
*
|
||||
* @param player 玩家
|
||||
* @param item 物品
|
||||
* @param amount 数量
|
||||
* @param remove 是否删除
|
||||
* @param player 玩家
|
||||
* @param item 物品
|
||||
* @param amount 数量
|
||||
* @param remove 是否删除
|
||||
*/
|
||||
public static boolean hasItem(Player player, ItemStack item, int amount, boolean remove) {
|
||||
int hasAmount = 0;
|
||||
@@ -63,24 +63,24 @@ public class InventoryUtil {
|
||||
ItemStack _item = player.getInventory().getItem(i);
|
||||
if (_item != null && _item.isSimilar(item)) {
|
||||
/**
|
||||
* 如果循环到的物品数量 小于 需要的数量
|
||||
* 则 删除物品,减少需要的数量
|
||||
* 如果循环到的物品数量 小于 需要的数量
|
||||
* 则 删除物品,减少需要的数量
|
||||
*/
|
||||
if (_item.getAmount() < requireAmount) {
|
||||
player.getInventory().setItem(i, null);
|
||||
requireAmount -= _item.getAmount();
|
||||
}
|
||||
/**
|
||||
* 如果循环到的物品数量 等于 需要的数量
|
||||
* 则 删除物品,直接结束
|
||||
* 如果循环到的物品数量 等于 需要的数量
|
||||
* 则 删除物品,直接结束
|
||||
*/
|
||||
else if (_item.getAmount() == requireAmount) {
|
||||
player.getInventory().setItem(i, null);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 如果循环到的物品数量 大于 需要的数量
|
||||
* 则扣除 需要的数量
|
||||
* 如果循环到的物品数量 大于 需要的数量
|
||||
* 则扣除 需要的数量
|
||||
*/
|
||||
else {
|
||||
_item.setAmount(_item.getAmount() - requireAmount);
|
||||
@@ -8,7 +8,6 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
@@ -25,14 +24,9 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.skymc.taboocode.TabooCodeItem;
|
||||
import me.skymc.taboocode4.manager.ItemManager;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
@@ -65,20 +59,20 @@ public class ItemUtils {
|
||||
private static LinkedHashMap<String, ItemStack> itemCachesFinal = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* 获取物品缓存
|
||||
* 检测顺序:
|
||||
* 1. 固定物品库
|
||||
* 2. 动态物品库
|
||||
* 获取物品缓存
|
||||
* 检测顺序:
|
||||
* 1. 固定物品库
|
||||
* 2. 动态物品库
|
||||
*
|
||||
* @param name 物品名称
|
||||
* @param name 物品名称
|
||||
* @return
|
||||
*/
|
||||
public static ItemStack getCacheItem(String name) {
|
||||
// 检测固定物品库是否存在该物品
|
||||
// 检测固定物品库是否存在该物品
|
||||
if (itemCachesFinal.containsKey(name)) {
|
||||
return itemCachesFinal.get(name);
|
||||
}
|
||||
// 返回动态物品库
|
||||
// 返回动态物品库
|
||||
return itemCaches.get(name);
|
||||
}
|
||||
|
||||
@@ -96,7 +90,7 @@ public class ItemUtils {
|
||||
FileConfiguration conf = ConfigUtils.load(Main.getInst(), file);
|
||||
for (String name : conf.getConfigurationSection("").getKeys(false)) {
|
||||
if (isExists(name)) {
|
||||
MsgUtils.warn("无法载入载入物品 &4" + name + "&c, 因为它已经存在了");
|
||||
MsgUtils.warn("无法载入载入物品 &4" + name + "&c, 因为它已经存在了");
|
||||
} else if (finalFile) {
|
||||
itemCachesFinal.put(name, loadItem(conf, name));
|
||||
} else {
|
||||
@@ -109,16 +103,16 @@ public class ItemUtils {
|
||||
itemCaches.clear();
|
||||
itemCachesFinal.clear();
|
||||
loadItemsFile(getItemCacheFile(), false);
|
||||
// 创建固定物品库
|
||||
// 创建固定物品库
|
||||
finalItemsFolder = new File(Main.getInst().getDataFolder(), "FinalItems");
|
||||
if (!finalItemsFolder.exists()) {
|
||||
finalItemsFolder.mkdir();
|
||||
}
|
||||
// 检查固定物品库中的物品
|
||||
// 检查固定物品库中的物品
|
||||
for (File file : finalItemsFolder.listFiles()) {
|
||||
loadItemsFile(file, true);
|
||||
}
|
||||
MsgUtils.send("载入 " + (itemCaches.size() + itemCachesFinal.size()) + " 项缓存物品");
|
||||
MsgUtils.send("载入 " + (itemCaches.size() + itemCachesFinal.size()) + " 项缓存物品");
|
||||
}
|
||||
|
||||
public static void reloadItemName() {
|
||||
@@ -127,7 +121,7 @@ public class ItemUtils {
|
||||
for (String a : conf.getConfigurationSection("").getKeys(false)) {
|
||||
itemlib.put(a, conf.getString(a));
|
||||
}
|
||||
MsgUtils.send("载入 " + itemlib.size() + " 项物品名称");
|
||||
MsgUtils.send("载入 " + itemlib.size() + " 项物品名称");
|
||||
}
|
||||
|
||||
public static File getItemCacheFile() {
|
||||
@@ -140,7 +134,7 @@ public class ItemUtils {
|
||||
|
||||
public static String getCustomName(ItemStack item) {
|
||||
if (item == null || item.getType().equals(Material.AIR)) {
|
||||
return "空";
|
||||
return "空";
|
||||
}
|
||||
int data = item.getType().getMaxDurability() == 0 ? item.getDurability() : 0;
|
||||
return item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : itemlib.get(item.getType() + ":" + data) == null ? item.getType().toString() : itemlib.get(item.getType() + ":" + data);
|
||||
@@ -148,17 +142,10 @@ public class ItemUtils {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ItemStack getItemFromDir(String name) {
|
||||
ItemStack item = new ItemStack(Material.STONE);
|
||||
if (Bukkit.getPluginManager().getPlugin("TabooCode").isEnabled()) {
|
||||
item = TabooCodeItem.getItem(name, true);
|
||||
if (itemdir != null) {
|
||||
return itemdir.getItemStack("item." + name);
|
||||
}
|
||||
else if (Bukkit.getPluginManager().getPlugin("TabooCode4").isEnabled()) {
|
||||
item = ItemManager.getFinishItem(name);
|
||||
}
|
||||
if (item == null && itemdir != null) {
|
||||
item = itemdir.getItemStack("item." + name);
|
||||
}
|
||||
return item;
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -208,9 +195,9 @@ public class ItemUtils {
|
||||
|
||||
public static String asString(String args, Player placeholderPlayer) {
|
||||
if (placeholderPlayer == null) {
|
||||
return args.replace("&", "§");
|
||||
return args.replace("&", "§");
|
||||
}
|
||||
return PlaceholderAPI.setPlaceholders(placeholderPlayer, args.replace("&", "§"));
|
||||
return PlaceholderAPI.setPlaceholders(placeholderPlayer, args.replace("&", "§"));
|
||||
}
|
||||
|
||||
public static List<String> asString(List<String> args, Player placeholderPlayer) {
|
||||
@@ -297,10 +284,10 @@ public class ItemUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 包含介绍
|
||||
* 包含介绍
|
||||
*
|
||||
* @param i 物品
|
||||
* @param a 关键字
|
||||
* @param i 物品
|
||||
* @param a 关键字
|
||||
*/
|
||||
public static boolean hasLore(ItemStack i, String a) {
|
||||
if (!isLored(i) || !i.getItemMeta().getLore().toString().contains(a)) {
|
||||
@@ -310,7 +297,7 @@ public class ItemUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果已描述
|
||||
* 如果已描述
|
||||
*
|
||||
* @param i
|
||||
* @return
|
||||
@@ -323,7 +310,7 @@ public class ItemUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果已命名
|
||||
* 如果已命名
|
||||
*
|
||||
* @param i
|
||||
* @return
|
||||
@@ -336,26 +323,26 @@ public class ItemUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加描述
|
||||
* 添加描述
|
||||
*
|
||||
* @param is 物品
|
||||
* @param lore 描述
|
||||
* @param is 物品
|
||||
* @param lore 描述
|
||||
*/
|
||||
public static ItemStack addLore(ItemStack is, String lore) {
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
|
||||
List<String> _lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
||||
_lore.add(lore.replaceAll("&", "§"));
|
||||
_lore.add(lore.replaceAll("&", "§"));
|
||||
|
||||
is.setItemMeta(meta);
|
||||
return is;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除描述
|
||||
* 移除描述
|
||||
*
|
||||
* @param is 物品
|
||||
* @param line 行数
|
||||
* @param is 物品
|
||||
* @param line 行数
|
||||
*/
|
||||
public static ItemStack delLore(ItemStack is, int line) {
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
@@ -371,10 +358,10 @@ public class ItemUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取介绍所在行数
|
||||
* 获取介绍所在行数
|
||||
*
|
||||
* @param i 物品
|
||||
* @param a 关键字
|
||||
* @param i 物品
|
||||
* @param a 关键字
|
||||
*/
|
||||
public static int getLore(ItemStack i, String a) {
|
||||
if (isLored(i)) {
|
||||
@@ -388,10 +375,10 @@ public class ItemUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加耐久
|
||||
* 添加耐久
|
||||
*
|
||||
* @param i 物品
|
||||
* @param d 耐久
|
||||
* @param i 物品
|
||||
* @param d 耐久
|
||||
*/
|
||||
public static ItemStack addDurability(ItemStack i, int d) {
|
||||
i.setDurability((short) (i.getDurability() + d));
|
||||
@@ -404,11 +391,11 @@ public class ItemUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换描述
|
||||
* 替换描述
|
||||
*
|
||||
* @param i 物品
|
||||
* @param l1 关键字1
|
||||
* @param l2 关键字2
|
||||
* @param i 物品
|
||||
* @param l1 关键字1
|
||||
* @param l2 关键字2
|
||||
*/
|
||||
public static ItemStack repalceLore(ItemStack i, String l1, String l2) {
|
||||
if (!isLored(i)) {
|
||||
@@ -438,23 +425,23 @@ public class ItemUtils {
|
||||
if (section.get("bukkit") instanceof ItemStack) {
|
||||
return section.getItemStack("bukkit");
|
||||
}
|
||||
// 材质
|
||||
// 材质
|
||||
ItemStack item = new ItemStack(asMaterial(section.get("material").toString()));
|
||||
// 数量
|
||||
// 数量
|
||||
item.setAmount(section.contains("amount") ? section.getInt("amount") : 1);
|
||||
// 耐久
|
||||
// 耐久
|
||||
item.setDurability((short) section.getInt("data"));
|
||||
// 元数据
|
||||
// 元数据
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
// 展示名
|
||||
// 展示名
|
||||
if (section.contains("name")) {
|
||||
meta.setDisplayName(asString(section.getString("name"), papiPlayer));
|
||||
}
|
||||
// 描述
|
||||
// 描述
|
||||
if (section.contains("lore")) {
|
||||
meta.setLore(asString(section.getStringList("lore"), papiPlayer));
|
||||
}
|
||||
// 附魔
|
||||
// 附魔
|
||||
if (section.contains("enchants")) {
|
||||
for (String preEnchant : section.getConfigurationSection("enchants").getKeys(false)) {
|
||||
Enchantment enchant = asEnchantment(preEnchant);
|
||||
@@ -462,12 +449,12 @@ public class ItemUtils {
|
||||
meta.addEnchant(enchant, section.getInt("enchants." + preEnchant), true);
|
||||
}
|
||||
else {
|
||||
MsgUtils.warn("&8" + preEnchant + " &c不是一个有效的附魔名称");
|
||||
MsgUtils.warn("&c输入 &4/taboolib enchants&c 查看所有附魔");
|
||||
MsgUtils.warn("&8" + preEnchant + " &c不是一个有效的附魔名称");
|
||||
MsgUtils.warn("&c输入 &4/taboolib enchants&c 查看所有附魔");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 标签
|
||||
// 标签
|
||||
if (section.contains("flags") && TabooLib.getVerint() > 10700) {
|
||||
for (String preFlag : section.getStringList("flags")) {
|
||||
ItemFlag flag = asItemFlag(preFlag);
|
||||
@@ -475,16 +462,16 @@ public class ItemUtils {
|
||||
meta.addItemFlags(flag);
|
||||
}
|
||||
else {
|
||||
MsgUtils.warn("&8" + preFlag + " &c不是一个有效的标签名称");
|
||||
MsgUtils.warn("&c输入 &4/taboolib flags&c 查看所有标签");
|
||||
MsgUtils.warn("&8" + preFlag + " &c不是一个有效的标签名称");
|
||||
MsgUtils.warn("&c输入 &4/taboolib flags&c 查看所有标签");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 皮革
|
||||
// 皮革
|
||||
if (meta instanceof LeatherArmorMeta && section.contains("color")) {
|
||||
((LeatherArmorMeta) meta).setColor(asColor(section.getString("color")));
|
||||
}
|
||||
// 药水
|
||||
// 药水
|
||||
if (meta instanceof PotionMeta && section.contains("potions")) {
|
||||
PotionMeta potionMeta = (PotionMeta) meta;
|
||||
for (String prePotionName : section.getConfigurationSection("potions").getKeys(false)) {
|
||||
@@ -496,16 +483,16 @@ public class ItemUtils {
|
||||
NumberUtils.getInteger(section.getString("potions." + prePotionName).split("-")[1]) - 1), true);
|
||||
}
|
||||
else {
|
||||
MsgUtils.warn("&8" + potionEffectType + " &c不是一个有效的药水名称");
|
||||
MsgUtils.warn("&c输入 &4/taboolib potions&c 查看所有药水");
|
||||
MsgUtils.warn("&8" + potionEffectType + " &c不是一个有效的药水名称");
|
||||
MsgUtils.warn("&c输入 &4/taboolib potions&c 查看所有药水");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 元数据
|
||||
// 元数据
|
||||
item.setItemMeta(meta);
|
||||
// 数据
|
||||
// 数据
|
||||
NBTItem nbt = new NBTItem(item);
|
||||
// 物品标签
|
||||
// 物品标签
|
||||
if (section.contains("nbt")) {
|
||||
for (String name : section.getConfigurationSection("nbt").getKeys(false)) {
|
||||
Object obj = section.get("nbt." + name);
|
||||
@@ -526,7 +513,7 @@ public class ItemUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 物品属性
|
||||
// 物品属性
|
||||
if (section.contains("attributes")) {
|
||||
NBTList attr = nbt.getList("AttributeModifiers", NBTType.NBTTagCompound);
|
||||
for (String hand : section.getConfigurationSection("attributes").getKeys(false)) {
|
||||
@@ -552,12 +539,12 @@ public class ItemUtils {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
MsgUtils.warn("&8" + name + " &c属性载入失败: &8" + e.getMessage());
|
||||
MsgUtils.warn("&8" + name + " &c属性载入失败: &8" + e.getMessage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
MsgUtils.warn("&8" + name + " &c不是一个有效的属性名称");
|
||||
MsgUtils.warn("&c输入 &4/taboolib attributes&c 查看所有属性");
|
||||
MsgUtils.warn("&8" + name + " &c不是一个有效的属性名称");
|
||||
MsgUtils.warn("&c输入 &4/taboolib attributes&c 查看所有属性");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -596,12 +583,12 @@ public class ItemUtils {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
MsgUtils.warn("&8" + name + " &c属性载入失败: &8" + e.getMessage());
|
||||
MsgUtils.warn("&8" + name + " &c属性载入失败: &8" + e.getMessage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
MsgUtils.warn("&8" + name + " &c不是一个有效的属性名称");
|
||||
MsgUtils.warn("&c输入 &4/taboolib attributes&c 查看所有属性");
|
||||
MsgUtils.warn("&8" + name + " &c不是一个有效的属性名称");
|
||||
MsgUtils.warn("&c输入 &4/taboolib attributes&c 查看所有属性");
|
||||
}
|
||||
return nbt;
|
||||
}
|
||||
@@ -6,40 +6,40 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月17日 下午8:35:42
|
||||
* @since 2018年2月17日 下午8:35:42
|
||||
*/
|
||||
public abstract interface AbstractSpecialItem {
|
||||
|
||||
/**
|
||||
* 当接口被载入
|
||||
* 当接口被载入
|
||||
*/
|
||||
default void onEnable() {}
|
||||
|
||||
/**
|
||||
* 当接口被卸载
|
||||
* 当接口被卸载
|
||||
*/
|
||||
default void onDisable() {}
|
||||
|
||||
/**
|
||||
* 获取识别名称
|
||||
* 获取识别名称
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
abstract String getName();
|
||||
|
||||
/**
|
||||
* 获取载入插件
|
||||
* 获取载入插件
|
||||
*
|
||||
* @return {@link Plugin}
|
||||
*/
|
||||
abstract Plugin getPlugin();
|
||||
|
||||
/**
|
||||
* 是否进行点击事件
|
||||
* 是否进行点击事件
|
||||
*
|
||||
* @param player 玩家
|
||||
* @param currentItem 点击物品
|
||||
* @param cursorItem 持有物品
|
||||
* @param player 玩家
|
||||
* @param currentItem 点击物品
|
||||
* @param cursorItem 持有物品
|
||||
* @return {@link SpecialItemResult[]}
|
||||
*/
|
||||
abstract SpecialItemResult[] isCorrectClick(Player player, ItemStack currentItem, ItemStack cursorItem);
|
||||
@@ -19,7 +19,7 @@ import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月17日 下午8:34:12
|
||||
* @since 2018年2月17日 下午8:34:12
|
||||
*/
|
||||
public class SpecialItem implements Listener {
|
||||
|
||||
@@ -31,14 +31,14 @@ public class SpecialItem implements Listener {
|
||||
private boolean isLoaded;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* 构造方法
|
||||
*/
|
||||
private SpecialItem() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工具对象
|
||||
* 获取工具对象
|
||||
*
|
||||
* @return {@link SpecialItem}
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ public class SpecialItem implements Listener {
|
||||
synchronized (SpecialItem.class) {
|
||||
if (specialItem == null) {
|
||||
specialItem = new SpecialItem();
|
||||
// 注册监听器
|
||||
// 注册监听器
|
||||
Bukkit.getPluginManager().registerEvents(specialItem, Main.getInst());
|
||||
}
|
||||
}
|
||||
@@ -56,13 +56,13 @@ public class SpecialItem implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册接口
|
||||
* 注册接口
|
||||
*
|
||||
* @param item 接口对象
|
||||
* @param item 接口对象
|
||||
*/
|
||||
public void register(AbstractSpecialItem item) {
|
||||
if (contains(item.getName())) {
|
||||
MsgUtils.warn("特殊物品接口已存在, 检查名称 &4" + item.getName() + " &c是否重复");
|
||||
MsgUtils.warn("特殊物品接口已存在, 检查名称 &4" + item.getName() + " &c是否重复");
|
||||
}
|
||||
else {
|
||||
ITEM_DATA.add(item);
|
||||
@@ -73,9 +73,9 @@ public class SpecialItem implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销接口
|
||||
* 注销接口
|
||||
*
|
||||
* @param name 注册名称
|
||||
* @param name 注册名称
|
||||
*/
|
||||
public void cancel(String name) {
|
||||
for (AbstractSpecialItem specialitem : ITEM_DATA) {
|
||||
@@ -87,9 +87,9 @@ public class SpecialItem implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销接口
|
||||
* 注销接口
|
||||
*
|
||||
* @param plugin 注册插件
|
||||
* @param plugin 注册插件
|
||||
*/
|
||||
public void cancel(Plugin plugin) {
|
||||
for (AbstractSpecialItem specialitem : ITEM_DATA) {
|
||||
@@ -101,9 +101,9 @@ public class SpecialItem implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断名称是否存在
|
||||
* 判断名称是否存在
|
||||
*
|
||||
* @param name 注册名称
|
||||
* @param name 注册名称
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean contains(String name) {
|
||||
@@ -116,7 +116,7 @@ public class SpecialItem implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 载入所有已注册接口
|
||||
* 载入所有已注册接口
|
||||
*/
|
||||
public void loadItems() {
|
||||
ITEM_DATA.forEach(x -> x.onEnable());
|
||||
@@ -124,7 +124,7 @@ public class SpecialItem implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销所有已注册接口
|
||||
* 注销所有已注册接口
|
||||
*/
|
||||
public void unloadItems() {
|
||||
ITEM_DATA.forEach(x -> x.onDisable());
|
||||
@@ -2,37 +2,37 @@ package me.skymc.taboolib.inventory.speciaitem;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月17日 下午8:55:36
|
||||
* @since 2018年2月17日 下午8:55:36
|
||||
*/
|
||||
public enum SpecialItemResult {
|
||||
|
||||
/**
|
||||
* 停止接口检测
|
||||
* 停止接口检测
|
||||
*/
|
||||
BREAK,
|
||||
|
||||
/**
|
||||
* 取消点击事件
|
||||
* 取消点击事件
|
||||
*/
|
||||
CANCEL,
|
||||
|
||||
/**
|
||||
* 移除点击物品
|
||||
* 移除点击物品
|
||||
*/
|
||||
REMOVE_ITEM_CURRENT,
|
||||
|
||||
/**
|
||||
* 移除鼠标物品
|
||||
* 移除鼠标物品
|
||||
*/
|
||||
REMOVE_ITEM_CURSOR,
|
||||
|
||||
/**
|
||||
* 移除一个点击物品
|
||||
* 移除一个点击物品
|
||||
*/
|
||||
REMOVE_ITEM_CURRENT_AMOUNT_1,
|
||||
|
||||
/**
|
||||
* 移除一个鼠标物品
|
||||
* 移除一个鼠标物品
|
||||
*/
|
||||
REMOVE_ITEM_CURSOR_AMOUNT_1;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class NBTList {
|
||||
method.invoke(listObject, compound);
|
||||
return new NBTListCompound(this, compound);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class NBTList {
|
||||
Object compound = method.invoke(listObject, id);
|
||||
return new NBTListCompound(this, compound);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class NBTList {
|
||||
Method method = listObject.getClass().getMethod("getString", int.class);
|
||||
return (String) method.invoke(listObject, i);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class NBTList {
|
||||
method.invoke(listObject, NBTReflectionUtil.getNBTTagString().getConstructor(String.class).newInstance(s));
|
||||
save();
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class NBTList {
|
||||
method.invoke(listObject, i, NBTReflectionUtil.getNBTTagString().getConstructor(String.class).newInstance(s));
|
||||
save();
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class NBTList {
|
||||
method.invoke(listObject, i);
|
||||
save();
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class NBTList {
|
||||
Method method = listObject.getClass().getMethod("size");
|
||||
return (int) method.invoke(listObject);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class NBTListCompound {
|
||||
compound.getClass().getMethod("setString", String.class, String.class).invoke(compound, key, value);
|
||||
owner.save();
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class NBTListCompound {
|
||||
compound.getClass().getMethod("setInt", String.class, int.class).invoke(compound, key, value);
|
||||
owner.save();
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class NBTListCompound {
|
||||
try {
|
||||
return (int) compound.getClass().getMethod("getInt", String.class).invoke(compound, value);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class NBTListCompound {
|
||||
compound.getClass().getMethod("setDouble", String.class, double.class).invoke(compound, key, value);
|
||||
owner.save();
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class NBTListCompound {
|
||||
try {
|
||||
return (double) compound.getClass().getMethod("getDouble", String.class).invoke(compound, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class NBTListCompound {
|
||||
try {
|
||||
return (String) compound.getClass().getMethod("getString", String.class).invoke(compound, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class NBTListCompound {
|
||||
try {
|
||||
return (boolean) compound.getClass().getMethod("hasKey", String.class).invoke(compound, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class NBTListCompound {
|
||||
try {
|
||||
return (Set<String>) compound.getClass().getMethod("c").invoke(compound);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class NBTListCompound {
|
||||
try {
|
||||
compound.getClass().getMethod("remove", String.class).invoke(compound, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class NBTReflectionUtil {
|
||||
Class clazz = Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack");
|
||||
return clazz;
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class NBTReflectionUtil {
|
||||
Class clazz = Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftEntity");
|
||||
return clazz;
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class NBTReflectionUtil {
|
||||
Class clazz = Class.forName("net.minecraft.server." + version + ".NBTBase");
|
||||
return clazz;
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class NBTReflectionUtil {
|
||||
return clazz;
|
||||
} catch (Exception ex) {
|
||||
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class NBTReflectionUtil {
|
||||
return clazz;
|
||||
} catch (Exception ex) {
|
||||
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class NBTReflectionUtil {
|
||||
return clazz;
|
||||
} catch (Exception ex) {
|
||||
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class NBTReflectionUtil {
|
||||
return clazz;
|
||||
} catch (Exception ex) {
|
||||
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class NBTReflectionUtil {
|
||||
return c;
|
||||
} catch (Exception ex) {
|
||||
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public class NBTReflectionUtil {
|
||||
return clazz;
|
||||
} catch (Exception ex) {
|
||||
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class NBTReflectionUtil {
|
||||
return clazz;
|
||||
} catch (Exception ex) {
|
||||
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class NBTReflectionUtil {
|
||||
return c.newInstance();
|
||||
} catch (Exception ex) {
|
||||
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class NBTReflectionUtil {
|
||||
return clazz.getConstructor(int.class, int.class, int.class).newInstance(x, y, z);
|
||||
} catch (Exception ex) {
|
||||
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(NMSItem, NBTTag);
|
||||
return NMSItem;
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -189,7 +189,7 @@ public class NBTReflectionUtil {
|
||||
Object answer = method.invoke(clazz, item);
|
||||
return answer;
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ public class NBTReflectionUtil {
|
||||
method = clazz.getMethod("getHandle");
|
||||
return method.invoke(getCraftEntity().cast(entity));
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public class NBTReflectionUtil {
|
||||
method = cis.getMethod("parse", String.class);
|
||||
return method.invoke(null, json);
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -231,7 +231,7 @@ public class NBTReflectionUtil {
|
||||
method = clazz.getMethod("a", InputStream.class);
|
||||
return method.invoke(clazz, stream);
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class NBTReflectionUtil {
|
||||
method = clazz.getMethod("a", getNBTTagCompound(), OutputStream.class);
|
||||
return method.invoke(clazz, nbt, stream);
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -260,7 +260,7 @@ public class NBTReflectionUtil {
|
||||
Object answer = method.invoke(clazz, item);
|
||||
return (ItemStack) answer;
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ public class NBTReflectionUtil {
|
||||
Object answer = method.invoke(nmsitem);
|
||||
return answer;
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -288,7 +288,7 @@ public class NBTReflectionUtil {
|
||||
Object nmsstack = clazz.getConstructor(getNBTTagCompound()).newInstance(nbtcompound.getCompound());
|
||||
return nmsstack;
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -303,7 +303,7 @@ public class NBTReflectionUtil {
|
||||
Object answer = method.invoke(nmsitem, getNewNBTTag());
|
||||
return new NBTContainer(answer);
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public class NBTReflectionUtil {
|
||||
answer = nbt;
|
||||
return answer;
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -333,7 +333,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(NMSItem, NBTTag);
|
||||
return NMSItem;
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -352,7 +352,7 @@ public class NBTReflectionUtil {
|
||||
answer = tag;
|
||||
return answer;
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -367,7 +367,7 @@ public class NBTReflectionUtil {
|
||||
method = getTileEntity().getMethod("a", getNBTTagCompound());
|
||||
method.invoke(o, comp);
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ public class NBTReflectionUtil {
|
||||
Object answer = method.invoke(compound, name);
|
||||
return answer;
|
||||
} catch (Exception e) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -405,7 +405,7 @@ public class NBTReflectionUtil {
|
||||
comp.setCompound(nbttag);
|
||||
return;
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -446,7 +446,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, nbtcompound.getCompound());
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, text);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getString", String.class);
|
||||
return (String) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -500,7 +500,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("get", String.class);
|
||||
return method.invoke(workingtag, key).toString();
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -522,7 +522,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, i);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getInt", String.class);
|
||||
return (Integer) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -560,7 +560,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, b);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getByteArray", String.class);
|
||||
return (byte[]) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -599,7 +599,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, i);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getIntArray", String.class);
|
||||
return (int[]) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -637,7 +637,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, (float) f);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getFloat", String.class);
|
||||
return (Float) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -675,7 +675,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, (long) f);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getLong", String.class);
|
||||
return (Long) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -713,7 +713,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, (short) f);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,7 +729,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getShort", String.class);
|
||||
return (Short) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -751,7 +751,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, (byte) f);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,7 +767,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getByte", String.class);
|
||||
return (Byte) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -789,7 +789,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, d);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -805,7 +805,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getDouble", String.class);
|
||||
return (Double) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -822,7 +822,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod(MethodNames.getTypeMethodName(), String.class);
|
||||
return (byte) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -844,7 +844,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, d);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -860,7 +860,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getBoolean", String.class);
|
||||
return (Boolean) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -885,7 +885,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key, val);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -901,7 +901,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("getList", String.class, int.class);
|
||||
return new NBTList(comp, key, type, method.invoke(workingtag, key, type.getId()));
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -911,7 +911,7 @@ public class NBTReflectionUtil {
|
||||
String json = GsonWrapper.getString(value);
|
||||
setString(comp, key, json);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -936,7 +936,7 @@ public class NBTReflectionUtil {
|
||||
method.invoke(workingtag, key);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -952,7 +952,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("hasKey", String.class);
|
||||
return (Boolean) method.invoke(workingtag, key);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -970,7 +970,7 @@ public class NBTReflectionUtil {
|
||||
method = workingtag.getClass().getMethod("c");
|
||||
return (Set<String>) method.invoke(workingtag);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class GsonWrapper {
|
||||
T obj = gson.fromJson(json, type);
|
||||
return type.cast(obj);
|
||||
} catch (Exception ex) {
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
MsgUtils.warn("NBT 操作出现异常: §7" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class JarUtils {
|
||||
method.setAccessible(true);
|
||||
method.invoke(sysloader, new Object[] { url });
|
||||
} catch (Throwable t) {
|
||||
MsgUtils.warn("无法添加添加 &4" + url + "&c 到运行库");
|
||||
MsgUtils.warn("无法添加添加 &4" + url + "&c 到运行库");
|
||||
MsgUtils.warn(t.getMessage());
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user