Moved WG handlers to WG module

This fixes the error given when using unsupported version of WG and gives message saying that you are using unsupported version of WG instead
This commit is contained in:
isokissa3 2018-12-09 23:08:39 +02:00
parent adbe09ad82
commit 7d12cdb0e1
22 changed files with 340 additions and 190 deletions

View file

@ -71,17 +71,17 @@
<version>7.0.0-beta-02</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>
<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>com.comphenix.protocol</groupId>

View file

@ -7,12 +7,10 @@ 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.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;
import net.goldtreeservers.worldguardextraflags.listeners.EntityListenerOnePointNine;
@ -23,20 +21,6 @@ import net.goldtreeservers.worldguardextraflags.listeners.WorldListener;
import net.goldtreeservers.worldguardextraflags.protocollib.ProtocolLibHelper;
import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures;
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;
import net.goldtreeservers.worldguardextraflags.wg.handlers.ConsoleCommandOnEntryFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.ConsoleCommandOnExitFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.FlyFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.GiveEffectsFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.GlideFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.GodmodeFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.PlaySoundsFlagHandler;
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.wrappers.AbstractSessionManagerWrapper;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.WorldGuardCommunicator;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.v6.WorldGuardSixCommunicator;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.v7.WorldGuardSevenCommunicator;
@ -75,7 +59,7 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
try
{
this.worldGuardCommunicator.onLoad();
this.worldGuardCommunicator.onLoad(this);
}
catch (Exception e)
{
@ -83,37 +67,6 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
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
@ -168,7 +121,7 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
try
{
this.worldGuardCommunicator.onEnable();
this.worldGuardCommunicator.onEnable(this);
}
catch (Exception e)
{
@ -176,21 +129,6 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin
throw new RuntimeException("Failed to enable WorldGuard communicator", e);
}
AbstractSessionManagerWrapper 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);

View file

@ -18,6 +18,10 @@
<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>
</repositories>
<dependencies>
@ -51,5 +55,11 @@
<version>7.0.0-beta-02</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

@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -15,7 +16,6 @@ import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.flags.data.PotionEffectDetails;
@ -24,21 +24,30 @@ import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class BlockedEffectsFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<BlockedEffectsFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<BlockedEffectsFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public BlockedEffectsFlagHandler create(Session session)
{
return new BlockedEffectsFlagHandler(session);
return new BlockedEffectsFlagHandler(this.getPlugin(), session);
}
}
private HashMap<PotionEffectType, PotionEffectDetails> removedEffects;
protected BlockedEffectsFlagHandler(Session session)
protected BlockedEffectsFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
this.removedEffects = new HashMap<>();
}

View file

