diff --git a/README.md b/README.md index 3b6ed98..9b660ad 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,10 @@ - **支持自定义哪个玩家的头颅** - **支持物品发光(附魔效果)** - **玩家进入游戏时赋予权限更早** -- 手动删除过期的或无效数据 +- **管理员查看玩家到期时间** +- **检测是否有新版本** +- **提示权限包到期** +- **玩家登录时删除过期的或无效数据** - 取消前置插件 diff --git a/pom.xml b/pom.xml index 7f68fe8..82c69c3 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 gg.frog.mc permissionstime - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT jar PermissionsTime 支持跨服的权限限时插件 diff --git a/src/main/gg/frog/mc/permissionstime/PluginMain.java b/src/main/gg/frog/mc/permissionstime/PluginMain.java index c202861..69e3123 100644 --- a/src/main/gg/frog/mc/permissionstime/PluginMain.java +++ b/src/main/gg/frog/mc/permissionstime/PluginMain.java @@ -18,6 +18,7 @@ import gg.frog.mc.permissionstime.database.SqlManager; import gg.frog.mc.permissionstime.listener.MainListener; import gg.frog.mc.permissionstime.utils.FileUtil; import gg.frog.mc.permissionstime.utils.StrUtil; +import gg.frog.mc.permissionstime.utils.UpdateCheck; import net.milkbowl.vault.permission.Permission; public class PluginMain extends JavaPlugin { @@ -59,6 +60,7 @@ public class PluginMain extends JavaPlugin { e.printStackTrace(); } } + getServer().getScheduler().runTask(pm, new UpdateCheck(pm)); getServer().getScheduler().runTask(pm, new Runnable() { public void run() { if (!checkPluginDepends()) { diff --git a/src/main/gg/frog/mc/permissionstime/command/GetCmd.java b/src/main/gg/frog/mc/permissionstime/command/GetCmd.java new file mode 100644 index 0000000..6846692 --- /dev/null +++ b/src/main/gg/frog/mc/permissionstime/command/GetCmd.java @@ -0,0 +1,56 @@ +package gg.frog.mc.permissionstime.command; + +import java.util.List; + +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; + +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.model.db.PlayerDataBean; +import gg.frog.mc.permissionstime.utils.StrUtil; + +public class GetCmd implements Runnable { + + private PluginMain pm; + private SqlManager sm; + private String[] args; + private CommandSender sender; + + public GetCmd(PluginMain pm, CommandSender sender, String[] args) { + this.pm = pm; + this.sm = pm.getSqlManager(); + this.sender = sender; + this.args = args; + } + + @Override + public void run() { + if (args.length == 2) { + sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING)); + OfflinePlayer p = pm.getOfflinePlayer(args[1]); + List ps = sm.getTime(p.getUniqueId().toString()); + if (ps.size() > 0) { + sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NUM_OF_PACKAGES, args[1], ps.size())); + for (PlayerDataBean pdb : ps) { + String expireString = StrUtil.timestampToString(pdb.getExpire()); + PermissionPackageBean pc = PackagesCfg.PACKAGES.get(pdb.getPackageName()); + if (pc != null) { + sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", pc.getDisplayName(), pdb.getPackageName(), expireString)); + } else { + sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", LangCfg.MSG_UNKNOWN_PACKAGE, pdb.getPackageName(), expireString)); + } + } + } else { + sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA)); + } + } else { + sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH)); + sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " get \n&8 - View player packages.")); + } + } +} diff --git a/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java b/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java index 2973500..64ba229 100644 --- a/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java +++ b/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java @@ -39,10 +39,6 @@ public class GiveCmd implements Runnable { int days = 0; try { days = Integer.parseInt(time); - if (days <= 0) { - sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DAYS_PARAMETER_INCORRECT)); - return; - } } catch (Exception e) { sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DAYS_PARAMETER_INCORRECT)); return; @@ -86,6 +82,7 @@ public class GiveCmd implements Runnable { } } else { sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH)); + sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " give