1
1
mirror of https://github.com/geekfrog/PermissionsTime.git synced 2024-11-21 23:08:48 +00:00

同名兼容处理 修复一些BUG

This commit is contained in:
GeekFrog 2017-08-02 02:11:50 +08:00
parent df53c5e651
commit 946af75651
7 changed files with 305 additions and 265 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>gg.frog.mc</groupId> <groupId>gg.frog.mc</groupId>
<artifactId>permissionstime</artifactId> <artifactId>permissionstime</artifactId>
<version>0.3.1-SNAPSHOT</version> <version>0.3.2-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>PermissionsTime</name> <name>PermissionsTime</name>
<description>支持跨服的权限限时插件</description> <description>支持跨服的权限限时插件</description>

View File

@ -41,11 +41,11 @@ public class GetCmd implements Runnable {
for (PlayerDataBean pdb : ps) { for (PlayerDataBean pdb : ps) {
String expireString = StrUtil.timestampToString(pdb.getExpire()); String expireString = StrUtil.timestampToString(pdb.getExpire());
PermissionPackageBean pc = PackagesCfg.PACKAGES.get(pdb.getPackageName()); PermissionPackageBean pc = PackagesCfg.PACKAGES.get(pdb.getPackageName());
if (!pdb.getGlobal() || pc != null) { if (pc != null && pdb.getGlobal() == pc.getGlobal()) {
sender.sendMessage(StrUtil.messageFormat( sender.sendMessage(
PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE,
pc != null ? pc.getDisplayName() : LangCfg.MSG_UNKNOWN_PACKAGE, pdb.getGlobal() ? "*" : "", pc.getDisplayName(), pdb.getPackageName(),
pdb.getPackageName(), expireString, StrUtil.getLeftTime(pdb.getExpire()))); expireString, StrUtil.getLeftTime(pdb.getExpire())));
} else { } else {
sender.sendMessage( sender.sendMessage(
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE,

View File

@ -36,11 +36,7 @@ public class MeCmd implements Runnable {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING)); sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
Player p = (Player) sender; Player p = (Player) sender;
List<PlayerDataBean> ps = sm.getTime(p.getUniqueId().toString()); List<PlayerDataBean> ps = sm.getTime(p.getUniqueId().toString());
if (ps.size() > 0) { PlayerPermissionShow.show(p, ps);
PlayerPermissionShow.show(p, ps);
} else {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA));
}
} else { } else {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH)); sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE)); sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE));

View File

