mirror of
https://github.com/TotalFreedomMC/TF-WorldGuardExtraFlagsPlugin.git
synced 2024-12-28 10:04:50 +00:00
Intial commit
This commit is contained in:
commit
09eae2ac3c
30 changed files with 2153 additions and 0 deletions
88
pom.xml
Normal file
88
pom.xml
Normal file
|
@ -0,0 +1,88 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.goldtreeservers</groupId>
|
||||
<artifactId>worldguardextraflags</artifactId>
|
||||
<version>2.11.0</version>
|
||||
<name>WorldGuardExtraFlags</name>
|
||||
|
||||
<build>
|
||||
<finalName>WorldGuardExtraFlagsPlugin</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>ess-repo</id>
|
||||
<url>http://repo.ess3.net/content/groups/essentials</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!--Spigot JAR-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.10.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Spigot API-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Bukkit API-->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--WorldGuard -->
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-legacy</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.connorlinfoot</groupId>
|
||||
<artifactId>TitleAPI</artifactId>
|
||||
<version>1.7.4</version>
|
||||
</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>3.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>Essentials</artifactId>
|
||||
<version>2.13-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,213 @@
|
|||
package net.goldtreeservers.worldguardextraflags;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.flags.BooleanFlag;
|
||||
import com.sk89q.worldguard.protection.flags.CommandStringFlag;
|
||||
import com.sk89q.worldguard.protection.flags.DoubleFlag;
|
||||
import com.sk89q.worldguard.protection.flags.LocationFlag;
|
||||
import com.sk89q.worldguard.protection.flags.SetFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StringFlag;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.flags.BlockedEffectsFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.CaseForcedStringFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.CommandOnEntryFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.CommandOnExitFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.ConsoleCommandOnEntryFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.ConsoleCommandOnExitFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.CustomSetFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.FlyFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.GiveEffectsFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.GlideFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.GodmodeFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.PlaySoundsFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.PotionEffectFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.PotionEffectTypeFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.SoundDataFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.TeleportOnEntryFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.TeleportOnExitFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.WalkSpeedFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.listeners.BlockListener;
|
||||
import net.goldtreeservers.worldguardextraflags.listeners.EntityListener;
|
||||
import net.goldtreeservers.worldguardextraflags.listeners.EssentialsListener;
|
||||
import net.goldtreeservers.worldguardextraflags.listeners.PlayerListener;
|
||||
import net.goldtreeservers.worldguardextraflags.listeners.WorldEditListener;
|
||||
import net.goldtreeservers.worldguardextraflags.utils.PluginUtils;
|
||||
import net.goldtreeservers.worldguardextraflags.utils.SoundData;
|
||||
|
||||
public class WorldGuardExtraFlagsPlugin extends JavaPlugin
|
||||
{
|
||||
private static WorldGuardExtraFlagsPlugin plugin;
|
||||
private static WorldGuardPlugin worldGuardPlugin;
|
||||
private static WorldEditPlugin worldEditPlugin;
|
||||
private static Essentials essentialsPlugin;
|
||||
private static boolean mythicMobsEnabled;
|
||||
private static boolean supportFrostwalker;
|
||||
private static boolean fastAsyncWorldEditEnabled;
|
||||
private static boolean essentialsEnabled;
|
||||
|
||||
public final static LocationFlag teleportOnEntry = new LocationFlag("teleport-on-entry");
|
||||
public final static LocationFlag teleportOnExit = new LocationFlag("teleport-on-exit");
|
||||
public final static CustomSetFlag<String> commandOnEntry = new CustomSetFlag<String>("command-on-entry", new CommandStringFlag(null));
|
||||
public final static CustomSetFlag<String> commandOnExit = new CustomSetFlag<String>("command-on-exit", new CommandStringFlag(null));
|
||||
public final static CustomSetFlag<String> consoleCommandOnEntry = new CustomSetFlag<String>("console-command-on-entry", new CommandStringFlag(null));
|
||||
public final static CustomSetFlag<String> consoleCommandOnExit = new CustomSetFlag<String>("console-command-on-exit", new CommandStringFlag(null));
|
||||
public final static DoubleFlag walkSpeed = new DoubleFlag("walk-speed");
|
||||
public final static BooleanFlag keepInventory = new BooleanFlag("keep-inventory");
|
||||
public final static BooleanFlag keepExp = new BooleanFlag("keep-exp");
|
||||
public final static StringFlag chatPrefix = new StringFlag("chat-prefix");
|
||||
public final static StringFlag chatSuffix = new StringFlag("chat-suffix");
|
||||
public final static SetFlag<PotionEffectType> blockedEffects = new SetFlag<PotionEffectType>("blocked-effects", new PotionEffectTypeFlag(null));
|
||||
public final static StateFlag godmode = new StateFlag("godmode", false);
|
||||
public final static LocationFlag respawnLocation = new LocationFlag("respawn-location");
|
||||
public final static StateFlag worldEdit = new StateFlag("worldedit", true);
|
||||
public final static SetFlag<PotionEffect> giveEffects = new SetFlag<PotionEffect>("give-effects", new PotionEffectFlag(null));
|
||||
public final static StateFlag fly = new StateFlag("fly", false);
|
||||
public final static SetFlag<SoundData> playSounds = new SetFlag<SoundData>("play-sounds", new SoundDataFlag(null));
|
||||
public final static StateFlag mythicMobsEggs = new StateFlag("mythicmobs-eggs", true);
|
||||
public final static StateFlag frostwalker = new StateFlag("frostwalker", true);
|
||||
public final static StateFlag netherPortals = new StateFlag("nether-portals", true);
|
||||
public final static SetFlag<String> allowBlockPlace = new SetFlag<String>("allow-block-place", new CaseForcedStringFlag(null, true));
|
||||
public final static SetFlag<String> denyBlockPlace = new SetFlag<String>("deny-block-place", new CaseForcedStringFlag(null, true));
|
||||
public final static SetFlag<String> allowBlockBreak = new SetFlag<String>("allow-block-break", new CaseForcedStringFlag(null, true));
|
||||
public final static SetFlag<String> denyBlockBreak = new SetFlag<String>("deny-block-break", new CaseForcedStringFlag(null, true));
|
||||
public final static StateFlag glide = new StateFlag("glide", false);
|
||||
|
||||
public WorldGuardExtraFlagsPlugin()
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.plugin = this;
|
||||
|
||||
String a = getServer().getClass().getPackage().getName();
|
||||
String version = a.substring(a.lastIndexOf('.') + 1);
|
||||
if (version.equalsIgnoreCase("v1_10_R1") || version.equalsIgnoreCase("v1_9_R1"))
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.supportFrostwalker = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.worldEditPlugin = (WorldEditPlugin) this.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin = (WorldGuardPlugin) this.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.teleportOnEntry);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.teleportOnExit);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.commandOnEntry);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.commandOnExit);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.consoleCommandOnEntry);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.consoleCommandOnExit);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.walkSpeed);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.keepInventory);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.keepExp);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.chatPrefix);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.chatSuffix);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.blockedEffects);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.godmode);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.respawnLocation);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.worldEdit);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.giveEffects);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.fly);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.playSounds);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.mythicMobsEggs);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.frostwalker);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.netherPortals);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.allowBlockPlace);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.denyBlockPlace);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.allowBlockBreak);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.denyBlockBreak);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getFlagRegistry().register(WorldGuardExtraFlagsPlugin.glide);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(TeleportOnEntryFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(TeleportOnExitFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(CommandOnEntryFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(CommandOnExitFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(ConsoleCommandOnEntryFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(ConsoleCommandOnExitFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(WalkSpeedFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(BlockedEffectsFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(GodmodeFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(GiveEffectsFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(FlyFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(PlaySoundsFlag.FACTORY, null);
|
||||
WorldGuardExtraFlagsPlugin.worldGuardPlugin.getSessionManager().registerHandler(GlideFlag.FACTORY, null);
|
||||
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new BlockListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new EntityListener(), this);
|
||||
|
||||
Plugin essentialsPlugin = this.getServer().getPluginManager().getPlugin("Essentials");
|
||||
if (essentialsPlugin != null)
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.essentialsPlugin = (Essentials)essentialsPlugin;
|
||||
}
|
||||
WorldGuardExtraFlagsPlugin.mythicMobsEnabled = this.getServer().getPluginManager().isPluginEnabled("MythicMobs");
|
||||
WorldGuardExtraFlagsPlugin.fastAsyncWorldEditEnabled = this.getServer().getPluginManager().isPluginEnabled("FastAsyncWorldEdit");
|
||||
WorldGuardExtraFlagsPlugin.essentialsEnabled = this.getServer().getPluginManager().isPluginEnabled("Essentials");
|
||||
|
||||
if (WorldGuardExtraFlagsPlugin.fastAsyncWorldEditEnabled)
|
||||
{
|
||||
PluginUtils.registerFAWE();
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.worldEditPlugin.getWorldEdit().getEventBus().register(new WorldEditListener());
|
||||
}
|
||||
|
||||
if (WorldGuardExtraFlagsPlugin.essentialsEnabled)
|
||||
{
|
||||
this.getServer().getPluginManager().registerEvents(new EssentialsListener(), this);
|
||||
}
|
||||
}
|
||||
|
||||
public static WorldGuardExtraFlagsPlugin getPlugin()
|
||||
{
|
||||
return WorldGuardExtraFlagsPlugin.plugin;
|
||||
}
|
||||
|
||||
public static WorldGuardPlugin getWorldGuard()
|
||||
{
|
||||
return WorldGuardExtraFlagsPlugin.worldGuardPlugin;
|
||||
}
|
||||
|
||||
public static WorldEditPlugin getWorldEditPlugin()
|
||||
{
|
||||
return WorldGuardExtraFlagsPlugin.worldEditPlugin;
|
||||
}
|
||||
|
||||
public static boolean isMythicMobsEnabled()
|
||||
{
|
||||
return WorldGuardExtraFlagsPlugin.mythicMobsEnabled;
|
||||
}
|
||||
|
||||
public static boolean isSupportingFrostwalker()
|
||||
{
|
||||
return WorldGuardExtraFlagsPlugin.supportFrostwalker;
|
||||
}
|
||||
|
||||
public static boolean isFastAsyncWorldEditEnabled()
|
||||
{
|
||||
return WorldGuardExtraFlagsPlugin.fastAsyncWorldEditEnabled;
|
||||
}
|
||||
|
||||
public static boolean isEssentialsEnabled()
|
||||
{
|
||||
return WorldGuardExtraFlagsPlugin.essentialsEnabled;
|
||||
}
|
||||
|
||||
public static Essentials getEssentialsPlugin()
|
||||
{
|
||||
return WorldGuardExtraFlagsPlugin.essentialsPlugin;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
|
||||
public class BlockedEffectsFlag extends Handler
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<BlockedEffectsFlag>
|
||||
{
|
||||
@Override
|
||||
public BlockedEffectsFlag create(Session session)
|
||||
{
|
||||
return new BlockedEffectsFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
protected BlockedEffectsFlag(Session session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Player player, ApplicableRegionSet set)
|
||||
{
|
||||
if (!this.getSession().getManager().hasBypass(player, player.getWorld()))
|
||||
{
|
||||
for(Set<PotionEffectType> potionEffects : set.queryAllValues(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.blockedEffects))
|
||||
{
|
||||
if (potionEffects != null)
|
||||
{
|
||||
for(PotionEffectType potionEffect : potionEffects)
|
||||
{
|
||||
if (potionEffect != null)
|
||||
{
|
||||
player.removePotionEffect(potionEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||
import com.sk89q.worldguard.protection.flags.StringFlag;
|
||||
|
||||
public class CaseForcedStringFlag extends StringFlag
|
||||
{
|
||||
private final boolean upperCase;
|
||||
|
||||
public CaseForcedStringFlag(String name, boolean upperCase)
|
||||
{
|
||||
super(name);
|
||||
|
||||
this.upperCase = upperCase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseInput(FlagContext context) throws InvalidFlagFormat
|
||||
{
|
||||
return this.upperCase ? super.parseInput(context).toUpperCase() : super.parseInput(context).toLowerCase();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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;
|
||||
|
||||
public class CommandOnEntryFlag extends Handler
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<CommandOnEntryFlag>
|
||||
{
|
||||
@Override
|
||||
public CommandOnEntryFlag create(Session session)
|
||||
{
|
||||
return new CommandOnEntryFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
protected CommandOnEntryFlag(Session session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
|
||||
{
|
||||
for(ProtectedRegion region : entered)
|
||||
{
|
||||
Set<String> commands = region.getFlag(WorldGuardExtraFlagsPlugin.commandOnEntry);
|
||||
if (commands != null)
|
||||
{
|
||||
for(String command : commands)
|
||||
{
|
||||
boolean isOp = player.isOp();
|
||||
|
||||
try
|
||||
{
|
||||
player.setOp(true);
|
||||
WorldGuardExtraFlagsPlugin.getPlugin().getServer().dispatchCommand(player, command.substring(1).replace("%username%", player.getName()));
|
||||
}
|
||||
finally
|
||||
{
|
||||
player.setOp(isOp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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;
|
||||
|
||||
public class CommandOnExitFlag extends Handler
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<CommandOnExitFlag>
|
||||
{
|
||||
@Override
|
||||
public CommandOnExitFlag create(Session session)
|
||||
{
|
||||
return new CommandOnExitFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
protected CommandOnExitFlag(Session session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
|
||||
{
|
||||
for(ProtectedRegion region : exited)
|
||||
{
|
||||
Set<String> commands = region.getFlag(WorldGuardExtraFlagsPlugin.commandOnExit);
|
||||
if (commands != null)
|
||||
{
|
||||
for(String command : commands)
|
||||
{
|
||||
boolean isOp = player.isOp();
|
||||
|
||||
try
|
||||
{
|
||||
player.setOp(true);
|
||||
WorldGuardExtraFlagsPlugin.getPlugin().getServer().dispatchCommand(player, command.substring(1).replace("%username%", player.getName()));
|
||||
}
|
||||
finally
|
||||
{
|
||||
player.setOp(isOp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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;
|
||||
|
||||
public class ConsoleCommandOnEntryFlag extends Handler
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<ConsoleCommandOnEntryFlag>
|
||||
{
|
||||
@Override
|
||||
public ConsoleCommandOnEntryFlag create(Session session)
|
||||
{
|
||||
return new ConsoleCommandOnEntryFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
protected ConsoleCommandOnEntryFlag(Session session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
|
||||
{
|
||||
for(ProtectedRegion region : entered)
|
||||
{
|
||||
Set<String> commands = region.getFlag(WorldGuardExtraFlagsPlugin.consoleCommandOnEntry);
|
||||
if (commands != null)
|
||||
{
|
||||
for(String command : commands)
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.getPlugin().getServer().dispatchCommand(WorldGuardExtraFlagsPlugin.getPlugin().getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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;
|
||||
|
||||
public class ConsoleCommandOnExitFlag extends Handler
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<ConsoleCommandOnExitFlag>
|
||||
{
|
||||
@Override
|
||||
public ConsoleCommandOnExitFlag create(Session session)
|
||||
{
|
||||
return new ConsoleCommandOnExitFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
protected ConsoleCommandOnExitFlag(Session session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
|
||||
{
|
||||
for(ProtectedRegion region : exited)
|
||||
{
|
||||
Set<String> commands = region.getFlag(WorldGuardExtraFlagsPlugin.consoleCommandOnExit);
|
||||
if (commands != null)
|
||||
{
|
||||
for(String command : commands)
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.getPlugin().getServer().dispatchCommand(WorldGuardExtraFlagsPlugin.getPlugin().getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||
import com.sk89q.worldguard.protection.flags.SetFlag;
|
||||
|
||||
public class CustomSetFlag<T> extends SetFlag<T>
|
||||
{
|
||||
public CustomSetFlag(String name, Flag<T> subFlag)
|
||||
{
|
||||
super(name, subFlag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<T> parseInput(FlagContext context) throws InvalidFlagFormat
|
||||
{
|
||||
String input = context.getUserInput();
|
||||
if (input.isEmpty())
|
||||
{
|
||||
return Sets.newHashSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
Set<T> items = Sets.newHashSet();
|
||||
|
||||
for (String str : input.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1))
|
||||
{
|
||||
if (str.startsWith("\"") && str.endsWith("\""))
|
||||
{
|
||||
str = str.substring(1, str.length() - 1);
|
||||
}
|
||||
FlagContext copy = context.copyWith(null, str, null);
|
||||
items.add(this.getType().parseInput(copy));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.FlagValueChangeHandler;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
|
||||
public class FlyFlag extends FlagValueChangeHandler<State>
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<FlyFlag>
|
||||
{
|
||||
@Override
|
||||
public FlyFlag create(Session session)
|
||||
{
|
||||
return new FlyFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean originalFly;
|
||||
private Boolean currentValue;
|
||||
|
||||
protected FlyFlag(Session session)
|
||||
{
|
||||
super(session, WorldGuardExtraFlagsPlugin.fly);
|
||||
}
|
||||
|
||||
private void updateFly(Player player, State newValue, World world)
|
||||
{
|
||||
this.currentValue = newValue == null ? null : newValue == State.ALLOW ? true : false;
|
||||
|
||||
if (!this.getSession().getManager().hasBypass(player, world) && this.currentValue != null)
|
||||
{
|
||||
if (player.getAllowFlight() != this.currentValue)
|
||||
{
|
||||
if (this.originalFly == null)
|
||||
{
|
||||
this.originalFly = player.getAllowFlight();
|
||||
}
|
||||
|
||||
player.setAllowFlight(this.currentValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.originalFly != null)
|
||||
{
|
||||
player.setAllowFlight(this.originalFly);
|
||||
this.originalFly = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitialValue(Player player, ApplicableRegionSet set, State value)
|
||||
{
|
||||
this.updateFly(player, value, player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSetValue(Player player, Location from, Location to, ApplicableRegionSet toSet, State currentValue, State lastValue, MoveType moveType)
|
||||
{
|
||||
this.updateFly(player, currentValue, to.getWorld());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onAbsentValue(Player player, Location from, Location to, ApplicableRegionSet toSet, State lastValue, MoveType moveType)
|
||||
{
|
||||
this.updateFly(player, null, player.getWorld());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testMoveTo(Player player, Location from, Location to, ApplicableRegionSet toSet, MoveType moveType)
|
||||
{
|
||||
if (this.currentValue != null && player.getAllowFlight() != this.currentValue)
|
||||
{
|
||||
player.setAllowFlight(this.currentValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Boolean getFlyStatys()
|
||||
{
|
||||
return this.currentValue;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
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;
|
||||
|
||||
public class GiveEffectsFlag extends Handler
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<GiveEffectsFlag>
|
||||
{
|
||||
@Override
|
||||
public GiveEffectsFlag create(Session session)
|
||||
{
|
||||
return new GiveEffectsFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<String, PotionEffect> originalPotionEffects = new HashMap<String, PotionEffect>();
|
||||
private HashSet<PotionEffectType> effectsGiven = new HashSet<PotionEffectType>();
|
||||
|
||||
protected GiveEffectsFlag(Session session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
|
||||
{
|
||||
for(ProtectedRegion enterd : entered)
|
||||
{
|
||||
Set<PotionEffect> potionEffects = enterd.getFlag(WorldGuardExtraFlagsPlugin.giveEffects);
|
||||
if (potionEffects != null)
|
||||
{
|
||||
for (PotionEffect potionEffect : potionEffects)
|
||||
{
|
||||
if (potionEffect != null)
|
||||
{
|
||||
if (player.hasPotionEffect(potionEffect.getType()))
|
||||
{
|
||||
if (!this.originalPotionEffects.containsKey(potionEffect.getType().getName()))
|
||||
{
|
||||
for(PotionEffect currentPotionEffect : player.getActivePotionEffects())
|
||||
{
|
||||
if (currentPotionEffect.getType().getName().equals(potionEffect.getType().getName()))
|
||||
{
|
||||
this.originalPotionEffects.put(potionEffect.getType().getName(), currentPotionEffect);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.removePotionEffect(potionEffect.getType());
|
||||
}
|
||||
|
||||
this.effectsGiven.add(potionEffect.getType());
|
||||
player.addPotionEffect(potionEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(ProtectedRegion exitd : exited)
|
||||
{
|
||||
Set<PotionEffect> potionEffects = exitd.getFlag(WorldGuardExtraFlagsPlugin.giveEffects);
|
||||
if (potionEffects != null)
|
||||
{
|
||||
for(PotionEffect potionEffect : potionEffects)
|
||||
{
|
||||
if (potionEffect != null)
|
||||
{
|
||||
this.effectsGiven.remove(potionEffect.getType());
|
||||
player.removePotionEffect(potionEffect.getType());
|
||||
|
||||
PotionEffect oldPotionEffect = this.originalPotionEffects.remove(potionEffect.getType().getName());
|
||||
if (oldPotionEffect != null)
|
||||
{
|
||||
player.addPotionEffect(oldPotionEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Player player, ApplicableRegionSet set)
|
||||
{
|
||||
if (this.originalPotionEffects != null)
|
||||
{
|
||||
for(PotionEffect oldPotionEffect : this.originalPotionEffects.values().toArray(new PotionEffect[0]))
|
||||
{
|
||||
this.originalPotionEffects.remove(oldPotionEffect);
|
||||
this.originalPotionEffects.put(oldPotionEffect.getType().getName(), new PotionEffect(oldPotionEffect.getType(), oldPotionEffect.getDuration() - 20, oldPotionEffect.getAmplifier(), oldPotionEffect.isAmbient(), oldPotionEffect.hasParticles()));
|
||||
}
|
||||
}
|
||||
|
||||
List<PotionEffectType> shouldRemove = new ArrayList<PotionEffectType>(this.effectsGiven);
|
||||
for(Set<PotionEffect> potionEffects : set.queryAllValues(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.giveEffects))
|
||||
{
|
||||
if (potionEffects != null)
|
||||
{
|
||||
for(PotionEffect potionEffect : potionEffects)
|
||||
{
|
||||
if (potionEffect != null)
|
||||
{
|
||||
if (player.hasPotionEffect(potionEffect.getType()))
|
||||
{
|
||||
for(PotionEffect effect : player.getActivePotionEffects())
|
||||
{
|
||||
if (effect.getType().equals(potionEffect.getType()))
|
||||
{
|
||||
if (effect.getAmplifier() != potionEffect.getAmplifier())
|
||||
{
|
||||
player.removePotionEffect(potionEffect.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.addPotionEffect(potionEffect);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.addPotionEffect(potionEffect);
|
||||
}
|
||||
|
||||
this.effectsGiven.add(potionEffect.getType());
|
||||
shouldRemove.remove(potionEffect.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(PotionEffectType effectType : shouldRemove)
|
||||
{
|
||||
PotionEffect oldPotionEffect = this.originalPotionEffects.remove(effectType.getName());
|
||||
if (oldPotionEffect != null)
|
||||
{
|
||||
if (player.hasPotionEffect(effectType))
|
||||
{
|
||||
player.removePotionEffect(effectType);
|
||||
}
|
||||
|
||||
player.addPotionEffect(oldPotionEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drinkMilk()
|
||||
{
|
||||
this.originalPotionEffects.clear();
|
||||
}
|
||||
|
||||
public void drinkPotion(Collection<PotionEffect> effects)
|
||||
{
|
||||
for(PotionEffect potionEffect : effects)
|
||||
{
|
||||
this.originalPotionEffects.put(potionEffect.getType().getName(), potionEffect);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.FlagValueChangeHandler;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
|
||||
public class GlideFlag extends FlagValueChangeHandler<State>
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<GlideFlag>
|
||||
{
|
||||
@Override
|
||||
public GlideFlag create(Session session)
|
||||
{
|
||||
return new GlideFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean originalGlide;
|
||||
private Boolean currentValue;
|
||||
|
||||
protected GlideFlag(Session session)
|
||||
{
|
||||
super(session, WorldGuardExtraFlagsPlugin.glide);
|
||||
}
|
||||
|
||||
private void updateGlide(Player player, State newValue, World world)
|
||||
{
|
||||
this.currentValue = newValue == null ? null : newValue == State.ALLOW ? true : false;
|
||||
|
||||
if (!this.getSession().getManager().hasBypass(player, world) && this.currentValue != null)
|
||||
{
|
||||
if (player.isGliding() != this.currentValue)
|
||||
{
|
||||
if (this.originalGlide == null)
|
||||
{
|
||||
this.originalGlide = player.isGliding();
|
||||
}
|
||||
|
||||
player.setGliding(this.currentValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.originalGlide != null)
|
||||
{
|
||||
player.setGliding(this.originalGlide);
|
||||
this.originalGlide = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitialValue(Player player, ApplicableRegionSet set, State value)
|
||||
{
|
||||
this.updateGlide(player, value, player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSetValue(Player player, Location from, Location to, ApplicableRegionSet toSet, State currentValue, State lastValue, MoveType moveType)
|
||||
{
|
||||
this.updateGlide(player, currentValue, to.getWorld());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onAbsentValue(Player player, Location from, Location to, ApplicableRegionSet toSet, State lastValue, MoveType moveType)
|
||||
{
|
||||
this.updateGlide(player, null, player.getWorld());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testMoveTo(Player player, Location from, Location to, ApplicableRegionSet toSet, MoveType moveType)
|
||||
{
|
||||
if (this.currentValue != null && player.isGliding() != this.currentValue)
|
||||
{
|
||||
player.setGliding(this.currentValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.FlagValueChangeHandler;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
|
||||
public class GodmodeFlag extends FlagValueChangeHandler<State>
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<GodmodeFlag>
|
||||
{
|
||||
@Override
|
||||
public GodmodeFlag create(Session session)
|
||||
{
|
||||
return new GodmodeFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean isGodmodeEnabled;
|
||||
private Boolean originalEssentialsGodmode;
|
||||
|
||||
protected GodmodeFlag(Session session)
|
||||
{
|
||||
super(session, WorldGuardExtraFlagsPlugin.godmode);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public State getInvincibility(Player player)
|
||||
{
|
||||
if (!this.getSession().getManager().hasBypass(player, player.getWorld()))
|
||||
{
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
|
||||
return regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.godmode);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateGodmode(Player player, State newValue, World world)
|
||||
{
|
||||
if (!this.getSession().getManager().hasBypass(player, world) && newValue != null)
|
||||
{
|
||||
if (this.isGodmodeEnabled == null || this.isGodmodeEnabled != (newValue == State.ALLOW ? true : false))
|
||||
{
|
||||
if (WorldGuardExtraFlagsPlugin.isEssentialsEnabled())
|
||||
{
|
||||
if (this.originalEssentialsGodmode == null)
|
||||
{
|
||||
this.originalEssentialsGodmode = WorldGuardExtraFlagsPlugin.getEssentialsPlugin().getUser(player).isGodModeEnabledRaw();
|
||||
}
|
||||
|
||||
WorldGuardExtraFlagsPlugin.getEssentialsPlugin().getUser(player).setGodModeEnabled(newValue == State.ALLOW ? true : false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isGodmodeEnabled = null;
|
||||
|
||||
if (this.originalEssentialsGodmode != null)
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.getEssentialsPlugin().getUser(player).setGodModeEnabled(this.originalEssentialsGodmode);
|
||||
this.originalEssentialsGodmode = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitialValue(Player player, ApplicableRegionSet set, State value)
|
||||
{
|
||||
this.updateGodmode(player, value, player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSetValue(Player player, Location from, Location to, ApplicableRegionSet toSet, State currentValue, State lastValue, MoveType moveType)
|
||||
{
|
||||
this.updateGodmode(player, currentValue, player.getWorld());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onAbsentValue(Player player, Location from, Location to, ApplicableRegionSet toSet, State lastValue, MoveType moveType)
|
||||
{
|
||||
this.updateGodmode(player, null, player.getWorld());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean shouldBlockEvent(Player player, World world)
|
||||
{
|
||||
return !this.getSession().getManager().hasBypass(player, world) && this.originalEssentialsGodmode != null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
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.utils.SoundData;
|
||||
|
||||
public class PlaySoundsFlag extends Handler
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<PlaySoundsFlag>
|
||||
{
|
||||
@Override
|
||||
public PlaySoundsFlag create(Session session)
|
||||
{
|
||||
return new PlaySoundsFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<ProtectedRegion, List<BukkitRunnable>> runnables = new HashMap<>();
|
||||
|
||||
protected PlaySoundsFlag(Session session)
|
||||
{
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
|
||||
{
|
||||
for(ProtectedRegion region : entered)
|
||||
{
|
||||
Set<SoundData> sounds = region.getFlag(WorldGuardExtraFlagsPlugin.playSounds);
|
||||
if (sounds != null)
|
||||
{
|
||||
List<BukkitRunnable> runnables = this.runnables.getOrDefault(region, new ArrayList<>());
|
||||
for(SoundData sound : sounds)
|
||||
{
|
||||
BukkitRunnable runnable = new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.playSound(player.getLocation(), sound.getSound(), Float.MAX_VALUE, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel()
|
||||
{
|
||||
super.cancel();
|
||||
|
||||
try
|
||||
{
|
||||
player.stopSound(sound.getSound());
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
runnables.add(runnable);
|
||||
runnable.runTaskTimer(WorldGuardExtraFlagsPlugin.getPlugin(), 0L, sound.getInterval());
|
||||
}
|
||||
|
||||
this.runnables.put(region, runnables);
|
||||
}
|
||||
}
|
||||
|
||||
for(ProtectedRegion region : exited)
|
||||
{
|
||||
List<BukkitRunnable> runnables = this.runnables.remove(region);
|
||||
if (runnables != null)
|
||||
{
|
||||
for(BukkitRunnable runnable : runnables)
|
||||
{
|
||||
runnable.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||
|
||||
public class PotionEffectFlag extends Flag<PotionEffect>
|
||||
{
|
||||
public PotionEffectFlag(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object marshal(PotionEffect o)
|
||||
{
|
||||
return o.getType().getName() + " " + o.getAmplifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PotionEffect parseInput(FlagContext context) throws InvalidFlagFormat
|
||||
{
|
||||
String[] splitd = context.getUserInput().trim().split(" ");
|
||||
if (splitd.length == 2)
|
||||
{
|
||||
return new PotionEffect(PotionEffectType.getByName(splitd[0]), Integer.MAX_VALUE, new Integer(splitd[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidFlagFormat("Please use format: <effect name> <effect amplifier>");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PotionEffect unmarshal(Object o)
|
||||
{
|
||||
String[] splitd = o.toString().split(" ");
|
||||
return new PotionEffect(PotionEffectType.getByName(splitd[0]), Integer.MAX_VALUE, new Integer(splitd[1]));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||
|
||||
public class PotionEffectTypeFlag extends Flag<PotionEffectType>
|
||||
{
|
||||
public PotionEffectTypeFlag(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object marshal(PotionEffectType o)
|
||||
{
|
||||
return o.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PotionEffectType parseInput(FlagContext context) throws InvalidFlagFormat
|
||||
{
|
||||
return PotionEffectType.getByName(context.getUserInput().trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PotionEffectType unmarshal(Object o)
|
||||
{
|
||||
return PotionEffectType.getByName(o.toString());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.utils.SoundData;
|
||||
|
||||
public class SoundDataFlag extends Flag<SoundData>
|
||||
{
|
||||
public SoundDataFlag(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object marshal(SoundData o)
|
||||
{
|
||||
return o.getSound().toString() + " " + o.getInterval();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundData parseInput(FlagContext context) throws InvalidFlagFormat
|
||||
{
|
||||
String[] splitd = context.getUserInput().trim().split(" ");
|
||||
if (splitd.length == 2)
|
||||
{
|
||||
return new SoundData(splitd[0], new Integer(splitd[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidFlagFormat("Please use format: <sound name> <interval in ticks>");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundData unmarshal(Object o)
|
||||
{
|
||||
String[] splitd = o.toString().split(" ");
|
||||
return new SoundData(splitd[0], new Integer(splitd[1]));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
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;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
|
||||
public class TeleportOnEntryFlag extends Handler
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<TeleportOnEntryFlag>
|
||||
{
|
||||
@Override
|
||||
public TeleportOnEntryFlag create(Session session)
|
||||
{
|
||||
return new TeleportOnEntryFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
protected TeleportOnEntryFlag(Session session)
|
||||
{
|
||||
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("WorldGuardExtraFlagsWaitingForTeleportationToBeDone"))
|
||||
{
|
||||
com.sk89q.worldedit.Location location = toSet.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.teleportOnEntry);
|
||||
if (location != null)
|
||||
{
|
||||
player.setMetadata("WorldGuardExtraFlagsWaitingForTeleportationToBeDone", new FixedMetadataValue(WorldGuardExtraFlagsPlugin.getPlugin(), null));
|
||||
player.teleport(BukkitUtil.toLocation(location));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
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;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
|
||||
public class TeleportOnExitFlag extends Handler
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<TeleportOnExitFlag>
|
||||
{
|
||||
@Override
|
||||
public TeleportOnExitFlag create(Session session)
|
||||
{
|
||||
return new TeleportOnExitFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
protected TeleportOnExitFlag(Session session)
|
||||
{
|
||||
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("WorldGuardExtraFlagsWaitingForTeleportationToBeDone"))
|
||||
{
|
||||
for(ProtectedRegion region : exited)
|
||||
{
|
||||
com.sk89q.worldedit.Location location = region.getFlag(WorldGuardExtraFlagsPlugin.teleportOnExit);
|
||||
if (location != null)
|
||||
{
|
||||
player.setMetadata("WorldGuardExtraFlagsWaitingForTeleportationToBeDone", new FixedMetadataValue(WorldGuardExtraFlagsPlugin.getPlugin(), null));
|
||||
player.teleport(BukkitUtil.toLocation(location));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.FlagValueChangeHandler;
|
||||
import com.sk89q.worldguard.session.handler.Handler;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
|
||||
public class WalkSpeedFlag extends FlagValueChangeHandler<Double>
|
||||
{
|
||||
public static final Factory FACTORY = new Factory();
|
||||
public static class Factory extends Handler.Factory<WalkSpeedFlag>
|
||||
{
|
||||
@Override
|
||||
public WalkSpeedFlag create(Session session)
|
||||
{
|
||||
return new WalkSpeedFlag(session);
|
||||
}
|
||||
}
|
||||
|
||||
private Float originalWalkSpeed;
|
||||
|
||||
protected WalkSpeedFlag(Session session)
|
||||
{
|
||||
super(session, WorldGuardExtraFlagsPlugin.walkSpeed);
|
||||
}
|
||||
|
||||
private void updateWalkSpeed(Player player, Double newValue, World world)
|
||||
{
|
||||
if (!this.getSession().getManager().hasBypass(player, world) && newValue != null)
|
||||
{
|
||||
if (newValue > 1.0)
|
||||
{
|
||||
newValue = 1.0;
|
||||
}
|
||||
else if (newValue < -1.0)
|
||||
{
|
||||
newValue = -1.0;
|
||||
}
|
||||
|
||||
if (player.getWalkSpeed() != newValue.floatValue())
|
||||
{
|
||||
if (this.originalWalkSpeed == null)
|
||||
{
|
||||
this.originalWalkSpeed = player.getWalkSpeed();
|
||||
}
|
||||
|
||||
player.setWalkSpeed(newValue.floatValue());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.originalWalkSpeed != null)
|
||||
{
|
||||
player.setWalkSpeed(this.originalWalkSpeed);
|
||||
this.originalWalkSpeed = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitialValue(Player player, ApplicableRegionSet set, Double value)
|
||||
{
|
||||
this.updateWalkSpeed(player, value, player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSetValue(Player player, Location from, Location to, ApplicableRegionSet toSet, Double currentValue, Double lastValue, MoveType moveType)
|
||||
{
|
||||
this.updateWalkSpeed(player, currentValue, to.getWorld());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onAbsentValue(Player player, Location from, Location to, ApplicableRegionSet toSet, Double lastValue, MoveType moveType)
|
||||
{
|
||||
this.updateWalkSpeed(player, null, player.getWorld());
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package net.goldtreeservers.worldguardextraflags.flags;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
|
||||
public class WorldEditFlag extends AbstractDelegateExtent
|
||||
{
|
||||
private final Actor actor;
|
||||
|
||||
public WorldEditFlag(Extent extent, Actor actor)
|
||||
{
|
||||
super(extent);
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException
|
||||
{
|
||||
Player player = WorldGuardExtraFlagsPlugin.getPlugin().getServer().getPlayer(this.actor.getUniqueId());
|
||||
if (WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().hasBypass(player, player.getWorld()))
|
||||
{
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(BukkitUtil.toLocation(player.getWorld(), location));
|
||||
State state = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.worldEdit);
|
||||
if (state != State.DENY)
|
||||
{
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
package net.goldtreeservers.worldguardextraflags.listeners;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
|
||||
public class BlockListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityBlockFormEvent(EntityBlockFormEvent event)
|
||||
{
|
||||
if (WorldGuardExtraFlagsPlugin.isSupportingFrostwalker())
|
||||
{
|
||||
if (event.getNewState().getType() == Material.FROSTED_ICE)
|
||||
{
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(event.getNewState().getLocation());
|
||||
State state = null;
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
state = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(((Player)event.getEntity())), WorldGuardExtraFlagsPlugin.frostwalker);
|
||||
}
|
||||
else
|
||||
{
|
||||
state = regions.queryValue(null, WorldGuardExtraFlagsPlugin.frostwalker);
|
||||
}
|
||||
|
||||
if (state == State.DENY)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
|
||||
public void onBlockPlaceEvent(PlaceBlockEvent event)
|
||||
{
|
||||
if (event.getResult() == Result.DEFAULT)
|
||||
{
|
||||
Object cause = event.getCause().getRootCause();
|
||||
|
||||
if (cause instanceof Player)
|
||||
{
|
||||
Player player = (Player)cause;
|
||||
|
||||
if (!WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().hasBypass(player, player.getWorld()))
|
||||
{
|
||||
for(Block block : event.getBlocks())
|
||||
{
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
|
||||
|
||||
Set<String> state = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.allowBlockPlace);
|
||||
if (state != null && state.contains(block.getType().toString().toUpperCase()))
|
||||
{
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
Set<String> state2 = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.denyBlockPlace);
|
||||
if (state2 != null && state2.contains(block.getType().toString().toUpperCase()))
|
||||
{
|
||||
event.setResult(Result.DENY);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setResult(Result.DEFAULT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
|
||||
public void onBlockBreakEvent(BreakBlockEvent event)
|
||||
{
|
||||
if (event.getResult() == Result.DEFAULT)
|
||||
{
|
||||
Object cause = event.getCause().getRootCause();
|
||||
|
||||
if (cause instanceof Player)
|
||||
{
|
||||
Player player = (Player)cause;
|
||||
|
||||
if (!WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().hasBypass(player, player.getWorld()))
|
||||
{
|
||||
for(Block block : event.getBlocks())
|
||||
{
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
|
||||
|
||||
Set<String> state = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.allowBlockBreak);
|
||||
if (state != null && state.contains(block.getType().toString().toUpperCase()))
|
||||
{
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
Set<String> state2 = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player), WorldGuardExtraFlagsPlugin.denyBlockBreak);
|
||||
if (state2 != null && state2.contains(block.getType().toString().toUpperCase()))
|
||||
{
|
||||
event.setResult(Result.DENY);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setResult(Result.DEFAULT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package net.goldtreeservers.worldguardextraflags.listeners;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
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 org.bukkit.event.world.PortalCreateEvent;
|
||||
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
|
||||
public class EntityListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPortalCreateEvent(PortalCreateEvent event)
|
||||
{
|
||||
for(Block block : event.getBlocks())
|
||||
{
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
|
||||
State allowNetherPortals = regions.queryValue(null, WorldGuardExtraFlagsPlugin.netherPortals);
|
||||
if (allowNetherPortals == State.DENY)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityToggleGlideEvent(EntityToggleGlideEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof LivingEntity)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
if (WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().hasBypass((Player)event.getEntity(), ((Player)event.getEntity()).getWorld()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(event.getEntity().getLocation());
|
||||
State allowGliding = regions.queryValue(event.getEntity() instanceof Player ? WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer((Player)event.getEntity()) : null, WorldGuardExtraFlagsPlugin.glide);
|
||||
if (allowGliding != null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
((LivingEntity)event.getEntity()).setGliding(allowGliding == State.ALLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package net.goldtreeservers.worldguardextraflags.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import net.ess3.api.events.GodStatusChangeEvent;
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.GodmodeFlag;
|
||||
|
||||
public class EssentialsListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onGodStatusChangeEvent(GodStatusChangeEvent event)
|
||||
{
|
||||
if (WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().get(event.getController().getBase()).getHandler(GodmodeFlag.class).shouldBlockEvent(event.getController().getBase(), event.getController().getBase().getWorld()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,232 @@
|
|||
package net.goldtreeservers.worldguardextraflags.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
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.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
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 net.elseland.xikage.MythicMobs.Mobs.EggManager;
|
||||
import net.elseland.xikage.MythicMobs.Mobs.MythicMob;
|
||||
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.FlyFlag;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.GiveEffectsFlag;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PlayerListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerTeleportEvent(PlayerTeleportEvent event)
|
||||
{
|
||||
event.getPlayer().removeMetadata("WorldGuardExtraFlagsWaitingForTeleportationToBeDone", WorldGuardExtraFlagsPlugin.getPlugin());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerDeathEvent(PlayerDeathEvent event)
|
||||
{
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(event.getEntity().getLocation());
|
||||
Boolean keepInventory = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(event.getEntity()), WorldGuardExtraFlagsPlugin.keepInventory);
|
||||
if (keepInventory != null && keepInventory)
|
||||
{
|
||||
event.setKeepInventory(true);
|
||||
event.getDrops().clear();
|
||||
}
|
||||
|
||||
Boolean keepExp = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(event.getEntity()), WorldGuardExtraFlagsPlugin.keepExp);
|
||||
if (keepExp != null && keepExp)
|
||||
{
|
||||
event.setKeepLevel(true);
|
||||
event.setDroppedExp(0);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
||||
{
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(event.getPlayer().getLocation());
|
||||
String prefix = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(event.getPlayer()), WorldGuardExtraFlagsPlugin.chatPrefix);
|
||||
String suffix = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(event.getPlayer()), WorldGuardExtraFlagsPlugin.chatSuffix);
|
||||
|
||||
if (prefix != null)
|
||||
{
|
||||
event.setFormat(prefix + event.getFormat());
|
||||
}
|
||||
|
||||
if (suffix != null)
|
||||
{
|
||||
event.setFormat(event.getFormat() + suffix);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerRespawnEvent(PlayerRespawnEvent event)
|
||||
{
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(event.getPlayer().getLocation());
|
||||
Location respawnLocation = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(event.getPlayer()), WorldGuardExtraFlagsPlugin.respawnLocation);
|
||||
if (respawnLocation != null)
|
||||
{
|
||||
event.setRespawnLocation(BukkitUtil.toLocation(respawnLocation));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerItemConsumeEvent(PlayerItemConsumeEvent event)
|
||||
{
|
||||
ItemMeta itemMeta = event.getItem().getItemMeta();
|
||||
if (itemMeta instanceof PotionMeta)
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().get(event.getPlayer()).getHandler(GiveEffectsFlag.class).drinkPotion(Potion.fromItemStack(event.getItem()).getEffects());
|
||||
}
|
||||
else
|
||||
{
|
||||
Material material = event.getItem().getType();
|
||||
if (material == Material.MILK_BUCKET)
|
||||
{
|
||||
WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().get(event.getPlayer()).getHandler(GiveEffectsFlag.class).drinkMilk();
|
||||
ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(event.getPlayer().getLocation());
|
||||
|
||||
List<PotionEffectType> effects = new ArrayList<PotionEffectType>();
|
||||
for(Set<PotionEffect> potionEffects : regions.queryAllValues(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(event.getPlayer()), WorldGuardExtraFlagsPlugin.giveEffects))
|
||||
{
|
||||
if (potionEffects != null)
|
||||
{
|
||||
for(PotionEffect potionEffect : potionEffects)
|
||||
{
|
||||
if (potionEffect != null)
|
||||
{
|
||||
effects.add(potionEffect.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerGameModeChangeEvent(PlayerGameModeChangeEvent event)
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
event.getPlayer().setAllowFlight(WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().get(event.getPlayer()).getHandler(FlyFlag.class).getFlyStatys());
|
||||
}
|
||||
catch(Exception ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}.runTask(WorldGuardExtraFlagsPlugin.getPlugin());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerInteractEvent(PlayerInteractEvent event)
|
||||
{
|
||||
if (WorldGuardExtraFlagsPlugin.isMythicMobsEnabled())
|
||||
{
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == 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.getWorldGuard().getRegionContainer().createQuery().getApplicableRegions(event.getAction() == Action.RIGHT_CLICK_BLOCK ? event.getClickedBlock().getLocation() : event.getPlayer().getLocation());
|
||||
State state = regions.queryValue(WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(event.getPlayer()), WorldGuardExtraFlagsPlugin.mythicMobsEggs);
|
||||
if (state == State.DENY)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerChangedWorldEvent(PlayerChangedWorldEvent event)
|
||||
{
|
||||
if (WorldGuardExtraFlagsPlugin.isEssentialsEnabled()) //Essentials how dare u do this to me!?!
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !WorldGuardExtraFlagsPlugin.getEssentialsPlugin().getUser(player).isAuthorized("essentials.fly"))
|
||||
{
|
||||
//Essentials now turns off flight, fuck him
|
||||
|
||||
try
|
||||
{
|
||||
player.setAllowFlight(WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().get(player).getHandler(FlyFlag.class).getFlyStatys());
|
||||
}
|
||||
catch(Exception ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerSpawnLocationEvent(PlayerSpawnLocationEvent event)
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
event.getPlayer().setAllowFlight(WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().get(event.getPlayer()).getHandler(FlyFlag.class).getFlyStatys());
|
||||
}
|
||||
catch(Exception ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}.runTask(WorldGuardExtraFlagsPlugin.getPlugin());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package net.goldtreeservers.worldguardextraflags.listeners;
|
||||
|
||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||
import com.sk89q.worldedit.util.eventbus.EventHandler;
|
||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||
|
||||
import net.goldtreeservers.worldguardextraflags.flags.WorldEditFlag;
|
||||
|
||||
public class WorldEditListener
|
||||
{
|
||||
@Subscribe(priority = EventHandler.Priority.VERY_EARLY)
|
||||
public void onEditSessionEvent(EditSessionEvent event)
|
||||
{
|
||||
if (event.getActor() != null) //Not a player?
|
||||
{
|
||||
event.setExtent(new WorldEditFlag(event.getExtent(), event.getActor()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package net.goldtreeservers.worldguardextraflags.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
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;
|
||||
|
||||
public class FaweWorldEditFlag extends FaweMaskManager<Player>
|
||||
{
|
||||
public FaweWorldEditFlag()
|
||||
{
|
||||
super("WorldGuardExtraFlags");
|
||||
}
|
||||
|
||||
public ProtectedRegion getRegion(final Player player, final Location loc)
|
||||
{
|
||||
final com.sk89q.worldguard.LocalPlayer localplayer = WorldGuardExtraFlagsPlugin.getWorldGuard().wrapPlayer(player);
|
||||
RegionManager manager = WorldGuardExtraFlagsPlugin.getWorldGuard().getRegionManager(player.getWorld());
|
||||
final ProtectedRegion global = manager.getRegion("__global__");
|
||||
if (global != null && !isDenied(localplayer, global))
|
||||
{
|
||||
return global;
|
||||
}
|
||||
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(player.getLocation());
|
||||
for (final ProtectedRegion region : regions)
|
||||
{
|
||||
if (!isDenied(localplayer, region))
|
||||
{
|
||||
return region;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isDenied(LocalPlayer localplayer, ProtectedRegion region)
|
||||
{
|
||||
return region.getFlag(WorldGuardExtraFlagsPlugin.worldEdit) == State.DENY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(FawePlayer<Player> fawePlayer)
|
||||
{
|
||||
final Player player = fawePlayer.parent;
|
||||
final Location location = player.getLocation();
|
||||
final ProtectedRegion myregion = this.getRegion(player, location);
|
||||
if (myregion != null)
|
||||
{
|
||||
final BlockVector pos1;
|
||||
final BlockVector pos2;
|
||||
if (myregion.getId().equals("__global__"))
|
||||
{
|
||||
pos1 = new BlockVector(Integer.MIN_VALUE, 0, Integer.MIN_VALUE);
|
||||
pos2 = new BlockVector(Integer.MAX_VALUE, 255, Integer.MAX_VALUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos1 = new BlockVector(myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
|
||||
pos2 = new BlockVector(myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
|
||||
}
|
||||
|
||||
return new FaweMask(pos1, pos2)
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return myregion.getId();
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package net.goldtreeservers.worldguardextraflags.utils;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
|
||||
public class PluginUtils
|
||||
{
|
||||
public static void registerFAWE()
|
||||
{
|
||||
FaweAPI.addMaskManager(new FaweWorldEditFlag());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package net.goldtreeservers.worldguardextraflags.utils;
|
||||
|
||||
public class SoundData
|
||||
{
|
||||
private final String sound;
|
||||
private final int interval;
|
||||
|
||||
public SoundData(String sound, int interval)
|
||||
{
|
||||
this.sound = sound;
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
public String getSound()
|
||||
{
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
public int getInterval()
|
||||
{
|
||||
return this.interval;
|
||||
}
|
||||
}
|
10
src/main/resources/plugin.yml
Normal file
10
src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
name: WorldGuardExtraFlags
|
||||
version: 2.11.0
|
||||
description: Add more flags to worldguard to help manage your server easily!
|
||||
author: isokissa3
|
||||
authors: [isokissa3]
|
||||
website: https://goldtreevers.net
|
||||
depend: [ WorldGuard ]
|
||||
softdepend: [ MythicMobs, FastAsyncWorldEdit, Essentials ]
|
||||
|
||||
main: net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin
|
Loading…
Reference in a new issue