diff --git a/pom.xml b/pom.xml
index fdc5768..b6162b4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
gg.frog.mc
permissionstime
- 0.0.1-SNAPSHOT
+ 0.0.1-TEST
jar
PermissionsTime
支持跨服的权限限时插件
diff --git a/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java b/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java
index 5fa17ac..a1a220d 100644
--- a/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java
+++ b/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java
@@ -2,12 +2,9 @@ package gg.frog.mc.permissionstime.command;
import java.util.UUID;
-import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
import gg.frog.mc.permissionstime.PluginMain;
-import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PackagesCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
@@ -17,30 +14,44 @@ import gg.frog.mc.permissionstime.utils.StrUtil;
public class GiveCmd {
- private static PluginMain pm = PluginMain.getInstance();
private static SqlManager sm = PluginMain.sm;
-
- public static boolean onCommand(CommandSender sender, Command command, boolean isPlayer, String[] args) {
+
+ public static boolean onCommand(CommandSender sender, boolean isPlayer, String[] args) {
if (args.length == 4) {
String playerName = args[1];
String packageName = args[2];
String time = args[3];
+ int days;
+ try {
+ days = Integer.parseInt(time);
+ if (days <= 0) {
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "时间参数不正确,请输入正整数"));
+ return false;
+ }
+ } catch (Exception e) {
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "时间参数不正确,请输入正整数"));
+ return false;
+ }
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
if (pack != null) {
UUID uuid = PluginUtil.getPlayerUUIDByName(playerName);
if (uuid != null) {
if (PluginCfg.IS_DEBUG) {
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid.toString() + "\n" + pack.toString() + "\n" + time));
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid.toString() + "\n" + pack.toString() + "\n" + time + "天"));
+ }
+ if (sm.giveTime(uuid.toString(), packageName, days)) {
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "给予玩家{0} {1}天的{2}", playerName, time, pack.getDisplayName()));
+ } else {
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "未给予玩家{0} {1}天的{2}", playerName, time, pack.getDisplayName()));
}
- return true;
} else {
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "找不到名为'" + playerName + "'的玩家"));
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "找不到名为'{0}'的玩家", playerName));
}
} else {
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "找不到名为'" + packageName + "'的权限包"));
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "找不到名为'{0}'的权限包", packageName));
}
} else {
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "参数不正确" + "