@ -16,248 +16,277 @@ import gg.frog.mc.permissionstime.utils.database.DatabaseUtil;
public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao { public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
private PluginMain pm; private PluginMain pm;
public MySQLPlayerDataDao(PluginMain pm, SqlManager sm) { public MySQLPlayerDataDao(PluginMain pm, SqlManager sm) {
super(sm); super(sm);
this.pm = pm; this.pm = pm;
} }
@Override @Override
public boolean tableExist() throws Exception { public boolean tableExist() throws Exception {
String sql = "SELECT count(*) AS num FROM information_schema.TABLES WHERE table_name ='" + PluginCfg.SQL_TABLE_PREFIX + "playerData';"; String sql = "SELECT count(*) AS num FROM information_schema.TABLES WHERE table_name ='"
try { + PluginCfg.SQL_TABLE_PREFIX + "playerData';";
ResultSet rs = getDB().query(sql); try {
rs.next(); ResultSet rs = getDB().query(sql);
int num = rs.getInt("num"); rs.next();
if (num == 1) { int num = rs.getInt("num");
return true; if (num == 1) {
} return true;
return false; }
} catch (Exception e) { return false;
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't check table is exist.")); } catch (Exception e) {
throw e; pm.getServer().getConsoleSender()
} .sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't check table is exist."));
} throw e;
}
}
@Override @Override
public boolean creatTable() throws Exception { public boolean creatTable() throws Exception {
String sql = "CREATE TABLE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `uuid` VARCHAR (36) NOT NULL, `packageName` VARCHAR (100) NOT NULL, `serverId` VARCHAR (100), `expire` BIGINT NOT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `UUID_PACKAGE_SERVERID` (`uuid`, `packageName`, `serverId`)) ENGINE=InnoDB DEFAULT CHARSET=utf8; "; String sql = "CREATE TABLE `" + PluginCfg.SQL_TABLE_PREFIX
try { + "playerData` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `uuid` VARCHAR (36) NOT NULL, `packageName` VARCHAR (100) NOT NULL, `serverId` VARCHAR (100), `expire` BIGINT NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8; ";
getDB().query(sql); try {
return true; getDB().query(sql);
} catch (Exception e) { return true;
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't creat table.")); } catch (Exception e) {
throw e; pm.getServer().getConsoleSender()
} .sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't creat table."));
} throw e;
}
}
@Override @Override
public boolean setPlayerData(PlayerDataBean bean) throws Exception { public boolean setPlayerData(PlayerDataBean bean) throws Exception {
PlayerDataBean pdb = bean; PlayerDataBean pdb = bean;
String sql; String sql;
if (pdb.getId() != null) { if (pdb.getId() != null) {
sql = "UPDATE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` SET `uuid`='" + pdb.getUuid() + "', `packageName`='" + pdb.getPackageName() + "', `expire`='" + pdb.getExpire() + "' WHERE (`id`='" + pdb.getId() + "');"; sql = "UPDATE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` SET `uuid`='" + pdb.getUuid()
} else { + "', `packageName`='" + pdb.getPackageName() + "', `expire`='" + pdb.getExpire()
if (bean.getGlobal()) { + "' WHERE (`id`='" + pdb.getId() + "');";
sql = "INSERT INTO `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` (`uuid`, `packageName`, `serverId`, `expire`) VALUES ('" + pdb.getUuid() + "', '" + pdb.getPackageName() + "', NULL, " + pdb.getExpire() + ");"; } else {
} else { if (bean.getGlobal()) {
sql = "INSERT INTO `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` (`uuid`, `packageName`, `serverId`, `expire`) VALUES ('" + pdb.getUuid() + "', '" + pdb.getPackageName() + "', '" + PluginCfg.SQL_SERVER_ID + "', " + pdb.getExpire() + ");"; sql = "INSERT INTO `" + PluginCfg.SQL_TABLE_PREFIX
} + "playerData` (`uuid`, `packageName`, `serverId`, `expire`) VALUES ('" + pdb.getUuid() + "', '"
} + pdb.getPackageName() + "', NULL, " + pdb.getExpire() + ");";
try { } else {
getDB().query(sql); sql = "INSERT INTO `" + PluginCfg.SQL_TABLE_PREFIX
return true; + "playerData` (`uuid`, `packageName`, `serverId`, `expire`) VALUES ('" + pdb.getUuid() + "', '"
} catch (Exception e) { + pdb.getPackageName() + "', '" + PluginCfg.SQL_SERVER_ID + "', " + pdb.getExpire() + ");";
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't creat data: {0}", pdb)); }
throw e; }
} try {
} getDB().query(sql);
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender()
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't creat data: {0}", pdb));
throw e;
}
}
@Override @Override
public boolean setTime(String uuid, String packageName, int time) throws Exception { public boolean setTime(String uuid, String packageName, int time) throws Exception {
boolean global = uuid.startsWith("g:") ? true : false; boolean global = uuid.startsWith("g:") ? true : false;
if (global) { if (global) {
uuid = uuid.substring(2); uuid = uuid.substring(2);
} }
long now = new Date().getTime(); long now = new Date().getTime();
long addTime = time * TIME_UNIT; long addTime = time * TIME_UNIT;
long expire = now + addTime; long expire = now + addTime;
PlayerDataBean pdb = queryPlayerData(uuid, packageName); PlayerDataBean pdb = queryPlayerData((global ? "g:" : "") + uuid, packageName);
if (pdb == null) { if (pdb == null) {
pdb = new PlayerDataBean(null, uuid, packageName, expire); pdb = new PlayerDataBean(null, uuid, packageName, expire);
if (global) { if (global) {
pdb.setGlobal(true); pdb.setGlobal(true);
} }
return setPlayerData(pdb); return setPlayerData(pdb);
} else { } else {
pdb.setExpire(expire); pdb.setExpire(expire);
if (global) { if (global) {
pdb.setGlobal(true); pdb.setGlobal(true);
} }
return setPlayerData(pdb); return setPlayerData(pdb);
} }
} }
@Override @Override
public boolean addTime(String uuid, String packageName, int time) throws Exception { public boolean addTime(String uuid, String packageName, int time) throws Exception {
boolean global = uuid.startsWith("g:") ? true : false; boolean global = uuid.startsWith("g:") ? true : false;
if (global) { if (global) {
uuid = uuid.substring(2); uuid = uuid.substring(2);
} }
long now = new Date().getTime(); long now = new Date().getTime();
long addTime = time * TIME_UNIT; long addTime = time * TIME_UNIT;
long expire = now + addTime; long expire = now + addTime;
PlayerDataBean pdb = queryPlayerData((global ? "g:" : "") + uuid, packageName); PlayerDataBean pdb = queryPlayerData((global ? "g:" : "") + uuid, packageName);
if (pdb == null) { if (pdb == null) {
pdb = new PlayerDataBean(null, uuid, packageName, expire); pdb = new PlayerDataBean(null, uuid, packageName, expire);
if (global) { if (global) {
pdb.setGlobal(true); pdb.setGlobal(true);
} }
return setPlayerData(pdb); return setPlayerData(pdb);
} else { } else {
if (pdb.getExpire() < now) { if (pdb.getExpire() < now) {
pdb.setExpire(expire); pdb.setExpire(expire);
if (global) { if (global) {
pdb.setGlobal(true); pdb.setGlobal(true);
} }
return setPlayerData(pdb); return setPlayerData(pdb);
} else { } else {
String sql = "UPDATE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` SET `expire`=`expire`+" + addTime + " WHERE (`id`='" + pdb.getId() + "');"; String sql = "UPDATE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` SET `expire`=`expire`+" + addTime
try { + " WHERE (`id`='" + pdb.getId() + "');";
getDB().query(sql); try {
return true; getDB().query(sql);
} catch (Exception e) { return true;
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't update data: {0}", pdb)); } catch (Exception e) {
throw e; pm.getServer().getConsoleSender().sendMessage(
} StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't update data: {0}", pdb));
} throw e;
} }
} }
}
}
@Override @Override
public List<PlayerDataBean> queryPlayerData(String uuid) throws Exception { public List<PlayerDataBean> queryPlayerData(String uuid) throws Exception {
String sql = "SELECT * FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` where `uuid`='" + uuid + "' AND (`serverId`='" + PluginCfg.SQL_SERVER_ID + "' OR `serverId` IS NULL);"; String sql = "SELECT * FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` where `uuid`='" + uuid
try { + "' AND (`serverId`='" + PluginCfg.SQL_SERVER_ID + "' OR `serverId` IS NULL);";
List<PlayerDataBean> pdbList = new ArrayList<>(); try {
ResultSet rs = getDB().query(sql); List<PlayerDataBean> pdbList = new ArrayList<>();
while (rs.next()) { ResultSet rs = getDB().query(sql);
long tid = rs.getLong("id"); while (rs.next()) {
String tuuid = rs.getString("uuid"); long tid = rs.getLong("id");
String tpackageName = rs.getString("packageName"); String tuuid = rs.getString("uuid");
String tserverId = rs.getString("serverId"); String tpackageName = rs.getString("packageName");
long texpire = rs.getLong("expire"); String tserverId = rs.getString("serverId");
PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire); long texpire = rs.getLong("expire");
if (tserverId == null) { PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire);
tpd.setGlobal(true); if (tserverId == null) {
} tpd.setGlobal(true);
pdbList.add(tpd); }
} pdbList.add(tpd);
return pdbList; }
} catch (Exception e) { return pdbList;
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}", uuid)); } catch (Exception e) {
throw e; pm.getServer().getConsoleSender().sendMessage(
} StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}", uuid));
} throw e;
}
}
@Override @Override
public PlayerDataBean queryPlayerData(String uuid, String packageName) throws Exception { public PlayerDataBean queryPlayerData(String uuid, String packageName) throws Exception {
String sql = "SELECT * FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` where `uuid`='" + uuid + "' AND `packageName`='" + packageName + "' AND `serverId`='" + PluginCfg.SQL_SERVER_ID + "';"; String sql = "SELECT * FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` where `uuid`='" + uuid
if (uuid.startsWith("g:")) { + "' AND `packageName`='" + packageName + "' AND `serverId`='" + PluginCfg.SQL_SERVER_ID + "';";
uuid = uuid.substring(2); if (uuid.startsWith("g:")) {
sql = "SELECT * FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` where `uuid`='" + uuid + "' AND `packageName`='" + packageName + "' AND `serverId` IS NULL;"; uuid = uuid.substring(2);
} sql = "SELECT * FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` where `uuid`='" + uuid
try { + "' AND `packageName`='" + packageName + "' AND `serverId` IS NULL;";
ResultSet rs = getDB().query(sql); }
while (rs.next()) { try {
long tid = rs.getLong("id"); ResultSet rs = getDB().query(sql);
String tuuid = rs.getString("uuid"); while (rs.next()) {
String tpackageName = rs.getString("packageName"); long tid = rs.getLong("id");
String tserverId = rs.getString("serverId"); String tuuid = rs.getString("uuid");
long texpire = rs.getLong("expire"); String tpackageName = rs.getString("packageName");
PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire); String tserverId = rs.getString("serverId");
if (tserverId == null) { long texpire = rs.getLong("expire");
tpd.setGlobal(true); PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire);
} if (tserverId == null) {
return tpd; tpd.setGlobal(true);
} }
return null; return tpd;
} catch (Exception e) { }
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}, packageName: {1}", uuid, packageName)); return null;
throw e; } catch (Exception e) {
} pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(
} PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}, packageName: {1}", uuid, packageName));
throw e;
}
}
@Override @Override
public List<PlayerDataBean> queryNotExpirePlayerData(String uuid) throws Exception { public List<PlayerDataBean> queryNotExpirePlayerData(String uuid) throws Exception {
long now = new Date().getTime(); long now = new Date().getTime();
String sql = "SELECT * FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` where `uuid`='" + uuid + "' AND (`serverId`='" + PluginCfg.SQL_SERVER_ID + "' OR `serverId` IS NULL) AND `expire` > " + now + ";"; String sql = "SELECT * FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` where `uuid`='" + uuid
try { + "' AND (`serverId`='" + PluginCfg.SQL_SERVER_ID + "' OR `serverId` IS NULL) AND `expire` > " + now
List<PlayerDataBean> pdbList = new ArrayList<>(); + ";";
ResultSet rs = getDB().query(sql); try {
while (rs.next()) { List<PlayerDataBean> pdbList = new ArrayList<>();
String tpackageName = rs.getString("packageName"); ResultSet rs = getDB().query(sql);
if (PackagesCfg.PACKAGES.containsKey(tpackageName)) { while (rs.next()) {
long tid = rs.getLong("id"); String tpackageName = rs.getString("packageName");
String tuuid = rs.getString("uuid"); if (PackagesCfg.PACKAGES.containsKey(tpackageName)) {
String tserverId = rs.getString("serverId"); long tid = rs.getLong("id");
long texpire = rs.getLong("expire"); String tuuid = rs.getString("uuid");
PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire); String tserverId = rs.getString("serverId");
if (tserverId == null) { long texpire = rs.getLong("expire");
tpd.setGlobal(true); PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire);
} if (tserverId == null) {
pdbList.add(tpd); tpd.setGlobal(true);
} }
} pdbList.add(tpd);
return pdbList; }
} catch (Exception e) { }
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}", uuid)); return pdbList;
throw e; } catch (Exception e) {
} pm.getServer().getConsoleSender().sendMessage(
} StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}", uuid));
throw e;
}
}
@Override @Override
public boolean delPlayData(Long id) throws Exception { public boolean delPlayData(Long id) throws Exception {
String sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `id`='" + id + "' AND (`serverId`='" + PluginCfg.SQL_SERVER_ID + "' OR `serverId` IS NULL);"; String sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `id`='" + id
try { + "' AND (`serverId`='" + PluginCfg.SQL_SERVER_ID + "' OR `serverId` IS NULL);";
getDB().query(sql); try {
return true; getDB().query(sql);
} catch (Exception e) { return true;
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by ID: {0}", id)); } catch (Exception e) {
throw e; pm.getServer().getConsoleSender()
} .sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by ID: {0}", id));
} throw e;
}
}
@Override @Override
public boolean delPlayData(String uuid) throws Exception { public boolean delPlayData(String uuid) throws Exception {
String sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid + "' AND `serverId`='" + PluginCfg.SQL_SERVER_ID + "';"; String sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid
if (uuid.startsWith("g:")) { + "' AND `serverId`='" + PluginCfg.SQL_SERVER_ID + "';";
uuid = uuid.substring(2); if (uuid.startsWith("g:")) {
sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid + "' AND `serverId` IS NULL;"; uuid = uuid.substring(2);
} sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid
try { + "' AND `serverId` IS NULL;";
getDB().query(sql); }
return true; try {
} catch (Exception e) { getDB().query(sql);
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by UUID: {0}", uuid)); return true;
throw e; } catch (Exception e) {
} pm.getServer().getConsoleSender().sendMessage(
} StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by UUID: {0}", uuid));
throw e;
}
}
@Override @Override
public boolean delPlayData(String uuid, String packageName) throws Exception { public boolean delPlayData(String uuid, String packageName) throws Exception {
String sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid + "' AND `packageName`='" + packageName + "'AND `serverId`='" + PluginCfg.SQL_SERVER_ID + "';"; String sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid
if (uuid.startsWith("g:")) { + "' AND `packageName`='" + packageName + "'AND `serverId`='" + PluginCfg.SQL_SERVER_ID + "';";
uuid = uuid.substring(2); if (uuid.startsWith("g:")) {
sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid + "' AND `packageName`='" + packageName + "'AND `serverId` IS NULL;"; uuid = uuid.substring(2);
} sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid
try { + "' AND `packageName`='" + packageName + "'AND `serverId` IS NULL;";
getDB().query(sql); }
return true; try {
} catch (Exception e) { getDB().query(sql);
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by UUID: {0}, packageName: {1}", uuid, packageName)); return true;
throw e; } catch (Exception e) {
} pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(
} PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by UUID: {0}, packageName: {1}", uuid, packageName));
throw e;
}
}
} }

