diff --git a/pom.xml b/pom.xml index e38a28c..bdbba95 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - net.pl3x.map.griefprevention - pl3xmap-griefprevention - Pl3xmap-GriefPrevention + net.pl3x.map.griefdefender + pl3xmap-griefdefender + Pl3xmap-Defender 1.0-SNAPSHOT - GriefPrevention addon for Pl3xMap + GriefDefender addon for Pl3xMap jar UTF-8 @@ -26,9 +26,9 @@ provided - com.github.TechFortress - GriefPrevention - 16.17.1 + com.github.bloodmc + GriefDefenderAPI + -dd5aa2224c-1 @@ -47,7 +47,7 @@ ${project.artifactId}-${project.version} - clean install + clean package org.apache.maven.plugins diff --git a/src/main/java/net/pl3x/map/griefprevention/Pl3xMapGriefprevention.java b/src/main/java/net/pl3x/map/griefdefender/Pl3xMapGriefdefender.java similarity index 71% rename from src/main/java/net/pl3x/map/griefprevention/Pl3xMapGriefprevention.java rename to src/main/java/net/pl3x/map/griefdefender/Pl3xMapGriefdefender.java index 288d5d9..db08347 100644 --- a/src/main/java/net/pl3x/map/griefprevention/Pl3xMapGriefprevention.java +++ b/src/main/java/net/pl3x/map/griefdefender/Pl3xMapGriefdefender.java @@ -1,18 +1,18 @@ -package net.pl3x.map.griefprevention; +package net.pl3x.map.griefdefender; -import net.pl3x.map.griefprevention.configuration.Config; -import net.pl3x.map.griefprevention.hook.Pl3xMapHook; +import net.pl3x.map.griefdefender.configuration.Config; +import net.pl3x.map.griefdefender.hook.Pl3xMapHook; import org.bukkit.plugin.java.JavaPlugin; -public final class Pl3xMapGriefprevention extends JavaPlugin { +public final class Pl3xMapGriefdefender extends JavaPlugin { private Pl3xMapHook pl3xmapHook; @Override public void onEnable() { Config.reload(this); - if (!getServer().getPluginManager().isPluginEnabled("GriefPrevention")) { - getLogger().severe("GriefPrevention not found!"); + if (!getServer().getPluginManager().isPluginEnabled("GriefDefender")) { + getLogger().severe("GriefDefender not found!"); getServer().getPluginManager().disablePlugin(this); return; } diff --git a/src/main/java/net/pl3x/map/griefprevention/configuration/Config.java b/src/main/java/net/pl3x/map/griefdefender/configuration/Config.java similarity index 97% rename from src/main/java/net/pl3x/map/griefprevention/configuration/Config.java rename to src/main/java/net/pl3x/map/griefdefender/configuration/Config.java index a4191fb..4607cc3 100644 --- a/src/main/java/net/pl3x/map/griefprevention/configuration/Config.java +++ b/src/main/java/net/pl3x/map/griefdefender/configuration/Config.java @@ -1,4 +1,4 @@ -package net.pl3x.map.griefprevention.configuration; +package net.pl3x.map.griefdefender.configuration; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -9,7 +9,7 @@ import java.io.IOException; public class Config { - public static String CONTROL_LABEL = "GriefPrevention"; + public static String CONTROL_LABEL = "GriefDefender"; public static boolean CONTROL_SHOW = true; public static boolean CONTROL_HIDE = false; public static int UPDATE_INTERVAL = 300; diff --git a/src/main/java/net/pl3x/map/griefdefender/hook/GPHook.java b/src/main/java/net/pl3x/map/griefdefender/hook/GPHook.java new file mode 100644 index 0000000..a932ab9 --- /dev/null +++ b/src/main/java/net/pl3x/map/griefdefender/hook/GPHook.java @@ -0,0 +1,17 @@ +package net.pl3x.map.griefdefender.hook; + +import com.griefdefender.api.GriefDefender; +import com.griefdefender.api.claim.Claim; + +import java.util.Collection; +import java.util.UUID; + +public class GPHook { + public static boolean isWorldEnabled(UUID uuid) { + return GriefDefender.getCore().isEnabled(uuid); + } + + public static Collection getClaims() { + return GriefDefender.getCore().getAllClaims(); + } +} diff --git a/src/main/java/net/pl3x/map/griefprevention/hook/Pl3xMapHook.java b/src/main/java/net/pl3x/map/griefdefender/hook/Pl3xMapHook.java similarity index 88% rename from src/main/java/net/pl3x/map/griefprevention/hook/Pl3xMapHook.java rename to src/main/java/net/pl3x/map/griefdefender/hook/Pl3xMapHook.java index 1797321..8ae7bb1 100644 --- a/src/main/java/net/pl3x/map/griefprevention/hook/Pl3xMapHook.java +++ b/src/main/java/net/pl3x/map/griefdefender/hook/Pl3xMapHook.java @@ -1,10 +1,10 @@ -package net.pl3x.map.griefprevention.hook; +package net.pl3x.map.griefdefender.hook; import net.pl3x.map.api.Key; import net.pl3x.map.api.Pl3xMapProvider; import net.pl3x.map.api.SimpleLayerProvider; -import net.pl3x.map.griefprevention.configuration.Config; -import net.pl3x.map.griefprevention.task.Pl3xMapTask; +import net.pl3x.map.griefdefender.configuration.Config; +import net.pl3x.map.griefdefender.task.Pl3xMapTask; import org.bukkit.plugin.Plugin; import java.util.HashMap; diff --git a/src/main/java/net/pl3x/map/griefprevention/task/Pl3xMapTask.java b/src/main/java/net/pl3x/map/griefdefender/task/Pl3xMapTask.java similarity index 65% rename from src/main/java/net/pl3x/map/griefprevention/task/Pl3xMapTask.java rename to src/main/java/net/pl3x/map/griefdefender/task/Pl3xMapTask.java index 8399b35..39a942e 100644 --- a/src/main/java/net/pl3x/map/griefprevention/task/Pl3xMapTask.java +++ b/src/main/java/net/pl3x/map/griefdefender/task/Pl3xMapTask.java @@ -1,6 +1,8 @@ -package net.pl3x.map.griefprevention.task; +package net.pl3x.map.griefdefender.task; -import me.ryanhamshire.GriefPrevention.Claim; +import com.flowpowered.math.vector.Vector3i; +import com.griefdefender.api.claim.Claim; +import com.griefdefender.api.claim.TrustTypes; import net.pl3x.map.api.Key; import net.pl3x.map.api.MapWorld; import net.pl3x.map.api.Point; @@ -8,19 +10,17 @@ import net.pl3x.map.api.marker.Marker; import net.pl3x.map.api.marker.MarkerOptions; import net.pl3x.map.api.marker.Rectangle; -import net.pl3x.map.griefprevention.configuration.Config; -import net.pl3x.map.griefprevention.hook.GPHook; +import net.pl3x.map.griefdefender.configuration.Config; +import net.pl3x.map.griefdefender.hook.GPHook; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.scheduler.BukkitRunnable; -import java.awt.Color; +import java.awt.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; public class Pl3xMapTask extends BukkitRunnable { private final MapWorld world; @@ -46,28 +46,26 @@ void updateClaims() { Collection topLevelClaims = GPHook.getClaims(); if (topLevelClaims != null) { topLevelClaims.stream() - .filter(claim -> claim.getGreaterBoundaryCorner().getWorld().getUID().equals(this.world.uuid())) - .filter(claim -> claim.parent == null) + .filter(claim -> claim.getWorldUniqueId().equals(this.world.uuid())) + .filter(claim -> !claim.getParent().isPresent()) .forEach(this::handleClaim); } } private void handleClaim(Claim claim) { - Location min = claim.getLesserBoundaryCorner(); - Location max = claim.getGreaterBoundaryCorner(); + Vector3i min = claim.getLesserBoundaryCorner(); + Vector3i max = claim.getGreaterBoundaryCorner(); if (min == null) { return; } + Rectangle rect = Marker.rectangle(Point.of(min.getX(), min.getZ()), Point.of(max.getX() + 1, max.getZ() + 1)); - Rectangle rect = Marker.rectangle(Point.of(min.getBlockX(), min.getBlockZ()), Point.of(max.getBlockX() + 1, max.getBlockZ() + 1)); + ArrayList builders = new ArrayList<>(claim.getUserTrusts(TrustTypes.BUILDER)); + ArrayList containers = new ArrayList<>(claim.getUserTrusts(TrustTypes.CONTAINER)); + ArrayList accessors = new ArrayList<>(claim.getUserTrusts(TrustTypes.ACCESSOR)); + ArrayList managers = new ArrayList<>(claim.getUserTrusts(TrustTypes.MANAGER)); - ArrayList builders = new ArrayList<>(); - ArrayList containers = new ArrayList<>(); - ArrayList accessors = new ArrayList<>(); - ArrayList managers = new ArrayList<>(); - claim.getPermissions(builders, containers, accessors, managers); - - String worldName = min.getWorld().getName(); + String worldName = Bukkit.getWorld(claim.getWorldUniqueId()).getName(); MarkerOptions.Builder options = MarkerOptions.builder() .strokeColor(Config.STROKE_COLOR) @@ -77,7 +75,7 @@ private void handleClaim(Claim claim) { .fillOpacity(Config.FILL_OPACITY) .clickTooltip((claim.isAdminClaim() ? Config.ADMIN_CLAIM_TOOLTIP : Config.CLAIM_TOOLTIP) .replace("{world}", worldName) - .replace("{id}", Long.toString(claim.getID())) + .replace("{id}", claim.getUniqueId().toString()) .replace("{owner}", claim.getOwnerName()) .replace("{managers}", getNames(managers)) .replace("{builders}", getNames(builders)) @@ -94,20 +92,15 @@ private void handleClaim(Claim claim) { rect.markerOptions(options); - String markerid = "griefprevention_" + worldName + "_region_" + Long.toHexString(claim.getID()); + String markerid = "griefprevention_" + worldName + "_region_" + claim.getUniqueId().toString(); this.provider.addMarker(Key.of(markerid), rect); } - private static String getNames(List list) { + private static String getNames(List list) { List names = new ArrayList<>(); - for (String str : list) { - try { - UUID uuid = UUID.fromString(str); - OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid); - names.add(offlinePlayer.getName()); - } catch (Exception e) { - names.add(str); - } + for (final UUID uuid : list) { + OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid); + names.add(offlinePlayer.getName()); } return String.join(", ", names); } diff --git a/src/main/java/net/pl3x/map/griefprevention/hook/GPHook.java b/src/main/java/net/pl3x/map/griefprevention/hook/GPHook.java deleted file mode 100644 index e63521a..0000000 --- a/src/main/java/net/pl3x/map/griefprevention/hook/GPHook.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.pl3x.map.griefprevention.hook; - -import me.ryanhamshire.GriefPrevention.Claim; -import me.ryanhamshire.GriefPrevention.GriefPrevention; -import org.bukkit.Bukkit; -import org.bukkit.World; - -import java.util.Collection; -import java.util.UUID; - -public class GPHook { - public static boolean isWorldEnabled(UUID uuid) { - World world = Bukkit.getWorld(uuid); - return GriefPrevention.instance.claimsEnabledForWorld(world); - } - - public static Collection getClaims() { - return GriefPrevention.instance.dataStore.getClaims(); - } -} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index be6a841..a207849 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,9 +1,9 @@ name: "${project.name}" -main: "${project.groupId}.Pl3xMapGriefprevention" +main: "${project.groupId}.Pl3xMapGriefdefender" version: "${project.version}" description: "${project.description}" api-version: "1.16" authors: [ BillyGalbreath ] softdepend: - - GriefPrevention + - GriefDefender - Pl3xMap