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)
return;
String currentVersion = plugin.getDescription().getVersion();
if (Integer.parseInt(newVersion.replace(".", "")) <= Integer.parseInt(currentVersion.replace(".", "")))
int currentVersion = Integer.parseInt(plugin.getDescription().getVersion().replace(".", ""));
if (Integer.parseInt(newVersion.replace(".", "")) <= currentVersion || currentVersion >=
Integer.parseInt(newVersion.replace(".", "")))
return;
List<String> msg = Arrays.asList(

View File

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

View File

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

View File

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

View File

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

View File

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