diff --git a/resources/Language2/zh_CN.yml b/resources/Language2/zh_CN.yml index b1866a7..09527b0 100644 --- a/resources/Language2/zh_CN.yml +++ b/resources/Language2/zh_CN.yml @@ -10,7 +10,7 @@ COMMAND-HELP: - '&f /tlm inv list &6- &e列出所有保存的背包' - '&f /tlm inv info &8[&7名称] &6- &e查看保存背包' - '&f /tlm inv save &8[&7名称] &6- &e保存当前背包' -- '&f /tlm inv paste &8[&7名称] &8<&7玩家&8> &6- &e覆盖背包' +- '&f /tlm inv paste &8[&7名称] &8<&7玩家&8> &8<&7-b|a&8> &6- &e覆盖背包' - '&f /tlm inv delete &8[&7名称] &6- &e删除保存背包' - '' - '&f /tlm list &6- &e列出所有模块' diff --git a/resources/plugin.yml b/resources/plugin.yml index 773120e..a1df55f 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -6,7 +6,7 @@ website: http://www.15imc.com/index.html main: me.skymc.taboolib.Main -version: 3.78 +version: 3.79 commands: taboolib: diff --git a/src/main/java/me/skymc/taboolib/entity/EntityTag.java b/src/main/java/me/skymc/taboolib/entity/EntityTag.java index 624b85f..8d44ae9 100644 --- a/src/main/java/me/skymc/taboolib/entity/EntityTag.java +++ b/src/main/java/me/skymc/taboolib/entity/EntityTag.java @@ -88,38 +88,36 @@ public class EntityTag { * 移除标签 * * @param key 键 - * @param value 值 * @param entity 实体 */ - public void remove(String key, Object value, Entity entity) { + public Object remove(String key, Entity entity) { if (contains(entity)) { entityData.get(entity.getUniqueId()).remove(key); if (entityData.get(entity.getUniqueId()).size() == 0) { - entityData.remove(entity.getUniqueId()); + return entityData.remove(entity.getUniqueId()); } } + return null; } /** * 移除标签 * * @param key 键 - * @param value 值 * @param entities 实体 */ - public void remove(String key, Object value, Entity... entities) { - for (Entity entity : entities) remove(key, value, entity); + public void remove(String key, Entity... entities) { + for (Entity entity : entities) remove(key, entity); } /** * 移除标签 * * @param key 键 - * @param value 值 * @param entities 实体 */ - public void remove(String key, Object value, List entities) { - for (Entity entity : entities) remove(key, value, entity); + public void remove(String key, List entities) { + for (Entity entity : entities) remove(key, entity); } /** diff --git a/src/main/java/me/skymc/taboolib/fileutils/FileUtils.java b/src/main/java/me/skymc/taboolib/fileutils/FileUtils.java index bff9aa2..2480c5d 100644 --- a/src/main/java/me/skymc/taboolib/fileutils/FileUtils.java +++ b/src/main/java/me/skymc/taboolib/fileutils/FileUtils.java @@ -112,7 +112,6 @@ public class FileUtils { if (_file1.isDirectory()) { for (File file : _file1.listFiles()) { if (file.isDirectory()) { - file.getName(); copyAllFile(file.getAbsolutePath(), file2 + "/" + file.getName()); } else { fileChannelCopy(file, new File(file2 + "/" + file.getName())); diff --git a/src/main/java/me/skymc/tlm/command/sub/TLMInvCommand.java b/src/main/java/me/skymc/tlm/command/sub/TLMInvCommand.java index 0012b99..63bd1cc 100644 --- a/src/main/java/me/skymc/tlm/command/sub/TLMInvCommand.java +++ b/src/main/java/me/skymc/tlm/command/sub/TLMInvCommand.java @@ -162,7 +162,7 @@ public class TLMInvCommand extends SubCommand { } // 覆盖背包 - moduleInventorySave.pasteInventory(player, args[2]); + moduleInventorySave.pasteInventory(player, args[2], args.length > 4 ? args[3] : "null"); // 如果是玩家 if (sender instanceof Player) { diff --git a/src/main/java/me/skymc/tlm/module/sub/ModuleInventorySave.java b/src/main/java/me/skymc/tlm/module/sub/ModuleInventorySave.java index 4dd9265..58ff82f 100644 --- a/src/main/java/me/skymc/tlm/module/sub/ModuleInventorySave.java +++ b/src/main/java/me/skymc/tlm/module/sub/ModuleInventorySave.java @@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack; import me.skymc.taboolib.Main; import me.skymc.taboolib.TabooLib; +import me.skymc.taboolib.inventory.ItemUtils; import me.skymc.taboolib.message.MsgUtils; import me.skymc.taboolib.playerdata.DataUtils; import me.skymc.tlm.annotation.DisableConfig; @@ -70,6 +71,17 @@ public class ModuleInventorySave implements ITabooLibraryModule, Listener { * @param name 名称 */ public void pasteInventory(Player player, String name) { + pasteInventory(player, name, "null"); + } + + /** + * 覆盖玩家背包 + * + * @param player 玩家 + * @param name 名称 + * @param module 模式 + */ + public void pasteInventory(Player player, String name, String module) { // 如果背包不存在 if (!conf.contains(name)) { MsgUtils.warn("模块执行异常: &4背包不存在"); @@ -77,11 +89,25 @@ public class ModuleInventorySave implements ITabooLibraryModule, Listener { MsgUtils.warn("位于: &4" + name); return; } - + // 异常物品 + List otherItem = new ArrayList<>(); // 设置物品 for (int i = 0 ; i < (TabooLib.getVerint() > 10800 ? 41 : 40) ; i++) { try { ItemStack item = (ItemStack) conf.get(name + "." + i); + // 如果原本有物品 + if (!ItemUtils.isNull(player.getInventory().getItem(i))) { + // 跳过 + if (module.equalsIgnoreCase("-b")) { + continue; + } + // 给予 + else if (module.equalsIgnoreCase("-a")) { + otherItem.add(item); + continue; + } + } + // 覆盖 player.getInventory().setItem(i, item); } catch (Exception e) { @@ -90,6 +116,10 @@ public class ModuleInventorySave implements ITabooLibraryModule, Listener { MsgUtils.warn("位于: &4" + name + ":" + i); } } + // 循环异常物品 + for (ItemStack item : otherItem) { + player.getInventory().addItem(item); + } } /**