diff --git a/pom.xml b/pom.xml index 273e092..b4b044a 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ worldedit-worldguard-repo - http://maven.sk89q.com/repo/ + https://maven.enginehub.org/repo/ essx-repo @@ -79,8 +79,8 @@ com.sk89q.worldguard - worldguard-legacy - 7.0.0-SNAPSHOT + worldguard-bukkit + 7.0.4-SNAPSHOT provided @@ -114,6 +114,13 @@ + + + junit + junit + 4.13 + test + diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/UUIDFetcher.java b/src/main/java/me/ryanhamshire/GriefPrevention/UUIDFetcher.java index b14ac77..ddc6db6 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/UUIDFetcher.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/UUIDFetcher.java @@ -3,10 +3,11 @@ package me.ryanhamshire.GriefPrevention; import com.google.common.base.Charsets; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import org.bukkit.OfflinePlayer; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; import java.io.InputStreamReader; import java.io.OutputStream; @@ -21,7 +22,7 @@ class UUIDFetcher { private static int PROFILES_PER_REQUEST = 100; private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft"; - private final JSONParser jsonParser = new JSONParser(); + private final Gson gson = new Gson(); private final List names; private final boolean rateLimiting; @@ -102,17 +103,17 @@ class UUIDFetcher for (int i = 0; i * PROFILES_PER_REQUEST < names.size(); i++) { boolean retry = false; - JSONArray array = null; + JsonArray array = null; do { HttpURLConnection connection = createConnection(); - String body = JSONArray.toJSONString(names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size()))); + String body = gson.toJson(names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size()))); writeBody(connection, body); retry = false; array = null; try { - array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream())); + array = gson.fromJson(new InputStreamReader(connection.getInputStream()), JsonArray.class); } catch (Exception e) { @@ -144,11 +145,11 @@ class UUIDFetcher } } while (retry); - for (Object profile : array) + for (JsonElement profile : array) { - JSONObject jsonProfile = (JSONObject) profile; - String id = (String) jsonProfile.get("id"); - String name = (String) jsonProfile.get("name"); + JsonObject jsonProfile = profile.getAsJsonObject(); + String id = jsonProfile.get("id").getAsString(); + String name = jsonProfile.get("name").getAsString(); UUID uuid = UUIDFetcher.getUUID(id); GriefPrevention.AddLogEntry(name + " --> " + uuid.toString()); lookupCache.put(name, uuid); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/WorldGuardWrapper.java b/src/main/java/me/ryanhamshire/GriefPrevention/WorldGuardWrapper.java index 3d49344..b6a9441 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/WorldGuardWrapper.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/WorldGuardWrapper.java @@ -5,7 +5,7 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.bukkit.BukkitPlayer; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.internal.permission.RegionPermissionModel; +import com.sk89q.worldguard.internal.platform.WorldGuardPlatform; import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.flags.Flags; import com.sk89q.worldguard.protection.managers.RegionManager; @@ -28,11 +28,12 @@ class WorldGuardWrapper try { BukkitPlayer localPlayer = new BukkitPlayer(this.worldGuard, creatingPlayer); - World world = WorldGuard.getInstance().getPlatform().getMatcher().getWorldByName(lesserCorner.getWorld().getName()); + WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform(); + World world = platform.getMatcher().getWorldByName(lesserCorner.getWorld().getName()); - if (new RegionPermissionModel(localPlayer).mayIgnoreRegionProtection(world)) return true; + if (platform.getSessionManager().hasBypass(localPlayer, world)) return true; - RegionManager manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(world); + RegionManager manager = platform.getRegionContainer().get(world); if (manager != null) {