From 73ed579dcbe16e10ebcdc6e7a63052c3976bdbcd Mon Sep 17 00:00:00 2001 From: Zrips Date: Mon, 21 Dec 2015 19:31:18 +0200 Subject: [PATCH] mcmmo skills and minimum payment --- com/gamingmesh/jobs/Jobs.java | 15 +++++++++++++++ com/gamingmesh/jobs/config/JobsConfiguration.java | 15 +++++++++++++-- .../jobs/listeners/JobsPaymentListener.java | 6 ++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/com/gamingmesh/jobs/Jobs.java b/com/gamingmesh/jobs/Jobs.java index 4a18a243..f17873ae 100644 --- a/com/gamingmesh/jobs/Jobs.java +++ b/com/gamingmesh/jobs/Jobs.java @@ -528,6 +528,7 @@ public class Jobs { OfflinePlayer dude = jPlayer.getPlayer(); // Calculate income + Double amount = income + ((income * multiplier) - income) + ((income * prog.getJob().getMoneyBoost()) - income) + ((income * prog.getMoneyBoost()) - income) + itemMoneyBoost + armorMoneyBoost; @@ -536,6 +537,13 @@ public class Jobs { amount += moneyBonus; } + if (ConfigManager.getJobsConfiguration().useMinimumOveralPayment && income > 0) { + double maxLimit = income * ConfigManager.getJobsConfiguration().MinimumOveralPaymentLimit; + if (amount < maxLimit) { + amount = maxLimit; + } + } + // Calculate exp double expAmount = exp + ((exp * multiplier) - exp) + ((exp * prog.getJob().getExpBoost()) - exp) + ((exp * prog.getExpBoost()) - exp) + itemExpBoost + armorExpBoost; @@ -545,6 +553,13 @@ public class Jobs { expAmount += expBonus; } + if (ConfigManager.getJobsConfiguration().useMinimumOveralPayment && exp > 0) { + double maxLimit = exp * ConfigManager.getJobsConfiguration().MinimumOveralPaymentLimit; + if (exp < maxLimit) { + exp = maxLimit; + } + } + if (!isUnderMoneyLimit(dude, amount)) { amount = 0.0000000001; if (ConfigManager.getJobsConfiguration().EconomyExpStop) diff --git a/com/gamingmesh/jobs/config/JobsConfiguration.java b/com/gamingmesh/jobs/config/JobsConfiguration.java index 51a76ce3..8764454d 100644 --- a/com/gamingmesh/jobs/config/JobsConfiguration.java +++ b/com/gamingmesh/jobs/config/JobsConfiguration.java @@ -78,10 +78,11 @@ public class JobsConfiguration { public int EconomyLimitTimeLimit, EconomyExpTimeLimit; public int EconomyLimitAnnouncmentDelay, EconomyLimitAnnouncmentExpDelay, globalblocktimer, CowMilkingTimer, CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval; - public Double payNearSpawnerMultiplier, VIPpayNearSpawnerMultiplier, TreeFellerMultiplier, gigaDrillMultiplier, PetPay, VipPetPay; + public Double payNearSpawnerMultiplier, VIPpayNearSpawnerMultiplier, TreeFellerMultiplier, gigaDrillMultiplier, superBreakerMultiplier, PetPay, VipPetPay; public String localeString; public boolean useBlockProtection; public boolean useBlockTimer; + public boolean useMinimumOveralPayment; public boolean useBreederFinder, CancelCowMilking; public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat, @@ -90,6 +91,7 @@ public class JobsConfiguration { public Integer levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume, SoundTitleChangePitch, ToplistInScoreboardInterval; public double BoostExp; + public double MinimumOveralPaymentLimit; public double BoostMoney; public double DynamicPaymentMaxPenalty; public double DynamicPaymentMaxBonus; @@ -428,9 +430,15 @@ public class JobsConfiguration { "Setting this too low may cause tick lag. Increase this to improve economy performance (at the cost of delays in payment)"); economyBatchDelay = getInt("economy-batch-delay", 5, config, writer); - writer.addComment("economy-async", "Enable async economy calls.", "Disabl this if you have issues with payments or your plugin is not thread safe."); + writer.addComment("economy-async", "Enable async economy calls.", "Disable this if you have issues with payments or your plugin is not thread safe."); economyAsync = getBoolean("economy-async", true, config, writer); + writer.addComment("Economy.MinimumOveralPayment.use", + "Determines minimum payment. In example if player uses McMMO treefeller and earns only 20%, but at same time he gets 25% penalty from dynamic payment. He can 'get' negative amount of money", + "This will limit it to particular percentage", "Works only when original payment is above 0"); + useMinimumOveralPayment = getBoolean("Economy.MinimumOveralPayment.use", true, config, writer); + MinimumOveralPaymentLimit = getDouble("Economy.MinimumOveralPayment.limit", 0.1, config, writer); + writer.addComment("Economy.DynamicPayment.use", "Do you want to use dinamic payment dependent on how many players already working for jobs", "This can help automaticaly lift up payments for not so popular jobs and lower for most popular ones"); useDynamicPayment = getBoolean("Economy.DynamicPayment.use", false, config, writer); @@ -593,6 +601,9 @@ public class JobsConfiguration { writer.addComment("ExploitProtections.McMMO.gigaDrillMultiplier", "Players will get part of money from braking blocks with gigaDrill ability enabled.", "0.2 means 20% of original price"); gigaDrillMultiplier = getDouble("ExploitProtections.McMMO.gigaDrillMultiplier", 0.2, config, writer); + writer.addComment("ExploitProtections.McMMO.superBreakerMultiplier", "Players will get part of money from braking blocks with super breaker ability enabled.", + "0.2 means 20% of original price"); + superBreakerMultiplier = getDouble("ExploitProtections.McMMO.superBreakerMultiplier", 0.2, config, writer); writer.addComment("ExploitProtections.Spawner.PreventSlimeSplit", "Prevent slime spliting when they are from spawner", "Protects agains exploiting as new splited slimes is treated as naturaly spawned and not from spawner"); diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index cb6ca005..0951d909 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -311,9 +311,11 @@ public class JobsPaymentListener implements Listener { try { if (McMMOlistener.mcMMOPresent) if (AbilityAPI.treeFellerEnabled(player)) - multiplier -= (1 - ConfigManager.getJobsConfiguration().TreeFellerMultiplier); + multiplier = multiplier * ConfigManager.getJobsConfiguration().TreeFellerMultiplier; else if (AbilityAPI.gigaDrillBreakerEnabled(player)) - multiplier -= (1 - ConfigManager.getJobsConfiguration().gigaDrillMultiplier); + multiplier = multiplier * ConfigManager.getJobsConfiguration().gigaDrillMultiplier; + else if (AbilityAPI.superBreakerEnabled(player)) + multiplier = multiplier * ConfigManager.getJobsConfiguration().superBreakerMultiplier; } catch (IndexOutOfBoundsException e) { }