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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user