@ -6,35 +6,43 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class CommandOnEntryFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<CommandOnEntryFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<CommandOnEntryFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public CommandOnEntryFlagHandler create(Session session)
{
return new CommandOnEntryFlagHandler(session);
return new CommandOnEntryFlagHandler(this.getPlugin(), session);
}
}
private Collection<Set<String>> lastCommands;
protected CommandOnEntryFlagHandler(Session session)
protected CommandOnEntryFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
this.lastCommands = new ArrayList<>();
}
@ -50,7 +58,7 @@ public class CommandOnEntryFlagHandler extends HandlerWrapper
{
for(String command : commands_)
{
WorldGuardExtraFlagsPlugin.getPlugin().getServer().dispatchCommand(player, command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
this.getPlugin().getServer().dispatchCommand(player, command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
}
break;

View file

@ -6,35 +6,43 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class CommandOnExitFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<CommandOnExitFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<CommandOnExitFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public CommandOnExitFlagHandler create(Session session)
{
return new CommandOnExitFlagHandler(session);
return new CommandOnExitFlagHandler(this.getPlugin(), session);
}
}
private Collection<Set<String>> lastCommands;
protected CommandOnExitFlagHandler(Session session)
protected CommandOnExitFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
this.lastCommands = new ArrayList<>();
}
@ -68,7 +76,7 @@ public class CommandOnExitFlagHandler extends HandlerWrapper
{
for(String command : commands_)
{
WorldGuardExtraFlagsPlugin.getPlugin().getServer().dispatchCommand(player, command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
this.getPlugin().getServer().dispatchCommand(player, command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
}
}
}

View file

@ -6,35 +6,43 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class ConsoleCommandOnEntryFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<ConsoleCommandOnEntryFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<ConsoleCommandOnEntryFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public ConsoleCommandOnEntryFlagHandler create(Session session)
{
return new ConsoleCommandOnEntryFlagHandler(session);
return new ConsoleCommandOnEntryFlagHandler(this.getPlugin(), session);
}
}
private Collection<Set<String>> lastCommands;
protected ConsoleCommandOnEntryFlagHandler(Session session)
protected ConsoleCommandOnEntryFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
this.lastCommands = new ArrayList<>();
}
@ -50,7 +58,7 @@ public class ConsoleCommandOnEntryFlagHandler extends HandlerWrapper
{
for(String command : commands_)
{
WorldGuardExtraFlagsPlugin.getPlugin().getServer().dispatchCommand(WorldGuardExtraFlagsPlugin.getPlugin().getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
this.getPlugin().getServer().dispatchCommand(this.getPlugin().getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
}
break;

View file

@ -6,35 +6,43 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class ConsoleCommandOnExitFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<ConsoleCommandOnExitFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<ConsoleCommandOnExitFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public ConsoleCommandOnExitFlagHandler create(Session session)
{
return new ConsoleCommandOnExitFlagHandler(session);
return new ConsoleCommandOnExitFlagHandler(this.getPlugin(), session);
}
}
private Collection<Set<String>> lastCommands;
protected ConsoleCommandOnExitFlagHandler(Session session)
protected ConsoleCommandOnExitFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
this.lastCommands = new ArrayList<>();
}
@ -68,7 +76,7 @@ public class ConsoleCommandOnExitFlagHandler extends HandlerWrapper
{
for(String command : commands_)
{
WorldGuardExtraFlagsPlugin.getPlugin().getServer().dispatchCommand(WorldGuardExtraFlagsPlugin.getPlugin().getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
this.getPlugin().getServer().dispatchCommand(this.getPlugin().getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
}
break;

View file

@ -4,13 +4,13 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
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;
import lombok.Getter;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
@ -19,22 +19,31 @@ import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class FlyFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<FlyFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<FlyFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public FlyFlagHandler create(Session session)
{
return new FlyFlagHandler(session);
return new FlyFlagHandler(this.getPlugin(), session);
}
}
@Getter private Boolean currentValue;
private Boolean originalFly;
protected FlyFlagHandler(Session session)
protected FlyFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
}
@Override

View file

@ -11,6 +11,7 @@ import java.util.concurrent.TimeUnit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -18,10 +19,8 @@ import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import lombok.Getter;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.flags.data.PotionEffectDetails;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
@ -29,13 +28,22 @@ import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class GiveEffectsFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<GiveEffectsFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<GiveEffectsFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public GiveEffectsFlagHandler create(Session session)
{
return new GiveEffectsFlagHandler(session);
return new GiveEffectsFlagHandler(this.getPlugin(), session);
}
}
@ -44,9 +52,9 @@ public class GiveEffectsFlagHandler extends HandlerWrapper
@Getter private boolean supressRemovePotionPacket;
protected GiveEffectsFlagHandler(Session session)
protected GiveEffectsFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
this.removedEffects = new HashMap<>();
this.givenEffects = new HashSet<>();
@ -165,7 +173,7 @@ public class GiveEffectsFlagHandler extends HandlerWrapper
{
this.removedEffects.clear();
this.check(player, WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()));
this.check(player, WorldGuardUtils.getCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()));
}
public void drinkPotion(Player player, Collection<PotionEffect> effects)
@ -175,6 +183,6 @@ public class GiveEffectsFlagHandler extends HandlerWrapper
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()));
this.check(player, WorldGuardUtils.getCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()));
}
}

View file

@ -4,13 +4,13 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
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;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
@ -18,21 +18,30 @@ import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class GlideFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<GlideFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<GlideFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public GlideFlagHandler create(Session session)
{
return new GlideFlagHandler(session);
return new GlideFlagHandler(this.getPlugin(), session);
}
}
private Boolean originalGlide;
protected GlideFlagHandler(Session session)
protected GlideFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
}
@Override

View file

