-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
调整:命令 /lang2 提示调整 调整:命令 /tlib 提示改为 JSON 形式 调整:命令 /tlm 需要独立的权限才能列出帮助,子命令的执行不需要列出帮助的权限 新增:命令 /taboo cycle list 列出所有已注册的时间周期 新增:命令 /taboo cycle info 查询已注册的时间周期 新增:命令 /taboo cycle reset 初始化已注册的时间周期 新增:命令 /taboo cycle update 更新已注册的时间周期 新增:Language2 工具新增 send(CommandSender) 方法 新增:PlaceholderAPI 变量 %taboolib_tlm_kit_礼包名% 用于获取礼包状态 新增:TLM 框架新增 Kits 模块,用于管理礼包的发放 新增:命令 /tlm kit reward 领取礼包 新增:命令 /tlm kit reset 刷新礼包 新增:TLM 框架新增语言文件 "language2/zh_CN.yml"
- Loading branch information
Showing
21 changed files
with
906 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/src/me/skymc/taboolib/commands/sub/HelpCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package me.skymc.taboolib.commands.sub; | ||
|
||
import java.util.HashMap; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map.Entry; | ||
|
||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.ConsoleCommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemFlag; | ||
|
||
import me.skymc.taboolib.TabooLib; | ||
import me.skymc.taboolib.commands.SubCommand; | ||
import me.skymc.taboolib.jsonformatter.JSONFormatter; | ||
import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent; | ||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent; | ||
|
||
public class HelpCommand extends SubCommand { | ||
|
||
public HelpCommand(CommandSender sender, String[] args) { | ||
super(sender, args); | ||
|
||
HashMap<String, String> helps = new LinkedHashMap<>(); | ||
helps.put("/taboolib save §8[§7名称§8]", "§e保存手中物品"); | ||
helps.put("/taboolib item §8[§7名称§8] §8<§7玩家§8> §8<§7数量§8>", "§e给予玩家物品"); | ||
helps.put("/taboolib iteminfo", "§e查看物品信息"); | ||
helps.put("/taboolib itemlist", "§e查看所有物品"); | ||
helps.put("/taboolib itemreload", "§e重载物品缓存"); | ||
helps.put("§a", null); | ||
helps.put("/taboolib attributes", "§e查看所有属性"); | ||
helps.put("/taboolib enchants", "§e查看所有附魔"); | ||
helps.put("/taboolib potions", "§e查看所有药水"); | ||
helps.put("/taboolib flags", "§e查看所有标签"); | ||
helps.put("/taboolib slots", "§e查看所有部位"); | ||
helps.put("§b", null); | ||
helps.put("/taboolib getvariable §8[§7-s|a§8] §8[§7键§8]", "§e查看变量"); | ||
helps.put("/taboolib setvariable §8[§7-s|a§8] §8[§7键§8] §8[§7值§8]", "§e更改变量"); | ||
helps.put("§c", null); | ||
helps.put("/taboolib cycle list", "§e列出所有时间检查器"); | ||
helps.put("/taboolib cycle info §8[§7名称§8]", "§e查询检查器信息"); | ||
helps.put("/taboolib cycle reset §8[§7名称§8]", "§e初始化时间检查器"); | ||
helps.put("/taboolib cycle update §8[§7名称§8]", "§e更新时间检查器"); | ||
helps.put("§d", null); | ||
helps.put("/taboolib shell load §8[§7名称§8]", "§e载入某个脚本"); | ||
helps.put("/taboolib shell unload §8[§7名称§8]", "§e卸载某个脚本"); | ||
helps.put("§e", null); | ||
helps.put("/taboolib importdata", "§4向数据库导入本地数据 §8(该操作将会清空数据库)"); | ||
|
||
if (sender instanceof ConsoleCommandSender || TabooLib.getVerint() < 10800) { | ||
sender.sendMessage("§f"); | ||
sender.sendMessage("§b§l----- §3§lTaooLib Commands §b§l-----"); | ||
sender.sendMessage("§f"); | ||
// 遍历命令 | ||
for (Entry<String, String> entry : helps.entrySet()) { | ||
if (entry.getValue() == null) { | ||
sender.sendMessage("§f"); | ||
} else { | ||
sender.sendMessage("§f " + entry.getKey() + " §6- " + entry.getValue()); | ||
} | ||
} | ||
sender.sendMessage("§f"); | ||
} | ||
else if (sender instanceof Player) { | ||
JSONFormatter json = new JSONFormatter(); | ||
json.append("§f"); json.newLine(); | ||
json.append("§b§l----- §3§lTaooLib Commands §b§l-----"); json.newLine(); | ||
json.append("§f"); json.newLine(); | ||
// 遍历命令 | ||
for (Entry<String, String> entry : helps.entrySet()) { | ||
if (entry.getValue() == null) { | ||
json.append("§f"); json.newLine(); | ||
} else { | ||
json.appendHoverClick("§f " + entry.getKey() + " §6- " + entry.getValue(), new ShowTextEvent("§f点击复制指令"), new SuggestCommandEvent(entry.getKey().split("§")[0])); json.newLine(); | ||
} | ||
} | ||
json.append("§f"); | ||
json.send((Player) sender); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/src/me/skymc/taboolib/commands/sub/cycle/CycleCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package me.skymc.taboolib.commands.sub.cycle; | ||
|
||
import java.io.File; | ||
|
||
import org.bukkit.command.CommandSender; | ||
|
||
import me.skymc.taboolib.commands.SubCommand; | ||
import me.skymc.taboolib.javashell.JavaShell; | ||
import me.skymc.taboolib.message.MsgUtils; | ||
|
||
public class CycleCommand extends SubCommand { | ||
|
||
public CycleCommand(CommandSender sender, String[] args) { | ||
super(sender, args); | ||
if (args.length > 1) { | ||
if (args[1].equalsIgnoreCase("list")) { | ||
new CycleListCommand(sender, args); | ||
} | ||
else if (args[1].equalsIgnoreCase("info")) { | ||
new CycleInfoCommand(sender, args); | ||
} | ||
else if (args[1].equalsIgnoreCase("reset")) { | ||
new CycleResetCommand(sender, args); | ||
} | ||
else if (args[1].equalsIgnoreCase("update")) { | ||
new CycleUpdateCommand(sender, args); | ||
} | ||
} | ||
else { | ||
MsgUtils.send(sender, "&4Ö¸Áî´íÎó"); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean command() { | ||
return true; | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
src/main/src/me/skymc/taboolib/commands/sub/cycle/CycleInfoCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package me.skymc.taboolib.commands.sub.cycle; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
|
||
import me.skymc.taboolib.Main; | ||
import me.skymc.taboolib.commands.SubCommand; | ||
import me.skymc.taboolib.database.GlobalDataManager; | ||
import me.skymc.taboolib.message.MsgUtils; | ||
import me.skymc.taboolib.other.DateUtils; | ||
import me.skymc.taboolib.timecycle.TimeCycle; | ||
import me.skymc.taboolib.timecycle.TimeCycleEvent; | ||
import me.skymc.taboolib.timecycle.TimeCycleInitializeEvent; | ||
import me.skymc.taboolib.timecycle.TimeCycleManager; | ||
|
||
public class CycleInfoCommand extends SubCommand { | ||
|
||
public CycleInfoCommand(CommandSender sender, String[] args) { | ||
super(sender, args); | ||
if (args.length < 3) { | ||
MsgUtils.send(sender, "&c请输入正确的检查器名称"); | ||
return; | ||
} | ||
|
||
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]); | ||
if (cycle == null) { | ||
MsgUtils.send(sender, "&c检查器 &4" + args[2] + " &c不存在"); | ||
return; | ||
} | ||
|
||
sender.sendMessage("§f"); | ||
sender.sendMessage("§b§l----- §3§lTimeCycle Info §b§l-----"); | ||
sender.sendMessage("§f"); | ||
sender.sendMessage(" §f- §7注册周期: §f" + asString(cycle.getCycle() / 1000L)); | ||
sender.sendMessage(" §f- §7注册插件: §f" + cycle.getPlugin().getName()); | ||
sender.sendMessage("§f"); | ||
sender.sendMessage(" §f- §7上次刷新时间: §f" + DateUtils.CH_ALL.format(TimeCycleManager.getBeforeTimeline(cycle.getName()))); | ||
sender.sendMessage(" §f- §7下次刷新时间: §f" + DateUtils.CH_ALL.format(TimeCycleManager.getAfterTimeline(cycle.getName()))); | ||
sender.sendMessage("§f"); | ||
} | ||
|
||
public String asString(long seconds) { | ||
long day = TimeUnit.SECONDS.toDays(seconds); | ||
long hours = TimeUnit.SECONDS.toHours(seconds) - day * 24; | ||
long minute = TimeUnit.SECONDS.toMinutes(seconds) - TimeUnit.SECONDS.toHours(seconds) * 60L; | ||
long second = TimeUnit.SECONDS.toSeconds(seconds) - TimeUnit.SECONDS.toMinutes(seconds) * 60L; | ||
return "§f" + day + "§7 天, §f" + hours + "§7 小时, §f" + minute + "§7 分钟, §f" + second + "§7 秒"; | ||
} | ||
|
||
@Override | ||
public boolean command() { | ||
return true; | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
src/main/src/me/skymc/taboolib/commands/sub/cycle/CycleListCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package me.skymc.taboolib.commands.sub.cycle; | ||
|
||
import java.io.File; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import me.skymc.taboolib.commands.SubCommand; | ||
import me.skymc.taboolib.javashell.JavaShell; | ||
import me.skymc.taboolib.jsonformatter.JSONFormatter; | ||
import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent; | ||
import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent; | ||
import me.skymc.taboolib.message.MsgUtils; | ||
import me.skymc.taboolib.timecycle.TimeCycle; | ||
import me.skymc.taboolib.timecycle.TimeCycleManager; | ||
|
||
public class CycleListCommand extends SubCommand { | ||
|
||
public CycleListCommand(CommandSender sender, String[] args) { | ||
super(sender, args); | ||
|
||
sender.sendMessage("§f"); | ||
sender.sendMessage("§b§l----- §3§lTimeCycle List §b§l-----"); | ||
sender.sendMessage("§f"); | ||
|
||
for (TimeCycle cycle : TimeCycleManager.getTimeCycles()) { | ||
if (isPlayer()) { | ||
JSONFormatter json = new JSONFormatter(); | ||
json.append(" §7- §f" + cycle.getName()); | ||
json.appendHoverClick(" §8(点击复制)", new ShowTextEvent("§f点击复制"), new SuggestCommandEvent(cycle.getName())); | ||
json.send((Player) sender); | ||
} | ||
else { | ||
sender.sendMessage(" §7- §f" + cycle.getName()); | ||
} | ||
} | ||
|
||
sender.sendMessage("§f"); | ||
} | ||
|
||
@Override | ||
public boolean command() { | ||
return true; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
src/main/src/me/skymc/taboolib/commands/sub/cycle/CycleResetCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package me.skymc.taboolib.commands.sub.cycle; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
|
||
import me.skymc.taboolib.Main; | ||
import me.skymc.taboolib.commands.SubCommand; | ||
import me.skymc.taboolib.database.GlobalDataManager; | ||
import me.skymc.taboolib.message.MsgUtils; | ||
import me.skymc.taboolib.timecycle.TimeCycle; | ||
import me.skymc.taboolib.timecycle.TimeCycleEvent; | ||
import me.skymc.taboolib.timecycle.TimeCycleInitializeEvent; | ||
import me.skymc.taboolib.timecycle.TimeCycleManager; | ||
|
||
public class CycleResetCommand extends SubCommand { | ||
|
||
public CycleResetCommand(CommandSender sender, String[] args) { | ||
super(sender, args); | ||
if (args.length < 3) { | ||
MsgUtils.send(sender, "&c请输入正确的检查器名称"); | ||
return; | ||
} | ||
|
||
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]); | ||
if (cycle == null) { | ||
MsgUtils.send(sender, "&c检查器 &4" + args[2] + " &c不存在"); | ||
return; | ||
} | ||
|
||
new BukkitRunnable() { | ||
|
||
@Override | ||
public void run() { | ||
long time = new TimeCycleInitializeEvent(cycle, System.currentTimeMillis()).call().getTimeline(); | ||
// 初始化 | ||
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(time)); | ||
// 触发器 | ||
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle)); | ||
// 提示 | ||
MsgUtils.send(sender, "检查器 &f" + args[2] + " &7初始化完成"); | ||
} | ||
}.runTaskAsynchronously(Main.getInst()); | ||
} | ||
|
||
@Override | ||
public boolean command() { | ||
return true; | ||
} | ||
|
||
} |
Oops, something went wrong.