1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-02-01 21:11:30 +01:00

Fix version checking

- Fix when the money/exp/points displayed more values than original. This was caused by boosted items even its not exists.
  - Fixes #851
This commit is contained in:
montlikadani 2020-07-09 19:08:04 +02:00
parent adce7558d2
commit 22f3f61bfc
6 changed files with 30 additions and 35 deletions

View File

@ -53,8 +53,9 @@ public class VersionChecker {
if (newVersion == null) if (newVersion == null)
return; return;
String currentVersion = plugin.getDescription().getVersion(); int currentVersion = Integer.parseInt(plugin.getDescription().getVersion().replace(".", ""));
if (Integer.parseInt(newVersion.replace(".", "")) <= Integer.parseInt(currentVersion.replace(".", ""))) if (Integer.parseInt(newVersion.replace(".", "")) <= currentVersion || currentVersion >=
Integer.parseInt(newVersion.replace(".", "")))
return; return;
List<String> msg = Arrays.asList( List<String> msg = Arrays.asList(

View File

@ -40,10 +40,10 @@ public class GuiManager {
gui.setTitle(Jobs.getLanguage().getMessage("command.info.gui.pickjob")); gui.setTitle(Jobs.getLanguage().getMessage("command.info.gui.pickjob"));
gui.setFiller(CMIMaterial.get(Jobs.getGCManager().guiFiller)); gui.setFiller(CMIMaterial.get(Jobs.getGCManager().guiFiller));
int GuiSize = Jobs.getGCManager().getJobsGUIRows() * 9; int GuiSize = Jobs.getGCManager().getJobsGUIRows() * 9,
neededSlots = JobsList.size() + ((JobsList.size() / Jobs.getGCManager().getJobsGUIGroupAmount())
int neededSlots = JobsList.size() + ((JobsList.size() / Jobs.getGCManager().getJobsGUIGroupAmount()) * Jobs.getGCManager().getJobsGUISkipAmount()) + Jobs.getGCManager().getJobsGUIStartPosition(); * Jobs.getGCManager().getJobsGUISkipAmount()) + Jobs.getGCManager().getJobsGUIStartPosition(),
int neededRows = (int) Math.ceil(neededSlots / 9D); neededRows = (int) Math.ceil(neededSlots / 9D);
// Resizing GUI in case we have more jobs then we could fit in current setup // Resizing GUI in case we have more jobs then we could fit in current setup
GuiSize = Jobs.getGCManager().getJobsGUIRows() > neededRows ? GuiSize : neededRows * 9; GuiSize = Jobs.getGCManager().getJobsGUIRows() > neededRows ? GuiSize : neededRows * 9;
@ -216,19 +216,16 @@ public class GuiManager {
} }
double income = jInfo.getIncome(level, numjobs); double income = jInfo.getIncome(level, numjobs);
income = boost.getFinalAmount(CurrencyType.MONEY, income) + ((Jobs.getPlayerManager().getInventoryBoost(player, job) income = boost.getFinalAmount(CurrencyType.MONEY, income);
.get(CurrencyType.MONEY)) + 1);
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString(); String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
double xp = jInfo.getExperience(level, numjobs); double xp = jInfo.getExperience(level, numjobs);
xp = boost.getFinalAmount(CurrencyType.EXP, xp) + ((Jobs.getPlayerManager().getInventoryBoost(player, job) xp = boost.getFinalAmount(CurrencyType.EXP, xp);
.get(CurrencyType.EXP)) + 1);
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString(); String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
double points = jInfo.getPoints(level, numjobs); double points = jInfo.getPoints(level, numjobs);
points = boost.getFinalAmount(CurrencyType.POINTS, points) + ((Jobs.getPlayerManager().getInventoryBoost(player, job) points = boost.getFinalAmount(CurrencyType.POINTS, points);
.get(CurrencyType.POINTS)) + 1); String pointsColor = points >= 0 ? "" : ChatColor.RED.toString();
String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString();
if (income == 0D && points == 0D && xp == 0D) if (income == 0D && points == 0D && xp == 0D)
continue; continue;
@ -236,15 +233,15 @@ public class GuiManager {
String itemName = jInfo.getRealisticName(); String itemName = jInfo.getRealisticName();
String val = ""; String val = "";
if (income != 0.0 && Jobs.getGCManager().PaymentMethodsMoney) if (income != 0.0)
val += Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor val += Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor
+ String.format(Jobs.getGCManager().getDecimalPlacesMoney(), income)); + String.format(Jobs.getGCManager().getDecimalPlacesMoney(), income));
if (points != 0.0 && Jobs.getGCManager().PaymentMethodsPoints) if (points != 0.0)
val += Jobs.getLanguage().getMessage("command.info.help.points", "%points%", pointsColor val += Jobs.getLanguage().getMessage("command.info.help.points", "%points%", pointsColor
+ String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points)); + String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points));
if (xp != 0.0 && Jobs.getGCManager().PaymentMethodsExp) if (xp != 0.0)
val += Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor val += Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor
+ String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp)); + String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp));
@ -376,19 +373,16 @@ public class GuiManager {
} }
double income = jInfo.getIncome(level, numjobs); double income = jInfo.getIncome(level, numjobs);
income = boost.getFinalAmount(CurrencyType.MONEY, income) + ((Jobs.getPlayerManager().getInventoryBoost(player, job) income = boost.getFinalAmount(CurrencyType.MONEY, income);
.get(CurrencyType.MONEY)) + 1);
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString(); String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
double xp = jInfo.getExperience(level, numjobs); double xp = jInfo.getExperience(level, numjobs);
xp = boost.getFinalAmount(CurrencyType.EXP, xp) + ((Jobs.getPlayerManager().getInventoryBoost(player, job) xp = boost.getFinalAmount(CurrencyType.EXP, xp);
.get(CurrencyType.EXP)) + 1);
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString(); String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
double points = jInfo.getPoints(level, numjobs); double points = jInfo.getPoints(level, numjobs);
points = boost.getFinalAmount(CurrencyType.POINTS, points) + ((Jobs.getPlayerManager().getInventoryBoost(player, job) points = boost.getFinalAmount(CurrencyType.POINTS, points);
.get(CurrencyType.POINTS)) + 1); String pointsColor = points >= 0 ? "" : ChatColor.RED.toString();
String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString();
if (income == 0D && points == 0D && xp == 0D) if (income == 0D && points == 0D && xp == 0D)
continue; continue;
@ -396,15 +390,15 @@ public class GuiManager {
String itemName = jInfo.getRealisticName(); String itemName = jInfo.getRealisticName();
String val = ""; String val = "";
if (income != 0.0 && Jobs.getGCManager().PaymentMethodsMoney) if (income != 0.0)
val += Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor val += Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor
+ String.format(Jobs.getGCManager().getDecimalPlacesMoney(), income)); + String.format(Jobs.getGCManager().getDecimalPlacesMoney(), income));
if (points != 0.0 && Jobs.getGCManager().PaymentMethodsPoints) if (points != 0.0)
val += Jobs.getLanguage().getMessage("command.info.help.points", "%points%", pointsColor val += Jobs.getLanguage().getMessage("command.info.help.points", "%points%", pointsColor
+ String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points)); + String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points));
if (xp != 0.0 && Jobs.getGCManager().PaymentMethodsExp) if (xp != 0.0)
val += Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor val += Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor
+ String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp)); + String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp));

