From aadf514dbabaa773679d00b2534c2aa9f7d1e289 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Sat, 5 Jan 2019 19:01:27 +0100 Subject: [PATCH] Fix #323 /jobs employ if target has, then checked the permission at the target - Now checking correctly for plants when break --- .../gamingmesh/jobs/commands/list/employ.java | 6 ++-- .../jobs/config/GeneralConfigManager.java | 20 ++++++------ .../jobs/economy/BufferedEconomy.java | 32 +++++++++---------- src/main/resources/jobConfig.yml | 12 +++---- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/employ.java b/src/main/java/com/gamingmesh/jobs/commands/list/employ.java index aaf853ae..7a9be9ce 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/employ.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/employ.java @@ -19,15 +19,15 @@ public class employ implements Cmd { return true; } + if (!Jobs.hasPermission(sender, "jobs.command.employ", true)) + return true; + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); if (jPlayer == null) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); return true; } - if (!Jobs.hasPermission(jPlayer.getPlayer(), "jobs.command.employ", true)) - return true; - Job job = Jobs.getJob(args[1]); if (job == null) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 5c01603b..34038fd8 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -100,8 +100,8 @@ public class GeneralConfigManager { private boolean useTnTFinder = false; public boolean CancelCowMilking; public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, - LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat, - EmptyServerAcountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, + LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAccountChat, + EmptyServerAccountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin; private int JobsGUIRows, JobsGUIBackButton, @@ -128,7 +128,7 @@ public class GeneralConfigManager { public boolean useMaxPaymentCurve; public float maxPaymentCurveFactor; public double TaxesAmount; - public String SoundLevelupSound, SoundTitleChangeSound, ServerAcountName, ServertaxesAcountName; + public String SoundLevelupSound, SoundTitleChangeSound, ServerAccountName, ServertaxesAccountName; public ArrayList keys; public boolean hideJobsInfoWithoutPermission; public boolean UseTaxes; @@ -621,15 +621,15 @@ public class GeneralConfigManager { useMaxPaymentCurve = c.get("Economy.MaxPayment.curve.use", false); int temp = c.get("Economy.MaxPayment.curve.factor", 10); maxPaymentCurveFactor = ((float) temp) / 1000; - c.getW().addComment("Economy.UseServerAcount", "Server economy account", "With this enabled, players will get money from defined user (server account)", + c.getW().addComment("Economy.UseServerAccount", "Server economy account", "With this enabled, players will get money from defined user (server account)", "If this account don't have enough money to pay for players for, player will get message"); - UseServerAccount = c.get("Economy.UseServerAcount", false); - c.getW().addComment("Economy.AcountName", "Username should be with Correct capitalization"); - ServerAcountName = c.get("Economy.AcountName", "Server"); + UseServerAccount = c.get("Economy.UseServerAccount", false); + c.getW().addComment("Economy.AccountName", "Username should be with Correct capitalization"); + ServerAccountName = c.get("Economy.AccountName", "Server"); c.getW().addComment("Economy.Taxes.use", "Do you want to use taxes feature for jobs payment"); UseTaxes = c.get("Economy.Taxes.use", false); c.getW().addComment("Economy.Taxes.AccountName", "Username should be with Correct capitalization, it can be same as setup in server account before"); - ServertaxesAcountName = c.get("Economy.Taxes.AccountName", "Server"); + ServertaxesAccountName = c.get("Economy.Taxes.AccountName", "Server"); c.getW().addComment("Economy.Taxes.Amount", "Amount in percentage"); TaxesAmount = c.get("Economy.Taxes.Amount", 15.0); c.getW().addComment("Economy.Taxes.TransferToServerAccount", "Do you want to transfer taxes to server account"); @@ -869,12 +869,12 @@ public class GeneralConfigManager { c.getW().addComment("ShowActionBars", "You can enable/disable message shown for players in action bar"); TitleChangeActionBar = c.get("ShowActionBars.OnTitleChange", true); LevelChangeActionBar = c.get("ShowActionBars.OnLevelChange", true); - EmptyServerAcountActionBar = c.get("ShowActionBars.OnEmptyServerAcount", true); + EmptyServerAccountActionBar = c.get("ShowActionBars.OnEmptyServerAccount", true); c.getW().addComment("ShowChatMessage", "Chat messages", "You can enable/disable message shown for players in chat"); TitleChangeChat = c.get("ShowChatMessage.OnTitleChange", true); LevelChangeChat = c.get("ShowChatMessage.OnLevelChange", true); - EmptyServerAcountChat = c.get("ShowChatMessage.OnEmptyServerAcount", true); + EmptyServerAccountChat = c.get("ShowChatMessage.OnEmptyServerAccount", true); c.getW().addComment("Sounds", "Sounds", "Extra sounds on some events", "All sounds can be found in https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html"); diff --git a/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java b/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java index 09a177f7..2afdb225 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java +++ b/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java @@ -131,8 +131,8 @@ public class BufferedEconomy { } boolean hasMoney = false; - String ServerAccountname = Jobs.getGCManager().ServerAcountName; - String ServerTaxesAccountname = Jobs.getGCManager().ServertaxesAcountName; + String ServerAccountname = Jobs.getGCManager().ServerAccountName; + String ServerTaxesAccountname = Jobs.getGCManager().ServertaxesAccountName; if (this.ServerAccount == null) this.ServerAccount = Bukkit.getOfflinePlayer(ServerAccountname); @@ -145,11 +145,9 @@ public class BufferedEconomy { if (ServerTaxesAccount.isOnline()) { if (!Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getGCManager().ActionBarsMessageByDefault) Jobs.getActionbarToggleList().put(ServerTaxesAccountname, true); - if (Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getActionbarToggleList().get(ServerTaxesAccountname)) { - Jobs.getActionBar(); + if (Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getActionbarToggleList().get(ServerTaxesAccountname)) Jobs.getActionBar().send(Bukkit.getPlayer(ServerAccountname), Jobs.getLanguage().getMessage("message.taxes", "[amount]", (int) (TotalAmount * 100) / 100.0)); - } } } @@ -184,14 +182,14 @@ public class BufferedEconomy { Jobs.getActionBar().send(payment.getOfflinePlayer().getPlayer(), Jobs.getLanguage().getMessage("economy.error.nomoney")); continue; } - if (Jobs.getGCManager().isEconomyAsync()) { + if (Jobs.getGCManager().isEconomyAsync()) Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i); - } else + else Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i); } else { - if (Jobs.getGCManager().isEconomyAsync()) { + if (Jobs.getGCManager().isEconomyAsync()) Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i); - } else + else Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i); } try { @@ -211,19 +209,19 @@ public class BufferedEconomy { } public void ShowActionBar(BufferedPayment payment) { - if (!payment.getOfflinePlayer().isOnline()) { + if (!payment.getOfflinePlayer().isOnline()) return; - } + String playername = payment.getOfflinePlayer().getName(); - if ((!Jobs.getActionbarToggleList().containsKey(playername)) && (Jobs.getGCManager().ActionBarsMessageByDefault)) { + if ((!Jobs.getActionbarToggleList().containsKey(playername)) && (Jobs.getGCManager().ActionBarsMessageByDefault)) Jobs.getActionbarToggleList().put(playername, Boolean.valueOf(true)); - } - if (playername == null) { + + if (playername == null) return; - } - if (!Jobs.getActionbarToggleList().containsKey(playername)) { + + if (!Jobs.getActionbarToggleList().containsKey(playername)) return; - } + Boolean show = Jobs.getActionbarToggleList().get(playername); Player abp = Bukkit.getPlayer(payment.getOfflinePlayer().getUniqueId()); if ((abp != null) && (show.booleanValue())) { diff --git a/src/main/resources/jobConfig.yml b/src/main/resources/jobConfig.yml index 8b4ec661..e3c74e9b 100644 --- a/src/main/resources/jobConfig.yml +++ b/src/main/resources/jobConfig.yml @@ -1850,23 +1850,23 @@ Jobs: income: 1.5 points: 1.5 experience: 3.0 - beetroots: + beetroots-7: income: 1.5 points: 1.5 experience: 3.0 - wheat: + wheat-7: income: 1.5 points: 1.5 experience: 3.0 - carrots: + carrots-7: income: 1.0 points: 1.0 experience: 1.0 - potatoes: + potatoes-7: income: 1.0 points: 1.0 experience: 1.0 - pumpkin: + pumpkin-7: income: 0.5 points: 0.5 experience: 1.0 @@ -1874,7 +1874,7 @@ Jobs: income: 0.2 points: 0.2 experience: 0.2 - cocoa: + cocoa-2: income: 4 points: 4 experience: 4.0