1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

Merge pull request #1391 from MisterFrans/limited-item

Avoid checking limited items if none are configured
This commit is contained in:
Zrips 2022-02-10 18:59:02 +02:00 committed by GitHub
commit a6f074607f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)