forked from clone/WorldGuardWrapper
Fix build, maven enhancements
This commit is contained in:
parent
b54027de6d
commit
6642dce9c4
|
@ -28,6 +28,9 @@
|
||||||
<repository>
|
<repository>
|
||||||
<id>sk89q-repo</id>
|
<id>sk89q-repo</id>
|
||||||
<url>http://maven.sk89q.com/repo/</url>
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
|
<snapshots>
|
||||||
|
<updatePolicy>always</updatePolicy>
|
||||||
|
</snapshots>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -49,10 +49,6 @@
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
|
||||||
<artifactId>jsr305</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.thoughtworks.paranamer</groupId>
|
<groupId>com.thoughtworks.paranamer</groupId>
|
||||||
<artifactId>paranamer</artifactId>
|
<artifactId>paranamer</artifactId>
|
||||||
|
|
|
@ -7,10 +7,10 @@ import com.sk89q.worldguard.protection.events.DisallowedPVPEvent;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event.Result;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.Event.Result;
|
|
||||||
import org.codemc.worldguardwrapper.event.*;
|
import org.codemc.worldguardwrapper.event.*;
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.codemc.worldguardwrapper.implementation.v6.flag;
|
package org.codemc.worldguardwrapper.implementation.v6.flag;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.codemc.worldguardwrapper.flag.IWrappedFlag;
|
import org.codemc.worldguardwrapper.flag.IWrappedFlag;
|
||||||
|
|
|
@ -3,7 +3,6 @@ package org.codemc.worldguardwrapper.implementation.v6.region;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
|
@ -35,6 +35,46 @@
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
<artifactId>commandbook</artifactId>
|
<artifactId>commandbook</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sk89q</groupId>
|
||||||
|
<artifactId>dummypermscompat</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sk89q.intake</groupId>
|
||||||
|
<artifactId>intake</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sk89q</groupId>
|
||||||
|
<artifactId>squirrelid</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.khelekore</groupId>
|
||||||
|
<artifactId>prtree</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>net.sf.opencsv</groupId>
|
||||||
|
<artifactId>opencsv</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.googlecode.json-simple</groupId>
|
||||||
|
<artifactId>json-simple</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.flywaydb</groupId>
|
||||||
|
<artifactId>flyway-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>io.papermc</groupId>
|
||||||
|
<artifactId>paperlib</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.bstats.bStats-Metrics</groupId>
|
||||||
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.bstats</groupId>
|
||||||
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package org.codemc.worldguardwrapper.implementation.v7;
|
package org.codemc.worldguardwrapper.implementation.v7;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
@ -15,8 +14,8 @@ import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -32,37 +31,28 @@ import org.codemc.worldguardwrapper.region.IWrappedRegion;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
public class WorldGuardImplementation implements IWorldGuardImplementation {
|
public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||||
|
|
||||||
private final WorldGuard core;
|
private final WorldGuard core = WorldGuard.getInstance();
|
||||||
private final FlagRegistry flagRegistry;
|
private final FlagRegistry flagRegistry = core.getFlagRegistry();
|
||||||
private final WorldGuardPlugin plugin;
|
private final WorldGuardPlugin plugin = WorldGuardPlugin.inst();
|
||||||
|
|
||||||
public WorldGuardImplementation() {
|
|
||||||
core = WorldGuard.getInstance();
|
|
||||||
flagRegistry = core.getFlagRegistry();
|
|
||||||
plugin = WorldGuardPlugin.inst();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Optional<LocalPlayer> wrapPlayer(Player player) {
|
private Optional<LocalPlayer> wrapPlayer(Player player) {
|
||||||
return Optional.ofNullable(player).map(bukkitPlayer -> plugin.wrapPlayer(player));
|
return Optional.ofNullable(player).map(bukkitPlayer -> plugin.wrapPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<Player> getPlayer(LocalPlayer player) {
|
|
||||||
return Optional.ofNullable(Bukkit.getPlayer(player.getUniqueId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Optional<RegionManager> getWorldManager(@NonNull World world) {
|
private Optional<RegionManager> getWorldManager(@NonNull World world) {
|
||||||
return Optional.ofNullable(core.getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world)));
|
return Optional.ofNullable(core.getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<ApplicableRegionSet> getApplicableRegions(@NonNull Location location) {
|
private Optional<ApplicableRegionSet> getApplicableRegions(@NonNull Location location) {
|
||||||
return getWorldManager(location.getWorld()).map(manager -> manager.getApplicableRegions(BukkitAdapter.asVector(location)));
|
return getWorldManager(location.getWorld()).map(manager -> manager.getApplicableRegions(BukkitAdapter.asBlockVector(location)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<ApplicableRegionSet> getApplicableRegions(@NonNull Location minimum, @NonNull Location maximum) {
|
private Optional<ApplicableRegionSet> getApplicableRegions(@NonNull Location minimum, @NonNull Location maximum) {
|
||||||
return getWorldManager(minimum.getWorld()).map(manager -> manager.getApplicableRegions(
|
return getWorldManager(minimum.getWorld()).map(manager -> manager.getApplicableRegions(
|
||||||
new ProtectedCuboidRegion("temp", new BlockVector(BukkitAdapter.asVector(minimum)), new BlockVector(BukkitAdapter.asVector(maximum)))));
|
new ProtectedCuboidRegion("temp", BukkitAdapter.asBlockVector(minimum), BukkitAdapter.asBlockVector(maximum))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private <V> Optional<V> queryValue(Player player, @NonNull Location location, @NonNull Flag<V> flag) {
|
private <V> Optional<V> queryValue(Player player, @NonNull Location location, @NonNull Flag<V> flag) {
|
||||||
|
@ -70,11 +60,6 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||||
.orElse(null), flag));
|
.orElse(null), flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<StateFlag.State> queryState(Player player, @NonNull Location location, @NonNull StateFlag... stateFlags) {
|
|
||||||
return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryState(wrapPlayer(player)
|
|
||||||
.orElse(null), stateFlags));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JavaPlugin getWorldGuardPlugin() {
|
public JavaPlugin getWorldGuardPlugin() {
|
||||||
return WorldGuardPlugin.inst();
|
return WorldGuardPlugin.inst();
|
||||||
|
@ -177,11 +162,11 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||||
ProtectedRegion region;
|
ProtectedRegion region;
|
||||||
World world = points.get(0).getWorld();
|
World world = points.get(0).getWorld();
|
||||||
if (points.size() == 2) {
|
if (points.size() == 2) {
|
||||||
region = new ProtectedCuboidRegion(id, new BlockVector(BukkitAdapter.asVector(points.get(0))),
|
region = new ProtectedCuboidRegion(id, BukkitAdapter.asBlockVector(points.get(0)),
|
||||||
new BlockVector(BukkitAdapter.asVector(points.get(1))));
|
BukkitAdapter.asBlockVector(points.get(1)));
|
||||||
} else {
|
} else {
|
||||||
List<BlockVector2D> vectorPoints = points.stream()
|
List<BlockVector2> vectorPoints = points.stream()
|
||||||
.map(location -> new BlockVector2D(BukkitAdapter.asVector(location).toVector2D()))
|
.map(location -> BukkitAdapter.asBlockVector(location).toBlockVector2())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
region = new ProtectedPolygonalRegion(id, vectorPoints, minY, maxY);
|
region = new ProtectedPolygonalRegion(id, vectorPoints, minY, maxY);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.codemc.worldguardwrapper.implementation.v7.region;
|
package org.codemc.worldguardwrapper.implementation.v7.region;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
@ -34,7 +34,7 @@ public class WrappedRegion implements IWrappedRegion {
|
||||||
@Override
|
@Override
|
||||||
public Set<Location> getPoints() {
|
public Set<Location> getPoints() {
|
||||||
return handle.getPoints().stream()
|
return handle.getPoints().stream()
|
||||||
.map(BlockVector2D::toVector)
|
.map(BlockVector2::toBlockVector3)
|
||||||
.map(vector -> BukkitAdapter.adapt(world, vector))
|
.map(vector -> BukkitAdapter.adapt(world, vector))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ public class WrappedRegion implements IWrappedRegion {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Location location) {
|
public boolean contains(Location location) {
|
||||||
return handle.contains(BukkitAdapter.asVector(location));
|
return handle.contains(BukkitAdapter.asBlockVector(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
5
pom.xml
5
pom.xml
|
@ -149,10 +149,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.2.1</version>
|
||||||
<configuration>
|
|
||||||
<minimizeJar>false</minimizeJar>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user