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)
{ {
case ALLOW:
break;
case DENY:
{
if (!event.isGliding())
{
return;
}
event.setCancelled(true); event.setCancelled(true);
player.setGliding(state == ForcedState.FORCE); //Prevent the player from being allowed to glide by spamming space
if (state == ForcedState.DENY)
{
player.teleport(player.getLocation()); player.teleport(player.getLocation());
break;
}
case FORCE:
{
if (event.isGliding())
{
return;
}
event.setCancelled(true);
break;
} }
} }
} }