Add WorldGuardExtraFlags Fly flag check
Add WorldGuardExtraFlags soft depency
This commit is contained in:
parent
d2e0f551aa
commit
6df07dc9d6
@ -5,7 +5,7 @@ website: ${project.url}
|
|||||||
description: ${project.description}
|
description: ${project.description}
|
||||||
authors: [Madus, Cayorion, Ulumulu1510, MarkehMe, Brettflan, AlkorZ3]
|
authors: [Madus, Cayorion, Ulumulu1510, MarkehMe, Brettflan, AlkorZ3]
|
||||||
depend: [MassiveCore]
|
depend: [MassiveCore]
|
||||||
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, LocalAreaChat, LWC, ChatManager, AuthMe, Vault, WorldEdit, WorldGuard]
|
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, LocalAreaChat, LWC, ChatManager, AuthMe, Vault, WorldEdit, WorldGuard, WorldGuardExtraFlags]
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
permissions:
|
permissions:
|
||||||
# -------------------------------------------- #
|
# -------------------------------------------- #
|
||||||
|
5
pom.xml
5
pom.xml
@ -49,6 +49,11 @@
|
|||||||
<groupId>com.sk89q.worldguard</groupId>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
<artifactId>worldguard-bukkit</artifactId>
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- WorldGuardExtraFlags -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.goldtreeservers</groupId>
|
||||||
|
<artifactId>worldguardextraflags</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- Vault -->
|
<!-- Vault -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
|
@ -2,6 +2,7 @@ package com.massivecraft.factions.engine;
|
|||||||
|
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.cmd.CmdFactions;
|
import com.massivecraft.factions.cmd.CmdFactions;
|
||||||
|
import com.massivecraft.factions.integration.worldguard.EngineWorldGuard;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColl;
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.factions.entity.MConf;
|
import com.massivecraft.factions.entity.MConf;
|
||||||
@ -190,7 +191,7 @@ public class EngineFly extends Engine
|
|||||||
throw new MassiveException().addMsg("<b>You are not allowed to fly within " + locationFaction.getName() + " faction.");
|
throw new MassiveException().addMsg("<b>You are not allowed to fly within " + locationFaction.getName() + " faction.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the faction does not have the flag ...
|
// If the location faction does not have the flag ...
|
||||||
if (!locationFaction.getFlag(MFlag.getFlagFly()))
|
if (!locationFaction.getFlag(MFlag.getFlagFly()))
|
||||||
{
|
{
|
||||||
MFlag flag = MFlag.getFlagFly();
|
MFlag flag = MFlag.getFlagFly();
|
||||||
@ -207,7 +208,8 @@ public class EngineFly extends Engine
|
|||||||
ex.addMessage(CmdFactions.get().cmdFactionsFlag.cmdFactionsFlagSet.getTemplate(false, true, mplayer.getSender()));
|
ex.addMessage(CmdFactions.get().cmdFactionsFlag.cmdFactionsFlagSet.getTemplate(false, true, mplayer.getSender()));
|
||||||
}
|
}
|
||||||
// ... otherwise ...
|
// ... otherwise ...
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
// .. tell them to have someone else edit it ...
|
// .. tell them to have someone else edit it ...
|
||||||
ex.addMsg("<i>You can ask a faction admin to change the flag.");
|
ex.addMsg("<i>You can ask a faction admin to change the flag.");
|
||||||
}
|
}
|
||||||
@ -245,6 +247,12 @@ public class EngineFly extends Engine
|
|||||||
}
|
}
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the WorldGuard Region doesn't allows the player to fly...
|
||||||
|
if (!EngineWorldGuard.isFlyAllowed(mplayer))
|
||||||
|
{
|
||||||
|
throw new MassiveException().addMsg("<b>You are not allowed to fly within this WorldGuard region.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deactivateForPlayer(Player player)
|
public static void deactivateForPlayer(Player player)
|
||||||
|
@ -6,15 +6,22 @@ import com.massivecraft.factions.entity.MPlayer;
|
|||||||
import com.massivecraft.factions.event.EventFactionsChunksChange;
|
import com.massivecraft.factions.event.EventFactionsChunksChange;
|
||||||
import com.massivecraft.massivecore.Engine;
|
import com.massivecraft.massivecore.Engine;
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
import com.massivecraft.massivecore.ps.PS;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
|
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -124,4 +131,24 @@ public class EngineWorldGuard extends Engine
|
|||||||
return overlapRegions;
|
return overlapRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean isFlyAllowed(MPlayer mplayer)
|
||||||
|
{
|
||||||
|
// Skip checks if the configuration has worldguardCheckEnabled disabled
|
||||||
|
if ( ! MConf.get().worldguardCheckEnabled) return(true);
|
||||||
|
|
||||||
|
LocalPlayer wrapperPlayer = WorldGuardPlugin.inst().wrapPlayer(mplayer.getPlayer());
|
||||||
|
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||||
|
ApplicableRegionSet set = query.getApplicableRegions(BukkitAdapter.adapt(mplayer.getPlayer().getLocation()));
|
||||||
|
|
||||||
|
if( set.queryState( wrapperPlayer, net.goldtreeservers.worldguardextraflags.flags.Flags.FLY) == StateFlag.State.DENY)
|
||||||
|
{
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user