mirror of
https://github.com/geekfrog/PermissionsTime.git
synced 2024-11-21 14:58:48 +00:00
修复BUG
称号功能完善
This commit is contained in:
parent
d9435886bc
commit
3a9169e30b
30
pom.xml
30
pom.xml
@ -34,10 +34,14 @@
|
||||
<id>bstats-repo</id>
|
||||
<url>http://repo.bstats.org/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>filoghost-repo</id>
|
||||
<url>https://ci.filoghost.me/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -58,17 +62,23 @@
|
||||
<version>1.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.0.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>lib.PatPeter.SQLibrary</groupId>
|
||||
<artifactId>SQLibrary</artifactId>
|
||||
<version>7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
<version>2.2.7-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>PermissionsTime-${project.version}</finalName>
|
||||
|
@ -2,7 +2,8 @@ package gg.frog.mc.permissionstime;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
@ -16,182 +17,196 @@ import gg.frog.mc.permissionstime.config.ConfigManager;
|
||||
import gg.frog.mc.permissionstime.config.PluginCfg;
|
||||
import gg.frog.mc.permissionstime.database.SqlManager;
|
||||
import gg.frog.mc.permissionstime.listener.MainListener;
|
||||
import gg.frog.mc.permissionstime.placeholder.TagPlaceholder;
|
||||
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.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
public class PluginMain extends JavaPlugin {
|
||||
|
||||
public String PLUGIN_NAME;
|
||||
public String PLUGIN_VERSION;
|
||||
public String PLUGIN_NAME_LOWER_CASE;
|
||||
public static final String DEPEND_PLUGIN = "SQLibrary,Vault";
|
||||
public static final Logger LOG = Logger.getLogger("Minecraft");
|
||||
public String PLUGIN_NAME;
|
||||
public String PLUGIN_VERSION;
|
||||
public String PLUGIN_NAME_LOWER_CASE;
|
||||
public static final String DEPEND_PLUGIN = "SQLibrary,Vault";
|
||||
public static final Logger LOG = Logger.getLogger("Minecraft");
|
||||
|
||||
private ConfigManager cm = null;
|
||||
private PluginMain pm = null;
|
||||
private SqlManager sm = null;
|
||||
private Permission permission = null;
|
||||
private Chat chat = null;
|
||||
private ConfigManager cm = null;
|
||||
private PluginMain pm = null;
|
||||
private SqlManager sm = null;
|
||||
private Permission permission = null;
|
||||
public static boolean enabledHdPlugin;
|
||||
public static boolean enabledPlaceholder;
|
||||
private static Map<String, OfflinePlayer> playerMap = new ConcurrentHashMap<>();
|
||||
|
||||
public PluginMain() {
|
||||
PLUGIN_NAME = getDescription().getName();
|
||||
PLUGIN_VERSION = getDescription().getVersion();
|
||||
PLUGIN_NAME_LOWER_CASE = PLUGIN_NAME.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
public PluginMain() {
|
||||
PLUGIN_NAME = getDescription().getName();
|
||||
PLUGIN_VERSION = getDescription().getVersion();
|
||||
PLUGIN_NAME_LOWER_CASE = PLUGIN_NAME.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
pm = this;
|
||||
cm = new ConfigManager(pm);
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "==============================="));
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX));
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " " + PLUGIN_NAME + " v" + PLUGIN_VERSION));
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " author:GeekFrog QQ:324747460"));
|
||||
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().getScheduler().runTask(pm, new Runnable() {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
pm = this;
|
||||
cm = new ConfigManager(pm);
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "==============================="));
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX));
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " " + PLUGIN_NAME + " v" + PLUGIN_VERSION));
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " author:GeekFrog QQ:324747460"));
|
||||
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().getScheduler().runTask(pm, new Runnable() {
|
||||
|
||||
public void run() {
|
||||
if (!checkPluginDepends()) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Startup failure!"));
|
||||
getServer().getPluginManager().disablePlugin(pm);
|
||||
} else {
|
||||
registerListeners();
|
||||
registerCommands();
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&2Startup successful!"));
|
||||
}
|
||||
if (PluginCfg.IS_METRICS) {
|
||||
try {
|
||||
new Metrics(pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
getServer().getScheduler().runTaskAsynchronously(pm, new UpdateCheck(pm));
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!checkPluginDepends()) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Startup failure!"));
|
||||
getServer().getPluginManager().disablePlugin(pm);
|
||||
} else {
|
||||
registerListeners();
|
||||
registerCommands();
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&2Startup successful!"));
|
||||
}
|
||||
if (PluginCfg.IS_METRICS) {
|
||||
try {
|
||||
new Metrics(pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
getServer().getScheduler().runTaskAsynchronously(pm, new UpdateCheck(pm));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册监听器 <br/>
|
||||
* 这里可以注册多个
|
||||
*/
|
||||
private void registerListeners() {
|
||||
pm.getServer().getPluginManager().registerEvents(new MainListener(pm), pm);
|
||||
}
|
||||
/**
|
||||
* 注册监听器 <br/>
|
||||
* 这里可以注册多个
|
||||
*/
|
||||
private void registerListeners() {
|
||||
pm.getServer().getPluginManager().registerEvents(new MainListener(pm), pm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册命令 <br/>
|
||||
* 这里可以注册多个,一般注册一个就够用
|
||||
*/
|
||||
private void registerCommands() {
|
||||
MainCommand mcmd = new MainCommand(pm);
|
||||
if (getDescription().getCommands().containsKey(PLUGIN_NAME_LOWER_CASE)) {
|
||||
getCommand(PLUGIN_NAME_LOWER_CASE).setExecutor(mcmd);
|
||||
}
|
||||
if (getDescription().getCommands().containsKey("pt")) {
|
||||
getCommand("pt").setExecutor(mcmd);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 注册命令 <br/>
|
||||
* 这里可以注册多个,一般注册一个就够用
|
||||
*/
|
||||
private void registerCommands() {
|
||||
MainCommand mcmd = new MainCommand(pm);
|
||||
if (getDescription().getCommands().containsKey(PLUGIN_NAME_LOWER_CASE)) {
|
||||
getCommand(PLUGIN_NAME_LOWER_CASE).setExecutor(mcmd);
|
||||
}
|
||||
if (getDescription().getCommands().containsKey("pt")) {
|
||||
getCommand("pt").setExecutor(mcmd);
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigManager getConfigManager() {
|
||||
return cm;
|
||||
}
|
||||
public ConfigManager getConfigManager() {
|
||||
return cm;
|
||||
}
|
||||
|
||||
public SqlManager getSqlManager() {
|
||||
return sm;
|
||||
}
|
||||
public SqlManager getSqlManager() {
|
||||
return sm;
|
||||
}
|
||||
|
||||
public Permission getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public Chat getChat() {
|
||||
return chat;
|
||||
public Permission getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
private boolean checkPluginDepends() {
|
||||
boolean needDepend = false;
|
||||
for (String name : DEPEND_PLUGIN.split(",")) {
|
||||
if (getServer().getPluginManager().getPlugin(name) == null) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Need depend plugins : " + name));
|
||||
needDepend = true;
|
||||
}
|
||||
}
|
||||
if (!needDepend && !setupPermissions()) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t hook vault permission"));
|
||||
needDepend = true;
|
||||
}
|
||||
if (!needDepend && !setupChat()) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t hook vault chat"));
|
||||
needDepend = true;
|
||||
}
|
||||
if (!needDepend && !setupDatabase()) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t setup database"));
|
||||
needDepend = true;
|
||||
}
|
||||
if (needDepend) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
boolean needDepend = false;
|
||||
for (String name : DEPEND_PLUGIN.split(",")) {
|
||||
if (!getServer().getPluginManager().isPluginEnabled(name)) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Need depend plugins : " + name + "."));
|
||||
needDepend = true;
|
||||
}
|
||||
}
|
||||
if (!needDepend && !setupPermissions()) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t hook vault permission."));
|
||||
needDepend = true;
|
||||
}
|
||||
if (!needDepend && !setupDatabase()) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t setup database."));
|
||||
needDepend = true;
|
||||
}
|
||||
enabledPlaceholder = Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
|
||||
if (!enabledPlaceholder) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&ePlaceholder is not installed or not enabled."));
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&eSome func will be disabled."));
|
||||
} else {
|
||||
boolean placeholdersHook = false;
|
||||
try {
|
||||
placeholdersHook = new TagPlaceholder(pm).register();
|
||||
} catch (Exception e) {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getServer().getServicesManager().unregisterAll(pm);
|
||||
Bukkit.getScheduler().cancelTasks(pm);
|
||||
try {
|
||||
sm.getDb().close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!placeholdersHook) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t hook placeholders"));
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4The placeholders '%permissionstime_displayname%' Cann''t use."));
|
||||
}
|
||||
}
|
||||
enabledHdPlugin = Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays");
|
||||
if (!enabledHdPlugin) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&eHolographicDisplays is not installed or not enabled."));
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&eSome func will be disabled."));
|
||||
}
|
||||
|
||||
private boolean setupPermissions() {
|
||||
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
permission = permissionProvider.getProvider();
|
||||
}
|
||||
return (permission != null);
|
||||
}
|
||||
if (needDepend) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean setupChat() {
|
||||
RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
|
||||
if (chatProvider != null) {
|
||||
chat = chatProvider.getProvider();
|
||||
}
|
||||
return (chat != null);
|
||||
}
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getServer().getServicesManager().unregisterAll(pm);
|
||||
Bukkit.getScheduler().cancelTasks(pm);
|
||||
try {
|
||||
sm.getDb().close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean setupDatabase() {
|
||||
sm = new SqlManager(pm);
|
||||
return sm.updateDatabase();
|
||||
}
|
||||
private boolean setupPermissions() {
|
||||
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
permission = permissionProvider.getProvider();
|
||||
}
|
||||
return (permission != null);
|
||||
}
|
||||
|
||||
public UUID getPlayerUUIDByName(String name) {
|
||||
OfflinePlayer p = getOfflinePlayer(name);
|
||||
if (p == null) {
|
||||
return null;
|
||||
} else {
|
||||
return p.getUniqueId();
|
||||
}
|
||||
}
|
||||
private boolean setupDatabase() {
|
||||
sm = new SqlManager(pm);
|
||||
return sm.updateDatabase();
|
||||
}
|
||||
|
||||
public OfflinePlayer getOfflinePlayer(String name) {
|
||||
for (OfflinePlayer p : getServer().getOfflinePlayers()) {
|
||||
if(p==null)
|
||||
continue;
|
||||
if (p.getName().equalsIgnoreCase(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public String getPlayerUUIDByName(String name) {
|
||||
OfflinePlayer p = getOfflinePlayer(name);
|
||||
if (p == null) {
|
||||
return null;
|
||||
} else {
|
||||
return p.getUniqueId().toString();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeFailLog(String content, Object... args) {
|
||||
FileUtil.writeOnFile(getDataFolder() + "/failure.log", "[" + StrUtil.nowTimeString() + "] " + MessageFormat.format(content, args));
|
||||
}
|
||||
public OfflinePlayer getOfflinePlayer(String name) {
|
||||
if (name != null) {
|
||||
OfflinePlayer p1 = playerMap.get(name);
|
||||
if (p1 != null)
|
||||
return p1;
|
||||
for (OfflinePlayer p2 : getServer().getOfflinePlayers()) {
|
||||
if (p2 == null)
|
||||
continue;
|
||||
if (p2.getName().equalsIgnoreCase(name)) {
|
||||
playerMap.put(name, p2);
|
||||
return p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void writeFailLog(String content, Object... args) {
|
||||
FileUtil.writeOnFile(getDataFolder() + "/failure.log", "[" + StrUtil.nowTimeString() + "] " + MessageFormat.format(content, args));
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ 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;
|
||||
@ -32,9 +31,9 @@ public class GetCmd implements Runnable {
|
||||
public void run() {
|
||||
if (args.length == 2) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
OfflinePlayer p = pm.getOfflinePlayer(args[1]);
|
||||
if (p != null) {
|
||||
List<PlayerDataBean> ps = sm.getTime(p.getUniqueId().toString());
|
||||
String uuid = pm.getPlayerUUIDByName(args[1]);
|
||||
if (uuid != null) {
|
||||
List<PlayerDataBean> ps = sm.getTime(uuid);
|
||||
if (ps.size() > 0) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NUM_OF_PACKAGES,
|
||||
args[1], ps.size()));
|
||||
|
@ -1,7 +1,6 @@
|
||||
package gg.frog.mc.permissionstime.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -18,90 +17,90 @@ import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
|
||||
public class GiveCmd implements Runnable {
|
||||
|
||||
private PluginMain pm;
|
||||
private SqlManager sm;
|
||||
private String[] args;
|
||||
private CommandSender sender;
|
||||
private PluginMain pm;
|
||||
private SqlManager sm;
|
||||
private String[] args;
|
||||
private CommandSender sender;
|
||||
|
||||
public GiveCmd(PluginMain pm, CommandSender sender, String[] args) {
|
||||
this.pm = pm;
|
||||
this.sm = pm.getSqlManager();
|
||||
this.sender = sender;
|
||||
this.args = args;
|
||||
}
|
||||
public GiveCmd(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 == 5) {
|
||||
String playerName = args[1];
|
||||
String packageName = args[2];
|
||||
String time = args[3];
|
||||
String unit = args[4];
|
||||
final String unitName;
|
||||
int minutes = 0;
|
||||
try {
|
||||
minutes = Integer.parseInt(time);
|
||||
if (minutes == 0) {
|
||||
throw new RuntimeException("not a nonzero integer.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
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;
|
||||
}
|
||||
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
|
||||
if (pack != null) {
|
||||
OfflinePlayer player = pm.getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
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, minutes)) {
|
||||
if (player.isOnline()) {
|
||||
Player p = player.getPlayer();
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = sm.getTime(player.getUniqueId().toString());
|
||||
PermissionPackageBean.reloadPlayerPermissions(player, pdbList, pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
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 + unitName, pack.getDisplayName()));
|
||||
}
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_GIVE_PACKAGE, playerName, time + unitName, pack.getDisplayName()));
|
||||
} else {
|
||||
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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 + unitName, pack.getDisplayName()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PACKAGE, packageName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_GIVE, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
if (args.length == 5) {
|
||||
String playerName = args[1];
|
||||
String packageName = args[2];
|
||||
String time = args[3];
|
||||
String unit = args[4];
|
||||
final String unitName;
|
||||
int minutes = 0;
|
||||
try {
|
||||
minutes = Integer.parseInt(time);
|
||||
if (minutes == 0) {
|
||||
throw new RuntimeException("not a nonzero integer.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
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;
|
||||
}
|
||||
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
|
||||
if (pack != null) {
|
||||
OfflinePlayer player = pm.getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
String uuid = player.getUniqueId().toString();
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid + "\n" + pack.toString() + "\n" + time + unitName + "."));
|
||||
}
|
||||
if (sm.giveTime(((PluginCfg.USE_MYSQL && pack.getGlobal()) ? "g:" : "") + uuid, packageName, minutes)) {
|
||||
if (player.isOnline()) {
|
||||
Player p = player.getPlayer();
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = sm.getTime(uuid);
|
||||
PermissionPackageBean.reloadPlayerPermissions(player, pdbList, pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
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 + unitName, pack.getDisplayName()));
|
||||
}
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_GIVE_PACKAGE, playerName, time + unitName, pack.getDisplayName()));
|
||||
} else {
|
||||
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pm.writeFailLog("Command execution failed. Give {0}({1}) {2} {3} Executor: {4}", playerName, uuid, time + unitName, pack.getDisplayName(), sender.getName());
|
||||
}
|
||||
});
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_GIVE_PACKAGE_FAIL, playerName, time + unitName, pack.getDisplayName()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PACKAGE, packageName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_GIVE, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package gg.frog.mc.permissionstime.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -16,34 +15,34 @@ import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
|
||||
public class MeCmd implements Runnable {
|
||||
|
||||
private PluginMain pm;
|
||||
private SqlManager sm;
|
||||
private String[] args;
|
||||
private CommandSender sender;
|
||||
private boolean isPlayer;
|
||||
private PluginMain pm;
|
||||
private SqlManager sm;
|
||||
private String[] args;
|
||||
private CommandSender sender;
|
||||
private boolean isPlayer;
|
||||
|
||||
public MeCmd(PluginMain pm, CommandSender sender, boolean isPlayer, String[] args) {
|
||||
this.pm = pm;
|
||||
this.sm = pm.getSqlManager();
|
||||
this.sender = sender;
|
||||
this.isPlayer = isPlayer;
|
||||
this.args = args;
|
||||
}
|
||||
public MeCmd(PluginMain pm, CommandSender sender, boolean isPlayer, String[] args) {
|
||||
this.pm = pm;
|
||||
this.sm = pm.getSqlManager();
|
||||
this.sender = sender;
|
||||
this.isPlayer = isPlayer;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (isPlayer) {
|
||||
if (args.length == 1) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
OfflinePlayer p = this.pm.getOfflinePlayer(sender.getName());
|
||||
List<PlayerDataBean> ps = sm.getTime(p.getUniqueId().toString());
|
||||
PlayerPermissionShow.show((Player) sender, ps);
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Only player can use this command."));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
if (isPlayer) {
|
||||
if (args.length == 1) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
String uuid = pm.getPlayerUUIDByName(sender.getName());
|
||||
List<PlayerDataBean> ps = sm.getTime(uuid);
|
||||
PlayerPermissionShow.show((Player) sender, ps);
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Only player can use this command."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package gg.frog.mc.permissionstime.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,61 +16,61 @@ import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
|
||||
public class RemoveAllCmd implements Runnable {
|
||||
|
||||
private PluginMain pm;
|
||||
private SqlManager sm;
|
||||
private String[] args;
|
||||
private CommandSender sender;
|
||||
private PluginMain pm;
|
||||
private SqlManager sm;
|
||||
private String[] args;
|
||||
private CommandSender sender;
|
||||
|
||||
public RemoveAllCmd(PluginMain pm, CommandSender sender, String[] args) {
|
||||
this.pm = pm;
|
||||
this.sm = pm.getSqlManager();
|
||||
this.sender = sender;
|
||||
this.args = args;
|
||||
}
|
||||
public RemoveAllCmd(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 || args.length == 3) {
|
||||
String playerName = args[1];
|
||||
boolean delGlobal = false;
|
||||
if (args.length == 3 && "t".equalsIgnoreCase(args[2]) && PluginCfg.USE_MYSQL) {
|
||||
delGlobal = true;
|
||||
}
|
||||
OfflinePlayer player = pm.getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid.toString()));
|
||||
}
|
||||
if (sm.removeAllTime((delGlobal ? "g:" : "") + uuid.toString())) {
|
||||
if (player.isOnline()) {
|
||||
Player p = player.getPlayer();
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = sm.getTime(player.getUniqueId().toString());
|
||||
PermissionPackageBean.reloadPlayerPermissions(player, pdbList, pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
||||
}
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TELL_DEL_ALL, sender.getName()));
|
||||
}
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DEL_ALL, playerName));
|
||||
} else {
|
||||
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pm.writeFailLog("Command execution failed. Delete {0}({1})'s all packages. Executor: {2}", playerName, player.getUniqueId().toString(), sender.getName());
|
||||
}
|
||||
});
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DEL_ALL_FAIL, playerName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_REMOVEALL, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
if (args.length == 2 || args.length == 3) {
|
||||
String playerName = args[1];
|
||||
boolean delGlobal = false;
|
||||
if (args.length == 3 && "t".equalsIgnoreCase(args[2]) && PluginCfg.USE_MYSQL) {
|
||||
delGlobal = true;
|
||||
}
|
||||
OfflinePlayer player = pm.getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
String uuid = player.getUniqueId().toString();
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid));
|
||||
}
|
||||
if (sm.removeAllTime((delGlobal ? "g:" : "") + uuid)) {
|
||||
if (player.isOnline()) {
|
||||
Player p = player.getPlayer();
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = sm.getTime(uuid);
|
||||
PermissionPackageBean.reloadPlayerPermissions(player, pdbList, pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
||||
}
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TELL_DEL_ALL, sender.getName()));
|
||||
}
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DEL_ALL, playerName));
|
||||
} else {
|
||||
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pm.writeFailLog("Command execution failed. Delete {0}({1})'s all packages. Executor: {2}", playerName, uuid, sender.getName());
|
||||
}
|
||||
});
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DEL_ALL_FAIL, playerName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_REMOVEALL, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package gg.frog.mc.permissionstime.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -18,67 +17,67 @@ import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
|
||||
public class RemoveCmd implements Runnable {
|
||||
|
||||
private PluginMain pm;
|
||||
private SqlManager sm;
|
||||
private String[] args;
|
||||
private CommandSender sender;
|
||||
private PluginMain pm;
|
||||
private SqlManager sm;
|
||||
private String[] args;
|
||||
private CommandSender sender;
|
||||
|
||||
public RemoveCmd(PluginMain pm, CommandSender sender, String[] args) {
|
||||
this.pm = pm;
|
||||
this.sm = pm.getSqlManager();
|
||||
this.sender = sender;
|
||||
this.args = args;
|
||||
}
|
||||
public RemoveCmd(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 == 3 || args.length == 4) {
|
||||
String playerName = args[1];
|
||||
String packageName = args[2];
|
||||
boolean delGlobal = false;
|
||||
if (args.length == 4 && "t".equalsIgnoreCase(args[3]) && PluginCfg.USE_MYSQL) {
|
||||
delGlobal = true;
|
||||
}
|
||||
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
|
||||
if (pack != null) {
|
||||
OfflinePlayer player = pm.getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid.toString() + "\n" + pack.toString()));
|
||||
}
|
||||
if (sm.removeTime((delGlobal ? "g:" : "") + uuid.toString(), packageName)) {
|
||||
if (player.isOnline()) {
|
||||
Player p = player.getPlayer();
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = sm.getTime(player.getUniqueId().toString());
|
||||
PermissionPackageBean.reloadPlayerPermissions(player, pdbList, pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
||||
}
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TELL_DEL_PACKAGE, sender.getName(), pack.getDisplayName()));
|
||||
}
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DEL_PACKAGE, playerName, pack.getDisplayName()));
|
||||
} else {
|
||||
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pm.writeFailLog("Command execution failed. Delete {0}({1})'s packages which be named {2} Executor: {3}", playerName, player.getUniqueId().toString(), pack.getDisplayName(), sender.getName());
|
||||
}
|
||||
});
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DEL_PACKAGE_FAIL, playerName, pack.getDisplayName()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PACKAGE, packageName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_REMOVE, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
if (args.length == 3 || args.length == 4) {
|
||||
String playerName = args[1];
|
||||
String packageName = args[2];
|
||||
boolean delGlobal = false;
|
||||
if (args.length == 4 && "t".equalsIgnoreCase(args[3]) && PluginCfg.USE_MYSQL) {
|
||||
delGlobal = true;
|
||||
}
|
||||
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
|
||||
if (pack != null) {
|
||||
OfflinePlayer player = pm.getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
String uuid = player.getUniqueId().toString();
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid + "\n" + pack.toString()));
|
||||
}
|
||||
if (sm.removeTime((delGlobal ? "g:" : "") + uuid, packageName)) {
|
||||
if (player.isOnline()) {
|
||||
Player p = player.getPlayer();
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = sm.getTime(uuid);
|
||||
PermissionPackageBean.reloadPlayerPermissions(player, pdbList, pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
||||
}
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TELL_DEL_PACKAGE, sender.getName(), pack.getDisplayName()));
|
||||
}
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DEL_PACKAGE, playerName, pack.getDisplayName()));
|
||||
} else {
|
||||
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pm.writeFailLog("Command execution failed. Delete {0}({1})'s packages which be named {2} Executor: {3}", playerName, uuid, pack.getDisplayName(), sender.getName());
|
||||
}
|
||||
});
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_DEL_PACKAGE_FAIL, playerName, pack.getDisplayName()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PACKAGE, packageName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_REMOVE, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package gg.frog.mc.permissionstime.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -18,90 +17,93 @@ import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
|
||||
public class SetCmd implements Runnable {
|
||||
|
||||
private PluginMain pm;
|
||||
private SqlManager sm;
|
||||
private String[] args;
|
||||
private CommandSender sender;
|
||||
private PluginMain pm;
|
||||
private SqlManager sm;
|
||||
private String[] args;
|
||||
private CommandSender sender;
|
||||
|
||||
public SetCmd(PluginMain pm, CommandSender sender, String[] args) {
|
||||
this.pm = pm;
|
||||
this.sm = pm.getSqlManager();
|
||||
this.sender = sender;
|
||||
this.args = args;
|
||||
}
|
||||
public SetCmd(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 == 5) {
|
||||
String playerName = args[1];
|
||||
String packageName = args[2];
|
||||
String time = args[3];
|
||||
String unit = args[4];
|
||||
final String unitName;
|
||||
int minutes = 0;
|
||||
try {
|
||||
minutes = Integer.parseInt(time);
|
||||
if (minutes == 0) {
|
||||
throw new RuntimeException("not a nonzero integer.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
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;
|
||||
}
|
||||
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
|
||||
if (pack != null) {
|
||||
OfflinePlayer player = pm.getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
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, minutes)) {
|
||||
if (player.isOnline()) {
|
||||
Player p = player.getPlayer();
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = sm.getTime(player.getUniqueId().toString());
|
||||
PermissionPackageBean.reloadPlayerPermissions(player, pdbList, pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
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 + unitName, pack.getDisplayName()));
|
||||
}
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_SET_PACKAGE, playerName, time + unitName, pack.getDisplayName()));
|
||||
} else {
|
||||
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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 + unitName, pack.getDisplayName()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PACKAGE, packageName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_SET, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
if (args.length == 5) {
|
||||
String playerName = args[1];
|
||||
String packageName = args[2];
|
||||
String time = args[3];
|
||||
String unit = args[4];
|
||||
final String unitName;
|
||||
int minutes = 0;
|
||||
try {
|
||||
minutes = Integer.parseInt(time);
|
||||
if (minutes == 0) {
|
||||
throw new RuntimeException("not a nonzero integer.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
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;
|
||||
}
|
||||
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
|
||||
if (pack != null) {
|
||||
OfflinePlayer player = pm.getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
String uuid = player.getUniqueId().toString();
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid + "\n" + pack.toString() + "\n" + time + unitName + " ."));
|
||||
}
|
||||
if (sm.setTime(((PluginCfg.USE_MYSQL && pack.getGlobal()) ? "g:" : "") + uuid, packageName, minutes)) {
|
||||
if (player.isOnline()) {
|
||||
Player p = player.getPlayer();
|
||||
if (p != null) {
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = sm.getTime(uuid);
|
||||
PermissionPackageBean.reloadPlayerPermissions(player, pdbList, pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
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 + unitName, pack.getDisplayName()));
|
||||
}
|
||||
|
||||
}
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_SET_PACKAGE, playerName, time + unitName, pack.getDisplayName()));
|
||||
} else {
|
||||
pm.getServer().getScheduler().runTask(pm, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pm.writeFailLog("Command execution failed. Set {0}({1}) {2} {3} Executor: {4}", playerName, uuid, time + unitName, pack.getDisplayName(), sender.getName());
|
||||
}
|
||||
});
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_SET_PACKAGE_FAIL, playerName, time + unitName, pack.getDisplayName()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, playerName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PACKAGE, packageName));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_SET, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
@ -58,7 +59,10 @@ public class TagCmd implements Runnable {
|
||||
}
|
||||
}
|
||||
OfflinePlayer player = pm.getOfflinePlayer(sender.getName());
|
||||
PlayerTagShow.show(player.getPlayer(), type, itemList);
|
||||
Player p = player.getPlayer();
|
||||
if (p != null) {
|
||||
PlayerTagShow.show(p, type, itemList);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
|
||||
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_TAG, pm.PLUGIN_NAME_LOWER_CASE));
|
||||
|
@ -11,119 +11,122 @@ import gg.frog.mc.permissionstime.utils.config.PluginConfig;
|
||||
*/
|
||||
public class LangCfg extends PluginConfig {
|
||||
|
||||
public static String INVENTORY_NAME = null;
|
||||
public static String TAG_INVENTORY_NAME = null;
|
||||
public static String EXPIRATION_TIME = null;
|
||||
public static String LEFT_TIME = 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 TIME_FOREVER = null;
|
||||
public static String TAG = null;
|
||||
public static String INVENTORY_NAME = null;
|
||||
public static String TAG_INVENTORY_NAME = null;
|
||||
public static String EXPIRATION_TIME = null;
|
||||
public static String LEFT_TIME = 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 TIME_FOREVER = null;
|
||||
public static String TAG = null;
|
||||
|
||||
public static String MSG_PARAMETER_MISMATCH = 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_NO_DATA = null;
|
||||
public static String MSG_PACKAGE_NUM = null;
|
||||
public static String MSG_PACKAGE_LIST = null;
|
||||
public static String MSG_PACKAGE_DETAIL = null;
|
||||
public static String MSG_NO_PERMISSION = null;
|
||||
public static String MSG_CONFIG_RELOADED = null;
|
||||
public static String MSG_FAIL_SET_PERMISSION = null;
|
||||
public static String MSG_NO_FIND_PLAYER = null;
|
||||
public static String MSG_NO_FIND_PACKAGE = null;
|
||||
public static String MSG_TELL_GIVE_PACKAGE = null;
|
||||
public static String MSG_GIVE_PACKAGE = null;
|
||||
public static String MSG_GIVE_PACKAGE_FAIL = null;
|
||||
public static String MSG_TELL_SET_PACKAGE = null;
|
||||
public static String MSG_SET_PACKAGE = null;
|
||||
public static String MSG_SET_PACKAGE_FAIL = null;
|
||||
public static String MSG_TELL_DEL_PACKAGE = null;
|
||||
public static String MSG_DEL_PACKAGE = null;
|
||||
public static String MSG_DEL_PACKAGE_FAIL = null;
|
||||
public static String MSG_TELL_DEL_ALL = null;
|
||||
public static String MSG_DEL_ALL = null;
|
||||
public static String MSG_DEL_ALL_FAIL = null;
|
||||
public static String MSG_NUM_OF_PACKAGES = null;
|
||||
public static String MSG_EXPIRATION_DATE = null;
|
||||
public static String MSG_UNKNOWN_PACKAGE = null;
|
||||
public static String MSG_IS_EXPIRATION_DATE = null;
|
||||
public static String MSG_FUNC_DISABLED = null;
|
||||
public static String MSG_TAG_SET_SUCCESS = null;
|
||||
public static String MSG_PARAMETER_MISMATCH = 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_NO_DATA = null;
|
||||
public static String MSG_NO_TAG_DATA = null;
|
||||
public static String MSG_PACKAGE_NUM = null;
|
||||
public static String MSG_PACKAGE_LIST = null;
|
||||
public static String MSG_PACKAGE_DETAIL = null;
|
||||
public static String MSG_NO_PERMISSION = null;
|
||||
public static String MSG_CONFIG_RELOADED = null;
|
||||
public static String MSG_FAIL_SET_PERMISSION = null;
|
||||
public static String MSG_NO_FIND_PLAYER = null;
|
||||
public static String MSG_NO_FIND_PACKAGE = null;
|
||||
public static String MSG_TELL_GIVE_PACKAGE = null;
|
||||
public static String MSG_GIVE_PACKAGE = null;
|
||||
public static String MSG_GIVE_PACKAGE_FAIL = null;
|
||||
public static String MSG_TELL_SET_PACKAGE = null;
|
||||
public static String MSG_SET_PACKAGE = null;
|
||||
public static String MSG_SET_PACKAGE_FAIL = null;
|
||||
public static String MSG_TELL_DEL_PACKAGE = null;
|
||||
public static String MSG_DEL_PACKAGE = null;
|
||||
public static String MSG_DEL_PACKAGE_FAIL = null;
|
||||
public static String MSG_TELL_DEL_ALL = null;
|
||||
public static String MSG_DEL_ALL = null;
|
||||
public static String MSG_DEL_ALL_FAIL = null;
|
||||
public static String MSG_NUM_OF_PACKAGES = null;
|
||||
public static String MSG_EXPIRATION_DATE = null;
|
||||
public static String MSG_UNKNOWN_PACKAGE = null;
|
||||
public static String MSG_IS_EXPIRATION_DATE = null;
|
||||
public static String MSG_FUNC_DISABLED = null;
|
||||
public static String MSG_TAG_SET_SUCCESS = null;
|
||||
|
||||
public static String CMD_HELP = null;
|
||||
public static String CMD_ME = null;
|
||||
public static String CMD_TAG = 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 static String CMD_HELP = null;
|
||||
public static String CMD_ME = null;
|
||||
public static String CMD_TAG = 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) {
|
||||
super(fileName, pm);
|
||||
}
|
||||
public LangCfg(String fileName, PluginMain pm) {
|
||||
super(fileName, pm);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {}
|
||||
@Override
|
||||
protected void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadToDo() {
|
||||
INVENTORY_NAME = getConfig().getString("inventoryName", "&4===Permissions Packages===");
|
||||
TAG_INVENTORY_NAME = getConfig().getString("tagInventoryName", "&4===Tag Packages===");
|
||||
EXPIRATION_TIME = getConfig().getString("expirationTime", "&4Expiration time: {0}");
|
||||
LEFT_TIME = getConfig().getString("leftTime", "&4Left time: About {0}{1} {2}{3} {4}{5}");
|
||||
TIME_UNIT_D = getConfig().getString("timeUnitD", "day(s)");
|
||||
TIME_UNIT_H = getConfig().getString("timeUnitH", "hour(s)");
|
||||
TIME_UNIT_M = getConfig().getString("timeUnitM", "minute(s)");
|
||||
TIME_FOREVER = getConfig().getString("timeForever", "Forever");
|
||||
TAG = getConfig().getString("tag", "Tag/Prefix");
|
||||
@Override
|
||||
protected void loadToDo() {
|
||||
INVENTORY_NAME = getConfig().getString("inventoryName", "&4===Permissions Packages===");
|
||||
TAG_INVENTORY_NAME = getConfig().getString("tagInventoryName", "&4===Tag Packages===");
|
||||
EXPIRATION_TIME = getConfig().getString("expirationTime", "&4Expiration time: {0}");
|
||||
LEFT_TIME = getConfig().getString("leftTime", "&4Left time: About {0}{1} {2}{3} {4}{5}");
|
||||
TIME_UNIT_D = getConfig().getString("timeUnitD", "day(s)");
|
||||
TIME_UNIT_H = getConfig().getString("timeUnitH", "hour(s)");
|
||||
TIME_UNIT_M = getConfig().getString("timeUnitM", "minute(s)");
|
||||
TIME_FOREVER = getConfig().getString("timeForever", "Forever");
|
||||
TAG = getConfig().getString("tag", "Tag/Prefix");
|
||||
|
||||
MSG_PARAMETER_MISMATCH = getConfig().getString("msg.parameterMismatch", "&4Parameter mismatch.");
|
||||
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_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_LIST = getConfig().getString("msg.packageList", "{0}packageName: {1}, displayName: {2}");
|
||||
MSG_PACKAGE_DETAIL = getConfig().getString("msg.packageDetail", "packageName: {0}, displayName: {1}&r\\nPermissions: {2}\\nGroups: {3}");
|
||||
MSG_NO_PERMISSION = getConfig().getString("msg.nopermission", "&4You do not have permission to do this.");
|
||||
MSG_CONFIG_RELOADED = getConfig().getString("msg.configReloaded", "&2Configuration overload is complete.");
|
||||
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_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} 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} package of {2}");
|
||||
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} 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_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_TELL_DEL_ALL = getConfig().getString("msg.tellDelAll", "&4{0} remove all your packages");
|
||||
MSG_DEL_ALL = getConfig().getString("msg.delAll", "&2Remove all packages for player {0}");
|
||||
MSG_DEL_ALL_FAIL = getConfig().getString("msg.delAllFail", "&4Failed to remove all packages for player {0}");
|
||||
MSG_NUM_OF_PACKAGES = getConfig().getString("msg.numOfPackages", "====={0} has {1} packages=====");
|
||||
MSG_EXPIRATION_DATE = getConfig().getString("msg.expirationDate", "{0}packages: {1}({2}), Expiration date: {3}, {4}");
|
||||
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_FUNC_DISABLED = getConfig().getString("msg.funcDisabled", "{0} functionality disabled.");
|
||||
MSG_TAG_SET_SUCCESS = getConfig().getString("msg.tagSetSuccess", "&2Tag Set Success.");
|
||||
MSG_PARAMETER_MISMATCH = getConfig().getString("msg.parameterMismatch", "&4Parameter mismatch.");
|
||||
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_NO_DATA = getConfig().getString("msg.noData", "&4No data for packages.");
|
||||
MSG_NO_TAG_DATA = getConfig().getString("msg.noTagData", "&4No data for tag packages.");
|
||||
MSG_PACKAGE_NUM = getConfig().getString("msg.packageNum", "&4There are {0} kinds of permissions packages.");
|
||||
MSG_PACKAGE_LIST = getConfig().getString("msg.packageList", "{0}packageName: {1}, displayName: {2}");
|
||||
MSG_PACKAGE_DETAIL = getConfig().getString("msg.packageDetail", "packageName: {0}, displayName: {1}&r\\nPermissions: {2}\\nGroups: {3}");
|
||||
MSG_NO_PERMISSION = getConfig().getString("msg.nopermission", "&4You do not have permission to do this.");
|
||||
MSG_CONFIG_RELOADED = getConfig().getString("msg.configReloaded", "&2Configuration overload is complete.");
|
||||
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_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} 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} package of {2}");
|
||||
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} 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_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_TELL_DEL_ALL = getConfig().getString("msg.tellDelAll", "&4{0} remove all your packages");
|
||||
MSG_DEL_ALL = getConfig().getString("msg.delAll", "&2Remove all packages for player {0}");
|
||||
MSG_DEL_ALL_FAIL = getConfig().getString("msg.delAllFail", "&4Failed to remove all packages for player {0}");
|
||||
MSG_NUM_OF_PACKAGES = getConfig().getString("msg.numOfPackages", "====={0} has {1} packages=====");
|
||||
MSG_EXPIRATION_DATE = getConfig().getString("msg.expirationDate", "{0}packages: {1}({2}), Expiration date: {3}, {4}");
|
||||
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_FUNC_DISABLED = getConfig().getString("msg.funcDisabled", "{0} functionality disabled.");
|
||||
MSG_TAG_SET_SUCCESS = getConfig().getString("msg.tagSetSuccess", "&2Tag Set Success.");
|
||||
|
||||
CMD_HELP = getConfig().getString("cmd.help", "/{0} help \\n&7 - Show commands.");
|
||||
CMD_ME = getConfig().getString("cmd.me", "&6/{0} me \\n&7 - View your packages.");
|
||||
CMD_TAG = getConfig().getString("cmd.tag", "&6/{0} tag <c/p/s> \\n&7 - View your color/prefix/suffix tags.");
|
||||
CMD_PACKAGES = getConfig().getString("cmd.packages", "&6/{0} packages [packageName] \\n&7 - View packages.");
|
||||
CMD_GET = getConfig().getString("cmd.get", "&6/{0} get <playerName> \\n&7 - View player packages.");
|
||||
CMD_GIVE = getConfig().getString("cmd.give", "&6/{0} give <playerName> <packageName> <time> <timeUnit:d/h/m> \\n&7 - Give player package some time. (Time accumulation.) \\n&7 timeUnit: d=day, h=hour, m=minute");
|
||||
CMD_SET = getConfig().getString("cmd.set", "&6/{0} set <playerName> <packageName> <time> <timeUnit:d/h/m> \\n&7 - Set player package some time. \\n&7 timeUnit: d=day, h=hour, m=minute");
|
||||
CMD_REMOVE = getConfig().getString("cmd.remove", "&6/{0} remove <playerName> <packageName> [t/f] \\n&7 - Remove player package. (t: Delete global package.)");
|
||||
CMD_REMOVEALL = getConfig().getString("cmd.removeall", "&6/{0} removeall <playerName> [t/f] \\n&7 - Remove player all package. (t: Delete global packages.)");
|
||||
CMD_RELOAD = getConfig().getString("cmd.reload", "&6/{0} reload \\n&7 - Reloads the config file.");
|
||||
}
|
||||
CMD_HELP = getConfig().getString("cmd.help", "/{0} help \\n&7 - Show commands.");
|
||||
CMD_ME = getConfig().getString("cmd.me", "&6/{0} me \\n&7 - View your packages.");
|
||||
CMD_TAG = getConfig().getString("cmd.tag", "&6/{0} tag <c/p/s> \\n&7 - View your color/prefix/suffix tags.");
|
||||
CMD_PACKAGES = getConfig().getString("cmd.packages", "&6/{0} packages [packageName] \\n&7 - View packages.");
|
||||
CMD_GET = getConfig().getString("cmd.get", "&6/{0} get <playerName> \\n&7 - View player packages.");
|
||||
CMD_GIVE = getConfig().getString("cmd.give", "&6/{0} give <playerName> <packageName> <time> <timeUnit:d/h/m> \\n&7 - Give player package some time. (Time accumulation.) \\n&7 timeUnit: d=day, h=hour, m=minute");
|
||||
CMD_SET = getConfig().getString("cmd.set", "&6/{0} set <playerName> <packageName> <time> <timeUnit:d/h/m> \\n&7 - Set player package some time. \\n&7 timeUnit: d=day, h=hour, m=minute");
|
||||
CMD_REMOVE = getConfig().getString("cmd.remove", "&6/{0} remove <playerName> <packageName> [t/f] \\n&7 - Remove player package. (t: Delete global package.)");
|
||||
CMD_REMOVEALL = getConfig().getString("cmd.removeall", "&6/{0} removeall <playerName> [t/f] \\n&7 - Remove player all package. (t: Delete global packages.)");
|
||||
CMD_RELOAD = getConfig().getString("cmd.reload", "&6/{0} reload \\n&7 - Reloads the config file.");
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,14 @@ import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
import gg.frog.mc.permissionstime.model.cfg.PlayerTagBean;
|
||||
import gg.frog.mc.permissionstime.model.PlayerTagBean;
|
||||
import gg.frog.mc.permissionstime.model.cfg.TagPackageBean;
|
||||
import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
import gg.frog.mc.permissionstime.utils.config.PluginConfig;
|
||||
@ -23,6 +26,8 @@ public class TagNameCfg extends PluginConfig {
|
||||
public static String DEFAULT_NAMECOLOR = null;
|
||||
public static String DEFAULT_PREFIX = null;
|
||||
public static String DEFAULT_SUFFIX = null;
|
||||
public static boolean USE_HD_PLUGIN = false;
|
||||
public static Integer REFRESH_TAG_TIME = null;
|
||||
public static Map<String, TagPackageBean> PACKAGES = new ConcurrentHashMap<>();
|
||||
|
||||
public static Map<String, List<ItemStack>> NAMECOLOR_ITEMS = new ConcurrentHashMap<>();
|
||||
@ -35,6 +40,10 @@ public class TagNameCfg extends PluginConfig {
|
||||
|
||||
public static Map<String, PlayerTagBean> PLAYER_TAG = new ConcurrentHashMap<>();
|
||||
|
||||
public static Scoreboard scoreboard = null;
|
||||
|
||||
private BukkitTask task = null;
|
||||
|
||||
public enum TagType {
|
||||
NAMECOLOR_TYPE, PREFIX_TYPE, SUFFIX_TYPE
|
||||
}
|
||||
@ -52,12 +61,15 @@ public class TagNameCfg extends PluginConfig {
|
||||
DEFAULT_NAMECOLOR = setGetDefault("defaultNamecolor", "");
|
||||
DEFAULT_PREFIX = setGetDefault("defaultPrefix", "");
|
||||
DEFAULT_SUFFIX = setGetDefault("defaultSuffix", "");
|
||||
USE_HD_PLUGIN = setGetDefault("useHdPlugin", false);
|
||||
REFRESH_TAG_TIME = setGetDefault("refreshTagTime", -1);
|
||||
PACKAGES = getObjMap("packages", TagPackageBean.class);
|
||||
saveObj("packages", PACKAGES);
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
System.out.println("defaultNamecolor:" + DEFAULT_NAMECOLOR);
|
||||
System.out.println("defaultPrefix:" + DEFAULT_PREFIX);
|
||||
System.out.println("defaultSuffix:" + DEFAULT_SUFFIX);
|
||||
System.out.println("useHdPlugin:" + USE_HD_PLUGIN);
|
||||
for (Entry<String, TagPackageBean> p : PACKAGES.entrySet()) {
|
||||
System.out.println(p.getKey() + ":" + p.getValue());
|
||||
}
|
||||
@ -70,6 +82,8 @@ public class TagNameCfg extends PluginConfig {
|
||||
PREFIX_PERMISSIONS.clear();
|
||||
SUFFIX_PERMISSIONS.clear();
|
||||
|
||||
PLAYER_TAG.clear();
|
||||
|
||||
for (Entry<String, TagPackageBean> e : PACKAGES.entrySet()) {
|
||||
List<ItemStack> items = getTagItem(TagType.NAMECOLOR_TYPE, e.getValue());
|
||||
if (NAMECOLOR_ITEMS.containsKey(e.getValue().getPermissions())) {
|
||||
@ -90,6 +104,25 @@ public class TagNameCfg extends PluginConfig {
|
||||
SUFFIX_ITEMS.put(e.getValue().getPermissions(), items);
|
||||
}
|
||||
}
|
||||
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
}
|
||||
refreshTagTask();
|
||||
}
|
||||
|
||||
private void refreshTagTask() {
|
||||
for (Player player : pm.getServer().getOnlinePlayers()) {
|
||||
PlayerTagBean.initPlayerTag(player, pm);
|
||||
}
|
||||
if (REFRESH_TAG_TIME > 0) {
|
||||
task = pm.getServer().getScheduler().runTaskLaterAsynchronously(pm, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
refreshTagTask();
|
||||
}
|
||||
}, REFRESH_TAG_TIME * 20);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ItemStack> getTagItem(TagType tagType, TagPackageBean tpb) {
|
||||
|
@ -14,126 +14,133 @@ import lib.PatPeter.SQLibrary.SQLite;
|
||||
|
||||
public class SqlManager {
|
||||
|
||||
private PluginMain pm;
|
||||
private Database db = null;
|
||||
private IPlayerDataDao pds = null;
|
||||
private PluginMain pm;
|
||||
private Database db = null;
|
||||
private IPlayerDataDao pds = null;
|
||||
|
||||
public SqlManager(PluginMain pm) {
|
||||
this.pm = pm;
|
||||
}
|
||||
public SqlManager(PluginMain pm) {
|
||||
this.pm = pm;
|
||||
}
|
||||
|
||||
public Database getDb() {
|
||||
return db;
|
||||
}
|
||||
public Database getDb() {
|
||||
return db;
|
||||
}
|
||||
|
||||
public boolean updateDatabase() {
|
||||
if (db != null) {
|
||||
db.close();
|
||||
}
|
||||
if (PluginCfg.USE_MYSQL) {
|
||||
db = new MySQL(PluginMain.LOG, "[" + pm.PLUGIN_NAME + "] ", PluginCfg.SQL_HOSTNAME, PluginCfg.SQL_PORT, PluginCfg.SQL_DATABASE, PluginCfg.SQL_USERNAME, PluginCfg.SQL_PASSWORD);
|
||||
pds = new MySQLPlayerDataDao(pm, this);
|
||||
} else {
|
||||
db = new SQLite(PluginMain.LOG, "[" + pm.PLUGIN_NAME + "] ", pm.getDataFolder().getAbsolutePath(), "playerData", ".db");
|
||||
pds = new SqlitePlayerDataDao(pm, this);
|
||||
}
|
||||
if (db.open()) {
|
||||
try {
|
||||
if (!pds.tableExist()) {
|
||||
pds.creatTable();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean updateDatabase() {
|
||||
if (db != null) {
|
||||
db.close();
|
||||
}
|
||||
if (PluginCfg.USE_MYSQL) {
|
||||
db = new MySQL(PluginMain.LOG, "[" + pm.PLUGIN_NAME + "] ", PluginCfg.SQL_HOSTNAME, PluginCfg.SQL_PORT, PluginCfg.SQL_DATABASE, PluginCfg.SQL_USERNAME, PluginCfg.SQL_PASSWORD);
|
||||
pds = new MySQLPlayerDataDao(pm, this);
|
||||
} else {
|
||||
db = new SQLite(PluginMain.LOG, "[" + pm.PLUGIN_NAME + "] ", pm.getDataFolder().getAbsolutePath(), "playerData", ".db");
|
||||
pds = new SqlitePlayerDataDao(pm, this);
|
||||
}
|
||||
if (db.open()) {
|
||||
try {
|
||||
if (!pds.tableExist()) {
|
||||
pds.creatTable();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<PlayerDataBean> getAllTime(String uuid) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
return pds.queryPlayerData(uuid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
public List<PlayerDataBean> getAllTime(String uuid) {
|
||||
if (uuid != null)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
return pds.queryPlayerData(uuid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<PlayerDataBean> getTime(String uuid) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
return pds.queryNotExpirePlayerData(uuid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
public List<PlayerDataBean> getTime(String uuid) {
|
||||
if (uuid != null)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
return pds.queryNotExpirePlayerData(uuid);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean giveTime(String uuid, String packageName, int time) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
if (pds.addTime(uuid, packageName, time)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public boolean setTime(String uuid, String packageName, int time) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
if (pds.setTime(uuid, packageName, time)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean giveTime(String uuid, String packageName, int time) {
|
||||
if (uuid != null)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
if (pds.addTime(uuid, packageName, time)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeTime(String uuid, String packageName) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
if (pds.delPlayData(uuid, packageName)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean setTime(String uuid, String packageName, int time) {
|
||||
if (uuid != null)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
if (pds.setTime(uuid, packageName, time)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeAllTime(String uuid) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
if (pds.delPlayData(uuid)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean removeTime(String uuid, String packageName) {
|
||||
if (uuid != null)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
if (pds.delPlayData(uuid, packageName)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean delById(Long id) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
if (pds.delPlayData(id)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean removeAllTime(String uuid) {
|
||||
if (uuid != null)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
if (pds.delPlayData(uuid)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean delById(Long id) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
if (pds.delPlayData(id)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package gg.frog.mc.permissionstime.gui;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -12,37 +12,36 @@ import gg.frog.mc.permissionstime.config.LangCfg;
|
||||
import gg.frog.mc.permissionstime.config.PluginCfg;
|
||||
import gg.frog.mc.permissionstime.config.TagNameCfg;
|
||||
import gg.frog.mc.permissionstime.config.TagNameCfg.TagType;
|
||||
import gg.frog.mc.permissionstime.model.cfg.PlayerTagBean;
|
||||
import gg.frog.mc.permissionstime.model.PlayerTagBean;
|
||||
import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
|
||||
public class PlayerTagShow {
|
||||
|
||||
public static void show(Player p, TagType tagType, List<ItemStack> itemList) {
|
||||
public static void show(OfflinePlayer p, TagType tagType, List<ItemStack> itemList) {
|
||||
Inventory inventory = null;
|
||||
int size = 0;
|
||||
if (itemList.size() > 0) {
|
||||
inventory = Bukkit.createInventory(null,
|
||||
(itemList.size() % 9 == 0 ? itemList.size() : (itemList.size() / 9 + 1) * 9),
|
||||
StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "&r&5&9&2&0&r"));
|
||||
inventory = Bukkit.createInventory(null, (itemList.size() % 9 == 0 ? itemList.size() : (itemList.size() / 9 + 1) * 9), StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "&r&5&9&2&0&r"));
|
||||
String uuid = p.getUniqueId().toString();
|
||||
PlayerTagBean playerTag = null;
|
||||
if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
|
||||
playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
|
||||
playerTag = playerTag.clone();
|
||||
if(playerTag != null) {
|
||||
if (playerTag != null) {
|
||||
for (ItemStack item : itemList) {
|
||||
ItemStack tItem = item.clone();
|
||||
ItemMeta meta = tItem.getItemMeta();
|
||||
List<String> lores = meta.getLore();
|
||||
String tag = lores.get(5);
|
||||
if(tagType == TagType.NAMECOLOR_TYPE) {
|
||||
if (tagType == TagType.NAMECOLOR_TYPE) {
|
||||
meta.setDisplayName(meta.getDisplayName() + p.getName());
|
||||
playerTag.setNamecolor(tag);
|
||||
}else if(tagType == TagType.PREFIX_TYPE) {
|
||||
playerTag.setPrefix(tag);
|
||||
}else if(tagType == TagType.SUFFIX_TYPE) {
|
||||
playerTag.setSuffix(tag);
|
||||
}
|
||||
lores.set(1,"效果展示: "+playerTag.getDisplayNameStr(p));
|
||||
} else if (tagType == TagType.PREFIX_TYPE) {
|
||||
playerTag.setPrefix(tag);
|
||||
} else if (tagType == TagType.SUFFIX_TYPE) {
|
||||
playerTag.setSuffix(tag);
|
||||
}
|
||||
lores.set(1, "效果展示: " + playerTag.getDisplayNameStr(p.getPlayer()));
|
||||
meta.setLore(lores);
|
||||
tItem.setItemMeta(meta);
|
||||
inventory.addItem(tItem);
|
||||
@ -52,9 +51,9 @@ public class PlayerTagShow {
|
||||
}
|
||||
}
|
||||
if (inventory != null && size > 0) {
|
||||
p.openInventory(inventory);
|
||||
p.getPlayer().openInventory(inventory);
|
||||
} else {
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA));
|
||||
p.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_TAG_DATA));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ import gg.frog.mc.permissionstime.PluginMain;
|
||||
import gg.frog.mc.permissionstime.config.LangCfg;
|
||||
import gg.frog.mc.permissionstime.config.PluginCfg;
|
||||
import gg.frog.mc.permissionstime.config.TagNameCfg;
|
||||
import gg.frog.mc.permissionstime.model.PlayerTagBean;
|
||||
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
|
||||
import gg.frog.mc.permissionstime.model.cfg.PlayerTagBean;
|
||||
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
|
||||
import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
|
||||
@ -35,23 +35,15 @@ public class MainListener implements Listener {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = pm.getSqlManager().getTime(event.getPlayer().getUniqueId().toString());
|
||||
String uuid = pm.getPlayerUUIDByName(event.getPlayer().getName());
|
||||
List<PlayerDataBean> pdbList = pm.getSqlManager().getTime(uuid);
|
||||
PermissionPackageBean.reloadPlayerPermissions(event.getPlayer(), pdbList, pm, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
event.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
||||
}
|
||||
if (PluginCfg.TAG_SYSTEM) {
|
||||
String uuid = event.getPlayer().getUniqueId().toString();
|
||||
PlayerTagBean playerTag = null;
|
||||
if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
|
||||
playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
|
||||
playerTag.setPlayerDisplayName(event.getPlayer());
|
||||
} else {
|
||||
playerTag = new PlayerTagBean("playerTag/" + uuid + ".yml", pm);
|
||||
playerTag.setPlayerDisplayName(event.getPlayer(), true);
|
||||
}
|
||||
TagNameCfg.PLAYER_TAG.put(uuid, playerTag);
|
||||
PlayerTagBean.initPlayerTag(event.getPlayer(), pm);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
@ -1,12 +1,8 @@
|
||||
package gg.frog.mc.permissionstime.model.cfg;
|
||||
package gg.frog.mc.permissionstime.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
@ -30,6 +26,8 @@ public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneabl
|
||||
private String prefix;
|
||||
// 后缀
|
||||
private String suffix;
|
||||
// 当前显示的名称
|
||||
private String displayName;
|
||||
|
||||
public PlayerTagBean(String fileName, PluginMain pm) {
|
||||
super(fileName, pm);
|
||||
@ -57,6 +55,18 @@ public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneabl
|
||||
super.saveConfig();
|
||||
}
|
||||
|
||||
public static void initPlayerTag(Player player, PluginMain pm) {
|
||||
String uuid = pm.getPlayerUUIDByName(player.getName());
|
||||
PlayerTagBean playerTag = null;
|
||||
if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
|
||||
playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
|
||||
} else {
|
||||
playerTag = new PlayerTagBean("playerTag/" + uuid + ".yml", pm);
|
||||
TagNameCfg.PLAYER_TAG.put(uuid, playerTag);
|
||||
}
|
||||
playerTag.setPlayerDisplayName(player, true);
|
||||
}
|
||||
|
||||
public void setPlayerDisplayName(Player player) {
|
||||
setPlayerDisplayName(player, false);
|
||||
}
|
||||
@ -105,31 +115,59 @@ public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneabl
|
||||
}
|
||||
}
|
||||
if (forceSet || namecolor_flag || prefix_flag || suffix_flag) {
|
||||
Scoreboard scoreboard = pm.getServer().getScoreboardManager().getNewScoreboard();
|
||||
Team team = scoreboard.getTeam(player.getName());
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(player.getName());
|
||||
}
|
||||
team.setPrefix(StrUtil.messageFormat(player, "&r" + prefix + "&r" + namecolor + "&r"));
|
||||
team.setSuffix(StrUtil.messageFormat(player, "&r" + suffix + "&r"));
|
||||
team.addEntry(player.getName());
|
||||
player.setScoreboard(scoreboard);
|
||||
List<World> worlds = pm.getServer().getWorlds();
|
||||
for (World world : worlds) {
|
||||
pm.getChat().setPlayerInfoString(world.getName(), player, "prefix", StrUtil.messageFormat(player, "&r" + prefix + "&r" + namecolor + "&r"));
|
||||
pm.getChat().setPlayerInfoString(world.getName(), player, "suffix", StrUtil.messageFormat(player, "&r" + suffix + "&r"));
|
||||
}
|
||||
player.setDisplayName(getDisplayNameStr(player));
|
||||
displayName = getDisplayNameStr(player);
|
||||
player.setDisplayName(displayName);
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
System.out.println("PlayerTagBean:" + playerTag);
|
||||
}
|
||||
if (!TagNameCfg.USE_HD_PLUGIN) {
|
||||
try {
|
||||
if (TagNameCfg.scoreboard == null) {
|
||||
TagNameCfg.scoreboard = pm.getServer().getScoreboardManager().getNewScoreboard();
|
||||
}
|
||||
Team team = TagNameCfg.scoreboard.getTeam(player.getName());
|
||||
if (team == null) {
|
||||
team = TagNameCfg.scoreboard.registerNewTeam(player.getName());
|
||||
}
|
||||
String teamPrefix = StrUtil.messageFormat(player, prefix + "&r" + namecolor);
|
||||
if (PluginCfg.IS_DEBUG)
|
||||
System.out.println(teamPrefix);
|
||||
teamPrefix = teamPrefix.length() > 16 ? (teamPrefix.substring(0, 7) + ".." + teamPrefix.substring(teamPrefix.length() - 7)) : teamPrefix;
|
||||
if (PluginCfg.IS_DEBUG)
|
||||
System.out.println(teamPrefix);
|
||||
team.setPrefix(teamPrefix);
|
||||
String teamSuffix = StrUtil.messageFormat(player, "&r" + suffix);
|
||||
if (PluginCfg.IS_DEBUG)
|
||||
System.out.println(teamSuffix);
|
||||
teamSuffix = teamSuffix.length() > 16 ? (teamSuffix.substring(0, 7) + ".." + teamSuffix.substring(teamSuffix.length() - 7)) : teamSuffix;
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
System.out.println(teamSuffix);
|
||||
}
|
||||
team.setSuffix(teamSuffix);
|
||||
team.addEntry(player.getName());
|
||||
player.setScoreboard(TagNameCfg.scoreboard);
|
||||
if (PluginCfg.IS_DEBUG)
|
||||
for (Team t : TagNameCfg.scoreboard.getTeams()) {
|
||||
System.out.println(t.getPrefix());
|
||||
System.out.println(t.getSuffix());
|
||||
for (String e : t.getEntries()) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
//TODO
|
||||
//player.setCustomNameVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getDisplayNameStr(Player player) {
|
||||
return StrUtil.messageFormat(player, prefix + namecolor + player.getName() + suffix + "&r");
|
||||
return StrUtil.messageFormat(player, "&r" + prefix + "&r" + namecolor + player.getName() + "&r" + suffix + "&r");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -167,6 +205,10 @@ public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneabl
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YamlConfiguration toConfig() {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
@ -11,7 +11,6 @@ import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
@ -153,69 +152,69 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
return "PermissionPackageBean [displayName=" + displayName + ", id=" + id + ", type=" + type + ", glowing=" + glowing + ", lores=" + lores + ", global=" + global + ", permissions=" + permissions + ", groups=" + groups + ", expireCommands=" + expireCommands + "]";
|
||||
}
|
||||
|
||||
private void givePlayer(OfflinePlayer player, Server server, Permission permission) {
|
||||
private void givePlayer(OfflinePlayer player, Server server, Permission permissionApi) {
|
||||
List<World> worlds = server.getWorlds();
|
||||
for (String pem : permissions) {
|
||||
for (String pem : this.permissions) {
|
||||
String[] args = pem.split(":");
|
||||
pem = args[0];
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String worldName = args[i];
|
||||
permission.playerAdd(worldName, player, pem);
|
||||
permissionApi.playerAdd(worldName, player, pem);
|
||||
}
|
||||
} else {
|
||||
for (World world : worlds) {
|
||||
String worldName = world.getName();
|
||||
permission.playerAdd(worldName, player, pem);
|
||||
permissionApi.playerAdd(worldName, player, pem);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String groupName : groups) {
|
||||
for (String groupName : this.groups) {
|
||||
String[] args = groupName.split(":");
|
||||
groupName = args[0];
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String worldName = args[i];
|
||||
permission.playerAddGroup(worldName, player, groupName);
|
||||
permissionApi.playerAddGroup(worldName, player, groupName);
|
||||
}
|
||||
} else {
|
||||
for (World world : worlds) {
|
||||
String worldName = world.getName();
|
||||
permission.playerAddGroup(worldName, player, groupName);
|
||||
permissionApi.playerAddGroup(worldName, player, groupName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clearPlayer(OfflinePlayer player, Server server, Permission permission) {
|
||||
private void clearPlayer(OfflinePlayer player, Server server, Permission permissionApi) {
|
||||
List<World> worlds = server.getWorlds();
|
||||
for (String pem : permissions) {
|
||||
for (String pem : this.permissions) {
|
||||
String[] args = pem.split(":");
|
||||
pem = args[0];
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String worldName = args[i];
|
||||
permission.playerRemove(worldName, player, pem);
|
||||
permissionApi.playerRemove(worldName, player, pem);
|
||||
}
|
||||
} else {
|
||||
for (World world : worlds) {
|
||||
String worldName = world.getName();
|
||||
permission.playerRemove(worldName, player, pem);
|
||||
permissionApi.playerRemove(worldName, player, pem);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String groupName : groups) {
|
||||
for (String groupName : this.groups) {
|
||||
String[] args = groupName.split(":");
|
||||
groupName = args[0];
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String worldName = args[i];
|
||||
permission.playerRemoveGroup(worldName, player, groupName);
|
||||
permissionApi.playerRemoveGroup(worldName, player, groupName);
|
||||
}
|
||||
} else {
|
||||
for (World world : worlds) {
|
||||
String worldName = world.getName();
|
||||
permission.playerRemoveGroup(worldName, player, groupName);
|
||||
permissionApi.playerRemoveGroup(worldName, player, groupName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -268,20 +267,28 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
addPpb.givePlayer(player, plugin.getServer(), plugin.getPermission());
|
||||
}
|
||||
checkExpire(player, plugin);
|
||||
BukkitTask task = taskMap.get(player.getUniqueId().toString());
|
||||
String uuid = player.getUniqueId().toString();
|
||||
BukkitTask task = taskMap.get(uuid);
|
||||
if (pdbList.size() > 0) {
|
||||
delay = (delay / 1000 + 1) * 20;// 1秒=20ticks
|
||||
task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<PlayerDataBean> tpdbList = plugin.getSqlManager().getTime(player.getUniqueId().toString());
|
||||
List<PlayerDataBean> tpdbList = plugin.getSqlManager().getTime(uuid);
|
||||
reloadPlayerPermissions(player, tpdbList, plugin);
|
||||
}
|
||||
}, delay);
|
||||
taskMap.put(player.getUniqueId().toString(), task);
|
||||
taskMap.put(uuid, task);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理玩家所有权限包中涉及的权限
|
||||
*
|
||||
* @param player
|
||||
* @param plugin
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void delPlayerAllPermissions(OfflinePlayer player, PluginMain plugin) throws Exception {
|
||||
PermissionPackageBean subPpb = new PermissionPackageBean();
|
||||
subPpb.getPermissions().addAll(PackagesCfg.allPermissions);
|
||||
@ -308,17 +315,14 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Player p = player.getPlayer();
|
||||
if (p != null) {
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_IS_EXPIRATION_DATE, packageBean != null ? packageBean.getDisplayName() : LangCfg.MSG_UNKNOWN_PACKAGE, playerData.getPackageName()));
|
||||
if(packageBean !=null) {
|
||||
for (String commands : packageBean.getExpireCommands()) {
|
||||
try {
|
||||
commands = StrUtil.messageFormat(player.getPlayer(), commands);
|
||||
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), commands);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
player.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_IS_EXPIRATION_DATE, packageBean != null ? packageBean.getDisplayName() : LangCfg.MSG_UNKNOWN_PACKAGE, playerData.getPackageName()));
|
||||
if (packageBean != null) {
|
||||
for (String commands : packageBean.getExpireCommands()) {
|
||||
try {
|
||||
commands = StrUtil.messageFormat(player.getPlayer(), commands);
|
||||
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), commands);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
package gg.frog.mc.permissionstime.placeholder;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
import gg.frog.mc.permissionstime.config.PluginCfg;
|
||||
import gg.frog.mc.permissionstime.config.TagNameCfg;
|
||||
import gg.frog.mc.permissionstime.model.PlayerTagBean;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
|
||||
public class TagPlaceholder extends PlaceholderExpansion {
|
||||
|
||||
private PluginMain pm;
|
||||
|
||||
public TagPlaceholder(PluginMain pm) {
|
||||
this.pm = pm;
|
||||
}
|
||||
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return pm.PLUGIN_NAME_LOWER_CASE;
|
||||
}
|
||||
|
||||
public String getPlugin() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return "GeekFrog";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return pm.PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
public String onPlaceholderRequest(Player player, String identifier) {
|
||||
if (identifier.equalsIgnoreCase("displayname") && PluginCfg.TAG_SYSTEM) {
|
||||
if (player != null) {
|
||||
String uuid = pm.getPlayerUUIDByName(player.getName());
|
||||
PlayerTagBean playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
|
||||
if (playerTag != null) {
|
||||
return playerTag.getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -4,59 +4,50 @@ import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
import gg.frog.mc.permissionstime.config.LangCfg;
|
||||
import gg.frog.mc.permissionstime.database.IPlayerDataDao;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
|
||||
public class StrUtil {
|
||||
|
||||
private static final String dfs = "yyyy/MM/dd HH:mm:ss";
|
||||
private static final long dt = 24 * 60 * IPlayerDataDao.TIME_UNIT;
|
||||
private static final long ht = 60 * IPlayerDataDao.TIME_UNIT;
|
||||
private static final long mt = IPlayerDataDao.TIME_UNIT;
|
||||
private static final boolean placeholderAPI;
|
||||
|
||||
static {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
placeholderAPI = true;
|
||||
}else {
|
||||
placeholderAPI = false;
|
||||
}
|
||||
}
|
||||
private static final String dfs = "yyyy/MM/dd HH:mm:ss";
|
||||
private static final long dt = 24 * 60 * IPlayerDataDao.TIME_UNIT;
|
||||
private static final long ht = 60 * IPlayerDataDao.TIME_UNIT;
|
||||
private static final long mt = IPlayerDataDao.TIME_UNIT;
|
||||
|
||||
public static String messageFormat(String src, Object... args) {
|
||||
return MessageFormat.format(src, args).replace("&", "§").replace("\\n", "\n");
|
||||
}
|
||||
public static String messageFormat(String src, Object... args) {
|
||||
return MessageFormat.format(src, args).replace("&", "§").replace("\\n", "\n");
|
||||
}
|
||||
|
||||
public static String messageFormat(Player player, String src, Object... args) {
|
||||
String message = MessageFormat.format(src, args).replace("&", "§").replace("\\n", "\n").replace("%player%", player.getDisplayName());
|
||||
if(placeholderAPI) {
|
||||
message = PlaceholderAPI.setPlaceholders(player, message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
public static String messageFormat(Player player, String src, Object... args) {
|
||||
String message = MessageFormat.format(src, args).replace("&", "§").replace("\\n", "\n").replace("%player%", player.getPlayer().getDisplayName());
|
||||
if (PluginMain.enabledPlaceholder) {
|
||||
message = PlaceholderAPI.setPlaceholders(player, message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String timestampToString(long time) {
|
||||
return DateFormatUtils.format(new Date(time), dfs);
|
||||
}
|
||||
public static String timestampToString(long time) {
|
||||
return DateFormatUtils.format(new Date(time), dfs);
|
||||
}
|
||||
|
||||
public static String dateToString(Date d) {
|
||||
return DateFormatUtils.format(d, dfs);
|
||||
}
|
||||
public static String dateToString(Date d) {
|
||||
return DateFormatUtils.format(d, dfs);
|
||||
}
|
||||
|
||||
public static String nowTimeString() {
|
||||
return DateFormatUtils.format(new Date(), dfs);
|
||||
}
|
||||
public static String nowTimeString() {
|
||||
return DateFormatUtils.format(new Date(), dfs);
|
||||
}
|
||||
|
||||
public static String getLeftTime(long time) {
|
||||
long leftTime = time - new Date().getTime();
|
||||
long d = leftTime / dt;
|
||||
long h = (leftTime % dt) / ht;
|
||||
long m = (leftTime % ht) / mt;
|
||||
return messageFormat(LangCfg.LEFT_TIME, d, LangCfg.TIME_UNIT_D, h, LangCfg.TIME_UNIT_H, m, LangCfg.TIME_UNIT_M);
|
||||
}
|
||||
public static String getLeftTime(long time) {
|
||||
long leftTime = time - new Date().getTime();
|
||||
long d = leftTime / dt;
|
||||
long h = (leftTime % dt) / ht;
|
||||
long m = (leftTime % ht) / mt;
|
||||
return messageFormat(LangCfg.LEFT_TIME, d, LangCfg.TIME_UNIT_D, h, LangCfg.TIME_UNIT_H, m, LangCfg.TIME_UNIT_M);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ msg:
|
||||
timeUnitParameterIncorrect: '&4The number of time unit is incorrect. Please use d/h/m. (d=day, h=hour, m=minute)'
|
||||
processing: '&2Please wait for processing...'
|
||||
noData: '&4No data for packages.'
|
||||
noTagData: '&4No data for tag packages.'
|
||||
packageNum: '&4There are {0} kinds of permissions packages.'
|
||||
packageList: '{0}packageName: {1}, displayName: {2}'
|
||||
packageDetail: 'packageName: {0}, displayName: {1}&r\nPermissions: {2}\nGroups: {3}'
|
||||
|
@ -13,6 +13,7 @@ msg:
|
||||
timeUnitParameterIncorrect: '&4时间单位不正确. 请使用 d或h或m. (d=天, h=小时, m=分钟)'
|
||||
processing: '&2执行中,请等待...'
|
||||
noData: '&4暂时无权限包.'
|
||||
noTagData: '&4暂时无称号包.'
|
||||
packageNum: '&4共有{0}种权限包.'
|
||||
packageList: '{0}权限包名: {1}, 显示名称: {2}'
|
||||
packageDetail: '权限包名: {0}, 显示名称: {1}&r\n权限: {2}\n权限组: {3}'
|
||||
|
@ -1,11 +1,13 @@
|
||||
name: PermissionsTime
|
||||
version: 0.4.0-SNAPSHOT
|
||||
main: gg.frog.mc.permissionstime.PluginMain
|
||||
author: GeekFrog
|
||||
author:
|
||||
- GeekFrog
|
||||
softdepend:
|
||||
- SQLibrary
|
||||
- Vault
|
||||
- PlaceholderAPI
|
||||
- HolographicDisplays
|
||||
commands:
|
||||
permissionstime:
|
||||
description: Show all commands.
|
||||
|
@ -7,6 +7,16 @@ defaultPrefix: ''
|
||||
# 默认后缀.
|
||||
# Default Suffix.
|
||||
defaultSuffix: ''
|
||||
# 使用HolographicDisplays显示称号
|
||||
# use HolographicDisplays to show Tags
|
||||
useHdPlugin: false
|
||||
# 称号刷新周期(秒).
|
||||
# 如果你你的称号使用了Placeholder请设置此项
|
||||
# 推荐600秒以上. 设置-1则禁用刷新.
|
||||
# Title refresh cycle (seconds).
|
||||
# If you use Placeholder, please set.
|
||||
# Recommend more than 600s. Set -1 to disable refresh.
|
||||
refreshTagTime: -1
|
||||
packages:
|
||||
# 称号包名称.
|
||||
# Tag package name.
|
||||
|
Loading…
Reference in New Issue
Block a user