1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-31 21:37:57 +01:00

Hiding more information when requirements are not met for shop items

This commit is contained in:
Zrips 2023-06-23 13:44:18 +03:00
parent 789e8ff7a6
commit aba467be70
3 changed files with 263 additions and 240 deletions

View File

@ -65,6 +65,7 @@ import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.NBT.CMINBT;
import net.Zrips.CMILib.Version.Version;
@ -487,6 +488,9 @@ public class PlayerManager {
job.updateTotalPlayers();
jPlayer.maxJobsEquation = getMaxJobs(jPlayer);
// Removing from cached item boost for recalculation
cache.remove(jPlayer.getUniqueId());
}
private static void performCommandsOnLeave(JobsPlayer jPlayer, Job job) {
@ -528,6 +532,10 @@ public class PlayerManager {
Jobs.getSignUtil().updateAllSign(job);
job.updateTotalPlayers();
// Removing from cached item boost for recalculation
cache.remove(jPlayer.getUniqueId());
return true;
}
@ -1055,6 +1063,8 @@ public class PlayerManager {
continue;
}
}
CMIDebug.d("get bonus item");
jitems.add(getJobsItemByNbt(item));
}
}

View File

@ -113,11 +113,14 @@ public class ShopManager {
List<String> lore = new ArrayList<>();
CMIMaterial mat = CMIMaterial.get(item.getIconMaterial());
boolean hiddenLore = false;
if (item.isHideWithoutPerm()) {
for (String onePerm : item.getRequiredPerm()) {
if (!player.hasPermission(onePerm)) {
mat = CMIMaterial.STONE_BUTTON;
lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy"));
hiddenLore = true;
break;
}
}
@ -127,6 +130,7 @@ public class ShopManager {
jPlayer.getTotalLevels() < item.getRequiredTotalLevels()) {
mat = CMIMaterial.STONE_BUTTON;
lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPoints"));
hiddenLore = true;
}
if (mat == CMIMaterial.NONE)
@ -142,6 +146,7 @@ public class ShopManager {
if (item.getIconName() != null)
meta.setDisplayName(item.getIconName());
if (!hiddenLore) {
lore.addAll(item.getIconLore());
if (item.getPointPrice() > 0) {
@ -185,6 +190,7 @@ public class ShopManager {
"%totalLevel%", (jPlayer.getTotalLevels() < item.getRequiredTotalLevels()
? Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevelColor") : "") + item.getRequiredTotalLevels()));
}
}
meta.setLore(lore);

View File

@ -225,8 +225,15 @@ public class Job {
eq.setVariable("totaljobs", Jobs.getJobs().size());
eq.setVariable("jobstotalplayers", getTotalPlayers());
double now = eq.getValue();
CMIDebug.d("Now",now);
double now = 0D;
try {
now = eq.getValue();
} catch (Throwable e) {
e.printStackTrace();
}
CMIDebug.d("Now", now, this.getName(), getTotalPlayers(), now == Double.POSITIVE_INFINITY);
if (now > Jobs.getGCManager().DynamicPaymentMaxBonus)
now = Jobs.getGCManager().DynamicPaymentMaxBonus;