mirror of
https://github.com/geekfrog/PermissionsTime.git
synced 2024-11-22 07:28:47 +00:00
功能扩展 + BUG修复
1.命令提示语言支持 2.mysql模式下的bug(时间累积和创建表) 3.支持自定义时间单位 天、小时、分钟
This commit is contained in:
parent
8bc004eb12
commit
6cdac1145d
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>gg.frog.mc</groupId>
|
<groupId>gg.frog.mc</groupId>
|
||||||
<artifactId>permissionstime</artifactId>
|
<artifactId>permissionstime</artifactId>
|
||||||
<version>0.1.3-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>PermissionsTime</name>
|
<name>PermissionsTime</name>
|
||||||
<description>支持跨服的权限限时插件</description>
|
<description>支持跨服的权限限时插件</description>
|
||||||
|
@ -9,7 +9,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.mcstats.Metrics;
|
|
||||||
|
|
||||||
import gg.frog.mc.permissionstime.command.MainCommand;
|
import gg.frog.mc.permissionstime.command.MainCommand;
|
||||||
import gg.frog.mc.permissionstime.config.ConfigManager;
|
import gg.frog.mc.permissionstime.config.ConfigManager;
|
||||||
@ -52,14 +51,6 @@ public class PluginMain extends JavaPlugin {
|
|||||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " https://github.com/geekfrog/PermissionsTime/ "));
|
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " https://github.com/geekfrog/PermissionsTime/ "));
|
||||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX));
|
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX));
|
||||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "==============================="));
|
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "==============================="));
|
||||||
if (PluginCfg.IS_METRICS) {
|
|
||||||
try {
|
|
||||||
Metrics metrics = new Metrics(pm);
|
|
||||||
metrics.start();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getServer().getScheduler().runTask(pm, new UpdateCheck(pm));
|
getServer().getScheduler().runTask(pm, new UpdateCheck(pm));
|
||||||
getServer().getScheduler().runTask(pm, new Runnable() {
|
getServer().getScheduler().runTask(pm, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -71,6 +62,14 @@ public class PluginMain extends JavaPlugin {
|
|||||||
registerCommands();
|
registerCommands();
|
||||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&2Startup successful!"));
|
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&2Startup successful!"));
|
||||||
}
|
}
|
||||||
|
if (PluginCfg.IS_METRICS) {
|
||||||
|
try {
|
||||||
|
org.mcstats.Metrics mcstats = new org.mcstats.Metrics(pm);
|
||||||
|
mcstats.start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ public class GetCmd implements Runnable {
|
|||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||||
OfflinePlayer p = pm.getOfflinePlayer(args[1]);
|
OfflinePlayer p = pm.getOfflinePlayer(args[1]);
|
||||||
|
if (p != null) {
|
||||||
List<PlayerDataBean> ps = sm.getTime(p.getUniqueId().toString());
|
List<PlayerDataBean> ps = sm.getTime(p.getUniqueId().toString());
|
||||||
if (ps.size() > 0) {
|
if (ps.size() > 0) {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NUM_OF_PACKAGES, args[1], ps.size()));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NUM_OF_PACKAGES, args[1], ps.size()));
|
||||||
@ -48,9 +49,12 @@ public class GetCmd implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, args[1]));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " get <playerName> \n&8 - View player packages."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_GET, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,15 +32,34 @@ public class GiveCmd implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (args.length == 4) {
|
if (args.length == 5) {
|
||||||
String playerName = args[1];
|
String playerName = args[1];
|
||||||
String packageName = args[2];
|
String packageName = args[2];
|
||||||
String time = args[3];
|
String time = args[3];
|
||||||
int days = 0;
|
String unit = args[4];
|
||||||
|
final String unitName;
|
||||||
|
int minutes = 0;
|
||||||
try {
|
try {
|
||||||
days = Integer.parseInt(time);
|
minutes = Integer.parseInt(time);
|
||||||
|
if (minutes == 0) {
|
||||||
|
throw new RuntimeException("not a nonzero integer.");
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DAYS_PARAMETER_INCORRECT));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TIME_PARAMETER_INCORRECT));
|
||||||
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_GIVE, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ("d".equalsIgnoreCase(unit)) {
|
||||||
|
minutes *= 24 * 60;
|
||||||
|
unitName = LangCfg.TIME_UNIT_D;
|
||||||
|
} else if ("h".equalsIgnoreCase(unit)) {
|
||||||
|
minutes *= 60;
|
||||||
|
unitName = LangCfg.TIME_UNIT_H;
|
||||||
|
} else if ("m".equalsIgnoreCase(unit)) {
|
||||||
|
unitName = LangCfg.TIME_UNIT_M;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TIME_UNIT_PARAMETER_INCORRECT));
|
||||||
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_GIVE, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
|
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
|
||||||
@ -50,9 +69,9 @@ public class GiveCmd implements Runnable {
|
|||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
if (PluginCfg.IS_DEBUG) {
|
if (PluginCfg.IS_DEBUG) {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid.toString() + "\n" + pack.toString() + "\n" + time + " days."));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid.toString() + "\n" + pack.toString() + "\n" + time + unitName + "."));
|
||||||
}
|
}
|
||||||
if (sm.giveTime(((PluginCfg.USE_MYSQL && pack.getGlobal()) ? "g:" : "") + uuid.toString(), packageName, days)) {
|
if (sm.giveTime(((PluginCfg.USE_MYSQL && pack.getGlobal()) ? "g:" : "") + uuid.toString(), packageName, minutes)) {
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
Player p = player.getPlayer();
|
Player p = player.getPlayer();
|
||||||
try {
|
try {
|
||||||
@ -62,17 +81,17 @@ public class GiveCmd implements Runnable {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
||||||
}
|
}
|
||||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TELL_GIVE_PACKAGE, sender.getName(), time, pack.getDisplayName()));
|
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TELL_GIVE_PACKAGE, sender.getName(), time + unitName, pack.getDisplayName()));
|
||||||
}
|
}
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_GIVE_PACKAGE, playerName, time, pack.getDisplayName()));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_GIVE_PACKAGE, playerName, time + unitName, pack.getDisplayName()));
|
||||||
} else {
|
} else {
|
||||||
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
pm.writeFailLog("Command execution failed. Give {0}({1}) {2}days {3} Executor: {4}", playerName, player.getUniqueId().toString(), time, pack.getDisplayName(), sender.getName());
|
pm.writeFailLog("Command execution failed. Give {0}({1}) {2} {3} Executor: {4}", playerName, player.getUniqueId().toString(), time + unitName, pack.getDisplayName(), sender.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_GIVE_PACKAGE_FAIL, playerName, time, pack.getDisplayName()));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_GIVE_PACKAGE_FAIL, playerName, time + unitName, pack.getDisplayName()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
||||||
@ -82,7 +101,7 @@ public class GiveCmd implements Runnable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " give <playerName> <packageName> <time> \n&8 - Give player package <time>day."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_GIVE, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
new Thread(packagesCmd).start();
|
new Thread(packagesCmd).start();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat("/" + pm.PLUGIN_NAME_LOWER_CASE + " help -Show commands."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_HELP, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -122,28 +122,28 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
private void getHelp(CommandSender sender, boolean isPlayer) {
|
private void getHelp(CommandSender sender, boolean isPlayer) {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "\n&a===== " + pm.PLUGIN_NAME + " Version:" + pm.PLUGIN_VERSION + (pm.getDescription().getCommands().containsKey("pt") ? " Aliases:/pt" : "") + " ====="));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "\n&a===== " + pm.PLUGIN_NAME + " Version:" + pm.PLUGIN_VERSION + (pm.getDescription().getCommands().containsKey("pt") ? " Aliases:/pt" : "") + " ====="));
|
||||||
if (isPlayer && (sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) {
|
if (isPlayer && (sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) {
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " me \n&8 - View self package."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".packages")) {
|
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".packages")) {
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " packages [packageName] \n&8 - View packages."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_PACKAGES, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
|
||||||
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".give")) {
|
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " give <playerName> <packageName> <time> \n&8 - Give player package <time>day."));
|
|
||||||
}
|
|
||||||
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".set")) {
|
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " set <playerName> <packageName> <time> \n&8 - Set player package <time>day."));
|
|
||||||
}
|
}
|
||||||
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".get")) {
|
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".get")) {
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " get <playerName> \n&8 - View player packages."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_GET, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
|
}
|
||||||
|
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".give")) {
|
||||||
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_GIVE, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
|
}
|
||||||
|
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".set")) {
|
||||||
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_SET, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".remove")) {
|
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".remove")) {
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " remove <playerName> <packageName> [t/f delGlobal] \n&8 - Remove player package."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_REMOVE, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".removeall")) {
|
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".removeall")) {
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " removeall <playerName> [t/f delGlobal] \n&8 - Remove player all package."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_REMOVEALL, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".reload")) {
|
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".reload")) {
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " reload \n&8 -Reloads the config file."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_RELOAD, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX));
|
||||||
}
|
}
|
||||||
@ -178,10 +178,10 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
if ("give".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".give"))) {
|
if ("give".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".give"))) {
|
||||||
tipList.add("give");
|
tipList.add("give");
|
||||||
}
|
}
|
||||||
if ("set".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + "set"))) {
|
if ("set".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".set"))) {
|
||||||
tipList.add("set");
|
tipList.add("set");
|
||||||
}
|
}
|
||||||
if ("get".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + "get"))) {
|
if ("get".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".get"))) {
|
||||||
tipList.add("get");
|
tipList.add("get");
|
||||||
}
|
}
|
||||||
if ("remove".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".remove"))) {
|
if ("remove".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".remove"))) {
|
||||||
@ -196,19 +196,19 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
|||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
args[0] = args[0].toLowerCase(Locale.ENGLISH);
|
args[0] = args[0].toLowerCase(Locale.ENGLISH);
|
||||||
args[1] = args[1].toLowerCase(Locale.ENGLISH);
|
args[1] = args[1].toLowerCase(Locale.ENGLISH);
|
||||||
if ("packages".equals(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) {
|
if ("packages".equalsIgnoreCase(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) {
|
||||||
for (String name : PackagesCfg.PACKAGES.keySet()) {
|
for (String name : PackagesCfg.PACKAGES.keySet()) {
|
||||||
if (name.startsWith(args[1])) {
|
if (name.startsWith(args[1])) {
|
||||||
tipList.add(name);
|
tipList.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ("give".equals(args[0]) || "set".equals(args[0]) || "get".equals(args[0]) || "remove".equals(args[0]) || "removeall".equals(args[0])) {
|
} else if ("give".equalsIgnoreCase(args[0]) || "set".equalsIgnoreCase(args[0]) || "get".equalsIgnoreCase(args[0]) || "remove".equalsIgnoreCase(args[0]) || "removeall".equalsIgnoreCase(args[0])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else if (args.length == 3) {
|
} else if (args.length == 3) {
|
||||||
args[0] = args[0].toLowerCase(Locale.ENGLISH);
|
args[0] = args[0].toLowerCase(Locale.ENGLISH);
|
||||||
args[2] = args[2].toLowerCase(Locale.ENGLISH);
|
args[2] = args[2].toLowerCase(Locale.ENGLISH);
|
||||||
if ("give".equals(args[0]) || "set".equals(args[0]) || "remove".equals(args[0])) {
|
if ("give".equalsIgnoreCase(args[0]) || "set".equalsIgnoreCase(args[0]) || "remove".equalsIgnoreCase(args[0])) {
|
||||||
for (String name : PackagesCfg.PACKAGES.keySet()) {
|
for (String name : PackagesCfg.PACKAGES.keySet()) {
|
||||||
if (name.startsWith(args[2])) {
|
if (name.startsWith(args[2])) {
|
||||||
tipList.add(name);
|
tipList.add(name);
|
||||||
|
@ -43,7 +43,7 @@ public class MeCmd implements Runnable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " me \n&8 - View self package."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Only player can use this command."));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Only player can use this command."));
|
||||||
|
@ -41,7 +41,7 @@ public class PackagesCmd implements Runnable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " packages [packageName] \n&8 - View packages."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_PACKAGES, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class RemoveAllCmd implements Runnable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " removeall <playerName> [t/f delGlobal] \n&8 - Remove player all package."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_REMOVEALL, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class RemoveCmd implements Runnable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " remove <playerName> <packageName> [t/f delGlobal] \n&8 - Remove player package."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_REMOVE, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,15 +32,34 @@ public class SetCmd implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (args.length == 4) {
|
if (args.length == 5) {
|
||||||
String playerName = args[1];
|
String playerName = args[1];
|
||||||
String packageName = args[2];
|
String packageName = args[2];
|
||||||
String time = args[3];
|
String time = args[3];
|
||||||
int days = 0;
|
String unit = args[4];
|
||||||
|
final String unitName;
|
||||||
|
int minutes = 0;
|
||||||
try {
|
try {
|
||||||
days = Integer.parseInt(time);
|
minutes = Integer.parseInt(time);
|
||||||
|
if (minutes == 0) {
|
||||||
|
throw new RuntimeException("not a nonzero integer.");
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DAYS_PARAMETER_INCORRECT));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TIME_PARAMETER_INCORRECT));
|
||||||
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_SET, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ("d".equalsIgnoreCase(unit)) {
|
||||||
|
minutes *= 24 * 60;
|
||||||
|
unitName = LangCfg.TIME_UNIT_D;
|
||||||
|
} else if ("h".equalsIgnoreCase(unit)) {
|
||||||
|
minutes *= 60;
|
||||||
|
unitName = LangCfg.TIME_UNIT_H;
|
||||||
|
} else if ("m".equalsIgnoreCase(unit)) {
|
||||||
|
unitName = LangCfg.TIME_UNIT_M;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TIME_UNIT_PARAMETER_INCORRECT));
|
||||||
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_SET, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
|
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
|
||||||
@ -50,9 +69,9 @@ public class SetCmd implements Runnable {
|
|||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
if (PluginCfg.IS_DEBUG) {
|
if (PluginCfg.IS_DEBUG) {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid.toString() + "\n" + pack.toString() + "\n" + time + " days."));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid.toString() + "\n" + pack.toString() + "\n" + time + unitName + " ."));
|
||||||
}
|
}
|
||||||
if (sm.setTime(((PluginCfg.USE_MYSQL && pack.getGlobal()) ? "g:" : "") + uuid.toString(), packageName, days)) {
|
if (sm.setTime(((PluginCfg.USE_MYSQL && pack.getGlobal()) ? "g:" : "") + uuid.toString(), packageName, minutes)) {
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
Player p = player.getPlayer();
|
Player p = player.getPlayer();
|
||||||
try {
|
try {
|
||||||
@ -62,17 +81,17 @@ public class SetCmd implements Runnable {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
||||||
}
|
}
|
||||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TELL_SET_PACKAGE, sender.getName(), time, pack.getDisplayName()));
|
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TELL_SET_PACKAGE, sender.getName(), time + unitName, pack.getDisplayName()));
|
||||||
}
|
}
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_SET_PACKAGE, playerName, time, pack.getDisplayName()));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_SET_PACKAGE, playerName, time + unitName, pack.getDisplayName()));
|
||||||
} else {
|
} else {
|
||||||
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
pm.writeFailLog("Command execution failed. Set {0}({1}) {2}days {3} Executor: {4}", playerName, player.getUniqueId().toString(), time, pack.getDisplayName(), sender.getName());
|
pm.writeFailLog("Command execution failed. Set {0}({1}) {2} {3} Executor: {4}", playerName, player.getUniqueId().toString(), time + unitName, pack.getDisplayName(), sender.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_SET_PACKAGE_FAIL, playerName, time, pack.getDisplayName()));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_SET_PACKAGE_FAIL, playerName, time + unitName, pack.getDisplayName()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
||||||
@ -82,7 +101,7 @@ public class SetCmd implements Runnable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||||
sender.sendMessage(StrUtil.messageFormat("&6/" + pm.PLUGIN_NAME_LOWER_CASE + " set <playerName> <packageName> <time> \n&8 - Set player package <time>day."));
|
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_SET, pm.PLUGIN_NAME_LOWER_CASE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,13 @@ public class LangCfg extends PluginConfig {
|
|||||||
|
|
||||||
public static String INVENTORY_NAME = null;
|
public static String INVENTORY_NAME = null;
|
||||||
public static String EXPIRATION_DATE = null;
|
public static String EXPIRATION_DATE = null;
|
||||||
|
public static String TIME_UNIT_D = null;
|
||||||
|
public static String TIME_UNIT_H = null;
|
||||||
|
public static String TIME_UNIT_M = null;
|
||||||
|
|
||||||
public static String MSG_PARAMETER_MISMATCH = null;
|
public static String MSG_PARAMETER_MISMATCH = null;
|
||||||
public static String MSG_DAYS_PARAMETER_INCORRECT = null;
|
public static String MSG_TIME_PARAMETER_INCORRECT = null;
|
||||||
|
public static String MSG_TIME_UNIT_PARAMETER_INCORRECT = null;
|
||||||
public static String MSG_PROCESSING = null;
|
public static String MSG_PROCESSING = null;
|
||||||
public static String MSG_NO_DATA = null;
|
public static String MSG_NO_DATA = null;
|
||||||
public static String MSG_PACKAGE_NUM = null;
|
public static String MSG_PACKAGE_NUM = null;
|
||||||
@ -42,6 +47,16 @@ public class LangCfg extends PluginConfig {
|
|||||||
public static String MSG_UNKNOWN_PACKAGE = null;
|
public static String MSG_UNKNOWN_PACKAGE = null;
|
||||||
public static String MSG_IS_EXPIRATION_DATE = null;
|
public static String MSG_IS_EXPIRATION_DATE = null;
|
||||||
|
|
||||||
|
public static String CMD_HELP = null;
|
||||||
|
public static String CMD_ME = null;
|
||||||
|
public static String CMD_PACKAGES = null;
|
||||||
|
public static String CMD_GET = null;
|
||||||
|
public static String CMD_GIVE = null;
|
||||||
|
public static String CMD_SET = null;
|
||||||
|
public static String CMD_REMOVE = null;
|
||||||
|
public static String CMD_REMOVEALL = null;
|
||||||
|
public static String CMD_RELOAD = null;
|
||||||
|
|
||||||
public LangCfg(String fileName, PluginMain pm) {
|
public LangCfg(String fileName, PluginMain pm) {
|
||||||
super(fileName, pm);
|
super(fileName, pm);
|
||||||
}
|
}
|
||||||
@ -53,8 +68,13 @@ public class LangCfg extends PluginConfig {
|
|||||||
protected void loadToDo() {
|
protected void loadToDo() {
|
||||||
INVENTORY_NAME = getConfig().getString("inventoryName", "&4===Permissions Packages===");
|
INVENTORY_NAME = getConfig().getString("inventoryName", "&4===Permissions Packages===");
|
||||||
EXPIRATION_DATE = getConfig().getString("expirationDate", "&4Expiration date: {0}");
|
EXPIRATION_DATE = getConfig().getString("expirationDate", "&4Expiration date: {0}");
|
||||||
|
TIME_UNIT_D = getConfig().getString("timeUnitD", "day(s)");
|
||||||
|
TIME_UNIT_H = getConfig().getString("timeUnitH", "hour(s)");
|
||||||
|
TIME_UNIT_M = getConfig().getString("timeUnitM", "minute(s)");
|
||||||
|
|
||||||
MSG_PARAMETER_MISMATCH = getConfig().getString("msg.parameterMismatch", "&4Parameter mismatch.");
|
MSG_PARAMETER_MISMATCH = getConfig().getString("msg.parameterMismatch", "&4Parameter mismatch.");
|
||||||
MSG_DAYS_PARAMETER_INCORRECT = getConfig().getString("msg.daysParameterIncorrect", "&4The number of days is incorrect. Please enter a positive integer.");
|
MSG_TIME_PARAMETER_INCORRECT = getConfig().getString("msg.timeParameterIncorrect", "&4The number of time is incorrect. Please enter a nonzero integer.");
|
||||||
|
MSG_TIME_UNIT_PARAMETER_INCORRECT = getConfig().getString("msg.timeUnitParameterIncorrect", "&4The number of time unit is incorrect. Please use d/h/m. (d=day, h=hour, m=minute)");
|
||||||
MSG_PROCESSING = getConfig().getString("msg.processing", "&2Please wait for processing...");
|
MSG_PROCESSING = getConfig().getString("msg.processing", "&2Please wait for processing...");
|
||||||
MSG_NO_DATA = getConfig().getString("msg.noData", "&4No data for packages.");
|
MSG_NO_DATA = getConfig().getString("msg.noData", "&4No data for packages.");
|
||||||
MSG_PACKAGE_NUM = getConfig().getString("msg.packageNum", "&4There are {0} kinds of permissions packages.");
|
MSG_PACKAGE_NUM = getConfig().getString("msg.packageNum", "&4There are {0} kinds of permissions packages.");
|
||||||
@ -65,12 +85,12 @@ public class LangCfg extends PluginConfig {
|
|||||||
MSG_FAIL_SET_PERMISSION = getConfig().getString("msg.failSetPermission", "&4Failed to modify permissions. Please re-enter the server!");
|
MSG_FAIL_SET_PERMISSION = getConfig().getString("msg.failSetPermission", "&4Failed to modify permissions. Please re-enter the server!");
|
||||||
MSG_NO_FIND_PLAYER = getConfig().getString("msg.noFindPlayer", "&4Can not find player named &2{0}");
|
MSG_NO_FIND_PLAYER = getConfig().getString("msg.noFindPlayer", "&4Can not find player named &2{0}");
|
||||||
MSG_NO_FIND_PACKAGE = getConfig().getString("msg.noFindPackage", "&4Can not find package named &2{0}");
|
MSG_NO_FIND_PACKAGE = getConfig().getString("msg.noFindPackage", "&4Can not find package named &2{0}");
|
||||||
MSG_TELL_GIVE_PACKAGE = getConfig().getString("msg.tellGivePackage", "&2{0} give you {1}days package of {2}");
|
MSG_TELL_GIVE_PACKAGE = getConfig().getString("msg.tellGivePackage", "&2{0} give you {1} package of {2}");
|
||||||
MSG_GIVE_PACKAGE = getConfig().getString("msg.givePackage", "&2Give the player {0} {1}days package of {2}");
|
MSG_GIVE_PACKAGE = getConfig().getString("msg.givePackage", "&2Give the player {0} {1} package of {2}");
|
||||||
MSG_GIVE_PACKAGE_FAIL = getConfig().getString("msg.givePackageFail", "&4Failed to give players {0} {1}days package of {2}");
|
MSG_GIVE_PACKAGE_FAIL = getConfig().getString("msg.givePackageFail", "&4Failed to give players {0} {1} package of {2}");
|
||||||
MSG_TELL_SET_PACKAGE = getConfig().getString("msg.tellSetPackage", "&2{0} set your package of {2} to {1}days");
|
MSG_TELL_SET_PACKAGE = getConfig().getString("msg.tellSetPackage", "&2{0} set your package of {2} to {1}");
|
||||||
MSG_SET_PACKAGE = getConfig().getString("msg.setPackage", "&2Set the player {0} {1}days package of {2}");
|
MSG_SET_PACKAGE = getConfig().getString("msg.setPackage", "&2Set the player {0} {1} package of {2}");
|
||||||
MSG_SET_PACKAGE_FAIL = getConfig().getString("msg.setPackageFail", "&4Failed to set the player {0} {1}days package of {2}");
|
MSG_SET_PACKAGE_FAIL = getConfig().getString("msg.setPackageFail", "&4Failed to set the player {0} {1} package of {2}");
|
||||||
MSG_TELL_DEL_PACKAGE = getConfig().getString("msg.tellDelPackage", "&4{0} deleted your package of {1}");
|
MSG_TELL_DEL_PACKAGE = getConfig().getString("msg.tellDelPackage", "&4{0} deleted your package of {1}");
|
||||||
MSG_DEL_PACKAGE = getConfig().getString("msg.delPackage", "&2Remove package of {1}&2 for player {0}");
|
MSG_DEL_PACKAGE = getConfig().getString("msg.delPackage", "&2Remove package of {1}&2 for player {0}");
|
||||||
MSG_DEL_PACKAGE_FAIL = getConfig().getString("msg.delPackageFail", "&4Failed to delete package of {1}&2 for player {0}");
|
MSG_DEL_PACKAGE_FAIL = getConfig().getString("msg.delPackageFail", "&4Failed to delete package of {1}&2 for player {0}");
|
||||||
@ -81,5 +101,15 @@ public class LangCfg extends PluginConfig {
|
|||||||
MSG_EXPIRATION_DATE = getConfig().getString("msg.expirationDate", "{0}packages: {1}({2}), Expiration date: {3}");
|
MSG_EXPIRATION_DATE = getConfig().getString("msg.expirationDate", "{0}packages: {1}({2}), Expiration date: {3}");
|
||||||
MSG_UNKNOWN_PACKAGE = getConfig().getString("msg.unknownPackage", "Unknown Packages");
|
MSG_UNKNOWN_PACKAGE = getConfig().getString("msg.unknownPackage", "Unknown Packages");
|
||||||
MSG_IS_EXPIRATION_DATE = getConfig().getString("msg.isExpirationDate", "Your package: {0}({1})&r has expired.");
|
MSG_IS_EXPIRATION_DATE = getConfig().getString("msg.isExpirationDate", "Your package: {0}({1})&r has expired.");
|
||||||
|
|
||||||
|
CMD_HELP = getConfig().getString("cmd.help", "/{0} help -Show commands.");
|
||||||
|
CMD_ME = getConfig().getString("cmd.me", "&6/{0} me \\n&8 - View self package.");
|
||||||
|
CMD_PACKAGES = getConfig().getString("cmd.packages", "&6/{0} packages [packageName] \\n&8 - View packages.");
|
||||||
|
CMD_GET = getConfig().getString("cmd.get", "&6/{0} get <playerName> \\n&8 - View player packages.");
|
||||||
|
CMD_GIVE = getConfig().getString("cmd.give", "&6/{0} give <playerName> <packageName> <time> <timeUnit:d/h/m> \\n&8 - Give player package some time.(Time accumulation.) \\n&8 timeUnit: d=day, h=hour, m=minute");
|
||||||
|
CMD_SET = getConfig().getString("cmd.set", "&6/{0} set <playerName> <packageName> <time> <timeUnit:d/h/m> \\n&8 - Set player package some time. \\n&8 timeUnit: d=day, h=hour, m=minute");
|
||||||
|
CMD_REMOVE = getConfig().getString("cmd.remove", "&6/{0} remove <playerName> <packageName> [t/f] \\n&8 - Remove player package.(t: Delete global package.)");
|
||||||
|
CMD_REMOVEALL = getConfig().getString("cmd.removeall", "&6/{0} removeall <playerName> [t/f] \\n&8 - Remove player all package.(t: Delete global packages.)");
|
||||||
|
CMD_RELOAD = getConfig().getString("cmd.reload", "&6/{0} reload \\n&8 - Reloads the config file.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
|
|||||||
|
|
||||||
public interface IPlayerDataDao {
|
public interface IPlayerDataDao {
|
||||||
|
|
||||||
static long TIME_UNIT = 24 * 60 * 60 * 1000L;// 一天
|
static long TIME_UNIT = 60 * 1000L;// 分钟
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查表是否
|
* 检查表是否
|
||||||
@ -31,8 +31,8 @@ public interface IPlayerDataDao {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
boolean setPlayerData(PlayerDataBean bean) throws Exception;
|
boolean setPlayerData(PlayerDataBean bean) throws Exception;
|
||||||
boolean setTime(String uuid, String packageName, int days) throws Exception;
|
boolean setTime(String uuid, String packageName, int time) throws Exception;
|
||||||
boolean addTime(String uuid, String packageName, int days) throws Exception;
|
boolean addTime(String uuid, String packageName, int time) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
|
@ -72,10 +72,10 @@ public class SqlManager {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean giveTime(String uuid, String packageName, int days) {
|
public boolean giveTime(String uuid, String packageName, int time) {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
try {
|
try {
|
||||||
if (pds.addTime(uuid, packageName, days)) {
|
if (pds.addTime(uuid, packageName, time)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -85,10 +85,10 @@ public class SqlManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setTime(String uuid, String packageName, int days) {
|
public boolean setTime(String uuid, String packageName, int time) {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
try {
|
try {
|
||||||
if (pds.setTime(uuid, packageName, days)) {
|
if (pds.setTime(uuid, packageName, time)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -42,7 +42,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean creatTable() throws Exception {
|
public boolean creatTable() throws Exception {
|
||||||
String sql = "CREATE TABLE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `uuid` VARCHAR (255) NOT NULL, `packageName` VARCHAR (255) NOT NULL, `serverId` VARCHAR (255), `expire` BIGINT NOT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `UUID_PACKAGE_SERVERID` (`uuid`, `packageName`, `serverId`));";
|
String sql = "CREATE TABLE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `uuid` VARCHAR (36) NOT NULL, `packageName` VARCHAR (100) NOT NULL, `serverId` VARCHAR (100), `expire` BIGINT NOT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `UUID_PACKAGE_SERVERID` (`uuid`, `packageName`, `serverId`)) ENGINE=InnoDB DEFAULT CHARSET=utf8; ";
|
||||||
try {
|
try {
|
||||||
getDB().query(sql);
|
getDB().query(sql);
|
||||||
return true;
|
return true;
|
||||||
@ -75,13 +75,13 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setTime(String uuid, String packageName, int days) throws Exception {
|
public boolean setTime(String uuid, String packageName, int time) throws Exception {
|
||||||
boolean global = uuid.startsWith("g:") ? true : false;
|
boolean global = uuid.startsWith("g:") ? true : false;
|
||||||
if (global) {
|
if (global) {
|
||||||
uuid = uuid.substring(2);
|
uuid = uuid.substring(2);
|
||||||
}
|
}
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
long addTime = days * TIME_UNIT;
|
long addTime = time * TIME_UNIT;
|
||||||
long expire = now + addTime;
|
long expire = now + addTime;
|
||||||
PlayerDataBean pdb = queryPlayerData(uuid, packageName);
|
PlayerDataBean pdb = queryPlayerData(uuid, packageName);
|
||||||
if (pdb == null) {
|
if (pdb == null) {
|
||||||
@ -100,13 +100,13 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addTime(String uuid, String packageName, int days) throws Exception {
|
public boolean addTime(String uuid, String packageName, int time) throws Exception {
|
||||||
boolean global = uuid.startsWith("g:") ? true : false;
|
boolean global = uuid.startsWith("g:") ? true : false;
|
||||||
if (global) {
|
if (global) {
|
||||||
uuid = uuid.substring(2);
|
uuid = uuid.substring(2);
|
||||||
}
|
}
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
long addTime = days * TIME_UNIT;
|
long addTime = time * TIME_UNIT;
|
||||||
long expire = now + addTime;
|
long expire = now + addTime;
|
||||||
PlayerDataBean pdb = queryPlayerData((global ? "g:" : "") + uuid, packageName);
|
PlayerDataBean pdb = queryPlayerData((global ? "g:" : "") + uuid, packageName);
|
||||||
if (pdb == null) {
|
if (pdb == null) {
|
||||||
@ -123,7 +123,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
|
|||||||
}
|
}
|
||||||
return setPlayerData(pdb);
|
return setPlayerData(pdb);
|
||||||
} else {
|
} else {
|
||||||
String sql = "UPDATE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` SET `expire`='" + addTime + "' WHERE (`id`='" + pdb.getId() + "');";
|
String sql = "UPDATE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` SET `expire`=`expire`+" + addTime + " WHERE (`id`='" + pdb.getId() + "');";
|
||||||
try {
|
try {
|
||||||
getDB().query(sql);
|
getDB().query(sql);
|
||||||
return true;
|
return true;
|
||||||
|
@ -70,9 +70,9 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setTime(String uuid, String packageName, int days) throws Exception {
|
public boolean setTime(String uuid, String packageName, int time) throws Exception {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
long addTime = days * TIME_UNIT;
|
long addTime = time * TIME_UNIT;
|
||||||
long expire = now + addTime;
|
long expire = now + addTime;
|
||||||
PlayerDataBean pdb = queryPlayerData(uuid, packageName);
|
PlayerDataBean pdb = queryPlayerData(uuid, packageName);
|
||||||
if (pdb == null) {
|
if (pdb == null) {
|
||||||
@ -85,9 +85,9 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addTime(String uuid, String packageName, int days) throws Exception {
|
public boolean addTime(String uuid, String packageName, int time) throws Exception {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
long addTime = days * TIME_UNIT;
|
long addTime = time * TIME_UNIT;
|
||||||
long expire = now + addTime;
|
long expire = now + addTime;
|
||||||
PlayerDataBean pdb = queryPlayerData(uuid, packageName);
|
PlayerDataBean pdb = queryPlayerData(uuid, packageName);
|
||||||
if (pdb == null) {
|
if (pdb == null) {
|
||||||
|
@ -218,6 +218,7 @@ public class PermissionPackageBean implements IConfigBean {
|
|||||||
long delay = -1;
|
long delay = -1;
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
PermissionPackageBean addPpb = new PermissionPackageBean();
|
PermissionPackageBean addPpb = new PermissionPackageBean();
|
||||||
|
addPpb.getGroups().add(PackagesCfg.DEFAULT_GROUP);
|
||||||
PermissionPackageBean subPpb = new PermissionPackageBean();
|
PermissionPackageBean subPpb = new PermissionPackageBean();
|
||||||
subPpb.getPermissions().addAll(PackagesCfg.allPermissions);
|
subPpb.getPermissions().addAll(PackagesCfg.allPermissions);
|
||||||
subPpb.getGroups().addAll(PackagesCfg.allGroups);
|
subPpb.getGroups().addAll(PackagesCfg.allGroups);
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
inventoryName: '&4===Permissions Packages==='
|
inventoryName: '&4===Permissions Packages==='
|
||||||
expirationDate: '&4Expiration date: {0}'
|
expirationDate: '&4Expiration date: {0}'
|
||||||
|
timeUnitD: 'day(s)'
|
||||||
|
timeUnitH: 'hour(s)'
|
||||||
|
timeUnitM: 'minute(s)'
|
||||||
msg:
|
msg:
|
||||||
parameterMismatch: '&4Parameter mismatch.'
|
parameterMismatch: '&4Parameter mismatch.'
|
||||||
daysParameterIncorrect: '&4The number of days is incorrect. Please enter a positive integer.'
|
timeParameterIncorrect: '&4The number of time is incorrect. Please enter a nonzero integer.'
|
||||||
|
timeUnitParameterIncorrect: '&4The number of time unit is incorrect. Please use d/h/m. (d=day, h=hour, m=minute)'
|
||||||
processing: '&2Please wait for processing...'
|
processing: '&2Please wait for processing...'
|
||||||
noData: '&4No data for packages.'
|
noData: '&4No data for packages.'
|
||||||
packageNum: '&4There are {0} kinds of permissions packages.'
|
packageNum: '&4There are {0} kinds of permissions packages.'
|
||||||
@ -13,12 +17,12 @@ msg:
|
|||||||
failSetPermission: '&4Failed to modify permissions. Please re-enter the server!'
|
failSetPermission: '&4Failed to modify permissions. Please re-enter the server!'
|
||||||
noFindPlayer: '&4Can not find player named &2{0}'
|
noFindPlayer: '&4Can not find player named &2{0}'
|
||||||
noFindPackage: '&4Can not find package named &2{0}'
|
noFindPackage: '&4Can not find package named &2{0}'
|
||||||
tellGivePackage: '&2{0} give you {1}days package of {2}'
|
tellGivePackage: '&2{0} give you {1} package of {2}'
|
||||||
givePackage: '&2Give the player {0} {1}days package of {2}'
|
givePackage: '&2Give the player {0} {1} package of {2}'
|
||||||
givePackageFail: '&4Failed to give players {0} {1}days package of {2}'
|
givePackageFail: '&4Failed to give players {0} {1} package of {2}'
|
||||||
tellSetPackage: '&2{0} set your package of {2} to {1}days'
|
tellSetPackage: '&2{0} set your package of {2} to {1}'
|
||||||
setPackage: '&2Set the player {0} {1}days package of {2}'
|
setPackage: '&2Set the player {0} {1} package of {2}'
|
||||||
setPackageFail: '&4Failed to set the player {0} {1}days package of {2}'
|
setPackageFail: '&4Failed to set the player {0} {1} package of {2}'
|
||||||
tellDelPackage: '&4{0} deleted your package of {1}'
|
tellDelPackage: '&4{0} deleted your package of {1}'
|
||||||
delPackage: '&2Remove package of {1}&2 for player {0}'
|
delPackage: '&2Remove package of {1}&2 for player {0}'
|
||||||
delPackageFail: '&4Failed to delete package of {1}&2 for player {0}'
|
delPackageFail: '&4Failed to delete package of {1}&2 for player {0}'
|
||||||
@ -29,3 +33,13 @@ msg:
|
|||||||
expirationDate: '{0}packages: {1}({2}), Expiration date: {3}'
|
expirationDate: '{0}packages: {1}({2}), Expiration date: {3}'
|
||||||
unknownPackage: 'Unknown Packages'
|
unknownPackage: 'Unknown Packages'
|
||||||
isExpirationDate: 'Your package: {0}({1})&r has expired.'
|
isExpirationDate: 'Your package: {0}({1})&r has expired.'
|
||||||
|
cmd:
|
||||||
|
help: '&6/{0} help \n&8 - Show commands.'
|
||||||
|
me: '&6/{0} me \n&8 - View self package.'
|
||||||
|
packages: '&6/{0} packages [packageName] \n&8 - View server packages.'
|
||||||
|
get: '&6/{0} get <playerName> \n&8 - View player packages.'
|
||||||
|
give: '&6/{0} give <playerName> <packageName> <time> <timeUnit:d/h/m> \n&8 - Give player package some time.(Time accumulation.) \n&8 timeUnit: d=day, h=hour, m=minute'
|
||||||
|
set: '&6/{0} set <playerName> <packageName> <time> <timeUnit:d/h/m> \n&8 - Set player package some time. \n&8 timeUnit: d=day, h=hour, m=minute'
|
||||||
|
remove: '&6/{0} remove <playerName> <packageName> [t/f] \n&8 - Remove player package.(t: Delete global package.)'
|
||||||
|
removeall: '&6/{0} removeall <playerName> [t/f] \n&8 - Remove player all package.(t: Delete global packages.)'
|
||||||
|
reload: '&6/{0} reload \n&8 - Reloads the config file.'
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
inventoryName: '&4===权限仓库==='
|
inventoryName: '&4===权限仓库==='
|
||||||
expirationDate: '&4到期时间: {0}.'
|
expirationDate: '&4到期时间: {0}.'
|
||||||
|
timeUnitD: '天'
|
||||||
|
timeUnitH: '小时'
|
||||||
|
timeUnitM: '分钟'
|
||||||
msg:
|
msg:
|
||||||
parameterMismatch: '&4参数不匹配.'
|
parameterMismatch: '&4参数不匹配.'
|
||||||
daysParameterIncorrect: '&4时间参数不正确,请输入正整数.'
|
timeParameterIncorrect: '&4时间参数不正确,请输入非零整数.'
|
||||||
|
timeUnitParameterIncorrect: '&4时间单位不正确. 请使用 d或h或m. (d=天, h=小时, m=分钟)'
|
||||||
processing: '&2执行中,请等待...'
|
processing: '&2执行中,请等待...'
|
||||||
noData: '&4暂时无权限包.'
|
noData: '&4暂时无权限包.'
|
||||||
packageNum: '&4共有{0}种权限包.'
|
packageNum: '&4共有{0}种权限包.'
|
||||||
@ -13,12 +17,12 @@ msg:
|
|||||||
failSetPermission: '&4修改权限失败, 请重新进入服务器!'
|
failSetPermission: '&4修改权限失败, 请重新进入服务器!'
|
||||||
noFindPlayer: '&4找不到名为&2{0}&4的玩家.'
|
noFindPlayer: '&4找不到名为&2{0}&4的玩家.'
|
||||||
noFindPackage: '&4找不到名为&2{0}&4的权限包.'
|
noFindPackage: '&4找不到名为&2{0}&4的权限包.'
|
||||||
tellGivePackage: '&2{0}给予你 {1}天的 {2}.'
|
tellGivePackage: '&2{0}给予你 {1}的 {2}.'
|
||||||
givePackage: '&2给予玩家 {0} {1}天的 {2}.'
|
givePackage: '&2给予玩家 {0} {1}的 {2}.'
|
||||||
givePackageFail: '&4未给予玩家 {0} {1}天的 {2}.'
|
givePackageFail: '&4未给予玩家 {0} {1}的 {2}.'
|
||||||
tellSetPackage: '&2{0}设置你 {1}天的 {2}.'
|
tellSetPackage: '&2{0}设置你 {1}的 {2}.'
|
||||||
setPackage: '&2设置玩家 {0} {1}天的 {2}.'
|
setPackage: '&2设置玩家 {0} {1}的 {2}.'
|
||||||
setPackageFail: '&4未设置玩家 {0} {1}天的 {2}.'
|
setPackageFail: '&4未设置玩家 {0} {1}的 {2}.'
|
||||||
tellDelPackage: '&4{0}删除了你的 {1}权限包.'
|
tellDelPackage: '&4{0}删除了你的 {1}权限包.'
|
||||||
delPackage: '&2删除玩家 {0} 的 {1}.'
|
delPackage: '&2删除玩家 {0} 的 {1}.'
|
||||||
delPackageFail: '&4未删除玩家 {0} 的 {1}.'
|
delPackageFail: '&4未删除玩家 {0} 的 {1}.'
|
||||||
@ -29,3 +33,13 @@ msg:
|
|||||||
expirationDate: '{0}权限包: {1}({2}), 到期时间: {3}'
|
expirationDate: '{0}权限包: {1}({2}), 到期时间: {3}'
|
||||||
unknownPackage: '未知权限包'
|
unknownPackage: '未知权限包'
|
||||||
isExpirationDate: '你的权限包: {0}({1})&r, 已到期.'
|
isExpirationDate: '你的权限包: {0}({1})&r, 已到期.'
|
||||||
|
cmd:
|
||||||
|
help: '&6/{0} help \n&8 - 显示所有命令.'
|
||||||
|
me: '&6/{0} me \n&8 - 显示自己的权限包.'
|
||||||
|
packages: '&6/{0} packages [权限包名] \n&8 - 查看服务器的(某个)权限包.'
|
||||||
|
get: '&6/{0} get <玩家> \n&8 - 查看玩家的权限包.'
|
||||||
|
give: '&6/{0} give <玩家> <权限包名> <时间> <单位:d或h或m> \n&8 - 给玩家一定时间的权限包.(时间累加.) \n&8 时间单位: d=天, h=小时, m=分钟'
|
||||||
|
set: '&6/{0} set <玩家> <权限包名> <时间> <单位:d或h或m> \n&8 - 重置玩家的权限包为一定时间. \n&8 时间单位: d=天, h=小时, m=分钟'
|
||||||
|
remove: '&6/{0} remove <玩家> <权限包名> [t/f] \n&8 - 删除玩家的某个权限包.(t: 删除跨服权限包.)'
|
||||||
|
removeall: '&6/{0} removeall <玩家> [t/f] \n&8 - 删除玩家所有的权限包.(t: 删除跨服权限包.)'
|
||||||
|
reload: '&6/{0} reload \n&8 - 重新加载插件配置.'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: PermissionsTime
|
name: PermissionsTime
|
||||||
version: 0.1.3-SNAPSHOT
|
version: 0.2.0-SNAPSHOT
|
||||||
main: gg.frog.mc.permissionstime.PluginMain
|
main: gg.frog.mc.permissionstime.PluginMain
|
||||||
author: GeekFrog
|
author: GeekFrog
|
||||||
softdepend:
|
softdepend:
|
||||||
@ -32,10 +32,10 @@ permissions:
|
|||||||
description: Reloads the config file.
|
description: Reloads the config file.
|
||||||
default: op
|
default: op
|
||||||
permissionstime.give:
|
permissionstime.give:
|
||||||
description: Give player package <time>day.
|
description: Give player package some time.
|
||||||
default: op
|
default: op
|
||||||
permissionstime.set:
|
permissionstime.set:
|
||||||
description: Set player package <time>day.
|
description: Set player package some time.
|
||||||
default: op
|
default: op
|
||||||
permissionstime.get:
|
permissionstime.get:
|
||||||
description: View player packages.
|
description: View player packages.
|
||||||
|
Loading…
Reference in New Issue
Block a user