Skip to content

Commit e89e8b8

Browse files
committed
版本更新至 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 命令,用于删除已保存的背包
1 parent 6f01452 commit e89e8b8

File tree

13 files changed

+571
-20
lines changed

13 files changed

+571
-20
lines changed

src/main/src/me/skymc/tlm/TLM.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import me.skymc.taboolib.message.MsgUtils;
1010
import me.skymc.taboolib.string.language2.Language2;
1111
import me.skymc.tlm.module.TabooLibraryModule;
12+
import me.skymc.tlm.module.sub.ModuleCommandChanger;
13+
import me.skymc.tlm.module.sub.ModuleInventorySave;
1214
import me.skymc.tlm.module.sub.ModuleKits;
1315
import me.skymc.tlm.module.sub.ModuleTimeCycle;
1416

@@ -40,6 +42,12 @@ private TLM() {
4042
if (isEnableModule("Kits")) {
4143
TabooLibraryModule.getInst().register(new ModuleKits());
4244
}
45+
if (isEnableModule("CommandChanger")) {
46+
TabooLibraryModule.getInst().register(new ModuleCommandChanger());
47+
}
48+
if (isEnableModule("InventorySave")) {
49+
TabooLibraryModule.getInst().register(new ModuleInventorySave());
50+
}
4351

4452
// 载入模块
4553
TabooLibraryModule.getInst().loadModules();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package me.skymc.tlm.annotation;
2+
3+
import static java.lang.annotation.ElementType.TYPE;
4+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
5+
6+
import java.lang.annotation.Retention;
7+
import java.lang.annotation.Target;
8+
9+
@Retention(RUNTIME)
10+
@Target(TYPE)
11+
/**
12+
* @author sky
13+
* @since 2018Äê2ÔÂ22ÈÕ ÏÂÎç3:59:30
14+
*/
15+
public @interface DisableConfig {
16+
17+
}

src/main/src/me/skymc/tlm/command/TLMCommands.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.bukkit.command.CommandSender;
66

77
import me.skymc.tlm.TLM;
8+
import me.skymc.tlm.command.sub.TLMInvCommand;
89
import me.skymc.tlm.command.sub.TLMKitCommand;
910
import me.skymc.tlm.command.sub.TLMListCommand;
1011
import me.skymc.tlm.command.sub.TLMReloadCommand;
@@ -24,23 +25,35 @@ public boolean onCommand(CommandSender sender, Command arg1, String arg2, String
2425
TLM.getInst().getLanguage().get("NOPERMISSION-HELP").send(sender);
2526
}
2627
}
28+
2729
else if (args[0].equalsIgnoreCase("reload")) {
2830
if (sender.hasPermission("taboolib.admin")) {
2931
new TLMReloadCommand(sender, args);
3032
} else {
3133
TLM.getInst().getLanguage().get("NOPERMISSION-RELOAD").send(sender);
3234
}
3335
}
36+
3437
else if (args[0].equalsIgnoreCase("list")) {
3538
if (sender.hasPermission("taboolib.admin")) {
3639
new TLMListCommand(sender, args);
3740
} else {
3841
TLM.getInst().getLanguage().get("NOPERMISSION-LIST").send(sender);
3942
}
4043
}
44+
45+
else if (args[0].equalsIgnoreCase("inv")) {
46+
if (sender.hasPermission("taboolib.admin")) {
47+
new TLMInvCommand(sender, args);
48+
} else {
49+
TLM.getInst().getLanguage().get("NOPERMISSION-INV").send(sender);
50+
}
51+
}
52+
4153
else if (args[0].equalsIgnoreCase("kit")) {
4254
new TLMKitCommand(sender, args);
4355
}
56+
4457
else {
4558
TLM.getInst().getLanguage().get("COMMAND-ERROR").send(sender);
4659
}
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
package me.skymc.tlm.command.sub;
2+
3+
4+
import java.util.List;
5+
6+
import org.bukkit.Bukkit;
7+
import org.bukkit.Material;
8+
import org.bukkit.command.CommandSender;
9+
import org.bukkit.entity.Player;
10+
import org.bukkit.inventory.Inventory;
11+
import org.bukkit.inventory.ItemStack;
12+
13+
import me.skymc.taboolib.commands.SubCommand;
14+
import me.skymc.taboolib.inventory.ItemUtils;
15+
import me.skymc.tlm.TLM;
16+
import me.skymc.tlm.inventory.TLMInventoryHolder;
17+
import me.skymc.tlm.module.TabooLibraryModule;
18+
import me.skymc.tlm.module.sub.ModuleInventorySave;
19+
20+
/**
21+
* @author sky
22+
* @since 2018年2月18日 下午2:53:58
23+
*/
24+
public class TLMInvCommand extends SubCommand {
25+
26+
/**
27+
* @param sender
28+
* @param args
29+
*/
30+
public TLMInvCommand(CommandSender sender, String[] args) {
31+
super(sender, args);
32+
if (TabooLibraryModule.getInst().valueOf("InventorySave") == null) {
33+
TLM.getInst().getLanguage().get("INV-DISABLE").send(sender);
34+
return;
35+
}
36+
37+
// 获取模块
38+
ModuleInventorySave moduleInventorySave = (ModuleInventorySave) TabooLibraryModule.getInst().valueOf("InventorySave");
39+
40+
// 判断命令
41+
if (args.length == 1) {
42+
TLM.getInst().getLanguage().get("INV-EMPTY").send(sender);
43+
}
44+
45+
// 列出背包
46+
else if (args[1].equalsIgnoreCase("list")) {
47+
TLM.getInst().getLanguage().get("INV-LIST").addPlaceholder("$name", moduleInventorySave.getInventorys().toString()).send(sender);
48+
}
49+
50+
// 查看背包
51+
else if (args[1].equalsIgnoreCase("info")) {
52+
// 如果是后台
53+
if (!(sender instanceof Player)) {
54+
TLM.getInst().getLanguage().get("INV-CONSOLE").send(sender);
55+
return;
56+
}
57+
58+
// 判断长度
59+
if (args.length < 3) {
60+
TLM.getInst().getLanguage().get("INV-NAME").send(sender);
61+
return;
62+
}
63+
64+
// 判断背包
65+
if (!moduleInventorySave.getInventorys().contains(args[2])) {
66+
TLM.getInst().getLanguage().get("INV-NOTFOUND").addPlaceholder("$name", args[2]).send(sender);
67+
return;
68+
}
69+
70+
// 获取玩家
71+
Player player = (Player) sender;
72+
73+
// 获取物品
74+
List<ItemStack> items = moduleInventorySave.getItems(args[2]);
75+
76+
// 打开界面
77+
Inventory inv = Bukkit.createInventory(new TLMInventoryHolder("InventorySave"), 54, TLM.getInst().getLanguage().get("INV-INFO-TITLE")
78+
.addPlaceholder("$name", args[2])
79+
.asString());
80+
81+
// 设置物品
82+
ItemStack barrier = ItemUtils.setName(new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15), "§f");
83+
84+
for (int i = 9 ; i < 18 ; i++) {
85+
inv.setItem(i, barrier);
86+
}
87+
88+
for (int i = 9 ; i < 35 ; i++) {
89+
inv.setItem(i + 9, items.get(i));
90+
}
91+
92+
for (int i = 0 ; i < 9 ; i++) {
93+
inv.setItem(i + 45, items.get(i));
94+
}
95+
96+
inv.setItem(1, items.get(39));
97+
inv.setItem(2, items.get(38));
98+
inv.setItem(3, items.get(37));
99+
inv.setItem(4, items.get(36));
100+
101+
// 判断版本
102+
if (items.size() == 41) {
103+
inv.setItem(6, items.get(40));
104+
}
105+
106+
// 打开背包
107+
player.openInventory(inv);
108+
}
109+
110+
// 保存背包
111+
else if (args[1].equalsIgnoreCase("save")) {
112+
// 如果是后台
113+
if (!(sender instanceof Player)) {
114+
TLM.getInst().getLanguage().get("INV-CONSOLE").send(sender);
115+
return;
116+
}
117+
118+
// 判断长度
119+
if (args.length < 3) {
120+
TLM.getInst().getLanguage().get("INV-NAME").send(sender);
121+
return;
122+
}
123+
124+
// 获取玩家
125+
Player player = (Player) sender;
126+
127+
// 保存背包
128+
moduleInventorySave.saveInventory(player, args[2]);
129+
130+
// 提示信息
131+
TLM.getInst().getLanguage().get("INV-SAVE").addPlaceholder("$name", args[2]).send(player);
132+
}
133+
134+
// 覆盖背包
135+
else if (args[1].equalsIgnoreCase("paste")) {
136+
// 判断长度
137+
if (args.length < 3) {
138+
TLM.getInst().getLanguage().get("INV-NAME").send(sender);
139+
return;
140+
}
141+
142+
// 判断背包
143+
if (!moduleInventorySave.getInventorys().contains(args[2])) {
144+
TLM.getInst().getLanguage().get("INV-NOTFOUND").addPlaceholder("$name", args[2]).send(sender);
145+
return;
146+
}
147+
148+
// 获取玩家
149+
Player player;
150+
if (args.length > 3) {
151+
player = Bukkit.getPlayerExact(args[3]);
152+
// 玩家不存在
153+
if (player == null) {
154+
TLM.getInst().getLanguage().get("INV-OFFLINE").addPlaceholder("$name", args[3]).send(sender);
155+
return;
156+
}
157+
} else if (sender instanceof Player) {
158+
player = (Player) sender;
159+
} else {
160+
TLM.getInst().getLanguage().get("INV-CONSOLE").send(sender);
161+
return;
162+
}
163+
164+
// 覆盖背包
165+
moduleInventorySave.pasteInventory(player, args[2]);
166+
167+
// 如果是玩家
168+
if (sender instanceof Player) {
169+
// 提示信息
170+
TLM.getInst().getLanguage().get("INV-PASTE")
171+
.addPlaceholder("$name", args[2])
172+
.addPlaceholder("$player", player.getName())
173+
.send(player);
174+
}
175+
}
176+
177+
// 删除背包
178+
else if (args[1].equalsIgnoreCase("delete")) {
179+
// 判断长度
180+
if (args.length < 3) {
181+
TLM.getInst().getLanguage().get("INV-NAME").send(sender);
182+
return;
183+
}
184+
185+
// 判断背包
186+
if (!moduleInventorySave.getInventorys().contains(args[2])) {
187+
TLM.getInst().getLanguage().get("INV-NOTFOUND").addPlaceholder("$name", args[2]).send(sender);
188+
return;
189+
}
190+
191+
// 删除
192+
moduleInventorySave.deleteInventory(args[2]);
193+
194+
// 提示信息
195+
TLM.getInst().getLanguage().get("KIT-DELETE").addPlaceholder("$name", args[2]).send(sender);
196+
}
197+
198+
else {
199+
TLM.getInst().getLanguage().get("INV-EMPTY").send(sender);
200+
}
201+
}
202+
}

