Skip to content

Commit

Permalink
版本更新至 3.56
Browse files Browse the repository at this point in the history
调整:命令 /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
Bkm016 committed Feb 18, 2018
1 parent 9383439 commit 3df9dbd
Show file tree
Hide file tree
Showing 21 changed files with 906 additions and 71 deletions.
31 changes: 7 additions & 24 deletions src/main/src/me/skymc/taboolib/commands/MainCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import me.skymc.taboolib.commands.sub.AttributesCommand;
import me.skymc.taboolib.commands.sub.EnchantCommand;
import me.skymc.taboolib.commands.sub.FlagCommand;
import me.skymc.taboolib.commands.sub.HelpCommand;
import me.skymc.taboolib.commands.sub.ImportCommand;
import me.skymc.taboolib.commands.sub.InfoCommand;
import me.skymc.taboolib.commands.sub.ItemCommand;
Expand All @@ -23,6 +24,7 @@
import me.skymc.taboolib.commands.sub.SlotCommand;
import me.skymc.taboolib.commands.sub.VariableGetCommand;
import me.skymc.taboolib.commands.sub.VariableSetCommand;
import me.skymc.taboolib.commands.sub.cycle.CycleCommand;
import me.skymc.taboolib.commands.sub.itemlist.ItemListCommand;
import me.skymc.taboolib.commands.sub.shell.ShellCommand;
import me.skymc.taboolib.inventory.ItemUtils;
Expand All @@ -32,30 +34,8 @@ public class MainCommands implements CommandExecutor{

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 0) {
sender.sendMessage("§f");
sender.sendMessage("§b§l----- §3§lTaooLib Commands §b§l-----");
sender.sendMessage("§f");
sender.sendMessage("§7 /taboolib save [名称] §f- §8保存手中物品");
sender.sendMessage("§7 /taboolib item/i [物品] <玩家> <数量> §f- §8给予玩家物品");
sender.sendMessage("§7 /taboolib iteminfo §f- §8查看物品信息");
sender.sendMessage("§7 /taboolib itemlist §f- §8查看所有物品");
sender.sendMessage("§7 /taboolib itemreload/ireload §f- §8重载物品缓存");
sender.sendMessage("§f");
sender.sendMessage("§7 /taboolib attributes §f- §8查看所有属性");
sender.sendMessage("§7 /taboolib enchants §f- §8查看所有附魔");
sender.sendMessage("§7 /taboolib potions §f- §8查看所有药水");
sender.sendMessage("§7 /taboolib flags §f- §8查看所有标签");
sender.sendMessage("§7 /taboolib slots §f- §8查看所有部位");
sender.sendMessage("§f");
sender.sendMessage("§7 /taboolib getvariable [-s|a] [键] §f- §8查看变量");
sender.sendMessage("§7 /taboolib setvariable [-s|a] [键] [值] §f- §8更改变量");
sender.sendMessage("§f");
sender.sendMessage("§7 /taboolib shell/s load [脚本] §f- §8载入某个脚本");
sender.sendMessage("§7 /taboolib shell/s unload [脚本] §f- §8卸载某个脚本");
sender.sendMessage("§f");
sender.sendMessage("§c /taboolib importdata §f- §4向数据库导入本地数据 §8(该操作将会清空数据库)");
sender.sendMessage("§f");
if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
new HelpCommand(sender, args);
}
else if (args[0].equalsIgnoreCase("itemreload") || args[0].equalsIgnoreCase("ireload")) {
ItemUtils.reloadItemCache();
Expand Down Expand Up @@ -101,6 +81,9 @@ else if (args[0].equalsIgnoreCase("getvariable")) {
else if (args[0].equalsIgnoreCase("shell") || args[0].equalsIgnoreCase("s")) {
new ShellCommand(sender, args);
}
else if (args[0].equalsIgnoreCase("cycle") || args[0].equalsIgnoreCase("c")) {
new CycleCommand(sender, args);
}
else {
MsgUtils.send(sender, "&4Ö¸Áî´íÎó");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class Language2Command implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 0) {
sender.sendMessage("§f");
sender.sendMessage("§b§l----- §3§lTabooLib Commands §b§l-----");
sender.sendMessage("§b§l----- §3§lLanguage2 Commands §b§l-----");
sender.sendMessage("§f");
sender.sendMessage(7 /language2 reload §f- §8重载语言库");
sender.sendMessage(7 /language2 send [玩家] [语言] <变量> §f- §8发送语言提示");
sender.sendMessage(f /language2 send §8[§7玩家§8] §8[§7语言§8] §8<§7变量§8> §6- §e发送语言提示");
sender.sendMessage(f /language2 reload §6- §e重载语言库");
sender.sendMessage("§f");
}
else if (args[0].equalsIgnoreCase("reload")) {
Expand Down
80 changes: 80 additions & 0 deletions src/main/src/me/skymc/taboolib/commands/sub/HelpCommand.java
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);
}
}
}
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;
}

}
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;
}

}
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;
}

}
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;
}

}
Loading

0 comments on commit 3df9dbd

Please sign in to comment.