mirror of
https://github.com/CodeMC/WorldGuardWrapper.git
synced 2024-11-10 05:05:20 +01:00
Fix build, maven enhancements
This commit is contained in:
parent
b54027de6d
commit
6642dce9c4
|
@ -28,6 +28,9 @@
|
|||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
<snapshots>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
|
|
@ -49,10 +49,6 @@
|
|||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.thoughtworks.paranamer</groupId>
|
||||
<artifactId>paranamer</artifactId>
|
||||
|
|
|
@ -7,10 +7,10 @@ import com.sk89q.worldguard.protection.events.DisallowedPVPEvent;
|
|||
import lombok.NoArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.codemc.worldguardwrapper.event.*;
|
||||
|
||||
@NoArgsConstructor
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.codemc.worldguardwrapper.implementation.v6.flag;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
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.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
|
|
|
@ -35,6 +35,46 @@
|
|||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>commandbook</artifactId>
|
||||
</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>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
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.BukkitWorld;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
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.ProtectedPolygonalRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -32,37 +31,28 @@ import org.codemc.worldguardwrapper.region.IWrappedRegion;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@NoArgsConstructor
|
||||
public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||
|
||||
private final WorldGuard core;
|
||||
private final FlagRegistry flagRegistry;
|
||||
private final WorldGuardPlugin plugin;
|
||||
|
||||
public WorldGuardImplementation() {
|
||||
core = WorldGuard.getInstance();
|
||||
flagRegistry = core.getFlagRegistry();
|
||||
plugin = WorldGuardPlugin.inst();
|
||||
}
|
||||
private final WorldGuard core = WorldGuard.getInstance();
|
||||
private final FlagRegistry flagRegistry = core.getFlagRegistry();
|
||||
private final WorldGuardPlugin plugin = WorldGuardPlugin.inst();
|
||||
|
||||
private Optional<LocalPlayer> wrapPlayer(Player 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) {
|
||||
return Optional.ofNullable(core.getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world)));
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
|
@ -70,11 +60,6 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
.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
|
||||
public JavaPlugin getWorldGuardPlugin() {
|
||||
return WorldGuardPlugin.inst();
|
||||
|
@ -177,11 +162,11 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
ProtectedRegion region;
|
||||
World world = points.get(0).getWorld();
|
||||
if (points.size() == 2) {
|
||||
region = new ProtectedCuboidRegion(id, new BlockVector(BukkitAdapter.asVector(points.get(0))),
|
||||
new BlockVector(BukkitAdapter.asVector(points.get(1))));
|
||||
region = new ProtectedCuboidRegion(id, BukkitAdapter.asBlockVector(points.get(0)),
|
||||
BukkitAdapter.asBlockVector(points.get(1)));
|
||||
} else {
|
||||
List<BlockVector2D> vectorPoints = points.stream()
|
||||
.map(location -> new BlockVector2D(BukkitAdapter.asVector(location).toVector2D()))
|
||||
List<BlockVector2> vectorPoints = points.stream()
|
||||
.map(location -> BukkitAdapter.asBlockVector(location).toBlockVector2())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
region = new ProtectedPolygonalRegion(id, vectorPoints, minY, maxY);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.codemc.worldguardwrapper.implementation.v7.region;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -34,7 +34,7 @@ public class WrappedRegion implements IWrappedRegion {
|
|||
@Override
|
||||
public Set<Location> getPoints() {
|
||||
return handle.getPoints().stream()
|
||||
.map(BlockVector2D::toVector)
|
||||
.map(BlockVector2::toBlockVector3)
|
||||
.map(vector -> BukkitAdapter.adapt(world, vector))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ public class WrappedRegion implements IWrappedRegion {
|
|||
|
||||
@Override
|
||||
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>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
</configuration>
|
||||
<version>3.2.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
|
Loading…
Reference in New Issue
Block a user