1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 15:03:36 +01:00

2.54.1 update

This commit is contained in:
Zrips 2015-12-10 15:13:57 +02:00
parent 43abccf7d7
commit 8f129bc217
12 changed files with 451 additions and 147 deletions

View File

@ -1,6 +1,7 @@
package com.gamingmesh.jobs.Gui; package com.gamingmesh.jobs.Gui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -61,7 +62,7 @@ public class GuiTools {
List<JobProgression> pJobs = JPlayer.getJobProgression(); List<JobProgression> pJobs = JPlayer.getJobProgression();
Inventory GuiInv = Bukkit.createInventory(null, GuiSize, "Pick your job!"); Inventory GuiInv = Bukkit.createInventory(null, GuiSize, Language.getMessage("command.info.gui.pickjob"));
for (int i = 0; i < JobsList.size(); i++) { for (int i = 0; i < JobsList.size(); i++) {
@ -92,16 +93,17 @@ public class GuiTools {
else else
Lore.add(Language.getMessage("command.browse.output.bonus").replace("[amount]", String.valueOf((int) (job.getBonus() * 100) / 100.0))); Lore.add(Language.getMessage("command.browse.output.bonus").replace("[amount]", String.valueOf((int) (job.getBonus() * 100) / 100.0)));
Lore.add(job.getDescription()); Lore.addAll(Arrays.asList(job.getDescription().split("/n")));
if (job.getMaxSlots() != null) if (job.getMaxSlots() != null)
Lore.add(Language.getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs.getUsedSlots(job)) : 0)); Lore.add(Language.getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs.getUsedSlots(
job)) : 0));
Lore.add(Language.getMessage("command.info.gui.actions")); Lore.add(Language.getMessage("command.info.gui.actions"));
for (ActionType actionType : ActionType.values()) { for (ActionType actionType : ActionType.values()) {
List<JobInfo> info = job.getJobInfo(actionType); List<JobInfo> info = job.getJobInfo(actionType);
if (info != null && !info.isEmpty()) { if (info != null && !info.isEmpty()) {
Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + actionType.getName())); Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Language.getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info")));
} }
} }
@ -227,7 +229,7 @@ public class GuiTools {
// backButton = 53; // backButton = 53;
// } // }
Inventory GuiInv = Bukkit.createInventory(null, GuiSize, job.getName() + " Info!"); Inventory GuiInv = Bukkit.createInventory(null, GuiSize, Language.getMessage("command.info.gui.jobinfo").replace("[jobname]", job.getName()));
for (int i1 = 0; i1 < items.size(); i1++) { for (int i1 = 0; i1 < items.size(); i1++) {
GuiInv.setItem(i1, items.get(i1)); GuiInv.setItem(i1, items.get(i1));

View File

@ -341,7 +341,8 @@ public class Jobs {
paymentLimit.put(playername, data); paymentLimit.put(playername, data);
} else { } else {
PaymentData data = paymentLimit.get(playername); PaymentData data = paymentLimit.get(playername);
if (data.IsReachedMoneyLimit(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit, ConfigManager.getJobsConfiguration().EconomyLimitMoneyLimit)) { JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(player);
if (data.IsReachedMoneyLimit(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit, JPlayer.getMoneyLimit())) {
if (player.isOnline() && !data.Informed && !data.isReseted()) { if (player.isOnline() && !data.Informed && !data.isReseted()) {
((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedlimit")); ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedlimit"));
((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedlimit2")); ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedlimit2"));
@ -379,7 +380,8 @@ public class Jobs {
ExpLimit.put(playername, data); ExpLimit.put(playername, data);
} else { } else {
PaymentData data = ExpLimit.get(playername); PaymentData data = ExpLimit.get(playername);
if (data.IsReachedExpLimit(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit, ConfigManager.getJobsConfiguration().EconomyExpLimit)) { JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(player);
if (data.IsReachedExpLimit(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit, JPlayer.getExpLimit())) {
if (player.isOnline() && !data.Informed && !data.isReseted()) { if (player.isOnline() && !data.Informed && !data.isReseted()) {
((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit")); ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit"));
((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit2")); ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit2"));

View File

@ -571,6 +571,8 @@ public class PlayerManager {
} }
if (jPlayer.isOnline()) { if (jPlayer.isOnline()) {
jPlayer.reloadHonorific(); jPlayer.reloadHonorific();
jPlayer.reloadMoneyLimit();
jPlayer.reloadExpLimit();
Jobs.getPermissionHandler().recalculatePermissions(jPlayer); Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
} }
} }

View File

@ -643,7 +643,7 @@ public class JobsCommands implements CommandExecutor {
lines.add(builder.toString()); lines.add(builder.toString());
if (!job.getDescription().isEmpty()) { if (!job.getDescription().isEmpty()) {
lines.add(" - " + job.getDescription()); lines.add(" - " + job.getDescription().replace("/n", ""));
} }
} }
@ -656,11 +656,13 @@ public class JobsCommands implements CommandExecutor {
((Player) sender).openInventory(GuiTools.CreateJobsGUI((Player) sender)); ((Player) sender).openInventory(GuiTools.CreateJobsGUI((Player) sender));
} }
sender.sendMessage(Language.getMessage("command.browse.output.header")); if (ConfigManager.getJobsConfiguration().JobsGUIShowChatBrowse) {
for (String line : lines) { sender.sendMessage(Language.getMessage("command.browse.output.header"));
sender.sendMessage(line); for (String line : lines) {
sender.sendMessage(line);
}
sender.sendMessage(Language.getMessage("command.browse.output.footer"));
} }
sender.sendMessage(Language.getMessage("command.browse.output.footer"));
return true; return true;
} }
@ -1268,6 +1270,7 @@ public class JobsCommands implements CommandExecutor {
player.sendMessage(Language.getMessage("command.limit.output.notenabled")); player.sendMessage(Language.getMessage("command.limit.output.notenabled"));
return true; return true;
} }
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
String playername = player.getName(); String playername = player.getName();
@ -1283,8 +1286,8 @@ public class JobsCommands implements CommandExecutor {
player.sendMessage(lefttimemessage); player.sendMessage(lefttimemessage);
String message = Language.getMessage("command.limit.output.moneylimit"); String message = Language.getMessage("command.limit.output.moneylimit");
message = message.replace("%money%", String.valueOf(data.GetAmountBylimit(ConfigManager.getJobsConfiguration().EconomyLimitMoneyLimit))); message = message.replace("%money%", String.valueOf(data.GetAmountBylimit(JPlayer.getMoneyLimit())));
message = message.replace("%totalmoney%", String.valueOf(ConfigManager.getJobsConfiguration().EconomyLimitMoneyLimit)); message = message.replace("%totalmoney%", String.valueOf(JPlayer.getMoneyLimit()));
player.sendMessage(message); player.sendMessage(message);
} else { } else {
@ -1315,7 +1318,7 @@ public class JobsCommands implements CommandExecutor {
player.sendMessage(message); player.sendMessage(message);
message = Language.getMessage("command.limit.output.moneylimit").replace("%money%", "0.0"); message = Language.getMessage("command.limit.output.moneylimit").replace("%money%", "0.0");
message = message.replace("%totalmoney%", String.valueOf(ConfigManager.getJobsConfiguration().EconomyLimitMoneyLimit)); message = message.replace("%totalmoney%", String.valueOf(JPlayer.getMoneyLimit()));
player.sendMessage(message); player.sendMessage(message);
} }
@ -1330,8 +1333,8 @@ public class JobsCommands implements CommandExecutor {
player.sendMessage(lefttimemessage); player.sendMessage(lefttimemessage);
String message = Language.getMessage("command.limit.output.explimit"); String message = Language.getMessage("command.limit.output.explimit");
message = message.replace("%exp%", String.valueOf(data.GetExpBylimit(ConfigManager.getJobsConfiguration().EconomyExpLimit))); message = message.replace("%exp%", String.valueOf(data.GetExpBylimit(JPlayer.getExpLimit())));
message = message.replace("%totalexp%", String.valueOf(ConfigManager.getJobsConfiguration().EconomyExpLimit)); message = message.replace("%totalexp%", String.valueOf(JPlayer.getExpLimit()));
player.sendMessage(message); player.sendMessage(message);
} else { } else {
@ -1362,7 +1365,7 @@ public class JobsCommands implements CommandExecutor {
player.sendMessage(message); player.sendMessage(message);
message = Language.getMessage("command.limit.output.explimit").replace("%exp%", "0.0"); message = Language.getMessage("command.limit.output.explimit").replace("%exp%", "0.0");
message = message.replace("%totalexp%", String.valueOf(ConfigManager.getJobsConfiguration().EconomyExpLimit)); message = message.replace("%totalexp%", String.valueOf(JPlayer.getExpLimit()));
player.sendMessage(message); player.sendMessage(message);
} }

View File

@ -75,7 +75,6 @@ public class JobsConfiguration {
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse, SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse,
EnableAnounceMessage, useBlockPiston, useSilkTouchProtection, UseCustomNames, EconomyMoneyStop, EnableAnounceMessage, useBlockPiston, useSilkTouchProtection, UseCustomNames, EconomyMoneyStop,
EconomyExpStop, UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit; EconomyExpStop, UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit;
public int EconomyLimitMoneyLimit, EconomyExpLimit;
public int EconomyLimitTimeLimit, EconomyExpTimeLimit; public int EconomyLimitTimeLimit, EconomyExpTimeLimit;
public int EconomyLimitAnnouncmentDelay, EconomyLimitAnnouncmentExpDelay, globalblocktimer, CowMilkingTimer, public int EconomyLimitAnnouncmentDelay, EconomyLimitAnnouncmentExpDelay, globalblocktimer, CowMilkingTimer,
CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval; CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval;
@ -87,7 +86,7 @@ public class JobsConfiguration {
public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat,
LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat, LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat,
EmptyServerAcountActionBar, JobsToggleEnabled, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, EmptyServerAcountActionBar, JobsToggleEnabled, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
useGlobalBoostScheduler, JobsGUIOpenOnBrowse,JobsGUIOpenOnJoin; useGlobalBoostScheduler, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin;
public Integer levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume, public Integer levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume,
SoundTitleChangePitch, ToplistInScoreboardInterval; SoundTitleChangePitch, ToplistInScoreboardInterval;
public double BoostExp; public double BoostExp;
@ -104,6 +103,8 @@ public class JobsConfiguration {
public boolean TakeFromPlayersPayment; public boolean TakeFromPlayersPayment;
public Parser DynamicPaymentEquation; public Parser DynamicPaymentEquation;
public Parser maxMoneyEquation;
public Parser maxExpEquation;
public List<Schedule> BoostSchedule = new ArrayList<Schedule>(); public List<Schedule> BoostSchedule = new ArrayList<Schedule>();
@ -476,7 +477,22 @@ public class JobsConfiguration {
EconomyLimitUse = getBoolean("Economy.Limit.Money.Use", false, config, writer); EconomyLimitUse = getBoolean("Economy.Limit.Money.Use", false, config, writer);
writer.addComment("Economy.Limit.Money.StopWithExp", "Do you want to stop money gain when exp limit reached?"); writer.addComment("Economy.Limit.Money.StopWithExp", "Do you want to stop money gain when exp limit reached?");
EconomyMoneyStop = getBoolean("Economy.Limit.Money.StopWithExp", false, config, writer); EconomyMoneyStop = getBoolean("Economy.Limit.Money.StopWithExp", false, config, writer);
EconomyLimitMoneyLimit = getInt("Economy.Limit.Money.MoneyLimit", 500, config, writer);
writer.addComment("Economy.Limit.Money.MoneyLimit",
"Equation to calculate max money limit. Option to use totallevel to include players total amount levels of current jobs",
"You can always use simple number to set money limit",
"Default equation is: 500+500*(totallevel/100), this will add 1% from 500 for each level player have",
"So player with 2 jobs with level 15 and 22 will have 685 limit");
String MoneyLimit = getString("Economy.Limit.Money.MoneyLimit", "500+500*(totallevel/100)", config, writer);
try {
maxMoneyEquation = new Parser(MoneyLimit);
maxMoneyEquation.setVariable("totallevel", 1);
maxMoneyEquation.getValue();
} catch (Exception e) {
Jobs.getPluginLogger().warning("MoneyLimit has an invalid value. Disabling money limit!");
EconomyLimitUse = false;
}
writer.addComment("Economy.Limit.Money.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); writer.addComment("Economy.Limit.Money.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
EconomyLimitTimeLimit = getInt("Economy.Limit.Money.TimeLimit", 3600, config, writer); EconomyLimitTimeLimit = getInt("Economy.Limit.Money.TimeLimit", 3600, config, writer);
writer.addComment("Economy.Limit.Money.AnnouncmentDelay", "Delay between announcements about reached money limit", writer.addComment("Economy.Limit.Money.AnnouncmentDelay", "Delay between announcements about reached money limit",
@ -488,7 +504,21 @@ public class JobsConfiguration {
EconomyExpLimitUse = getBoolean("Economy.Limit.Exp.Use", false, config, writer); EconomyExpLimitUse = getBoolean("Economy.Limit.Exp.Use", false, config, writer);
writer.addComment("Economy.Limit.Exp.StopWithMoney", "Do you want to stop exp gain when money limit reached?"); writer.addComment("Economy.Limit.Exp.StopWithMoney", "Do you want to stop exp gain when money limit reached?");
EconomyExpStop = getBoolean("Economy.Limit.Exp.StopWithMoney", false, config, writer); EconomyExpStop = getBoolean("Economy.Limit.Exp.StopWithMoney", false, config, writer);
EconomyExpLimit = getInt("Economy.Limit.Exp.Limit", 5000, config, writer);
writer.addComment("Economy.Limit.Exp.Limit", "Equation to calculate max money limit. Option to use totallevel to include players total amount of current jobs",
"You can always use simple number to set exp limit",
"Default equation is: 5000+5000*(totallevel/100), this will add 1% from 5000 for each level player have",
"So player with 2 jobs with level 15 and 22 will have 6850 limit");
String expLimit = getString("Economy.Limit.Exp.Limit", "5000+5000*(totallevel/100)", config, writer);
try {
maxExpEquation = new Parser(expLimit);
maxExpEquation.setVariable("totallevel", 1);
maxExpEquation.getValue();
} catch (Exception e) {
Jobs.getPluginLogger().warning("ExpLimit has an invalid value. Disabling money limit!");
EconomyExpLimitUse = false;
}
writer.addComment("Economy.Limit.Exp.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); writer.addComment("Economy.Limit.Exp.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours");
EconomyExpTimeLimit = getInt("Economy.Limit.Exp.TimeLimit", 3600, config, writer); EconomyExpTimeLimit = getInt("Economy.Limit.Exp.TimeLimit", 3600, config, writer);
writer.addComment("Economy.Limit.Exp.AnnouncmentDelay", "Delay between announcements about reached Exp limit", writer.addComment("Economy.Limit.Exp.AnnouncmentDelay", "Delay between announcements about reached Exp limit",
@ -627,6 +657,11 @@ public class JobsConfiguration {
writer.addComment("JobsGUI.OpenOnBrowse", "Do you want to show GUI when performing /jobs browse command"); writer.addComment("JobsGUI.OpenOnBrowse", "Do you want to show GUI when performing /jobs browse command");
JobsGUIOpenOnBrowse = getBoolean("JobsGUI.OpenOnBrowse", true, config, writer); JobsGUIOpenOnBrowse = getBoolean("JobsGUI.OpenOnBrowse", true, config, writer);
writer.addComment("JobsGUI.ShowChatBrowse", "Do you want to show chat information when performing /jobs browse command");
JobsGUIShowChatBrowse = getBoolean("JobsGUI.ShowChatBrowse", true, config, writer);
writer.addComment("JobsGUI.SwitcheButtons", "With true left mouse button will join job and right will show more info",
"With false left mouse button will show more info, rigth will join job", "Dont forget to adjust locale file");
JobsGUISwitcheButtons = getBoolean("JobsGUI.SwitcheButtons", false, config, writer);
writer.addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show GUI when performing /jobs join command"); writer.addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show GUI when performing /jobs join command");
JobsGUIOpenOnJoin = getBoolean("JobsGUI.OpenOnJoin", true, config, writer); JobsGUIOpenOnJoin = getBoolean("JobsGUI.OpenOnJoin", true, config, writer);
@ -1219,6 +1254,8 @@ public class JobsConfiguration {
GetConfigString("command.info.help.max", " - &emax level:&f ", writer, conf, true); GetConfigString("command.info.help.max", " - &emax level:&f ", writer, conf, true);
GetConfigString("command.info.help.material", "&7%material%", writer, conf, true); GetConfigString("command.info.help.material", "&7%material%", writer, conf, true);
GetConfigString("command.info.gui.pickjob", "&ePick your job!", writer, conf, true);
GetConfigString("command.info.gui.jobinfo", "&e[jobname] info!", writer, conf, true);
GetConfigString("command.info.gui.actions", "&eValid actions are:", writer, conf, true); GetConfigString("command.info.gui.actions", "&eValid actions are:", writer, conf, true);
GetConfigString("command.info.gui.leftClick", "&eLeft Click for more info", writer, conf, true); GetConfigString("command.info.gui.leftClick", "&eLeft Click for more info", writer, conf, true);
GetConfigString("command.info.gui.rightClick", "&eRight click to join job", writer, conf, true); GetConfigString("command.info.gui.rightClick", "&eRight click to join job", writer, conf, true);
@ -1327,7 +1364,8 @@ public class JobsConfiguration {
GetConfigString("command.glog.help.info", "Shows global statistics.", writer, conf, true); GetConfigString("command.glog.help.info", "Shows global statistics.", writer, conf, true);
GetConfigString("command.glog.help.args", "", writer, conf, true); GetConfigString("command.glog.help.args", "", writer, conf, true);
GetConfigString("command.glog.output.topline", "&7*********************** &6Global statistics &7***********************", writer, conf, true); GetConfigString("command.glog.output.topline", "&7*********************** &6Global statistics &7***********************", writer, conf, true);
GetConfigString("command.glog.output.list", "&7* &6%number%. &3%username% &e%action%: &6%item% &eqty: %qty% &6money: %money% &eexp: %exp%", writer, conf, true); GetConfigString("command.glog.output.list", "&7* &6%number%. &3%username% &e%action%: &6%item% &eqty: %qty% &6money: %money% &eexp: %exp%", writer, conf,
true);
GetConfigString("command.glog.output.bottomline", "&7**************************************************************", writer, conf, true); GetConfigString("command.glog.output.bottomline", "&7**************************************************************", writer, conf, true);
GetConfigString("command.transfer.help.info", "Transfer a player's job from an old job to a new job.", writer, conf, true); GetConfigString("command.transfer.help.info", "Transfer a player's job from an old job to a new job.", writer, conf, true);

View File

@ -30,6 +30,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.config.ConfigManager;
import com.gamingmesh.jobs.dao.JobsDAO; import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.dao.JobsDAOData; import com.gamingmesh.jobs.dao.JobsDAOData;
import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor; import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Perm; import com.gamingmesh.jobs.stuff.Perm;
@ -50,6 +51,9 @@ public class JobsPlayer {
private double VipSpawnerMultiplier = -1; private double VipSpawnerMultiplier = -1;
private int MoneyLimit = 0;
private int ExpLimit = 0;
// save lock // save lock
// public final Object saveLock = new Object(); // public final Object saveLock = new Object();
@ -67,23 +71,25 @@ public class JobsPlayer {
jPlayer.playerUUID = player.getUniqueId(); jPlayer.playerUUID = player.getUniqueId();
List<JobsDAOData> list = dao.getAllJobs(player); List<JobsDAOData> list = dao.getAllJobs(player);
// synchronized (jPlayer.saveLock) { // synchronized (jPlayer.saveLock) {
jPlayer.progression.clear(); jPlayer.progression.clear();
for (JobsDAOData jobdata : list) { for (JobsDAOData jobdata : list) {
if (Jobs.getJob(jobdata.getJobName()) == null) if (Jobs.getJob(jobdata.getJobName()) == null)
continue; continue;
// add the job // add the job
Job job = Jobs.getJob(jobdata.getJobName()); Job job = Jobs.getJob(jobdata.getJobName());
if (job == null) if (job == null)
continue; continue;
// create the progression object // create the progression object
JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience(), -1, -1); JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience(), -1, -1);
// calculate the max level // calculate the max level
// add the progression level. // add the progression level.
jPlayer.progression.add(jobProgression); jPlayer.progression.add(jobProgression);
} }
jPlayer.reloadMaxExperience(); jPlayer.reloadMaxExperience();
jPlayer.reloadMoneyLimit();
jPlayer.reloadExpLimit();
// } // }
return jPlayer; return jPlayer;
} }
@ -162,6 +168,40 @@ public class JobsPlayer {
} }
} }
/**
* Reloads money limit for this player.
*/
public void reloadMoneyLimit() {
int TotalLevel = 0;
for (JobProgression prog : progression) {
TotalLevel += prog.getLevel();
}
Parser eq = ConfigManager.getJobsConfiguration().maxMoneyEquation;
eq.setVariable("totallevel", TotalLevel);
MoneyLimit = (int) eq.getValue();
}
/**
* Reloads exp limit for this player.
*/
public void reloadExpLimit() {
int TotalLevel = 0;
for (JobProgression prog : progression) {
TotalLevel += prog.getLevel();
}
Parser eq = ConfigManager.getJobsConfiguration().maxExpEquation;
eq.setVariable("totallevel", TotalLevel);
ExpLimit = (int) eq.getValue();
}
public int getMoneyLimit() {
return this.MoneyLimit;
}
public int getExpLimit() {
return this.ExpLimit;
}
/** /**
* Get the list of job progressions * Get the list of job progressions
* @return the list of job progressions * @return the list of job progressions
@ -218,23 +258,25 @@ public class JobsPlayer {
*/ */
public boolean joinJob(Job job, JobsPlayer jPlayer) { public boolean joinJob(Job job, JobsPlayer jPlayer) {
// synchronized (saveLock) { // synchronized (saveLock) {
if (!isInJob(job)) { if (!isInJob(job)) {
int level = 1; int level = 1;
int exp = 0; int exp = 0;
if (Jobs.getJobsDAO().checkArchive(jPlayer, job).size() > 0) { if (Jobs.getJobsDAO().checkArchive(jPlayer, job).size() > 0) {
List<Integer> info = Jobs.getJobsDAO().checkArchive(jPlayer, job); List<Integer> info = Jobs.getJobsDAO().checkArchive(jPlayer, job);
level = info.get(0); level = info.get(0);
//exp = info.get(1); //exp = info.get(1);
Jobs.getJobsDAO().deleteArchive(jPlayer, job); Jobs.getJobsDAO().deleteArchive(jPlayer, job);
}
progression.add(new JobProgression(job, this, level, exp, -1, -1));
reloadMaxExperience();
reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(this);
return true;
} }
return false;
progression.add(new JobProgression(job, this, level, exp, -1, -1));
reloadMaxExperience();
reloadMoneyLimit();
reloadExpLimit();
reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(this);
return true;
}
return false;
// } // }
} }
@ -244,15 +286,17 @@ public class JobsPlayer {
*/ */
public boolean leaveJob(Job job) { public boolean leaveJob(Job job) {
// synchronized (saveLock) { // synchronized (saveLock) {
JobProgression prog = getJobProgression(job); JobProgression prog = getJobProgression(job);
if (prog != null) { if (prog != null) {
progression.remove(prog); progression.remove(prog);
reloadMaxExperience(); reloadMaxExperience();
reloadHonorific(); reloadMoneyLimit();
Jobs.getPermissionHandler().recalculatePermissions(this); reloadExpLimit();
return true; reloadHonorific();
} Jobs.getPermissionHandler().recalculatePermissions(this);
return false; return true;
}
return false;
// } // }
} }
@ -262,11 +306,11 @@ public class JobsPlayer {
*/ */
public boolean leaveAllJobs() { public boolean leaveAllJobs() {
// synchronized (saveLock) { // synchronized (saveLock) {
progression.clear(); progression.clear();
reloadHonorific(); reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(this); Jobs.getPermissionHandler().recalculatePermissions(this);
; ;
return true; return true;
// } // }
} }
@ -277,22 +321,22 @@ public class JobsPlayer {
*/ */
public void promoteJob(Job job, int levels, JobsPlayer player) { public void promoteJob(Job job, int levels, JobsPlayer player) {
// synchronized (saveLock) { // synchronized (saveLock) {
JobProgression prog = getJobProgression(job); JobProgression prog = getJobProgression(job);
if (prog == null) if (prog == null)
return; return;
if (levels <= 0) if (levels <= 0)
return; return;
int newLevel = prog.getLevel() + levels; int newLevel = prog.getLevel() + levels;
int maxLevel = job.getMaxLevel(); int maxLevel = job.getMaxLevel();
if (player.havePermission("jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0) if (player.havePermission("jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0)
maxLevel = job.getVipMaxLevel(); maxLevel = job.getVipMaxLevel();
if (maxLevel > 0 && newLevel > maxLevel) { if (maxLevel > 0 && newLevel > maxLevel) {
newLevel = maxLevel; newLevel = maxLevel;
} }
setLevel(job, newLevel); setLevel(job, newLevel);
// } // }
} }
@ -303,16 +347,16 @@ public class JobsPlayer {
*/ */
public void demoteJob(Job job, int levels) { public void demoteJob(Job job, int levels) {
// synchronized (saveLock) { // synchronized (saveLock) {
JobProgression prog = getJobProgression(job); JobProgression prog = getJobProgression(job);
if (prog == null) if (prog == null)
return; return;
if (levels <= 0) if (levels <= 0)
return; return;
int newLevel = prog.getLevel() - levels; int newLevel = prog.getLevel() - levels;
if (newLevel < 1) { if (newLevel < 1) {
newLevel = 1; newLevel = 1;
} }
setLevel(job, newLevel); setLevel(job, newLevel);
// } // }
} }
@ -323,16 +367,16 @@ public class JobsPlayer {
*/ */
private void setLevel(Job job, int level) { private void setLevel(Job job, int level) {
// synchronized (saveLock) { // synchronized (saveLock) {
JobProgression prog = getJobProgression(job); JobProgression prog = getJobProgression(job);
if (prog == null) if (prog == null)
return; return;
if (level != prog.getLevel()) { if (level != prog.getLevel()) {
prog.setLevel(level); prog.setLevel(level);
reloadHonorific(); reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(this); Jobs.getPermissionHandler().recalculatePermissions(this);
; ;
} }
// } // }
} }
@ -343,30 +387,32 @@ public class JobsPlayer {
*/ */
public boolean transferJob(Job oldjob, Job newjob, JobsPlayer jPlayer) { public boolean transferJob(Job oldjob, Job newjob, JobsPlayer jPlayer) {
// synchronized (saveLock) { // synchronized (saveLock) {
if (!isInJob(newjob)) { if (!isInJob(newjob)) {
for (JobProgression prog : progression) { for (JobProgression prog : progression) {
if (!prog.getJob().equals(oldjob)) if (!prog.getJob().equals(oldjob))
continue; continue;
prog.setJob(newjob); prog.setJob(newjob);
int maxLevel = 0; int maxLevel = 0;
if (jPlayer.havePermission("jobs." + newjob.getName() + ".vipmaxlevel")) if (jPlayer.havePermission("jobs." + newjob.getName() + ".vipmaxlevel"))
maxLevel = newjob.getVipMaxLevel(); maxLevel = newjob.getVipMaxLevel();
else else
maxLevel = newjob.getMaxLevel(); maxLevel = newjob.getMaxLevel();
if (newjob.getMaxLevel() > 0 && prog.getLevel() > maxLevel) { if (newjob.getMaxLevel() > 0 && prog.getLevel() > maxLevel) {
prog.setLevel(maxLevel); prog.setLevel(maxLevel);
}
reloadMaxExperience();
reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(this);
;
return true;
} }
reloadMaxExperience();
reloadMoneyLimit();
reloadExpLimit();
reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(this);
;
return true;
} }
return false; }
return false;
// } // }
} }

View File

@ -1,19 +1,20 @@
package com.gamingmesh.jobs.container; package com.gamingmesh.jobs.container;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gamingmesh.jobs.stuff.OfflinePlayerList; import com.gamingmesh.jobs.stuff.OfflinePlayerList;
import com.gamingmesh.jobs.stuff.UUIDUtil;
public final class TopList { public final class TopList {
private String player; private String player;
private int level; private int level;
private int exp; private int exp;
private byte[] uuid; private UUID uuid;
public TopList(String player, int level, int exp, byte[] uuid) { public TopList(String player, int level, int exp, UUID uuid) {
this.player = player; this.player = player;
this.level = level; this.level = level;
this.exp = exp; this.exp = exp;
@ -22,11 +23,11 @@ public final class TopList {
public String getPlayerName() { public String getPlayerName() {
if (this.player == null || this.player == "") { if (this.player == null || this.player == "") {
Player player = Bukkit.getPlayer(UUIDUtil.fromBytes(this.uuid)); Player player = Bukkit.getPlayer(this.uuid);
if (player != null) if (player != null)
return player.getName(); return player.getName();
else { else {
OfflinePlayer Offlineplayer = OfflinePlayerList.getPlayer(UUIDUtil.fromBytes(this.uuid)); OfflinePlayer Offlineplayer = OfflinePlayerList.getPlayer(this.uuid);
if (Offlineplayer != null) if (Offlineplayer != null)
return Offlineplayer.getName(); return Offlineplayer.getName();
else else

View File

@ -24,6 +24,7 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -84,7 +85,10 @@ public abstract class JobsDAO {
if (version <= 5) if (version <= 5)
checkUpdate6(); checkUpdate6();
version = 6; if (version <= 6)
checkUpdate7();
version = 7;
} finally { } finally {
updateSchemaVersion(version); updateSchemaVersion(version);
} }
@ -102,6 +106,8 @@ public abstract class JobsDAO {
protected abstract void checkUpdate6() throws SQLException; protected abstract void checkUpdate6() throws SQLException;
protected abstract void checkUpdate7() throws SQLException;
/** /**
* Gets the database prefix * Gets the database prefix
* @return the prefix * @return the prefix
@ -122,7 +128,7 @@ public abstract class JobsDAO {
return jobs; return jobs;
try { try {
PreparedStatement prest = conn.prepareStatement("SELECT `player_uuid`, `job`, `level`, `experience` FROM `" + prefix + "jobs` WHERE `player_uuid` = ?;"); PreparedStatement prest = conn.prepareStatement("SELECT `player_uuid`, `job`, `level`, `experience` FROM `" + prefix + "jobs` WHERE `player_uuid` = ?;");
prest.setBytes(1, UUIDUtil.toBytes(player.getUniqueId())); prest.setString(1, player.getUniqueId().toString());
ResultSet res = prest.executeQuery(); ResultSet res = prest.executeQuery();
while (res.next()) { while (res.next()) {
jobs.add(new JobsDAOData(player.getUniqueId(), res.getString(2), res.getInt(3), res.getInt(4))); jobs.add(new JobsDAOData(player.getUniqueId(), res.getString(2), res.getInt(3), res.getInt(4)));
@ -225,7 +231,7 @@ public abstract class JobsDAO {
} }
PreparedStatement prest = conn.prepareStatement("INSERT INTO `" + prefix PreparedStatement prest = conn.prepareStatement("INSERT INTO `" + prefix
+ "jobs` (`player_uuid`, `username`, `job`, `level`, `experience`) VALUES (?, ?, ?, ?, ?);"); + "jobs` (`player_uuid`, `username`, `job`, `level`, `experience`) VALUES (?, ?, ?, ?, ?);");
prest.setBytes(1, UUIDUtil.toBytes(jPlayer.getPlayerUUID())); prest.setString(1, jPlayer.getPlayerUUID().toString());
prest.setString(2, jPlayer.getUserName()); prest.setString(2, jPlayer.getUserName());
prest.setString(3, job.getName()); prest.setString(3, job.getName());
prest.setInt(4, level); prest.setInt(4, level);
@ -291,7 +297,7 @@ public abstract class JobsDAO {
i--; i--;
Convert convertData = list.get(i); Convert convertData = list.get(i);
insert.setString(1, convertData.GetName()); insert.setString(1, convertData.GetName());
insert.setBytes(2, UUIDUtil.toBytes(convertData.GetUuid())); insert.setString(2, convertData.GetUuid().toString());
insert.setString(3, convertData.GetJobName()); insert.setString(3, convertData.GetJobName());
insert.setInt(4, convertData.GetLevel()); insert.setInt(4, convertData.GetLevel());
insert.setInt(5, convertData.GetExp()); insert.setInt(5, convertData.GetExp());
@ -322,7 +328,7 @@ public abstract class JobsDAO {
return; return;
try { try {
PreparedStatement prest = conn.prepareStatement("DELETE FROM `" + prefix + "jobs` WHERE `player_uuid` = ? AND `job` = ?;"); PreparedStatement prest = conn.prepareStatement("DELETE FROM `" + prefix + "jobs` WHERE `player_uuid` = ? AND `job` = ?;");
prest.setBytes(1, UUIDUtil.toBytes(jPlayer.getPlayerUUID())); prest.setString(1, jPlayer.getPlayerUUID().toString());
prest.setString(2, job.getName()); prest.setString(2, job.getName());
prest.execute(); prest.execute();
prest.close(); prest.close();
@ -351,7 +357,7 @@ public abstract class JobsDAO {
} }
PreparedStatement prest = conn.prepareStatement("INSERT INTO `" + prefix PreparedStatement prest = conn.prepareStatement("INSERT INTO `" + prefix
+ "archive` (`player_uuid`, `username`, `job`, `level`, `experience`) VALUES (?, ?, ?, ?, ?);"); + "archive` (`player_uuid`, `username`, `job`, `level`, `experience`) VALUES (?, ?, ?, ?, ?);");
prest.setBytes(1, UUIDUtil.toBytes(jPlayer.getPlayerUUID())); prest.setString(1, jPlayer.getPlayerUUID().toString());
prest.setString(2, jPlayer.getUserName()); prest.setString(2, jPlayer.getUserName());
prest.setString(3, job.getName()); prest.setString(3, job.getName());
prest.setInt(4, level); prest.setInt(4, level);
@ -375,7 +381,7 @@ public abstract class JobsDAO {
try { try {
List<Integer> info = new ArrayList<Integer>(); List<Integer> info = new ArrayList<Integer>();
PreparedStatement prest = conn.prepareStatement("SELECT `level`, `experience` FROM `" + prefix + "archive` WHERE `player_uuid` = ? AND `job` = ?;"); PreparedStatement prest = conn.prepareStatement("SELECT `level`, `experience` FROM `" + prefix + "archive` WHERE `player_uuid` = ? AND `job` = ?;");
prest.setBytes(1, UUIDUtil.toBytes(jPlayer.getPlayerUUID())); prest.setString(1, jPlayer.getPlayerUUID().toString());
prest.setString(2, job.getName()); prest.setString(2, job.getName());
ResultSet res = prest.executeQuery(); ResultSet res = prest.executeQuery();
if (res.next()) { if (res.next()) {
@ -427,7 +433,7 @@ public abstract class JobsDAO {
while (res.next()) { while (res.next()) {
TopList top = new TopList(res.getString("username"), res.getInt("totallvl"), 0, res.getBytes("player_uuid")); TopList top = new TopList(res.getString("username"), res.getInt("totallvl"), 0, UUID.fromString(res.getString("player_uuid")));
names.add(top); names.add(top);
} }
@ -452,7 +458,7 @@ public abstract class JobsDAO {
try { try {
List<String> info = new ArrayList<String>(); List<String> info = new ArrayList<String>();
PreparedStatement prest = conn.prepareStatement("SELECT `job`, `level`, `experience` FROM `" + prefix + "archive` WHERE `player_uuid` = ?;"); PreparedStatement prest = conn.prepareStatement("SELECT `job`, `level`, `experience` FROM `" + prefix + "archive` WHERE `player_uuid` = ?;");
prest.setBytes(1, UUIDUtil.toBytes(jPlayer.getPlayerUUID())); prest.setString(1, jPlayer.getPlayerUUID().toString());
ResultSet res = prest.executeQuery(); ResultSet res = prest.executeQuery();
while (res.next()) { while (res.next()) {
@ -491,7 +497,7 @@ public abstract class JobsDAO {
return; return;
try { try {
PreparedStatement prest = conn.prepareStatement("DELETE FROM `" + prefix + "archive` WHERE `player_uuid` = ? AND `job` = ?;"); PreparedStatement prest = conn.prepareStatement("DELETE FROM `" + prefix + "archive` WHERE `player_uuid` = ? AND `job` = ?;");
prest.setBytes(1, UUIDUtil.toBytes(jPlayer.getPlayerUUID())); prest.setString(1, jPlayer.getPlayerUUID().toString());
prest.setString(2, job.getName()); prest.setString(2, job.getName());
prest.execute(); prest.execute();
prest.close(); prest.close();
@ -513,7 +519,7 @@ public abstract class JobsDAO {
for (JobProgression progression : player.getJobProgression()) { for (JobProgression progression : player.getJobProgression()) {
prest.setInt(1, progression.getLevel()); prest.setInt(1, progression.getLevel());
prest.setInt(2, (int) progression.getExperience()); prest.setInt(2, (int) progression.getExperience());
prest.setBytes(3, UUIDUtil.toBytes(player.getPlayerUUID())); prest.setString(3, player.getPlayerUUID().toString());
prest.setString(4, progression.getJob().getName()); prest.setString(4, progression.getJob().getName());
prest.execute(); prest.execute();
} }
@ -544,7 +550,7 @@ public abstract class JobsDAO {
prest.setDouble(2, one.getValue().getMoney()); prest.setDouble(2, one.getValue().getMoney());
prest.setDouble(3, one.getValue().getExp()); prest.setDouble(3, one.getValue().getExp());
prest.setBytes(4, UUIDUtil.toBytes(player.getPlayerUUID())); prest.setString(4, player.getPlayerUUID().toString());
prest.setInt(5, log.getDate()); prest.setInt(5, log.getDate());
prest.setString(6, log.getActionType()); prest.setString(6, log.getActionType());
prest.setString(7, one.getKey()); prest.setString(7, one.getKey());
@ -561,7 +567,7 @@ public abstract class JobsDAO {
one.getValue().setNewEntry(false); one.getValue().setNewEntry(false);
prest.setBytes(1, UUIDUtil.toBytes(player.getPlayerUUID())); prest.setString(1, player.getPlayerUUID().toString());
prest.setString(2, player.getUserName()); prest.setString(2, player.getUserName());
prest.setInt(3, log.getDate()); prest.setInt(3, log.getDate());
prest.setString(4, log.getActionType()); prest.setString(4, log.getActionType());
@ -592,7 +598,7 @@ public abstract class JobsDAO {
PreparedStatement prest = conn.prepareStatement("SELECT `player_uuid`, `username`, `time`, `action`, `itemname`, `count`, `money`, `exp` FROM `" + prefix PreparedStatement prest = conn.prepareStatement("SELECT `player_uuid`, `username`, `time`, `action`, `itemname`, `count`, `money`, `exp` FROM `" + prefix
+ "log` WHERE `player_uuid` = ? AND `time` = ? ;"); + "log` WHERE `player_uuid` = ? AND `time` = ? ;");
prest.setBytes(1, UUIDUtil.toBytes(player.getPlayerUUID())); prest.setString(1, player.getPlayerUUID().toString());
prest.setInt(2, time); prest.setInt(2, time);
ResultSet res = prest.executeQuery(); ResultSet res = prest.executeQuery();
while (res.next()) { while (res.next()) {
@ -659,10 +665,10 @@ public abstract class JobsDAO {
Job job = Jobs.getJob(jobsname); Job job = Jobs.getJob(jobsname);
if (job != null) { if (job != null) {
JobProgression prog = jobsinfo.getJobProgression(job); JobProgression prog = jobsinfo.getJobProgression(job);
jobs.add(new TopList(player.getName(), prog.getLevel(), (int) prog.getExperience(), UUIDUtil.toBytes(player.getUniqueId()))); jobs.add(new TopList(player.getName(), prog.getLevel(), (int) prog.getExperience(), player.getUniqueId()));
} }
} else } else
jobs.add(new TopList(res.getString(1), res.getInt(2), res.getInt(3), res.getBytes(4))); jobs.add(new TopList(res.getString(1), res.getInt(2), res.getInt(3), UUID.fromString(res.getString(4))));
} }
res.close(); res.close();
prest.close(); prest.close();

View File

@ -330,4 +330,105 @@ public class JobsDAOMySQL extends JobsDAO {
} }
executeSQL("ALTER TABLE `" + getPrefix() + "log` MODIFY `itemname` VARCHAR(60);"); executeSQL("ALTER TABLE `" + getPrefix() + "log` MODIFY `itemname` VARCHAR(60);");
} }
@Override
protected synchronized void checkUpdate7() throws SQLException {
JobsConnection conn = getConnection();
if (conn == null) {
Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to MySQL!");
return;
}
Jobs.getPluginLogger().info("Converting byte uuids to string. This could take a long time!!!");
// Converting jobs players byte uuid into string
executeSQL("CREATE TABLE `" + getPrefix()
+ "jobs_temp` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` varchar(36) NOT NULL,`username` varchar(20), `job` varchar(20), `experience` int, `level` int);");
PreparedStatement pst1 = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "jobs`;");
ResultSet rs = pst1.executeQuery();
PreparedStatement insert = null;
while (rs.next()) {
String uuid = UUIDUtil.fromBytes(rs.getBytes("player_uuid")).toString();
if (uuid != null) {
insert = conn.prepareStatement("INSERT INTO `" + getPrefix()
+ "jobs_temp` (`player_uuid`, `username`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?, ?);");
insert.setString(1, uuid);
insert.setString(2, rs.getString("username"));
insert.setString(3, rs.getString("job"));
insert.setInt(4, rs.getInt("experience"));
insert.setInt(5, rs.getInt("level"));
insert.execute();
}
}
rs.close();
if (insert != null)
insert.close();
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "jobs`;");
executeSQL("ALTER TABLE `" + getPrefix() + "jobs_temp` RENAME TO `" + getPrefix() + "jobs`;");
// Converting archive players byte uuid into string
executeSQL("CREATE TABLE `" + getPrefix()
+ "archive_temp` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` varchar(36) NOT NULL, `username` varchar(20), `job` varchar(20), `experience` int, `level` int);");
PreparedStatement pst11 = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "archive`;");
ResultSet rs1 = pst11.executeQuery();
PreparedStatement insert1 = null;
while (rs1.next()) {
String uuid = UUIDUtil.fromBytes(rs1.getBytes("player_uuid")).toString();
if (uuid != null) {
insert1 = conn.prepareStatement("INSERT INTO `" + getPrefix()
+ "archive_temp` (`player_uuid`, `username`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?, ?);");
insert1.setString(1, uuid);
insert1.setString(2, rs1.getString("username"));
insert1.setString(3, rs1.getString("job"));
insert1.setInt(4, rs1.getInt("experience"));
insert1.setInt(5, rs1.getInt("level"));
insert1.execute();
}
}
rs1.close();
if (insert1 != null)
insert1.close();
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "archive`;");
executeSQL("ALTER TABLE `" + getPrefix() + "archive_temp` RENAME TO `" + getPrefix() + "archive`;");
// Converting log players byte uuid into string
executeSQL("CREATE TABLE `" + getPrefix()
+ "log_temp` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` varchar(36) NOT NULL, `username` varchar(20), `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
PreparedStatement pst111 = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "log`;");
ResultSet rs11 = pst111.executeQuery();
PreparedStatement insert11 = null;
while (rs11.next()) {
String uuid = UUIDUtil.fromBytes(rs11.getBytes("player_uuid")).toString();
if (uuid != null) {
insert11 = conn.prepareStatement("INSERT INTO `" + getPrefix()
+ "log_temp` (`player_uuid`, `username`, `time`, `action`, `itemname`, `count`, `money`, `exp`) VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
insert11.setString(1, uuid);
insert11.setString(2, rs11.getString("username"));
insert11.setLong(3, rs11.getLong("time"));
insert11.setString(4, rs11.getString("action"));
insert11.setString(5, rs11.getString("itemname"));
insert11.setInt(6, rs11.getInt("count"));
insert11.setDouble(7, rs11.getDouble("money"));
insert11.setDouble(8, rs11.getDouble("exp"));
insert11.execute();
}
}
rs11.close();
if (insert11 != null)
insert11.close();
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;");
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
}
} }

View File

@ -310,4 +310,105 @@ public class JobsDAOSQLite extends JobsDAO {
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;"); executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
} }
@Override
protected synchronized void checkUpdate7() throws SQLException {
JobsConnection conn = getConnection();
if (conn == null) {
Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to MySQL!");
return;
}
Jobs.getPluginLogger().info("Converting byte uuids to string. This could take a long time!!!");
executeSQL("CREATE TABLE `" + getPrefix()
+ "jobs_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` varchar(36) NOT NULL,`username` varchar(20), `job` varchar(20), `experience` int, `level` int);");
PreparedStatement pst1 = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "jobs`;");
ResultSet rs = pst1.executeQuery();
PreparedStatement insert = null;
while (rs.next()) {
String uuid = UUIDUtil.fromBytes(rs.getBytes("player_uuid")).toString();
if (uuid != null) {
insert = conn.prepareStatement("INSERT INTO `" + getPrefix()
+ "jobs_temp` (`player_uuid`, `username`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?, ?);");
insert.setString(1, uuid);
insert.setString(2, rs.getString("username"));
insert.setString(3, rs.getString("job"));
insert.setInt(4, rs.getInt("experience"));
insert.setInt(5, rs.getInt("level"));
insert.execute();
}
}
rs.close();
if (insert != null)
insert.close();
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "jobs`;");
executeSQL("ALTER TABLE `" + getPrefix() + "jobs_temp` RENAME TO `" + getPrefix() + "jobs`;");
// Converting archive players byte uuid into string
executeSQL("CREATE TABLE `" + getPrefix()
+ "archive_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` varchar(36) NOT NULL, `username` varchar(20), `job` varchar(20), `experience` int, `level` int);");
PreparedStatement pst11 = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "archive`;");
ResultSet rs1 = pst11.executeQuery();
PreparedStatement insert1 = null;
while (rs1.next()) {
String uuid = UUIDUtil.fromBytes(rs1.getBytes("player_uuid")).toString();
if (uuid != null) {
insert1 = conn.prepareStatement("INSERT INTO `" + getPrefix()
+ "archive_temp` (`player_uuid`, `username`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?, ?);");
insert1.setString(1, uuid);
insert1.setString(2, rs1.getString("username"));
insert1.setString(3, rs1.getString("job"));
insert1.setInt(4, rs1.getInt("experience"));
insert1.setInt(5, rs1.getInt("level"));
insert1.execute();
}
}
rs1.close();
if (insert1 != null)
insert1.close();
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "archive`;");
executeSQL("ALTER TABLE `" + getPrefix() + "archive_temp` RENAME TO `" + getPrefix() + "archive`;");
// Converting log players byte uuid into string
executeSQL("CREATE TABLE `" + getPrefix()
+ "log_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` varchar(36) NOT NULL, `username` varchar(20), `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);");
PreparedStatement pst111 = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "log`;");
ResultSet rs11 = pst111.executeQuery();
PreparedStatement insert11 = null;
while (rs11.next()) {
String uuid = UUIDUtil.fromBytes(rs11.getBytes("player_uuid")).toString();
if (uuid != null) {
insert11 = conn.prepareStatement("INSERT INTO `" + getPrefix()
+ "log_temp` (`player_uuid`, `username`, `time`, `action`, `itemname`, `count`, `money`, `exp`) VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
insert11.setString(1, uuid);
insert11.setString(2, rs11.getString("username"));
insert11.setLong(3, rs11.getLong("time"));
insert11.setString(4, rs11.getString("action"));
insert11.setString(5, rs11.getString("itemname"));
insert11.setInt(6, rs11.getInt("count"));
insert11.setDouble(7, rs11.getDouble("money"));
insert11.setDouble(8, rs11.getDouble("exp"));
insert11.execute();
}
}
rs11.close();
if (insert11 != null)
insert11.close();
executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;");
executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;");
}
} }

View File

@ -83,7 +83,8 @@ public class JobsListener implements Listener {
int slot = event.getRawSlot(); int slot = event.getRawSlot();
if (slot >= 0) { if (slot >= 0) {
if (event.getClick() == ClickType.LEFT) { if (!ConfigManager.getJobsConfiguration().JobsGUISwitcheButtons && event.getClick() == ClickType.LEFT ||
ConfigManager.getJobsConfiguration().JobsGUISwitcheButtons && event.getClick() == ClickType.RIGHT) {
if (!joblist.isJobInfo() && slot < joblist.getJobList().size()) { if (!joblist.isJobInfo() && slot < joblist.getJobList().size()) {
player.closeInventory(); player.closeInventory();
player.openInventory(GuiTools.CreateJobsSubGUI(player, joblist.getJobList().get(slot))); player.openInventory(GuiTools.CreateJobsSubGUI(player, joblist.getJobList().get(slot)));
@ -93,7 +94,8 @@ public class JobsListener implements Listener {
player.openInventory(GuiTools.CreateJobsGUI(player)); player.openInventory(GuiTools.CreateJobsGUI(player));
} }
} }
} else if (event.getClick() == ClickType.RIGHT) { } else if (!ConfigManager.getJobsConfiguration().JobsGUISwitcheButtons && event.getClick() == ClickType.RIGHT ||
ConfigManager.getJobsConfiguration().JobsGUISwitcheButtons && event.getClick() == ClickType.LEFT) {
if (!joblist.isJobInfo() && slot < joblist.getJobList().size()) { if (!joblist.isJobInfo() && slot < joblist.getJobList().size()) {
Bukkit.dispatchCommand(player, "jobs join " + joblist.getJobList().get(slot).getName()); Bukkit.dispatchCommand(player, "jobs join " + joblist.getJobList().get(slot).getName());
player.getOpenInventory().getTopInventory().setContents(GuiTools.CreateJobsGUI(player).getContents()); player.getOpenInventory().getTopInventory().setContents(GuiTools.CreateJobsGUI(player).getContents());

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: 2.53.0 version: 2.54.1
author: phrstbrn author: phrstbrn
softdepend: [Vault, CoreProtect, MythicMobs, McMMO] softdepend: [Vault, CoreProtect, MythicMobs, McMMO]
commands: commands: