Fix edge case with glide flag

This commit is contained in:
isokissa3 2020-07-08 22:16:15 +03:00
parent 7cd74edb2e
commit d9f15956cd

View file

@ -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;
} }
} }
} }