mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Document area getters in PlotAreaManager, and replace y-value with z in the area contains check.
This commit is contained in:
parent
3ffa6cdb6c
commit
67e5d50e0d
@ -5,6 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -61,7 +62,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
int y;
|
||||
int z;
|
||||
int x;
|
||||
switch (areas.length) {
|
||||
case 1:
|
||||
@ -74,9 +75,9 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
|
||||
case 7:
|
||||
case 8:
|
||||
x = location.getX();
|
||||
y = location.getY();
|
||||
z = location.getZ();
|
||||
for (PlotArea area : areas) {
|
||||
if (area.contains(x, y)) {
|
||||
if (area.contains(x, z)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
@ -139,7 +140,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public PlotArea getPlotArea(Location location) {
|
||||
@Override public PlotArea getPlotArea(@NotNull Location location) {
|
||||
switch (this.plotAreas.length) {
|
||||
case 0:
|
||||
return null;
|
||||
@ -174,7 +175,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
|
||||
return null;
|
||||
}
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
switch (areas.length) {
|
||||
case 0:
|
||||
PlotArea a = areas[0];
|
||||
@ -187,9 +188,9 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
|
||||
case 7:
|
||||
case 8:
|
||||
x = location.getX();
|
||||
y = location.getY();
|
||||
z = location.getZ();
|
||||
for (PlotArea area : areas) {
|
||||
if (area.contains(x, y)) {
|
||||
if (area.contains(x, z)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,33 @@ package com.github.intellectualsites.plotsquared.plot.object.worlds;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface PlotAreaManager {
|
||||
|
||||
/**
|
||||
* Get the plot area for a particular location. This
|
||||
* method assumes that the caller already knows that
|
||||
* the location belongs to a plot area, in which
|
||||
* case it will return the appropriate plot area.
|
||||
*
|
||||
* If the location does not belong to a plot area,
|
||||
* it may still return an area.
|
||||
*
|
||||
* @param location The location
|
||||
* @return An applicable area, or null
|
||||
*/
|
||||
PlotArea getApplicablePlotArea(Location location);
|
||||
|
||||
PlotArea getPlotArea(Location location);
|
||||
/**
|
||||
* Get the plot area, if there is any, for the given
|
||||
* location. This may return null, if given location
|
||||
* does not belong to a plot area.
|
||||
*
|
||||
* @param location The location
|
||||
* @return The area, if found
|
||||
*/
|
||||
PlotArea getPlotArea(@NotNull Location location);
|
||||
|
||||
PlotArea getPlotArea(String world, String id);
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ArrayUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
||||
private final SinglePlotArea[] array;
|
||||
@ -82,7 +83,7 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
||||
return isWorld(world) || world.equals("*") ? area : super.getPlotArea(world, id);
|
||||
}
|
||||
|
||||
@Override public PlotArea getPlotArea(Location location) {
|
||||
@Override public PlotArea getPlotArea(@NotNull Location location) {
|
||||
PlotArea found = super.getPlotArea(location);
|
||||
if (found != null) {
|
||||
return found;
|
||||
|
Loading…
Reference in New Issue
Block a user