From 8f129bc217a0e04e2bc97cbe45a107f305c1e8ec Mon Sep 17 00:00:00 2001 From: Zrips Date: Thu, 10 Dec 2015 15:13:57 +0200 Subject: [PATCH] 2.54.1 update --- com/gamingmesh/jobs/Gui/GuiTools.java | 12 +- com/gamingmesh/jobs/Jobs.java | 6 +- com/gamingmesh/jobs/PlayerManager.java | 2 + .../jobs/commands/JobsCommands.java | 25 +- .../jobs/config/JobsConfiguration.java | 54 +++- com/gamingmesh/jobs/container/JobsPlayer.java | 238 +++++++++++------- com/gamingmesh/jobs/container/TopList.java | 11 +- com/gamingmesh/jobs/dao/JobsDAO.java | 40 +-- com/gamingmesh/jobs/dao/JobsDAOMySQL.java | 101 ++++++++ com/gamingmesh/jobs/dao/JobsDAOSQLite.java | 101 ++++++++ .../jobs/listeners/JobsListener.java | 6 +- plugin.yml | 2 +- 12 files changed, 451 insertions(+), 147 deletions(-) diff --git a/com/gamingmesh/jobs/Gui/GuiTools.java b/com/gamingmesh/jobs/Gui/GuiTools.java index 6dd04e84..6b3e299f 100644 --- a/com/gamingmesh/jobs/Gui/GuiTools.java +++ b/com/gamingmesh/jobs/Gui/GuiTools.java @@ -1,6 +1,7 @@ package com.gamingmesh.jobs.Gui; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -61,7 +62,7 @@ public class GuiTools { List 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++) { @@ -92,16 +93,17 @@ public class GuiTools { else 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) - 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")); for (ActionType actionType : ActionType.values()) { List info = job.getJobInfo(actionType); 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; // } - 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++) { GuiInv.setItem(i1, items.get(i1)); diff --git a/com/gamingmesh/jobs/Jobs.java b/com/gamingmesh/jobs/Jobs.java index 4909747c..4a18a243 100644 --- a/com/gamingmesh/jobs/Jobs.java +++ b/com/gamingmesh/jobs/Jobs.java @@ -341,7 +341,8 @@ public class Jobs { paymentLimit.put(playername, data); } else { 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()) { ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedlimit")); ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedlimit2")); @@ -379,7 +380,8 @@ public class Jobs { ExpLimit.put(playername, data); } else { 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()) { ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit")); ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit2")); diff --git a/com/gamingmesh/jobs/PlayerManager.java b/com/gamingmesh/jobs/PlayerManager.java index 31f23ac5..6165bd76 100644 --- a/com/gamingmesh/jobs/PlayerManager.java +++ b/com/gamingmesh/jobs/PlayerManager.java @@ -571,6 +571,8 @@ public class PlayerManager { } if (jPlayer.isOnline()) { jPlayer.reloadHonorific(); + jPlayer.reloadMoneyLimit(); + jPlayer.reloadExpLimit(); Jobs.getPermissionHandler().recalculatePermissions(jPlayer); } } diff --git a/com/gamingmesh/jobs/commands/JobsCommands.java b/com/gamingmesh/jobs/commands/JobsCommands.java index 4c287972..44a6301a 100644 --- a/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/com/gamingmesh/jobs/commands/JobsCommands.java @@ -643,7 +643,7 @@ public class JobsCommands implements CommandExecutor { lines.add(builder.toString()); 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)); } - sender.sendMessage(Language.getMessage("command.browse.output.header")); - for (String line : lines) { - sender.sendMessage(line); + if (ConfigManager.getJobsConfiguration().JobsGUIShowChatBrowse) { + sender.sendMessage(Language.getMessage("command.browse.output.header")); + 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; } @@ -1268,6 +1270,7 @@ public class JobsCommands implements CommandExecutor { player.sendMessage(Language.getMessage("command.limit.output.notenabled")); return true; } + JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player); String playername = player.getName(); @@ -1283,8 +1286,8 @@ public class JobsCommands implements CommandExecutor { player.sendMessage(lefttimemessage); String message = Language.getMessage("command.limit.output.moneylimit"); - message = message.replace("%money%", String.valueOf(data.GetAmountBylimit(ConfigManager.getJobsConfiguration().EconomyLimitMoneyLimit))); - message = message.replace("%totalmoney%", String.valueOf(ConfigManager.getJobsConfiguration().EconomyLimitMoneyLimit)); + message = message.replace("%money%", String.valueOf(data.GetAmountBylimit(JPlayer.getMoneyLimit()))); + message = message.replace("%totalmoney%", String.valueOf(JPlayer.getMoneyLimit())); player.sendMessage(message); } else { @@ -1315,7 +1318,7 @@ public class JobsCommands implements CommandExecutor { player.sendMessage(message); 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); } @@ -1330,8 +1333,8 @@ public class JobsCommands implements CommandExecutor { player.sendMessage(lefttimemessage); String message = Language.getMessage("command.limit.output.explimit"); - message = message.replace("%exp%", String.valueOf(data.GetExpBylimit(ConfigManager.getJobsConfiguration().EconomyExpLimit))); - message = message.replace("%totalexp%", String.valueOf(ConfigManager.getJobsConfiguration().EconomyExpLimit)); + message = message.replace("%exp%", String.valueOf(data.GetExpBylimit(JPlayer.getExpLimit()))); + message = message.replace("%totalexp%", String.valueOf(JPlayer.getExpLimit())); player.sendMessage(message); } else { @@ -1362,7 +1365,7 @@ public class JobsCommands implements CommandExecutor { player.sendMessage(message); 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); } diff --git a/com/gamingmesh/jobs/config/JobsConfiguration.java b/com/gamingmesh/jobs/config/JobsConfiguration.java index eafd0965..045ec42a 100644 --- a/com/gamingmesh/jobs/config/JobsConfiguration.java +++ b/com/gamingmesh/jobs/config/JobsConfiguration.java @@ -75,7 +75,6 @@ public class JobsConfiguration { SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse, EnableAnounceMessage, useBlockPiston, useSilkTouchProtection, UseCustomNames, EconomyMoneyStop, EconomyExpStop, UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit; - public int EconomyLimitMoneyLimit, EconomyExpLimit; public int EconomyLimitTimeLimit, EconomyExpTimeLimit; public int EconomyLimitAnnouncmentDelay, EconomyLimitAnnouncmentExpDelay, globalblocktimer, CowMilkingTimer, CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval; @@ -87,7 +86,7 @@ public class JobsConfiguration { public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat, EmptyServerAcountActionBar, JobsToggleEnabled, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, - useGlobalBoostScheduler, JobsGUIOpenOnBrowse,JobsGUIOpenOnJoin; + useGlobalBoostScheduler, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin; public Integer levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume, SoundTitleChangePitch, ToplistInScoreboardInterval; public double BoostExp; @@ -104,6 +103,8 @@ public class JobsConfiguration { public boolean TakeFromPlayersPayment; public Parser DynamicPaymentEquation; + public Parser maxMoneyEquation; + public Parser maxExpEquation; public List BoostSchedule = new ArrayList(); @@ -476,7 +477,22 @@ public class JobsConfiguration { 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?"); 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"); EconomyLimitTimeLimit = getInt("Economy.Limit.Money.TimeLimit", 3600, config, writer); 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); 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); - 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"); EconomyExpTimeLimit = getInt("Economy.Limit.Exp.TimeLimit", 3600, config, writer); writer.addComment("Economy.Limit.Exp.AnnouncmentDelay", "Delay between announcements about reached Exp limit", @@ -627,9 +657,14 @@ public class JobsConfiguration { writer.addComment("JobsGUI.OpenOnBrowse", "Do you want to show GUI when performing /jobs browse command"); 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"); JobsGUIOpenOnJoin = getBoolean("JobsGUI.OpenOnJoin", true, config, writer); - + writer.addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost"); useGlobalBoostScheduler = getBoolean("Schedule.Boost.Enable", false, config, writer); @@ -1219,13 +1254,15 @@ public class JobsConfiguration { GetConfigString("command.info.help.max", " - &emax level:&f ", 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.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.leftSlots", "&eLeft slots:&f ", writer, conf, true); GetConfigString("command.info.gui.working", "&2&nAlready working", writer, conf, true); GetConfigString("command.info.gui.max", "&eMax level:&f ", writer, conf, true); - + GetConfigString("command.info.output.break.info", "Break", writer, conf, true); GetConfigString("command.info.output.break.none", "%jobname% does not get money for breaking blocks.", writer, conf, true); GetConfigString("command.info.output.place.info", "Place", writer, conf, true); @@ -1327,9 +1364,10 @@ public class JobsConfiguration { GetConfigString("command.glog.help.info", "Shows global statistics.", 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.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.transfer.help.info", "Transfer a player's job from an old job to a new job.", writer, conf, true); GetConfigString("command.transfer.help.args", "[playername] [oldjob] [newjob]", writer, conf, true); GetConfigString("command.transfer.output.target", "You have been transferred from %oldjobname% to %newjobname%.", writer, conf, true); diff --git a/com/gamingmesh/jobs/container/JobsPlayer.java b/com/gamingmesh/jobs/container/JobsPlayer.java index 92259ffc..ea93e815 100644 --- a/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/com/gamingmesh/jobs/container/JobsPlayer.java @@ -30,6 +30,7 @@ import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.dao.JobsDAO; import com.gamingmesh.jobs.dao.JobsDAOData; +import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.stuff.ChatColor; import com.gamingmesh.jobs.stuff.Perm; @@ -50,6 +51,9 @@ public class JobsPlayer { private double VipSpawnerMultiplier = -1; + private int MoneyLimit = 0; + private int ExpLimit = 0; + // save lock // public final Object saveLock = new Object(); @@ -67,23 +71,25 @@ public class JobsPlayer { jPlayer.playerUUID = player.getUniqueId(); List list = dao.getAllJobs(player); // synchronized (jPlayer.saveLock) { - jPlayer.progression.clear(); - for (JobsDAOData jobdata : list) { - if (Jobs.getJob(jobdata.getJobName()) == null) - continue; - // add the job - Job job = Jobs.getJob(jobdata.getJobName()); - if (job == null) - continue; + jPlayer.progression.clear(); + for (JobsDAOData jobdata : list) { + if (Jobs.getJob(jobdata.getJobName()) == null) + continue; + // add the job + Job job = Jobs.getJob(jobdata.getJobName()); + if (job == null) + continue; - // create the progression object - JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience(), -1, -1); - // calculate the max level - // add the progression level. - jPlayer.progression.add(jobProgression); + // create the progression object + JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience(), -1, -1); + // calculate the max level + // add the progression level. + jPlayer.progression.add(jobProgression); - } - jPlayer.reloadMaxExperience(); + } + jPlayer.reloadMaxExperience(); + jPlayer.reloadMoneyLimit(); + jPlayer.reloadExpLimit(); // } 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 * @return the list of job progressions @@ -218,23 +258,25 @@ public class JobsPlayer { */ public boolean joinJob(Job job, JobsPlayer jPlayer) { // synchronized (saveLock) { - if (!isInJob(job)) { - int level = 1; - int exp = 0; - if (Jobs.getJobsDAO().checkArchive(jPlayer, job).size() > 0) { - List info = Jobs.getJobsDAO().checkArchive(jPlayer, job); - level = info.get(0); - //exp = info.get(1); - Jobs.getJobsDAO().deleteArchive(jPlayer, job); - } - - progression.add(new JobProgression(job, this, level, exp, -1, -1)); - reloadMaxExperience(); - reloadHonorific(); - Jobs.getPermissionHandler().recalculatePermissions(this); - return true; + if (!isInJob(job)) { + int level = 1; + int exp = 0; + if (Jobs.getJobsDAO().checkArchive(jPlayer, job).size() > 0) { + List info = Jobs.getJobsDAO().checkArchive(jPlayer, job); + level = info.get(0); + //exp = info.get(1); + Jobs.getJobsDAO().deleteArchive(jPlayer, job); } - 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) { // synchronized (saveLock) { - JobProgression prog = getJobProgression(job); - if (prog != null) { - progression.remove(prog); - reloadMaxExperience(); - reloadHonorific(); - Jobs.getPermissionHandler().recalculatePermissions(this); - return true; - } - return false; + JobProgression prog = getJobProgression(job); + if (prog != null) { + progression.remove(prog); + reloadMaxExperience(); + reloadMoneyLimit(); + reloadExpLimit(); + reloadHonorific(); + Jobs.getPermissionHandler().recalculatePermissions(this); + return true; + } + return false; // } } @@ -262,11 +306,11 @@ public class JobsPlayer { */ public boolean leaveAllJobs() { // synchronized (saveLock) { - progression.clear(); - reloadHonorific(); - Jobs.getPermissionHandler().recalculatePermissions(this); - ; - return true; + progression.clear(); + reloadHonorific(); + Jobs.getPermissionHandler().recalculatePermissions(this); + ; + return true; // } } @@ -277,22 +321,22 @@ public class JobsPlayer { */ public void promoteJob(Job job, int levels, JobsPlayer player) { // synchronized (saveLock) { - JobProgression prog = getJobProgression(job); - if (prog == null) - return; - if (levels <= 0) - return; - int newLevel = prog.getLevel() + levels; + JobProgression prog = getJobProgression(job); + if (prog == null) + return; + if (levels <= 0) + return; + int newLevel = prog.getLevel() + levels; - int maxLevel = job.getMaxLevel(); + int maxLevel = job.getMaxLevel(); - if (player.havePermission("jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0) - maxLevel = job.getVipMaxLevel(); + if (player.havePermission("jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0) + maxLevel = job.getVipMaxLevel(); - if (maxLevel > 0 && newLevel > maxLevel) { - newLevel = maxLevel; - } - setLevel(job, newLevel); + if (maxLevel > 0 && newLevel > maxLevel) { + newLevel = maxLevel; + } + setLevel(job, newLevel); // } } @@ -303,16 +347,16 @@ public class JobsPlayer { */ public void demoteJob(Job job, int levels) { // synchronized (saveLock) { - JobProgression prog = getJobProgression(job); - if (prog == null) - return; - if (levels <= 0) - return; - int newLevel = prog.getLevel() - levels; - if (newLevel < 1) { - newLevel = 1; - } - setLevel(job, newLevel); + JobProgression prog = getJobProgression(job); + if (prog == null) + return; + if (levels <= 0) + return; + int newLevel = prog.getLevel() - levels; + if (newLevel < 1) { + newLevel = 1; + } + setLevel(job, newLevel); // } } @@ -323,16 +367,16 @@ public class JobsPlayer { */ private void setLevel(Job job, int level) { // synchronized (saveLock) { - JobProgression prog = getJobProgression(job); - if (prog == null) - return; + JobProgression prog = getJobProgression(job); + if (prog == null) + return; - if (level != prog.getLevel()) { - prog.setLevel(level); - reloadHonorific(); - Jobs.getPermissionHandler().recalculatePermissions(this); - ; - } + if (level != prog.getLevel()) { + prog.setLevel(level); + reloadHonorific(); + Jobs.getPermissionHandler().recalculatePermissions(this); + ; + } // } } @@ -343,30 +387,32 @@ public class JobsPlayer { */ public boolean transferJob(Job oldjob, Job newjob, JobsPlayer jPlayer) { // synchronized (saveLock) { - if (!isInJob(newjob)) { - for (JobProgression prog : progression) { - if (!prog.getJob().equals(oldjob)) - continue; + if (!isInJob(newjob)) { + for (JobProgression prog : progression) { + if (!prog.getJob().equals(oldjob)) + continue; - prog.setJob(newjob); + prog.setJob(newjob); - int maxLevel = 0; - if (jPlayer.havePermission("jobs." + newjob.getName() + ".vipmaxlevel")) - maxLevel = newjob.getVipMaxLevel(); - else - maxLevel = newjob.getMaxLevel(); + int maxLevel = 0; + if (jPlayer.havePermission("jobs." + newjob.getName() + ".vipmaxlevel")) + maxLevel = newjob.getVipMaxLevel(); + else + maxLevel = newjob.getMaxLevel(); - if (newjob.getMaxLevel() > 0 && prog.getLevel() > maxLevel) { - prog.setLevel(maxLevel); - } - reloadMaxExperience(); - reloadHonorific(); - Jobs.getPermissionHandler().recalculatePermissions(this); - ; - return true; + if (newjob.getMaxLevel() > 0 && prog.getLevel() > maxLevel) { + prog.setLevel(maxLevel); } + reloadMaxExperience(); + reloadMoneyLimit(); + reloadExpLimit(); + reloadHonorific(); + Jobs.getPermissionHandler().recalculatePermissions(this); + ; + return true; } - return false; + } + return false; // } } diff --git a/com/gamingmesh/jobs/container/TopList.java b/com/gamingmesh/jobs/container/TopList.java index 15236ddb..1cb4206f 100644 --- a/com/gamingmesh/jobs/container/TopList.java +++ b/com/gamingmesh/jobs/container/TopList.java @@ -1,19 +1,20 @@ package com.gamingmesh.jobs.container; +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import com.gamingmesh.jobs.stuff.OfflinePlayerList; -import com.gamingmesh.jobs.stuff.UUIDUtil; public final class TopList { private String player; private int level; 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.level = level; this.exp = exp; @@ -22,11 +23,11 @@ public final class TopList { public String getPlayerName() { if (this.player == null || this.player == "") { - Player player = Bukkit.getPlayer(UUIDUtil.fromBytes(this.uuid)); + Player player = Bukkit.getPlayer(this.uuid); if (player != null) return player.getName(); else { - OfflinePlayer Offlineplayer = OfflinePlayerList.getPlayer(UUIDUtil.fromBytes(this.uuid)); + OfflinePlayer Offlineplayer = OfflinePlayerList.getPlayer(this.uuid); if (Offlineplayer != null) return Offlineplayer.getName(); else diff --git a/com/gamingmesh/jobs/dao/JobsDAO.java b/com/gamingmesh/jobs/dao/JobsDAO.java index 3e253339..09ca4a70 100644 --- a/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/com/gamingmesh/jobs/dao/JobsDAO.java @@ -24,6 +24,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; +import java.util.UUID; import java.util.Map.Entry; import org.bukkit.Bukkit; @@ -80,11 +81,14 @@ public abstract class JobsDAO { checkUpdate4(); checkUpdate5(); - + if (version <= 5) checkUpdate6(); - version = 6; + if (version <= 6) + checkUpdate7(); + + version = 7; } finally { updateSchemaVersion(version); } @@ -102,6 +106,8 @@ public abstract class JobsDAO { protected abstract void checkUpdate6() throws SQLException; + protected abstract void checkUpdate7() throws SQLException; + /** * Gets the database prefix * @return the prefix @@ -122,7 +128,7 @@ public abstract class JobsDAO { return jobs; try { 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(); while (res.next()) { 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 + "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(3, job.getName()); prest.setInt(4, level); @@ -291,7 +297,7 @@ public abstract class JobsDAO { i--; Convert convertData = list.get(i); insert.setString(1, convertData.GetName()); - insert.setBytes(2, UUIDUtil.toBytes(convertData.GetUuid())); + insert.setString(2, convertData.GetUuid().toString()); insert.setString(3, convertData.GetJobName()); insert.setInt(4, convertData.GetLevel()); insert.setInt(5, convertData.GetExp()); @@ -322,7 +328,7 @@ public abstract class JobsDAO { return; try { 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.execute(); prest.close(); @@ -351,7 +357,7 @@ public abstract class JobsDAO { } PreparedStatement prest = conn.prepareStatement("INSERT INTO `" + prefix + "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(3, job.getName()); prest.setInt(4, level); @@ -375,7 +381,7 @@ public abstract class JobsDAO { try { List info = new ArrayList(); 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()); ResultSet res = prest.executeQuery(); if (res.next()) { @@ -427,7 +433,7 @@ public abstract class JobsDAO { 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); } @@ -452,7 +458,7 @@ public abstract class JobsDAO { try { List info = new ArrayList(); 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(); while (res.next()) { @@ -491,7 +497,7 @@ public abstract class JobsDAO { return; try { 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.execute(); prest.close(); @@ -513,7 +519,7 @@ public abstract class JobsDAO { for (JobProgression progression : player.getJobProgression()) { prest.setInt(1, progression.getLevel()); 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.execute(); } @@ -544,7 +550,7 @@ public abstract class JobsDAO { prest.setDouble(2, one.getValue().getMoney()); 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.setString(6, log.getActionType()); prest.setString(7, one.getKey()); @@ -561,7 +567,7 @@ public abstract class JobsDAO { one.getValue().setNewEntry(false); - prest.setBytes(1, UUIDUtil.toBytes(player.getPlayerUUID())); + prest.setString(1, player.getPlayerUUID().toString()); prest.setString(2, player.getUserName()); prest.setInt(3, log.getDate()); 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 + "log` WHERE `player_uuid` = ? AND `time` = ? ;"); - prest.setBytes(1, UUIDUtil.toBytes(player.getPlayerUUID())); + prest.setString(1, player.getPlayerUUID().toString()); prest.setInt(2, time); ResultSet res = prest.executeQuery(); while (res.next()) { @@ -659,10 +665,10 @@ public abstract class JobsDAO { Job job = Jobs.getJob(jobsname); if (job != null) { 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 - 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(); prest.close(); diff --git a/com/gamingmesh/jobs/dao/JobsDAOMySQL.java b/com/gamingmesh/jobs/dao/JobsDAOMySQL.java index 486e4f67..a0ff3c73 100644 --- a/com/gamingmesh/jobs/dao/JobsDAOMySQL.java +++ b/com/gamingmesh/jobs/dao/JobsDAOMySQL.java @@ -330,4 +330,105 @@ public class JobsDAOMySQL extends JobsDAO { } 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`;"); + } } diff --git a/com/gamingmesh/jobs/dao/JobsDAOSQLite.java b/com/gamingmesh/jobs/dao/JobsDAOSQLite.java index 3b4ee423..7a416347 100644 --- a/com/gamingmesh/jobs/dao/JobsDAOSQLite.java +++ b/com/gamingmesh/jobs/dao/JobsDAOSQLite.java @@ -310,4 +310,105 @@ public class JobsDAOSQLite extends JobsDAO { 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`;"); + } + } diff --git a/com/gamingmesh/jobs/listeners/JobsListener.java b/com/gamingmesh/jobs/listeners/JobsListener.java index c7d1412c..bce9b731 100644 --- a/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/com/gamingmesh/jobs/listeners/JobsListener.java @@ -83,7 +83,8 @@ public class JobsListener implements Listener { int slot = event.getRawSlot(); 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()) { player.closeInventory(); player.openInventory(GuiTools.CreateJobsSubGUI(player, joblist.getJobList().get(slot))); @@ -93,7 +94,8 @@ public class JobsListener implements Listener { 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()) { Bukkit.dispatchCommand(player, "jobs join " + joblist.getJobList().get(slot).getName()); player.getOpenInventory().getTopInventory().setContents(GuiTools.CreateJobsGUI(player).getContents()); diff --git a/plugin.yml b/plugin.yml index 5c9a6f5f..56de266c 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: Jobs description: Jobs Plugin for the BukkitAPI main: com.gamingmesh.jobs.JobsPlugin -version: 2.53.0 +version: 2.54.1 author: phrstbrn softdepend: [Vault, CoreProtect, MythicMobs, McMMO] commands: