+ 修复 /tlib cycleInfo/cycleReset/cycleUpdate 命令参数错误问题
+ 更换阿里云镜像,加速下载
This commit is contained in:
坏黑 2018-07-30 21:28:42 +08:00
parent 17fcc8d837
commit 88cc9cc7bf
6 changed files with 60 additions and 185 deletions

View File

@ -6,7 +6,7 @@
<groupId>me.skymc</groupId>
<artifactId>TabooLib</artifactId>
<version>4.14</version>
<version>4.15</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -9,11 +9,17 @@ import me.skymc.taboolib.commands.internal.type.CommandArgument;
import me.skymc.taboolib.commands.internal.type.CommandRegister;
import me.skymc.taboolib.commands.internal.type.CommandType;
import me.skymc.taboolib.commands.taboolib.*;
import me.skymc.taboolib.database.GlobalDataManager;
import me.skymc.taboolib.fileutils.FileUtils;
import me.skymc.taboolib.inventory.ItemUtils;
import me.skymc.taboolib.other.DateUtils;
import me.skymc.taboolib.other.NumberUtils;
import me.skymc.taboolib.player.PlayerUtils;
import me.skymc.taboolib.plugin.PluginUtils;
import me.skymc.taboolib.timecycle.TimeCycle;
import me.skymc.taboolib.timecycle.TimeCycleEvent;
import me.skymc.taboolib.timecycle.TimeCycleInitializeEvent;
import me.skymc.taboolib.timecycle.TimeCycleManager;
import me.skymc.taboolib.update.UpdateTask;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@ -21,6 +27,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.util.concurrent.TimeUnit;
/**
* @Author sky
@ -417,7 +424,9 @@ public class TabooLibMainCommand extends BaseMainCommand {
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new CycleListCommand(sender, args);
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.HEAD");
TimeCycleManager.getTimeCycles().forEach(cycle -> TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.BODY", cycle.getName()));
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.FOOT");
}
};
@ -443,12 +452,24 @@ public class TabooLibMainCommand extends BaseMainCommand {
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new CycleInfoCommand(sender, args);
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[0]);
if (cycle == null) {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[0]);
} else {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-INFO",
asString(cycle.getCycle() / 1000L),
cycle.getPlugin().getName(),
DateUtils.CH_ALL.format(TimeCycleManager.getBeforeTimeline(cycle.getName())),
DateUtils.CH_ALL.format(TimeCycleManager.getAfterTimeline(cycle.getName())));
}
}
@Override
public boolean ignoredLabel() {
return false;
private 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 秒";
}
};
@ -474,12 +495,24 @@ public class TabooLibMainCommand extends BaseMainCommand {
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new CycleResetCommand(sender, args);
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[0]);
if (cycle == null) {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[0]);
return;
}
new BukkitRunnable() {
@Override
public boolean ignoredLabel() {
return false;
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));
// 提示
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-RESET", args[0]);
}
}.runTaskAsynchronously(Main.getInst());
}
};
@ -505,12 +538,23 @@ public class TabooLibMainCommand extends BaseMainCommand {
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
new CycleUpdateCommand(sender, args);
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[0]);
if (cycle == null) {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[0]);
return;
}
new BukkitRunnable() {
@Override
public boolean ignoredLabel() {
return false;
public void run() {
// 重置
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(System.currentTimeMillis()));
// 触发器
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
// 提示
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-UPDATE", args[0]);
}
}.runTaskAsynchronously(Main.getInst());
}
};

View File

@ -1,46 +0,0 @@
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.other.DateUtils;
import me.skymc.taboolib.timecycle.TimeCycle;
import me.skymc.taboolib.timecycle.TimeCycleManager;
import org.bukkit.command.CommandSender;
import java.util.concurrent.TimeUnit;
public class CycleInfoCommand extends SubCommand {
public CycleInfoCommand(CommandSender sender, String[] args) {
super(sender, args);
if (args.length < 2) {
TLocale.sendTo(sender, "COMMANDS.PARAMETER.UNKNOWN");
return;
}
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]);
if (cycle == null) {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[2]);
return;
}
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-INFO",
asString(cycle.getCycle() / 1000L),
cycle.getPlugin().getName(),
DateUtils.CH_ALL.format(TimeCycleManager.getBeforeTimeline(cycle.getName())),
DateUtils.CH_ALL.format(TimeCycleManager.getAfterTimeline(cycle.getName())));
}
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;
}
}

View File

@ -1,25 +0,0 @@
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.timecycle.TimeCycleManager;
import org.bukkit.command.CommandSender;
public class CycleListCommand extends SubCommand {
public CycleListCommand(CommandSender sender, String[] args) {
super(sender, args);
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.HEAD");
TimeCycleManager.getTimeCycles().forEach(cycle -> TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.BODY", cycle.getName()));
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.FOOT");
}
@Override
public boolean command() {
return true;
}
}

View File

@ -1,50 +0,0 @@
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.database.GlobalDataManager;
import me.skymc.taboolib.timecycle.TimeCycle;
import me.skymc.taboolib.timecycle.TimeCycleEvent;
import me.skymc.taboolib.timecycle.TimeCycleInitializeEvent;
import me.skymc.taboolib.timecycle.TimeCycleManager;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
public class CycleResetCommand extends SubCommand {
public CycleResetCommand(CommandSender sender, String[] args) {
super(sender, args);
if (args.length < 2) {
TLocale.sendTo(sender, "COMMANDS.PARAMETER.UNKNOWN");
return;
}
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]);
if (cycle == null) {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[2]);
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));
// 提示
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-RESET", args[2]);
}
}.runTaskAsynchronously(Main.getInst());
}
@Override
public boolean command() {
return true;
}
}

View File

@ -1,48 +0,0 @@
package me.skymc.taboolib.commands.taboolib;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.database.GlobalDataManager;
import me.skymc.taboolib.timecycle.TimeCycle;
import me.skymc.taboolib.timecycle.TimeCycleEvent;
import me.skymc.taboolib.timecycle.TimeCycleManager;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
public class CycleUpdateCommand extends SubCommand {
public CycleUpdateCommand(CommandSender sender, String[] args) {
super(sender, args);
if (args.length < 2) {
TLocale.sendTo(sender, "COMMANDS.PARAMETER.UNKNOWN");
return;
}
TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]);
if (cycle == null) {
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[2]);
return;
}
new BukkitRunnable() {
@Override
public void run() {
// 重置
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(System.currentTimeMillis()));
// 触发器
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
// 提示
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-UPDATE", args[2]);
}
}.runTaskAsynchronously(Main.getInst());
}
@Override
public boolean command() {
return true;
}
}