1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-03 14:58:34 +01:00

mysql fixes / recalculate boost on command / disable autojoin if needed

This commit is contained in:
Zrips 2016-06-15 13:27:43 +03:00
parent a8466e5e2f
commit 445e30e407
10 changed files with 214 additions and 132 deletions

View File

@ -571,9 +571,12 @@ public class PlayerManager {
return false; return false;
} }
public double GetBoostInPerc(JobsPlayer player, Job job, BoostType type) { public double GetBoostInPerc(JobsPlayer player, Job job, BoostType type) {
double Boost = player.getBoost(job.getName(), type) * 100.0 - 100.0; return GetBoostInPerc(player, job, type, false);
}
public double GetBoostInPerc(JobsPlayer player, Job job, BoostType type, boolean force) {
double Boost = player.getBoost(job.getName(), type, force) * 100.0 - 100.0;
return Boost; return Boost;
} }
@ -713,6 +716,8 @@ public class PlayerManager {
return; return;
if (player.isOp()) if (player.isOp())
return; return;
if (!Jobs.getGCManager().AutoJobJoinUse)
return;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() { public void run() {
if (!player.isOnline()) if (!player.isOnline())
@ -720,20 +725,18 @@ public class PlayerManager {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null) if (jPlayer == null)
return; return;
if (player.hasPermission("jobs.*"))
return;
int confMaxJobs = Jobs.getGCManager().getMaxJobs(); int confMaxJobs = Jobs.getGCManager().getMaxJobs();
for (Job one : Jobs.getJobs()) { for (Job one : Jobs.getJobs()) {
if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots()) if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots())
continue; continue;
short PlayerMaxJobs = (short) jPlayer.getJobProgression().size(); short PlayerMaxJobs = (short) jPlayer.getJobProgression().size();
if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(player, PlayerMaxJobs)) if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(player, PlayerMaxJobs))
break; break;
if (jPlayer.isInJob(one)) if (jPlayer.isInJob(one))
continue; continue;
if (player.hasPermission("jobs.autojoin." + one.getName().toLowerCase()))
if (Perm.hasPermission(player, "jobs.autojoin." + one.getName().toLowerCase()))
Jobs.getPlayerManager().joinJob(jPlayer, one); Jobs.getPlayerManager().joinJob(jPlayer, one);
} }
return; return;

View File

