1
1
mirror of https://github.com/geekfrog/PermissionsTime.git synced 2025-09-06 11:06:58 +00:00

权限包功能

give功能
配置BUG修复
This commit is contained in:
GeekFrog
2017-07-12 05:21:26 +08:00
parent d0e3e86377
commit f00284314f
15 changed files with 334 additions and 97 deletions

View File

@ -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 + "参数不正确" + "<playerName> <packageName> <time>"));
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "参数不正确"));
}
return false;
}