View File

@ -10,28 +10,41 @@ import org.bukkit.inventory.meta.ItemMeta;
import gg.frog.mc.permissionstime.config.LangCfg; import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PackagesCfg; import gg.frog.mc.permissionstime.config.PackagesCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean; import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean; import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
import gg.frog.mc.permissionstime.utils.StrUtil; import gg.frog.mc.permissionstime.utils.StrUtil;
public class PlayerPermissionShow { public class PlayerPermissionShow {
public static void show(Player p, List<PlayerDataBean> pdbList) { public static void show(Player p, List<PlayerDataBean> pdbList) {
Inventory inventory = Bukkit.createInventory(null, (pdbList.size() % 9 == 0 ? pdbList.size() : (pdbList.size() / 9 + 1) * 9), StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "&r&5&9&2&0&r")); Inventory inventory = null;
for (PlayerDataBean pdb : pdbList) { int size = 0;
PermissionPackageBean ppb = PackagesCfg.PACKAGES.get(pdb.getPackageName()); if (pdbList.size() > 0) {
if (ppb != null && pdb.getGlobal() == ppb.getGlobal()) { inventory = Bukkit.createInventory(null,
ItemStack item = PackagesCfg.PACKAGE_ITEMS.get(pdb.getPackageName()); (pdbList.size() % 9 == 0 ? pdbList.size() : (pdbList.size() / 9 + 1) * 9),
ItemStack tItem = item.clone(); StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "&r&5&9&2&0&r"));
ItemMeta meta = tItem.getItemMeta(); for (PlayerDataBean pdb : pdbList) {
List<String> lores = meta.getLore(); PermissionPackageBean ppb = PackagesCfg.PACKAGES.get(pdb.getPackageName());
lores.add(StrUtil.messageFormat(LangCfg.EXPIRATION_TIME, StrUtil.timestampToString(pdb.getExpire()))); if (ppb != null && pdb.getGlobal() == ppb.getGlobal()) {
lores.add(StrUtil.getLeftTime(pdb.getExpire())); ItemStack item = PackagesCfg.PACKAGE_ITEMS.get(pdb.getPackageName());
meta.setLore(lores); ItemStack tItem = item.clone();
tItem.setItemMeta(meta); ItemMeta meta = tItem.getItemMeta();
inventory.addItem(tItem); List<String> lores = meta.getLore();
} lores.add(
} StrUtil.messageFormat(LangCfg.EXPIRATION_TIME, StrUtil.timestampToString(pdb.getExpire())));
p.openInventory(inventory); lores.add(StrUtil.getLeftTime(pdb.getExpire()));
} meta.setLore(lores);
tItem.setItemMeta(meta);
inventory.addItem(tItem);
size++;
}
}
}
if (inventory != null && size > 0) {
p.openInventory(inventory);
} else {
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA));
}
}
} }

