mirror of
https://github.com/geekfrog/PermissionsTime.git
synced 2024-11-21 23:08:48 +00:00
同名兼容处理 修复一些BUG
This commit is contained in:
parent
df53c5e651
commit
946af75651
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>gg.frog.mc</groupId>
|
||||
<artifactId>permissionstime</artifactId>
|
||||
<version>0.3.1-SNAPSHOT</version>
|
||||
<version>0.3.2-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>PermissionsTime</name>
|
||||
<description>支持跨服的权限限时插件</description>
|
||||
|
@ -41,11 +41,11 @@ public class GetCmd implements Runnable {
|
||||
for (PlayerDataBean pdb : ps) {
|
||||
String expireString = StrUtil.timestampToString(pdb.getExpire());
|
||||
PermissionPackageBean pc = PackagesCfg.PACKAGES.get(pdb.getPackageName());
|
||||
if (!pdb.getGlobal() || pc != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(
|
||||
PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "",
|
||||
pc != null ? pc.getDisplayName() : LangCfg.MSG_UNKNOWN_PACKAGE,
|
||||
pdb.getPackageName(), expireString, StrUtil.getLeftTime(pdb.getExpire())));
|
||||
if (pc != null && pdb.getGlobal() == pc.getGlobal()) {
|
||||
sender.sendMessage(
|
||||
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE,
|
||||
pdb.getGlobal() ? "*" : "", pc.getDisplayName(), pdb.getPackageName(),
|
||||
expireString, StrUtil.getLeftTime(pdb.getExpire())));
|
||||
} else {
|
||||
sender.sendMessage(
|
||||
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE,
|
||||
|
@ -36,11 +36,7 @@ public class MeCmd implements Runnable {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
|
||||
Player p = (Player) sender;
|
||||
List<PlayerDataBean> ps = sm.getTime(p.getUniqueId().toString());
|
||||
if (ps.size() > 0) {
|
||||
PlayerPermissionShow.show(p, ps);
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA));
|
||||
}
|
||||
PlayerPermissionShow.show(p, 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));
|
||||
|
@ -16,248 +16,277 @@ import gg.frog.mc.permissionstime.utils.database.DatabaseUtil;
|
||||
|
||||
public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
|
||||
|
||||
private PluginMain pm;
|
||||
private PluginMain pm;
|
||||
|
||||
public MySQLPlayerDataDao(PluginMain pm, SqlManager sm) {
|
||||
super(sm);
|
||||
this.pm = pm;
|
||||
}
|
||||
public MySQLPlayerDataDao(PluginMain pm, SqlManager sm) {
|
||||
super(sm);
|
||||
this.pm = pm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tableExist() throws Exception {
|
||||
String sql = "SELECT count(*) AS num FROM information_schema.TABLES WHERE table_name ='" + PluginCfg.SQL_TABLE_PREFIX + "playerData';";
|
||||
try {
|
||||
ResultSet rs = getDB().query(sql);
|
||||
rs.next();
|
||||
int num = rs.getInt("num");
|
||||
if (num == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't check table is exist."));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean tableExist() throws Exception {
|
||||
String sql = "SELECT count(*) AS num FROM information_schema.TABLES WHERE table_name ='"
|
||||
+ PluginCfg.SQL_TABLE_PREFIX + "playerData';";
|
||||
try {
|
||||
ResultSet rs = getDB().query(sql);
|
||||
rs.next();
|
||||
int num = rs.getInt("num");
|
||||
if (num == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
pm.getServer().getConsoleSender()
|
||||
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't check table is exist."));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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; ";
|
||||
try {
|
||||
getDB().query(sql);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't creat table."));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
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`)) ENGINE=InnoDB DEFAULT CHARSET=utf8; ";
|
||||
try {
|
||||
getDB().query(sql);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
pm.getServer().getConsoleSender()
|
||||
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't creat table."));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPlayerData(PlayerDataBean bean) throws Exception {
|
||||
PlayerDataBean pdb = bean;
|
||||
String sql;
|
||||
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() + "');";
|
||||
} else {
|
||||
if (bean.getGlobal()) {
|
||||
sql = "INSERT INTO `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` (`uuid`, `packageName`, `serverId`, `expire`) VALUES ('" + pdb.getUuid() + "', '" + pdb.getPackageName() + "', NULL, " + pdb.getExpire() + ");";
|
||||
} else {
|
||||
sql = "INSERT INTO `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` (`uuid`, `packageName`, `serverId`, `expire`) VALUES ('" + pdb.getUuid() + "', '" + pdb.getPackageName() + "', '" + PluginCfg.SQL_SERVER_ID + "', " + pdb.getExpire() + ");";
|
||||
}
|
||||
}
|
||||
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
|
||||
public boolean setPlayerData(PlayerDataBean bean) throws Exception {
|
||||
PlayerDataBean pdb = bean;
|
||||
String sql;
|
||||
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() + "');";
|
||||
} else {
|
||||
if (bean.getGlobal()) {
|
||||
sql = "INSERT INTO `" + PluginCfg.SQL_TABLE_PREFIX
|
||||
+ "playerData` (`uuid`, `packageName`, `serverId`, `expire`) VALUES ('" + pdb.getUuid() + "', '"
|
||||
+ pdb.getPackageName() + "', NULL, " + pdb.getExpire() + ");";
|
||||
} else {
|
||||
sql = "INSERT INTO `" + PluginCfg.SQL_TABLE_PREFIX
|
||||
+ "playerData` (`uuid`, `packageName`, `serverId`, `expire`) VALUES ('" + pdb.getUuid() + "', '"
|
||||
+ pdb.getPackageName() + "', '" + PluginCfg.SQL_SERVER_ID + "', " + pdb.getExpire() + ");";
|
||||
}
|
||||
}
|
||||
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
|
||||
public boolean setTime(String uuid, String packageName, int time) throws Exception {
|
||||
boolean global = uuid.startsWith("g:") ? true : false;
|
||||
if (global) {
|
||||
uuid = uuid.substring(2);
|
||||
}
|
||||
long now = new Date().getTime();
|
||||
long addTime = time * TIME_UNIT;
|
||||
long expire = now + addTime;
|
||||
PlayerDataBean pdb = queryPlayerData(uuid, packageName);
|
||||
if (pdb == null) {
|
||||
pdb = new PlayerDataBean(null, uuid, packageName, expire);
|
||||
if (global) {
|
||||
pdb.setGlobal(true);
|
||||
}
|
||||
return setPlayerData(pdb);
|
||||
} else {
|
||||
pdb.setExpire(expire);
|
||||
if (global) {
|
||||
pdb.setGlobal(true);
|
||||
}
|
||||
return setPlayerData(pdb);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean setTime(String uuid, String packageName, int time) throws Exception {
|
||||
boolean global = uuid.startsWith("g:") ? true : false;
|
||||
if (global) {
|
||||
uuid = uuid.substring(2);
|
||||
}
|
||||
long now = new Date().getTime();
|
||||
long addTime = time * TIME_UNIT;
|
||||
long expire = now + addTime;
|
||||
PlayerDataBean pdb = queryPlayerData((global ? "g:" : "") + uuid, packageName);
|
||||
if (pdb == null) {
|
||||
pdb = new PlayerDataBean(null, uuid, packageName, expire);
|
||||
if (global) {
|
||||
pdb.setGlobal(true);
|
||||
}
|
||||
return setPlayerData(pdb);
|
||||
} else {
|
||||
pdb.setExpire(expire);
|
||||
if (global) {
|
||||
pdb.setGlobal(true);
|
||||
}
|
||||
return setPlayerData(pdb);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addTime(String uuid, String packageName, int time) throws Exception {
|
||||
boolean global = uuid.startsWith("g:") ? true : false;
|
||||
if (global) {
|
||||
uuid = uuid.substring(2);
|
||||
}
|
||||
long now = new Date().getTime();
|
||||
long addTime = time * TIME_UNIT;
|
||||
long expire = now + addTime;
|
||||
PlayerDataBean pdb = queryPlayerData((global ? "g:" : "") + uuid, packageName);
|
||||
if (pdb == null) {
|
||||
pdb = new PlayerDataBean(null, uuid, packageName, expire);
|
||||
if (global) {
|
||||
pdb.setGlobal(true);
|
||||
}
|
||||
return setPlayerData(pdb);
|
||||
} else {
|
||||
if (pdb.getExpire() < now) {
|
||||
pdb.setExpire(expire);
|
||||
if (global) {
|
||||
pdb.setGlobal(true);
|
||||
}
|
||||
return setPlayerData(pdb);
|
||||
} else {
|
||||
String sql = "UPDATE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` SET `expire`=`expire`+" + addTime + " WHERE (`id`='" + pdb.getId() + "');";
|
||||
try {
|
||||
getDB().query(sql);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't update data: {0}", pdb));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean addTime(String uuid, String packageName, int time) throws Exception {
|
||||
boolean global = uuid.startsWith("g:") ? true : false;
|
||||
if (global) {
|
||||
uuid = uuid.substring(2);
|
||||
}
|
||||
long now = new Date().getTime();
|
||||
long addTime = time * TIME_UNIT;
|
||||
long expire = now + addTime;
|
||||
PlayerDataBean pdb = queryPlayerData((global ? "g:" : "") + uuid, packageName);
|
||||
if (pdb == null) {
|
||||
pdb = new PlayerDataBean(null, uuid, packageName, expire);
|
||||
if (global) {
|
||||
pdb.setGlobal(true);
|
||||
}
|
||||
return setPlayerData(pdb);
|
||||
} else {
|
||||
if (pdb.getExpire() < now) {
|
||||
pdb.setExpire(expire);
|
||||
if (global) {
|
||||
pdb.setGlobal(true);
|
||||
}
|
||||
return setPlayerData(pdb);
|
||||
} else {
|
||||
String sql = "UPDATE `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` SET `expire`=`expire`+" + addTime
|
||||
+ " WHERE (`id`='" + pdb.getId() + "');";
|
||||
try {
|
||||
getDB().query(sql);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
pm.getServer().getConsoleSender().sendMessage(
|
||||
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't update data: {0}", pdb));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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);";
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = new ArrayList<>();
|
||||
ResultSet rs = getDB().query(sql);
|
||||
while (rs.next()) {
|
||||
long tid = rs.getLong("id");
|
||||
String tuuid = rs.getString("uuid");
|
||||
String tpackageName = rs.getString("packageName");
|
||||
String tserverId = rs.getString("serverId");
|
||||
long texpire = rs.getLong("expire");
|
||||
PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire);
|
||||
if (tserverId == null) {
|
||||
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));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
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);";
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = new ArrayList<>();
|
||||
ResultSet rs = getDB().query(sql);
|
||||
while (rs.next()) {
|
||||
long tid = rs.getLong("id");
|
||||
String tuuid = rs.getString("uuid");
|
||||
String tpackageName = rs.getString("packageName");
|
||||
String tserverId = rs.getString("serverId");
|
||||
long texpire = rs.getLong("expire");
|
||||
PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire);
|
||||
if (tserverId == null) {
|
||||
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));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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 + "';";
|
||||
if (uuid.startsWith("g:")) {
|
||||
uuid = uuid.substring(2);
|
||||
sql = "SELECT * FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` where `uuid`='" + uuid + "' AND `packageName`='" + packageName + "' AND `serverId` IS NULL;";
|
||||
}
|
||||
try {
|
||||
ResultSet rs = getDB().query(sql);
|
||||
while (rs.next()) {
|
||||
long tid = rs.getLong("id");
|
||||
String tuuid = rs.getString("uuid");
|
||||
String tpackageName = rs.getString("packageName");
|
||||
String tserverId = rs.getString("serverId");
|
||||
long texpire = rs.getLong("expire");
|
||||
PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire);
|
||||
if (tserverId == null) {
|
||||
tpd.setGlobal(true);
|
||||
}
|
||||
return tpd;
|
||||
}
|
||||
return null;
|
||||
} 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
|
||||
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 + "';";
|
||||
if (uuid.startsWith("g:")) {
|
||||
uuid = uuid.substring(2);
|
||||
sql = "SELECT * FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` where `uuid`='" + uuid
|
||||
+ "' AND `packageName`='" + packageName + "' AND `serverId` IS NULL;";
|
||||
}
|
||||
try {
|
||||
ResultSet rs = getDB().query(sql);
|
||||
while (rs.next()) {
|
||||
long tid = rs.getLong("id");
|
||||
String tuuid = rs.getString("uuid");
|
||||
String tpackageName = rs.getString("packageName");
|
||||
String tserverId = rs.getString("serverId");
|
||||
long texpire = rs.getLong("expire");
|
||||
PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire);
|
||||
if (tserverId == null) {
|
||||
tpd.setGlobal(true);
|
||||
}
|
||||
return tpd;
|
||||
}
|
||||
return null;
|
||||
} 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
|
||||
public List<PlayerDataBean> queryNotExpirePlayerData(String uuid) throws Exception {
|
||||
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 + ";";
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = new ArrayList<>();
|
||||
ResultSet rs = getDB().query(sql);
|
||||
while (rs.next()) {
|
||||
String tpackageName = rs.getString("packageName");
|
||||
if (PackagesCfg.PACKAGES.containsKey(tpackageName)) {
|
||||
long tid = rs.getLong("id");
|
||||
String tuuid = rs.getString("uuid");
|
||||
String tserverId = rs.getString("serverId");
|
||||
long texpire = rs.getLong("expire");
|
||||
PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire);
|
||||
if (tserverId == null) {
|
||||
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));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public List<PlayerDataBean> queryNotExpirePlayerData(String uuid) throws Exception {
|
||||
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
|
||||
+ ";";
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = new ArrayList<>();
|
||||
ResultSet rs = getDB().query(sql);
|
||||
while (rs.next()) {
|
||||
String tpackageName = rs.getString("packageName");
|
||||
if (PackagesCfg.PACKAGES.containsKey(tpackageName)) {
|
||||
long tid = rs.getLong("id");
|
||||
String tuuid = rs.getString("uuid");
|
||||
String tserverId = rs.getString("serverId");
|
||||
long texpire = rs.getLong("expire");
|
||||
PlayerDataBean tpd = new PlayerDataBean(tid, tuuid, tpackageName, texpire);
|
||||
if (tserverId == null) {
|
||||
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));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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);";
|
||||
try {
|
||||
getDB().query(sql);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by ID: {0}", id));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
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);";
|
||||
try {
|
||||
getDB().query(sql);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
pm.getServer().getConsoleSender()
|
||||
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by ID: {0}", id));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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 + "';";
|
||||
if (uuid.startsWith("g:")) {
|
||||
uuid = uuid.substring(2);
|
||||
sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid + "' AND `serverId` IS NULL;";
|
||||
}
|
||||
try {
|
||||
getDB().query(sql);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by UUID: {0}", uuid));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
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 + "';";
|
||||
if (uuid.startsWith("g:")) {
|
||||
uuid = uuid.substring(2);
|
||||
sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid
|
||||
+ "' AND `serverId` IS NULL;";
|
||||
}
|
||||
try {
|
||||
getDB().query(sql);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
pm.getServer().getConsoleSender().sendMessage(
|
||||
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by UUID: {0}", uuid));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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 + "';";
|
||||
if (uuid.startsWith("g:")) {
|
||||
uuid = uuid.substring(2);
|
||||
sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid + "' AND `packageName`='" + packageName + "'AND `serverId` IS NULL;";
|
||||
}
|
||||
try {
|
||||
getDB().query(sql);
|
||||
return true;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
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 + "';";
|
||||
if (uuid.startsWith("g:")) {
|
||||
uuid = uuid.substring(2);
|
||||
sql = "DELETE FROM `" + PluginCfg.SQL_TABLE_PREFIX + "playerData` WHERE `uuid`='" + uuid
|
||||
+ "' AND `packageName`='" + packageName + "'AND `serverId` IS NULL;";
|
||||
}
|
||||
try {
|
||||
getDB().query(sql);
|
||||
return true;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,28 +10,41 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import gg.frog.mc.permissionstime.config.LangCfg;
|
||||
import gg.frog.mc.permissionstime.config.PackagesCfg;
|
||||
import gg.frog.mc.permissionstime.config.PluginCfg;
|
||||
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
|
||||
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
|
||||
import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
|
||||
public class PlayerPermissionShow {
|
||||
|
||||
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"));
|
||||
for (PlayerDataBean pdb : pdbList) {
|
||||
PermissionPackageBean ppb = PackagesCfg.PACKAGES.get(pdb.getPackageName());
|
||||
if (ppb != null && pdb.getGlobal() == ppb.getGlobal()) {
|
||||
ItemStack item = PackagesCfg.PACKAGE_ITEMS.get(pdb.getPackageName());
|
||||
ItemStack tItem = item.clone();
|
||||
ItemMeta meta = tItem.getItemMeta();
|
||||
List<String> lores = meta.getLore();
|
||||
lores.add(StrUtil.messageFormat(LangCfg.EXPIRATION_TIME, StrUtil.timestampToString(pdb.getExpire())));
|
||||
lores.add(StrUtil.getLeftTime(pdb.getExpire()));
|
||||
meta.setLore(lores);
|
||||
tItem.setItemMeta(meta);
|
||||
inventory.addItem(tItem);
|
||||
}
|
||||
}
|
||||
p.openInventory(inventory);
|
||||
}
|
||||
public static void show(Player p, List<PlayerDataBean> pdbList) {
|
||||
Inventory inventory = null;
|
||||
int size = 0;
|
||||
if (pdbList.size() > 0) {
|
||||
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"));
|
||||
for (PlayerDataBean pdb : pdbList) {
|
||||
PermissionPackageBean ppb = PackagesCfg.PACKAGES.get(pdb.getPackageName());
|
||||
if (ppb != null && pdb.getGlobal() == ppb.getGlobal()) {
|
||||
ItemStack item = PackagesCfg.PACKAGE_ITEMS.get(pdb.getPackageName());
|
||||
ItemStack tItem = item.clone();
|
||||
ItemMeta meta = tItem.getItemMeta();
|
||||
List<String> lores = meta.getLore();
|
||||
lores.add(
|
||||
StrUtil.messageFormat(LangCfg.EXPIRATION_TIME, StrUtil.timestampToString(pdb.getExpire())));
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: PermissionsTime
|
||||
version: 0.3.1-SNAPSHOT
|
||||
version: 0.3.2-SNAPSHOT
|
||||
main: gg.frog.mc.permissionstime.PluginMain
|
||||
author: GeekFrog
|
||||
softdepend:
|
||||
|
10
帖子代码.txt
10
帖子代码.txt
@ -3,7 +3,7 @@
|
||||
[align=center][table=98%,#4169e1]
|
||||
[tr][td][align=center][size=6][color=#ffffff][b]唠叨[/b][/color][/size][/align][/td][/tr]
|
||||
[/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]
|
||||
[tr][td][align=center][size=6][color=#ffffff][b]前言[/b][/color][/size][/align][/td][/tr]
|
||||
[/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]
|
||||
[/table][/align][align=center][table=98%,gray]
|
||||
[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]
|
||||
1.跨服与非跨服权限包同名兼容处理[/color][/quote]
|
||||
[color=#ffffff]2017年8月2日 V0.3.1-V0.3.2[/color][quote][color=#000000]
|
||||
1.跨服与非跨服权限包同名兼容处理
|
||||
2.优化同名兼容处理
|
||||
3.修复一些BUG[/color][/quote]
|
||||
[color=#ffffff]2017年8月1日 V0.3.0[/color][quote][color=#000000]
|
||||
1.权限包到期可执行自定义命令[/color][/quote]
|
||||
[color=#ffffff]2017年7月31日 V0.2.4[/color][quote][color=#000000]
|
||||
@ -234,7 +236,7 @@ cmd:
|
||||
[/table][/align][align=center][table=98%,#4169e1]
|
||||
[tr][td][align=center][size=6][color=#ffffff][b]下载地址[/b][/color][/size][/align][/td][/tr]
|
||||
[/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][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]
|
||||
|
Loading…
Reference in New Issue
Block a user