9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-28 19:29:16 +00:00

Various performance improvements to RPGRegionsIntegration

This commit is contained in:
SamB440
2022-09-17 16:40:26 +01:00
parent 6eb563198f
commit b60ba7d4a5
3 changed files with 9 additions and 7 deletions

View File

@@ -135,7 +135,7 @@ public class RPGRegionsIntegration implements IntegrationManager {
RPGRegionsRegion highest = null;
for (String key : regions.keySet()) {
final RPGRegionsRegion region = regions.get(key);
if (region.isWithinBounds(location) && (highest == null || region.getPriority() > highest.getPriority())) {
if ((highest == null || region.getPriority() > highest.getPriority()) && region.isWithinBounds(location)) {
highest = region;
}
}

View File

@@ -3,6 +3,8 @@ package net.islandearth.rpgregions.api.integrations.rpgregions.region;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import java.util.List;
public class CuboidRegion extends RPGRegionsRegion {
public CuboidRegion(final String name) {
@@ -11,9 +13,10 @@ public class CuboidRegion extends RPGRegionsRegion {
@Override
public boolean isWithinBounds(Location location) {
if (getPoints().size() < 2) return false;
Location first = getPoints().get(0);
Location second = getPoints().get(1);
final List<Location> points = getPoints();
if (points.size() < 2) return false;
Location first = points.get(0);
Location second = points.get(1);
final double x1 = first.getX();
final double x2 = second.getX();
final double y1 = first.getY();

View File

@@ -1,6 +1,5 @@
package net.islandearth.rpgregions.api.integrations.rpgregions.region;
import com.google.common.collect.ImmutableList;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -31,8 +30,8 @@ public abstract class RPGRegionsRegion {
this.priority = priority;
}
public ImmutableList<Location> getPoints() {
return ImmutableList.copyOf(points);
public List<Location> getPoints() {
return points;
}
public void addPoint(final Location location) {