@ -4,40 +4,48 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
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;
import lombok.Getter;
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.wrappers.HandlerWrapper;
public class GodmodeFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<GodmodeFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<GodmodeFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public GodmodeFlagHandler create(Session session)
{
return new GodmodeFlagHandler(session);
return new GodmodeFlagHandler(this.getPlugin(), session);
}
}
@Getter private Boolean isGodmodeEnabled;
private Boolean originalEssentialsGodmode;
protected GodmodeFlagHandler(Session session)
protected GodmodeFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
}
@Override
@ -67,10 +75,11 @@ public class GodmodeFlagHandler extends HandlerWrapper
this.isGodmodeEnabled = null;
}
EssentialsHelper helper = WorldGuardExtraFlagsPlugin.getPlugin().getEssentialsHelper();
if (helper != null)
//For now at least
Plugin essentials = this.getPlugin().getServer().getPluginManager().getPlugin("Essentials");
if (essentials != null)
{
User user = helper.getEssentialsPlugin().getUser(player);
User user = ((Essentials)essentials).getUser(player);
if (this.isGodmodeEnabled != null)
{

View file

@ -8,15 +8,14 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.flags.data.SoundData;
import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures;
@ -25,21 +24,30 @@ import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class PlaySoundsFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<PlaySoundsFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<PlaySoundsFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public PlaySoundsFlagHandler create(Session session)
{
return new PlaySoundsFlagHandler(session);
return new PlaySoundsFlagHandler(this.getPlugin(), session);
}
}
private Map<String, BukkitRunnable> runnables;
protected PlaySoundsFlagHandler(Session session)
protected PlaySoundsFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
this.runnables = new HashMap<>();
}
@ -93,7 +101,8 @@ public class PlaySoundsFlagHandler extends HandlerWrapper
};
this.runnables.put(sound.getSound(), runnable);
runnable.runTaskTimer(WorldGuardExtraFlagsPlugin.getPlugin(), 0L, sound.getInterval());
runnable.runTaskTimer(this.getPlugin(), 0L, sound.getInterval());
}
}
}

View file

@ -5,14 +5,13 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.we.WorldEditUtils;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
@ -20,19 +19,28 @@ import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class TeleportOnEntryFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<TeleportOnEntryFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<TeleportOnEntryFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public TeleportOnEntryFlagHandler create(Session session)
{
return new TeleportOnEntryFlagHandler(session);
return new TeleportOnEntryFlagHandler(this.getPlugin(), session);
}
}
protected TeleportOnEntryFlagHandler(Session session)
protected TeleportOnEntryFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
}
@Override
@ -43,7 +51,8 @@ public class TeleportOnEntryFlagHandler extends HandlerWrapper
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.setMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META, new FixedMetadataValue(this.getPlugin(), true));
player.teleport(WorldEditUtils.toLocation(location));
return false;

View file

@ -5,14 +5,13 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.we.WorldEditUtils;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
@ -20,19 +19,28 @@ import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class TeleportOnExitFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<TeleportOnExitFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<TeleportOnExitFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public TeleportOnExitFlagHandler create(Session session)
{
return new TeleportOnExitFlagHandler(session);
return new TeleportOnExitFlagHandler(this.getPlugin(), session);
}
}
protected TeleportOnExitFlagHandler(Session session)
protected TeleportOnExitFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
}
@Override
@ -43,7 +51,8 @@ public class TeleportOnExitFlagHandler extends HandlerWrapper
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.setMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META, new FixedMetadataValue(this.getPlugin(), true));
player.teleport(WorldEditUtils.toLocation(location));
return false;

View file

