版本更新至:3.79
新增:/tlm inv paste 命令增加 "-a", "-b" 两个参数,用于调整背包覆盖方式 调整:EntityTag 工具删除 remove 方法的无用参数
This commit is contained in:
parent
fb58c9838f
commit
0179e269b5
@ -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列出所有模块'
|
||||
|
@ -6,7 +6,7 @@ website: http://www.15imc.com/index.html
|
||||
|
||||
main: me.skymc.taboolib.Main
|
||||
|
||||
version: 3.78
|
||||
version: 3.79
|
||||
|
||||
commands:
|
||||
taboolib:
|
||||
|
@ -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<Entity> entities) {
|
||||
for (Entity entity : entities) remove(key, value, entity);
|
||||
public void remove(String key, List<Entity> entities) {
|
||||
for (Entity entity : entities) remove(key, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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()));
|
||||
|
@ -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) {
|
||||
|
@ -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<ItemStack> 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user