diff --git a/src/main/gg/frog/mc/permissionstime/PluginMain.java b/src/main/gg/frog/mc/permissionstime/PluginMain.java index bfbab8f..7bc7d0d 100644 --- a/src/main/gg/frog/mc/permissionstime/PluginMain.java +++ b/src/main/gg/frog/mc/permissionstime/PluginMain.java @@ -8,7 +8,7 @@ import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; import org.mcstats.Metrics; -import gg.frog.mc.permissionstime.command.TheCommand; +import gg.frog.mc.permissionstime.command.MainCommand; import gg.frog.mc.permissionstime.config.ConfigManager; import gg.frog.mc.permissionstime.config.PluginCfg; import gg.frog.mc.permissionstime.database.SqlManager; @@ -84,7 +84,7 @@ public class PluginMain extends JavaPlugin { * 这里可以注册多个,一般注册一个就够用 */ private void registerCommands() { - this.getCommand(PLUGIN_NAME_LOWER_CASE).setExecutor(new TheCommand()); + this.getCommand(PLUGIN_NAME_LOWER_CASE).setExecutor(new MainCommand()); } public ConfigManager getConfigManager() { diff --git a/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java b/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java new file mode 100644 index 0000000..5fa17ac --- /dev/null +++ b/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java @@ -0,0 +1,47 @@ +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; +import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean; +import gg.frog.mc.permissionstime.utils.PluginUtil; +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) { + if (args.length == 4) { + String playerName = args[1]; + String packageName = args[2]; + String time = args[3]; + 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)); + } + return true; + } else { + sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "找不到名为'" + playerName + "'的玩家")); + } + } else { + sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "找不到名为'" + packageName + "'的权限包")); + } + } else { + sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "参数不正确" + "