@ -4,12 +4,12 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import net.goldtreeservers.worldguardextraflags.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
@ -17,21 +17,30 @@ import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
public class WalkSpeedFlagHandler extends HandlerWrapper
{
public static final Factory FACTORY = new Factory();
public static class Factory extends Handler.Factory<WalkSpeedFlagHandler>
public static final Factory FACTORY(Plugin plugin)
{
return new Factory(plugin);
}
public static class Factory extends HandlerWrapper.Factory<WalkSpeedFlagHandler>
{
@Override
public Factory(Plugin plugin)
{
super(plugin);
}
@Override
public WalkSpeedFlagHandler create(Session session)
{
return new WalkSpeedFlagHandler(session);
return new WalkSpeedFlagHandler(this.getPlugin(), session);
}
}
private Float originalWalkSpeed;
protected WalkSpeedFlagHandler(Session session)
protected WalkSpeedFlagHandler(Plugin plugin, Session session)
{
super(session);
super(plugin, session);
}
@Override

View file

@ -4,6 +4,7 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.LocalPlayer;
@ -15,11 +16,17 @@ import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.Handler;
import lombok.Getter;
public abstract class HandlerWrapper extends Handler
{
protected HandlerWrapper(Session session)
@Getter private final Plugin plugin;
protected HandlerWrapper(Plugin plugin, Session session)
{
super(session);
this.plugin = plugin;
}
public void initialize(Player player, Location current, ApplicableRegionSet set)
@ -63,4 +70,14 @@ public abstract class HandlerWrapper extends Handler
{
return this.getInvincibility(((BukkitPlayer)localPlayer).getPlayer());
}
public abstract static class Factory<T extends HandlerWrapper> extends Handler.Factory<T>
{
@Getter private final Plugin plugin;
public Factory(Plugin plugin)
{
this.plugin = plugin;
}
}
}

View file

@ -1,6 +1,7 @@
package net.goldtreeservers.worldguardextraflags.wg.wrappers;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
@ -10,10 +11,74 @@ 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.flags.Flags;
import net.goldtreeservers.worldguardextraflags.wg.handlers.BlockedEffectsFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.CommandOnEntryFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.CommandOnExitFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.ConsoleCommandOnEntryFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.ConsoleCommandOnExitFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.FlyFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.GiveEffectsFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.GlideFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.GodmodeFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.PlaySoundsFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.TeleportOnEntryFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.TeleportOnExitFlagHandler;
import net.goldtreeservers.worldguardextraflags.wg.handlers.WalkSpeedFlagHandler;
public interface WorldGuardCommunicator
{
public void onLoad() throws Exception;
public void onEnable() throws Exception;
default public void onLoad(Plugin plugin) throws Exception
{
FlagRegistry flagRegistry = this.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);
}
default public void onEnable(Plugin plugin) throws Exception
{
AbstractSessionManagerWrapper sessionManager = this.getSessionManager();
sessionManager.registerHandler(TeleportOnEntryFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(TeleportOnExitFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(CommandOnEntryFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(CommandOnExitFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(ConsoleCommandOnEntryFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(ConsoleCommandOnExitFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(WalkSpeedFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(BlockedEffectsFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(GodmodeFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(GiveEffectsFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(FlyFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(PlaySoundsFlagHandler.FACTORY(plugin));
sessionManager.registerHandler(GlideFlagHandler.FACTORY(plugin));
}
public FlagRegistry getFlagRegistry();

View file

@ -2,6 +2,7 @@ package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6;
import org.bukkit.Chunk;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
@ -27,15 +28,18 @@ public class WorldGuardSixCommunicator implements WorldGuardCommunicator
private AbstractRegionContainerWrapper regionContainer;
@Override
public void onLoad() throws Exception
public void onLoad(Plugin plugin) throws Exception
{
WorldGuardCommunicator.super.onLoad(plugin);
}
@Override
public void onEnable() throws Exception
public void onEnable(Plugin plugin) throws Exception
{
this.sessionManager = new SessionManagerWrapper(WorldGuardPlugin.inst().getSessionManager());
this.regionContainer = new RegionContainerWrapper();
WorldGuardCommunicator.super.onEnable(plugin);
}
@Override

View file

@ -2,6 +2,7 @@ package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7;
import org.bukkit.Chunk;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
@ -28,15 +29,18 @@ public class WorldGuardSevenCommunicator implements WorldGuardCommunicator
private AbstractRegionContainerWrapper regionContainer;
@Override
public void onLoad() throws Exception
public void onLoad(Plugin plugin) throws Exception
{
WorldGuardCommunicator.super.onLoad(plugin);
}
@Override
public void onEnable() throws Exception
public void onEnable(Plugin plugin) throws Exception
{
this.sessionManager = new SessionManagerWrapper(WorldGuard.getInstance().getPlatform().getSessionManager());
this.regionContainer = new RegionContainerWrapper();
WorldGuardCommunicator.super.onEnable(plugin);
}
@Override