src/main/src/me/skymc/tlm/command/sub/TLMKitCommand.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ public TLMKitCommand(CommandSender sender, String[] args) {
3939
return;
4040
}
4141

42+
else if (args[1].equalsIgnoreCase("list")) {
43+
// 判断权限
44+
if (!sender.hasPermission("taboolib.kit.list")) {
45+
TLM.getInst().getLanguage().get("NOPERMISSION-KIT-LIST").send(sender);
46+
return;
47+
}
48+
else {
49+
TLM.getInst().getLanguage().get("KIT-LIST")
50+
.addPlaceholder("$kits", moduleKits.getConfig().getConfigurationSection("Kits").getKeys(false).toString())
51+
.send(sender);
52+
}
53+
}
54+
4255
else if (args[1].equalsIgnoreCase("reward")) {
4356
// 判断权限
4457
if (!sender.hasPermission("taboolib.kit.reward")) {
@@ -108,6 +121,11 @@ else if (args[1].equalsIgnoreCase("reward")) {
108121
}
109122
}
110123

124+
// 执行命令
125+
for (String command : moduleKits.getCommands(args[2])) {
126+
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("$player", player.getName()));
127+
}
128+
111129
// 已领取
112130
moduleKits.setPlayerReward(player, args[2], true);
113131

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package me.skymc.tlm.inventory;
2+
3+
import java.util.HashMap;
4+
5+
import org.bukkit.inventory.Inventory;
6+
import org.bukkit.inventory.InventoryHolder;
7+
8+
import lombok.Getter;
9+
10+
/**
11+
* @author sky
12+
* @since 2018Äê2ÔÂ22ÈÕ ÏÂÎç3:34:59
13+
*/
14+
public class TLMInventoryHolder implements InventoryHolder {
15+
16+
@Getter
17+
private String module;
18+
19+
@Getter
20+
private HashMap<String, Object> holderData = new HashMap<>();
21+
22+
public TLMInventoryHolder(String module) {
23+
this.module = module;
24+
}
25+
26+
@Override
27+
public Inventory getInventory() {
28+
return null;
29+
}
30+
}

src/main/src/me/skymc/tlm/module/TabooLibraryModule.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.bukkit.event.Listener;
1111

1212
import me.skymc.taboolib.Main;
13+
import me.skymc.tlm.annotation.DisableConfig;
1314

1415
/**
1516
* @author sky
@@ -60,7 +61,7 @@ public void reloadConfig() {
6061
}
6162

6263
public void reloadConfig(ITabooLibraryModule module, boolean isReload) {
63-
if (module.getName() == null) {
64+
if (module.getName() == null || module.getClass().getAnnotation(DisableConfig.class) != null) {
6465
return;
6566
}
6667
File file = new File(Main.getInst().getDataFolder(), "TLM/" + module.getName() + ".yml");

0 commit comments

Comments
 (0)