mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 15:03:36 +01:00
Merge pull request #1391 from MisterFrans/limited-item
Avoid checking limited items if none are configured
This commit is contained in:
commit
a6f074607f
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user