版本更新至 3.6
新增:DisableConfig 注释,用于禁止 TLM 模块生成配置文件 新增:TLM/InventorySave 模块,用于保存,覆盖玩家背包 新增:TLM/CommandChanger 模块,用于转换控制台、玩家命令 新增:TLM/Kit 模块新增命令配置,可在领取时执行控制台命令 新增:/tlm kit list 命令,用于列出礼包 新增:/tlm inv list 命令,用于列出已保存的背包 新增:/tlm inv info 命令,用于查看已保存的背包 新增:/tlm inv save 命令,用于保存当前背包 新增:/tlm inv paste 命令,用于将已保存的背包覆盖到玩家背包内 新增:/tlm inv delete 命令,用于删除已保存的背包
This commit is contained in:
parent
021c89a0e8
commit
06f6340863
@ -9,6 +9,8 @@ import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.string.language2.Language2;
|
||||
import me.skymc.tlm.module.TabooLibraryModule;
|
||||
import me.skymc.tlm.module.sub.ModuleCommandChanger;
|
||||
import me.skymc.tlm.module.sub.ModuleInventorySave;
|
||||
import me.skymc.tlm.module.sub.ModuleKits;
|
||||
import me.skymc.tlm.module.sub.ModuleTimeCycle;
|
||||
|
||||
@ -40,6 +42,12 @@ public class TLM {
|
||||
if (isEnableModule("Kits")) {
|
||||
TabooLibraryModule.getInst().register(new ModuleKits());
|
||||
}
|
||||
if (isEnableModule("CommandChanger")) {
|
||||
TabooLibraryModule.getInst().register(new ModuleCommandChanger());
|
||||
}
|
||||
if (isEnableModule("InventorySave")) {
|
||||
TabooLibraryModule.getInst().register(new ModuleInventorySave());
|
||||
}
|
||||
|
||||
// ÔØÈëÄ£¿é
|
||||
TabooLibraryModule.getInst().loadModules();
|
||||
|
17
src/main/src/me/skymc/tlm/annotation/DisableConfig.java
Normal file
17
src/main/src/me/skymc/tlm/annotation/DisableConfig.java
Normal file
@ -0,0 +1,17 @@
|
||||
package me.skymc.tlm.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target(TYPE)
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018Äê2ÔÂ22ÈÕ ÏÂÎç3:59:30
|
||||
*/
|
||||
public @interface DisableConfig {
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import me.skymc.tlm.TLM;
|
||||
import me.skymc.tlm.command.sub.TLMInvCommand;
|
||||
import me.skymc.tlm.command.sub.TLMKitCommand;
|
||||
import me.skymc.tlm.command.sub.TLMListCommand;
|
||||
import me.skymc.tlm.command.sub.TLMReloadCommand;
|
||||
@ -24,6 +25,7 @@ public class TLMCommands implements CommandExecutor {
|
||||
TLM.getInst().getLanguage().get("NOPERMISSION-HELP").send(sender);
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (sender.hasPermission("taboolib.admin")) {
|
||||
new TLMReloadCommand(sender, args);
|
||||
@ -31,6 +33,7 @@ public class TLMCommands implements CommandExecutor {
|
||||
TLM.getInst().getLanguage().get("NOPERMISSION-RELOAD").send(sender);
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("list")) {
|
||||
if (sender.hasPermission("taboolib.admin")) {
|
||||
new TLMListCommand(sender, args);
|
||||
@ -38,9 +41,19 @@ public class TLMCommands implements CommandExecutor {
|
||||
TLM.getInst().getLanguage().get("NOPERMISSION-LIST").send(sender);
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("inv")) {
|
||||
if (sender.hasPermission("taboolib.admin")) {
|
||||
new TLMInvCommand(sender, args);
|
||||
} else {
|
||||
TLM.getInst().getLanguage().get("NOPERMISSION-INV").send(sender);
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("kit")) {
|
||||
new TLMKitCommand(sender, args);
|
||||
}
|
||||
|
||||
else {
|
||||
TLM.getInst().getLanguage().get("COMMAND-ERROR").send(sender);
|
||||
}
|
||||
|
202
src/main/src/me/skymc/tlm/command/sub/TLMInvCommand.java
Normal file
202
src/main/src/me/skymc/tlm/command/sub/TLMInvCommand.java
Normal file
@ -0,0 +1,202 @@
|
||||
package me.skymc.tlm.command.sub;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.commands.SubCommand;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.tlm.TLM;
|
||||
import me.skymc.tlm.inventory.TLMInventoryHolder;
|
||||
import me.skymc.tlm.module.TabooLibraryModule;
|
||||
import me.skymc.tlm.module.sub.ModuleInventorySave;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月18日 下午2:53:58
|
||||
*/
|
||||
public class TLMInvCommand extends SubCommand {
|
||||
|
||||
/**
|
||||
* @param sender
|
||||
* @param args
|
||||
*/
|
||||
public TLMInvCommand(CommandSender sender, String[] args) {
|
||||
super(sender, args);
|
||||
if (TabooLibraryModule.getInst().valueOf("InventorySave") == null) {
|
||||
TLM.getInst().getLanguage().get("INV-DISABLE").send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取模块
|
||||
ModuleInventorySave moduleInventorySave = (ModuleInventorySave) TabooLibraryModule.getInst().valueOf("InventorySave");
|
||||
|
||||
// 判断命令
|
||||
if (args.length == 1) {
|
||||
TLM.getInst().getLanguage().get("INV-EMPTY").send(sender);
|
||||
}
|
||||
|
||||
// 列出背包
|
||||
else if (args[1].equalsIgnoreCase("list")) {
|
||||
TLM.getInst().getLanguage().get("INV-LIST").addPlaceholder("$name", moduleInventorySave.getInventorys().toString()).send(sender);
|
||||
}
|
||||
|
||||
// 查看背包
|
||||
else if (args[1].equalsIgnoreCase("info")) {
|
||||
// 如果是后台
|
||||
if (!(sender instanceof Player)) {
|
||||
TLM.getInst().getLanguage().get("INV-CONSOLE").send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 判断长度
|
||||
if (args.length < 3) {
|
||||
TLM.getInst().getLanguage().get("INV-NAME").send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 判断背包
|
||||
if (!moduleInventorySave.getInventorys().contains(args[2])) {
|
||||
TLM.getInst().getLanguage().get("INV-NOTFOUND").addPlaceholder("$name", args[2]).send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取玩家
|
||||
Player player = (Player) sender;
|
||||
|
||||
// 获取物品
|
||||
List<ItemStack> items = moduleInventorySave.getItems(args[2]);
|
||||
|
||||
// 打开界面
|
||||
Inventory inv = Bukkit.createInventory(new TLMInventoryHolder("InventorySave"), 54, TLM.getInst().getLanguage().get("INV-INFO-TITLE")
|
||||
.addPlaceholder("$name", args[2])
|
||||
.asString());
|
||||
|
||||
// 设置物品
|
||||
ItemStack barrier = ItemUtils.setName(new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15), "§f");
|
||||
|
||||
for (int i = 9 ; i < 18 ; i++) {
|
||||
inv.setItem(i, barrier);
|
||||
}
|
||||
|
||||
for (int i = 9 ; i < 35 ; i++) {
|
||||
inv.setItem(i + 9, items.get(i));
|
||||
}
|
||||
|
||||
for (int i = 0 ; i < 9 ; i++) {
|
||||
inv.setItem(i + 45, items.get(i));
|
||||
}
|
||||
|
||||
inv.setItem(1, items.get(39));
|
||||
inv.setItem(2, items.get(38));
|
||||
inv.setItem(3, items.get(37));
|
||||
inv.setItem(4, items.get(36));
|
||||
|
||||
// 判断版本
|
||||
if (items.size() == 41) {
|
||||
inv.setItem(6, items.get(40));
|
||||
}
|
||||
|
||||
// 打开背包
|
||||
player.openInventory(inv);
|
||||
}
|
||||
|
||||
// 保存背包
|
||||
else if (args[1].equalsIgnoreCase("save")) {
|
||||
// 如果是后台
|
||||
if (!(sender instanceof Player)) {
|
||||
TLM.getInst().getLanguage().get("INV-CONSOLE").send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 判断长度
|
||||
if (args.length < 3) {
|
||||
TLM.getInst().getLanguage().get("INV-NAME").send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取玩家
|
||||
Player player = (Player) sender;
|
||||
|
||||
// 保存背包
|
||||
moduleInventorySave.saveInventory(player, args[2]);
|
||||
|
||||
// 提示信息
|
||||
TLM.getInst().getLanguage().get("INV-SAVE").addPlaceholder("$name", args[2]).send(player);
|
||||
}
|
||||
|
||||
// 覆盖背包
|
||||
else if (args[1].equalsIgnoreCase("paste")) {
|
||||
// 判断长度
|
||||
if (args.length < 3) {
|
||||
TLM.getInst().getLanguage().get("INV-NAME").send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 判断背包
|
||||
if (!moduleInventorySave.getInventorys().contains(args[2])) {
|
||||
TLM.getInst().getLanguage().get("INV-NOTFOUND").addPlaceholder("$name", args[2]).send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取玩家
|
||||
Player player;
|
||||
if (args.length > 3) {
|
||||
player = Bukkit.getPlayerExact(args[3]);
|
||||
// 玩家不存在
|
||||
if (player == null) {
|
||||
TLM.getInst().getLanguage().get("INV-OFFLINE").addPlaceholder("$name", args[3]).send(sender);
|
||||
return;
|
||||
}
|
||||
} else if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
} else {
|
||||
TLM.getInst().getLanguage().get("INV-CONSOLE").send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 覆盖背包
|
||||
moduleInventorySave.pasteInventory(player, args[2]);
|
||||
|
||||
// 如果是玩家
|
||||
if (sender instanceof Player) {
|
||||
// 提示信息
|
||||
TLM.getInst().getLanguage().get("INV-PASTE")
|
||||
.addPlaceholder("$name", args[2])
|
||||
.addPlaceholder("$player", player.getName())
|
||||
.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除背包
|
||||
else if (args[1].equalsIgnoreCase("delete")) {
|
||||
// 判断长度
|
||||
if (args.length < 3) {
|
||||
TLM.getInst().getLanguage().get("INV-NAME").send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 判断背包
|
||||
if (!moduleInventorySave.getInventorys().contains(args[2])) {
|
||||
TLM.getInst().getLanguage().get("INV-NOTFOUND").addPlaceholder("$name", args[2]).send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// 删除
|
||||
moduleInventorySave.deleteInventory(args[2]);
|
||||
|
||||
// 提示信息
|
||||
TLM.getInst().getLanguage().get("KIT-DELETE").addPlaceholder("$name", args[2]).send(sender);
|
||||
}
|
||||
|
||||
else {
|
||||
TLM.getInst().getLanguage().get("INV-EMPTY").send(sender);
|
||||
}
|
||||
}
|
||||
}
|
@ -39,6 +39,19 @@ public class TLMKitCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
else if (args[1].equalsIgnoreCase("list")) {
|
||||
// ÅжÏȨÏÞ
|
||||
if (!sender.hasPermission("taboolib.kit.list")) {
|
||||
TLM.getInst().getLanguage().get("NOPERMISSION-KIT-LIST").send(sender);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
TLM.getInst().getLanguage().get("KIT-LIST")
|
||||
.addPlaceholder("$kits", moduleKits.getConfig().getConfigurationSection("Kits").getKeys(false).toString())
|
||||
.send(sender);
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[1].equalsIgnoreCase("reward")) {
|
||||
// ÅжÏȨÏÞ
|
||||
if (!sender.hasPermission("taboolib.kit.reward")) {
|
||||
@ -108,6 +121,11 @@ public class TLMKitCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
// Ö´ÐÐÃüÁî
|
||||
for (String command : moduleKits.getCommands(args[2])) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("$player", player.getName()));
|
||||
}
|
||||
|
||||
// ÒÑÁìÈ¡
|
||||
moduleKits.setPlayerReward(player, args[2], true);
|
||||
|
||||
|
30
src/main/src/me/skymc/tlm/inventory/TLMInventoryHolder.java
Normal file
30
src/main/src/me/skymc/tlm/inventory/TLMInventoryHolder.java
Normal file
@ -0,0 +1,30 @@
|
||||
package me.skymc.tlm.inventory;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018Äê2ÔÂ22ÈÕ ÏÂÎç3:34:59
|
||||
*/
|
||||
public class TLMInventoryHolder implements InventoryHolder {
|
||||
|
||||
@Getter
|
||||
private String module;
|
||||
|
||||
@Getter
|
||||
private HashMap<String, Object> holderData = new HashMap<>();
|
||||
|
||||
public TLMInventoryHolder(String module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.tlm.annotation.DisableConfig;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
@ -60,7 +61,7 @@ public class TabooLibraryModule {
|
||||
}
|
||||
|
||||
public void reloadConfig(ITabooLibraryModule module, boolean isReload) {
|
||||
if (module.getName() == null) {
|
||||
if (module.getName() == null || module.getClass().getAnnotation(DisableConfig.class) != null) {
|
||||
return;
|
||||
}
|
||||
File file = new File(Main.getInst().getDataFolder(), "TLM/" + module.getName() + ".yml");
|
||||
|
@ -0,0 +1,56 @@
|
||||
package me.skymc.tlm.module.sub;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
import me.skymc.tlm.module.ITabooLibraryModule;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月22日 下午1:32:29
|
||||
*/
|
||||
public class ModuleCommandChanger implements ITabooLibraryModule, Listener {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CommandChanger";
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void command(PlayerCommandPreprocessEvent e) {
|
||||
// 循环命令
|
||||
for (String id : getConfig().getConfigurationSection("Commands").getKeys(false)) {
|
||||
// 获取命令
|
||||
String key = getConfig().getString("Commands." + id + ".Input");
|
||||
// 判断命令
|
||||
if (e.getMessage().startsWith(key)) {
|
||||
// 判断执行方式
|
||||
if (!getConfig().contains("Commands." + id + ".ReplaceMode") || getConfig().getString("Commands." + id + ".ReplaceMode").equals("PLAYER")) {
|
||||
// 替换命令
|
||||
e.setMessage(e.getMessage().replace(key, getConfig().getString("Commands." + id + ".Replace")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void command(ServerCommandEvent e) {
|
||||
// 循环命令
|
||||
for (String id : getConfig().getConfigurationSection("Commands").getKeys(false)) {
|
||||
// 获取命令
|
||||
String key = getConfig().getString("Commands." + id + ".Input");
|
||||
// 判断命令
|
||||
if (e.getCommand().startsWith(key)) {
|
||||
// 判断执行方式
|
||||
if (!getConfig().contains("Commands." + id + ".ReplaceMode") || getConfig().getString("Commands." + id + ".ReplaceMode").equals("CONSOLE")) {
|
||||
// 替换命令
|
||||
e.setCommand(e.getCommand().replace(key, getConfig().getString("Commands." + id + ".Replace")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
155
src/main/src/me/skymc/tlm/module/sub/ModuleInventorySave.java
Normal file
155
src/main/src/me/skymc/tlm/module/sub/ModuleInventorySave.java
Normal file
@ -0,0 +1,155 @@
|
||||
package me.skymc.tlm.module.sub;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import me.skymc.taboolib.playerdata.DataUtils;
|
||||
import me.skymc.tlm.annotation.DisableConfig;
|
||||
import me.skymc.tlm.inventory.TLMInventoryHolder;
|
||||
import me.skymc.tlm.module.ITabooLibraryModule;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月22日 下午2:48:27
|
||||
*/
|
||||
@DisableConfig
|
||||
public class ModuleInventorySave implements ITabooLibraryModule, Listener {
|
||||
|
||||
private FileConfiguration conf;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "InventorySave";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReload() {
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
conf = DataUtils.addPluginData("InventorySave", Main.getInst());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存玩家背包
|
||||
*
|
||||
* @param player 玩家
|
||||
* @param name 名称
|
||||
*/
|
||||
public void saveInventory(Player player, String name) {
|
||||
// 设置物品
|
||||
for (int i = 0 ; i < (TabooLib.getVerint() > 10800 ? 41 : 40) ; i++) {
|
||||
ItemStack item = player.getInventory().getItem(i);
|
||||
conf.set(name + "." + i, item == null ? new ItemStack(Material.AIR) : item.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖玩家背包
|
||||
*
|
||||
* @param player 玩家
|
||||
* @param name 名称
|
||||
*/
|
||||
public void pasteInventory(Player player, String name) {
|
||||
// 如果背包不存在
|
||||
if (!conf.contains(name)) {
|
||||
MsgUtils.warn("模块执行异常: &4背包不存在");
|
||||
MsgUtils.warn("模块: &4InventorySave");
|
||||
MsgUtils.warn("位于: &4" + name);
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置物品
|
||||
for (int i = 0 ; i < (TabooLib.getVerint() > 10800 ? 41 : 40) ; i++) {
|
||||
try {
|
||||
ItemStack item = (ItemStack) conf.get(name + "." + i);
|
||||
player.getInventory().setItem(i, item);
|
||||
}
|
||||
catch (Exception e) {
|
||||
MsgUtils.warn("模块执行异常: &4物品覆盖出错");
|
||||
MsgUtils.warn("模块: &4InventorySave");
|
||||
MsgUtils.warn("位于: &4" + name + ":" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取背包内所有物品
|
||||
*
|
||||
* @param name 背包名称
|
||||
* @return {@link List}
|
||||
*/
|
||||
public List<ItemStack> getItems(String name) {
|
||||
// 如果背包不存在
|
||||
if (!conf.contains(name)) {
|
||||
MsgUtils.warn("模块执行异常: &4背包不存在");
|
||||
MsgUtils.warn("模块: &4InventorySave");
|
||||
MsgUtils.warn("位于: &4" + name);
|
||||
return new LinkedList<>();
|
||||
}
|
||||
|
||||
List<ItemStack> items = new LinkedList<>();
|
||||
// 设置物品
|
||||
for (int i = 0 ; i < (TabooLib.getVerint() > 10800 ? 41 : 40) ; i++) {
|
||||
try {
|
||||
ItemStack item = (ItemStack) conf.get(name + "." + i);
|
||||
items.add(item);
|
||||
}
|
||||
catch (Exception e) {
|
||||
MsgUtils.warn("模块执行异常: &4物品获取出错");
|
||||
MsgUtils.warn("模块: &4InventorySave");
|
||||
MsgUtils.warn("位于: &4" + name + ":" + i);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有背包
|
||||
*
|
||||
* @return {@link Set}
|
||||
*/
|
||||
public Set<String> getInventorys() {
|
||||
return conf.getConfigurationSection("").getKeys(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除背包
|
||||
*
|
||||
* @param name 名称
|
||||
*/
|
||||
public void deleteInventory(String name) {
|
||||
conf.set(name, null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
if (!(e.getInventory().getHolder() instanceof TLMInventoryHolder)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TLMInventoryHolder holder = (TLMInventoryHolder) e.getInventory().getHolder();
|
||||
if (holder.getModule().equals(getName())) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.skymc.taboolib.database.PlayerDataManager;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
@ -157,4 +158,14 @@ public class ModuleKits implements ITabooLibraryModule {
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取礼包命令
|
||||
*
|
||||
* @param kit 礼包名
|
||||
* @return {@link List}
|
||||
*/
|
||||
public List<String> getCommands(String kit) {
|
||||
return getConfig().contains("Kits." + kit + ".Commands") ? getConfig().getStringList("Kits." + kit + ".Commands") : new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
COMMAND-ERROR: '&8[&2&lTLM&8] &4指令错误'
|
||||
COMMAND-ERROR: '&8[&3&lTLM&8] &4指令错误'
|
||||
COMMAND-HELP:
|
||||
- ''
|
||||
- '&b&l----- &3&lTaooLibraryModule Commands &b&l-----'
|
||||
@ -6,32 +6,54 @@ COMMAND-HELP:
|
||||
- '&f /tlm kit reward &8[&7名称] &8<&7名称&8> &6- &e领取礼包'
|
||||
- '&f /tlm kit reset &8[&7名称] &8<&7玩家&8> &6- &e刷新礼包'
|
||||
- ''
|
||||
- '&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 delete &8[&7名称] &6- &e删除保存背包'
|
||||
- ''
|
||||
- '&f /tlm list &6- &e列出所有模块'
|
||||
- ''
|
||||
- '&f /tlm reload &8[&7模块名|TLM|ALL&8] &6- &e列出所有模块'
|
||||
- ''
|
||||
|
||||
NOPERMISSION-HELP: '&8[&2&lTLM&8] &4你没有权限列出帮助命令'
|
||||
NOPERMISSION-LIST: '&8[&2&lTLM&8] &4你没有权限这么做'
|
||||
NOPERMISSION-RELOAD: '&8[&2&lTLM&8] &4你没有权限这么做'
|
||||
NOPERMISSION-KIT-REWARD: '&8[&2&lTLM&8] &4你没有权限这么做'
|
||||
NOPERMISSION-KIT-RESET: '&8[&2&lTLM&8] &4你没有权限这么做'
|
||||
# 3.58 增加
|
||||
NOPERMISSION-HELP: '&8[&3&lTLM&8] &4你没有权限列出帮助命令'
|
||||
NOPERMISSION-LIST: '&8[&3&lTLM&8] &4你没有权限这么做'
|
||||
NOPERMISSION-RELOAD: '&8[&3&lTLM&8] &4你没有权限这么做'
|
||||
NOPERMISSION-KIT-REWARD: '&8[&3&lTLM&8] &4你没有权限这么做'
|
||||
NOPERMISSION-KIT-RESET: '&8[&3&lTLM&8] &4你没有权限这么做'
|
||||
NOPERMISSION-INV: '&8[&3&lTLM&8] &4你没有权限这么做'
|
||||
|
||||
KIT-EMPTY: '&8[&2&lTLM&8] &4参数错误'
|
||||
KIT-NAME: '&8[&2&lTLM&8] &4请输入正确的礼包名称'
|
||||
KIT-DISABLE: '&8[&2&lTLM&8] &4该模块尚未在配置文件中启用'
|
||||
KIT-NOTFOUND: '&8[&2&lTLM&8] &4礼包 &c$kit &4不存在'
|
||||
KIT-OFFLINE: '&8[&2&lTLM&8] &4玩家 &c$name &4不在线'
|
||||
KIT-CONSOLE: '&8[&2&lTLM&8] &4后台不允许输入这个指令'
|
||||
KIT-COOLDOWN: '&8[&2&lTLM&8] &4礼包 &c$kit &4正在冷却中'
|
||||
KIT-DISPOSABLE: '&8[&2&lTLM&8] &4礼包 &c$kit &4只能领取一次'
|
||||
KIT-RESET-ALL: '&8[&2&lTLM&8] &7礼包 &f$kit &7已刷新'
|
||||
KIT-RESET-PLAYER: '&8[&2&lTLM&8] &7玩家 &f$player &7的礼包 &f$kit &7已刷新'
|
||||
KIT-SUCCESS: '&8[&2&lTLM&8] &7礼包 &f$kit &7已领取'
|
||||
# 3.59 增加
|
||||
KIT-EMPTY: '&8[&3&lTLM&8] &4参数错误'
|
||||
KIT-NAME: '&8[&3&lTLM&8] &4请输入正确的礼包名称'
|
||||
KIT-DISABLE: '&8[&3&lTLM&8] &4该模块尚未在配置文件中启用'
|
||||
KIT-NOTFOUND: '&8[&3&lTLM&8] &4礼包 &c$kit &4不存在'
|
||||
KIT-OFFLINE: '&8[&3&lTLM&8] &4玩家 &c$name &4不在线'
|
||||
KIT-CONSOLE: '&8[&3&lTLM&8] &4后台不允许输入这个指令'
|
||||
KIT-COOLDOWN: '&8[&3&lTLM&8] &4礼包 &c$kit &4正在冷却中'
|
||||
KIT-DISPOSABLE: '&8[&3&lTLM&8] &4礼包 &c$kit &4只能领取一次'
|
||||
KIT-RESET-ALL: '&8[&3&lTLM&8] &7礼包 &f$kit &7已刷新'
|
||||
KIT-RESET-PLAYER: '&8[&3&lTLM&8] &7玩家 &f$player &7的礼包 &f$kit &7已刷新'
|
||||
KIT-SUCCESS: '&8[&3&lTLM&8] &7礼包 &f$kit &7已领取'
|
||||
KIT-PLACEHOLDER:
|
||||
0: '&4模块未启用'
|
||||
1: '&4礼包不存在'
|
||||
2: '&8已领取'
|
||||
3: '&a可领取'
|
||||
4: '&4冷却中'
|
||||
5: '&4无权限'
|
||||
5: '&4无权限'
|
||||
|
||||
# 3.60 增加
|
||||
INV-EMPTY: '&8[&3&lTLM&8] &4参数错误'
|
||||
INV-DISABLE: '&8[&3&lTLM&8] &4该模块尚未在配置文件中启用'
|
||||
INV-CONSOLE: '&8[&3&lTLM&8] &4该命令不允许控制台执行'
|
||||
INV-NAME: '&8[&3&lTLM&8] &4请输入正确的背包名称'
|
||||
INV-LIST: '&8[&3&lTLM&8] &7当前已保存背包: &f$name'
|
||||
INV-NOTFOUND: '&8[&3&lTLM&8] &4背包 &c$name &4不存在'
|
||||
INV-INFO-TITLE: '背包信息: $name'
|
||||
INV-SAVE: '&8[&3&lTLM&8] &7背包 &f$name &7已保存!'
|
||||
INV-OFFLINE: '&8[&3&lTLM&8] &4玩家 &c$name &4不在线'
|
||||
INV-PASTE: '&8[&3&lTLM&8] &7背包 &f$name &7已覆盖到玩家 &f$player&7!'
|
||||
INV-DELETE: '&8[&3&lTLM&8] &4背包 &c$name &4已删除'
|
14
src/resources/TLM/CommandChanger.yml
Normal file
14
src/resources/TLM/CommandChanger.yml
Normal file
@ -0,0 +1,14 @@
|
||||
# 指令配置
|
||||
Commands:
|
||||
# 配置序号(不可重复)
|
||||
test:
|
||||
# 输入命令
|
||||
Input: '/kit'
|
||||
# 替换命令
|
||||
Replace: '/tlm kit'
|
||||
# 替换模式(省略默认全部)
|
||||
# ---------- #
|
||||
# CONSOLE = 后台
|
||||
# PLAYER = 玩家
|
||||
# ---------- #
|
||||
ReplaceMode: 'PLAYER'
|
@ -27,4 +27,8 @@ Kits:
|
||||
# 礼包内容
|
||||
# 空格左侧为物品名,右侧为物品数量
|
||||
Items:
|
||||
- 'UnlimitSword 1'
|
||||
- 'UnlimitSword 1'
|
||||
|
||||
# 礼包命令
|
||||
Commands:
|
||||
- 'say $player 领取了礼包 kit_name!'
|
Loading…
Reference in New Issue
Block a user