mirror of
https://github.com/geekfrog/PermissionsTime.git
synced 2025-09-09 11:48:26 +00:00
修复BUG
称号功能完善
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user