9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2026-01-04 15:31:38 +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; RPGRegionsRegion highest = null;
for (String key : regions.keySet()) { for (String key : regions.keySet()) {
final RPGRegionsRegion region = regions.get(key); 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; highest = region;
} }
} }

View File

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

View File

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