forked from clone/WorldGuardWrapper
Compare commits
No commits in common. "master" and "dependabot/add-v2-config-file" have entirely different histories.
master
...
dependabot
7
.github/dependabot.yml
vendored
Normal file
7
.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: maven
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -65,5 +65,8 @@ nbactions.xml
|
|||
nb-configuration.xml
|
||||
.nb-gradle/
|
||||
|
||||
# Git
|
||||
!.gitignore
|
||||
|
||||
# VSCode
|
||||
.vscode/
|
8
.travis.yml
Normal file
8
.travis.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
sudo: false
|
||||
dist: trusty
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
cache:
|
||||
directories:
|
||||
- '$HOME/.m2/repository'
|
|
@ -10,7 +10,6 @@ A wrapper for the WorldGuard API that allows plugins to support both v6 and v7 A
|
|||
How to include WorldEditWrapper into your maven project:
|
||||
|
||||
```xml
|
||||
<project>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
|
@ -22,10 +21,9 @@ How to include WorldEditWrapper into your maven project:
|
|||
<dependency>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper</artifactId>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
```
|
||||
|
||||
Remember to include/relocate the library into your final jar, example:
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
group 'org.codemc.worldguardwrapper'
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT'
|
||||
|
||||
compileOnly 'org.projectlombok:lombok:1.18.26'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.26'
|
||||
}
|
16
api/pom.xml
Normal file
16
api/pom.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-parent</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper-api</artifactId>
|
||||
|
||||
<name>WorldGuardWrapper-API</name>
|
||||
</project>
|
|
@ -1,7 +1,6 @@
|
|||
package org.codemc.worldguardwrapper.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -21,12 +20,10 @@ public class WrappedDamageEntityEvent extends AbstractWrappedEvent {
|
|||
private final Entity entity;
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.codemc.worldguardwrapper.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
@ -18,12 +17,10 @@ public class WrappedDisallowedPVPEvent extends AbstractWrappedEvent {
|
|||
private final Event cause;
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.codemc.worldguardwrapper.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
@ -25,12 +24,10 @@ public class WrappedUseBlockEvent extends AbstractWrappedEvent {
|
|||
private final Material effectiveMaterial;
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.codemc.worldguardwrapper.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -21,12 +20,10 @@ public class WrappedUseEntityEvent extends AbstractWrappedEvent {
|
|||
private final Entity entity;
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.codemc.worldguardwrapper.flag;
|
|||
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IWrappedFlag<T> {
|
||||
|
||||
String getName();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package org.codemc.worldguardwrapper.flag;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IWrappedStatusFlag extends IWrappedFlag<WrappedState> {
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.codemc.worldguardwrapper.flag;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public enum WrappedState {
|
||||
ALLOW,
|
||||
DENY;
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package org.codemc.worldguardwrapper.handler;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.codemc.worldguardwrapper.flag.WrappedState;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegion;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegionSet;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IHandler {
|
||||
|
||||
default void initialize(Player player, Location current, IWrappedRegionSet regionSet) {
|
||||
}
|
||||
|
||||
default boolean testMoveTo(
|
||||
Player player,
|
||||
Location from,
|
||||
Location to,
|
||||
IWrappedRegionSet regionSet,
|
||||
String moveType
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean onCrossBoundary(
|
||||
Player player,
|
||||
Location from,
|
||||
Location to,
|
||||
IWrappedRegionSet toSet,
|
||||
Set<IWrappedRegion> entered,
|
||||
Set<IWrappedRegion> exited,
|
||||
String moveType
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
default void tick(Player player, IWrappedRegionSet regionSet) {
|
||||
}
|
||||
|
||||
default WrappedState getInvincibility(Player player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,17 +6,13 @@ import org.bukkit.World;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.codemc.worldguardwrapper.flag.IWrappedFlag;
|
||||
import org.codemc.worldguardwrapper.handler.IHandler;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegion;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegionSet;
|
||||
import org.codemc.worldguardwrapper.selection.ICuboidSelection;
|
||||
import org.codemc.worldguardwrapper.selection.IPolygonalSelection;
|
||||
import org.codemc.worldguardwrapper.selection.ISelection;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IWorldGuardImplementation {
|
||||
|
||||
/**
|
||||
|
@ -33,8 +29,6 @@ public interface IWorldGuardImplementation {
|
|||
*/
|
||||
int getApiVersion();
|
||||
|
||||
void registerHandler(Supplier<IHandler> factory);
|
||||
|
||||
/**
|
||||
* Query a flag's value for a given player at a given location.
|
||||
*
|
||||
|
@ -59,7 +53,7 @@ public interface IWorldGuardImplementation {
|
|||
*
|
||||
* @param name The flag name
|
||||
* @param type The flag type
|
||||
* @return The flag, empty if it doesn't exist
|
||||
* @return The flag, empty if it doesn't exists
|
||||
*/
|
||||
<T> Optional<IWrappedFlag<T>> getFlag(String name, Class<T> type);
|
||||
|
||||
|
@ -123,14 +117,6 @@ public interface IWorldGuardImplementation {
|
|||
*/
|
||||
Set<IWrappedRegion> getRegions(@NonNull Location minimum, @NonNull Location maximum);
|
||||
|
||||
/**
|
||||
* Get the applicable region set at the given location-
|
||||
*
|
||||
* @param location The location
|
||||
* @return The region set
|
||||
*/
|
||||
Optional<IWrappedRegionSet> getRegionSet(@NonNull Location location);
|
||||
|
||||
/**
|
||||
* Add a region. If only two points are given, a cuboid region will be created.
|
||||
*
|
||||
|
@ -150,11 +136,7 @@ public interface IWorldGuardImplementation {
|
|||
* @param point2 The second point of the region
|
||||
* @return The added region
|
||||
*/
|
||||
default Optional<IWrappedRegion> addCuboidRegion(
|
||||
@NonNull String id,
|
||||
@NonNull Location point1,
|
||||
@NonNull Location point2
|
||||
) {
|
||||
default Optional<IWrappedRegion> addCuboidRegion(@NonNull String id, @NonNull Location point1, @NonNull Location point2) {
|
||||
return addRegion(id, Arrays.asList(point1, point2), 0, 0);
|
||||
}
|
||||
|
||||
|
@ -173,8 +155,7 @@ public interface IWorldGuardImplementation {
|
|||
IPolygonalSelection sel = (IPolygonalSelection) selection;
|
||||
return addRegion(id, new ArrayList<>(sel.getPoints()), sel.getMinimumY(), sel.getMaximumY());
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unknown " + selection.getClass().getSimpleName()
|
||||
+ " selection type!");
|
||||
throw new UnsupportedOperationException("Unknown " + selection.getClass().getSimpleName() + " selection type!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.codemc.worldguardwrapper.region;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IWrappedDomain {
|
||||
|
||||
Set<UUID> getPlayers();
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.codemc.worldguardwrapper.selection.ISelection;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IWrappedRegion {
|
||||
|
||||
ISelection getSelection();
|
||||
|
@ -22,8 +21,6 @@ public interface IWrappedRegion {
|
|||
|
||||
int getPriority();
|
||||
|
||||
void setPriority(int priority);
|
||||
|
||||
IWrappedDomain getOwners();
|
||||
|
||||
IWrappedDomain getMembers();
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package org.codemc.worldguardwrapper.region;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.codemc.worldguardwrapper.flag.IWrappedFlag;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IWrappedRegionSet extends Iterable<IWrappedRegion> {
|
||||
|
||||
boolean isVirtual();
|
||||
|
||||
<V> Optional<V> queryValue(OfflinePlayer subject, IWrappedFlag<V> flag);
|
||||
|
||||
<V> Collection<V> queryAllValues(OfflinePlayer subject, IWrappedFlag<V> flag);
|
||||
|
||||
boolean isOwnerOfAll(OfflinePlayer player);
|
||||
|
||||
boolean isMemberOfAll(OfflinePlayer player);
|
||||
|
||||
int size();
|
||||
|
||||
Set<IWrappedRegion> getRegions();
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@ package org.codemc.worldguardwrapper.selection;
|
|||
|
||||
import org.bukkit.Location;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface ICuboidSelection extends ISelection {
|
||||
|
||||
Location getMinimumPoint();
|
||||
|
|
|
@ -2,13 +2,11 @@ package org.codemc.worldguardwrapper.selection;
|
|||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IPolygonalSelection extends ISelection {
|
||||
|
||||
List<Location> getPoints();
|
||||
Set<Location> getPoints();
|
||||
|
||||
int getMinimumY();
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package org.codemc.worldguardwrapper.selection;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface ISelection {
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ import org.bukkit.Location;
|
|||
import org.codemc.worldguardwrapper.selection.ICuboidSelection;
|
||||
import org.codemc.worldguardwrapper.selection.IPolygonalSelection;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@UtilityClass
|
||||
public class SelectionUtilities {
|
||||
|
||||
|
@ -53,9 +53,8 @@ public class SelectionUtilities {
|
|||
public IPolygonalSelection createPolygonalSelection(Collection<Location> points, int minY, int maxY) {
|
||||
return new IPolygonalSelection() {
|
||||
@Override
|
||||
public List<Location> getPoints() {
|
||||
//recoreHosting -> set to list , maintains order but remove duplicates
|
||||
return new ArrayList<>(points).stream().distinct().collect(Collectors.toList());
|
||||
public Set<Location> getPoints() {
|
||||
return new HashSet<>(points);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
22
build.gradle
22
build.gradle
|
@ -1,22 +0,0 @@
|
|||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.0.0" apply false
|
||||
}
|
||||
|
||||
group 'org.codemc.worldguardwrapper'
|
||||
version '1.2.1-SNAPSHOT'
|
||||
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
group = parent.group
|
||||
version = parent.version
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "https://maven.enginehub.org/repo/" }
|
||||
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
|
||||
}
|
||||
}
|
||||
|
7
gradle/wrapper/gradle-wrapper.properties
vendored
7
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,7 +0,0 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
249
gradlew
vendored
249
gradlew
vendored
|
@ -1,249 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
92
gradlew.bat
vendored
92
gradlew.bat
vendored
|
@ -1,92 +0,0 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -1,5 +0,0 @@
|
|||
dependencies {
|
||||
api project(':implementation:v7')
|
||||
api project(':implementation:v6')
|
||||
api project(':implementation:legacy')
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
group 'org.codemc.worldguardwrapper.implementation.legacy'
|
||||
|
||||
dependencies {
|
||||
api project(':api')
|
||||
compileOnly 'org.spigotmc:spigot-api:1.12.1-R0.1-SNAPSHOT'
|
||||
compileOnly 'com.sk89q:worldguard:6.1.1-SNAPSHOT'
|
||||
|
||||
compileOnly 'org.projectlombok:lombok:1.18.26'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.26'
|
||||
}
|
41
implementation/legacy/pom.xml
Normal file
41
implementation/legacy/pom.xml
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-implementation</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper-implementation-legacy</artifactId>
|
||||
|
||||
<name>WorldGuardWrapper-Implementation-Legacy</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
<snapshots>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-api</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,6 +1,5 @@
|
|||
package org.codemc.worldguardwrapper.implementation.legacy;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
|
@ -17,25 +16,21 @@ import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
|||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.codemc.worldguardwrapper.flag.IWrappedFlag;
|
||||
import org.codemc.worldguardwrapper.handler.IHandler;
|
||||
import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation;
|
||||
import org.codemc.worldguardwrapper.implementation.legacy.flag.AbstractWrappedFlag;
|
||||
import org.codemc.worldguardwrapper.implementation.legacy.region.WrappedRegion;
|
||||
import org.codemc.worldguardwrapper.implementation.legacy.utility.WorldGuardFlagUtilities;
|
||||
import org.codemc.worldguardwrapper.implementation.legacy.utility.WorldGuardVectorUtilities;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegion;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegionSet;
|
||||
import org.codemc.worldguardwrapper.selection.ICuboidSelection;
|
||||
import org.codemc.worldguardwrapper.selection.IPolygonalSelection;
|
||||
import org.codemc.worldguardwrapper.selection.ISelection;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||
|
@ -52,9 +47,8 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
}
|
||||
|
||||
private Optional<LocalPlayer> wrapPlayer(OfflinePlayer player) {
|
||||
return Optional.ofNullable(player).map(bukkitPlayer -> bukkitPlayer.isOnline() ?
|
||||
worldGuardPlugin.wrapPlayer((Player) bukkitPlayer) : worldGuardPlugin.wrapOfflinePlayer(bukkitPlayer));
|
||||
private Optional<LocalPlayer> wrapPlayer(Player player) {
|
||||
return Optional.ofNullable(player).map(bukkitPlayer -> worldGuardPlugin.wrapPlayer(player));
|
||||
}
|
||||
|
||||
private Optional<RegionManager> getWorldManager(@NonNull World world) {
|
||||
|
@ -62,83 +56,17 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
private Optional<ApplicableRegionSet> getApplicableRegions(@NonNull Location location) {
|
||||
return getWorldManager(Objects.requireNonNull(location.getWorld()))
|
||||
.map(manager -> manager.getApplicableRegions(location));
|
||||
return getWorldManager(location.getWorld()).map(manager -> manager.getApplicableRegions(location));
|
||||
}
|
||||
|
||||
private Optional<ApplicableRegionSet> getApplicableRegions(@NonNull Location minimum, @NonNull Location maximum) {
|
||||
return getWorldManager(Objects.requireNonNull(minimum.getWorld()))
|
||||
.map(manager ->
|
||||
manager.getApplicableRegions(
|
||||
new ProtectedCuboidRegion(
|
||||
"temp",
|
||||
WorldGuardVectorUtilities.toBlockVector(minimum),
|
||||
WorldGuardVectorUtilities.toBlockVector(maximum)
|
||||
)
|
||||
)
|
||||
);
|
||||
return getWorldManager(minimum.getWorld()).map(manager -> manager.getApplicableRegions(
|
||||
new ProtectedCuboidRegion("temp", WorldGuardVectorUtilities.toBlockVector(minimum), WorldGuardVectorUtilities.toBlockVector(maximum))));
|
||||
}
|
||||
|
||||
private <V> Optional<V> queryValue(Player player, @NonNull Location location, @NonNull Flag<V> flag) {
|
||||
return getApplicableRegions(location)
|
||||
.map(applicableRegions -> applicableRegions.queryValue(wrapPlayer(player).orElse(null), flag));
|
||||
}
|
||||
|
||||
private IWrappedRegionSet wrapRegionSet(@NonNull World world, @NonNull ApplicableRegionSet regionSet) {
|
||||
return new IWrappedRegionSet() {
|
||||
|
||||
@Override
|
||||
public Iterator<IWrappedRegion> iterator() {
|
||||
return Iterators.transform(regionSet.iterator(), region -> new WrappedRegion(world, region));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVirtual() {
|
||||
return regionSet.isVirtual();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> Optional<V> queryValue(OfflinePlayer subject, IWrappedFlag<V> flag) {
|
||||
LocalPlayer subjectHandle = wrapPlayer(subject).orElse(null);
|
||||
AbstractWrappedFlag<V> wrappedFlag = (AbstractWrappedFlag<V>) flag;
|
||||
return Optional.ofNullable(regionSet.queryValue(subjectHandle, wrappedFlag.getHandle()))
|
||||
.flatMap(wrappedFlag::fromWGValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> Collection<V> queryAllValues(OfflinePlayer subject, IWrappedFlag<V> flag) {
|
||||
LocalPlayer subjectHandle = wrapPlayer(subject).orElse(null);
|
||||
AbstractWrappedFlag<V> wrappedFlag = (AbstractWrappedFlag<V>) flag;
|
||||
return regionSet.queryAllValues(subjectHandle, wrappedFlag.getHandle()).stream()
|
||||
.map(wrappedFlag::fromWGValue)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOwnerOfAll(OfflinePlayer player) {
|
||||
LocalPlayer playerHandle = wrapPlayer(player).orElse(null);
|
||||
return regionSet.isOwnerOfAll(playerHandle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMemberOfAll(OfflinePlayer player) {
|
||||
LocalPlayer playerHandle = wrapPlayer(player).orElse(null);
|
||||
return regionSet.isMemberOfAll(playerHandle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return regionSet.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IWrappedRegion> getRegions() {
|
||||
return regionSet.getRegions().stream()
|
||||
.map(region -> new WrappedRegion(world, region)).collect(Collectors.toSet());
|
||||
}
|
||||
};
|
||||
return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryValue(wrapPlayer(player)
|
||||
.orElse(null), flag));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,11 +79,6 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
return -6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandler(Supplier<IHandler> factory) {
|
||||
throw new UnsupportedOperationException("Custom flag handlers aren't supported in this version of WorldGuard!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<IWrappedFlag<T>> getFlag(String name, Class<T> type) {
|
||||
for (Flag<?> currentFlag : DefaultFlag.getFlags()) {
|
||||
|
@ -167,10 +90,9 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> queryFlag(Player player, @NonNull Location location, @NonNull IWrappedFlag<T> flag) {
|
||||
public <T> Optional<T> queryFlag(Player player, Location location, IWrappedFlag<T> flag) {
|
||||
AbstractWrappedFlag<T> wrappedFlag = (AbstractWrappedFlag<T>) flag;
|
||||
|
||||
return queryValue(player, location, wrappedFlag.getHandle()).flatMap(wrappedFlag::fromWGValue);
|
||||
return queryValue(player, location, wrappedFlag.getHandle()).flatMap(value -> wrappedFlag.fromWGValue(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -196,7 +118,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
Map.Entry<IWrappedFlag<?>, Object> wrapped = WorldGuardFlagUtilities.wrap(flag, value);
|
||||
flags.put(wrapped.getKey(), wrapped.getValue());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Unsupported flag type
|
||||
continue; // Unsupported flag type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,19 +128,19 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<IWrappedFlag<T>> registerFlag(@NonNull String name, @NonNull Class<T> type, T defaultValue) {
|
||||
public <T> Optional<IWrappedFlag<T>> registerFlag(String name, Class<T> type, T defaultValue) {
|
||||
throw new UnsupportedOperationException("Custom flags aren't supported in this version of WorldGuard!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<IWrappedRegion> getRegion(@NonNull World world, @NonNull String id) {
|
||||
public Optional<IWrappedRegion> getRegion(World world, String id) {
|
||||
return getWorldManager(world)
|
||||
.map(regionManager -> regionManager.getRegion(id))
|
||||
.map(region -> new WrappedRegion(world, region));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, IWrappedRegion> getRegions(@NonNull World world) {
|
||||
public Map<String, IWrappedRegion> getRegions(World world) {
|
||||
RegionManager regionManager = worldGuardPlugin.getRegionManager(world);
|
||||
Map<String, ProtectedRegion> regions = regionManager.getRegions();
|
||||
|
||||
|
@ -229,7 +151,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<IWrappedRegion> getRegions(@NonNull Location location) {
|
||||
public Set<IWrappedRegion> getRegions(Location location) {
|
||||
ApplicableRegionSet regionSet = getApplicableRegions(location).orElse(null);
|
||||
Set<IWrappedRegion> set = new HashSet<>();
|
||||
|
||||
|
@ -242,7 +164,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<IWrappedRegion> getRegions(@NonNull Location minimum, @NonNull Location maximum) {
|
||||
public Set<IWrappedRegion> getRegions(Location minimum, Location maximum) {
|
||||
ApplicableRegionSet regionSet = getApplicableRegions(minimum, maximum).orElse(null);
|
||||
Set<IWrappedRegion> set = new HashSet<>();
|
||||
|
||||
|
@ -255,28 +177,13 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<IWrappedRegionSet> getRegionSet(@NonNull Location location) {
|
||||
return getApplicableRegions(location)
|
||||
.map(regionSet -> wrapRegionSet(Objects.requireNonNull(location.getWorld()), regionSet));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<IWrappedRegion> addRegion(@NonNull String id, @NonNull List<Location> points, int minY, int maxY) {
|
||||
public Optional<IWrappedRegion> addRegion(String id, List<Location> points, int minY, int maxY) {
|
||||
ProtectedRegion region;
|
||||
World world = Objects.requireNonNull(points.get(0).getWorld());
|
||||
World world = points.get(0).getWorld();
|
||||
if (points.size() == 2) {
|
||||
region = new ProtectedCuboidRegion(
|
||||
id,
|
||||
WorldGuardVectorUtilities.toBlockVector(points.get(0)),
|
||||
WorldGuardVectorUtilities.toBlockVector(points.get(1))
|
||||
);
|
||||
region = new ProtectedCuboidRegion(id, WorldGuardVectorUtilities.toBlockVector(points.get(0)), WorldGuardVectorUtilities.toBlockVector(points.get(1)));
|
||||
} else {
|
||||
region = new ProtectedPolygonalRegion(
|
||||
id,
|
||||
WorldGuardVectorUtilities.toBlockVector2DList(points),
|
||||
minY,
|
||||
maxY
|
||||
);
|
||||
region = new ProtectedPolygonalRegion(id, WorldGuardVectorUtilities.toBlockVector2DList(points), minY, maxY);
|
||||
}
|
||||
|
||||
Optional<RegionManager> manager = getWorldManager(world);
|
||||
|
@ -289,7 +196,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<Set<IWrappedRegion>> removeRegion(@NonNull World world, @NonNull String id) {
|
||||
public Optional<Set<IWrappedRegion>> removeRegion(World world, String id) {
|
||||
Optional<Set<ProtectedRegion>> set = getWorldManager(world).map(manager -> manager.removeRegion(id));
|
||||
return set.map(protectedRegions -> protectedRegions.stream().map(region -> new WrappedRegion(world, region))
|
||||
.collect(Collectors.toSet()));
|
||||
|
@ -314,17 +221,11 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
} else if (selection instanceof Polygonal2DSelection) {
|
||||
return new IPolygonalSelection() {
|
||||
@Override
|
||||
public List<Location> getPoints() {
|
||||
public Set<Location> getPoints() {
|
||||
return ((Polygonal2DSelection) selection).getNativePoints().stream()
|
||||
.distinct()
|
||||
.map(vector -> new BlockVector(vector.toVector()))
|
||||
.map(vector ->
|
||||
WorldGuardVectorUtilities.fromBlockVector(
|
||||
selection.getWorld(),
|
||||
vector
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
.map(vector -> WorldGuardVectorUtilities.fromBlockVector(selection.getWorld(), vector))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -338,8 +239,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
};
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unsupported " + selection.getClass().getSimpleName()
|
||||
+ " selection!");
|
||||
throw new UnsupportedOperationException("Unsupported " + selection.getClass().getSimpleName() + " selection!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.codemc.worldguardwrapper.implementation.legacy.flag;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.codemc.worldguardwrapper.implementation.legacy.utility.WorldGuardFlagUtilities;
|
||||
|
|
|
@ -10,16 +10,20 @@ import lombok.Getter;
|
|||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.codemc.worldguardwrapper.flag.IWrappedFlag;
|
||||
import org.codemc.worldguardwrapper.implementation.legacy.flag.AbstractWrappedFlag;
|
||||
import org.codemc.worldguardwrapper.implementation.legacy.utility.WorldGuardFlagUtilities;
|
||||
import org.codemc.worldguardwrapper.implementation.legacy.utility.WorldGuardVectorUtilities;
|
||||
import org.codemc.worldguardwrapper.implementation.legacy.flag.AbstractWrappedFlag;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedDomain;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegion;
|
||||
import org.codemc.worldguardwrapper.selection.ICuboidSelection;
|
||||
import org.codemc.worldguardwrapper.selection.IPolygonalSelection;
|
||||
import org.codemc.worldguardwrapper.selection.ISelection;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@AllArgsConstructor
|
||||
|
@ -46,12 +50,11 @@ public class WrappedRegion implements IWrappedRegion {
|
|||
} else if (handle instanceof ProtectedPolygonalRegion) {
|
||||
return new IPolygonalSelection() {
|
||||
@Override
|
||||
public List<Location> getPoints() {
|
||||
public Set<Location> getPoints() {
|
||||
return handle.getPoints().stream()
|
||||
.distinct()
|
||||
.map(vector -> new BlockVector(vector.toVector()))
|
||||
.map(vector -> WorldGuardVectorUtilities.fromBlockVector(world, vector))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,11 +111,6 @@ public class WrappedRegion implements IWrappedRegion {
|
|||
return handle.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int priority) {
|
||||
handle.setPriority(priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWrappedDomain getOwners() {
|
||||
return new IWrappedDomain() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.google.common.collect.Maps;
|
|||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
@ -15,6 +15,8 @@ import org.codemc.worldguardwrapper.implementation.legacy.flag.AbstractWrappedFl
|
|||
import org.codemc.worldguardwrapper.implementation.legacy.flag.WrappedPrimitiveFlag;
|
||||
import org.codemc.worldguardwrapper.implementation.legacy.flag.WrappedStatusFlag;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@UtilityClass
|
||||
|
@ -40,8 +42,6 @@ public class WorldGuardFlagUtilities {
|
|||
wrappedFlag = new WrappedPrimitiveFlag(flag);
|
||||
} else if (type.equals(Vector.class)) {
|
||||
wrappedFlag = new WrappedPrimitiveFlag(flag);
|
||||
} else if (type.equals(Object.class)) {
|
||||
wrappedFlag = new WrappedPrimitiveFlag(flag);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported flag type " + type.getName());
|
||||
}
|
||||
|
@ -66,8 +66,7 @@ public class WorldGuardFlagUtilities {
|
|||
|
||||
public Map.Entry<IWrappedFlag<?>, Object> wrap(Flag<?> flag, Object value) {
|
||||
IWrappedFlag<?> wrappedFlag = wrapFixType(flag, value.getClass());
|
||||
Object wrappedValue = ((AbstractWrappedFlag<?>) wrappedFlag).fromWGValue(value)
|
||||
.orElseThrow(NullPointerException::new); // value should never be null
|
||||
Object wrappedValue = ((AbstractWrappedFlag<?>) wrappedFlag).fromWGValue(value).get(); // value is non-null
|
||||
return Maps.immutableEntry(wrappedFlag, wrappedValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,7 @@ public class WorldGuardVectorUtilities {
|
|||
}
|
||||
|
||||
public List<BlockVector2D> toBlockVector2DList(List<Location> locations) {
|
||||
return locations.stream()
|
||||
.map(location -> new BlockVector2D(location.getX(), location.getZ()))
|
||||
.collect(Collectors.toList());
|
||||
return locations.stream().map(location -> new BlockVector2D(location.getX(), location.getZ())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
27
implementation/pom.xml
Normal file
27
implementation/pom.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-parent</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper-implementation</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>legacy</module>
|
||||
<module>v6</module>
|
||||
<module>v7</module>
|
||||
</modules>
|
||||
|
||||
<name>WorldGuardWrapper-Implementation</name>
|
||||
|
||||
<properties>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
</properties>
|
||||
</project>
|
|
@ -1,14 +0,0 @@
|
|||
group 'org.codemc.worldguardwrapper.implementation.legacy'
|
||||
|
||||
dependencies {
|
||||
api project(':api')
|
||||
|
||||
compileOnly 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT'
|
||||
compileOnly 'com.sk89q.worldguard:worldguard-legacy:6.2'
|
||||
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:6.1.5'
|
||||
compileOnly 'com.sk89q.worldedit:worldedit-core:6.1.3-SNAPSHOT'
|
||||
compileOnly 'org.javassist:javassist:3.29.2-GA'
|
||||
|
||||
compileOnly 'org.projectlombok:lombok:1.18.26'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.26'
|
||||
}
|
87
implementation/v6/pom.xml
Normal file
87
implementation/v6/pom.xml
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-implementation</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper-implementation-v6</artifactId>
|
||||
|
||||
<name>WorldGuardWrapper-Implementation-V6</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
<snapshots>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-api</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-legacy</artifactId>
|
||||
<version>6.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>6.1.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-core</artifactId>
|
||||
<version>6.1.4-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>de.schlichtherle</groupId>
|
||||
<artifactId>truezip</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>rhino</groupId>
|
||||
<artifactId>js</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.thoughtworks.paranamer</groupId>
|
||||
<artifactId>paranamer</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.lib</groupId>
|
||||
<artifactId>jlibnoise</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>jchronic</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,6 +1,5 @@
|
|||
package org.codemc.worldguardwrapper.implementation.v6;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
|
@ -16,35 +15,25 @@ 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 com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
import javassist.util.proxy.ProxyFactory;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.codemc.worldguardwrapper.flag.IWrappedFlag;
|
||||
import org.codemc.worldguardwrapper.flag.WrappedState;
|
||||
import org.codemc.worldguardwrapper.handler.IHandler;
|
||||
import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation;
|
||||
import org.codemc.worldguardwrapper.implementation.v6.flag.AbstractWrappedFlag;
|
||||
import org.codemc.worldguardwrapper.implementation.v6.handler.ProxyHandler;
|
||||
import org.codemc.worldguardwrapper.implementation.v6.region.WrappedRegion;
|
||||
import org.codemc.worldguardwrapper.implementation.v6.utility.WorldGuardFlagUtilities;
|
||||
import org.codemc.worldguardwrapper.implementation.v6.utility.WorldGuardVectorUtilities;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegion;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegionSet;
|
||||
import org.codemc.worldguardwrapper.selection.ICuboidSelection;
|
||||
import org.codemc.worldguardwrapper.selection.IPolygonalSelection;
|
||||
import org.codemc.worldguardwrapper.selection.ISelection;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||
|
@ -63,13 +52,8 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
flagRegistry = worldGuardPlugin.getFlagRegistry();
|
||||
}
|
||||
|
||||
private Optional<LocalPlayer> wrapPlayer(OfflinePlayer player) {
|
||||
return Optional.ofNullable(player).map(bukkitPlayer -> {
|
||||
if (bukkitPlayer.isOnline()) {
|
||||
return worldGuardPlugin.wrapPlayer((Player) bukkitPlayer);
|
||||
}
|
||||
return worldGuardPlugin.wrapOfflinePlayer(bukkitPlayer);
|
||||
});
|
||||
private Optional<LocalPlayer> wrapPlayer(Player player) {
|
||||
return Optional.ofNullable(player).map(bukkitPlayer -> worldGuardPlugin.wrapPlayer(player));
|
||||
}
|
||||
|
||||
private Optional<RegionManager> getWorldManager(@NonNull World world) {
|
||||
|
@ -77,83 +61,17 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
private Optional<ApplicableRegionSet> getApplicableRegions(@NonNull Location location) {
|
||||
return getWorldManager(Objects.requireNonNull(location.getWorld()))
|
||||
.map(manager -> manager.getApplicableRegions(location));
|
||||
return getWorldManager(location.getWorld()).map(manager -> manager.getApplicableRegions(location));
|
||||
}
|
||||
|
||||
private Optional<ApplicableRegionSet> getApplicableRegions(@NonNull Location minimum, @NonNull Location maximum) {
|
||||
return getWorldManager(Objects.requireNonNull(minimum.getWorld()))
|
||||
.map(manager -> manager.getApplicableRegions(
|
||||
new ProtectedCuboidRegion(
|
||||
"temp",
|
||||
WorldGuardVectorUtilities.toBlockVector(minimum),
|
||||
WorldGuardVectorUtilities.toBlockVector(maximum)
|
||||
)
|
||||
));
|
||||
return getWorldManager(minimum.getWorld()).map(manager -> manager.getApplicableRegions(
|
||||
new ProtectedCuboidRegion("temp", WorldGuardVectorUtilities.toBlockVector(minimum), WorldGuardVectorUtilities.toBlockVector(maximum))));
|
||||
}
|
||||
|
||||
private <V> Optional<V> queryValue(Player player, @NonNull Location location, @NonNull Flag<V> flag) {
|
||||
return getApplicableRegions(location)
|
||||
.map(applicableRegions -> applicableRegions.queryValue(wrapPlayer(player).orElse(null), flag));
|
||||
}
|
||||
|
||||
public IWrappedRegionSet wrapRegionSet(@NonNull World world, @NonNull ApplicableRegionSet regionSet) {
|
||||
return new IWrappedRegionSet() {
|
||||
|
||||
@Override
|
||||
public Iterator<IWrappedRegion> iterator() {
|
||||
return Iterators.transform(regionSet.iterator(), region -> new WrappedRegion(world, region));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVirtual() {
|
||||
return regionSet.isVirtual();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> Optional<V> queryValue(OfflinePlayer subject, IWrappedFlag<V> flag) {
|
||||
LocalPlayer subjectHandle = wrapPlayer(subject).orElse(null);
|
||||
AbstractWrappedFlag<V> wrappedFlag = (AbstractWrappedFlag<V>) flag;
|
||||
return Optional.ofNullable(regionSet.queryValue(subjectHandle, wrappedFlag.getHandle()))
|
||||
.flatMap(wrappedFlag::fromWGValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> Collection<V> queryAllValues(OfflinePlayer subject, IWrappedFlag<V> flag) {
|
||||
LocalPlayer subjectHandle = wrapPlayer(subject).orElse(null);
|
||||
AbstractWrappedFlag<V> wrappedFlag = (AbstractWrappedFlag<V>) flag;
|
||||
return regionSet.queryAllValues(subjectHandle, wrappedFlag.getHandle()).stream()
|
||||
.map(wrappedFlag::fromWGValue)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOwnerOfAll(OfflinePlayer player) {
|
||||
LocalPlayer playerHandle = wrapPlayer(player).orElse(null);
|
||||
return regionSet.isOwnerOfAll(playerHandle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMemberOfAll(OfflinePlayer player) {
|
||||
LocalPlayer playerHandle = wrapPlayer(player).orElse(null);
|
||||
return regionSet.isMemberOfAll(playerHandle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return regionSet.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IWrappedRegion> getRegions() {
|
||||
return regionSet.getRegions()
|
||||
.stream()
|
||||
.map(region -> new WrappedRegion(world, region))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
};
|
||||
return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryValue(wrapPlayer(player)
|
||||
.orElse(null), flag));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,39 +84,6 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandler(Supplier<IHandler> factory) {
|
||||
ProxyFactory proxyFactory = new ProxyFactory();
|
||||
proxyFactory.setUseCache(false);
|
||||
proxyFactory.setSuperclass(ProxyHandler.class);
|
||||
|
||||
Class<? extends ProxyHandler> handlerClass;
|
||||
Constructor<? extends ProxyHandler> handlerConstructor;
|
||||
try {
|
||||
//noinspection unchecked
|
||||
handlerClass = (Class<? extends ProxyHandler>) proxyFactory.createClass();
|
||||
handlerConstructor = handlerClass.getDeclaredConstructor(
|
||||
WorldGuardImplementation.class,
|
||||
IHandler.class,
|
||||
Session.class
|
||||
);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
worldGuardPlugin.getSessionManager().registerHandler(new Handler.Factory<Handler>() {
|
||||
@Override
|
||||
public Handler create(Session session) {
|
||||
IHandler handler = factory.get();
|
||||
try {
|
||||
return handlerConstructor.newInstance(WorldGuardImplementation.this, handler, session);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<IWrappedFlag<T>> getFlag(String name, Class<T> type) {
|
||||
return Optional.ofNullable(flagRegistry.get(name))
|
||||
|
@ -206,9 +91,9 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> queryFlag(Player player, @NonNull Location location, @NonNull IWrappedFlag<T> flag) {
|
||||
public <T> Optional<T> queryFlag(Player player, Location location, IWrappedFlag<T> flag) {
|
||||
AbstractWrappedFlag<T> wrappedFlag = (AbstractWrappedFlag<T>) flag;
|
||||
return queryValue(player, location, wrappedFlag.getHandle()).flatMap(wrappedFlag::fromWGValue);
|
||||
return queryValue(player, location, wrappedFlag.getHandle()).flatMap(value -> wrappedFlag.fromWGValue(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -234,7 +119,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
Map.Entry<IWrappedFlag<?>, Object> wrapped = WorldGuardFlagUtilities.wrap(flag, value);
|
||||
flags.put(wrapped.getKey(), wrapped.getValue());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Unsupported flag type
|
||||
continue; // Unsupported flag type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -243,9 +128,9 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
return flags;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> Optional<IWrappedFlag<T>> registerFlag(@NonNull String name, @NonNull Class<T> type, T defaultValue) {
|
||||
public <T> Optional<IWrappedFlag<T>> registerFlag(String name, Class<T> type, T defaultValue) {
|
||||
final Flag<?> flag;
|
||||
if (type.equals(WrappedState.class)) {
|
||||
flag = new StateFlag(name, defaultValue == WrappedState.ALLOW);
|
||||
|
@ -275,14 +160,14 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<IWrappedRegion> getRegion(@NonNull World world, @NonNull String id) {
|
||||
public Optional<IWrappedRegion> getRegion(World world, String id) {
|
||||
return getWorldManager(world)
|
||||
.map(regionManager -> regionManager.getRegion(id))
|
||||
.map(region -> new WrappedRegion(world, region));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, IWrappedRegion> getRegions(@NonNull World world) {
|
||||
public Map<String, IWrappedRegion> getRegions(World world) {
|
||||
RegionManager regionManager = worldGuardPlugin.getRegionManager(world);
|
||||
Map<String, ProtectedRegion> regions = regionManager.getRegions();
|
||||
|
||||
|
@ -293,7 +178,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<IWrappedRegion> getRegions(@NonNull Location location) {
|
||||
public Set<IWrappedRegion> getRegions(Location location) {
|
||||
ApplicableRegionSet regionSet = getApplicableRegions(location).orElse(null);
|
||||
Set<IWrappedRegion> set = new HashSet<>();
|
||||
|
||||
|
@ -306,7 +191,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<IWrappedRegion> getRegions(@NonNull Location minimum, @NonNull Location maximum) {
|
||||
public Set<IWrappedRegion> getRegions(Location minimum, Location maximum) {
|
||||
ApplicableRegionSet regionSet = getApplicableRegions(minimum, maximum).orElse(null);
|
||||
Set<IWrappedRegion> set = new HashSet<>();
|
||||
|
||||
|
@ -319,28 +204,13 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<IWrappedRegionSet> getRegionSet(@NonNull Location location) {
|
||||
return getApplicableRegions(location)
|
||||
.map(regionSet -> wrapRegionSet(Objects.requireNonNull(location.getWorld()), regionSet));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<IWrappedRegion> addRegion(@NonNull String id, @NonNull List<Location> points, int minY, int maxY) {
|
||||
public Optional<IWrappedRegion> addRegion(String id, List<Location> points, int minY, int maxY) {
|
||||
ProtectedRegion region;
|
||||
World world = Objects.requireNonNull(points.get(0).getWorld());
|
||||
World world = points.get(0).getWorld();
|
||||
if (points.size() == 2) {
|
||||
region = new ProtectedCuboidRegion(
|
||||
id,
|
||||
WorldGuardVectorUtilities.toBlockVector(points.get(0)),
|
||||
WorldGuardVectorUtilities.toBlockVector(points.get(1))
|
||||
);
|
||||
region = new ProtectedCuboidRegion(id, WorldGuardVectorUtilities.toBlockVector(points.get(0)), WorldGuardVectorUtilities.toBlockVector(points.get(1)));
|
||||
} else {
|
||||
region = new ProtectedPolygonalRegion(
|
||||
id,
|
||||
WorldGuardVectorUtilities.toBlockVector2DList(points),
|
||||
minY,
|
||||
maxY
|
||||
);
|
||||
region = new ProtectedPolygonalRegion(id, WorldGuardVectorUtilities.toBlockVector2DList(points), minY, maxY);
|
||||
}
|
||||
|
||||
Optional<RegionManager> manager = getWorldManager(world);
|
||||
|
@ -353,13 +223,10 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<Set<IWrappedRegion>> removeRegion(@NonNull World world, @NonNull String id) {
|
||||
public Optional<Set<IWrappedRegion>> removeRegion(World world, String id) {
|
||||
Optional<Set<ProtectedRegion>> set = getWorldManager(world).map(manager -> manager.removeRegion(id));
|
||||
return set.map(protectedRegions ->
|
||||
protectedRegions.stream()
|
||||
.map(region -> new WrappedRegion(world, region))
|
||||
.collect(Collectors.toSet())
|
||||
);
|
||||
return set.map(protectedRegions -> protectedRegions.stream().map(region -> new WrappedRegion(world, region))
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -381,17 +248,11 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
} else if (selection instanceof Polygonal2DSelection) {
|
||||
return new IPolygonalSelection() {
|
||||
@Override
|
||||
public List<Location> getPoints() {
|
||||
public Set<Location> getPoints() {
|
||||
return ((Polygonal2DSelection) selection).getNativePoints().stream()
|
||||
.distinct()
|
||||
.map(vector -> new BlockVector(vector.toVector()))
|
||||
.map(vector ->
|
||||
WorldGuardVectorUtilities.fromBlockVector(
|
||||
selection.getWorld(),
|
||||
vector
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
.map(vector -> WorldGuardVectorUtilities.fromBlockVector(selection.getWorld(), vector))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -405,8 +266,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
};
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unsupported " + selection.getClass().getSimpleName()
|
||||
+ " selection!");
|
||||
throw new UnsupportedOperationException("Unsupported " + selection.getClass().getSimpleName() + " selection!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.codemc.worldguardwrapper.implementation.v6.flag;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.codemc.worldguardwrapper.implementation.v6.utility.WorldGuardFlagUtilities;
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
package org.codemc.worldguardwrapper.implementation.v6.handler;
|
||||
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.codemc.worldguardwrapper.flag.WrappedState;
|
||||
import org.codemc.worldguardwrapper.handler.IHandler;
|
||||
import org.codemc.worldguardwrapper.implementation.v6.WorldGuardImplementation;
|
||||
import org.codemc.worldguardwrapper.implementation.v6.region.WrappedRegion;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegion;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class ProxyHandler extends Handler {
|
||||
|
||||
private final WorldGuardImplementation implementation;
|
||||
private final IHandler handler;
|
||||
|
||||
public ProxyHandler(WorldGuardImplementation implementation, IHandler handler, Session session) {
|
||||
super(session);
|
||||
this.implementation = implementation;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(Player player, Location current, ApplicableRegionSet set) {
|
||||
handler.initialize(
|
||||
player,
|
||||
current,
|
||||
implementation.wrapRegionSet(Objects.requireNonNull(current.getWorld()), set)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testMoveTo(Player player, Location from, Location to, ApplicableRegionSet toSet, MoveType moveType) {
|
||||
return handler.testMoveTo(player,
|
||||
from,
|
||||
to,
|
||||
implementation.wrapRegionSet(Objects.requireNonNull(to.getWorld()), toSet),
|
||||
moveType.name()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCrossBoundary(
|
||||
Player player,
|
||||
Location from,
|
||||
Location to,
|
||||
ApplicableRegionSet toSet,
|
||||
Set<ProtectedRegion> entered,
|
||||
Set<ProtectedRegion> exited,
|
||||
MoveType moveType
|
||||
) {
|
||||
Set<IWrappedRegion> mappedEntered = ImmutableSet.copyOf(
|
||||
Collections2.transform(entered, region -> new WrappedRegion(to.getWorld(), region))
|
||||
);
|
||||
Set<IWrappedRegion> mappedExited = ImmutableSet.copyOf(
|
||||
Collections2.transform(exited, region -> new WrappedRegion(from.getWorld(), region))
|
||||
);
|
||||
return handler.onCrossBoundary(
|
||||
player,
|
||||
from,
|
||||
to,
|
||||
implementation.wrapRegionSet(Objects.requireNonNull(to.getWorld()), toSet),
|
||||
mappedEntered,
|
||||
mappedExited,
|
||||
moveType.name()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Player player, ApplicableRegionSet set) {
|
||||
handler.tick(player, implementation.wrapRegionSet(player.getWorld(), set));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public StateFlag.State getInvincibility(Player player) {
|
||||
WrappedState state = handler.getInvincibility(player);
|
||||
if (state == null) {
|
||||
return null;
|
||||
}
|
||||
return state == WrappedState.ALLOW ? StateFlag.State.ALLOW : StateFlag.State.DENY;
|
||||
}
|
||||
}
|
|
@ -46,12 +46,11 @@ public class WrappedRegion implements IWrappedRegion {
|
|||
} else if (handle instanceof ProtectedPolygonalRegion) {
|
||||
return new IPolygonalSelection() {
|
||||
@Override
|
||||
public List<Location> getPoints() {
|
||||
public Set<Location> getPoints() {
|
||||
return handle.getPoints().stream()
|
||||
.distinct()
|
||||
.map(vector -> new BlockVector(vector.toVector()))
|
||||
.map(vector -> WorldGuardVectorUtilities.fromBlockVector(world, vector))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,11 +107,6 @@ public class WrappedRegion implements IWrappedRegion {
|
|||
return handle.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int priority) {
|
||||
handle.setPriority(priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWrappedDomain getOwners() {
|
||||
return new IWrappedDomain() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.google.common.collect.Maps;
|
|||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.util.Vector;
|
||||
|
@ -14,6 +14,8 @@ import org.codemc.worldguardwrapper.implementation.v6.flag.AbstractWrappedFlag;
|
|||
import org.codemc.worldguardwrapper.implementation.v6.flag.WrappedPrimitiveFlag;
|
||||
import org.codemc.worldguardwrapper.implementation.v6.flag.WrappedStatusFlag;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@UtilityClass
|
||||
|
@ -39,8 +41,6 @@ public class WorldGuardFlagUtilities {
|
|||
wrappedFlag = new WrappedPrimitiveFlag(flag);
|
||||
} else if (type.equals(Vector.class)) {
|
||||
wrappedFlag = new WrappedPrimitiveFlag(flag);
|
||||
} else if (type.equals(Object.class)) {
|
||||
wrappedFlag = new WrappedPrimitiveFlag(flag);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported flag type " + type.getName());
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ public class WorldGuardFlagUtilities {
|
|||
|
||||
public Map.Entry<IWrappedFlag<?>, Object> wrap(Flag<?> flag, Object value) {
|
||||
IWrappedFlag<?> wrappedFlag = wrapFixType(flag, value.getClass());
|
||||
//noinspection OptionalGetWithoutIsPresent
|
||||
Object wrappedValue = ((AbstractWrappedFlag<?>) wrappedFlag).fromWGValue(value).get(); // value is non-null
|
||||
return Maps.immutableEntry(wrappedFlag, wrappedValue);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@ public class WorldGuardVectorUtilities {
|
|||
}
|
||||
|
||||
public List<BlockVector2D> toBlockVector2DList(List<Location> locations) {
|
||||
return locations.stream()
|
||||
.map(location -> new BlockVector2D(location.getX(), location.getZ())).collect(Collectors.toList());
|
||||
return locations.stream().map(location -> new BlockVector2D(location.getX(), location.getZ())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
|
||||
group ' org.codemc.worldguardwrapper.implementation.v7'
|
||||
|
||||
dependencies {
|
||||
api project(':api')
|
||||
|
||||
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.1-SNAPSHOT'
|
||||
compileOnly 'org.javassist:javassist:3.29.2-GA'
|
||||
|
||||
compileOnly 'org.projectlombok:lombok:1.18.26'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.26'
|
||||
}
|
131
implementation/v7/pom.xml
Normal file
131
implementation/v7/pom.xml
Normal file
|
@ -0,0 +1,131 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-implementation</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper-implementation-v7</artifactId>
|
||||
|
||||
<name>WorldGuardWrapper-Implementation-V7</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>enginehub-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
<snapshots>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-api</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.3-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<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>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.bstats.bStats-Metrics</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>rhino</groupId>
|
||||
<artifactId>js</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>de.schlichtherle</groupId>
|
||||
<artifactId>truezip</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>jchronic</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.thoughtworks.paranamer</groupId>
|
||||
<artifactId>paranamer</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.lib</groupId>
|
||||
<artifactId>jlibnoise</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,10 +1,10 @@
|
|||
package org.codemc.worldguardwrapper.implementation.v7;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
|
@ -20,53 +20,46 @@ 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 com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
import javassist.util.proxy.ProxyFactory;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.codemc.worldguardwrapper.flag.IWrappedFlag;
|
||||
import org.codemc.worldguardwrapper.flag.WrappedState;
|
||||
import org.codemc.worldguardwrapper.handler.IHandler;
|
||||
import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation;
|
||||
import org.codemc.worldguardwrapper.implementation.v7.flag.AbstractWrappedFlag;
|
||||
import org.codemc.worldguardwrapper.implementation.v7.handler.ProxyHandler;
|
||||
import org.codemc.worldguardwrapper.implementation.v7.region.WrappedRegion;
|
||||
import org.codemc.worldguardwrapper.implementation.v7.utility.WorldGuardFlagUtilities;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegion;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegionSet;
|
||||
import org.codemc.worldguardwrapper.selection.ICuboidSelection;
|
||||
import org.codemc.worldguardwrapper.selection.IPolygonalSelection;
|
||||
import org.codemc.worldguardwrapper.selection.ISelection;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WorldGuardImplementation implements IWorldGuardImplementation {
|
||||
|
||||
private final WorldGuard core;
|
||||
private final FlagRegistry flagRegistry;
|
||||
private final WorldGuardPlugin worldGuardPlugin;
|
||||
private final WorldEditPlugin worldEditPlugin;
|
||||
|
||||
public WorldGuardImplementation() {
|
||||
core = WorldGuard.getInstance();
|
||||
flagRegistry = core.getFlagRegistry();
|
||||
worldGuardPlugin = WorldGuardPlugin.inst();
|
||||
try {
|
||||
worldEditPlugin = worldGuardPlugin.getWorldEdit();
|
||||
} catch (CommandException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<LocalPlayer> wrapPlayer(OfflinePlayer player) {
|
||||
return Optional.ofNullable(player).map(bukkitPlayer -> {
|
||||
if (bukkitPlayer.isOnline()) {
|
||||
return WorldGuardPlugin.inst().wrapPlayer((Player) bukkitPlayer);
|
||||
}
|
||||
return WorldGuardPlugin.inst().wrapOfflinePlayer(bukkitPlayer);
|
||||
});
|
||||
private Optional<LocalPlayer> wrapPlayer(Player player) {
|
||||
return Optional.ofNullable(player).map(bukkitPlayer -> worldGuardPlugin.wrapPlayer(player));
|
||||
}
|
||||
|
||||
private Optional<RegionManager> getWorldManager(@NonNull World world) {
|
||||
|
@ -74,81 +67,17 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
private Optional<ApplicableRegionSet> getApplicableRegions(@NonNull Location location) {
|
||||
return getWorldManager(Objects.requireNonNull(location.getWorld()))
|
||||
.map(manager -> manager.getApplicableRegions(BukkitAdapter.asBlockVector(location)));
|
||||
return getWorldManager(location.getWorld()).map(manager -> manager.getApplicableRegions(BukkitAdapter.asBlockVector(location)));
|
||||
}
|
||||
|
||||
private Optional<ApplicableRegionSet> getApplicableRegions(@NonNull Location minimum, @NonNull Location maximum) {
|
||||
return getWorldManager(Objects.requireNonNull(minimum.getWorld()))
|
||||
.map(manager -> manager.getApplicableRegions(
|
||||
new ProtectedCuboidRegion(
|
||||
"temp",
|
||||
BukkitAdapter.asBlockVector(minimum),
|
||||
BukkitAdapter.asBlockVector(maximum)
|
||||
)
|
||||
));
|
||||
return getWorldManager(minimum.getWorld()).map(manager -> manager.getApplicableRegions(
|
||||
new ProtectedCuboidRegion("temp", BukkitAdapter.asBlockVector(minimum), BukkitAdapter.asBlockVector(maximum))));
|
||||
}
|
||||
|
||||
private <V> Optional<V> queryValue(Player player, @NonNull Location location, @NonNull Flag<V> flag) {
|
||||
return getApplicableRegions(location)
|
||||
.map(applicableRegions -> applicableRegions.queryValue(wrapPlayer(player).orElse(null), flag));
|
||||
}
|
||||
|
||||
public IWrappedRegionSet wrapRegionSet(@NonNull World world, @NonNull ApplicableRegionSet regionSet) {
|
||||
return new IWrappedRegionSet() {
|
||||
|
||||
@Override
|
||||
public Iterator<IWrappedRegion> iterator() {
|
||||
return Iterators.transform(regionSet.iterator(), region -> new WrappedRegion(world, region));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVirtual() {
|
||||
return regionSet.isVirtual();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> Optional<V> queryValue(OfflinePlayer subject, IWrappedFlag<V> flag) {
|
||||
LocalPlayer subjectHandle = wrapPlayer(subject).orElse(null);
|
||||
AbstractWrappedFlag<V> wrappedFlag = (AbstractWrappedFlag<V>) flag;
|
||||
return Optional.ofNullable(regionSet.queryValue(subjectHandle, wrappedFlag.getHandle()))
|
||||
.flatMap(wrappedFlag::fromWGValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> Collection<V> queryAllValues(OfflinePlayer subject, IWrappedFlag<V> flag) {
|
||||
LocalPlayer subjectHandle = wrapPlayer(subject).orElse(null);
|
||||
AbstractWrappedFlag<V> wrappedFlag = (AbstractWrappedFlag<V>) flag;
|
||||
return regionSet.queryAllValues(subjectHandle, wrappedFlag.getHandle()).stream()
|
||||
.map(wrappedFlag::fromWGValue)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOwnerOfAll(OfflinePlayer player) {
|
||||
LocalPlayer playerHandle = wrapPlayer(player).orElse(null);
|
||||
return regionSet.isOwnerOfAll(playerHandle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMemberOfAll(OfflinePlayer player) {
|
||||
LocalPlayer playerHandle = wrapPlayer(player).orElse(null);
|
||||
return regionSet.isMemberOfAll(playerHandle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return regionSet.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IWrappedRegion> getRegions() {
|
||||
return regionSet.getRegions().stream()
|
||||
.map(region -> new WrappedRegion(world, region)).collect(Collectors.toSet());
|
||||
}
|
||||
};
|
||||
return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryValue(wrapPlayer(player)
|
||||
.orElse(null), flag));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -161,39 +90,6 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandler(Supplier<IHandler> factory) {
|
||||
ProxyFactory proxyFactory = new ProxyFactory();
|
||||
proxyFactory.setUseCache(false);
|
||||
proxyFactory.setSuperclass(ProxyHandler.class);
|
||||
|
||||
Class<? extends ProxyHandler> handlerClass;
|
||||
Constructor<? extends ProxyHandler> handlerConstructor;
|
||||
try {
|
||||
//noinspection unchecked
|
||||
handlerClass = (Class<? extends ProxyHandler>) proxyFactory.createClass();
|
||||
handlerConstructor = handlerClass.getDeclaredConstructor(
|
||||
WorldGuardImplementation.class,
|
||||
IHandler.class,
|
||||
Session.class
|
||||
);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
core.getPlatform().getSessionManager().registerHandler(new Handler.Factory<Handler>() {
|
||||
@Override
|
||||
public Handler create(Session session) {
|
||||
IHandler handler = factory.get();
|
||||
try {
|
||||
return handlerConstructor.newInstance(WorldGuardImplementation.this, handler, session);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<IWrappedFlag<T>> getFlag(String name, Class<T> type) {
|
||||
return Optional.ofNullable(flagRegistry.get(name))
|
||||
|
@ -201,9 +97,9 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> queryFlag(Player player, @NonNull Location location, @NonNull IWrappedFlag<T> flag) {
|
||||
public <T> Optional<T> queryFlag(Player player, Location location, IWrappedFlag<T> flag) {
|
||||
AbstractWrappedFlag<T> wrappedFlag = (AbstractWrappedFlag<T>) flag;
|
||||
return queryValue(player, location, wrappedFlag.getHandle()).flatMap(wrappedFlag::fromWGValue);
|
||||
return queryValue(player, location, wrappedFlag.getHandle()).flatMap(value -> wrappedFlag.fromWGValue(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -229,7 +125,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
Map.Entry<IWrappedFlag<?>, Object> wrapped = WorldGuardFlagUtilities.wrap(flag, value);
|
||||
flags.put(wrapped.getKey(), wrapped.getValue());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Unsupported flag type
|
||||
continue; // Unsupported flag type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,9 +134,9 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
return flags;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> Optional<IWrappedFlag<T>> registerFlag(@NonNull String name, @NonNull Class<T> type, T defaultValue) {
|
||||
public <T> Optional<IWrappedFlag<T>> registerFlag(String name, Class<T> type, T defaultValue) {
|
||||
final Flag<?> flag;
|
||||
if (type.equals(WrappedState.class)) {
|
||||
flag = new StateFlag(name, defaultValue == WrappedState.ALLOW);
|
||||
|
@ -270,14 +166,14 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<IWrappedRegion> getRegion(@NonNull World world, @NonNull String id) {
|
||||
public Optional<IWrappedRegion> getRegion(World world, String id) {
|
||||
return getWorldManager(world)
|
||||
.map(regionManager -> regionManager.getRegion(id))
|
||||
.map(region -> new WrappedRegion(world, region));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, IWrappedRegion> getRegions(@NonNull World world) {
|
||||
public Map<String, IWrappedRegion> getRegions(World world) {
|
||||
RegionManager regionManager = core.getPlatform().getRegionContainer().get(new BukkitWorld(world));
|
||||
if (regionManager == null) {
|
||||
return Collections.emptyMap();
|
||||
|
@ -290,7 +186,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<IWrappedRegion> getRegions(@NonNull Location location) {
|
||||
public Set<IWrappedRegion> getRegions(Location location) {
|
||||
ApplicableRegionSet regionSet = getApplicableRegions(location).orElse(null);
|
||||
if (regionSet == null) {
|
||||
return Collections.emptySet();
|
||||
|
@ -302,7 +198,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<IWrappedRegion> getRegions(@NonNull Location minimum, @NonNull Location maximum) {
|
||||
public Set<IWrappedRegion> getRegions(Location minimum, Location maximum) {
|
||||
ApplicableRegionSet regionSet = getApplicableRegions(minimum, maximum).orElse(null);
|
||||
if (regionSet == null) {
|
||||
return Collections.emptySet();
|
||||
|
@ -314,14 +210,9 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<IWrappedRegionSet> getRegionSet(@NonNull Location location) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<IWrappedRegion> addRegion(@NonNull String id, @NonNull List<Location> points, int minY, int maxY) {
|
||||
public Optional<IWrappedRegion> addRegion(String id, List<Location> points, int minY, int maxY) {
|
||||
ProtectedRegion region;
|
||||
World world = Objects.requireNonNull(points.get(0).getWorld());
|
||||
World world = points.get(0).getWorld();
|
||||
if (points.size() == 2) {
|
||||
region = new ProtectedCuboidRegion(id, BukkitAdapter.asBlockVector(points.get(0)),
|
||||
BukkitAdapter.asBlockVector(points.get(1)));
|
||||
|
@ -343,7 +234,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<Set<IWrappedRegion>> removeRegion(@NonNull World world, @NonNull String id) {
|
||||
public Optional<Set<IWrappedRegion>> removeRegion(World world, String id) {
|
||||
Optional<Set<ProtectedRegion>> set = getWorldManager(world).map(manager -> manager.removeRegion(id));
|
||||
return set.map(protectedRegions -> protectedRegions.stream()
|
||||
.map(region -> new WrappedRegion(world, region)).collect(Collectors.toSet()));
|
||||
|
@ -353,18 +244,13 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
public Optional<ISelection> getPlayerSelection(@NonNull Player player) {
|
||||
Region region;
|
||||
try {
|
||||
region = WorldEdit.getInstance()
|
||||
.getSessionManager()
|
||||
.get(BukkitAdapter.adapt(player))
|
||||
.getSelection(BukkitAdapter.adapt(player.getWorld()));
|
||||
region = worldEditPlugin.getSession(player).getSelection(BukkitAdapter.adapt(player.getWorld()));
|
||||
} catch (IncompleteRegionException e) {
|
||||
region = null;
|
||||
}
|
||||
return Optional.ofNullable(region)
|
||||
.map(selection -> {
|
||||
World world = Optional.ofNullable(selection.getWorld())
|
||||
.map(BukkitAdapter::adapt)
|
||||
.orElse(null);
|
||||
World world = Optional.ofNullable(selection.getWorld()).map(BukkitAdapter::adapt).orElse(null);
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -383,12 +269,11 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
} else if (selection instanceof Polygonal2DRegion) {
|
||||
return new IPolygonalSelection() {
|
||||
@Override
|
||||
public List<Location> getPoints() {
|
||||
public Set<Location> getPoints() {
|
||||
return ((Polygonal2DRegion) selection).getPoints().stream()
|
||||
.distinct()
|
||||
.map(BlockVector2::toBlockVector3)
|
||||
.map(vector -> BukkitAdapter.adapt(world, vector))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -402,8 +287,7 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
|
|||
}
|
||||
};
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unsupported " + selection.getClass().getSimpleName()
|
||||
+ " selection!");
|
||||
throw new UnsupportedOperationException("Unsupported " + selection.getClass().getSimpleName() + " selection!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.codemc.worldguardwrapper.implementation.v7.flag;
|
|||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.codemc.worldguardwrapper.implementation.v7.utility.WorldGuardFlagUtilities;
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
package org.codemc.worldguardwrapper.implementation.v7.handler;
|
||||
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.codemc.worldguardwrapper.flag.WrappedState;
|
||||
import org.codemc.worldguardwrapper.handler.IHandler;
|
||||
import org.codemc.worldguardwrapper.implementation.v7.WorldGuardImplementation;
|
||||
import org.codemc.worldguardwrapper.implementation.v7.region.WrappedRegion;
|
||||
import org.codemc.worldguardwrapper.region.IWrappedRegion;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class ProxyHandler extends Handler {
|
||||
|
||||
private final WorldGuardImplementation implementation;
|
||||
private final IHandler handler;
|
||||
|
||||
public ProxyHandler(WorldGuardImplementation implementation, IHandler handler, Session session) {
|
||||
super(session);
|
||||
this.implementation = implementation;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(LocalPlayer player, com.sk89q.worldedit.util.Location current, ApplicableRegionSet set) {
|
||||
Player bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
Location bukkitLocation = BukkitAdapter.adapt(current);
|
||||
handler.initialize(
|
||||
bukkitPlayer,
|
||||
bukkitLocation,
|
||||
implementation.wrapRegionSet(Objects.requireNonNull(bukkitLocation.getWorld()),set)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testMoveTo(
|
||||
LocalPlayer player,
|
||||
com.sk89q.worldedit.util.Location from,
|
||||
com.sk89q.worldedit.util.Location to,
|
||||
ApplicableRegionSet toSet,
|
||||
MoveType moveType
|
||||
) {
|
||||
Player bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
Location bukkitFrom = BukkitAdapter.adapt(from);
|
||||
Location bukkitTo = BukkitAdapter.adapt(to);
|
||||
return handler.testMoveTo(
|
||||
bukkitPlayer,
|
||||
bukkitFrom,
|
||||
bukkitTo,
|
||||
implementation.wrapRegionSet(Objects.requireNonNull(bukkitTo.getWorld()), toSet),
|
||||
moveType.name()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCrossBoundary(
|
||||
LocalPlayer player,
|
||||
com.sk89q.worldedit.util.Location from,
|
||||
com.sk89q.worldedit.util.Location to,
|
||||
ApplicableRegionSet toSet,
|
||||
Set<ProtectedRegion> entered,
|
||||
Set<ProtectedRegion> exited,
|
||||
MoveType moveType
|
||||
) {
|
||||
Player bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
Location bukkitFrom = BukkitAdapter.adapt(from);
|
||||
Location bukkitTo = BukkitAdapter.adapt(to);
|
||||
Set<IWrappedRegion> mappedEntered = ImmutableSet.copyOf(Collections2.transform(entered, region ->
|
||||
new WrappedRegion(bukkitTo.getWorld(), region)
|
||||
));
|
||||
Set<IWrappedRegion> mappedExited = ImmutableSet.copyOf(Collections2.transform(exited, region ->
|
||||
new WrappedRegion(bukkitFrom.getWorld(), region)
|
||||
));
|
||||
return handler.onCrossBoundary(
|
||||
bukkitPlayer,
|
||||
bukkitFrom,
|
||||
bukkitTo,
|
||||
implementation.wrapRegionSet(Objects.requireNonNull(bukkitTo.getWorld()), toSet),
|
||||
mappedEntered,
|
||||
mappedExited,
|
||||
moveType.name()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(LocalPlayer player, ApplicableRegionSet set) {
|
||||
Player bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
handler.tick(bukkitPlayer, implementation.wrapRegionSet(bukkitPlayer.getWorld(), set));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public StateFlag.State getInvincibility(LocalPlayer player) {
|
||||
Player bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
WrappedState state = handler.getInvincibility(bukkitPlayer);
|
||||
if (state == null) {
|
||||
return null;
|
||||
}
|
||||
return state == WrappedState.ALLOW ? StateFlag.State.ALLOW : StateFlag.State.DENY;
|
||||
}
|
||||
}
|
|
@ -46,12 +46,11 @@ public class WrappedRegion implements IWrappedRegion {
|
|||
} else if (handle instanceof ProtectedPolygonalRegion) {
|
||||
return new IPolygonalSelection() {
|
||||
@Override
|
||||
public List<Location> getPoints() {
|
||||
public Set<Location> getPoints() {
|
||||
return handle.getPoints().stream()
|
||||
.distinct()
|
||||
.map(BlockVector2::toBlockVector3)
|
||||
.map(vector -> BukkitAdapter.adapt(world, vector))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,11 +107,6 @@ public class WrappedRegion implements IWrappedRegion {
|
|||
return handle.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int priority) {
|
||||
handle.setPriority(priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWrappedDomain getOwners() {
|
||||
return new IWrappedDomain() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.google.common.collect.Maps;
|
|||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.codemc.worldguardwrapper.flag.IWrappedFlag;
|
||||
|
@ -13,7 +13,10 @@ import org.codemc.worldguardwrapper.implementation.v7.flag.AbstractWrappedFlag;
|
|||
import org.codemc.worldguardwrapper.implementation.v7.flag.WrappedPrimitiveFlag;
|
||||
import org.codemc.worldguardwrapper.implementation.v7.flag.WrappedStatusFlag;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@UtilityClass
|
||||
public class WorldGuardFlagUtilities {
|
||||
|
@ -38,8 +41,6 @@ public class WorldGuardFlagUtilities {
|
|||
wrappedFlag = new WrappedPrimitiveFlag(flag);
|
||||
} else if (type.equals(Vector.class)) {
|
||||
wrappedFlag = new WrappedPrimitiveFlag(flag);
|
||||
} else if (type.equals(Object.class)) {
|
||||
wrappedFlag = new WrappedPrimitiveFlag(flag);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported flag type " + type.getName());
|
||||
}
|
||||
|
@ -64,7 +65,6 @@ public class WorldGuardFlagUtilities {
|
|||
|
||||
public Map.Entry<IWrappedFlag<?>, Object> wrap(Flag<?> flag, Object value) {
|
||||
IWrappedFlag<?> wrappedFlag = wrapFixType(flag, value.getClass());
|
||||
//noinspection OptionalGetWithoutIsPresent
|
||||
Object wrappedValue = ((AbstractWrappedFlag<?>) wrappedFlag).fromWGValue(value).get(); // value is non-null
|
||||
return Maps.immutableEntry(wrappedFlag, wrappedValue);
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'com.github.johnrengelman.shadow'
|
||||
id 'maven-publish'
|
||||
id 'signing'
|
||||
}
|
||||
|
||||
group 'org.codemc.worldguardwrapper'
|
||||
version parent.version
|
||||
|
||||
assemble.dependsOn shadowJar
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "https://maven.enginehub.org/repo/" }
|
||||
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(':api')
|
||||
api project(':implementation')
|
||||
compileOnly 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT'
|
||||
implementation 'org.javassist:javassist:3.29.2-GA'
|
||||
compileOnly 'org.projectlombok:lombok:1.18.26'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.26'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependencies {
|
||||
exclude(dependency('org.projectlombok:lombok'))
|
||||
exclude(dependency('org.jetbrains:annotations'))
|
||||
}
|
||||
relocate 'javassist', 'org.codemc.worldguardwrapper.libs.javassist'
|
||||
|
||||
archiveFileName = "WorldGuardWrapper-${project.version}.jar"
|
||||
}
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
groupId = 'org.codemc.worldguardwrapper'
|
||||
artifactId = 'worldguardwrapper'
|
||||
artifact("build/libs/WorldGuardWrapper-${project.version}.jar") {
|
||||
extension 'jar'
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name 'secure'
|
||||
url = "https://repo.recorehosting.com/repository/maven-snapshots"
|
||||
credentials(org.gradle.api.credentials.PasswordCredentials)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
56
library/pom.xml
Normal file
56
library/pom.xml
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-parent</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>worldguardwrapper</artifactId>
|
||||
|
||||
<name>WorldGuardWrapper-Library</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-api</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-implementation-legacy</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-implementation-v6</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>worldguardwrapper-implementation-v7</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -6,8 +6,6 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation;
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class WorldGuardWrapper implements IWorldGuardImplementation {
|
||||
|
||||
private static WorldGuardWrapper instance;
|
||||
|
@ -25,8 +23,8 @@ public class WorldGuardWrapper implements IWorldGuardImplementation {
|
|||
}
|
||||
|
||||
@Delegate
|
||||
private final IWorldGuardImplementation implementation;
|
||||
private final Listener listener;
|
||||
private IWorldGuardImplementation implementation;
|
||||
private Listener listener;
|
||||
|
||||
private WorldGuardWrapper() {
|
||||
int targetVersion;
|
||||
|
@ -48,6 +46,15 @@ public class WorldGuardWrapper implements IWorldGuardImplementation {
|
|||
implementation = new org.codemc.worldguardwrapper.implementation.legacy.WorldGuardImplementation();
|
||||
listener = new org.codemc.worldguardwrapper.implementation.legacy.event.EventListener();
|
||||
} else {
|
||||
/*
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("FastAsyncWorldEdit")) {
|
||||
implementation = new org.codemc.worldguardwrapper.implementation.v7fawe.WorldGuardImplementation();
|
||||
listener = new org.codemc.worldguardwrapper.implementation.v7fawe.event.EventListener();
|
||||
} else {
|
||||
implementation = new org.codemc.worldguardwrapper.implementation.v7.WorldGuardImplementation();
|
||||
listener = new org.codemc.worldguardwrapper.implementation.v7.event.EventListener();
|
||||
}
|
||||
*/
|
||||
implementation = new org.codemc.worldguardwrapper.implementation.v7.WorldGuardImplementation();
|
||||
listener = new org.codemc.worldguardwrapper.implementation.v7.event.EventListener();
|
||||
}
|
||||
|
|
166
pom.xml
Normal file
166
pom.xml
Normal file
|
@ -0,0 +1,166 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper-parent</artifactId>
|
||||
<version>1.1.9-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>api</module>
|
||||
<module>library</module>
|
||||
<module>implementation</module>
|
||||
</modules>
|
||||
|
||||
<name>WorldGuardWrapper-Parent</name>
|
||||
<description>A wrapper for the WorldGuard API that allows plugins to support both v6 and v7 APIs.</description>
|
||||
<url>https://github.com/CodeMC/WorldGuardWrapper</url>
|
||||
<inceptionYear>2018</inceptionYear>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://github.com/CodeMC/WorldGuardWrapper.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:CodeMC/WorldGuardWrapper.git</developerConnection>
|
||||
<url>https://github.com/CodeMC/WorldGuardWrapper</url>
|
||||
</scm>
|
||||
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>http://ci.codemc.org/job/CodeMC/job/HolographicDisplays/</url>
|
||||
</ciManagement>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/CodeMC/WorldGuardWrapper/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>codemc-snapshots</id>
|
||||
<url>https://repo.codemc.org/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>codemc-releases</id>
|
||||
<url>https://repo.codemc.org/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spigot-api.version>1.15.2-R0.1-SNAPSHOT</spigot-api.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigotmc-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>${spigot-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<show>public</show>
|
||||
<failOnError>false</failOnError>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||
rootProject.name = 'WorldGuardWrapper'
|
||||
|
||||
include 'library'
|
||||
include 'api'
|
||||
include 'implementation'
|
||||
include 'implementation:v6'
|
||||
include 'implementation:v7'
|
||||
include 'implementation:legacy'
|
Loading…
Reference in New Issue
Block a user