mirror of
https://github.com/TotalFreedomMC/TF-WorldGuardExtraFlagsPlugin.git
synced 2024-12-27 17:44:47 +00:00
Fix edge case with glide flag
This commit is contained in:
parent
7cd74edb2e
commit
d9f15956cd
1 changed files with 25 additions and 6 deletions
|
@ -31,15 +31,34 @@ public class EntityListenerOnePointNine implements Listener
|
||||||
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
|
ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());
|
||||||
|
|
||||||
ForcedState state = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.GLIDE);
|
ForcedState state = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.GLIDE);
|
||||||
if (state != ForcedState.ALLOW)
|
switch(state)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
case ALLOW:
|
||||||
|
break;
|
||||||
player.setGliding(state == ForcedState.FORCE);
|
case DENY:
|
||||||
|
|
||||||
if (state == ForcedState.DENY)
|
|
||||||
{
|
{
|
||||||
|
if (!event.isGliding())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//Prevent the player from being allowed to glide by spamming space
|
||||||
player.teleport(player.getLocation());
|
player.teleport(player.getLocation());
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FORCE:
|
||||||
|
{
|
||||||
|
if (event.isGliding())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue