");
}
- RegionManager regions = plugin.getRegionContainer().get(world);
+ RegionManager regions = WorldGuard.getInstance().getPlatform().getRegionContainer().get(weWorld);
if (regions != null) {
DataReport section = new DataReport("Regions");
section.append("Region Count", regions.size());
diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServerReport.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServerReport.java
index 608efba0..aa090bb3 100644
--- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServerReport.java
+++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServerReport.java
@@ -19,7 +19,6 @@
package com.sk89q.worldguard.bukkit.util.report;
-import com.sk89q.worldguard.bukkit.BukkitUtil;
import com.sk89q.worldguard.util.report.DataReport;
import org.bukkit.Bukkit;
import org.bukkit.Server;
@@ -35,7 +34,7 @@ public ServerReport() {
append("Server Name", server.getServerName());
append("Bukkit Version", server.getBukkitVersion());
append("Implementation", server.getVersion());
- append("Player Count", "%d/%d", BukkitUtil.getOnlinePlayers().size(), server.getMaxPlayers());
+ append("Player Count", "%d/%d", Bukkit.getOnlinePlayers().size(), server.getMaxPlayers());
append("Server Class Source", server.getClass().getProtectionDomain().getCodeSource().getLocation());
diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/protection/GlobalRegionManager.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/protection/GlobalRegionManager.java
index 06dd6a63..91970119 100644
--- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/protection/GlobalRegionManager.java
+++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/protection/GlobalRegionManager.java
@@ -24,18 +24,11 @@
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.LocalPlayer;
-import com.sk89q.worldguard.bukkit.BukkitRegionContainer;
+import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.internal.platform.WorldGuardPlatform;
import com.sk89q.worldguard.protection.association.RegionAssociable;
-import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.StateFlag;
-import com.sk89q.worldguard.protection.managers.RegionManager;
-import com.sk89q.worldguard.protection.regions.RegionQuery;
-
-import java.util.Collections;
-import java.util.List;
-
-import javax.annotation.Nullable;
+import com.sk89q.worldguard.protection.regions.RegionContainer;
/**
* This is the legacy class for accessing region data.
@@ -45,96 +38,13 @@
@Deprecated
public class GlobalRegionManager {
- private final BukkitRegionContainer container;
-
/**
* Create a new instance.
*
* @param container the container
*/
- public GlobalRegionManager(BukkitRegionContainer container) {
+ public GlobalRegionManager(RegionContainer container) {
checkNotNull(container);
- this.container = container;
- }
-
- /**
- * Get the region manager for a world if one exists.
- *
- * This method may return {@code null} if region data for the given
- * world has not been loaded, has failed to load, or support for regions
- * has been disabled.
- *
- * @param world the world
- * @return a region manager, or {@code null} if one is not available
- */
- @Nullable
- public RegionManager get(World world) {
- return container.get(world);
- }
-
- /**
- * Get an immutable list of loaded {@link RegionManager}s.
- *
- * @return a list of managers
- */
- public List getLoaded() {
- return Collections.unmodifiableList(container.getLoaded());
- }
-
- /**
- * Create a new region query.
- *
- * @return a new query
- */
- private RegionQuery createQuery() {
- return container.createQuery();
- }
-
- /**
- * Test whether the given player has region protection bypass permission.
- *
- * @param player the player
- * @param world the world
- * @return true if a bypass is permitted
- * @deprecated use {@link BukkitRegionContainer#createQuery()}
- */
- @Deprecated
- public boolean hasBypass(LocalPlayer player, World world) {
- return player.hasPermission("worldguard.region.bypass." + world.getName());
- }
-
- /**
- * Test whether the player can build (place, use, destroy blocks and
- * entities) at the given position, considering only the build flag
- * and the region's members.
- *
- * This method is not an absolute test as to whether WorldGuard
- * would allow or block an event because this method doesn't
- * consider flags (i.e. chest-access flags when concerning a chest) or
- * other modules in WorldGuard (i.e chest protection).
- *
- * @param player the player
- * @param location the location
- * @return true if a bypass is permitted
- * @deprecated use {@link BukkitRegionContainer#createQuery()}
- */
- @Deprecated
- public boolean canBuild(LocalPlayer player, Location location) {
- return hasBypass(player, (World) location.getExtent()) || createQuery().testState(location, player, Flags.BUILD);
-
- }
-
- /**
- * Test whether the player can place blocks at the given position.
- *
- * @param player the player
- * @param location the location
- * @return true if permitted
- * @deprecated the construct flag is being removed
- */
- @Deprecated
- public boolean canConstruct(LocalPlayer player, Location location) {
- return canBuild(player, location);
}
/**
@@ -143,31 +53,11 @@ public boolean canConstruct(LocalPlayer player, Location location) {
* @param flag the flag
* @param location the location
* @return true if set to true
- * @deprecated use {@link BukkitRegionContainer#createQuery()}
+ * @deprecated use {@link RegionContainer#createQuery()}
*/
@Deprecated
@SuppressWarnings("deprecation")
public boolean allows(StateFlag flag, Location location) {
- return allows(flag, location, null);
+ return StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(location, (RegionAssociable) null, flag));
}
-
- /**
- * Test the value of a state flag at a location, using the player as the
- * relevant actor.
- *
- * @param flag the flag
- * @param location the location
- * @param player the actor
- * @return true if set to true
- * @deprecated use {@link BukkitRegionContainer#createQuery()}
- */
- @Deprecated
- public boolean allows(StateFlag flag, Location location, @Nullable LocalPlayer player) {
- if (player == null) {
- return StateFlag.test(createQuery().queryState(location, (RegionAssociable) null, flag));
- } else {
- return StateFlag.test(createQuery().queryState(location, player, flag));
- }
- }
-
}
diff --git a/worldguard-legacy/src/main/resources/plugin.yml b/worldguard-legacy/src/main/resources/plugin.yml
index 7a97a8d7..9a8a62c6 100644
--- a/worldguard-legacy/src/main/resources/plugin.yml
+++ b/worldguard-legacy/src/main/resources/plugin.yml
@@ -2,3 +2,4 @@ name: WorldGuard
main: com.sk89q.worldguard.bukkit.WorldGuardPlugin
version: "${project.internalVersion}"
softdepend: [WorldEdit, CommandBook]
+api-version: 1.13
diff --git a/worldguard-legacy/src/test/java/com/sk89q/worldguard/TestPlayer.java b/worldguard-legacy/src/test/java/com/sk89q/worldguard/TestPlayer.java
index ff7d406e..b46fd7b1 100644
--- a/worldguard-legacy/src/test/java/com/sk89q/worldguard/TestPlayer.java
+++ b/worldguard-legacy/src/test/java/com/sk89q/worldguard/TestPlayer.java
@@ -20,17 +20,27 @@
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.extent.inventory.BlockBag;
+import com.sk89q.worldedit.session.SessionKey;
+import com.sk89q.worldedit.util.HandSide;
+import com.sk89q.worldedit.util.Location;
+import com.sk89q.worldedit.world.World;
+import com.sk89q.worldedit.world.weather.WeatherType;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
+import javax.annotation.Nullable;
+
@org.junit.Ignore
public class TestPlayer extends LocalPlayer {
private final UUID uuid = UUID.randomUUID();
private final String name;
- private final Set groups = new HashSet();
+ private final Set groups = new HashSet<>();
public TestPlayer(String name) {
this.name = name;
@@ -55,11 +65,6 @@ public boolean hasGroup(String group) {
return groups.contains(group.toLowerCase());
}
- @Override
- public Vector getPosition() {
- return new Vector(0, 0, 0);
- }
-
@Override
public void kick(String msg) {
System.out.println("TestPlayer{" + this.name + "} kicked!");
@@ -70,11 +75,96 @@ public void ban(String msg) {
System.out.println("TestPlayer{" + this.name + "} banned!");
}
+ @Override
+ public double getHealth() {
+ return 0;
+ }
+
+ @Override
+ public void setHealth(double health) {
+
+ }
+
+ @Override
+ public double getMaxHealth() {
+ return 0;
+ }
+
+ @Override
+ public double getFoodLevel() {
+ return 0;
+ }
+
+ @Override
+ public void setFoodLevel(double foodLevel) {
+
+ }
+
+ @Override
+ public double getSaturation() {
+ return 0;
+ }
+
+ @Override
+ public void setSaturation(double saturation) {
+
+ }
+
+ @Override
+ public WeatherType getPlayerWeather() {
+ return null;
+ }
+
+ @Override
+ public void setPlayerWeather(WeatherType weather) {
+
+ }
+
+ @Override
+ public void resetPlayerWeather() {
+
+ }
+
+ @Override
+ public boolean isPlayerTimeRelative() {
+ return false;
+ }
+
+ @Override
+ public long getPlayerTimeOffset() {
+ return 0;
+ }
+
+ @Override
+ public void setPlayerTime(long time, boolean relative) {
+
+ }
+
+ @Override
+ public void resetPlayerTime() {
+
+ }
+
@Override
public void printRaw(String msg) {
System.out.println("-> TestPlayer{" + this.name + "}: " + msg);
}
+ @Override
+ public void printDebug(String msg) {
+
+ }
+
+ @Override
+ public void print(String msg) {
+
+ }
+
+ @Override
+ public void printError(String msg) {
+
+ }
+
@Override
public String[] getGroups() {
return groups.toArray(new String[groups.size()]);
@@ -84,4 +174,51 @@ public String[] getGroups() {
public boolean hasPermission(String perm) {
return true;
}
+
+ @Override
+ public World getWorld() {
+ return null;
+ }
+
+ @Override
+ public BaseItemStack getItemInHand(HandSide handSide) {
+ return null;
+ }
+
+ @Override
+ public void giveItem(BaseItemStack itemStack) {
+
+ }
+
+ @Override
+ public BlockBag getInventoryBlockBag() {
+ return null;
+ }
+
+ @Override
+ public void setPosition(Vector pos, float pitch, float yaw) {
+
+ }
+
+ @Nullable
+ @Override
+ public BaseEntity getState() {
+ return null;
+ }
+
+ @Override
+ public Location getLocation() {
+ return null;
+ }
+
+ @Override
+ public SessionKey getSessionKey() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public T getFacet(Class extends T> cls) {
+ return null;
+ }
}
diff --git a/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionEntryExitTest.java b/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionEntryExitTest.java
index 0b38be6b..888254f3 100644
--- a/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionEntryExitTest.java
+++ b/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionEntryExitTest.java
@@ -22,6 +22,7 @@
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
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.RegionGroup;
@@ -56,8 +57,7 @@ public abstract class RegionEntryExitTest {
TestPlayer builderPlayer;
protected FlagRegistry getFlagRegistry() {
- FlagRegistry registry = new SimpleFlagRegistry();
- return registry;
+ return WorldGuard.getInstance().getFlagRegistry();
}
protected abstract RegionManager createRegionManager() throws Exception;
diff --git a/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionOverlapTest.java b/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionOverlapTest.java
index 02dc062a..83765611 100644
--- a/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionOverlapTest.java
+++ b/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionOverlapTest.java
@@ -23,6 +23,7 @@
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector;
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;
@@ -61,9 +62,7 @@ public abstract class RegionOverlapTest {
TestPlayer player2;
protected FlagRegistry getFlagRegistry() {
- FlagRegistry registry = new SimpleFlagRegistry();
- registry.registerAll(Flags.getDefaultFlags());
- return registry;
+ return WorldGuard.getInstance().getFlagRegistry();
}
protected abstract RegionManager createRegionManager() throws Exception;
diff --git a/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionPriorityTest.java b/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionPriorityTest.java
index 4ec669d5..2409cc40 100644
--- a/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionPriorityTest.java
+++ b/worldguard-legacy/src/test/java/com/sk89q/worldguard/protection/RegionPriorityTest.java
@@ -23,6 +23,7 @@
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector;
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;
@@ -59,9 +60,7 @@ public abstract class RegionPriorityTest {
TestPlayer player2;
protected FlagRegistry getFlagRegistry() {
- FlagRegistry registry = new SimpleFlagRegistry();
- registry.registerAll(Flags.getDefaultFlags());
- return registry;
+ return WorldGuard.getInstance().getFlagRegistry();
}
protected abstract RegionManager createRegionManager() throws Exception;