Adds support for PlotSquared 6

This commit is contained in:
RoinujNosde committed 2021-07-08 20:54:49 -03:00
1 parent 001382558b
commit ae1f846077
6 files changed
+199 -29

No files matched your search

+30 -4
View File
@@ -84,15 +84,41 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-shed:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino-runtime:1.7.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.26" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TechFortress:GriefPrevention:16.17.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:PlotSquared-Core:5.13.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:PlotSquared-Bukkit:5.13.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:PlotSquared-Bukkit:6.0.6-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc.paper:paper-api:1.17-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-api:4.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-key:4.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:examination-api:1.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.checkerframework:checker-qual:3.10.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:examination-string:1.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-gson:4.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-legacy:4.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-plain:4.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm:9.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:9.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:9.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:9.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.14.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:squirrelid:1.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.incendo.serverlib:ServerLib:2.2.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.intellectualsites.arkitektonika:Arkitektonika-Client:2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.intellectualsites.http:HTTP4J:1.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.intellectualsites.paster:Paster:1.0.2-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-api:4.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-craftbukkit:4.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-gson-legacy-impl:4.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-bungeecord:4.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-nbt:4.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-facet:4.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-viaversion:4.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:plotsquared-api:3.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:plotsquared-bukkitapi:3.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.milkbowl.vault:VaultAPI:1.7" level="project" />
+29 -7
View File
@@ -247,22 +247,44 @@
<version>16.17.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Core</artifactId>
<version>5.13.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Bukkit</artifactId>
<version>5.13.3</version>
<version>6.0.6-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>PlotSquared-Core</artifactId>
<groupId>*</groupId>
</exclusion>
<exclusion>
<artifactId>paper-api</artifactId>
<groupId>io.papermc.paper</groupId>
</exclusion>
<exclusion>
<artifactId>squirrelid</artifactId>
<groupId>com.sk89q</groupId>
</exclusion>
<exclusion>
<artifactId>ServerLib</artifactId>
<groupId>org.incendo.serverlib</groupId>
</exclusion>
<exclusion>
<artifactId>Arkitektonika-Client</artifactId>
<groupId>com.intellectualsites.arkitektonika</groupId>
</exclusion>
<exclusion>
<artifactId>HTTP4J</artifactId>
<groupId>com.intellectualsites.http</groupId>
</exclusion>
<exclusion>
<artifactId>Paster</artifactId>
<groupId>com.intellectualsites.paster</groupId>
</exclusion>
<exclusion>
<artifactId>adventure-platform-bukkit</artifactId>
<groupId>net.kyori</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
+3 -9
View File
@@ -186,23 +186,17 @@
<version>16.17.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Core</artifactId>
<version>5.13.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Bukkit</artifactId>
<version>5.13.3</version>
<scope>provided</scope>
<version>6.0.6-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>PlotSquared-Core</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.plotsquared</groupId>
@@ -13,34 +13,44 @@ import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
@SuppressWarnings("unused")
public class PlotSquared5Provider implements ProtectionProvider {
private Method getPlot;
private Method getPlots;
private Method getPlotsUUID;
@SuppressWarnings("JavaReflectionMemberAccess")
@Override
public void setup() {
try {
getPlot = BukkitUtil.class.getMethod("getPlot", Location.class);
getPlots = PlotSquared.class.getMethod("getPlots", String.class);
getPlotsUUID = PlotSquared.class.getMethod("getPlots", String.class, UUID.class);
} catch (NoSuchMethodException ex) {
throw new RuntimeException(ex);
}
}
@Override
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
Plot plot = BukkitUtil.getPlot(location);
Plot plot = getPlot(location);
if (plot != null) {
return Collections.singleton(getLand(plot));
}
return Collections.emptySet();
}
@NotNull
private Land getLand(@NotNull Plot plot) {
return new Land(getIdPrefix() + plot.getId().toString(), plot.getOwners());
}
@Override
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
Set<Plot> plots = PlotSquared.get().getPlots(world.getName(), player.getUniqueId());
Set<Plot> plots = getPlots(world.getName(), player.getUniqueId());
return plots.stream().map(this::getLand).collect(Collectors.toSet());
}
@@ -52,9 +62,9 @@ public class PlotSquared5Provider implements ProtectionProvider {
@Override
public void deleteLand(@NotNull String id, @NotNull World world) {
id = id.replace(getIdPrefix(), "");
for (Plot plot : PlotSquared.get().getPlots(world.getName())) {
for (Plot plot : getPlots(world.getName())) {
if (plot.getId().toString().equals(id)) {
plot.deletePlot(null);
plot.unclaim();
break;
}
}
@@ -74,4 +84,35 @@ public class PlotSquared5Provider implements ProtectionProvider {
public @Nullable String getRequiredPluginName() {
return "PlotSquared";
}
@NotNull
private Land getLand(@NotNull Plot plot) {
return new Land(getIdPrefix() + plot.getId(), plot.getOwners());
}
private @Nullable Plot getPlot(Location location) {
try {
return (Plot) getPlot.invoke(null, location);
} catch (IllegalAccessException | InvocationTargetException e) {
return null;
}
}
private Set<Plot> getPlots(String world, UUID owner) {
try {
//noinspection unchecked
return (Set<Plot>) getPlotsUUID.invoke(PlotSquared.get(), world, owner);
} catch (IllegalAccessException | InvocationTargetException e) {
return Collections.emptySet();
}
}
private Set<Plot> getPlots(String world) {
try {
//noinspection unchecked
return (Set<Plot>) getPlots.invoke(PlotSquared.get(), world);
} catch (IllegalAccessException | InvocationTargetException e) {
return Collections.emptySet();
}
}
}
@@ -0,0 +1,86 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
@SuppressWarnings("unused")
public class PlotSquared6Provider implements ProtectionProvider {
@Override
public void setup() {
}
@Override
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
Plot plot = BukkitUtil.adapt(location).getPlot();
if (plot != null) {
return Collections.singleton(getLand(plot));
}
return Collections.emptySet();
}
@Override
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
Set<Plot> plots = new HashSet<>();
for (PlotArea plotArea : PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world.getName())) {
plots.addAll(plotArea.getPlots(player.getUniqueId()));
}
return plots.stream().map(this::getLand).collect(Collectors.toSet());
}
@Override
public @NotNull String getIdPrefix() {
return "ps";
}
@Override
public void deleteLand(@NotNull String id, @NotNull World world) {
id = id.replace(getIdPrefix(), "");
Set<Plot> plots = new HashSet<>();
for (PlotArea plotArea : PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world.getName())) {
for (Plot plot : plotArea.getPlots()) {
if (plot.getId().toString().equals(id)) {
plot.unclaim();
return;
}
}
}
}
@Override
public @Nullable Class<? extends Event> getCreateLandEvent() {
return null;
}
@Override
public @Nullable Player getPlayer(Event event) {
return null;
}
@Override
public @Nullable String getRequiredPluginName() {
return "PlotSquared";
}
@NotNull
private Land getLand(@NotNull Plot plot) {
return new Land(getIdPrefix() + plot.getId(), plot.getOwners());
}
}
+1
View File
@@ -57,6 +57,7 @@ war-and-protection:
protection-providers:
- WorldGuardProvider
- WorldGuard6Provider
- PlotSquared6Provider
- PlotSquared5Provider
- PlotSquared3Provider
- GriefPreventionProvider