@ -102,6 +102,7 @@ public class SignUtil {
int timelapse = 1; int timelapse = 1;
for (com.gamingmesh.jobs.Signs.Sign one : Copy) { for (com.gamingmesh.jobs.Signs.Sign one : Copy) {
String SignJobName = one.GetJobName(); String SignJobName = one.GetJobName();
if (JobName.equalsIgnoreCase(SignJobName)) { if (JobName.equalsIgnoreCase(SignJobName)) {
String SignsWorld = one.GetWorld(); String SignsWorld = one.GetWorld();
double SignsX = one.GetX(); double SignsX = one.GetX();
@ -198,6 +199,7 @@ public class SignUtil {
public void UpdateHead(final org.bukkit.block.Sign sign, final String Playername, final int timelapse) { public void UpdateHead(final org.bukkit.block.Sign sign, final String Playername, final int timelapse) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@SuppressWarnings("deprecation")
public void run() { public void run() {
org.bukkit.material.Sign signMat = (org.bukkit.material.Sign) sign.getData(); org.bukkit.material.Sign signMat = (org.bukkit.material.Sign) sign.getData();

View File

@ -41,11 +41,11 @@ public class bonus implements Cmd {
return false; return false;
// sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", job.getChatColor() + job.getName())); // sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", job.getChatColor() + job.getName()));
double PMoneyBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.MONEY); double PMoneyBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.MONEY, true);
PMoneyBoost = (int) (PMoneyBoost * 100D) / 100D; PMoneyBoost = (int) (PMoneyBoost * 100D) / 100D;
double PPointBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.POINTS); double PPointBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.POINTS, true);
PPointBoost = (int) (PPointBoost * 100D) / 100D; PPointBoost = (int) (PPointBoost * 100D) / 100D;
double PExpBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.EXP); double PExpBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.EXP, true);
PExpBoost = (int) (PExpBoost * 100D) / 100D; PExpBoost = (int) (PExpBoost * 100D) / 100D;
double GMoneyBoost = job.getMoneyBoost() * 100.0 - 100.0; double GMoneyBoost = job.getMoneyBoost() * 100.0 - 100.0;

View File

@ -125,7 +125,9 @@ public class GeneralConfigManager {
public boolean UseTaxes; public boolean UseTaxes;
public boolean TransferToServerAccount; public boolean TransferToServerAccount;
public boolean TakeFromPlayersPayment; public boolean TakeFromPlayersPayment;
public int AutoJobJoinDelay; public int AutoJobJoinDelay;
public boolean AutoJobJoinUse;
//BossBar //BossBar
public boolean BossBarEnabled; public boolean BossBarEnabled;
@ -418,12 +420,15 @@ public class GeneralConfigManager {
MultiServerCompatability = c.get("MultiServerCompatability", false); MultiServerCompatability = c.get("MultiServerCompatability", false);
if (MultiServerCompatability) if (MultiServerCompatability)
saveOnDisconnect = true; saveOnDisconnect = true;
c.getW().addComment("Optimizations.AutoJobJoinDelay", "Delay in seconds to perform auto join job if used after player joins server", c.getW().addComment("Optimizations.AutoJobJoin.Use", "Use or not auto join jobs feature",
"If you are not using auto join feature, keep it disabled");
AutoJobJoinUse = c.get("Optimizations.AutoJobJoin.Use", false);
c.getW().addComment("Optimizations.AutoJobJoin.Delay", "Delay in seconds to perform auto join job if used after player joins server",
"If you using offline server, try to keep it slightly more than your login plugin gives time to enter password", "If you using offline server, try to keep it slightly more than your login plugin gives time to enter password",
"For player to auto join job add permission node jobs.autojoin.[jobname]", "For player to auto join job add permission node jobs.autojoin.[jobname]",
"Op players are ignored"); "Op players are ignored");
AutoJobJoinDelay = c.get("Optimizations.AutoJobJoinDelay", 15); AutoJobJoinDelay = c.get("Optimizations.AutoJobJoin.Delay", 15);
c.getW().addComment("Optimizations.UseLocalOfflinePlayersData", "With this set to true, offline player data will be taken from local player data files", c.getW().addComment("Optimizations.UseLocalOfflinePlayersData", "With this set to true, offline player data will be taken from local player data files",
"This will eliminate small lag spikes when request is being send to mojangs servers for offline players data", "This will eliminate small lag spikes when request is being send to mojangs servers for offline players data",

View File

@ -209,6 +209,10 @@ public class JobsPlayer {
* @return the Boost * @return the Boost
*/ */
public double getBoost(String JobName, BoostType type) { public double getBoost(String JobName, BoostType type) {
return getBoost(JobName, type, false);
}
public double getBoost(String JobName, BoostType type, boolean force) {
if (this.player == null) if (this.player == null)
this.player = Bukkit.getPlayer(this.OffPlayer.getUniqueId()); this.player = Bukkit.getPlayer(this.OffPlayer.getUniqueId());
@ -225,7 +229,7 @@ public class JobsPlayer {
for (BoostCounter counter : counterList) { for (BoostCounter counter : counterList) {
if (counter.getType() != type) if (counter.getType() != type)
continue; continue;
if (time - counter.getTime() > 1000 * 60) { if (force || time - counter.getTime() > 1000 * 60) {
Boost = getPlayerBoost(JobName, type); Boost = getPlayerBoost(JobName, type);
counter.setBoost(Boost); counter.setBoost(Boost);
counter.setTime(time); counter.setTime(time);
@ -245,13 +249,11 @@ public class JobsPlayer {
counterList.add(new BoostCounter(type, Boost, time)); counterList.add(new BoostCounter(type, Boost, time));
boostCounter.put(JobName, counterList); boostCounter.put(JobName, counterList);
return Boost; return Boost;
} }
private Double getPlayerBoost(String JobName, BoostType type) { private Double getPlayerBoost(String JobName, BoostType type) {
double Boost = 1.0; double Boost = 1.0;
Debug.D("recalculating for " + JobName);
if (Perm.hasPermission(player, "jobs.boost." + JobName + "." + type.getName().toLowerCase()) || if (Perm.hasPermission(player, "jobs.boost." + JobName + "." + type.getName().toLowerCase()) ||
Perm.hasPermission(player, "jobs.boost." + JobName + ".all") || Perm.hasPermission(player, "jobs.boost." + JobName + ".all") ||
Perm.hasPermission(player, "jobs.boost.all.all") || Perm.hasPermission(player, "jobs.boost.all.all") ||

View File

@ -527,35 +527,97 @@ public class JobsDAOMySQL extends JobsDAO {
+ "points` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `userid` int, `totalpoints` double, `currentpoints` double);"); + "points` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `userid` int, `totalpoints` double, `currentpoints` double);");
} catch (SQLException e) { } catch (SQLException e) {
} }
// dropping 2 columns
PreparedStatement prestLogTemp = null;
ResultSet rsLogTemp = null;
try {
prestLogTemp = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "log`;");
rsLogTemp = prestLogTemp.executeQuery();
while (rsLogTemp.next()) {
rsLogTemp.getInt("userid");
rsLogTemp.getLong("time");
rsLogTemp.getString("action");
rsLogTemp.getString("itemname");
rsLogTemp.getInt("count");
rsLogTemp.getDouble("money");
rsLogTemp.getDouble("exp");
break;
}
} catch (Exception ex) {
try {
if (rsLogTemp != null)
rsLogTemp.close();
if (prestLogTemp != null)
prestLogTemp.close();
} catch (Exception e) {
}
try {
executeSQL("CREATE TABLE `" + getPrefix()
+ "log` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `userid` int, `username` varchar(20), `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
} catch (Exception e) {
}
} finally {
try {
if (rsLogTemp != null)
rsLogTemp.close();
if (prestLogTemp != null)
prestLogTemp.close();
} catch (Exception e) {
}
}
if (rows == 0) { if (rows == 0) {
HashMap<String, String> tempMap = new HashMap<String, String>(); HashMap<String, String> tempMap = new HashMap<String, String>();
PreparedStatement prest = null; PreparedStatement prestJobs = null;
try { try {
prest = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "jobs;"); prestJobs = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "jobs;");
ResultSet res = prest.executeQuery(); ResultSet res = prestJobs.executeQuery();
while (res.next()) { while (res.next()) {
tempMap.put(res.getString("player_uuid"), res.getString("username")); tempMap.put(res.getString("player_uuid"), res.getString("username"));
} }
} catch (Exception e) { } catch (Exception e) {
} finally {
if (prestJobs != null) {
try {
prestJobs.close();
} catch (SQLException e) {
}
}
} }
PreparedStatement prestArchive = null;
try { try {
prest = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "archive;"); prestArchive = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "archive;");
ResultSet res = prest.executeQuery(); ResultSet res = prestArchive.executeQuery();
while (res.next()) { while (res.next()) {
tempMap.put(res.getString("player_uuid"), res.getString("username")); tempMap.put(res.getString("player_uuid"), res.getString("username"));
} }
} catch (Exception e) { } catch (Exception e) {
} finally {
if (prestArchive != null) {
try {
prestArchive.close();
} catch (SQLException e) {
}
}
} }
PreparedStatement prestLog = null;
try { try {
prest = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "log;"); prestLog = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "log;");
ResultSet res = prest.executeQuery(); ResultSet res = prestLog.executeQuery();
while (res.next()) { while (res.next()) {
tempMap.put(res.getString("player_uuid"), res.getString("username")); tempMap.put(res.getString("player_uuid"), res.getString("username"));
} }
} catch (Exception e) { } catch (Exception e) {
} finally {
if (prestLog != null) {
try {
prestLog.close();
} catch (SQLException e) {
}
}
} }
try { try {
@ -565,31 +627,47 @@ public class JobsDAOMySQL extends JobsDAO {
e.printStackTrace(); e.printStackTrace();
} }
PreparedStatement prestUsers = null;
try { try {
prest = conn.prepareStatement("INSERT INTO `" + getPrefix() + "users` (`player_uuid`, `username`) VALUES (?, ?);"); prestUsers = conn.prepareStatement("INSERT INTO `" + getPrefix() + "users` (`player_uuid`, `username`) VALUES (?, ?);");
conn.setAutoCommit(false); conn.setAutoCommit(false);
for (Entry<String, String> users : tempMap.entrySet()) { for (Entry<String, String> users : tempMap.entrySet()) {
prest.setString(1, users.getKey()); prestUsers.setString(1, users.getKey());
prest.setString(2, users.getValue()); prestUsers.setString(2, users.getValue());
prest.addBatch(); prestUsers.addBatch();
} }
prest.executeBatch(); prestUsers.executeBatch();
conn.commit(); conn.commit();
conn.setAutoCommit(true); conn.setAutoCommit(true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (prestUsers != null) {
try {
prestUsers.close();
} catch (SQLException e) {
}
}
} }
HashMap<String, PlayerInfo> tempPlayerMap = new HashMap<String, PlayerInfo>(); HashMap<String, PlayerInfo> tempPlayerMap = new HashMap<String, PlayerInfo>();
PreparedStatement prestUsersT = null;
try { try {
prest = conn.prepareStatement("SELECT * FROM " + getPrefix() + "users;"); prestUsersT = conn.prepareStatement("SELECT * FROM " + getPrefix() + "users;");
ResultSet res = prest.executeQuery(); ResultSet res = prestUsersT.executeQuery();
while (res.next()) { while (res.next()) {
tempPlayerMap.put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id"))); tempPlayerMap.put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id")));
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (prestUsersT != null) {
try {
prestUsersT.close();
} catch (SQLException e) {
}
}
} }
// Modifying jobs main table // Modifying jobs main table
@ -597,19 +675,27 @@ public class JobsDAOMySQL extends JobsDAO {
executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `userid` int;"); executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `userid` int;");
} catch (Exception e) { } catch (Exception e) {
} }
PreparedStatement prestJobsT = null;
try { try {
prest = conn.prepareStatement("UPDATE `" + getPrefix() + "jobs` SET `userid` = ? WHERE `player_uuid` = ?;"); prestJobsT = conn.prepareStatement("UPDATE `" + getPrefix() + "jobs` SET `userid` = ? WHERE `player_uuid` = ?;");
conn.setAutoCommit(false); conn.setAutoCommit(false);
for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) { for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) {
prest.setInt(1, users.getValue().getID()); prestJobsT.setInt(1, users.getValue().getID());
prest.setString(2, users.getKey()); prestJobsT.setString(2, users.getKey());
prest.addBatch(); prestJobsT.addBatch();
} }
prest.executeBatch(); prestJobsT.executeBatch();
conn.commit(); conn.commit();
conn.setAutoCommit(true); conn.setAutoCommit(true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (prestJobsT != null) {
try {
prestJobsT.close();
} catch (SQLException e) {
}
}
} }
try { try {
@ -621,53 +707,32 @@ public class JobsDAOMySQL extends JobsDAO {
executeSQL("ALTER TABLE `" + getPrefix() + "archive` ADD COLUMN `userid` int;"); executeSQL("ALTER TABLE `" + getPrefix() + "archive` ADD COLUMN `userid` int;");
} catch (Exception e) { } catch (Exception e) {
} }
try {
prest = conn.prepareStatement("UPDATE `" + getPrefix() + "archive` SET `userid` = ? WHERE `player_uuid` = ?;");
conn.setAutoCommit(false);
for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) {
prest.setInt(1, users.getValue().getID());
prest.setString(2, users.getKey());
prest.addBatch();
}
prest.executeBatch();
conn.commit();
conn.setAutoCommit(true);
} catch (Exception e) {
e.printStackTrace();
}
PreparedStatement prestArchiveT = null;
try { try {
executeSQL("ALTER TABLE `" + getPrefix() + "archive` DROP COLUMN `player_uuid`, DROP COLUMN `username`;"); prestArchiveT = conn.prepareStatement("UPDATE `" + getPrefix() + "archive` SET `userid` = ? WHERE `player_uuid` = ?;");
} catch (Exception e) {
}
// Modifying jobs log table
try {
executeSQL("ALTER TABLE `" + getPrefix() + "log` ADD COLUMN `userid` int;");
} catch (Exception e) {
}
try {
prest = conn.prepareStatement("UPDATE `" + getPrefix() + "log` SET `userid` = ? WHERE `player_uuid` = ?;");
conn.setAutoCommit(false); conn.setAutoCommit(false);
for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) { for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) {
prest.setInt(1, users.getValue().getID()); prestArchiveT.setInt(1, users.getValue().getID());
prest.setString(2, users.getKey()); prestArchiveT.setString(2, users.getKey());
prest.addBatch(); prestArchiveT.addBatch();
} }
prest.executeBatch(); prestArchiveT.executeBatch();
conn.commit(); conn.commit();
conn.setAutoCommit(true); conn.setAutoCommit(true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if (prest != null) { if (prestArchiveT != null) {
try { try {
prest.close(); prestArchiveT.close();
} catch (SQLException e) { } catch (SQLException e) {
} }
} }
} }
try { try {
executeSQL("ALTER TABLE `" + getPrefix() + "log` DROP COLUMN `player_uuid`, DROP COLUMN `username`;"); executeSQL("ALTER TABLE `" + getPrefix() + "archive` DROP COLUMN `player_uuid`, DROP COLUMN `username`;");
} catch (Exception e) { } catch (Exception e) {
} }

View File

@ -29,7 +29,6 @@ import org.bukkit.Bukkit;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.PlayerInfo; import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.UUIDUtil; import com.gamingmesh.jobs.stuff.UUIDUtil;
public class JobsDAOSQLite extends JobsDAO { public class JobsDAOSQLite extends JobsDAO {
@ -504,7 +503,6 @@ public class JobsDAOSQLite extends JobsDAO {
@Override @Override
protected synchronized void checkUpdate9() throws SQLException { protected synchronized void checkUpdate9() throws SQLException {
Debug.D("checkling 9");
JobsConnection conn = getConnection(); JobsConnection conn = getConnection();
if (conn == null) { if (conn == null) {
Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to SQLite!"); Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to SQLite!");
@ -528,14 +526,55 @@ public class JobsDAOSQLite extends JobsDAO {
} }
} }
} }
// Create new points table // Create new points table
try { try {
executeSQL("CREATE TABLE `" + getPrefix() executeSQL("CREATE TABLE `" + getPrefix()
+ "points` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `totalpoints` double, `currentpoints` double);"); + "points` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `totalpoints` double, `currentpoints` double);");
} catch (Exception e) { } catch (Exception e) {
} }
// checking log table, recreating if old version present
PreparedStatement prestLogTemp = null;
ResultSet rsLogTemp = null;
try {
prestLogTemp = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "log`;");
rsLogTemp = prestLogTemp.executeQuery();
while (rsLogTemp.next()) {
rsLogTemp.getInt("userid");
rsLogTemp.getLong("time");
rsLogTemp.getString("action");
rsLogTemp.getString("itemname");
rsLogTemp.getInt("count");
rsLogTemp.getDouble("money");
rsLogTemp.getDouble("exp");
break;
}
} catch (Exception ex) {
try {
if (rsLogTemp != null)
rsLogTemp.close();
if (prestLogTemp != null)
prestLogTemp.close();
} catch (Exception e) {
}
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;");
try {
executeSQL("CREATE TABLE `" + getPrefix()
+ "log_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
} catch (Exception e) {
e.printStackTrace();
}
} finally {
try {
if (rsLogTemp != null)
rsLogTemp.close();
if (prestLogTemp != null)
prestLogTemp.close();
} catch (Exception e) {
}
}
if (rows != 0) if (rows != 0)
return; return;
@ -712,26 +751,33 @@ public class JobsDAOSQLite extends JobsDAO {
} catch (Exception e) { } catch (Exception e) {
} }
PreparedStatement pstArchive = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "archive`;"); PreparedStatement pstArchive = null;
ResultSet rsArchive = pstArchive.executeQuery(); ResultSet rsArchive = null;
PreparedStatement insertArchive = null; PreparedStatement insertArchive = null;
while (rsArchive.next()) { try {
String uuid = UUIDUtil.fromBytes(rsArchive.getBytes("player_uuid")).toString(); pstArchive = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "archive`;");
if (uuid != null) { rsArchive = pstArchive.executeQuery();
insertArchive = conn.prepareStatement("INSERT INTO `" + getPrefix() + "archive_temp` (`userid`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?);"); while (rsArchive.next()) {
insertArchive.setInt(1, rsArchive.getInt("userid")); String uuid = UUIDUtil.fromBytes(rsArchive.getBytes("player_uuid")).toString();
insertArchive.setString(2, rsArchive.getString("job")); if (uuid != null) {
insertArchive.setInt(3, rsArchive.getInt("experience")); insertArchive = conn.prepareStatement("INSERT INTO `" + getPrefix() + "archive_temp` (`userid`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?);");
insertArchive.setInt(4, rsArchive.getInt("level")); insertArchive.setInt(1, rsArchive.getInt("userid"));
insertArchive.execute(); insertArchive.setString(2, rsArchive.getString("job"));
insertArchive.setInt(3, rsArchive.getInt("experience"));
insertArchive.setInt(4, rsArchive.getInt("level"));
insertArchive.execute();
}
} }
} catch (Exception e) {
} finally {
if (rsArchive != null)
rsArchive.close();
if (insertArchive != null)
insertArchive.close();
if (pstArchive != null)
pstArchive.close();
} }
if (rsArchive != null)
rsArchive.close();
if (insertArchive != null)
insertArchive.close();
if (pstArchive != null)
pstArchive.close();
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "archive`;"); executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "archive`;");
try { try {
executeSQL("ALTER TABLE `" + getPrefix() + "archive_temp` RENAME TO `" + getPrefix() + "archive`;"); executeSQL("ALTER TABLE `" + getPrefix() + "archive_temp` RENAME TO `" + getPrefix() + "archive`;");
@ -760,45 +806,6 @@ public class JobsDAOSQLite extends JobsDAO {
} }
} }
// dropping 2 columns
try {
executeSQL("CREATE TABLE `" + getPrefix()
+ "log_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
} catch (Exception e) {
e.printStackTrace();
}
PreparedStatement prestLogT = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "log`;");
ResultSet rsLog = prestLogT.executeQuery();
PreparedStatement insertLog = null;
while (rsLog.next()) {
String uuid = UUIDUtil.fromBytes(rsLog.getBytes("player_uuid")).toString();
if (uuid != null) {
insertLog = conn.prepareStatement("INSERT INTO `" + getPrefix()
+ "log_temp` (`userid`, `time`, `action`, `itemname`, `count`, `money`, `exp`) VALUES (?, ?, ?, ?, ?, ?, ?);");
insertLog.setInt(1, rsLog.getInt("userid"));
insertLog.setLong(2, rsLog.getLong("time"));
insertLog.setString(3, rsLog.getString("action"));
insertLog.setString(4, rsLog.getString("itemname"));
insertLog.setInt(5, rsLog.getInt("count"));
insertLog.setDouble(6, rsLog.getDouble("money"));
insertLog.setDouble(7, rsLog.getDouble("exp"));
insertLog.execute();
}
}
rsLog.close();
if (insertLog != null)
insertLog.close();
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;");
try {
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
} catch (Exception e) {
e.printStackTrace();
}
} }
private boolean createDefaultExploreBase() { private boolean createDefaultExploreBase() {

View File

@ -426,10 +426,8 @@ public class JobsListener implements Listener {
public void onPlayerChat(AsyncPlayerChatEvent event) { public void onPlayerChat(AsyncPlayerChatEvent event) {
if (!plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
if (!Jobs.getGCManager().getModifyChat()) if (!Jobs.getGCManager().getModifyChat())
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);

View File

@ -5,11 +5,11 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Debug { public class Debug {
public static void D(String message) { public static void D(Object message) {
Player player = Bukkit.getPlayer("Zrips"); Player player = Bukkit.getPlayer("Zrips");
if (player == null) if (player == null)
return; return;
player.sendMessage(ChatColor.DARK_GRAY + "[Jobs Debug] " + ChatColor.DARK_AQUA + ChatColor.translateAlternateColorCodes('&', message)); player.sendMessage(ChatColor.DARK_GRAY + "[Jobs Debug] " + ChatColor.DARK_AQUA + ChatColor.translateAlternateColorCodes('&', String.valueOf(message)));
return; return;
} }
} }

View File

@ -1,7 +1,7 @@
name: Jobs name: Jobs
description: Jobs Plugin for the BukkitAPI description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.JobsPlugin main: com.gamingmesh.jobs.JobsPlugin
version: 3.4.5 version: 3.4.7
author: phrstbrn author: phrstbrn
depend: [Vault] depend: [Vault]
softdepend: [CoreProtect, MythicMobs, McMMO] softdepend: [CoreProtect, MythicMobs, McMMO]