mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-18 06:01:46 +01:00
Improve minimum overal payments conflicting with only money limit
This commit is contained in:
parent
c8b4eaa479
commit
36075276f8
@ -195,10 +195,14 @@ public class Jobs extends JavaPlugin {
|
||||
if (papi == null || !papi.isEnabled())
|
||||
return false;
|
||||
|
||||
try {
|
||||
if (Integer.parseInt(papi
|
||||
.getDescription().getVersion().replaceAll("[^\\d]", "")) >= 2100 && new PlaceholderAPIHook(this).register()) {
|
||||
consoleMsg("&e[Jobs] PlaceholderAPI hooked.");
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1000,26 +1004,29 @@ public class Jobs extends JavaPlugin {
|
||||
}
|
||||
|
||||
// Calculate income
|
||||
|
||||
if (income != 0D) {
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
|
||||
if (gConfigManager.useMinimumOveralPayment && income > 0) {
|
||||
double maxLimit = income * gConfigManager.MinimumOveralPaymentLimit;
|
||||
|
||||
if (income < maxLimit)
|
||||
income = maxLimit;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate points
|
||||
|
||||
if (pointAmount != 0D) {
|
||||
pointAmount = boost.getFinalAmount(CurrencyType.POINTS, pointAmount);
|
||||
|
||||
if (gConfigManager.useMinimumOveralPoints && pointAmount > 0) {
|
||||
double maxLimit = pointAmount * gConfigManager.MinimumOveralPaymentLimit;
|
||||
double maxLimit = pointAmount * gConfigManager.MinimumOveralPointsLimit;
|
||||
|
||||
if (pointAmount < maxLimit)
|
||||
pointAmount = maxLimit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!jPlayer.isUnderLimit(CurrencyType.MONEY, income)) {
|
||||
if (gConfigManager.useMaxPaymentCurve) {
|
||||
double percentOver = jPlayer.percentOverLimit(CurrencyType.MONEY);
|
||||
@ -1136,8 +1143,10 @@ public class Jobs extends JavaPlugin {
|
||||
// Calculate income
|
||||
if (income != 0D) {
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
|
||||
if (gConfigManager.useMinimumOveralPayment && income > 0) {
|
||||
double maxLimit = income * gConfigManager.MinimumOveralPaymentLimit;
|
||||
|
||||
if (income < maxLimit)
|
||||
income = maxLimit;
|
||||
}
|
||||
@ -1146,21 +1155,26 @@ public class Jobs extends JavaPlugin {
|
||||
// Calculate points
|
||||
if (pointAmount != 0D) {
|
||||
pointAmount = boost.getFinalAmount(CurrencyType.POINTS, pointAmount);
|
||||
|
||||
if (gConfigManager.useMinimumOveralPoints && pointAmount > 0) {
|
||||
double maxLimit = pointAmount * gConfigManager.MinimumOveralPaymentLimit;
|
||||
double maxLimit = pointAmount * gConfigManager.MinimumOveralPointsLimit;
|
||||
|
||||
if (pointAmount < maxLimit)
|
||||
pointAmount = maxLimit;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate exp
|
||||
if (expAmount != 0D) {
|
||||
expAmount = boost.getFinalAmount(CurrencyType.EXP, expAmount);
|
||||
|
||||
if (gConfigManager.useMinimumOveralPayment && expAmount > 0) {
|
||||
double maxLimit = expAmount * gConfigManager.MinimumOveralPaymentLimit;
|
||||
if (gConfigManager.useMinimumOveralExp && expAmount > 0) {
|
||||
double maxLimit = expAmount * gConfigManager.minimumOveralExpLimit;
|
||||
|
||||
if (expAmount < maxLimit)
|
||||
expAmount = maxLimit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!jPlayer.isUnderLimit(CurrencyType.MONEY, income)) {
|
||||
income = 0D;
|
||||
|
@ -102,12 +102,9 @@ public class JobsCommands implements CommandExecutor {
|
||||
|
||||
private String getUsage(String cmd) {
|
||||
String cmdString = Jobs.getLanguage().getMessage("command.help.output.cmdFormat", "[command]", Jobs.getLanguage().getMessage("command.help.output.label") + " " + cmd);
|
||||
String key = "command." + cmd + ".help.args";
|
||||
if (Jobs.getLanguage().containsKey(key) && !Jobs.getLanguage().getMessage(key).isEmpty()) {
|
||||
cmdString = cmdString.replace("[arguments]", Jobs.getLanguage().getMessage(key));
|
||||
} else
|
||||
cmdString = cmdString.replace("[arguments]", "");
|
||||
String msg = Jobs.getLanguage().getMessage("command." + cmd + ".help.args");
|
||||
|
||||
cmdString = cmdString.replace("[arguments]", !msg.isEmpty() ? msg : "");
|
||||
return cmdString;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class GeneralConfigManager {
|
||||
private int ResetTimeHour, ResetTimeMinute, DailyQuestsSkips, FurnacesMaxDefault, BrewingStandsMaxDefault,
|
||||
BrowseAmountToShow, JobsGUIRows, JobsGUIBackButton, JobsGUINextButton, JobsGUIStartPosition, JobsGUIGroupAmount, JobsGUISkipAmount;
|
||||
|
||||
public double skipQuestCost, MinimumOveralPaymentLimit, MinimumOveralPointsLimit, MonsterDamagePercentage,
|
||||
public double skipQuestCost, MinimumOveralPaymentLimit, minimumOveralExpLimit, MinimumOveralPointsLimit, MonsterDamagePercentage,
|
||||
DynamicPaymentMaxPenalty, DynamicPaymentMaxBonus, TaxesAmount;
|
||||
|
||||
public Double TreeFellerMultiplier, gigaDrillMultiplier, superBreakerMultiplier;
|
||||
@ -85,7 +85,7 @@ public class GeneralConfigManager {
|
||||
PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps,
|
||||
BrowseUseNewLook, payExploringWhenGliding = false, disablePaymentIfMaxLevelReached, disablePaymentIfRiding,
|
||||
boostedItemsInOffHand = false, boostedItemsInMainHand, boostedArmorItems/*, preventCropResizePayment*/, payItemDurabilityLoss,
|
||||
applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useBreederFinder,
|
||||
applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useMinimumOveralExp, useBreederFinder,
|
||||
CancelCowMilking, fixAtMaxLevel, TitleChangeChat, TitleChangeActionBar, LevelChangeChat,
|
||||
LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAccountChat,
|
||||
EmptyServerAccountActionBar, ActionBarsMessageByDefault, aBarSilentMode, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
|
||||
@ -556,15 +556,26 @@ public class GeneralConfigManager {
|
||||
applyToNegativeIncome = c.get("Economy.ApplyToNegativeIncome", false);
|
||||
|
||||
c.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",
|
||||
"Determines minimum payment.",
|
||||
"In example if player uses McMMO treefeller and earns only 20%, but at same time player gets 25% penalty from dynamic payment.",
|
||||
"The player can 'get' negative amount of money",
|
||||
"This will limit it to particular percentage", "Works only when original payment is above 0");
|
||||
useMinimumOveralPayment = c.get("Economy.MinimumOveralPayment.use", true);
|
||||
MinimumOveralPaymentLimit = c.get("Economy.MinimumOveralPayment.limit", 0.1);
|
||||
c.addComment("Economy.MinimumOveralPoints.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",
|
||||
"Determines minimum payment for points.",
|
||||
"In example if player uses McMMO treefeller and earns only 20%, but at same time player gets 25% penalty from dynamic payment.",
|
||||
"The player can 'get' negative amount of points",
|
||||
"This will limit it to particular percentage", "Works only when original payment is above 0");
|
||||
useMinimumOveralPoints = c.get("Economy.MinimumOveralPoints.use", true);
|
||||
MinimumOveralPointsLimit = c.get("Economy.MinimumOveralPoints.limit", 0.1);
|
||||
c.addComment("Economy.MinimumOveralExp.use",
|
||||
"Determines minimum payment for experience.",
|
||||
"In example if player uses McMMO treefeller and earns only 20%, but at same time player gets 25% penalty from dynamic payment.",
|
||||
"The player can 'get' negative amount of experience",
|
||||
"This will limit it to particular percentage", "Works only when original payment is above 0");
|
||||
useMinimumOveralExp = c.get("Economy.MinimumOveralExp.use", true);
|
||||
minimumOveralExpLimit = c.get("Economy.MinimumOveralExp.limit", 0.1);
|
||||
|
||||
c.addComment("Economy.DynamicPayment.use", "Do you want to use dynamic payment dependent on how many players already working for jobs?",
|
||||
"This can help automatically lift up payments for not so popular jobs and lower for most popular ones");
|
||||
|
@ -28,10 +28,11 @@ public class Boost {
|
||||
}
|
||||
|
||||
public double get(BoostOf boostOf, CurrencyType type, boolean percent) {
|
||||
if (!map.containsKey(boostOf))
|
||||
BoostMultiplier bm = map.get(boostOf);
|
||||
if (bm == null)
|
||||
return 0D;
|
||||
|
||||
double r = map.get(boostOf).get(type);
|
||||
double r = bm.get(type);
|
||||
if (r < -1)
|
||||
r = -1;
|
||||
|
||||
@ -45,7 +46,7 @@ public class Boost {
|
||||
public double getFinalAmount(CurrencyType type, double income) {
|
||||
double f = income;
|
||||
|
||||
if (income > 0 || income < 0 && Jobs.getGCManager().applyToNegativeIncome)
|
||||
if (income > 0 || (income < 0 && Jobs.getGCManager().applyToNegativeIncome))
|
||||
f = income + income * getFinal(type, false, false);
|
||||
|
||||
if (income > 0 && f < 0 || income < 0 && f > 0)
|
||||
@ -58,13 +59,13 @@ public class Boost {
|
||||
double r = 0D;
|
||||
|
||||
for (BoostOf one : BoostOf.values()) {
|
||||
if (!map.containsKey(one))
|
||||
BoostMultiplier bm = map.get(one);
|
||||
if (bm == null)
|
||||
continue;
|
||||
|
||||
if (excludeExtra && (one == BoostOf.NearSpawner || one == BoostOf.PetPay))
|
||||
continue;
|
||||
|
||||
BoostMultiplier bm = map.get(one);
|
||||
if (bm.isValid(type))
|
||||
r += bm.get(type);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class Language {
|
||||
String missing = "MLF " + key;
|
||||
String msg = "";
|
||||
try {
|
||||
if (customlocale == null || !customlocale.contains(key))
|
||||
if (!customlocale.contains(key))
|
||||
msg = enlocale.isString(key) ? CMIChatColor.translate(enlocale.getString(key)) : missing;
|
||||
else
|
||||
msg = customlocale.isString(key) ? CMIChatColor.translate(customlocale.getString(key)) : missing;
|
||||
@ -75,10 +75,14 @@ public class Language {
|
||||
try {
|
||||
|
||||
List<String> ls = null;
|
||||
if (customlocale != null && customlocale.isList(key))
|
||||
|
||||
if (customlocale.isList(key))
|
||||
ls = colorsArray(customlocale.getStringList(key), true);
|
||||
else if (enlocale.isList(key))
|
||||
ls = !enlocale.getStringList(key).isEmpty() ? colorsArray(enlocale.getStringList(key), true) : Arrays.asList(missing);
|
||||
else if (enlocale.isList(key)) {
|
||||
ls = enlocale.getStringList(key);
|
||||
ls = !ls.isEmpty() ? colorsArray(ls, true) : Arrays.asList(missing);
|
||||
}
|
||||
|
||||
if (ls != null)
|
||||
for (String one : ls) {
|
||||
if (!msg.isEmpty())
|
||||
@ -113,8 +117,10 @@ public class Language {
|
||||
List<String> ls;
|
||||
if (customlocale.isList(key))
|
||||
ls = colorsArray(customlocale.getStringList(key), true);
|
||||
else
|
||||
ls = !enlocale.getStringList(key).isEmpty() ? colorsArray(enlocale.getStringList(key), true) : Arrays.asList(missing);
|
||||
else {
|
||||
ls = enlocale.getStringList(key);
|
||||
ls = !ls.isEmpty() ? colorsArray(ls, true) : Arrays.asList(missing);
|
||||
}
|
||||
|
||||
if (variables != null && variables.length > 0)
|
||||
for (int i = 0; i < ls.size(); i++) {
|
||||
@ -139,32 +145,14 @@ public class Language {
|
||||
|
||||
public List<String> colorsArray(List<String> text, boolean colorize) {
|
||||
List<String> temp = new ArrayList<>();
|
||||
|
||||
for (String part : text) {
|
||||
if (colorize)
|
||||
part = CMIChatColor.translate(part);
|
||||
temp.add(CMIChatColor.translate(part));
|
||||
|
||||
temp.add(part);
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message with the correct key
|
||||
* @param key - the key of the message
|
||||
* @return the message
|
||||
*/
|
||||
public String getDefaultMessage(String key) {
|
||||
return enlocale.contains(key) ? CMIChatColor.translate(enlocale.getString(key)) : "Can't find locale";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if key exists
|
||||
* @param key - the key of the message
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean containsKey(String key) {
|
||||
if (customlocale == null || !customlocale.contains(key))
|
||||
return enlocale.contains(key);
|
||||
return customlocale.contains(key);
|
||||
}
|
||||
}
|
||||
|
@ -1138,7 +1138,6 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
|
||||
LivingEntity lVictim = (LivingEntity) e.getEntity();
|
||||
UUID lVictimUUID = lVictim.getUniqueId();
|
||||
boolean hadSpawnerMobMetadata = lVictim.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata());
|
||||
|
||||
if (hadSpawnerMobMetadata) {
|
||||
@ -1149,10 +1148,14 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().MonsterDamageUse) {
|
||||
UUID lVictimUUID = lVictim.getUniqueId();
|
||||
Double damage = damageDealtByPlayers.getIfPresent(lVictimUUID);
|
||||
|
||||
if (damage != null) {
|
||||
double perc = (damage * 100D) / Jobs.getNms().getMaxHealth(lVictim);
|
||||
|
||||
damageDealtByPlayers.invalidate(lVictimUUID);
|
||||
|
||||
if (perc < Jobs.getGCManager().MonsterDamagePercentage)
|
||||
return;
|
||||
}
|
||||
@ -1172,23 +1175,25 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
|
||||
Player pDamager = null;
|
||||
|
||||
boolean isTameable = e.getDamager() instanceof Tameable;
|
||||
boolean isMyPet = HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager(), null);
|
||||
|
||||
// Checking if killer is player
|
||||
if (e.getDamager() instanceof Player) {
|
||||
if (e.getDamager() instanceof Player) { // Checking if killer is player
|
||||
pDamager = (Player) e.getDamager();
|
||||
// Checking if killer is MyPet animal
|
||||
} else if (isMyPet) {
|
||||
} else if (isMyPet) { // Checking if killer is MyPet animal
|
||||
UUID uuid = HookManager.getMyPetManager().getOwnerOfPet(e.getDamager());
|
||||
|
||||
if (uuid != null)
|
||||
pDamager = Bukkit.getPlayer(uuid);
|
||||
// Checking if killer is tamed animal
|
||||
} else if (e.getDamager() instanceof Tameable) {
|
||||
} else if (isTameable) { // Checking if killer is tamed animal
|
||||
Tameable t = (Tameable) e.getDamager();
|
||||
|
||||
if (t.isTamed() && t.getOwner() instanceof Player)
|
||||
pDamager = (Player) t.getOwner();
|
||||
} else if (e.getDamager() instanceof Projectile) {
|
||||
Projectile pr = (Projectile) e.getDamager();
|
||||
|
||||
if (pr.getShooter() instanceof Player)
|
||||
pDamager = (Player) pr.getShooter();
|
||||
}
|
||||
@ -1197,10 +1202,9 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
|
||||
// Prevent payment for killing mobs with pet by denying permission
|
||||
if (isMyPet || (e.getDamager() instanceof Tameable && ((Tameable) e.getDamager()).isTamed() &&
|
||||
((Tameable) e.getDamager()).getOwner() instanceof Player)) {
|
||||
if (isMyPet || isTameable) {
|
||||
for (PermissionAttachmentInfo perm : pDamager.getEffectivePermissions()) {
|
||||
if (!perm.getValue() && "jobs.petpay".equals(perm.getPermission())) {
|
||||
if (!perm.getValue() && perm.getPermission().contains("jobs.petpay")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1695,7 +1699,7 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
|
||||
public static boolean payIfCreative(Player player) {
|
||||
if (player.getGameMode() == GameMode.CREATIVE && !Jobs.getGCManager().payInCreative() && !player.hasPermission("jobs.paycreative"))
|
||||
if (!Jobs.getGCManager().payInCreative() && player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("jobs.paycreative"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user