版本更新至:3.79

新增:/tlm inv paste 命令增加 "-a", "-b" 两个参数,用于调整背包覆盖方式
调整:EntityTag 工具删除 remove 方法的无用参数
This commit is contained in:
坏黑 2018-03-13 21:44:45 +08:00
parent fb58c9838f
commit 0179e269b5
6 changed files with 41 additions and 14 deletions

View File

@ -10,7 +10,7 @@ COMMAND-HELP:
- '&f /tlm inv list &6- &e列出所有保存的背包' - '&f /tlm inv list &6- &e列出所有保存的背包'
- '&f /tlm inv info &8[&7名称] &6- &e查看保存背包' - '&f /tlm inv info &8[&7名称] &6- &e查看保存背包'
- '&f /tlm inv save &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 inv delete &8[&7名称] &6- &e删除保存背包'
- '' - ''
- '&f /tlm list &6- &e列出所有模块' - '&f /tlm list &6- &e列出所有模块'

View File

@ -6,7 +6,7 @@ website: http://www.15imc.com/index.html
main: me.skymc.taboolib.Main main: me.skymc.taboolib.Main
version: 3.78 version: 3.79
commands: commands:
taboolib: taboolib:

View File

@ -88,38 +88,36 @@ public class EntityTag {
* 移除标签 * 移除标签
* *
* @param key * @param key
* @param value
* @param entity 实体 * @param entity 实体
*/ */
public void remove(String key, Object value, Entity entity) { public Object remove(String key, Entity entity) {
if (contains(entity)) { if (contains(entity)) {
entityData.get(entity.getUniqueId()).remove(key); entityData.get(entity.getUniqueId()).remove(key);
if (entityData.get(entity.getUniqueId()).size() == 0) { if (entityData.get(entity.getUniqueId()).size() == 0) {
entityData.remove(entity.getUniqueId()); return entityData.remove(entity.getUniqueId());
} }
} }
return null;
} }
/** /**
* 移除标签 * 移除标签
* *
* @param key * @param key
* @param value
* @param entities 实体 * @param entities 实体
*/ */
public void remove(String key, Object value, Entity... entities) { public void remove(String key, Entity... entities) {
for (Entity entity : entities) remove(key, value, entity); for (Entity entity : entities) remove(key, entity);
} }
/** /**
* 移除标签 * 移除标签
* *
* @param key * @param key
* @param value
* @param entities 实体 * @param entities 实体
*/ */
public void remove(String key, Object value, List<Entity> entities) { public void remove(String key, List<Entity> entities) {
for (Entity entity : entities) remove(key, value, entity); for (Entity entity : entities) remove(key, entity);
} }
/** /**

View File

@ -112,7 +112,6 @@ public class FileUtils {
if (_file1.isDirectory()) { if (_file1.isDirectory()) {
for (File file : _file1.listFiles()) { for (File file : _file1.listFiles()) {
if (file.isDirectory()) { if (file.isDirectory()) {
file.getName();
copyAllFile(file.getAbsolutePath(), file2 + "/" + file.getName()); copyAllFile(file.getAbsolutePath(), file2 + "/" + file.getName());
} else { } else {
fileChannelCopy(file, new File(file2 + "/" + file.getName())); fileChannelCopy(file, new File(file2 + "/" + file.getName()));

View File

@ -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) { if (sender instanceof Player) {

View File

@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
import me.skymc.taboolib.Main; import me.skymc.taboolib.Main;
import me.skymc.taboolib.TabooLib; import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.inventory.ItemUtils;
import me.skymc.taboolib.message.MsgUtils; import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.playerdata.DataUtils; import me.skymc.taboolib.playerdata.DataUtils;
import me.skymc.tlm.annotation.DisableConfig; import me.skymc.tlm.annotation.DisableConfig;
@ -70,6 +71,17 @@ public class ModuleInventorySave implements ITabooLibraryModule, Listener {
* @param name 名称 * @param name 名称
*/ */
public void pasteInventory(Player player, String 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)) { if (!conf.contains(name)) {
MsgUtils.warn("模块执行异常: &4背包不存在"); MsgUtils.warn("模块执行异常: &4背包不存在");
@ -77,11 +89,25 @@ public class ModuleInventorySave implements ITabooLibraryModule, Listener {
MsgUtils.warn("位于: &4" + name); MsgUtils.warn("位于: &4" + name);
return; return;
} }
// 异常物品
List<ItemStack> otherItem = new ArrayList<>();
// 设置物品 // 设置物品
for (int i = 0 ; i < (TabooLib.getVerint() > 10800 ? 41 : 40) ; i++) { for (int i = 0 ; i < (TabooLib.getVerint() > 10800 ? 41 : 40) ; i++) {
try { try {
ItemStack item = (ItemStack) conf.get(name + "." + i); 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); player.getInventory().setItem(i, item);
} }
catch (Exception e) { catch (Exception e) {
@ -90,6 +116,10 @@ public class ModuleInventorySave implements ITabooLibraryModule, Listener {
MsgUtils.warn("位于: &4" + name + ":" + i); MsgUtils.warn("位于: &4" + name + ":" + i);
} }
} }
// 循环异常物品
for (ItemStack item : otherItem) {
player.getInventory().addItem(item);
}
} }
/** /**