Cleaned up WG 6/7 combatiblity

This commit is contained in:
isokissa3 2018-11-12 20:48:17 +02:00
parent a4751cd6dd
commit 07d03b2229
73 changed files with 767 additions and 560 deletions

88
Common/pom.xml Normal file
View file

@ -0,0 +1,88 @@
<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>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.0</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>common</artifactId>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.sk89q.com/repo/</url>
</repository>
<repository>
<id>ess-repo</id>
<url>http://repo.ess3.net/content/groups/essentials</url>
</repository>
<repository>
<id>empcraft</id>
<url>http://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/</url>
</repository>
<!-- FOR NOW -->
<repository>
<id>elMakers</id>
<url>http://maven.elmakers.com/repository/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg6</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg7</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit</artifactId>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.boydti</groupId>
<artifactId>fawe-api</artifactId>
<version>18.07.27-3ed2e57-1163-20.5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>Essentials</artifactId>
<version>2.13-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -20,6 +20,7 @@ import net.goldtreeservers.worldguardextraflags.listeners.PlayerListener;
import net.goldtreeservers.worldguardextraflags.listeners.WorldEditListener;
import net.goldtreeservers.worldguardextraflags.listeners.WorldListener;
import net.goldtreeservers.worldguardextraflags.utils.WorldUtils;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.handlers.BlockedEffectsFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.CommandOnEntryFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.CommandOnExitFlagHandler;
@ -33,8 +34,8 @@ import net.goldtreeservers.worldguardextraflags.wg.handlers.PlaySoundsFlagHandle
import net.goldtreeservers.worldguardextraflags.wg.handlers.TeleportOnEntryFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.TeleportOnExitFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.WalkSpeedFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.legacy.WorldGuardCommunicator;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractSessionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.WorldGuardCommunicator;
public class WorldGuardExtraFlagsPlugin extends JavaPlugin
{
@ -59,7 +60,7 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
this.worldEditPlugin = (WorldEditPlugin)this.getServer().getPluginManager().getPlugin("WorldEdit");
this.worldGuardPlugin = (WorldGuardPlugin)this.getServer().getPluginManager().getPlugin("WorldGuard");
this.worldGuardCommunicator = WorldGuardCommunicator.create();
this.worldGuardCommunicator = WorldGuardUtils.createWorldGuardCommunicator();
if (this.worldGuardCommunicator == null)
{
throw new RuntimeException("Unsupported WorldGuard version: " + this.worldGuardPlugin.getDescription().getVersion());
@ -156,7 +157,7 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
throw new RuntimeException("Failed to enable WorldGuard communicator", e);
}
SessionManagerWrapper sessionManager = this.worldGuardCommunicator.getSessionManager();
AbstractSessionManagerWrapper sessionManager = this.worldGuardCommunicator.getSessionManager();
sessionManager.registerHandler(TeleportOnEntryFlagHandler.FACTORY);
sessionManager.registerHandler(TeleportOnExitFlagHandler.FACTORY);
sessionManager.registerHandler(CommandOnEntryFlagHandler.FACTORY);

View file

@ -13,7 +13,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionManagerWrapper;
public class FaweWorldEditFlagMaskManager extends FaweMaskManager<Player>
{
@ -29,7 +29,7 @@ public class FaweWorldEditFlagMaskManager extends FaweMaskManager<Player>
public ProtectedRegion getRegion(Player player, Location loc)
{
final com.sk89q.worldguard.LocalPlayer localplayer = this.plugin.getWorldGuardCommunicator().wrapPlayer(player);
RegionManagerWrapper manager = this.plugin.getWorldGuardCommunicator().getRegionContainer().get(player.getWorld());
AbstractRegionManagerWrapper manager = this.plugin.getWorldGuardCommunicator().getRegionContainer().get(player.getWorld());
final ProtectedRegion global = manager.getRegion("__global__");
if (global != null && !isDenied(localplayer, global))
{

View file

@ -12,8 +12,8 @@ import com.sk89q.worldguard.protection.flags.SetFlag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.StringFlag;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.data.SoundData;
import net.goldtreeservers.worldguardextraflags.flags.helpers.CustomSetFlag;
import net.goldtreeservers.worldguardextraflags.flags.helpers.MaterialFlag;
import net.goldtreeservers.worldguardextraflags.flags.helpers.PotionEffectFlag;
import net.goldtreeservers.worldguardextraflags.flags.helpers.PotionEffectTypeFlag;
@ -24,11 +24,11 @@ public final class Flags
public final static LocationFlag TELEPORT_ON_ENTRY = new LocationFlag("teleport-on-entry");
public final static LocationFlag TELEPORT_ON_EXIT = new LocationFlag("teleport-on-exit");
public final static CustomSetFlag<String> COMMAND_ON_ENTRY = new CustomSetFlag<String>("command-on-entry", new CommandStringFlag(null));
public final static CustomSetFlag<String> COMMAND_ON_EXIT = new CustomSetFlag<String>("command-on-exit", new CommandStringFlag(null));
public final static SetFlag<String> COMMAND_ON_ENTRY = WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getCustomSetFlag("command-on-entry", new CommandStringFlag(null));
public final static SetFlag<String> COMMAND_ON_EXIT = WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getCustomSetFlag("command-on-exit", new CommandStringFlag(null));
public final static CustomSetFlag<String> CONSOLE_COMMAND_ON_ENTRY = new CustomSetFlag<String>("console-command-on-entry", new CommandStringFlag(null));
public final static CustomSetFlag<String> CONSOLE_COMMAND_ON_EXIT = new CustomSetFlag<String>("console-command-on-exit", new CommandStringFlag(null));
public final static SetFlag<String> CONSOLE_COMMAND_ON_ENTRY = WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getCustomSetFlag("console-command-on-entry", new CommandStringFlag(null));
public final static SetFlag<String> CONSOLE_COMMAND_ON_EXIT = WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getCustomSetFlag("console-command-on-exit", new CommandStringFlag(null));
public final static DoubleFlag WALK_SPEED = new DoubleFlag("walk-speed");

View file

@ -2,8 +2,6 @@ package net.goldtreeservers.worldguardextraflags.flags.data;
import java.util.concurrent.TimeUnit;
import org.bukkit.Color;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@ -14,7 +12,6 @@ public class PotionEffectDetails
@Getter private final int amplifier;
@Getter private final boolean ambient;
@Getter private final boolean particles;
@Getter private final Color color;
public long getTimeLeft()
{

View file

@ -4,7 +4,6 @@ import java.awt.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import lombok.Getter;
@ -14,7 +13,6 @@ import lombok.Getter;
public class SupportedFeatures
{
@Getter private static boolean frostwalkerSupported;
@Getter private static boolean mobEffectColorsSupported;
@Getter private static boolean stopSoundSupported;
static
@ -27,14 +25,6 @@ public class SupportedFeatures
{
}
try
{
SupportedFeatures.mobEffectColorsSupported = PotionEffect.class.getDeclaredMethod("getColor", Color.class) != null;
}
catch (Throwable ignored)
{
}
try
{
SupportedFeatures.stopSoundSupported = Player.class.getDeclaredMethod("stopSound", Color.class) != null;

View file

@ -17,6 +17,9 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.util.NormativeOrders;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.WorldGuardCommunicator;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.v6.WorldGuardSixCommunicator;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.v7.WorldGuardSevenCommunicator;
public class WorldGuardUtils
{
@ -83,4 +86,33 @@ public class WorldGuardUtils
return new FlagValueCalculator(checkForRegions, global);
}
public static WorldGuardCommunicator createWorldGuardCommunicator()
{
try
{
Class.forName("com.sk89q.worldguard.WorldGuard"); //Only exists in WG 7
return new WorldGuardSevenCommunicator();
}
catch (Throwable ignored)
{
}
try
{
Class<?> clazz = Class.forName("com.sk89q.worldguard.bukkit.WorldGuardPlugin");
if (clazz.getMethod("getFlagRegistry") != null)
{
return new WorldGuardSixCommunicator();
}
}
catch (Throwable ignored)
{
ignored.printStackTrace();
}
return null;
}
}

View file

@ -19,9 +19,8 @@ import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.flags.data.PotionEffectDetails;
import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class BlockedEffectsFlagHandler extends HandlerWrapper
{
@ -83,7 +82,7 @@ public class BlockedEffectsFlagHandler extends HandlerWrapper
if (effect != null)
{
this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), SupportedFeatures.isMobEffectColorsSupported() ? effect.getColor() : null));
this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
player.removePotionEffect(effectType);
}
@ -102,17 +101,10 @@ public class BlockedEffectsFlagHandler extends HandlerWrapper
{
int timeLeft = removedEffect.getTimeLeftInTicks();
if (timeLeft > 0)
{
if (SupportedFeatures.isMobEffectColorsSupported())
{
player.addPotionEffect(new PotionEffect(potionEffect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles(), removedEffect.getColor()), true);
}
else
{
player.addPotionEffect(new PotionEffect(potionEffect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles()), true);
}
}
}
potionEffects_.remove();
}

View file

@ -16,7 +16,7 @@ import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class CommandOnEntryFlagHandler extends HandlerWrapper
{

View file

@ -16,7 +16,7 @@ import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class CommandOnExitFlagHandler extends HandlerWrapper
{

View file

@ -16,7 +16,7 @@ import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class ConsoleCommandOnEntryFlagHandler extends HandlerWrapper
{

View file

@ -16,7 +16,7 @@ import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class ConsoleCommandOnExitFlagHandler extends HandlerWrapper
{

View file

@ -15,7 +15,7 @@ import com.sk89q.worldguard.session.handler.Handler;
import lombok.Getter;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class FlyFlagHandler extends HandlerWrapper
{

View file

@ -23,9 +23,8 @@ import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.flags.data.PotionEffectDetails;
import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class GiveEffectsFlagHandler extends HandlerWrapper
{
@ -89,7 +88,7 @@ public class GiveEffectsFlagHandler extends HandlerWrapper
if (this.givenEffects.add(effect.getType()) && effect_ != null)
{
this.removedEffects.put(effect_.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect_.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect_.getAmplifier(), effect_.isAmbient(), effect_.hasParticles(), SupportedFeatures.isMobEffectColorsSupported() ? effect_.getColor() : null));
this.removedEffects.put(effect_.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect_.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect_.getAmplifier(), effect_.isAmbient(), effect_.hasParticles()));
player.removePotionEffect(effect_.getType());
}
@ -138,17 +137,10 @@ public class GiveEffectsFlagHandler extends HandlerWrapper
int timeLeft = removedEffect.getTimeLeftInTicks();
if (timeLeft > 0)
{
if (SupportedFeatures.isMobEffectColorsSupported())
{
player.addPotionEffect(new PotionEffect(effect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles(), removedEffect.getColor()), true);
}
else
{
player.addPotionEffect(new PotionEffect(effect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles()), true);
}
}
}
potionEffects_.remove();
}
@ -166,7 +158,7 @@ public class GiveEffectsFlagHandler extends HandlerWrapper
{
for(PotionEffect effect : effects)
{
this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), SupportedFeatures.isMobEffectColorsSupported() ? effect.getColor() : null));
this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
}
this.check(player, WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()));

View file

@ -14,7 +14,7 @@ import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class GlideFlagHandler extends HandlerWrapper
{

View file

@ -18,7 +18,7 @@ import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.essentials.EssentialsHelper;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class GodmodeFlagHandler extends HandlerWrapper
{

View file

@ -21,7 +21,7 @@ import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.flags.data.SoundData;
import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class PlaySoundsFlagHandler extends HandlerWrapper
{

View file

@ -16,7 +16,7 @@ import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.we.WorldEditUtils;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class TeleportOnEntryFlagHandler extends HandlerWrapper
{

View file

@ -16,7 +16,7 @@ import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.we.WorldEditUtils;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class TeleportOnExitFlagHandler extends HandlerWrapper
{

View file

@ -13,7 +13,7 @@ import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class WalkSpeedFlagHandler extends HandlerWrapper
{

71
Spigot/pom.xml Normal file
View file

@ -0,0 +1,71 @@
<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>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.0</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>Spigot</artifactId>
<build>
<finalName>WorldGuardExtraFlags</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.SF</exclude>
<exclude>**/*.DSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg6</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg7</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View file

@ -1,5 +1,5 @@
name: WorldGuardExtraFlags
version: 3.0.4
version: 4.1.0
description: Adds more flags to WorldGuard to help manage your server easily!
author: isokissa3
website: https://goldtreevers.net

48
WG/pom.xml Normal file
View file

@ -0,0 +1,48 @@
<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>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.0</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg</artifactId>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.sk89q.com/repo/</url>
</repository>
<!-- FOR NOW -->
<repository>
<id>elMakers</id>
<url>http://maven.elmakers.com/repository/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit</artifactId>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,9 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers;
import org.bukkit.World;
public abstract class AbstractRegionContainerWrapper
{
public abstract AbstractRegionQueryWrapper createQuery();
public abstract AbstractRegionManagerWrapper get(World world);
}

View file

@ -1,4 +1,4 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers;
package net.goldtreeservers.worldguardextraflags.wg.wrappers;
import java.util.Map;
@ -14,7 +14,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public abstract class RegionManagerWrapper
public abstract class AbstractRegionManagerWrapper
{
protected final RegionManager regionManager;

View file

@ -1,10 +1,10 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers;
package net.goldtreeservers.worldguardextraflags.wg.wrappers;
import org.bukkit.Location;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
public abstract class RegionQueryWrapper
public abstract class AbstractRegionQueryWrapper
{
public abstract ApplicableRegionSet getApplicableRegions(Location location);
}

View file

@ -1,4 +1,4 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers;
package net.goldtreeservers.worldguardextraflags.wg.wrappers;
import org.bukkit.entity.Player;
@ -9,7 +9,7 @@ import com.sk89q.worldguard.session.handler.Handler;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public abstract class SessionManagerWrapper
public abstract class AbstractSessionManagerWrapper
{
protected final SessionManager sessionManager;

View file

@ -1,4 +1,4 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers;
package net.goldtreeservers.worldguardextraflags.wg.wrappers;
import java.util.Set;
@ -24,7 +24,6 @@ public abstract class HandlerWrapper extends Handler
public void initialize(Player player, Location current, ApplicableRegionSet set)
{
}
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
@ -34,7 +33,6 @@ public abstract class HandlerWrapper extends Handler
public void tick(Player player, ApplicableRegionSet set)
{
}
public State getInvincibility(Player player)

View file

@ -0,0 +1,23 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.SetFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
public interface WorldGuardCommunicator
{
public void onLoad() throws Exception;
public void onEnable() throws Exception;
public FlagRegistry getFlagRegistry();
public AbstractSessionManagerWrapper getSessionManager();
public AbstractRegionContainerWrapper getRegionContainer();
public LocalPlayer wrapPlayer(Player player);
public <T> SetFlag<T> getCustomSetFlag(String name, Flag<T> flag);
}

49
WG6/pom.xml Normal file
View file

@ -0,0 +1,49 @@
<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>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.0</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg6</artifactId>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.sk89q.com/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>guavabackport</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
<version>6.1.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -1,4 +1,4 @@
package net.goldtreeservers.worldguardextraflags.flags.helpers;
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6;
import java.util.Set;
@ -33,6 +33,7 @@ public class CustomSetFlag<T> extends SetFlag<T>
{
str = str.substring(1, str.length() - 1);
}
FlagContext copy = context.copyWith(null, str, null);
items.add(this.getType().parseInput(copy));
}

View file

@ -0,0 +1,24 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6;
import org.bukkit.World;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionContainerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionQueryWrapper;
public class RegionContainerWrapper extends AbstractRegionContainerWrapper
{
@Override
public AbstractRegionQueryWrapper createQuery()
{
return new RegionQueryWrapper(WorldGuardPlugin.inst().getRegionContainer().createQuery());
}
@Override
public AbstractRegionManagerWrapper get(World world)
{
return new RegionManagerWrapper(WorldGuardPlugin.inst().getRegionManager(world));
}
}

View file

@ -0,0 +1,13 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6;
import com.sk89q.worldguard.protection.managers.RegionManager;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionManagerWrapper;
public class RegionManagerWrapper extends AbstractRegionManagerWrapper
{
public RegionManagerWrapper(RegionManager regionManager)
{
super(regionManager);
}
}

View file

@ -0,0 +1,21 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6;
import org.bukkit.Location;
import com.sk89q.worldguard.bukkit.RegionQuery;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionQueryWrapper;
@RequiredArgsConstructor
public class RegionQueryWrapper extends AbstractRegionQueryWrapper
{
private final RegionQuery regionQuery;
@Override
public ApplicableRegionSet getApplicableRegions(Location location)
{
return this.regionQuery.getApplicableRegions(location);
}
}

View file

@ -0,0 +1,36 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.SessionManager;
import com.sk89q.worldguard.session.handler.Handler;
import com.sk89q.worldguard.session.handler.Handler.Factory;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractSessionManagerWrapper;
public class SessionManagerWrapper extends AbstractSessionManagerWrapper
{
public SessionManagerWrapper(SessionManager sessionManager)
{
super(sessionManager);
}
@Override
public Session get(Player player)
{
return this.sessionManager.get(player);
}
@Override
public Session getIfPresent(Player player)
{
return this.sessionManager.getIfPresent(player);
}
@Override
public void registerHandler(Factory<? extends Handler> factory)
{
this.sessionManager.registerHandler(factory, null);
}
}

View file

@ -0,0 +1,61 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.SetFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionContainerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractSessionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.WorldGuardCommunicator;
public class WorldGuardSixCommunicator implements WorldGuardCommunicator
{
private AbstractSessionManagerWrapper sessionManager;
private AbstractRegionContainerWrapper regionContainer;
@Override
public void onLoad() throws Exception
{
}
@Override
public void onEnable() throws Exception
{
this.sessionManager = new SessionManagerWrapper(WorldGuardPlugin.inst().getSessionManager());
this.regionContainer = new RegionContainerWrapper();
}
@Override
public FlagRegistry getFlagRegistry()
{
return WorldGuardPlugin.inst().getFlagRegistry();
}
@Override
public AbstractSessionManagerWrapper getSessionManager()
{
return this.sessionManager;
}
@Override
public AbstractRegionContainerWrapper getRegionContainer()
{
return this.regionContainer;
}
@Override
public LocalPlayer wrapPlayer(Player player)
{
return WorldGuardPlugin.inst().wrapPlayer(player);
}
@Override
public <T> SetFlag<T> getCustomSetFlag(String name, Flag<T> flag)
{
return new CustomSetFlag<T>(name, flag);
}
}

54
WG7/pom.xml Normal file
View file

@ -0,0 +1,54 @@
<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>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.1.0</version>
</parent>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg7</artifactId>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.sk89q.com/repo/</url>
</repository>
<!-- FOR NOW -->
<repository>
<id>elMakers</id>
<url>http://maven.elmakers.com/repository/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit</artifactId>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,44 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7;
import java.util.Set;
import com.google.common.collect.Sets;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.FlagContext;
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
import com.sk89q.worldguard.protection.flags.SetFlag;
public class CustomSetFlag<T> extends SetFlag<T>
{
public CustomSetFlag(String name, Flag<T> subFlag)
{
super(name, subFlag);
}
@Override
public Set<T> parseInput(FlagContext context) throws InvalidFlagFormat
{
String input = context.getUserInput();
if (input.isEmpty())
{
return Sets.newHashSet();
}
else
{
Set<T> items = Sets.newHashSet();
for (String str : input.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1))
{
if (str.startsWith("\"") && str.endsWith("\""))
{
str = str.substring(1, str.length() - 1);
}
FlagContext copy = context.copyWith(null, str, null);
items.add(this.getType().parseInput(copy));
}
return items;
}
}
}

View file

@ -0,0 +1,26 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7;
import org.bukkit.World;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionContainerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionQueryWrapper;
public class RegionContainerWrapper extends AbstractRegionContainerWrapper
{
@Override
public AbstractRegionQueryWrapper createQuery()
{
return new RegionQueryWrapper(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery());
}
@Override
public AbstractRegionManagerWrapper get(World world)
{
return new RegionManagerWrapper(WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world)));
}
}

View file

@ -0,0 +1,13 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7;
import com.sk89q.worldguard.protection.managers.RegionManager;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionManagerWrapper;
public class RegionManagerWrapper extends AbstractRegionManagerWrapper
{
public RegionManagerWrapper(RegionManager regionManager)
{
super(regionManager);
}
}

View file

@ -1,4 +1,4 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7;
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7;
import org.bukkit.Location;
@ -7,12 +7,12 @@ import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionQueryWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionQueryWrapper;
@RequiredArgsConstructor
public class RegionQueryWrapperSeven extends RegionQueryWrapper
public class RegionQueryWrapper extends AbstractRegionQueryWrapper
{
protected final RegionQuery regionQuery;
private final RegionQuery regionQuery;
@Override
public ApplicableRegionSet getApplicableRegions(Location location)

View file

@ -0,0 +1,37 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.SessionManager;
import com.sk89q.worldguard.session.handler.Handler;
import com.sk89q.worldguard.session.handler.Handler.Factory;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractSessionManagerWrapper;
public class SessionManagerWrapper extends AbstractSessionManagerWrapper
{
public SessionManagerWrapper(SessionManager sessionManager)
{
super(sessionManager);
}
@Override
public Session get(Player player)
{
return this.sessionManager.get(WorldGuardPlugin.inst().wrapPlayer(player));
}
@Override
public Session getIfPresent(Player player)
{
return this.sessionManager.getIfPresent(WorldGuardPlugin.inst().wrapPlayer(player));
}
@Override
public void registerHandler(Factory<? extends Handler> factory)
{
this.sessionManager.registerHandler(factory, null);
}
}

View file

@ -0,0 +1,62 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.SetFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionContainerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractSessionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.WorldGuardCommunicator;
public class WorldGuardSevenCommunicator implements WorldGuardCommunicator
{
private AbstractSessionManagerWrapper sessionManager;
private AbstractRegionContainerWrapper regionContainer;
@Override
public void onLoad() throws Exception
{
}
@Override
public void onEnable() throws Exception
{
this.sessionManager = new SessionManagerWrapper(WorldGuard.getInstance().getPlatform().getSessionManager());
this.regionContainer = new RegionContainerWrapper();
}
@Override
public FlagRegistry getFlagRegistry()
{
return WorldGuard.getInstance().getFlagRegistry();
}
@Override
public AbstractSessionManagerWrapper getSessionManager()
{
return this.sessionManager;
}
@Override
public AbstractRegionContainerWrapper getRegionContainer()
{
return this.regionContainer;
}
@Override
public LocalPlayer wrapPlayer(Player player)
{
return WorldGuardPlugin.inst().wrapPlayer(player);
}
@Override
public <T> SetFlag<T> getCustomSetFlag(String name, Flag<T> flag)
{
return new CustomSetFlag<T>(name, flag);
}
}

64
pom.xml
View file

@ -4,10 +4,11 @@
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<name>WorldGuardExtraFlags</name>
<version>4.0.0</version>
<version>4.1.0</version>
<packaging>pom</packaging>
<build>
<finalName>WorldGuardExtraFlagsPlugin</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -21,29 +22,6 @@
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.sk89q.com/repo/</url>
</repository>
<repository>
<id>ess-repo</id>
<url>http://repo.ess3.net/content/groups/essentials</url>
</repository>
<repository>
<id>empcraft</id>
<url>http://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/</url>
</repository>
<!-- FOR NOW -->
<repository>
<id>elMakers</id>
<url>http://maven.elmakers.com/repository/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
@ -51,33 +29,13 @@
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit</artifactId>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.boydti</groupId>
<artifactId>fawe-api</artifactId>
<version>18.07.27-3ed2e57-1163-20.5.2</version>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>Essentials</artifactId>
<version>2.13-SNAPSHOT</version>
</dependency>
</dependencies>
<modules>
<module>WG6</module>
<module>Common</module>
<module>WG</module>
<module>WG7</module>
<module>Spigot</module>
</modules>
</project>

View file

@ -1,53 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionContainerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6.WorldGuardSixCommunicator;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7.WorldGuardSevenCommunicator;
public interface WorldGuardCommunicator
{
public void onLoad() throws Exception;
public void onEnable() throws Exception;
public FlagRegistry getFlagRegistry();
public SessionManagerWrapper getSessionManager();
public RegionContainerWrapper getRegionContainer();
public LocalPlayer wrapPlayer(Player player);
public static WorldGuardCommunicator create()
{
try
{
Class.forName("com.sk89q.worldguard.WorldGuard"); //Only exists in WG 7
return new WorldGuardSevenCommunicator();
}
catch (Throwable ignored)
{
}
try
{
Class<?> clazz = Class.forName("com.sk89q.worldguard.bukkit.WorldGuardPlugin");
if (clazz.getMethod("getFlagRegistry") != null)
{
return new WorldGuardSixCommunicator();
}
}
catch (Throwable ignored)
{
ignored.printStackTrace();
}
return null;
}
}

View file

@ -1,9 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers;
import org.bukkit.World;
public abstract class RegionContainerWrapper
{
public abstract RegionQueryWrapper createQuery();
public abstract RegionManagerWrapper get(World world);
}

View file

@ -1,54 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.bukkit.World;
import com.sk89q.worldguard.protection.managers.RegionManager;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionContainerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionQueryWrapper;
public class RegionContainerWrapperSix extends RegionContainerWrapper
{
protected final Object regionContainer;
private Method createQueryMethod;
private Method getMethod;
public RegionContainerWrapperSix(Object regionContainer) throws NoSuchMethodException, SecurityException
{
this.regionContainer = regionContainer;
this.createQueryMethod = regionContainer.getClass().getMethod("createQuery");
this.getMethod = regionContainer.getClass().getMethod("get", World.class);
}
@Override
public RegionQueryWrapper createQuery()
{
try
{
return new RegionQueryWrapperSix(this.createQueryMethod.invoke(this.regionContainer));
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e)
{
throw new RuntimeException(e);
}
}
@Override
public RegionManagerWrapper get(World world)
{
try
{
return new RegionManagerWrapperSix((RegionManager)this.getMethod.invoke(this.regionContainer, world));
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
}

View file

@ -1,13 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6;
import com.sk89q.worldguard.protection.managers.RegionManager;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionManagerWrapper;
public class RegionManagerWrapperSix extends RegionManagerWrapper
{
public RegionManagerWrapperSix(RegionManager regionManager)
{
super(regionManager);
}
}

View file

@ -1,37 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.bukkit.Location;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionQueryWrapper;
public class RegionQueryWrapperSix extends RegionQueryWrapper
{
protected final Object regionQuery;
private Method getApplicableRegionsMethod;
public RegionQueryWrapperSix(Object regionQuery) throws NoSuchMethodException, SecurityException
{
this.regionQuery = regionQuery;
this.getApplicableRegionsMethod = regionQuery.getClass().getMethod("getApplicableRegions", Location.class);
}
@Override
public ApplicableRegionSet getApplicableRegions(Location location)
{
try
{
return (ApplicableRegionSet)this.getApplicableRegionsMethod.invoke(this.regionQuery, location);
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
}

View file

@ -1,70 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.SessionManager;
import com.sk89q.worldguard.session.handler.Handler;
import com.sk89q.worldguard.session.handler.Handler.Factory;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper;
public class SessionManagerWrapperSix extends SessionManagerWrapper
{
private Method getMethod;
private Method getIfPresentMethod;
private Method registerHandlerMethod;
public SessionManagerWrapperSix(SessionManager sessionManager) throws NoSuchMethodException, SecurityException
{
super(sessionManager);
this.getMethod = sessionManager.getClass().getMethod("get", Player.class);
this.getIfPresentMethod = sessionManager.getClass().getMethod("getIfPresent", Player.class);
this.registerHandlerMethod = sessionManager.getClass().getMethod("registerHandler", Factory.class, Factory.class);
}
@Override
public Session get(Player player)
{
try
{
return (Session)this.getMethod.invoke(this.sessionManager, player);
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
@Override
public Session getIfPresent(Player player)
{
try
{
return (Session)this.getIfPresentMethod.invoke(this.sessionManager, player);
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
@Override
public void registerHandler(Factory<? extends Handler> factory)
{
try
{
this.registerHandlerMethod.invoke(this.sessionManager, factory, null);
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
}

View file

@ -1,61 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6;
import java.lang.reflect.Method;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import com.sk89q.worldguard.session.SessionManager;
import net.goldtreeservers.worldguardextraflags.wg.legacy.WorldGuardCommunicator;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionContainerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper;
public class WorldGuardSixCommunicator implements WorldGuardCommunicator
{
private FlagRegistry flagRegistry;
private SessionManagerWrapper sessionManager;
private RegionContainerWrapper regionContainer;
public void onLoad() throws Exception
{
Method getFlagRegistryMethod = WorldGuardPlugin.class.getMethod("getFlagRegistry");
this.flagRegistry = (FlagRegistry)getFlagRegistryMethod.invoke(WorldGuardPlugin.inst());
}
public void onEnable() throws Exception
{
Method getSessionManagerMethod = WorldGuardPlugin.class.getMethod("getSessionManager");
Method getRegionContainerMethod = WorldGuardPlugin.class.getMethod("getRegionContainer");
this.sessionManager = new SessionManagerWrapperSix((SessionManager)getSessionManagerMethod.invoke(WorldGuardPlugin.inst()));
this.regionContainer = new RegionContainerWrapperSix(getRegionContainerMethod.invoke(WorldGuardPlugin.inst()));
}
@Override
public FlagRegistry getFlagRegistry()
{
return this.flagRegistry;
}
@Override
public SessionManagerWrapper getSessionManager()
{
return this.sessionManager;
}
@Override
public RegionContainerWrapper getRegionContainer()
{
return this.regionContainer;
}
@Override
public LocalPlayer wrapPlayer(Player player)
{
return WorldGuardPlugin.inst().wrapPlayer(player);
}
}

View file

@ -1,29 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7;
import org.bukkit.World;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionContainerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionQueryWrapper;
@RequiredArgsConstructor
public class RegionContainerWrapperSeven extends RegionContainerWrapper
{
protected final RegionContainer regionContainer;
@Override
public RegionQueryWrapper createQuery()
{
return new RegionQueryWrapperSeven(this.regionContainer.createQuery());
}
@Override
public RegionManagerWrapper get(World world)
{
return new RegionManagerWrapperSeven(this.regionContainer.get(BukkitAdapter.adapt(world)));
}
}

View file

@ -1,13 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7;
import com.sk89q.worldguard.protection.managers.RegionManager;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionManagerWrapper;
public class RegionManagerWrapperSeven extends RegionManagerWrapper
{
public RegionManagerWrapperSeven(RegionManager regionManager)
{
super(regionManager);
}
}

View file

@ -1,37 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.SessionManager;
import com.sk89q.worldguard.session.handler.Handler;
import com.sk89q.worldguard.session.handler.Handler.Factory;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper;
public class SessionManagerWrapperSeven extends SessionManagerWrapper
{
public SessionManagerWrapperSeven(SessionManager sessionManager)
{
super(sessionManager);
}
@Override
public Session get(Player player)
{
return this.sessionManager.get(WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().wrapPlayer(player));
}
@Override
public Session getIfPresent(Player player)
{
return this.sessionManager.getIfPresent(WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().wrapPlayer(player));
}
@Override
public void registerHandler(Factory<? extends Handler> factory)
{
this.sessionManager.registerHandler(factory, null);
}
}

View file

@ -1,57 +0,0 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import net.goldtreeservers.worldguardextraflags.wg.legacy.WorldGuardCommunicator;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionContainerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper;
public class WorldGuardSevenCommunicator implements WorldGuardCommunicator
{
private SessionManagerWrapper sessionManager;
private RegionContainerWrapper regionContainer;
public WorldGuardSevenCommunicator()
{
}
@Override
public void onLoad() throws Exception
{
}
@Override
public void onEnable() throws Exception
{
this.sessionManager = new SessionManagerWrapperSeven(WorldGuard.getInstance().getPlatform().getSessionManager());
this.regionContainer = new RegionContainerWrapperSeven(WorldGuard.getInstance().getPlatform().getRegionContainer());
}
@Override
public FlagRegistry getFlagRegistry()
{
return WorldGuard.getInstance().getFlagRegistry();
}
@Override
public SessionManagerWrapper getSessionManager()
{
return this.sessionManager;
}
@Override
public RegionContainerWrapper getRegionContainer()
{
return this.regionContainer;
}
@Override
public LocalPlayer wrapPlayer(Player player)
{
return WorldGuardPlugin.inst().wrapPlayer(player);
}
}