mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-23 02:55:23 +01:00
Update to the new Vector system
This commit is contained in:
parent
0dc5781326
commit
91696533cf
@ -19,19 +19,19 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
abstract class AbstractBlacklistEvent implements BlacklistEvent {
|
||||
|
||||
@Nullable
|
||||
private final LocalPlayer player;
|
||||
private final Vector position;
|
||||
private final BlockVector3 position;
|
||||
private final Target target;
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ abstract class AbstractBlacklistEvent implements BlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
AbstractBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
AbstractBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
checkNotNull(position);
|
||||
checkNotNull(target);
|
||||
this.player = player;
|
||||
@ -61,7 +61,7 @@ public String getCauseName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getPosition() {
|
||||
public BlockVector3 getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -47,14 +47,14 @@ public interface BlacklistEvent {
|
||||
*
|
||||
* @return The position of this event
|
||||
*/
|
||||
Vector getPosition();
|
||||
BlockVector3 getPosition();
|
||||
|
||||
/**
|
||||
* Get the position that should be logged.
|
||||
*
|
||||
* @return The position that be logged.
|
||||
*/
|
||||
Vector getLoggedPosition();
|
||||
BlockVector3 getLoggedPosition();
|
||||
|
||||
/**
|
||||
* Get the item type.
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -34,7 +34,7 @@ abstract class BlockBlacklistEvent extends AbstractBlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
BlockBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
BlockBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
super(player, position, target);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public String getLoggerMessage() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getLoggedPosition() {
|
||||
public BlockVector3 getLoggedPosition() {
|
||||
return getPosition();
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -34,7 +34,7 @@ public final class BlockBreakBlacklistEvent extends BlockBlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
public BlockBreakBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
public BlockBreakBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
super(player, position, target);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -34,7 +34,7 @@ public final class BlockDispenseBlacklistEvent extends BlockBlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
public BlockDispenseBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
public BlockDispenseBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
super(player, position, target);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -34,7 +34,7 @@ public final class BlockInteractBlacklistEvent extends BlockBlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
public BlockInteractBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
public BlockInteractBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
super(player, position, target);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -34,7 +34,7 @@ public final class BlockPlaceBlacklistEvent extends BlockBlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
public BlockPlaceBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
public BlockPlaceBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
super(player, position, target);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -34,7 +34,7 @@ public final class ItemAcquireBlacklistEvent extends ItemBlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
public ItemAcquireBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
public ItemAcquireBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
super(player, position, target);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -34,7 +34,7 @@ abstract class ItemBlacklistEvent extends AbstractBlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
ItemBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
ItemBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
super(player, position, target);
|
||||
}
|
||||
|
||||
@ -44,8 +44,8 @@ public String getLoggerMessage() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getLoggedPosition() {
|
||||
return getPlayer() != null ? getPlayer().getLocation().toVector() : getPosition();
|
||||
public BlockVector3 getLoggedPosition() {
|
||||
return getPlayer() != null ? getPlayer().getLocation().toVector().toBlockPoint() : getPosition();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -34,7 +34,7 @@ public final class ItemDestroyWithBlacklistEvent extends ItemBlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
public ItemDestroyWithBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
public ItemDestroyWithBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
super(player, position, target);
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ public EventType getEventType() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getLoggedPosition() {
|
||||
public BlockVector3 getLoggedPosition() {
|
||||
// Use the block position instead
|
||||
return getPosition();
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -34,7 +34,7 @@ public final class ItemDropBlacklistEvent extends ItemBlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
public ItemDropBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
public ItemDropBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
super(player, position, target);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.event;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
|
||||
@ -34,7 +34,7 @@ public final class ItemUseBlacklistEvent extends ItemBlacklistEvent {
|
||||
* @param position The position the event occurred at
|
||||
* @param target The target of the event
|
||||
*/
|
||||
public ItemUseBlacklistEvent(@Nullable LocalPlayer player, Vector position, Target target) {
|
||||
public ItemUseBlacklistEvent(@Nullable LocalPlayer player, BlockVector3 position, Target target) {
|
||||
super(player, position, target);
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,11 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.logger;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.event.BlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.event.EventType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
@ -32,6 +31,8 @@
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DatabaseHandler implements LoggerHandler {
|
||||
|
||||
private final String dsn;
|
||||
@ -84,7 +85,7 @@ private Connection getConnection() throws SQLException {
|
||||
* @param item The item used
|
||||
* @param comment The comment associated with the event
|
||||
*/
|
||||
private void logEvent(EventType eventType, @Nullable LocalPlayer player, Vector pos, String item, String comment) {
|
||||
private void logEvent(EventType eventType, @Nullable LocalPlayer player, BlockVector3 pos, String item, String comment) {
|
||||
try {
|
||||
Connection conn = getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement(
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist.logger;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.event.BlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
@ -48,7 +48,7 @@ public class FileHandler implements LoggerHandler {
|
||||
private int cacheSize = 10;
|
||||
private String pathPattern;
|
||||
private String worldName;
|
||||
private TreeMap<String,LogFileWriter> writers = new TreeMap<String,LogFileWriter>();
|
||||
private TreeMap<String,LogFileWriter> writers = new TreeMap<>();
|
||||
|
||||
private final Logger logger;
|
||||
|
||||
@ -217,11 +217,11 @@ private void log(LocalPlayer player, String message, String comment) {
|
||||
* @param pos The position to get coordinates for
|
||||
* @return The position's coordinates in human-readable form
|
||||
*/
|
||||
private String getCoordinates(Vector pos) {
|
||||
private String getCoordinates(BlockVector3 pos) {
|
||||
return "@" + pos.getBlockX() + "," + pos.getBlockY() + "," + pos.getBlockZ();
|
||||
}
|
||||
|
||||
private void logEvent(BlacklistEvent event, String text, Target target, Vector pos, String comment) {
|
||||
private void logEvent(BlacklistEvent event, String text, Target target, BlockVector3 pos, String comment) {
|
||||
log(event.getPlayer(), "Tried to " + text + " " + target.getFriendlyName() + " " + getCoordinates(pos), comment);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public abstract class SignChestProtection implements ChestProtection {
|
||||
public abstract Boolean isProtectedSign(Location block, LocalPlayer player);
|
||||
|
||||
public boolean isProtected(Location location, LocalPlayer player) {
|
||||
com.sk89q.worldedit.world.block.BlockState blockState = location.getExtent().getBlock(location.toVector());
|
||||
com.sk89q.worldedit.world.block.BlockState blockState = location.getExtent().getBlock(location.toVector().toBlockPoint());
|
||||
if (isChest(blockState.getBlockType())) {
|
||||
return isProtectedSignAround(location.setY(location.getY() - 1), player);
|
||||
} else if (blockState.getBlockType() == BlockTypes.SIGN) {
|
||||
@ -77,7 +77,7 @@ private boolean isProtectedSignAround(Location searchBlock, LocalPlayer player)
|
||||
}
|
||||
|
||||
private Boolean isProtectedSignAndChest(Location block, LocalPlayer player) {
|
||||
if (!isChest(block.getExtent().getBlock(block.setY(block.getY() + 1).toVector()).getBlockType())) {
|
||||
if (!isChest(block.getExtent().getBlock(block.setY(block.getY() + 1).toVector().toBlockPoint()).getBlockType())) {
|
||||
return null;
|
||||
}
|
||||
return isProtectedSign(block, player);
|
||||
|
@ -144,7 +144,7 @@ public Set<ProtectedRegion> getRegions() {
|
||||
if (regionSet != null) {
|
||||
return regionSet;
|
||||
}
|
||||
regionSet = Collections.unmodifiableSet(new HashSet<ProtectedRegion>(applicable));
|
||||
regionSet = Collections.unmodifiableSet(new HashSet<>(applicable));
|
||||
return regionSet;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.flags;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
@ -38,12 +38,12 @@ private static World findWorld(String worldName) {
|
||||
return WorldGuard.getInstance().getPlatform().getWorldByName(worldName);
|
||||
}
|
||||
|
||||
public LazyLocation(String worldName, Vector position, float yaw, float pitch) {
|
||||
public LazyLocation(String worldName, Vector3 position, float yaw, float pitch) {
|
||||
super(findWorld(worldName), position, yaw, pitch);
|
||||
this.worldName = worldName;
|
||||
}
|
||||
|
||||
public LazyLocation(String worldName, Vector position) {
|
||||
public LazyLocation(String worldName, Vector3 position) {
|
||||
super(findWorld(worldName), position);
|
||||
this.worldName = worldName;
|
||||
}
|
||||
@ -56,11 +56,11 @@ public LazyLocation setAngles(float yaw, float pitch) {
|
||||
return new LazyLocation(worldName, toVector(), yaw, pitch);
|
||||
}
|
||||
|
||||
public LazyLocation setPosition(Vector position) {
|
||||
public LazyLocation setPosition(Vector3 position) {
|
||||
return new LazyLocation(worldName, position, getYaw(), getPitch());
|
||||
}
|
||||
|
||||
public LazyLocation add(Vector other) {
|
||||
public LazyLocation add(Vector3 other) {
|
||||
return this.setPosition(toVector().add(other));
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.flags;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
@ -61,7 +61,7 @@ public Location parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
final float yaw = split.length < 4 ? 0 : Float.parseFloat(split[3]);
|
||||
final float pitch = split.length < 5 ? 0 : Float.parseFloat(split[4]);
|
||||
|
||||
loc = new LazyLocation(world.getName(), new Vector(x, y, z), yaw, pitch);
|
||||
loc = new LazyLocation(world.getName(), Vector3.at(x, y, z), yaw, pitch);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
@ -71,7 +71,7 @@ public Location parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
if (obj instanceof ProtectedRegion) {
|
||||
ProtectedRegion rg = (ProtectedRegion) obj;
|
||||
if (WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(player.getWorld()).boundedLocationFlags) {
|
||||
if (!rg.contains(loc.toVector())) {
|
||||
if (!rg.contains(loc.toVector().toBlockPoint())) {
|
||||
if (new RegionPermissionModel(player).mayOverrideLocationFlagBounds(rg)) {
|
||||
player.printDebug("WARNING: Flag location is outside of region.");
|
||||
} else {
|
||||
@ -112,7 +112,7 @@ public Location unmarshal(Object o) {
|
||||
Object rawPitch = map.get("pitch");
|
||||
if (rawPitch == null) return null;
|
||||
|
||||
Vector position = new Vector(toNumber(rawX), toNumber(rawY), toNumber(rawZ));
|
||||
Vector3 position = Vector3.at(toNumber(rawX), toNumber(rawY), toNumber(rawZ));
|
||||
float yaw = (float) toNumber(rawYaw);
|
||||
float pitch = (float) toNumber(rawPitch);
|
||||
|
||||
@ -124,7 +124,7 @@ public Location unmarshal(Object o) {
|
||||
|
||||
@Override
|
||||
public Object marshal(Location o) {
|
||||
Vector position = o.toVector();
|
||||
Vector3 position = o.toVector();
|
||||
Map<String, Object> vec = new HashMap<>();
|
||||
if (o instanceof LazyLocation) {
|
||||
vec.put("world", ((LazyLocation) o).getWorldName());
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.flags;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -27,7 +27,7 @@
|
||||
/**
|
||||
* Stores a vector.
|
||||
*/
|
||||
public class VectorFlag extends Flag<Vector> {
|
||||
public class VectorFlag extends Flag<Vector3> {
|
||||
|
||||
public VectorFlag(String name, RegionGroup defaultGroup) {
|
||||
super(name, defaultGroup);
|
||||
@ -38,7 +38,7 @@ public VectorFlag(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
public Vector3 parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
String input = context.getUserInput();
|
||||
|
||||
if ("here".equalsIgnoreCase(input)) {
|
||||
@ -47,7 +47,7 @@ public Vector parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
String[] split = input.split(",");
|
||||
if (split.length == 3) {
|
||||
try {
|
||||
return new Vector(
|
||||
return Vector3.at(
|
||||
Double.parseDouble(split[0]),
|
||||
Double.parseDouble(split[1]),
|
||||
Double.parseDouble(split[2])
|
||||
@ -61,7 +61,7 @@ public Vector parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector unmarshal(Object o) {
|
||||
public Vector3 unmarshal(Object o) {
|
||||
if (o instanceof Map<?, ?>) {
|
||||
Map<?, ?> map = (Map<?, ?>) o;
|
||||
|
||||
@ -73,14 +73,14 @@ public Vector unmarshal(Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Vector(toNumber(rawX), toNumber(rawY), toNumber(rawZ));
|
||||
return Vector3.at(toNumber(rawX), toNumber(rawY), toNumber(rawZ));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object marshal(Vector o) {
|
||||
public Object marshal(Vector3 o) {
|
||||
Map<String, Object> vec = new HashMap<>();
|
||||
vec.put("x", o.getX());
|
||||
vec.put("y", o.getY());
|
||||
|
@ -22,8 +22,8 @@
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.RegionResultSet;
|
||||
@ -74,7 +74,7 @@ public RegionManager(RegionDatabase store, Supplier<? extends ConcurrentRegionIn
|
||||
checkNotNull(flagRegistry, "flagRegistry");
|
||||
|
||||
this.store = store;
|
||||
this.indexFactory = indexFactory::get;
|
||||
this.indexFactory = indexFactory;
|
||||
this.index = indexFactory.get();
|
||||
this.flagRegistry = flagRegistry;
|
||||
}
|
||||
@ -154,7 +154,7 @@ public boolean saveChanges() throws StorageException {
|
||||
*
|
||||
* @param position the position
|
||||
*/
|
||||
public void loadChunk(Vector2D position) {
|
||||
public void loadChunk(BlockVector2 position) {
|
||||
index.bias(position);
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ public void loadChunk(Vector2D position) {
|
||||
*
|
||||
* @param positions a collection of positions
|
||||
*/
|
||||
public void loadChunks(Collection<Vector2D> positions) {
|
||||
public void loadChunks(Collection<BlockVector2> positions) {
|
||||
index.biasAll(positions);
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ public void loadChunks(Collection<Vector2D> positions) {
|
||||
*
|
||||
* @param position the position
|
||||
*/
|
||||
public void unloadChunk(Vector2D position) {
|
||||
public void unloadChunk(BlockVector2 position) {
|
||||
index.forget(position);
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ public Set<ProtectedRegion> removeRegion(String id, RemovalStrategy strategy) {
|
||||
* @param position the position
|
||||
* @return the query object
|
||||
*/
|
||||
public ApplicableRegionSet getApplicableRegions(Vector position) {
|
||||
public ApplicableRegionSet getApplicableRegions(BlockVector3 position) {
|
||||
checkNotNull(position);
|
||||
|
||||
Set<ProtectedRegion> regions = Sets.newHashSet();
|
||||
@ -349,7 +349,7 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion region) {
|
||||
* @param position the position
|
||||
* @return a list of names
|
||||
*/
|
||||
public List<String> getApplicableRegionsIDs(Vector position) {
|
||||
public List<String> getApplicableRegionsIDs(BlockVector3 position) {
|
||||
checkNotNull(position);
|
||||
|
||||
final List<String> names = new ArrayList<>();
|
||||
|
@ -19,21 +19,21 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.managers.index;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.sk89q.worldguard.util.concurrent.EvenMoreExecutors;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.protection.managers.RegionDifference;
|
||||
import com.sk89q.worldguard.protection.managers.RemovalStrategy;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.util.RegionCollectionConsumer;
|
||||
import com.sk89q.worldguard.util.collect.LongHashTable;
|
||||
import com.sk89q.worldguard.util.concurrent.EvenMoreExecutors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -41,9 +41,10 @@
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Maintains a hash table for each chunk containing a list of regions that
|
||||
@ -52,7 +53,7 @@
|
||||
public class ChunkHashTable implements ConcurrentRegionIndex {
|
||||
|
||||
private ListeningExecutorService executor = createExecutor();
|
||||
private LongHashTable<ChunkState> states = new LongHashTable<ChunkState>();
|
||||
private LongHashTable<ChunkState> states = new LongHashTable<>();
|
||||
private final RegionIndex index;
|
||||
private final Object lock = new Object();
|
||||
@Nullable
|
||||
@ -86,7 +87,7 @@ private ListeningExecutorService createExecutor() {
|
||||
* @return a chunk state object, or {@code null} (only if {@code create} is false)
|
||||
*/
|
||||
@Nullable
|
||||
private ChunkState get(Vector2D position, boolean create) {
|
||||
private ChunkState get(BlockVector2 position, boolean create) {
|
||||
ChunkState state;
|
||||
synchronized (lock) {
|
||||
state = states.get(position.getBlockX(), position.getBlockZ());
|
||||
@ -106,7 +107,7 @@ private ChunkState get(Vector2D position, boolean create) {
|
||||
* @param position the position
|
||||
* @return a state
|
||||
*/
|
||||
private ChunkState getOrCreate(Vector2D position) {
|
||||
private ChunkState getOrCreate(BlockVector2 position) {
|
||||
return get(position, true);
|
||||
}
|
||||
|
||||
@ -119,12 +120,12 @@ private void rebuild() {
|
||||
LongHashTable<ChunkState> previousStates = states;
|
||||
|
||||
previousExecutor.shutdownNow();
|
||||
states = new LongHashTable<ChunkState>();
|
||||
states = new LongHashTable<>();
|
||||
executor = createExecutor();
|
||||
|
||||
List<Vector2D> positions = new ArrayList<Vector2D>();
|
||||
List<BlockVector2> positions = new ArrayList<>();
|
||||
for (ChunkState state : previousStates.values()) {
|
||||
Vector2D position = state.getPosition();
|
||||
BlockVector2 position = state.getPosition();
|
||||
positions.add(position);
|
||||
states.put(position.getBlockX(), position.getBlockZ(), new ChunkState(position));
|
||||
}
|
||||
@ -157,22 +158,22 @@ public boolean awaitCompletion(long timeout, TimeUnit unit) throws InterruptedEx
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bias(Vector2D chunkPosition) {
|
||||
public void bias(BlockVector2 chunkPosition) {
|
||||
checkNotNull(chunkPosition);
|
||||
getOrCreate(chunkPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void biasAll(Collection<Vector2D> chunkPositions) {
|
||||
public void biasAll(Collection<BlockVector2> chunkPositions) {
|
||||
synchronized (lock) {
|
||||
for (Vector2D position : chunkPositions) {
|
||||
for (BlockVector2 position : chunkPositions) {
|
||||
bias(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forget(Vector2D chunkPosition) {
|
||||
public void forget(BlockVector2 chunkPosition) {
|
||||
checkNotNull(chunkPosition);
|
||||
synchronized (lock) {
|
||||
states.remove(chunkPosition.getBlockX(), chunkPosition.getBlockZ());
|
||||
@ -187,7 +188,7 @@ public void forget(Vector2D chunkPosition) {
|
||||
public void forgetAll() {
|
||||
synchronized (lock) {
|
||||
executor.shutdownNow();
|
||||
states = new LongHashTable<ChunkState>();
|
||||
states = new LongHashTable<>();
|
||||
executor = createExecutor();
|
||||
lastState = null;
|
||||
}
|
||||
@ -229,7 +230,7 @@ public void apply(Predicate<ProtectedRegion> consumer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyContaining(Vector position, Predicate<ProtectedRegion> consumer) {
|
||||
public void applyContaining(BlockVector3 position, Predicate<ProtectedRegion> consumer) {
|
||||
checkNotNull(position);
|
||||
checkNotNull(consumer);
|
||||
|
||||
@ -238,13 +239,13 @@ public void applyContaining(Vector position, Predicate<ProtectedRegion> consumer
|
||||
int chunkZ = position.getBlockZ() >> 4;
|
||||
|
||||
if (state == null || state.getPosition().getBlockX() != chunkX || state.getPosition().getBlockZ() != chunkZ) {
|
||||
state = get(new Vector2D(chunkX, chunkZ), false);
|
||||
state = get(BlockVector2.at(chunkX, chunkZ), false);
|
||||
}
|
||||
|
||||
if (state != null && state.isLoaded()) {
|
||||
for (ProtectedRegion region : state.getRegions()) {
|
||||
if (region.contains(position)) {
|
||||
consumer.apply(region);
|
||||
consumer.test(region);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -291,13 +292,13 @@ public void setDirty(boolean dirty) {
|
||||
* A task to enumerate the regions for a list of provided chunks.
|
||||
*/
|
||||
private class EnumerateRegions implements Runnable {
|
||||
private final List<Vector2D> positions;
|
||||
private final List<BlockVector2> positions;
|
||||
|
||||
private EnumerateRegions(Vector2D position) {
|
||||
private EnumerateRegions(BlockVector2 position) {
|
||||
this(Arrays.asList(checkNotNull(position)));
|
||||
}
|
||||
|
||||
private EnumerateRegions(List<Vector2D> positions) {
|
||||
private EnumerateRegions(List<BlockVector2> positions) {
|
||||
checkNotNull(positions);
|
||||
checkArgument(!positions.isEmpty(), "List of positions can't be empty");
|
||||
this.positions = positions;
|
||||
@ -305,15 +306,15 @@ private EnumerateRegions(List<Vector2D> positions) {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Vector2D position : positions) {
|
||||
for (BlockVector2 position : positions) {
|
||||
ChunkState state = get(position, false);
|
||||
|
||||
if (state != null) {
|
||||
List<ProtectedRegion> regions = new ArrayList<ProtectedRegion>();
|
||||
List<ProtectedRegion> regions = new ArrayList<>();
|
||||
ProtectedRegion chunkRegion = new ProtectedCuboidRegion(
|
||||
"_",
|
||||
position.multiply(16).toVector(0).toBlockVector(),
|
||||
position.add(1, 1).multiply(16).toVector(Integer.MAX_VALUE).toBlockVector());
|
||||
position.multiply(16).toBlockVector3(0),
|
||||
position.add(1, 1).multiply(16).toBlockVector3(Integer.MAX_VALUE));
|
||||
index.applyIntersecting(chunkRegion, new RegionCollectionConsumer(regions, false));
|
||||
Collections.sort(regions);
|
||||
|
||||
@ -331,15 +332,15 @@ public void run() {
|
||||
* Stores a cache of region data for a chunk.
|
||||
*/
|
||||
private class ChunkState {
|
||||
private final Vector2D position;
|
||||
private final BlockVector2 position;
|
||||
private boolean loaded = false;
|
||||
private List<ProtectedRegion> regions = Collections.emptyList();
|
||||
|
||||
private ChunkState(Vector2D position) {
|
||||
private ChunkState(BlockVector2 position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public Vector2D getPosition() {
|
||||
public BlockVector2 getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
@ -19,15 +19,15 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.managers.index;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldguard.util.Normal.normalize;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.protection.managers.RegionDifference;
|
||||
import com.sk89q.worldguard.protection.managers.RemovalStrategy;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@ -35,9 +35,10 @@
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldguard.util.Normal.normalize;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An index that stores regions in a hash map, which allows for fast lookup
|
||||
@ -48,8 +49,8 @@
|
||||
*/
|
||||
public class HashMapIndex extends AbstractRegionIndex implements ConcurrentRegionIndex {
|
||||
|
||||
private final ConcurrentMap<String, ProtectedRegion> regions = new ConcurrentHashMap<String, ProtectedRegion>();
|
||||
private Set<ProtectedRegion> removed = new HashSet<ProtectedRegion>();
|
||||
private final ConcurrentMap<String, ProtectedRegion> regions = new ConcurrentHashMap<>();
|
||||
private Set<ProtectedRegion> removed = new HashSet<>();
|
||||
private final Object lock = new Object();
|
||||
|
||||
/**
|
||||
@ -104,17 +105,17 @@ public void addAll(Collection<ProtectedRegion> regions) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bias(Vector2D chunkPosition) {
|
||||
public void bias(BlockVector2 chunkPosition) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void biasAll(Collection<Vector2D> chunkPositions) {
|
||||
public void biasAll(Collection<BlockVector2> chunkPositions) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forget(Vector2D chunkPosition) {
|
||||
public void forget(BlockVector2 chunkPosition) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
@ -137,7 +138,7 @@ public Set<ProtectedRegion> remove(String id, RemovalStrategy strategy) {
|
||||
checkNotNull(id);
|
||||
checkNotNull(strategy);
|
||||
|
||||
Set<ProtectedRegion> removedSet = new HashSet<ProtectedRegion>();
|
||||
Set<ProtectedRegion> removedSet = new HashSet<>();
|
||||
|
||||
synchronized (lock) {
|
||||
ProtectedRegion removed = regions.remove(normalize(id));
|
||||
@ -187,26 +188,21 @@ public ProtectedRegion get(String id) {
|
||||
@Override
|
||||
public void apply(Predicate<ProtectedRegion> consumer) {
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
if (!consumer.apply(region)) {
|
||||
if (!consumer.test(region)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyContaining(final Vector position, final Predicate<ProtectedRegion> consumer) {
|
||||
apply(new Predicate<ProtectedRegion>() {
|
||||
@Override
|
||||
public boolean apply(ProtectedRegion region) {
|
||||
return !region.contains(position) || consumer.apply(region);
|
||||
}
|
||||
});
|
||||
public void applyContaining(final BlockVector3 position, final Predicate<ProtectedRegion> consumer) {
|
||||
apply(region -> !region.contains(position) || consumer.test(region));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyIntersecting(ProtectedRegion region, Predicate<ProtectedRegion> consumer) {
|
||||
for (ProtectedRegion found : region.getIntersectingRegions(regions.values())) {
|
||||
if (!consumer.apply(found)) {
|
||||
if (!consumer.test(found)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -220,7 +216,7 @@ public int size() {
|
||||
@Override
|
||||
public RegionDifference getAndClearDifference() {
|
||||
synchronized (lock) {
|
||||
Set<ProtectedRegion> changed = new HashSet<ProtectedRegion>();
|
||||
Set<ProtectedRegion> changed = new HashSet<>();
|
||||
Set<ProtectedRegion> removed = this.removed;
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
@ -230,7 +226,7 @@ public RegionDifference getAndClearDifference() {
|
||||
}
|
||||
}
|
||||
|
||||
this.removed = new HashSet<ProtectedRegion>();
|
||||
this.removed = new HashSet<>();
|
||||
|
||||
return new RegionDifference(changed, removed);
|
||||
}
|
||||
|
@ -19,9 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.managers.index;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegionMBRConverter;
|
||||
import org.khelekore.prtree.MBR;
|
||||
@ -32,13 +30,15 @@
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* An implementation of an index that uses {@link HashMapIndex} for queries
|
||||
* by region name and a priority R-tree for spatial queries.
|
||||
*
|
||||
* <p>At the moment, the R-tree is only utilized for the
|
||||
* {@link #applyContaining(Vector, Predicate)} method, and the underlying
|
||||
* {@link #applyContaining(BlockVector3, Predicate)} method, and the underlying
|
||||
* hash map-based index is used for the other spatial queries. In addition,
|
||||
* every modification to the index requires the entire R-tree to be rebuilt,
|
||||
* although this operation is reasonably quick.</p>
|
||||
@ -55,29 +55,26 @@ public class PriorityRTreeIndex extends HashMapIndex {
|
||||
private PRTree<ProtectedRegion> tree;
|
||||
|
||||
public PriorityRTreeIndex() {
|
||||
tree = new PRTree<ProtectedRegion>(CONVERTER, BRANCH_FACTOR);
|
||||
tree.load(Collections.<ProtectedRegion>emptyList());
|
||||
tree = new PRTree<>(CONVERTER, BRANCH_FACTOR);
|
||||
tree.load(Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rebuildIndex() {
|
||||
PRTree<ProtectedRegion> newTree = new PRTree<ProtectedRegion>(CONVERTER, BRANCH_FACTOR);
|
||||
PRTree<ProtectedRegion> newTree = new PRTree<>(CONVERTER, BRANCH_FACTOR);
|
||||
newTree.load(values());
|
||||
this.tree = newTree;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyContaining(Vector position, Predicate<ProtectedRegion> consumer) {
|
||||
// Floor the vector to ensure we get accurate points
|
||||
position = position.floor();
|
||||
|
||||
Set<ProtectedRegion> seen = new HashSet<ProtectedRegion>();
|
||||
public void applyContaining(BlockVector3 position, Predicate<ProtectedRegion> consumer) {
|
||||
Set<ProtectedRegion> seen = new HashSet<>();
|
||||
MBR pointMBR = new SimpleMBR(position.getX(), position.getX(), position.getY(), position.getY(), position.getZ(), position.getZ());
|
||||
|
||||
for (ProtectedRegion region : tree.find(pointMBR)) {
|
||||
if (region.contains(position) && !seen.contains(region)) {
|
||||
seen.add(region);
|
||||
if (!consumer.apply(region)) {
|
||||
if (!consumer.test(region)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -86,10 +83,10 @@ public void applyContaining(Vector position, Predicate<ProtectedRegion> consumer
|
||||
|
||||
@Override
|
||||
public void applyIntersecting(ProtectedRegion region, Predicate<ProtectedRegion> consumer) {
|
||||
Vector min = region.getMinimumPoint().floor();
|
||||
Vector max = region.getMaximumPoint().ceil();
|
||||
BlockVector3 min = region.getMinimumPoint().floor();
|
||||
BlockVector3 max = region.getMaximumPoint().ceil();
|
||||
|
||||
Set<ProtectedRegion> candidates = new HashSet<ProtectedRegion>();
|
||||
Set<ProtectedRegion> candidates = new HashSet<>();
|
||||
MBR pointMBR = new SimpleMBR(min.getX(), max.getX(), min.getY(), max.getY(), min.getZ(), max.getZ());
|
||||
|
||||
for (ProtectedRegion found : tree.find(pointMBR)) {
|
||||
@ -97,7 +94,7 @@ public void applyIntersecting(ProtectedRegion region, Predicate<ProtectedRegion>
|
||||
}
|
||||
|
||||
for (ProtectedRegion found : region.getIntersectingRegions(candidates)) {
|
||||
if (!consumer.apply(found)) {
|
||||
if (!consumer.test(found)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -19,18 +19,19 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.managers.index;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.protection.managers.RegionDifference;
|
||||
import com.sk89q.worldguard.protection.managers.RemovalStrategy;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.util.ChangeTracked;
|
||||
import com.sk89q.worldguard.util.Normal;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An index of regions to allow for fast lookups of regions by their ID and
|
||||
@ -47,7 +48,7 @@ public interface RegionIndex extends ChangeTracked {
|
||||
*
|
||||
* @param chunkPosition the chunk position
|
||||
*/
|
||||
void bias(Vector2D chunkPosition);
|
||||
void bias(BlockVector2 chunkPosition);
|
||||
|
||||
/**
|
||||
* Bias the given chunk for faster lookups (put it in a hash table, etc.).
|
||||
@ -56,18 +57,18 @@ public interface RegionIndex extends ChangeTracked {
|
||||
*
|
||||
* @param chunkPosition the chunk position
|
||||
*/
|
||||
void biasAll(Collection<Vector2D> chunkPosition);
|
||||
void biasAll(Collection<BlockVector2> chunkPosition);
|
||||
|
||||
/**
|
||||
* No longer bias the given chunk for faster lookup.
|
||||
*
|
||||
* @param chunkPosition the chunk position
|
||||
*/
|
||||
void forget(Vector2D chunkPosition);
|
||||
void forget(BlockVector2 chunkPosition);
|
||||
|
||||
/**
|
||||
* Clearly all extra cache data created by any calls to
|
||||
* {@link #bias(Vector2D)}.
|
||||
* {@link #bias(BlockVector2)}.
|
||||
*/
|
||||
void forgetAll();
|
||||
|
||||
@ -134,7 +135,7 @@ public interface RegionIndex extends ChangeTracked {
|
||||
* @param position the position
|
||||
* @param consumer a predicate that returns true to continue iterating
|
||||
*/
|
||||
void applyContaining(Vector position, Predicate<ProtectedRegion> consumer);
|
||||
void applyContaining(BlockVector3 position, Predicate<ProtectedRegion> consumer);
|
||||
|
||||
/**
|
||||
* Apply the given predicate to all regions that intersect the given
|
||||
|
@ -50,8 +50,8 @@ public class UUIDMigration extends AbstractMigration {
|
||||
private final Timer timer = new Timer();
|
||||
private final ProfileService profileService;
|
||||
private final FlagRegistry flagRegistry;
|
||||
private final ConcurrentMap<String, UUID> resolvedNames = new ConcurrentHashMap<String, UUID>();
|
||||
private final Set<String> unresolvedNames = new HashSet<String>();
|
||||
private final ConcurrentMap<String, UUID> resolvedNames = new ConcurrentHashMap<>();
|
||||
private final Set<String> unresolvedNames = new HashSet<>();
|
||||
private boolean keepUnresolvedNames = true;
|
||||
|
||||
/**
|
||||
@ -106,7 +106,7 @@ private boolean migrate(Collection<ProtectedRegion> regions) throws MigrationExc
|
||||
|
||||
// Don't lookup names that we already looked up for previous
|
||||
// worlds -- note: all names are lowercase in these collections
|
||||
Set<String> lookupNames = new HashSet<String>(names);
|
||||
Set<String> lookupNames = new HashSet<>(names);
|
||||
lookupNames.removeAll(resolvedNames.keySet());
|
||||
|
||||
// Ask Mojang for names
|
||||
@ -161,7 +161,7 @@ protected void postMigration() {
|
||||
* @return a set of names
|
||||
*/
|
||||
private static Set<String> getNames(Collection<ProtectedRegion> regions) {
|
||||
Set<String> names = new HashSet<String>();
|
||||
Set<String> names = new HashSet<>();
|
||||
for (ProtectedRegion region : regions) {
|
||||
// Names are already lower case
|
||||
names.addAll(region.getOwners().getPlayers());
|
||||
|
@ -19,12 +19,14 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.managers.storage.file;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLFormat;
|
||||
import com.sk89q.util.yaml.YAMLNode;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.FlagUtil;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
@ -46,12 +48,18 @@
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* A store that persists regions in a YAML-encoded file.
|
||||
*/
|
||||
@ -135,15 +143,15 @@ public Set<ProtectedRegion> loadAll(FlagRegistry flagRegistry) throws StorageExc
|
||||
"Here is what the region data looks like:\n\n" + toYamlOutput(entry.getValue().getMap()) + "\n");
|
||||
continue;
|
||||
} else if (type.equals("cuboid")) {
|
||||
Vector pt1 = checkNotNull(node.getVector("min"));
|
||||
Vector pt2 = checkNotNull(node.getVector("max"));
|
||||
BlockVector min = Vector.getMinimum(pt1, pt2).toBlockVector();
|
||||
BlockVector max = Vector.getMaximum(pt1, pt2).toBlockVector();
|
||||
Vector3 pt1 = checkNotNull(node.getVector("min"));
|
||||
Vector3 pt2 = checkNotNull(node.getVector("max"));
|
||||
BlockVector3 min = pt1.getMinimum(pt2).toBlockPoint();
|
||||
BlockVector3 max = pt1.getMaximum(pt2).toBlockPoint();
|
||||
region = new ProtectedCuboidRegion(id, min, max);
|
||||
} else if (type.equals("poly2d")) {
|
||||
Integer minY = checkNotNull(node.getInt("min-y"));
|
||||
Integer maxY = checkNotNull(node.getInt("max-y"));
|
||||
List<BlockVector2D> points = node.getBlockVector2dList("points", null);
|
||||
List<BlockVector2> points = node.getBlockVector2List("points", null);
|
||||
region = new ProtectedPolygonalRegion(id, points, minY, maxY);
|
||||
} else if (type.equals("global")) {
|
||||
region = new GlobalProtectedRegion(id);
|
||||
@ -208,7 +216,7 @@ public void saveAll(Set<ProtectedRegion> regions) throws StorageException {
|
||||
node.setProperty("max-y", poly.getMaximumPoint().getBlockY());
|
||||
|
||||
List<Map<String, Object>> points = new ArrayList<>();
|
||||
for (BlockVector2D point : poly.getPoints()) {
|
||||
for (BlockVector2 point : poly.getPoints()) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("x", point.getBlockX());
|
||||
data.put("z", point.getBlockZ());
|
||||
@ -248,7 +256,6 @@ public void saveChanges(RegionDifference difference) throws DifferenceSaveExcept
|
||||
throw new DifferenceSaveException("Not supported");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private DefaultDomain parseDomain(YAMLNode node) {
|
||||
if (node == null) {
|
||||
return new DefaultDomain();
|
||||
@ -292,7 +299,6 @@ private void setFlags(FlagRegistry flagRegistry, ProtectedRegion region, YAMLNod
|
||||
private Map<String, Object> getDomainData(DefaultDomain domain) {
|
||||
Map<String, Object> domainData = new HashMap<>();
|
||||
|
||||
//noinspection deprecation
|
||||
setDomainData(domainData, "players", domain.getPlayers());
|
||||
setDomainData(domainData, "unique-ids", domain.getUniqueIds());
|
||||
setDomainData(domainData, "groups", domain.getGroups());
|
||||
|
@ -19,13 +19,14 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.managers.storage.sql;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Table;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import com.sk89q.worldguard.protection.managers.storage.RegionDatabaseUtils;
|
||||
@ -52,8 +53,6 @@
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
class DataLoader {
|
||||
|
||||
private static final Logger log = Logger.getLogger(DataLoader.class.getCanonicalName());
|
||||
@ -63,8 +62,8 @@ class DataLoader {
|
||||
final int worldId;
|
||||
final FlagRegistry flagRegistry;
|
||||
|
||||
private final Map<String, ProtectedRegion> loaded = new HashMap<String, ProtectedRegion>();
|
||||
private final Map<ProtectedRegion, String> parentSets = new HashMap<ProtectedRegion, String>();
|
||||
private final Map<String, ProtectedRegion> loaded = new HashMap<>();
|
||||
private final Map<ProtectedRegion, String> parentSets = new HashMap<>();
|
||||
private final Yaml yaml = SQLRegionDatabase.createYaml();
|
||||
|
||||
DataLoader(SQLRegionDatabase regionStore, Connection conn, FlagRegistry flagRegistry) throws SQLException {
|
||||
@ -87,7 +86,7 @@ public Set<ProtectedRegion> load() throws SQLException {
|
||||
|
||||
RegionDatabaseUtils.relinkParents(loaded, parentSets);
|
||||
|
||||
return new HashSet<ProtectedRegion>(loaded.values());
|
||||
return new HashSet<>(loaded.values());
|
||||
}
|
||||
|
||||
private void loadCuboids() throws SQLException {
|
||||
@ -107,11 +106,11 @@ private void loadCuboids() throws SQLException {
|
||||
ResultSet rs = closer.register(stmt.executeQuery());
|
||||
|
||||
while (rs.next()) {
|
||||
Vector pt1 = new Vector(rs.getInt("min_x"), rs.getInt("min_y"), rs.getInt("min_z"));
|
||||
Vector pt2 = new Vector(rs.getInt("max_x"), rs.getInt("max_y"), rs.getInt("max_z"));
|
||||
BlockVector3 pt1 = BlockVector3.at(rs.getInt("min_x"), rs.getInt("min_y"), rs.getInt("min_z"));
|
||||
BlockVector3 pt2 = BlockVector3.at(rs.getInt("max_x"), rs.getInt("max_y"), rs.getInt("max_z"));
|
||||
|
||||
BlockVector min = Vector.getMinimum(pt1, pt2).toBlockVector();
|
||||
BlockVector max = Vector.getMaximum(pt1, pt2).toBlockVector();
|
||||
BlockVector3 min = pt1.getMinimum(pt2);
|
||||
BlockVector3 max = pt1.getMaximum(pt2);
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(rs.getString("id"), min, max);
|
||||
|
||||
region.setPriority(rs.getInt("priority"));
|
||||
@ -158,7 +157,7 @@ private void loadGlobals() throws SQLException {
|
||||
}
|
||||
|
||||
private void loadPolygons() throws SQLException {
|
||||
ListMultimap<String, BlockVector2D> pointsCache = ArrayListMultimap.create();
|
||||
ListMultimap<String, BlockVector2> pointsCache = ArrayListMultimap.create();
|
||||
|
||||
// First get all the vertices and store them in memory
|
||||
Closer closer = Closer.create();
|
||||
@ -171,7 +170,7 @@ private void loadPolygons() throws SQLException {
|
||||
ResultSet rs = closer.register(stmt.executeQuery());
|
||||
|
||||
while (rs.next()) {
|
||||
pointsCache.put(rs.getString("region_id"), new BlockVector2D(rs.getInt("x"), rs.getInt("z")));
|
||||
pointsCache.put(rs.getString("region_id"), BlockVector2.at(rs.getInt("x"), rs.getInt("z")));
|
||||
}
|
||||
} finally {
|
||||
closer.closeQuietly();
|
||||
@ -196,7 +195,7 @@ private void loadPolygons() throws SQLException {
|
||||
String id = rs.getString("id");
|
||||
|
||||
// Get the points from the cache
|
||||
List<BlockVector2D> points = pointsCache.get(id);
|
||||
List<BlockVector2> points = pointsCache.get(id);
|
||||
|
||||
if (points.size() < 3) {
|
||||
log.log(Level.WARNING, "Invalid polygonal region '" + id + "': region has " + points.size() + " point(s) (less than the required 3). Skipping this region.");
|
||||
|
@ -20,8 +20,8 @@
|
||||
package com.sk89q.worldguard.protection.managers.storage.sql;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||
@ -109,8 +109,8 @@ private void insertCuboids() throws SQLException {
|
||||
|
||||
for (List<ProtectedCuboidRegion> partition : Lists.partition(cuboids, StatementBatch.MAX_BATCH_SIZE)) {
|
||||
for (ProtectedCuboidRegion region : partition) {
|
||||
BlockVector min = region.getMinimumPoint();
|
||||
BlockVector max = region.getMaximumPoint();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
|
||||
stmt.setString(1, region.getId());
|
||||
stmt.setInt(2, min.getBlockZ());
|
||||
@ -165,7 +165,7 @@ private void insertPolygonVertices() throws SQLException {
|
||||
StatementBatch batch = new StatementBatch(stmt, StatementBatch.MAX_BATCH_SIZE);
|
||||
|
||||
for (ProtectedPolygonalRegion region : polygons) {
|
||||
for (BlockVector2D point : region.getPoints()) {
|
||||
for (BlockVector2 point : region.getPoints()) {
|
||||
stmt.setString(1, region.getId());
|
||||
stmt.setInt(2, point.getBlockZ());
|
||||
stmt.setInt(3, point.getBlockX());
|
||||
|
@ -35,9 +35,9 @@ class RegionRemover {
|
||||
private final DataSourceConfig config;
|
||||
private final Connection conn;
|
||||
private final int worldId;
|
||||
private final List<String> regionQueue = new ArrayList<String>();
|
||||
private final List<String> cuboidGeometryQueue = new ArrayList<String>();
|
||||
private final List<String> polygonGeometryQueue = new ArrayList<String>();
|
||||
private final List<String> regionQueue = new ArrayList<>();
|
||||
private final List<String> cuboidGeometryQueue = new ArrayList<>();
|
||||
private final List<String> polygonGeometryQueue = new ArrayList<>();
|
||||
|
||||
RegionRemover(DataUpdater updater) {
|
||||
this.config = updater.config;
|
||||
|
@ -50,16 +50,16 @@ class RegionUpdater {
|
||||
private final int worldId;
|
||||
private final DomainTableCache domainTableCache;
|
||||
|
||||
private final Set<String> userNames = new HashSet<String>();
|
||||
private final Set<UUID> userUuids = new HashSet<UUID>();
|
||||
private final Set<String> groupNames = new HashSet<String>();
|
||||
private final Set<String> userNames = new HashSet<>();
|
||||
private final Set<UUID> userUuids = new HashSet<>();
|
||||
private final Set<String> groupNames = new HashSet<>();
|
||||
|
||||
private final Yaml yaml = SQLRegionDatabase.createYaml();
|
||||
|
||||
private final List<ProtectedRegion> typesToUpdate = new ArrayList<ProtectedRegion>();
|
||||
private final List<ProtectedRegion> parentsToSet = new ArrayList<ProtectedRegion>();
|
||||
private final List<ProtectedRegion> flagsToReplace = new ArrayList<ProtectedRegion>();
|
||||
private final List<ProtectedRegion> domainsToReplace = new ArrayList<ProtectedRegion>();
|
||||
private final List<ProtectedRegion> typesToUpdate = new ArrayList<>();
|
||||
private final List<ProtectedRegion> parentsToSet = new ArrayList<>();
|
||||
private final List<ProtectedRegion> flagsToReplace = new ArrayList<>();
|
||||
private final List<ProtectedRegion> domainsToReplace = new ArrayList<>();
|
||||
|
||||
RegionUpdater(DataUpdater updater) {
|
||||
this.config = updater.config;
|
||||
|
@ -53,7 +53,7 @@ abstract class TableCache<V> {
|
||||
private static final int MAX_NUMBER_PER_QUERY = 100;
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
private final Map<V, Integer> cache = new HashMap<V, Integer>();
|
||||
private final Map<V, Integer> cache = new HashMap<>();
|
||||
private final DataSourceConfig config;
|
||||
private final Connection conn;
|
||||
private final String tableName;
|
||||
@ -115,7 +115,7 @@ public void fetch(Collection<V> entries) throws SQLException {
|
||||
checkNotNull(entries);
|
||||
|
||||
// Get a list of missing entries
|
||||
List<V> fetchList = new ArrayList<V>();
|
||||
List<V> fetchList = new ArrayList<>();
|
||||
for (V entry : entries) {
|
||||
if (!cache.containsKey(toKey(entry))) {
|
||||
fetchList.add(entry);
|
||||
@ -154,7 +154,7 @@ public void fetch(Collection<V> entries) throws SQLException {
|
||||
}
|
||||
}
|
||||
|
||||
List<V> missing = new ArrayList<V>();
|
||||
List<V> missing = new ArrayList<>();
|
||||
for (V entry : fetchList) {
|
||||
if (!cache.containsKey(toKey(entry))) {
|
||||
missing.add(entry);
|
||||
|
@ -19,9 +19,8 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.awt.geom.Area;
|
||||
import java.util.ArrayList;
|
||||
@ -57,8 +56,8 @@ public GlobalProtectedRegion(String id) {
|
||||
*/
|
||||
public GlobalProtectedRegion(String id, boolean transientRegion) {
|
||||
super(id, transientRegion);
|
||||
min = new BlockVector(0, 0, 0);
|
||||
max = new BlockVector(0, 0, 0);
|
||||
min = BlockVector3.ZERO;
|
||||
max = BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,10 +66,10 @@ public boolean isPhysicalArea() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector2D> getPoints() {
|
||||
public List<BlockVector2> getPoints() {
|
||||
// This doesn't make sense
|
||||
List<BlockVector2D> pts = new ArrayList<BlockVector2D>();
|
||||
pts.add(new BlockVector2D(min.getBlockX(), min.getBlockZ()));
|
||||
List<BlockVector2> pts = new ArrayList<>();
|
||||
pts.add(BlockVector2.at(min.getBlockX(), min.getBlockZ()));
|
||||
return pts;
|
||||
}
|
||||
|
||||
@ -80,7 +79,7 @@ public int volume() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector pt) {
|
||||
public boolean contains(BlockVector3 pt) {
|
||||
// Global regions are handled separately so it must not contain any positions
|
||||
return false;
|
||||
}
|
||||
|
@ -19,18 +19,17 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.util.MathUtils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Area;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Represents a cuboid region that can be protected.
|
||||
*
|
||||
@ -40,7 +39,7 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
||||
|
||||
/**
|
||||
* Construct a new instance of this cuboid region.<br>
|
||||
* Equivalent to {@link #ProtectedCuboidRegion(String, boolean, BlockVector, BlockVector)
|
||||
* Equivalent to {@link #ProtectedCuboidRegion(String, boolean, BlockVector3, BlockVector3)
|
||||
* ProtectedCuboidRegion(id, false, pt1, pt2)}<br>
|
||||
* <code>transientRegion</code> will be set to false, and this region can be saved.
|
||||
*
|
||||
@ -48,7 +47,7 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
||||
* @param pt1 the first point of this region
|
||||
* @param pt2 the second point of this region
|
||||
*/
|
||||
public ProtectedCuboidRegion(String id, BlockVector pt1, BlockVector pt2) {
|
||||
public ProtectedCuboidRegion(String id, BlockVector3 pt1, BlockVector3 pt2) {
|
||||
this(id, false, pt1, pt2);
|
||||
}
|
||||
|
||||
@ -60,7 +59,7 @@ public ProtectedCuboidRegion(String id, BlockVector pt1, BlockVector pt2) {
|
||||
* @param pt1 the first point of this region
|
||||
* @param pt2 the second point of this region
|
||||
*/
|
||||
public ProtectedCuboidRegion(String id, boolean transientRegion, BlockVector pt1, BlockVector pt2) {
|
||||
public ProtectedCuboidRegion(String id, boolean transientRegion, BlockVector3 pt1, BlockVector3 pt2) {
|
||||
super(id, transientRegion);
|
||||
setMinMaxPoints(pt1, pt2);
|
||||
}
|
||||
@ -71,11 +70,11 @@ public ProtectedCuboidRegion(String id, boolean transientRegion, BlockVector pt1
|
||||
* @param position1 the first point of this region
|
||||
* @param position2 the second point of this region
|
||||
*/
|
||||
private void setMinMaxPoints(BlockVector position1, BlockVector position2) {
|
||||
private void setMinMaxPoints(BlockVector3 position1, BlockVector3 position2) {
|
||||
checkNotNull(position1);
|
||||
checkNotNull(position2);
|
||||
|
||||
List<Vector> points = new ArrayList<Vector>();
|
||||
List<BlockVector3> points = new ArrayList<>();
|
||||
points.add(position1);
|
||||
points.add(position2);
|
||||
setMinMaxPoints(points);
|
||||
@ -86,7 +85,7 @@ private void setMinMaxPoints(BlockVector position1, BlockVector position2) {
|
||||
*
|
||||
* @param position the point to set as the minimum point
|
||||
*/
|
||||
public void setMinimumPoint(BlockVector position) {
|
||||
public void setMinimumPoint(BlockVector3 position) {
|
||||
setMinMaxPoints(position, max);
|
||||
}
|
||||
|
||||
@ -95,7 +94,7 @@ public void setMinimumPoint(BlockVector position) {
|
||||
*
|
||||
* @param position the point to set as the maximum point
|
||||
*/
|
||||
public void setMaximumPoint(BlockVector position) {
|
||||
public void setMaximumPoint(BlockVector3 position) {
|
||||
setMinMaxPoints(min, position);
|
||||
}
|
||||
|
||||
@ -105,23 +104,23 @@ public boolean isPhysicalArea() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector2D> getPoints() {
|
||||
List<BlockVector2D> pts = new ArrayList<BlockVector2D>();
|
||||
public List<BlockVector2> getPoints() {
|
||||
List<BlockVector2> pts = new ArrayList<>();
|
||||
int x1 = min.getBlockX();
|
||||
int x2 = max.getBlockX();
|
||||
int z1 = min.getBlockZ();
|
||||
int z2 = max.getBlockZ();
|
||||
|
||||
pts.add(new BlockVector2D(x1, z1));
|
||||
pts.add(new BlockVector2D(x2, z1));
|
||||
pts.add(new BlockVector2D(x2, z2));
|
||||
pts.add(new BlockVector2D(x1, z2));
|
||||
pts.add(BlockVector2.at(x1, z1));
|
||||
pts.add(BlockVector2.at(x2, z1));
|
||||
pts.add(BlockVector2.at(x2, z2));
|
||||
pts.add(BlockVector2.at(x1, z2));
|
||||
|
||||
return pts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector pt) {
|
||||
public boolean contains(BlockVector3 pt) {
|
||||
final double x = pt.getX();
|
||||
final double y = pt.getY();
|
||||
final double z = pt.getZ();
|
||||
|
@ -19,20 +19,20 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.regions;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.awt.Polygon;
|
||||
import java.awt.geom.Area;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class ProtectedPolygonalRegion extends ProtectedRegion {
|
||||
|
||||
private final ImmutableList<BlockVector2D> points;
|
||||
private final ImmutableList<BlockVector2> points;
|
||||
private final int minY;
|
||||
private final int maxY;
|
||||
|
||||
@ -47,7 +47,7 @@ public class ProtectedPolygonalRegion extends ProtectedRegion {
|
||||
* @param minY the minimum y coordinate
|
||||
* @param maxY the maximum y coordinate
|
||||
*/
|
||||
public ProtectedPolygonalRegion(String id, List<BlockVector2D> points, int minY, int maxY) {
|
||||
public ProtectedPolygonalRegion(String id, List<BlockVector2> points, int minY, int maxY) {
|
||||
this(id, false, points, minY, maxY);
|
||||
}
|
||||
|
||||
@ -60,9 +60,9 @@ public ProtectedPolygonalRegion(String id, List<BlockVector2D> points, int minY,
|
||||
* @param minY the minimum y coordinate
|
||||
* @param maxY the maximum y coordinate
|
||||
*/
|
||||
public ProtectedPolygonalRegion(String id, boolean transientRegion, List<BlockVector2D> points, int minY, int maxY) {
|
||||
public ProtectedPolygonalRegion(String id, boolean transientRegion, List<BlockVector2> points, int minY, int maxY) {
|
||||
super(id, transientRegion);
|
||||
ImmutableList<BlockVector2D> immutablePoints = ImmutableList.copyOf(points);
|
||||
ImmutableList<BlockVector2> immutablePoints = ImmutableList.copyOf(points);
|
||||
setMinMaxPoints(immutablePoints, minY, maxY);
|
||||
this.points = immutablePoints;
|
||||
this.minY = min.getBlockY();
|
||||
@ -76,13 +76,13 @@ public ProtectedPolygonalRegion(String id, boolean transientRegion, List<BlockVe
|
||||
* @param minY The minimum y coordinate
|
||||
* @param maxY The maximum y coordinate
|
||||
*/
|
||||
private void setMinMaxPoints(List<BlockVector2D> points2D, int minY, int maxY) {
|
||||
private void setMinMaxPoints(List<BlockVector2> points2D, int minY, int maxY) {
|
||||
checkNotNull(points2D);
|
||||
|
||||
List<Vector> points = new ArrayList<Vector>();
|
||||
List<BlockVector3> points = new ArrayList<>();
|
||||
int y = minY;
|
||||
for (BlockVector2D point2D : points2D) {
|
||||
points.add(new Vector(point2D.getBlockX(), y, point2D.getBlockZ()));
|
||||
for (BlockVector2 point2D : points2D) {
|
||||
points.add(BlockVector3.at(point2D.getBlockX(), y, point2D.getBlockZ()));
|
||||
y = maxY;
|
||||
}
|
||||
setMinMaxPoints(points);
|
||||
@ -94,12 +94,12 @@ public boolean isPhysicalArea() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector2D> getPoints() {
|
||||
public List<BlockVector2> getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(BlockVector3 position) {
|
||||
checkNotNull(position);
|
||||
|
||||
int targetX = position.getBlockX(); // Width
|
||||
@ -166,13 +166,13 @@ public RegionType getType() {
|
||||
|
||||
@Override
|
||||
Area toArea() {
|
||||
List<BlockVector2D> points = getPoints();
|
||||
List<BlockVector2> points = getPoints();
|
||||
int numPoints = points.size();
|
||||
int[] xCoords = new int[numPoints];
|
||||
int[] yCoords = new int[numPoints];
|
||||
|
||||
int i = 0;
|
||||
for (BlockVector2D point : points) {
|
||||
for (BlockVector2 point : points) {
|
||||
xCoords[i] = point.getBlockX();
|
||||
yCoords[i] = point.getBlockZ();
|
||||
i++;
|
||||
|
@ -22,9 +22,8 @@
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
@ -53,8 +52,8 @@ public abstract class ProtectedRegion implements ChangeTracked, Comparable<Prote
|
||||
public static final String GLOBAL_REGION = "__global__";
|
||||
private static final Pattern VALID_ID_PATTERN = Pattern.compile("^[A-Za-z0-9_,'\\-\\+/]{1,}$");
|
||||
|
||||
protected BlockVector min;
|
||||
protected BlockVector max;
|
||||
protected BlockVector3 min;
|
||||
protected BlockVector3 max;
|
||||
|
||||
private final String id;
|
||||
private final boolean transientRegion;
|
||||
@ -62,7 +61,7 @@ public abstract class ProtectedRegion implements ChangeTracked, Comparable<Prote
|
||||
private ProtectedRegion parent;
|
||||
private DefaultDomain owners = new DefaultDomain();
|
||||
private DefaultDomain members = new DefaultDomain();
|
||||
private ConcurrentMap<Flag<?>, Object> flags = new ConcurrentHashMap<Flag<?>, Object>();
|
||||
private ConcurrentMap<Flag<?>, Object> flags = new ConcurrentHashMap<>();
|
||||
private boolean dirty = true;
|
||||
|
||||
/**
|
||||
@ -88,7 +87,7 @@ public abstract class ProtectedRegion implements ChangeTracked, Comparable<Prote
|
||||
*
|
||||
* @param points the points to set with at least one entry
|
||||
*/
|
||||
protected void setMinMaxPoints(List<Vector> points) {
|
||||
protected void setMinMaxPoints(List<BlockVector3> points) {
|
||||
int minX = points.get(0).getBlockX();
|
||||
int minY = points.get(0).getBlockY();
|
||||
int minZ = points.get(0).getBlockZ();
|
||||
@ -96,7 +95,7 @@ protected void setMinMaxPoints(List<Vector> points) {
|
||||
int maxY = minY;
|
||||
int maxZ = minZ;
|
||||
|
||||
for (Vector v : points) {
|
||||
for (BlockVector3 v : points) {
|
||||
int x = v.getBlockX();
|
||||
int y = v.getBlockY();
|
||||
int z = v.getBlockZ();
|
||||
@ -111,8 +110,8 @@ protected void setMinMaxPoints(List<Vector> points) {
|
||||
}
|
||||
|
||||
setDirty(true);
|
||||
min = new BlockVector(minX, minY, minZ);
|
||||
max = new BlockVector(maxX, maxY, maxZ);
|
||||
min = BlockVector3.at(minX, minY, minZ);
|
||||
max = BlockVector3.at(maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,7 +136,7 @@ public String getId() {
|
||||
*
|
||||
* @return the minimum point
|
||||
*/
|
||||
public BlockVector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return min;
|
||||
}
|
||||
|
||||
@ -147,7 +146,7 @@ public BlockVector getMinimumPoint() {
|
||||
*
|
||||
* @return the maximum point
|
||||
*/
|
||||
public BlockVector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return max;
|
||||
}
|
||||
|
||||
@ -473,7 +472,7 @@ public void setFlags(Map<Flag<?>, Object> flags) {
|
||||
checkNotNull(flags);
|
||||
|
||||
setDirty(true);
|
||||
this.flags = new ConcurrentHashMap<Flag<?>, Object>(flags);
|
||||
this.flags = new ConcurrentHashMap<>(flags);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -499,7 +498,7 @@ public void copyFrom(ProtectedRegion other) {
|
||||
*
|
||||
* @return the points
|
||||
*/
|
||||
public abstract List<BlockVector2D> getPoints();
|
||||
public abstract List<BlockVector2> getPoints();
|
||||
|
||||
/**
|
||||
* Get the number of blocks in this region.
|
||||
@ -514,7 +513,7 @@ public void copyFrom(ProtectedRegion other) {
|
||||
* @param pt The point to check
|
||||
* @return Whether {@code pt} is in this region
|
||||
*/
|
||||
public abstract boolean contains(Vector pt);
|
||||
public abstract boolean contains(BlockVector3 pt);
|
||||
|
||||
/**
|
||||
* Check to see if a position is contained within this region.
|
||||
@ -522,9 +521,9 @@ public void copyFrom(ProtectedRegion other) {
|
||||
* @param position the position to check
|
||||
* @return whether {@code position} is in this region
|
||||
*/
|
||||
public boolean contains(BlockVector2D position) {
|
||||
public boolean contains(BlockVector2 position) {
|
||||
checkNotNull(position);
|
||||
return contains(new Vector(position.getBlockX(), min.getBlockY(), position.getBlockZ()));
|
||||
return contains(BlockVector3.at(position.getBlockX(), min.getBlockY(), position.getBlockZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -536,7 +535,7 @@ public boolean contains(BlockVector2D position) {
|
||||
* @return whether this region contains the point
|
||||
*/
|
||||
public boolean contains(int x, int y, int z) {
|
||||
return contains(new Vector(x, y, z));
|
||||
return contains(BlockVector3.at(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -546,10 +545,10 @@ public boolean contains(int x, int y, int z) {
|
||||
* @param positions a list of positions
|
||||
* @return true if contained
|
||||
*/
|
||||
public boolean containsAny(List<BlockVector2D> positions) {
|
||||
public boolean containsAny(List<BlockVector2> positions) {
|
||||
checkNotNull(positions);
|
||||
|
||||
for (BlockVector2D pt : positions) {
|
||||
for (BlockVector2 pt : positions) {
|
||||
if (contains(pt)) {
|
||||
return true;
|
||||
}
|
||||
@ -614,15 +613,15 @@ protected boolean intersects(ProtectedRegion region, Area thisArea) {
|
||||
* @return whether the given region intersects
|
||||
*/
|
||||
protected boolean intersectsBoundingBox(ProtectedRegion region) {
|
||||
BlockVector rMaxPoint = region.getMaximumPoint();
|
||||
BlockVector min = getMinimumPoint();
|
||||
BlockVector3 rMaxPoint = region.getMaximumPoint();
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
|
||||
if (rMaxPoint.getBlockX() < min.getBlockX()) return false;
|
||||
if (rMaxPoint.getBlockY() < min.getBlockY()) return false;
|
||||
if (rMaxPoint.getBlockZ() < min.getBlockZ()) return false;
|
||||
|
||||
BlockVector rMinPoint = region.getMinimumPoint();
|
||||
BlockVector max = getMaximumPoint();
|
||||
BlockVector3 rMinPoint = region.getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
if (rMinPoint.getBlockX() > max.getBlockX()) return false;
|
||||
if (rMinPoint.getBlockY() > max.getBlockY()) return false;
|
||||
@ -638,12 +637,12 @@ protected boolean intersectsBoundingBox(ProtectedRegion region) {
|
||||
* @return whether any edges of a region intersect
|
||||
*/
|
||||
protected boolean intersectsEdges(ProtectedRegion region) {
|
||||
List<BlockVector2D> pts1 = getPoints();
|
||||
List<BlockVector2D> pts2 = region.getPoints();
|
||||
BlockVector2D lastPt1 = pts1.get(pts1.size() - 1);
|
||||
BlockVector2D lastPt2 = pts2.get(pts2.size() - 1);
|
||||
for (BlockVector2D aPts1 : pts1) {
|
||||
for (BlockVector2D aPts2 : pts2) {
|
||||
List<BlockVector2> pts1 = getPoints();
|
||||
List<BlockVector2> pts2 = region.getPoints();
|
||||
BlockVector2 lastPt1 = pts1.get(pts1.size() - 1);
|
||||
BlockVector2 lastPt2 = pts2.get(pts2.size() - 1);
|
||||
for (BlockVector2 aPts1 : pts1) {
|
||||
for (BlockVector2 aPts2 : pts2) {
|
||||
|
||||
Line2D line1 = new Line2D.Double(
|
||||
lastPt1.getBlockX(),
|
||||
|
@ -55,7 +55,7 @@ public ApplicableRegionSet queryContains(RegionManager manager, Location locatio
|
||||
CacheKey key = new CacheKey(location);
|
||||
ApplicableRegionSet result = cache.get(key);
|
||||
if (result == null) {
|
||||
result = manager.getApplicableRegions(location.toVector());
|
||||
result = manager.getApplicableRegions(location.toVector().toBlockPoint());
|
||||
cache.put(key, result);
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -187,7 +187,7 @@ public BlockBag getInventoryBlockBag() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
@ -93,7 +93,7 @@ public void onChunkLoad(ChunkLoadEvent event) {
|
||||
RegionManager manager = get(BukkitAdapter.adapt(event.getWorld()));
|
||||
if (manager != null) {
|
||||
Chunk chunk = event.getChunk();
|
||||
manager.loadChunk(new Vector2D(chunk.getX(), chunk.getZ()));
|
||||
manager.loadChunk(BlockVector2.at(chunk.getX(), chunk.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
RegionManager manager = get(BukkitAdapter.adapt(event.getWorld()));
|
||||
if (manager != null) {
|
||||
Chunk chunk = event.getChunk();
|
||||
manager.unloadChunk(new Vector2D(chunk.getX(), chunk.getZ()));
|
||||
manager.unloadChunk(BlockVector2.at(chunk.getX(), chunk.getZ()));
|
||||
}
|
||||
}
|
||||
}, plugin);
|
||||
@ -175,9 +175,9 @@ private RegionManager load(World world) {
|
||||
|
||||
if (manager != null) {
|
||||
// Bias the region data for loaded chunks
|
||||
List<Vector2D> positions = new ArrayList<>();
|
||||
List<BlockVector2> positions = new ArrayList<>();
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
positions.add(new Vector2D(chunk.getX(), chunk.getZ()));
|
||||
positions.add(BlockVector2.at(chunk.getX(), chunk.getZ()));
|
||||
}
|
||||
manager.loadChunks(positions);
|
||||
}
|
||||
|
@ -22,12 +22,11 @@
|
||||
import com.google.common.base.Joiner;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -179,7 +178,7 @@ protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManag
|
||||
* @throws CommandException thrown if no region was found
|
||||
*/
|
||||
protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, LocalPlayer player, boolean allowGlobal) throws CommandException {
|
||||
ApplicableRegionSet set = regionManager.getApplicableRegions(player.getLocation().toVector());
|
||||
ApplicableRegionSet set = regionManager.getApplicableRegions(player.getLocation().toVector().toBlockPoint());
|
||||
|
||||
if (set.size() == 0) {
|
||||
if (allowGlobal) {
|
||||
@ -284,8 +283,8 @@ protected static ProtectedRegion checkRegionFromSelection(Player player, String
|
||||
int maxY = polySel.getMaximumPoint().getBlockY();
|
||||
return new ProtectedPolygonalRegion(id, polySel.getPoints(), minY, maxY);
|
||||
} else if (selection instanceof CuboidRegion) {
|
||||
BlockVector min = selection.getMinimumPoint().toBlockVector();
|
||||
BlockVector max = selection.getMaximumPoint().toBlockVector();
|
||||
BlockVector3 min = selection.getMinimumPoint();
|
||||
BlockVector3 max = selection.getMaximumPoint();
|
||||
return new ProtectedCuboidRegion(id, min, max);
|
||||
} else {
|
||||
throw new CommandException("Sorry, you can only use cuboids and polygons for WorldGuard regions.");
|
||||
@ -355,8 +354,8 @@ protected static void setPlayerSelection(Player player, ProtectedRegion region)
|
||||
// Set selection
|
||||
if (region instanceof ProtectedCuboidRegion) {
|
||||
ProtectedCuboidRegion cuboid = (ProtectedCuboidRegion) region;
|
||||
Vector pt1 = cuboid.getMinimumPoint();
|
||||
Vector pt2 = cuboid.getMaximumPoint();
|
||||
BlockVector3 pt1 = cuboid.getMinimumPoint();
|
||||
BlockVector3 pt2 = cuboid.getMaximumPoint();
|
||||
|
||||
session.setRegionSelector(localPlayer.getWorld(), new CuboidRegionSelector(localPlayer.getWorld(), pt1, pt2));
|
||||
player.sendMessage(ChatColor.YELLOW + "Region selected as a cuboid.");
|
||||
|
@ -20,7 +20,7 @@
|
||||
package com.sk89q.worldguard.bukkit.commands.region;
|
||||
|
||||
import com.sk89q.squirrelid.cache.ProfileCache;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
@ -236,8 +236,8 @@ private void addDomainString(DefaultDomain domain) {
|
||||
* Add information about coordinates.
|
||||
*/
|
||||
public void appendBounds() {
|
||||
BlockVector min = region.getMinimumPoint();
|
||||
BlockVector max = region.getMaximumPoint();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
builder.append(ChatColor.BLUE);
|
||||
builder.append("Bounds:");
|
||||
builder.append(ChatColor.YELLOW);
|
||||
|
@ -88,10 +88,10 @@ public void onBreakBlock(final BreakBlockEvent event) {
|
||||
|
||||
event.filter(target -> {
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new BlockBreakBlacklistEvent(localPlayer, BukkitAdapter.asVector(target), createTarget(target.getBlock())), false, false)) {
|
||||
new BlockBreakBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(target), createTarget(target.getBlock())), false, false)) {
|
||||
return false;
|
||||
} else if (!wcfg.getBlacklist().check(
|
||||
new ItemDestroyWithBlacklistEvent(localPlayer, BukkitAdapter.asVector(target), createTarget(player.getItemInHand())), false, false)) {
|
||||
new ItemDestroyWithBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(target), createTarget(player.getItemInHand())), false, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public void onPlaceBlock(final PlaceBlockEvent event) {
|
||||
}
|
||||
|
||||
event.filter(target -> wcfg.getBlacklist().check(new BlockPlaceBlacklistEvent(
|
||||
localPlayer, BukkitAdapter.asVector(target), createTarget(target.getBlock())), false, false));
|
||||
localPlayer, BukkitAdapter.asBlockVector(target), createTarget(target.getBlock())), false, false));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@ -136,7 +136,7 @@ public void onUseBlock(final UseBlockEvent event) {
|
||||
}
|
||||
|
||||
event.filter(target -> wcfg.getBlacklist().check(new BlockInteractBlacklistEvent(
|
||||
localPlayer, BukkitAdapter.asVector(target), createTarget(target.getBlock())), false, false));
|
||||
localPlayer, BukkitAdapter.asBlockVector(target), createTarget(target.getBlock())), false, false));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@ -157,7 +157,7 @@ public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
|
||||
Material material = Materials.getRelatedMaterial(event.getEffectiveType());
|
||||
if (material != null) {
|
||||
if (!wcfg.getBlacklist().check(new ItemUseBlacklistEvent(localPlayer, BukkitAdapter.asVector(event.getTarget()), createTarget(material)), false, false)) {
|
||||
if (!wcfg.getBlacklist().check(new ItemUseBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(event.getTarget()), createTarget(material)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -184,7 +184,7 @@ public void onDestroyEntity(DestroyEntityEvent event) {
|
||||
Item item = (Item) target;
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new ItemAcquireBlacklistEvent(localPlayer,
|
||||
BukkitAdapter.asVector(target.getLocation()), createTarget(item.getItemStack())), false, true)) {
|
||||
BukkitAdapter.asBlockVector(target.getLocation()), createTarget(item.getItemStack())), false, true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -193,7 +193,7 @@ public void onDestroyEntity(DestroyEntityEvent event) {
|
||||
Material material = Materials.getRelatedMaterial(target.getType());
|
||||
if (material != null) {
|
||||
// Not really a block but we only have one on-break blacklist event
|
||||
if (!wcfg.getBlacklist().check(new BlockBreakBlacklistEvent(localPlayer, BukkitAdapter.asVector(event.getTarget()), createTarget(material)), false, false)) {
|
||||
if (!wcfg.getBlacklist().check(new BlockBreakBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(event.getTarget()), createTarget(material)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -216,7 +216,7 @@ public void onUseItem(UseItemEvent event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wcfg.getBlacklist().check(new ItemUseBlacklistEvent(localPlayer, BukkitAdapter.asVector(player.getLocation()), createTarget(target)), false, false)) {
|
||||
if (!wcfg.getBlacklist().check(new ItemUseBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(player.getLocation()), createTarget(target)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -231,7 +231,7 @@ public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new ItemDropBlacklistEvent(getPlugin().wrapPlayer(event.getPlayer()),
|
||||
BukkitAdapter.asVector(ci.getLocation()), createTarget(ci.getItemStack())), false, false)) {
|
||||
BukkitAdapter.asBlockVector(ci.getLocation()), createTarget(ci.getItemStack())), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -243,7 +243,7 @@ public void onBlockDispense(BlockDispenseEvent event) {
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getBlock().getWorld()));
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
if (!wcfg.getBlacklist().check(new BlockDispenseBlacklistEvent(null, BukkitAdapter.asVector(event.getBlock().getLocation()),
|
||||
if (!wcfg.getBlacklist().check(new BlockDispenseBlacklistEvent(null, BukkitAdapter.asBlockVector(event.getBlock().getLocation()),
|
||||
createTarget(event.getItem())), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -263,7 +263,7 @@ public void onInventoryClick(InventoryClickEvent event) {
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
if (wcfg.getBlacklist() != null && !wcfg.getBlacklist().check(
|
||||
new ItemAcquireBlacklistEvent(localPlayer, BukkitAdapter.asVector(entity.getLocation()), createTarget(item)), false, false)) {
|
||||
new ItemAcquireBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(entity.getLocation()), createTarget(item)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
if (inventory.getHolder().equals(player)) {
|
||||
@ -285,7 +285,7 @@ public void onInventoryCreative(InventoryCreativeEvent event) {
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
if (wcfg.getBlacklist() != null && !wcfg.getBlacklist().check(
|
||||
new ItemAcquireBlacklistEvent(localPlayer, BukkitAdapter.asVector(entity.getLocation()), createTarget(item)), false, false)) {
|
||||
new ItemAcquireBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(entity.getLocation()), createTarget(item)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
event.setCursor(null);
|
||||
}
|
||||
@ -304,7 +304,7 @@ public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
if (wcfg.getBlacklist() != null && !wcfg.getBlacklist().check(
|
||||
new ItemAcquireBlacklistEvent(localPlayer, BukkitAdapter.asVector(player.getLocation()), createTarget(item)), false, false)) {
|
||||
new ItemAcquireBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(player.getLocation()), createTarget(item)), false, false)) {
|
||||
inventory.setItem(event.getNewSlot(), null);
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
@ -45,7 +45,7 @@ public static void clearSpongeWater(World world, int ox, int oy, int oz) {
|
||||
for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) {
|
||||
for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) {
|
||||
for (int cz = -wcfg.spongeRadius; cz <= wcfg.spongeRadius; cz++) {
|
||||
BlockVector vector = new BlockVector(ox + cx, oy + cy, oz + cz);
|
||||
BlockVector3 vector = BlockVector3.at(ox + cx, oy + cy, oz + cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
world.setBlock(vector, BlockTypes.AIR.getDefaultState());
|
||||
@ -68,8 +68,8 @@ public static void clearSpongeWater(World world, int ox, int oy, int oz) {
|
||||
* @param oz z
|
||||
*/
|
||||
private static void setBlockToWater(World world, int ox, int oy, int oz) throws WorldEditException {
|
||||
BlockVector vector = new BlockVector(ox, oy, oz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.AIR) {
|
||||
BlockVector3 vector = BlockVector3.at(ox, oy, oz);
|
||||
if (world.getBlock(vector).getBlockType().getMaterial().isAir()) {
|
||||
world.setBlock(vector, BlockTypes.WATER.getDefaultState());
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||
int cx = ox - wcfg.spongeRadius - 1;
|
||||
for (int cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
BlockVector3 vector = BlockVector3.at(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx + 1, cy, cz);
|
||||
@ -104,7 +104,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||
cx = ox + wcfg.spongeRadius + 1;
|
||||
for (int cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
BlockVector3 vector = BlockVector3.at(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx - 1, cy, cz);
|
||||
@ -119,7 +119,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||
int cy = oy - wcfg.spongeRadius - 1;
|
||||
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
BlockVector3 vector = BlockVector3.at(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx, cy + 1, cz);
|
||||
@ -134,7 +134,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||
cy = oy + wcfg.spongeRadius + 1;
|
||||
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
BlockVector3 vector = BlockVector3.at(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx, cy - 1, cz);
|
||||
@ -149,7 +149,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||
int cz = oz - wcfg.spongeRadius - 1;
|
||||
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||
for (cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
BlockVector3 vector = BlockVector3.at(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx, cy, cz + 1);
|
||||
@ -164,7 +164,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||
cz = oz + wcfg.spongeRadius + 1;
|
||||
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||
for (cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||
BlockVector vector = new BlockVector(cx, cy, cz);
|
||||
BlockVector3 vector = BlockVector3.at(cx, cy, cz);
|
||||
if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) {
|
||||
try {
|
||||
setBlockToWater(world, cx, cy, cz - 1);
|
||||
|
@ -448,8 +448,8 @@ public void onPlayerPortal(PlayerPortalEvent event) {
|
||||
Location max = event.getTo().clone().add(radius, radius, radius);
|
||||
com.sk89q.worldedit.world.World world = BukkitAdapter.adapt(event.getTo().getWorld());
|
||||
|
||||
ProtectedRegion check = new ProtectedCuboidRegion("__portalcheck__", BukkitAdapter.adapt(min.getBlock().getLocation()).toVector().toBlockVector(),
|
||||
BukkitAdapter.adapt(max.getBlock().getLocation()).toVector().toBlockVector());
|
||||
ProtectedRegion check = new ProtectedCuboidRegion("__portalcheck__", BukkitAdapter.adapt(min.getBlock().getLocation()).toVector().toBlockPoint(),
|
||||
BukkitAdapter.adapt(max.getBlock().getLocation()).toVector().toBlockPoint());
|
||||
|
||||
if (wcfg.useRegions && !WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, world)) {
|
||||
RegionManager mgr = WorldGuard.getInstance().getPlatform().getRegionContainer().get(world);
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package com.sk89q.worldguard;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -197,7 +197,7 @@ public BlockBag getInventoryBlockBag() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.TestPlayer;
|
||||
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
public class MockApplicableRegionSet {
|
||||
|
||||
private List<ProtectedRegion> regions = new ArrayList<ProtectedRegion>();
|
||||
private List<ProtectedRegion> regions = new ArrayList<>();
|
||||
private ProtectedRegion global;
|
||||
private int id = 0;
|
||||
private int playerIndex = 0;
|
||||
@ -55,14 +55,14 @@ public ProtectedRegion global() {
|
||||
|
||||
public ProtectedRegion createOutside(int priority) {
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(getNextId(),
|
||||
new BlockVector(0, 0, 0), new BlockVector(1, 1, 1));
|
||||
BlockVector3.at(0, 0, 0), BlockVector3.at(1, 1, 1));
|
||||
region.setPriority(priority);
|
||||
return region;
|
||||
}
|
||||
|
||||
public ProtectedRegion add(int priority) {
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(getNextId(),
|
||||
new BlockVector(0, 0, 0), new BlockVector(1, 1, 1));
|
||||
BlockVector3.at(0, 0, 0), BlockVector3.at(1, 1, 1));
|
||||
region.setPriority(priority);
|
||||
add(region);
|
||||
return region;
|
||||
@ -71,7 +71,7 @@ public ProtectedRegion add(int priority) {
|
||||
public ProtectedRegion add(int priority, ProtectedRegion parent)
|
||||
throws ProtectedRegion.CircularInheritanceException {
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(getNextId(),
|
||||
new BlockVector(0, 0, 0), new BlockVector(1, 1, 1));
|
||||
BlockVector3.at(0, 0, 0), BlockVector3.at(1, 1, 1));
|
||||
region.setPriority(priority);
|
||||
region.setParent(parent);
|
||||
add(region);
|
||||
|
@ -19,8 +19,10 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.TestPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
@ -28,7 +30,6 @@
|
||||
import com.sk89q.worldguard.protection.flags.RegionGroup;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
@ -36,9 +37,6 @@
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public abstract class RegionEntryExitTest {
|
||||
|
||||
static String ENTRY_ID = "entry_rg";
|
||||
@ -46,8 +44,8 @@ public abstract class RegionEntryExitTest {
|
||||
static String BUILDER_GROUP = "builder";
|
||||
static String VIP_GROUP = "vip";
|
||||
|
||||
Vector inEntry = new Vector(5, 64, 5);
|
||||
Vector inExit = new Vector(-5, 65, -5);
|
||||
BlockVector3 inEntry = BlockVector3.at(5, 64, 5);
|
||||
BlockVector3 inExit = BlockVector3.at(-5, 65, -5);
|
||||
|
||||
RegionManager manager;
|
||||
ProtectedRegion globalRegion;
|
||||
@ -92,7 +90,7 @@ void setUpEntryRegion() {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
domain.addGroup(VIP_GROUP);
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(ENTRY_ID, new BlockVector(1, 0, 1), new BlockVector(10, 255, 10));
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(ENTRY_ID, BlockVector3.at(1, 0, 1), BlockVector3.at(10, 255, 10));
|
||||
|
||||
region.setMembers(domain);
|
||||
manager.addRegion(region);
|
||||
@ -109,7 +107,7 @@ void setUpExitRegion() throws Exception {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
domain.addGroup(BUILDER_GROUP);
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(EXIT_ID, new BlockVector(-1, 0, -1), new BlockVector(-10, 255, -10));
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(EXIT_ID, BlockVector3.at(-1, 0, -1), BlockVector3.at(-10, 255, -10));
|
||||
|
||||
region.setOwners(domain);
|
||||
manager.addRegion(region);
|
||||
|
@ -19,16 +19,17 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.TestPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
@ -40,9 +41,6 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public abstract class RegionOverlapTest {
|
||||
static String COURTYARD_ID = "courtyard";
|
||||
static String FOUNTAIN_ID = "fountain";
|
||||
@ -50,10 +48,10 @@ public abstract class RegionOverlapTest {
|
||||
static String MEMBER_GROUP = "member";
|
||||
static String COURTYARD_GROUP = "courtyard";
|
||||
|
||||
Vector inFountain = new Vector(2, 2, 2);
|
||||
Vector inCourtyard = new Vector(7, 7, 7);
|
||||
Vector outside = new Vector(15, 15, 15);
|
||||
Vector inNoFire = new Vector(150, 150, 150);
|
||||
BlockVector3 inFountain = BlockVector3.at(2, 2, 2);
|
||||
BlockVector3 inCourtyard = BlockVector3.at(7, 7, 7);
|
||||
BlockVector3 outside = BlockVector3.at(15, 15, 15);
|
||||
BlockVector3 inNoFire = BlockVector3.at(150, 150, 150);
|
||||
RegionManager manager;
|
||||
ProtectedRegion globalRegion;
|
||||
ProtectedRegion courtyard;
|
||||
@ -96,11 +94,11 @@ void setUpCourtyardRegion() {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
domain.addGroup(COURTYARD_GROUP);
|
||||
|
||||
ArrayList<BlockVector2D> points = new ArrayList<BlockVector2D>();
|
||||
points.add(new BlockVector2D(0, 0));
|
||||
points.add(new BlockVector2D(10, 0));
|
||||
points.add(new BlockVector2D(10, 10));
|
||||
points.add(new BlockVector2D(0, 10));
|
||||
ArrayList<BlockVector2> points = new ArrayList<>();
|
||||
points.add(BlockVector2.ZERO);
|
||||
points.add(BlockVector2.at(10, 0));
|
||||
points.add(BlockVector2.at(10, 10));
|
||||
points.add(BlockVector2.at(0, 10));
|
||||
|
||||
//ProtectedRegion region = new ProtectedCuboidRegion(COURTYARD_ID, new BlockVector(0, 0, 0), new BlockVector(10, 10, 10));
|
||||
ProtectedRegion region = new ProtectedPolygonalRegion(COURTYARD_ID, points, 0, 10);
|
||||
@ -116,7 +114,7 @@ void setUpFountainRegion() throws Exception {
|
||||
domain.addGroup(MEMBER_GROUP);
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(FOUNTAIN_ID,
|
||||
new BlockVector(0, 0, 0), new BlockVector(5, 5, 5));
|
||||
BlockVector3.ZERO, BlockVector3.at(5, 5, 5));
|
||||
region.setMembers(domain);
|
||||
manager.addRegion(region);
|
||||
|
||||
@ -127,7 +125,7 @@ void setUpFountainRegion() throws Exception {
|
||||
|
||||
void setUpNoFireRegion() throws Exception {
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(NO_FIRE_ID,
|
||||
new BlockVector(100, 100, 100), new BlockVector(200, 200, 200));
|
||||
BlockVector3.at(100, 100, 100), BlockVector3.at(200, 200, 200));
|
||||
manager.addRegion(region);
|
||||
region.setFlag(Flags.FIRE_SPREAD, StateFlag.State.DENY);
|
||||
}
|
||||
|
@ -19,16 +19,17 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.TestPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
@ -39,9 +40,6 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public abstract class RegionPriorityTest {
|
||||
static String COURTYARD_ID = "courtyard";
|
||||
static String FOUNTAIN_ID = "fountain";
|
||||
@ -49,9 +47,9 @@ public abstract class RegionPriorityTest {
|
||||
static String MEMBER_GROUP = "member";
|
||||
static String COURTYARD_GROUP = "courtyard";
|
||||
|
||||
Vector inFountain = new Vector(2, 2, 2);
|
||||
Vector inCourtyard = new Vector(7, 7, 7);
|
||||
Vector outside = new Vector(15, 15, 15);
|
||||
BlockVector3 inFountain = BlockVector3.at(2, 2, 2);
|
||||
BlockVector3 inCourtyard = BlockVector3.at(7, 7, 7);
|
||||
BlockVector3 outside = BlockVector3.at(15, 15, 15);
|
||||
RegionManager manager;
|
||||
ProtectedRegion globalRegion;
|
||||
ProtectedRegion courtyard;
|
||||
@ -93,11 +91,11 @@ void setUpCourtyardRegion() {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
domain.addGroup(COURTYARD_GROUP);
|
||||
|
||||
ArrayList<BlockVector2D> points = new ArrayList<BlockVector2D>();
|
||||
points.add(new BlockVector2D(0, 0));
|
||||
points.add(new BlockVector2D(10, 0));
|
||||
points.add(new BlockVector2D(10, 10));
|
||||
points.add(new BlockVector2D(0, 10));
|
||||
ArrayList<BlockVector2> points = new ArrayList<>();
|
||||
points.add(BlockVector2.ZERO);
|
||||
points.add(BlockVector2.at(10, 0));
|
||||
points.add(BlockVector2.at(10, 10));
|
||||
points.add(BlockVector2.at(0, 10));
|
||||
|
||||
//ProtectedRegion region = new ProtectedCuboidRegion(COURTYARD_ID, new BlockVector(0, 0, 0), new BlockVector(10, 10, 10));
|
||||
ProtectedRegion region = new ProtectedPolygonalRegion(COURTYARD_ID, points, 0, 10);
|
||||
@ -114,7 +112,7 @@ void setUpFountainRegion() throws Exception {
|
||||
domain.addGroup(MEMBER_GROUP);
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(FOUNTAIN_ID,
|
||||
new BlockVector(0, 0, 0), new BlockVector(5, 5, 5));
|
||||
BlockVector3.ZERO, BlockVector3.at(5, 5, 5));
|
||||
region.setMembers(domain);
|
||||
manager.addRegion(region);
|
||||
|
||||
|
@ -19,66 +19,66 @@
|
||||
|
||||
package com.sk89q.worldguard.protection.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class RegionIntersectTest {
|
||||
|
||||
@Test
|
||||
public void testCuboidGetIntersectingRegions() {
|
||||
ProtectedRegion region = new ProtectedCuboidRegion("square",
|
||||
new BlockVector(100, 40, 0), new BlockVector(140, 128, 40));
|
||||
BlockVector3.at(100, 40, 0), BlockVector3.at(140, 128, 40));
|
||||
|
||||
assertIntersection(region, new ProtectedCuboidRegion("normal",
|
||||
new BlockVector(80, 40, -20), new BlockVector(120, 128, 20)),
|
||||
BlockVector3.at(80, 40, -20), BlockVector3.at(120, 128, 20)),
|
||||
true);
|
||||
|
||||
assertIntersection(region, new ProtectedCuboidRegion("small",
|
||||
new BlockVector(98, 45, 20), new BlockVector(103, 50, 25)),
|
||||
BlockVector3.at(98, 45, 20), BlockVector3.at(103, 50, 25)),
|
||||
true);
|
||||
|
||||
assertIntersection(region, new ProtectedCuboidRegion("large",
|
||||
new BlockVector(-500, 0, -600), new BlockVector(1000, 128, 1000)),
|
||||
BlockVector3.at(-500, 0, -600), BlockVector3.at(1000, 128, 1000)),
|
||||
true);
|
||||
|
||||
assertIntersection(region, new ProtectedCuboidRegion("short",
|
||||
new BlockVector(50, 40, -1), new BlockVector(150, 128, 2)),
|
||||
BlockVector3.at(50, 40, -1), BlockVector3.at(150, 128, 2)),
|
||||
true);
|
||||
|
||||
assertIntersection(region, new ProtectedCuboidRegion("long",
|
||||
new BlockVector(0, 40, 5), new BlockVector(1000, 128, 8)),
|
||||
BlockVector3.at(0, 40, 5), BlockVector3.at(1000, 128, 8)),
|
||||
true);
|
||||
|
||||
List<BlockVector2D> triangleOverlap = new ArrayList<BlockVector2D>();
|
||||
triangleOverlap.add(new BlockVector2D(90, -10));
|
||||
triangleOverlap.add(new BlockVector2D(120, -10));
|
||||
triangleOverlap.add(new BlockVector2D(90, 20));
|
||||
List<BlockVector2> triangleOverlap = new ArrayList<>();
|
||||
triangleOverlap.add(BlockVector2.at(90, -10));
|
||||
triangleOverlap.add(BlockVector2.at(120, -10));
|
||||
triangleOverlap.add(BlockVector2.at(90, 20));
|
||||
|
||||
assertIntersection(region, new ProtectedPolygonalRegion("triangleOverlap",
|
||||
triangleOverlap, 0, 128),
|
||||
true);
|
||||
|
||||
List<BlockVector2D> triangleNoOverlap = new ArrayList<BlockVector2D>();
|
||||
triangleNoOverlap.add(new BlockVector2D(90, -10));
|
||||
triangleNoOverlap.add(new BlockVector2D(105, -10));
|
||||
triangleNoOverlap.add(new BlockVector2D(90, 5));
|
||||
List<BlockVector2> triangleNoOverlap = new ArrayList<>();
|
||||
triangleNoOverlap.add(BlockVector2.at(90, -10));
|
||||
triangleNoOverlap.add(BlockVector2.at(105, -10));
|
||||
triangleNoOverlap.add(BlockVector2.at(90, 5));
|
||||
|
||||
assertIntersection(region, new ProtectedPolygonalRegion("triangleNoOverlap",
|
||||
triangleNoOverlap, 0, 128),
|
||||
false);
|
||||
|
||||
List<BlockVector2D> triangleOverlapNoPoints = new ArrayList<BlockVector2D>();
|
||||
triangleOverlapNoPoints.add(new BlockVector2D(100, -10));
|
||||
triangleOverlapNoPoints.add(new BlockVector2D(120, 50));
|
||||
triangleOverlapNoPoints.add(new BlockVector2D(140, -20));
|
||||
List<BlockVector2> triangleOverlapNoPoints = new ArrayList<>();
|
||||
triangleOverlapNoPoints.add(BlockVector2.at(100, -10));
|
||||
triangleOverlapNoPoints.add(BlockVector2.at(120, 50));
|
||||
triangleOverlapNoPoints.add(BlockVector2.at(140, -20));
|
||||
|
||||
assertIntersection(region, new ProtectedPolygonalRegion("triangleOverlapNoPoints",
|
||||
triangleOverlapNoPoints, 60, 80),
|
||||
@ -87,7 +87,7 @@ public void testCuboidGetIntersectingRegions() {
|
||||
|
||||
private void assertIntersection(ProtectedRegion region1, ProtectedRegion region2, boolean expected) {
|
||||
boolean actual = false;
|
||||
List<ProtectedRegion> regions = new ArrayList<ProtectedRegion>();
|
||||
List<ProtectedRegion> regions = new ArrayList<>();
|
||||
regions.add(region2);
|
||||
|
||||
try {
|
||||
@ -99,20 +99,20 @@ private void assertIntersection(ProtectedRegion region1, ProtectedRegion region2
|
||||
assertEquals("Check for '" + region2.getId() + "' region failed.", expected, actual);
|
||||
}
|
||||
|
||||
private static final BlockVector2D[] polygon = {
|
||||
new BlockVector2D(1, 0),
|
||||
new BlockVector2D(4, 3),
|
||||
new BlockVector2D(4, -3),
|
||||
private static final BlockVector2[] polygon = {
|
||||
BlockVector2.at(1, 0),
|
||||
BlockVector2.at(4, 3),
|
||||
BlockVector2.at(4, -3),
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testIntersection() throws Exception {
|
||||
final ProtectedCuboidRegion cuboidRegion = new ProtectedCuboidRegion("cuboidRegion", new BlockVector(-3, -3, -3), new BlockVector(3, 3, 3));
|
||||
final ProtectedCuboidRegion cuboidRegion = new ProtectedCuboidRegion("cuboidRegion", BlockVector3.at(-3, -3, -3), BlockVector3.at(3, 3, 3));
|
||||
for (int angle = 0; angle < 360; angle += 90) {
|
||||
final BlockVector2D[] rotatedPolygon = new BlockVector2D[polygon.length];
|
||||
final BlockVector2[] rotatedPolygon = new BlockVector2[polygon.length];
|
||||
for (int i = 0; i < polygon.length; i++) {
|
||||
final BlockVector2D vertex = polygon[i];
|
||||
rotatedPolygon[i] = vertex.transform2D(angle, 0, 0, 0, 0).toBlockVector2D();
|
||||
final BlockVector2 vertex = polygon[i];
|
||||
rotatedPolygon[i] = vertex.transform2D(angle, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
final ProtectedPolygonalRegion polygonalRegion = new ProtectedPolygonalRegion("polygonalRegion", Arrays.asList(rotatedPolygon), -3, 3);
|
||||
|
Loading…
Reference in New Issue
Block a user