forked from clone/WorldGuardWrapper
getPoints returns no longer a Set but a List to maintains object order but removing dupicates (distinct)
This commit is contained in:
parent
900e0a5017
commit
70aa8186e2
|
@ -2,12 +2,13 @@ package org.codemc.worldguardwrapper.selection;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public interface IPolygonalSelection extends ISelection {
|
public interface IPolygonalSelection extends ISelection {
|
||||||
|
|
||||||
Set<Location> getPoints();
|
List<Location> getPoints();
|
||||||
|
|
||||||
int getMinimumY();
|
int getMinimumY();
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,8 @@ import org.bukkit.Location;
|
||||||
import org.codemc.worldguardwrapper.selection.ICuboidSelection;
|
import org.codemc.worldguardwrapper.selection.ICuboidSelection;
|
||||||
import org.codemc.worldguardwrapper.selection.IPolygonalSelection;
|
import org.codemc.worldguardwrapper.selection.IPolygonalSelection;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
import java.util.stream.Collectors;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
|
@ -54,8 +53,9 @@ public class SelectionUtilities {
|
||||||
public IPolygonalSelection createPolygonalSelection(Collection<Location> points, int minY, int maxY) {
|
public IPolygonalSelection createPolygonalSelection(Collection<Location> points, int minY, int maxY) {
|
||||||
return new IPolygonalSelection() {
|
return new IPolygonalSelection() {
|
||||||
@Override
|
@Override
|
||||||
public Set<Location> getPoints() {
|
public List<Location> getPoints() {
|
||||||
return new HashSet<>(points);
|
//recoreHosting -> set to list , maintains order but remove duplicates
|
||||||
|
return new ArrayList<>(points).stream().distinct().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -314,8 +314,9 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||||
} else if (selection instanceof Polygonal2DSelection) {
|
} else if (selection instanceof Polygonal2DSelection) {
|
||||||
return new IPolygonalSelection() {
|
return new IPolygonalSelection() {
|
||||||
@Override
|
@Override
|
||||||
public Set<Location> getPoints() {
|
public List<Location> getPoints() {
|
||||||
return ((Polygonal2DSelection) selection).getNativePoints().stream()
|
return ((Polygonal2DSelection) selection).getNativePoints().stream()
|
||||||
|
.distinct()
|
||||||
.map(vector -> new BlockVector(vector.toVector()))
|
.map(vector -> new BlockVector(vector.toVector()))
|
||||||
.map(vector ->
|
.map(vector ->
|
||||||
WorldGuardVectorUtilities.fromBlockVector(
|
WorldGuardVectorUtilities.fromBlockVector(
|
||||||
|
@ -323,7 +324,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||||
vector
|
vector
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,11 +46,12 @@ public class WrappedRegion implements IWrappedRegion {
|
||||||
} else if (handle instanceof ProtectedPolygonalRegion) {
|
} else if (handle instanceof ProtectedPolygonalRegion) {
|
||||||
return new IPolygonalSelection() {
|
return new IPolygonalSelection() {
|
||||||
@Override
|
@Override
|
||||||
public Set<Location> getPoints() {
|
public List<Location> getPoints() {
|
||||||
return handle.getPoints().stream()
|
return handle.getPoints().stream()
|
||||||
|
.distinct()
|
||||||
.map(vector -> new BlockVector(vector.toVector()))
|
.map(vector -> new BlockVector(vector.toVector()))
|
||||||
.map(vector -> WorldGuardVectorUtilities.fromBlockVector(world, vector))
|
.map(vector -> WorldGuardVectorUtilities.fromBlockVector(world, vector))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -381,8 +381,9 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||||
} else if (selection instanceof Polygonal2DSelection) {
|
} else if (selection instanceof Polygonal2DSelection) {
|
||||||
return new IPolygonalSelection() {
|
return new IPolygonalSelection() {
|
||||||
@Override
|
@Override
|
||||||
public Set<Location> getPoints() {
|
public List<Location> getPoints() {
|
||||||
return ((Polygonal2DSelection) selection).getNativePoints().stream()
|
return ((Polygonal2DSelection) selection).getNativePoints().stream()
|
||||||
|
.distinct()
|
||||||
.map(vector -> new BlockVector(vector.toVector()))
|
.map(vector -> new BlockVector(vector.toVector()))
|
||||||
.map(vector ->
|
.map(vector ->
|
||||||
WorldGuardVectorUtilities.fromBlockVector(
|
WorldGuardVectorUtilities.fromBlockVector(
|
||||||
|
@ -390,7 +391,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||||
vector
|
vector
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,11 +46,12 @@ public class WrappedRegion implements IWrappedRegion {
|
||||||
} else if (handle instanceof ProtectedPolygonalRegion) {
|
} else if (handle instanceof ProtectedPolygonalRegion) {
|
||||||
return new IPolygonalSelection() {
|
return new IPolygonalSelection() {
|
||||||
@Override
|
@Override
|
||||||
public Set<Location> getPoints() {
|
public List<Location> getPoints() {
|
||||||
return handle.getPoints().stream()
|
return handle.getPoints().stream()
|
||||||
|
.distinct()
|
||||||
.map(vector -> new BlockVector(vector.toVector()))
|
.map(vector -> new BlockVector(vector.toVector()))
|
||||||
.map(vector -> WorldGuardVectorUtilities.fromBlockVector(world, vector))
|
.map(vector -> WorldGuardVectorUtilities.fromBlockVector(world, vector))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -383,11 +383,12 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||||
} else if (selection instanceof Polygonal2DRegion) {
|
} else if (selection instanceof Polygonal2DRegion) {
|
||||||
return new IPolygonalSelection() {
|
return new IPolygonalSelection() {
|
||||||
@Override
|
@Override
|
||||||
public Set<Location> getPoints() {
|
public List<Location> getPoints() {
|
||||||
return ((Polygonal2DRegion) selection).getPoints().stream()
|
return ((Polygonal2DRegion) selection).getPoints().stream()
|
||||||
|
.distinct()
|
||||||
.map(BlockVector2::toBlockVector3)
|
.map(BlockVector2::toBlockVector3)
|
||||||
.map(vector -> BukkitAdapter.adapt(world, vector))
|
.map(vector -> BukkitAdapter.adapt(world, vector))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,11 +46,12 @@ public class WrappedRegion implements IWrappedRegion {
|
||||||
} else if (handle instanceof ProtectedPolygonalRegion) {
|
} else if (handle instanceof ProtectedPolygonalRegion) {
|
||||||
return new IPolygonalSelection() {
|
return new IPolygonalSelection() {
|
||||||
@Override
|
@Override
|
||||||
public Set<Location> getPoints() {
|
public List<Location> getPoints() {
|
||||||
return handle.getPoints().stream()
|
return handle.getPoints().stream()
|
||||||
|
.distinct()
|
||||||
.map(BlockVector2::toBlockVector3)
|
.map(BlockVector2::toBlockVector3)
|
||||||
.map(vector -> BukkitAdapter.adapt(world, vector))
|
.map(vector -> BukkitAdapter.adapt(world, vector))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user