1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 23:13:48 +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; public static LoadStatus status = LoadStatus.Good;
private static boolean hasLimitedItems = false;
private static final int MAX_ENTRIES = 5; private static final int MAX_ENTRIES = 5;
public static final LinkedHashMap<UUID, FastPayment> FASTPAYMENT = new LinkedHashMap<UUID, FastPayment>(MAX_ENTRIES + 1, .75F, false) { public static final LinkedHashMap<UUID, FastPayment> FASTPAYMENT = new LinkedHashMap<UUID, FastPayment>(MAX_ENTRIES + 1, .75F, false) {
protected boolean removeEldestEntry(Map.Entry<UUID, FastPayment> eldest) { protected boolean removeEldestEntry(Map.Entry<UUID, FastPayment> eldest) {
@ -834,6 +836,8 @@ public final class Jobs extends JavaPlugin {
getLanguage().reload(); getLanguage().reload();
getConfigManager().reload(); getConfigManager().reload();
hasLimitedItems = Jobs.getJobs().stream().anyMatch(job -> !job.getLimitedItems().isEmpty());
getDBManager().getDB().loadAllJobsWorlds(); getDBManager().getDB().loadAllJobsWorlds();
getDBManager().getDB().loadAllJobsNames(); getDBManager().getDB().loadAllJobsNames();
@ -1506,4 +1510,8 @@ public final class Jobs extends JavaPlugin {
if (pageCount != 0) if (pageCount != 0)
rm.show(sender); 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) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onLimitedItemInteract(PlayerInteractEvent event) { public void onLimitedItemInteract(PlayerInteractEvent event) {
if(!Jobs.hasLimitedItems())
{
return;
}
Player player = event.getPlayer(); Player player = event.getPlayer();
ItemStack iih = CMIItemStack.getItemInMainHand(player); ItemStack iih = CMIItemStack.getItemInMainHand(player);
if (iih.getType() == Material.AIR) if (iih.getType() == Material.AIR)