View File

@ -1,5 +1,5 @@
name: PermissionsTime name: PermissionsTime
version: 0.3.1-SNAPSHOT version: 0.3.2-SNAPSHOT
main: gg.frog.mc.permissionstime.PluginMain main: gg.frog.mc.permissionstime.PluginMain
author: GeekFrog author: GeekFrog
softdepend: softdepend:

View File

@ -3,7 +3,7 @@
[align=center][table=98%,#4169e1] [align=center][table=98%,#4169e1]
[tr][td][align=center][size=6][color=#ffffff][b]唠叨[/b][/color][/size][/align][/td][/tr] [tr][td][align=center][size=6][color=#ffffff][b]唠叨[/b][/color][/size][/align][/td][/tr]
[/table][/align][align=center][table=98%,gray] [/table][/align][align=center][table=98%,gray]
[tr][td][align=center][size=4][color=#ffa500][b]这是本人第一个发布的插件, 希望能让大家满意![/b][/color][/size][/align][align=center][size=4][color=#dda0dd][b]本插件需要JAVA8[/b][/color][/size][/align][align=center][size=4][color=#98fb98][b]下载地址在最下面![/b][/color][/size][/align][align=center][size=4][color=#c0c0c0][b]最新版本: [/b][/color][b][color=#8b0000]0.3.1[/color][color=#c0c0c0]推荐大家使用新版本只需替换插件的jar包和语言文件即可[/color][/b][/size][/align][/td][/tr] [tr][td][align=center][size=4][color=#ffa500][b]这是本人第一个发布的插件, 希望能让大家满意![/b][/color][/size][/align][align=center][size=4][color=#dda0dd][b]本插件需要JAVA8[/b][/color][/size][/align][align=center][size=4][color=#98fb98][b]下载地址在最下面![/b][/color][/size][/align][align=center][size=4][color=#c0c0c0][b]最新版本: [/b][/color][b][color=#8b0000]0.3.2[/color][color=#c0c0c0]推荐大家使用新版本只需替换插件的jar包和语言文件即可! [/color][/b][/size][/align][/td][/tr]
[/table][/align][align=center][table=98%,#4169e1] [/table][/align][align=center][table=98%,#4169e1]
[tr][td][align=center][size=6][color=#ffffff][b]前言[/b][/color][/size][/align][/td][/tr] [tr][td][align=center][size=6][color=#ffffff][b]前言[/b][/color][/size][/align][/td][/tr]
[/table][/align][align=center][table=98%,gray] [/table][/align][align=center][table=98%,gray]
@ -203,8 +203,10 @@ cmd:
[tr][td][align=center][size=6][color=#ffffff][b]更新日志[/b][/color][/size][/align][/td][/tr] [tr][td][align=center][size=6][color=#ffffff][b]更新日志[/b][/color][/size][/align][/td][/tr]
[/table][/align][align=center][table=98%,gray] [/table][/align][align=center][table=98%,gray]
[tr][td][spoiler][size=4][b][url=http://ci.frog.gg/jenkins/job/PermissionsTime/changes]详细的更新记录[/url] [tr][td][spoiler][size=4][b][url=http://ci.frog.gg/jenkins/job/PermissionsTime/changes]详细的更新记录[/url]
[color=#ffffff]2017年8月2日 V0.3.1[/color][quote][color=#000000] [color=#ffffff]2017年8月2日 V0.3.1-V0.3.2[/color][quote][color=#000000]
1.跨服与非跨服权限包同名兼容处理[/color][/quote] 1.跨服与非跨服权限包同名兼容处理
2.优化同名兼容处理
3.修复一些BUG[/color][/quote]
[color=#ffffff]2017年8月1日 V0.3.0[/color][quote][color=#000000] [color=#ffffff]2017年8月1日 V0.3.0[/color][quote][color=#000000]
1.权限包到期可执行自定义命令[/color][/quote] 1.权限包到期可执行自定义命令[/color][/quote]
[color=#ffffff]2017年7月31日 V0.2.4[/color][quote][color=#000000] [color=#ffffff]2017年7月31日 V0.2.4[/color][quote][color=#000000]
@ -234,7 +236,7 @@ cmd:
[/table][/align][align=center][table=98%,#4169e1] [/table][/align][align=center][table=98%,#4169e1]
[tr][td][align=center][size=6][color=#ffffff][b]下载地址[/b][/color][/size][/align][/td][/tr] [tr][td][align=center][size=6][color=#ffffff][b]下载地址[/b][/color][/size][/align][/td][/tr]
[/table][/align][align=center][table=98%,gray] [/table][/align][align=center][table=98%,gray]
[tr][td][size=4][b][align=center][color=#000] [url=http://ci.frog.gg/jenkins/job/PermissionsTime/65/]V0.3.1版下载地址[/url][/color][/align][align=center][color=#ffffff]前置插件:[/color][color=#000][url=https://dev.bukkit.org/projects/vault/files]vault[/url][/color][color=#000000] , [/color][color=#000][url=https://dev.bukkit.org/projects/sqlibrary/files]sqlibrary[/url][/color][/align][align=center][color=#ffffff]前置插件最好去原站下载适合的版本, 如果无法下载可以在帖内下载。[/color][/align] [tr][td][size=4][b][align=center][color=#000] [url=http://ci.frog.gg/jenkins/job/PermissionsTime/66/]V0.3.2版下载地址[/url][/color][/align][align=center][color=#ffffff]前置插件:[/color][color=#000][url=https://dev.bukkit.org/projects/vault/files]vault[/url][/color][color=#000000] , [/color][color=#000][url=https://dev.bukkit.org/projects/sqlibrary/files]sqlibrary[/url][/color][/align][align=center][color=#ffffff]前置插件最好去原站下载适合的版本, 如果无法下载可以在帖内下载。[/color][/align]
[align=center][b][color=#ffffff]帖内下载:[/color][/b][/align][align=center][color=#000][attach]1101088[/attach][/color][/align][align=center][color=#000][b][color=#ff0000]前置插件必须安装[/color][/b][/color][/align][align=center][color=#000][attach]1101089[/attach][/color][/align][align=center][color=#000][attach]1101090[/attach][/color][/align][align=center][color=#000][attach]1101110[/attach][/color][/align] [align=center][b][color=#ffffff]帖内下载:[/color][/b][/align][align=center][color=#000][attach]1101088[/attach][/color][/align][align=center][color=#000][b][color=#ff0000]前置插件必须安装[/color][/b][/color][/align][align=center][color=#000][attach]1101089[/attach][/color][/align][align=center][color=#000][attach]1101090[/attach][/color][/align][align=center][color=#000][attach]1101110[/attach][/color][/align]
[align=center][color=#000][color=#ff0000][b]如果大家觉得好用就给点金粒吧,如果不好请告诉我,帮助我改进。[/b][/color][/color][/align][align=center][color=#000][b]BUG可以在帖内回复我。[/b][/color][/align][/b][/size][/td][/tr] [align=center][color=#000][color=#ff0000][b]如果大家觉得好用就给点金粒吧,如果不好请告诉我,帮助我改进。[/b][/color][/color][/align][align=center][color=#000][b]BUG可以在帖内回复我。[/b][/color][/align][/b][/size][/td][/tr]
[/table][/align][align=center][table=98%,#4169e1] [/table][/align][align=center][table=98%,#4169e1]