1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-18 06:01:46 +01:00

Avoid checking limited items if none are configured

This commit is contained in:
François 2022-02-08 18:07:12 +01:00
parent 137ec98ab0
commit d3d1948fc5
2 changed files with 14 additions and 0 deletions

View File

@ -165,6 +165,8 @@ public final class Jobs extends JavaPlugin {
public static LoadStatus status = LoadStatus.Good;
private static boolean hasLimitedItems = false;
private static final int MAX_ENTRIES = 5;
public static final LinkedHashMap<UUID, FastPayment> FASTPAYMENT = new LinkedHashMap<UUID, FastPayment>(MAX_ENTRIES + 1, .75F, false) {
protected boolean removeEldestEntry(Map.Entry<UUID, FastPayment> eldest) {
@ -834,6 +836,8 @@ public final class Jobs extends JavaPlugin {
getLanguage().reload();
getConfigManager().reload();
hasLimitedItems = Jobs.getJobs().stream().anyMatch(job -> !job.getLimitedItems().isEmpty());
getDBManager().getDB().loadAllJobsWorlds();
getDBManager().getDB().loadAllJobsNames();
@ -1506,4 +1510,8 @@ public final class Jobs extends JavaPlugin {
if (pageCount != 0)
rm.show(sender);
}
public static boolean hasLimitedItems() {
return hasLimitedItems;
}
}

View File

@ -382,6 +382,12 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onLimitedItemInteract(PlayerInteractEvent event) {
if(!Jobs.hasLimitedItems())
{
return;
}
Player player = event.getPlayer();
ItemStack iih = CMIItemStack.getItemInMainHand(player);
if (iih.getType() == Material.AIR)