mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-22 02:25:49 +01:00
fix: improve performance by fetching materials only once
This commit is contained in:
parent
6a228d8e7d
commit
2a75aca157
@ -102,9 +102,11 @@ public class Listeners implements Listener {
|
||||
Location loc = player.getLocation();
|
||||
Location eyeLoc = player.getEyeLocation();
|
||||
UUID uuid = player.getUniqueId();
|
||||
Material block = loc.getBlock().getType();
|
||||
Material eyeBlock = eyeLoc.getBlock().getType();
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (!portal.inPortal.contains(uuid)
|
||||
&& (Portal.locationInPortalTrigger(portal, loc) || Portal.locationInPortalTrigger(portal, eyeLoc))) {
|
||||
&& (Portal.locationInPortalTrigger(portal, loc, block) || Portal.locationInPortalTrigger(portal, eyeLoc, eyeBlock))) {
|
||||
portal.inPortal.add(uuid);
|
||||
}
|
||||
}
|
||||
|
@ -694,14 +694,23 @@ public class Portal {
|
||||
}
|
||||
|
||||
public static boolean inPortalTriggerRegion(Location loc) {
|
||||
Material block = loc.getBlock().getType();
|
||||
for (AdvancedPortal portal : Portal.portals)
|
||||
if (Portal.locationInPortalTrigger(portal, loc))
|
||||
if (Portal.locationInPortalTrigger(portal, loc, block))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean locationInPortalTrigger(AdvancedPortal portal, Location loc, int additionalArea) {
|
||||
return portal.getTriggers().contains(loc.getBlock().getType()) && locationInPortal(portal, loc, additionalArea);
|
||||
return locationInPortalTrigger(portal, loc, additionalArea, loc.getBlock().getType());
|
||||
}
|
||||
|
||||
public static boolean locationInPortalTrigger(AdvancedPortal portal, Location loc, int additionalArea, Material type) {
|
||||
return portal.getTriggers().contains(type) && locationInPortal(portal, loc, additionalArea);
|
||||
}
|
||||
|
||||
public static boolean locationInPortalTrigger(AdvancedPortal portal, Location loc, Material type) {
|
||||
return locationInPortalTrigger(portal, loc, 0, type);
|
||||
}
|
||||
|
||||
public static boolean locationInPortalTrigger(AdvancedPortal portal, Location loc) {
|
||||
|
Loading…
Reference in New Issue
Block a user