View File

@ -35,7 +35,9 @@ public class editquests implements Cmd {
@Override @Override
@JobCommand(721) @JobCommand(721)
public boolean perform(Jobs plugin, CommandSender sender, String[] args) { public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (sender instanceof Player) { if (!(sender instanceof Player))
return false;
Player player = (Player) sender; Player player = (Player) sender;
if (args.length == 0) { if (args.length == 0) {
@ -580,7 +582,6 @@ public class editquests implements Cmd {
} }
Util.getQuestsEditorMap().remove(player.getUniqueId()); Util.getQuestsEditorMap().remove(player.getUniqueId());
return true; return true;
} }
@ -588,7 +589,7 @@ public class editquests implements Cmd {
default: default:
break; break;
} }
}
return false; return false;
} }

View File

@ -23,20 +23,21 @@ public class entitylist implements Cmd {
int i = 0; int i = 0;
for (EntityType type : EntityType.values()) { for (EntityType type : EntityType.values()) {
if (!type.isAlive()) if (!type.isAlive() || !type.isSpawnable())
continue;
if (!type.isSpawnable())
continue; continue;
i++; i++;
if (!msg.isEmpty()) if (!msg.isEmpty())
msg += ", "; msg += ", ";
if (i > 1) { if (i > 1) {
msg += c1; msg += c1;
i = 0; i = 0;
} else { } else {
msg += c2; msg += c2;
} }
msg += type.name().toLowerCase(); msg += type.name().toLowerCase();
} }

View File

@ -30,7 +30,6 @@ public class McMMO1_X_listener implements Listener {
@EventHandler @EventHandler
public void onFishingTreasure(McMMOPlayerFishingTreasureEvent event) { public void onFishingTreasure(McMMOPlayerFishingTreasureEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
@ -56,7 +55,7 @@ public class McMMO1_X_listener implements Listener {
if (event.getTreasure() == null) if (event.getTreasure() == null)
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null) if (jPlayer == null)
return; return;

View File

@ -30,7 +30,6 @@ public class McMMO2_X_listener implements Listener {
@EventHandler @EventHandler
public void onFishingTreasure(McMMOPlayerFishingTreasureEvent event) { public void onFishingTreasure(McMMOPlayerFishingTreasureEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!plugin.isEnabled()) if (!plugin.isEnabled())
return; return;