Updated to WG 7 and support MC 1.13 offically

This version sitll has support for old WG 6 using some hacky stuff

Closes #43
This commit is contained in:
isokissa3 2018-07-29 19:27:50 +03:00
parent 3c3fc1f660
commit a4751cd6dd
48 changed files with 1028 additions and 336 deletions

66
pom.xml
View file

@ -4,6 +4,8 @@
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<name>WorldGuardExtraFlags</name>
<version>4.0.0</version>
<build>
<finalName>WorldGuardExtraFlagsPlugin</finalName>
<plugins>
@ -18,6 +20,7 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
@ -35,43 +38,46 @@
<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>
<!--Spigot API-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--WorldGuard -->
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
<version>6.1.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.elseland.xikage</groupId>
<artifactId>MythicMobs</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>com.boydti</groupId>
<artifactId>fawe-api</artifactId>
<version>17.07.12-6b6f285-750-13.7.8</version>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>Essentials</artifactId>
<version>2.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<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>
<version>3.0.4</version>
</project>

View file

@ -7,10 +7,11 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import lombok.Getter;
import net.goldtreeservers.worldguardextraflags.essentials.EssentialsUtils;
import net.goldtreeservers.worldguardextraflags.fawe.FAWEUtils;
import net.goldtreeservers.worldguardextraflags.essentials.EssentialsHelper;
import net.goldtreeservers.worldguardextraflags.fawe.FAWEHelper;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.listeners.BlockListener;
import net.goldtreeservers.worldguardextraflags.listeners.EntityListener;
@ -18,7 +19,6 @@ import net.goldtreeservers.worldguardextraflags.listeners.EntityListenerOnePoint
import net.goldtreeservers.worldguardextraflags.listeners.PlayerListener;
import net.goldtreeservers.worldguardextraflags.listeners.WorldEditListener;
import net.goldtreeservers.worldguardextraflags.listeners.WorldListener;
import net.goldtreeservers.worldguardextraflags.mb.MythicMobsUtils;
import net.goldtreeservers.worldguardextraflags.utils.WorldUtils;
import net.goldtreeservers.worldguardextraflags.wg.handlers.BlockedEffectsFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.CommandOnEntryFlagHandler;
@ -33,17 +33,20 @@ 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;
public class WorldGuardExtraFlagsPlugin extends JavaPlugin
{
@Getter private static WorldGuardExtraFlagsPlugin plugin;
@Getter private static WorldGuardPlugin worldGuardPlugin;
@Getter private static WorldEditPlugin worldEditPlugin;
@Getter private WorldGuardPlugin worldGuardPlugin;
@Getter private WorldEditPlugin worldEditPlugin;
@Getter private WorldGuardCommunicator worldGuardCommunicator;
@Getter private static boolean essentialsPluginEnabled;
@Getter private static boolean mythicMobsPluginEnabled;
@Getter private static boolean fastAsyncWorldEditPluginEnabled;
@Getter private EssentialsHelper essentialsHelper;
@Getter private FAWEHelper faweHelper;
public WorldGuardExtraFlagsPlugin()
{
@ -53,38 +56,56 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
@Override
public void onLoad()
{
WorldGuardExtraFlagsPlugin.worldEditPlugin = (WorldEditPlugin)this.getServer().getPluginManager().getPlugin("WorldEdit");
this.worldEditPlugin = (WorldEditPlugin)this.getServer().getPluginManager().getPlugin("WorldEdit");
this.worldGuardPlugin = (WorldGuardPlugin)this.getServer().getPluginManager().getPlugin("WorldGuard");
WorldGuardExtraFlagsPlugin.worldGuardPlugin = (WorldGuardPlugin)this.getServer().getPluginManager().getPlugin("WorldGuard");
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.TELEPORT_ON_ENTRY);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.TELEPORT_ON_EXIT);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.COMMAND_ON_ENTRY);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.COMMAND_ON_EXIT);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.CONSOLE_COMMAND_ON_ENTRY);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.CONSOLE_COMMAND_ON_EXIT);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.WALK_SPEED);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.KEEP_INVENTORY);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.KEEP_EXP);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.CHAT_PREFIX);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.CHAT_SUFFIX);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.BLOCKED_EFFECTS);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.GODMODE);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.RESPAWN_LOCATION);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.WORLDEDIT);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.GIVE_EFFECTS);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.FLY);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.PLAY_SOUNDS);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.MYTHICMOB_EGGS);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.FROSTWALKER);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.NETHER_PORTALS);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.ALLOW_BLOCK_PLACE);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.DENY_BLOCK_PLACE);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.ALLOW_BLOCK_BREAK);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.DENY_BLOCK_BREAK);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.GLIDE);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.CHUNK_UNLOAD);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.ITEM_DURABILITY);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(Flags.JOIN_LOCATION);
this.worldGuardCommunicator = WorldGuardCommunicator.create();
if (this.worldGuardCommunicator == null)
{
throw new RuntimeException("Unsupported WorldGuard version: " + this.worldGuardPlugin.getDescription().getVersion());
}
try
{
this.worldGuardCommunicator.onLoad();
}
catch (Exception e)
{
this.getServer().getPluginManager().disablePlugin(this);
throw new RuntimeException("Failed to load WorldGuard communicator", e);
}
FlagRegistry flagRegistry = this.worldGuardCommunicator.getFlagRegistry();
flagRegistry.register(Flags.TELEPORT_ON_ENTRY);
flagRegistry.register(Flags.TELEPORT_ON_EXIT);
flagRegistry.register(Flags.COMMAND_ON_ENTRY);
flagRegistry.register(Flags.COMMAND_ON_EXIT);
flagRegistry.register(Flags.CONSOLE_COMMAND_ON_ENTRY);
flagRegistry.register(Flags.CONSOLE_COMMAND_ON_EXIT);
flagRegistry.register(Flags.WALK_SPEED);
flagRegistry.register(Flags.KEEP_INVENTORY);
flagRegistry.register(Flags.KEEP_EXP);
flagRegistry.register(Flags.CHAT_PREFIX);
flagRegistry.register(Flags.CHAT_SUFFIX);
flagRegistry.register(Flags.BLOCKED_EFFECTS);
flagRegistry.register(Flags.GODMODE);
flagRegistry.register(Flags.RESPAWN_LOCATION);
flagRegistry.register(Flags.WORLDEDIT);
flagRegistry.register(Flags.GIVE_EFFECTS);
flagRegistry.register(Flags.FLY);
flagRegistry.register(Flags.PLAY_SOUNDS);
flagRegistry.register(Flags.MYTHICMOB_EGGS);
flagRegistry.register(Flags.FROSTWALKER);
flagRegistry.register(Flags.NETHER_PORTALS);
flagRegistry.register(Flags.ALLOW_BLOCK_PLACE);
flagRegistry.register(Flags.DENY_BLOCK_PLACE);
flagRegistry.register(Flags.ALLOW_BLOCK_BREAK);
flagRegistry.register(Flags.DENY_BLOCK_BREAK);
flagRegistry.register(Flags.GLIDE);
flagRegistry.register(Flags.CHUNK_UNLOAD);
flagRegistry.register(Flags.ITEM_DURABILITY);
flagRegistry.register(Flags.JOIN_LOCATION);
//Soft dependencies, due to some compatibility issues or add flags related to a plugin
try
@ -92,27 +113,10 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
Plugin essentialsPlugin = WorldGuardExtraFlagsPlugin.getPlugin().getServer().getPluginManager().getPlugin("Essentials");
if (essentialsPlugin != null)
{
EssentialsUtils.onLoad(essentialsPlugin);
WorldGuardExtraFlagsPlugin.essentialsPluginEnabled = true;
this.essentialsHelper = new EssentialsHelper(this, essentialsPlugin);
}
}
catch(Throwable ex)
{
}
try
{
Plugin mythicMobsPlugin = this.getServer().getPluginManager().getPlugin("MythicMobs");
if (mythicMobsPlugin != null)
{
MythicMobsUtils.onLoad(mythicMobsPlugin);
WorldGuardExtraFlagsPlugin.mythicMobsPluginEnabled = true;
}
}
catch(Throwable ex)
catch(Throwable ignore)
{
}
@ -122,12 +126,10 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
Plugin fastAsyncWorldEditPlugin = this.getServer().getPluginManager().getPlugin("FastAsyncWorldEdit");
if (fastAsyncWorldEditPlugin != null)
{
FAWEUtils.onLoad(fastAsyncWorldEditPlugin);
WorldGuardExtraFlagsPlugin.fastAsyncWorldEditPluginEnabled = true;
this.faweHelper = new FAWEHelper(this, fastAsyncWorldEditPlugin);
}
}
catch(Throwable ex)
catch(Throwable ignore)
{
}
@ -136,30 +138,49 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
@Override
public void onEnable()
{
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(TeleportOnEntryFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(TeleportOnExitFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(CommandOnEntryFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(CommandOnExitFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(ConsoleCommandOnEntryFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(ConsoleCommandOnExitFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(WalkSpeedFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(BlockedEffectsFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(GodmodeFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(GiveEffectsFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(FlyFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(PlaySoundsFlagHandler.FACTORY, null);
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(GlideFlagHandler.FACTORY, null);
if (this.worldGuardCommunicator == null)
{
this.getServer().getPluginManager().disablePlugin(this);
return;
}
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
this.getServer().getPluginManager().registerEvents(new BlockListener(), this);
this.getServer().getPluginManager().registerEvents(new EntityListener(), this);
this.getServer().getPluginManager().registerEvents(new WorldListener(), this);
try
{
this.worldGuardCommunicator.onEnable();
}
catch (Exception e)
{
this.getServer().getPluginManager().disablePlugin(this);
throw new RuntimeException("Failed to enable WorldGuard communicator", e);
}
SessionManagerWrapper sessionManager = this.worldGuardCommunicator.getSessionManager();
sessionManager.registerHandler(TeleportOnEntryFlagHandler.FACTORY);
sessionManager.registerHandler(TeleportOnExitFlagHandler.FACTORY);
sessionManager.registerHandler(CommandOnEntryFlagHandler.FACTORY);
sessionManager.registerHandler(CommandOnExitFlagHandler.FACTORY);
sessionManager.registerHandler(ConsoleCommandOnEntryFlagHandler.FACTORY);
sessionManager.registerHandler(ConsoleCommandOnExitFlagHandler.FACTORY);
sessionManager.registerHandler(WalkSpeedFlagHandler.FACTORY);
sessionManager.registerHandler(BlockedEffectsFlagHandler.FACTORY);
sessionManager.registerHandler(GodmodeFlagHandler.FACTORY);
sessionManager.registerHandler(GiveEffectsFlagHandler.FACTORY);
sessionManager.registerHandler(FlyFlagHandler.FACTORY);
sessionManager.registerHandler(PlaySoundsFlagHandler.FACTORY);
sessionManager.registerHandler(GlideFlagHandler.FACTORY);
this.getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
this.getServer().getPluginManager().registerEvents(new BlockListener(this), this);
this.getServer().getPluginManager().registerEvents(new EntityListener(this), this);
this.getServer().getPluginManager().registerEvents(new WorldListener(this), this);
try
{
if (EntityToggleGlideEvent.class != null) //LOL, Just making it look nice xD
{
this.getServer().getPluginManager().registerEvents(new EntityListenerOnePointNine(), this);
this.getServer().getPluginManager().registerEvents(new EntityListenerOnePointNine(this), this);
}
}
catch(NoClassDefFoundError ignored)
@ -167,18 +188,18 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
}
if (WorldGuardExtraFlagsPlugin.isFastAsyncWorldEditPluginEnabled())
if (this.faweHelper != null)
{
FAWEUtils.onEnable();
this.faweHelper.onEnable();
}
else
{
WorldGuardExtraFlagsPlugin.getWorldEditPlugin().getWorldEdit().getEventBus().register(new WorldEditListener());
this.worldEditPlugin.getWorldEdit().getEventBus().register(new WorldEditListener());
}
if (WorldGuardExtraFlagsPlugin.isEssentialsPluginEnabled())
if (this.essentialsHelper != null)
{
EssentialsUtils.onEnable();
this.essentialsHelper.onEnable();
}
for(World world : this.getServer().getWorlds())

View file

@ -0,0 +1,27 @@
package net.goldtreeservers.worldguardextraflags.essentials;
import org.bukkit.plugin.Plugin;
import com.earth2me.essentials.Essentials;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.listeners.EssentialsListener;
@RequiredArgsConstructor
public class EssentialsHelper
{
@Getter private final WorldGuardExtraFlagsPlugin plugin;
@Getter private final Essentials essentialsPlugin;
public EssentialsHelper(WorldGuardExtraFlagsPlugin plugin, Plugin essentialsPlugin)
{
this(plugin, (Essentials)essentialsPlugin);
}
public void onEnable()
{
this.plugin.getServer().getPluginManager().registerEvents(new EssentialsListener(this.plugin, this.essentialsPlugin), this.plugin);
}
}

View file

@ -1,24 +0,0 @@
package net.goldtreeservers.worldguardextraflags.essentials;
import org.bukkit.plugin.Plugin;
import com.earth2me.essentials.Essentials;
import lombok.Getter;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.listeners.EssentialsListener;
public class EssentialsUtils
{
@Getter private static Essentials plugin;
public static void onLoad(Plugin essentialsPlugin)
{
EssentialsUtils.plugin = (Essentials)essentialsPlugin;
}
public static void onEnable()
{
WorldGuardExtraFlagsPlugin.getPlugin().getServer().getPluginManager().registerEvents(new EssentialsListener(), WorldGuardExtraFlagsPlugin.getPlugin());
}
}

View file

@ -0,0 +1,21 @@
package net.goldtreeservers.worldguardextraflags.fawe;
import org.bukkit.plugin.Plugin;
import com.boydti.fawe.FaweAPI;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
@RequiredArgsConstructor
public class FAWEHelper
{
@Getter private final WorldGuardExtraFlagsPlugin plugin;
@Getter private final Plugin fawePlugin;
public void onEnable()
{
FaweAPI.addMaskManager(new FaweWorldEditFlagMaskManager(this.plugin));
}
}

View file

@ -1,22 +0,0 @@
package net.goldtreeservers.worldguardextraflags.fawe;
import org.bukkit.plugin.Plugin;
import com.boydti.fawe.FaweAPI;
import lombok.Getter;
public class FAWEUtils
{
@Getter private static Plugin plugin;
public static void onLoad(Plugin plugin)
{
FAWEUtils.plugin = plugin;
}
public static void onEnable()
{
FaweAPI.addMaskManager(new FaweWorldEditFlagMaskManager());
}
}

View file

@ -6,27 +6,30 @@ import org.bukkit.entity.Player;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.FaweMaskManager;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
import com.sk89q.worldguard.protection.managers.RegionManager;
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;
public class FaweWorldEditFlagMaskManager extends FaweMaskManager<Player>
{
public FaweWorldEditFlagMaskManager()
private final WorldGuardExtraFlagsPlugin plugin;
public FaweWorldEditFlagMaskManager(WorldGuardExtraFlagsPlugin plugin)
{
super("WorldGuardExtraFlags");
super(plugin.getName());
this.plugin = plugin;
}
public ProtectedRegion getRegion(Player player, Location loc)
{
final com.sk89q.worldguard.LocalPlayer localplayer = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().wrapPlayer(player);
RegionManager manager = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionManager(player.getWorld());
final com.sk89q.worldguard.LocalPlayer localplayer = this.plugin.getWorldGuardCommunicator().wrapPlayer(player);
RegionManagerWrapper manager = this.plugin.getWorldGuardCommunicator().getRegionContainer().get(player.getWorld());
final ProtectedRegion global = manager.getRegion("__global__");
if (global != null && !isDenied(localplayer, global))
{
@ -52,7 +55,9 @@ public class FaweWorldEditFlagMaskManager extends FaweMaskManager<Player>
@Override
public FaweMask getMask(FawePlayer<Player> fawePlayer)
{
final Player player = fawePlayer.parent;
return null; //Problems here due to FaweMask using LocalWorld
/*final Player player = fawePlayer.parent;
final Location location = player.getLocation();
final ProtectedRegion myregion = this.getRegion(player, location);
@ -83,6 +88,6 @@ public class FaweWorldEditFlagMaskManager extends FaweMaskManager<Player>
else
{
return null;
}
}*/
}
}

View file

@ -18,13 +18,18 @@ import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
@RequiredArgsConstructor
public class BlockListener implements Listener
{
@Getter private final WorldGuardExtraFlagsPlugin plugin;
@EventHandler(ignoreCancelled = true)
public void onEntityBlockFormEvent(EntityBlockFormEvent event)
{
@ -33,7 +38,7 @@ public class BlockListener implements Listener
BlockState newState = event.getNewState();
if (newState.getType() == Material.FROSTED_ICE)
{
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(newState.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(newState.getLocation());
Entity entity = event.getEntity();
if (entity instanceof Player)
@ -68,7 +73,7 @@ public class BlockListener implements Listener
for(Block block : event.getBlocks())
{
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
Set<Material> state = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.ALLOW_BLOCK_PLACE);
if (state != null && state.contains(block.getType()))
@ -106,7 +111,7 @@ public class BlockListener implements Listener
for(Block block : event.getBlocks())
{
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
Set<Material> state = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.ALLOW_BLOCK_BREAK);
if (state != null && state.contains(block.getType()))

View file

@ -8,11 +8,16 @@ import org.bukkit.event.world.PortalCreateEvent;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
@RequiredArgsConstructor
public class EntityListener implements Listener
{
@Getter private final WorldGuardExtraFlagsPlugin plugin;
@EventHandler(ignoreCancelled = true)
public void onPortalCreateEvent(PortalCreateEvent event)
{
@ -20,7 +25,7 @@ public class EntityListener implements Listener
{
//Unable to get the player who created it....
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
if (regions.queryValue(null, Flags.NETHER_PORTALS) == State.DENY)
{
event.setCancelled(true);

View file

@ -3,20 +3,24 @@ package net.goldtreeservers.worldguardextraflags.listeners;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityToggleGlideEvent;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
@RequiredArgsConstructor
public class EntityListenerOnePointNine implements Listener
{
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@Getter private final WorldGuardExtraFlagsPlugin plugin;
@EventHandler(ignoreCancelled = true)
public void onEntityToggleGlideEvent(EntityToggleGlideEvent event)
{
Entity entity = event.getEntity();
@ -24,9 +28,9 @@ public class EntityListenerOnePointNine implements Listener
{
Player player = (Player)entity;
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
State state = regions.queryValue(WorldGuardUtils.wrapPlayer(player), Flags.GLIDE);
State state = WorldGuardUtils.queryState(player, player.getWorld(), regions.getRegions(), Flags.GLIDE);
if (state != null)
{
event.setCancelled(true);

View file

@ -1,37 +1,63 @@
package net.goldtreeservers.worldguardextraflags.listeners;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import com.earth2me.essentials.Essentials;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.ess3.api.IUser;
import net.ess3.api.events.GodStatusChangeEvent;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.handlers.FlyFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.GodmodeFlagHandler;
@RequiredArgsConstructor
public class EssentialsListener implements Listener
{
@Getter private final WorldGuardExtraFlagsPlugin plugin;
@Getter private final Essentials essentialsPlugin;
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onGodStatusChangeEvent(GodStatusChangeEvent event)
{
IUser user = event.getAffected();
Player player = user.getBase();
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
State state = WorldGuardUtils.queryState(player, player.getWorld(), regions.getRegions(), Flags.GODMODE);
if (state != null)
{
if (WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(GodmodeFlagHandler.class).getIsGodmodeEnabled() != null)
if (this.plugin.getWorldGuardCommunicator().getSessionManager().get(player).getHandler(GodmodeFlagHandler.class).getIsGodmodeEnabled() != null)
{
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerChangedWorldEvent(PlayerChangedWorldEvent event)
{
Player player = event.getPlayer();
if (player.getGameMode() != GameMode.CREATIVE && !this.essentialsPlugin.getUser(player).isAuthorized("essentials.fly"))
{
//Essentials now turns off flight, fuck him
Boolean value = this.plugin.getWorldGuardCommunicator().getSessionManager().get(player).getHandler(FlyFlagHandler.class).getCurrentValue();
if (value != null)
{
player.setAllowFlight(value);
}
}
}
}

View file

@ -1,6 +1,5 @@
package net.goldtreeservers.worldguardextraflags.listeners;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -8,7 +7,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerItemDamageEvent;
@ -21,26 +19,29 @@ import org.bukkit.potion.Potion;
import org.bukkit.scheduler.BukkitRunnable;
import org.spigotmc.event.player.PlayerSpawnLocationEvent;
import com.sk89q.worldedit.Location;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
import com.sk89q.worldguard.session.Session;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.essentials.EssentialsUtils;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.we.WorldEditUtils;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.handlers.FlyFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.GiveEffectsFlagHandler;
@SuppressWarnings("deprecation")
@RequiredArgsConstructor
public class PlayerListener implements Listener
{
@Getter private final WorldGuardExtraFlagsPlugin plugin;
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerTeleportEvent(PlayerTeleportEvent event)
{
Player player = event.getPlayer();
player.removeMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META, WorldGuardExtraFlagsPlugin.getPlugin());
}
@ -49,7 +50,7 @@ public class PlayerListener implements Listener
{
Player player = event.getEntity();
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
Boolean keepInventory = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.KEEP_INVENTORY);
if (Boolean.TRUE.equals(keepInventory))
@ -71,7 +72,7 @@ public class PlayerListener implements Listener
{
Player player = event.getPlayer();
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
String prefix = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.CHAT_PREFIX);
String suffix = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.CHAT_SUFFIX);
@ -92,12 +93,12 @@ public class PlayerListener implements Listener
{
Player player = event.getPlayer();
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
Location respawnLocation = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.RESPAWN_LOCATION);
Object respawnLocation = WorldGuardUtils.queryValueUnchecked(player, player.getWorld(), regions.getRegions(), Flags.RESPAWN_LOCATION);
if (respawnLocation != null)
{
event.setRespawnLocation(BukkitUtil.toLocation(respawnLocation));
event.setRespawnLocation(WorldEditUtils.toLocation(respawnLocation));
}
}
@ -109,14 +110,14 @@ public class PlayerListener implements Listener
ItemMeta itemMeta = event.getItem().getItemMeta();
if (itemMeta instanceof PotionMeta)
{
WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(GiveEffectsFlagHandler.class).drinkPotion(player, Potion.fromItemStack(event.getItem()).getEffects());
this.plugin.getWorldGuardCommunicator().getSessionManager().get(player).getHandler(GiveEffectsFlagHandler.class).drinkPotion(player, Potion.fromItemStack(event.getItem()).getEffects());
}
else
{
Material material = event.getItem().getType();
if (material == Material.MILK_BUCKET)
{
WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(GiveEffectsFlagHandler.class).drinkMilk(player);
this.plugin.getWorldGuardCommunicator().getSessionManager().get(player).getHandler(GiveEffectsFlagHandler.class).drinkMilk(player);
}
}
}
@ -126,7 +127,7 @@ public class PlayerListener implements Listener
{
Player player = event.getPlayer();
Session wgSession = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().getIfPresent(player);
Session wgSession = this.plugin.getWorldGuardCommunicator().getSessionManager().getIfPresent(player);
if (wgSession != null)
{
Boolean value = wgSession.getHandler(FlyFlagHandler.class).getCurrentValue();
@ -157,80 +158,19 @@ public class PlayerListener implements Listener
private void checkFlyStatus(Player player)
{
Boolean value = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(FlyFlagHandler.class).getCurrentValue();
Boolean value = this.plugin.getWorldGuardCommunicator().getSessionManager().get(player).getHandler(FlyFlagHandler.class).getCurrentValue();
if (value != null)
{
player.setAllowFlight(value);
}
}
//Re-enable if needed and the plugin checks for cancelled events
/*@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteractEvent(PlayerInteractEvent event)
{
if (WorldGuardExtraFlagsPlugin.isMythicMobsPluginEnabled())
{
Player player = event.getPlayer();
if (!WorldGuardUtils.hasBypass(player))
{
Action action = event.getAction();
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
{
if (event.hasItem())
{
ItemStack item = event.getItem();
if (item.getType() == Material.MONSTER_EGG)
{
if (item.getItemMeta().hasLore())
{
List<String> lore = item.getItemMeta().getLore();
if (lore.get(0).equals(ChatColor.DARK_GRAY + "" + ChatColor.ITALIC + "A Mythical Egg that can"))
{
MythicMob mm = EggManager.getMythicMobFromEgg(lore.get(2));
if (mm != null)
{
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(action == Action.RIGHT_CLICK_BLOCK ? event.getClickedBlock().getLocation() : player.getLocation());
if (regions.queryValue(WorldGuardUtils.wrapPlayer(player), Flags.MYTHICMOB_EGGS) == State.DENY)
{
event.setCancelled(true);
event.setUseItemInHand(Result.DENY);
}
}
}
}
}
}
}
}
}
}*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerChangedWorldEvent(PlayerChangedWorldEvent event)
{
Player player = event.getPlayer();
if (WorldGuardExtraFlagsPlugin.isEssentialsPluginEnabled()) //Essentials how dare u do this to me!?!
{
if (player.getGameMode() != GameMode.CREATIVE && !EssentialsUtils.getPlugin().getUser(player).isAuthorized("essentials.fly"))
{
//Essentials now turns off flight, fuck him
Boolean value = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(FlyFlagHandler.class).getCurrentValue();
if (value != null)
{
player.setAllowFlight(value);
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerItemDamageEvent(PlayerItemDamageEvent event)
{
Player player = event.getPlayer();
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
if (WorldGuardUtils.queryState(player, player.getWorld(), regions.getRegions(), Flags.ITEM_DURABILITY) == State.DENY)
{
event.setCancelled(true);
@ -242,12 +182,12 @@ public class PlayerListener implements Listener
{
Player player = event.getPlayer();
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
Location location = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.JOIN_LOCATION);
Object location = WorldGuardUtils.queryValueUnchecked(player, player.getWorld(), regions.getRegions(), Flags.JOIN_LOCATION);
if (location != null)
{
event.setSpawnLocation(BukkitUtil.toLocation(location));
event.setSpawnLocation(WorldEditUtils.toLocation(location));
}
}
@ -256,7 +196,7 @@ public class PlayerListener implements Listener
{
Player player = event.getPlayer();
Boolean value = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(FlyFlagHandler.class).getCurrentValue();
Boolean value = this.plugin.getWorldGuardCommunicator().getSessionManager().get(player).getHandler(FlyFlagHandler.class).getCurrentValue();
if (value != null)
{
player.setAllowFlight(value);

View file

@ -13,12 +13,17 @@ import com.sk89q.worldguard.protection.flags.StateFlag.State;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.utils.WorldUtils;
@RequiredArgsConstructor
public class WorldListener implements Listener
{
@Getter private final WorldGuardExtraFlagsPlugin plugin;
@EventHandler(priority = EventPriority.MONITOR)
public void onWorldLoadEvent(WorldLoadEvent event)
{
@ -30,7 +35,8 @@ public class WorldListener implements Listener
{
World world = event.getWorld();
Chunk chunk = event.getChunk();
for (ProtectedRegion region : WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionManager(world).getApplicableRegions(new ProtectedCuboidRegion("UnloadChunkFlagTester", new BlockVector(chunk.getX() * 16, 0, chunk.getZ() * 16), new BlockVector(chunk.getX() * 16 + 15, 256, chunk.getZ() * 16 + 15))))
for (ProtectedRegion region : this.plugin.getWorldGuardCommunicator().getRegionContainer().get(world).getApplicableRegions(new ProtectedCuboidRegion("UnloadChunkFlagTester", new BlockVector(chunk.getX() * 16, 0, chunk.getZ() * 16), new BlockVector(chunk.getX() * 16 + 15, 256, chunk.getZ() * 16 + 15))))
{
if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY)
{

View file

@ -1,16 +0,0 @@
package net.goldtreeservers.worldguardextraflags.mb;
import org.bukkit.plugin.Plugin;
import lombok.Getter;
import net.elseland.xikage.MythicMobs.MythicMobs;
public class MythicMobsUtils
{
@Getter private static MythicMobs mythicMobsPlugin;
public static void onLoad(Plugin mythicMobsPlugin)
{
MythicMobsUtils.mythicMobsPlugin = (MythicMobs)mythicMobsPlugin;
}
}

View file

@ -1,9 +1,8 @@
package net.goldtreeservers.worldguardextraflags.utils;
import org.bukkit.Location;
import org.bukkit.World;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
@ -14,18 +13,18 @@ public class WorldUtils
{
public static void doUnloadChunkFlagCheck(World world)
{
for (ProtectedRegion region : WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionManager(world).getRegions().values())
for (ProtectedRegion region : WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getRegionContainer().get(world).getRegions().values())
{
if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY)
{
WorldGuardExtraFlagsPlugin.getPlugin().getLogger().info("Loading chunks for region " + region.getId() + " located in " + world.getName() + " due to chunk-unload flag being deny");
Location min = BukkitUtil.toLocation(world, region.getMinimumPoint());
Location max = BukkitUtil.toLocation(world, region.getMaximumPoint());
BlockVector min = region.getMinimumPoint();
BlockVector max = region.getMaximumPoint();
for(int x = min.getChunk().getX(); x <= max.getChunk().getX(); x++)
for(int x = min.getBlockX() << 16; x <= max.getBlockX() << 16; x++)
{
for(int z = min.getChunk().getZ(); z <= max.getChunk().getZ(); z++)
for(int z = max.getBlockZ() << 16; z <= max.getBlockZ() << 16; z++)
{
world.getChunkAt(x, z).load(true);
}

View file

@ -0,0 +1,40 @@
package net.goldtreeservers.worldguardextraflags.we;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
public abstract class AbstractWorldEditFlagHandler extends AbstractDelegateExtent
{
protected final org.bukkit.World world;
protected final org.bukkit.entity.Player player;
protected AbstractWorldEditFlagHandler(World world, Extent extent, Player player)
{
super(extent);
this.world = WorldGuardExtraFlagsPlugin.getPlugin().getServer().getWorld(world.getName());
this.player = WorldGuardExtraFlagsPlugin.getPlugin().getServer().getPlayer(player.getUniqueId());
}
public abstract boolean setBlock(Vector location, BlockState block) throws WorldEditException;
//TODO: Prebuild list
@Override
public boolean setBlock(Vector location, @SuppressWarnings("rawtypes") BlockStateHolder block) throws WorldEditException
{
if (this.setBlock(location, block.toImmutableState()))
{
return super.setBlock(location, block);
}
return false;
}
}

View file

@ -2,12 +2,10 @@ package net.goldtreeservers.worldguardextraflags.we;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
@ -15,29 +13,22 @@ import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
public class WorldEditFlagHandler extends AbstractDelegateExtent
public class WorldEditFlagHandler extends AbstractWorldEditFlagHandler
{
private final org.bukkit.World world;
private final org.bukkit.entity.Player player;
public WorldEditFlagHandler(World world, Extent extent, Player player)
{
super(extent);
this.world = WorldGuardExtraFlagsPlugin.getPlugin().getServer().getWorld(world.getName());
this.player = WorldGuardExtraFlagsPlugin.getPlugin().getServer().getPlayer(player.getUniqueId());
super(world, extent, player);
}
//TODO: Prebuild list
@Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException
@Override
public boolean setBlock(Vector location, BlockState block) throws WorldEditException
{
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(BukkitUtil.toLocation(this.world, location));
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getRegionContainer().get(this.world).getApplicableRegions(location);
State state = WorldGuardUtils.queryState(this.player, this.world, regions.getRegions(), Flags.WORLDEDIT);
if (state != State.DENY)
{
return super.setBlock(location, block);
return true;
}
return false;

View file

@ -0,0 +1,45 @@
package net.goldtreeservers.worldguardextraflags.we;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.util.Location;
public class WorldEditUtils
{
private static Method legacyToLocationMethod;
static
{
try
{
Class<?> bukkitUtilClass = Class.forName("com.sk89q.worldedit.bukkit.BukkitUtil");
Class<?> legacyLocationClass = Class.forName("com.sk89q.worldedit.Location");
WorldEditUtils.legacyToLocationMethod = bukkitUtilClass.getMethod("toLocation", legacyLocationClass);
}
catch (Throwable ignore)
{
}
}
public static org.bukkit.Location toLocation(Object location)
{
if (WorldEditUtils.legacyToLocationMethod != null)
{
try
{
return (org.bukkit.Location)WorldEditUtils.legacyToLocationMethod.invoke(null, location);
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e)
{
throw new RuntimeException("Unsupported WorldEdit version");
}
}
else
{
return BukkitAdapter.adapt((Location)location);
}
}
}

View file

@ -22,9 +22,9 @@ public class WorldGuardUtils
{
public static final String PREVENT_TELEPORT_LOOP_META = "WGEFP: TLP";
public static LocalPlayer wrapPlayer(Player player)
private static LocalPlayer wrapPlayer(Player player)
{
return WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().wrapPlayer(player);
return WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().wrapPlayer(player);
}
public static boolean hasBypass(Player player, World world, ProtectedRegion region, Flag<?> flag)
@ -48,6 +48,12 @@ public class WorldGuardUtils
return WorldGuardUtils.createFlagValueCalculator(player, world, regions, flag).queryValue(WorldGuardUtils.wrapPlayer(player), flag);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Object queryValueUnchecked(Player player, World world, Set<ProtectedRegion> regions, Flag flag)
{
return WorldGuardUtils.createFlagValueCalculator(player, world, regions, flag).queryValue(WorldGuardUtils.wrapPlayer(player), flag);
}
public static <T> Collection<T> queryAllValues(Player player, World world, Set<ProtectedRegion> regions, Flag<T> flag)
{
return WorldGuardUtils.createFlagValueCalculator(player, world, regions, flag).queryAllValues(WorldGuardUtils.wrapPlayer(player), flag);
@ -66,7 +72,7 @@ public class WorldGuardUtils
NormativeOrders.sort(checkForRegions);
ProtectedRegion global = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionManager(world).getRegion(ProtectedRegion.GLOBAL_REGION);
ProtectedRegion global = WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getRegionContainer().get(world).getRegion(ProtectedRegion.GLOBAL_REGION);
if (global != null) //Global region can be null
{
if (WorldGuardUtils.hasBypass(player, world, global, flag)) //Lets do like this for now to reduce dublicated code

View file

@ -21,8 +21,9 @@ 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;
public class BlockedEffectsFlagHandler extends Handler
public class BlockedEffectsFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<BlockedEffectsFlagHandler>
@ -42,13 +43,13 @@ public class BlockedEffectsFlagHandler extends Handler
this.removedEffects = new HashMap<>();
}
@Override
public void initialize(Player player, Location current, ApplicableRegionSet set)
{
this.check(player, set);
}
@Override
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
{
@ -56,7 +57,7 @@ public class BlockedEffectsFlagHandler extends Handler
return true;
}
@Override
public void tick(Player player, ApplicableRegionSet set)
{

View file

@ -16,8 +16,9 @@ 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;
public class CommandOnEntryFlagHandler extends Handler
public class CommandOnEntryFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<CommandOnEntryFlagHandler>

View file

@ -16,8 +16,9 @@ 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;
public class CommandOnExitFlagHandler extends Handler
public class CommandOnExitFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<CommandOnExitFlagHandler>

View file

@ -16,8 +16,9 @@ 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;
public class ConsoleCommandOnEntryFlagHandler extends Handler
public class ConsoleCommandOnEntryFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<ConsoleCommandOnEntryFlagHandler>

View file

@ -16,8 +16,9 @@ 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;
public class ConsoleCommandOnExitFlagHandler extends Handler
public class ConsoleCommandOnExitFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<ConsoleCommandOnExitFlagHandler>

View file

@ -15,8 +15,9 @@ 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;
public class FlyFlagHandler extends Handler
public class FlyFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<FlyFlagHandler>

View file

@ -25,8 +25,9 @@ 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;
public class GiveEffectsFlagHandler extends Handler
public class GiveEffectsFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<GiveEffectsFlagHandler>
@ -158,7 +159,7 @@ public class GiveEffectsFlagHandler extends Handler
{
this.removedEffects.clear();
this.check(player, WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()));
this.check(player, WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()));
}
public void drinkPotion(Player player, Collection<PotionEffect> effects)
@ -168,6 +169,6 @@ public class GiveEffectsFlagHandler extends Handler
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.check(player, WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()));
this.check(player, WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()));
}
}

View file

@ -14,8 +14,9 @@ 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;
public class GlideFlagHandler extends Handler
public class GlideFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<GlideFlagHandler>

View file

@ -2,8 +2,6 @@ package net.goldtreeservers.worldguardextraflags.wg.handlers;
import java.util.Set;
import javax.annotation.Nullable;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -17,11 +15,12 @@ import com.sk89q.worldguard.session.handler.Handler;
import lombok.Getter;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.essentials.EssentialsUtils;
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;
public class GodmodeFlagHandler extends Handler
public class GodmodeFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<GodmodeFlagHandler>
@ -68,9 +67,10 @@ public class GodmodeFlagHandler extends Handler
this.isGodmodeEnabled = null;
}
if (WorldGuardExtraFlagsPlugin.isEssentialsPluginEnabled())
EssentialsHelper helper = WorldGuardExtraFlagsPlugin.getPlugin().getEssentialsHelper();
if (helper != null)
{
User user = EssentialsUtils.getPlugin().getUser(player);
User user = helper.getEssentialsPlugin().getUser(player);
if (this.isGodmodeEnabled != null)
{
@ -96,7 +96,6 @@ public class GodmodeFlagHandler extends Handler
}
}
@Nullable
@Override
public State getInvincibility(Player player)
{

View file

@ -21,8 +21,9 @@ 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;
public class PlaySoundsFlagHandler extends Handler
public class PlaySoundsFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<PlaySoundsFlagHandler>

View file

@ -6,7 +6,6 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
@ -15,9 +14,11 @@ import com.sk89q.worldguard.session.handler.Handler;
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;
public class TeleportOnEntryFlagHandler extends Handler
public class TeleportOnEntryFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<TeleportOnEntryFlagHandler>
@ -34,17 +35,16 @@ public class TeleportOnEntryFlagHandler extends Handler
super(session);
}
@SuppressWarnings("deprecation")
@Override
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
{
if (!player.hasMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META))
{
com.sk89q.worldedit.Location location = WorldGuardUtils.queryValue(player, to.getWorld(), entered, Flags.TELEPORT_ON_ENTRY);
Object location = WorldGuardUtils.queryValueUnchecked(player, to.getWorld(), entered, Flags.TELEPORT_ON_ENTRY);
if (location != null)
{
player.setMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META, new FixedMetadataValue(WorldGuardExtraFlagsPlugin.getPlugin(), true));
player.teleport(BukkitUtil.toLocation(location));
player.teleport(WorldEditUtils.toLocation(location));
return false;
}

View file

@ -6,7 +6,6 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
@ -15,9 +14,11 @@ import com.sk89q.worldguard.session.handler.Handler;
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;
public class TeleportOnExitFlagHandler extends Handler
public class TeleportOnExitFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<TeleportOnExitFlagHandler>
@ -34,17 +35,16 @@ public class TeleportOnExitFlagHandler extends Handler
super(session);
}
@SuppressWarnings("deprecation")
@Override
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
{
if (!player.hasMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META))
{
com.sk89q.worldedit.Location location = WorldGuardUtils.queryValue(player, to.getWorld(), exited, Flags.TELEPORT_ON_EXIT);
Object location = WorldGuardUtils.queryValueUnchecked(player, to.getWorld(), exited, Flags.TELEPORT_ON_EXIT);
if (location != null)
{
player.setMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META, new FixedMetadataValue(WorldGuardExtraFlagsPlugin.getPlugin(), true));
player.teleport(BukkitUtil.toLocation(location));
player.teleport(WorldEditUtils.toLocation(location));
return false;
}

View file

@ -13,8 +13,9 @@ 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;
public class WalkSpeedFlagHandler extends Handler
public class WalkSpeedFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<WalkSpeedFlagHandler>

View file

@ -0,0 +1,53 @@
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

@ -0,0 +1,68 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.bukkit.BukkitPlayer;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
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;
public abstract class HandlerWrapper extends Handler
{
protected HandlerWrapper(Session session)
{
super(session);
}
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)
{
return true;
}
public void tick(Player player, ApplicableRegionSet set)
{
}
public State getInvincibility(Player player)
{
return null;
}
@Override
public void initialize(LocalPlayer localPlayer, com.sk89q.worldedit.util.Location current, ApplicableRegionSet set)
{
this.initialize(((BukkitPlayer)localPlayer).getPlayer(), BukkitAdapter.adapt(current), set);
}
@Override
public boolean onCrossBoundary(LocalPlayer localPlayer, com.sk89q.worldedit.util.Location from, com.sk89q.worldedit.util.Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
{
return this.onCrossBoundary(((BukkitPlayer)localPlayer).getPlayer(), BukkitAdapter.adapt(from), BukkitAdapter.adapt(to), toSet, entered, exited, moveType);
}
@Override
public void tick(LocalPlayer localPlayer, ApplicableRegionSet set)
{
this.tick(((BukkitPlayer)localPlayer).getPlayer(), set);
}
@Override
public State getInvincibility(LocalPlayer localPlayer)
{
return this.getInvincibility(((BukkitPlayer)localPlayer).getPlayer());
}
}

View file

@ -0,0 +1,9 @@
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

@ -0,0 +1,45 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers;
import java.util.Map;
import org.bukkit.Location;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public abstract class RegionManagerWrapper
{
protected final RegionManager regionManager;
public ProtectedRegion getRegion(String id)
{
return this.regionManager.getRegion(id);
}
public ApplicableRegionSet getApplicableRegions(Vector location)
{
return this.regionManager.getApplicableRegions(location);
}
public ApplicableRegionSet getApplicableRegions(Location location)
{
return this.getApplicableRegions(BukkitAdapter.asVector(location));
}
public ApplicableRegionSet getApplicableRegions(ProtectedCuboidRegion protectedCuboidRegion)
{
return this.regionManager.getApplicableRegions(protectedCuboidRegion);
}
public Map<String, ProtectedRegion> getRegions()
{
return this.regionManager.getRegions();
}
}

View file

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

View file

@ -0,0 +1,20 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers;
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 lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public abstract class SessionManagerWrapper
{
protected final SessionManager sessionManager;
public abstract Session get(Player player);
public abstract Session getIfPresent(Player player);
public abstract void registerHandler(Handler.Factory<? extends Handler> factory);
}

View file

@ -0,0 +1,54 @@
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

@ -0,0 +1,13 @@
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

@ -0,0 +1,37 @@
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

@ -0,0 +1,70 @@
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

@ -0,0 +1,61 @@
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

@ -0,0 +1,29 @@
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

@ -0,0 +1,13 @@
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

@ -0,0 +1,22 @@
package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7;
import org.bukkit.Location;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import lombok.RequiredArgsConstructor;
import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionQueryWrapper;
@RequiredArgsConstructor
public class RegionQueryWrapperSeven extends RegionQueryWrapper
{
protected final RegionQuery regionQuery;
@Override
public ApplicableRegionSet getApplicableRegions(Location location)
{
return this.regionQuery.getApplicableRegions(BukkitAdapter.adapt(location));
}
}

View file

@ -0,0 +1,37 @@
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

@ -0,0 +1,57 @@
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);
}
}