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