mirror of
https://github.com/TotalFreedomMC/TF-WorldGuardExtraFlagsPlugin.git
synced 2024-12-28 10:04:50 +00:00
Fixed god flag & gliding flag screen flickering if user is OP
This commit is contained in:
parent
09eae2ac3c
commit
de1055bc36
3 changed files with 22 additions and 17 deletions
|
@ -82,10 +82,13 @@ public class GlideFlag extends FlagValueChangeHandler<State>
|
|||
@Override
|
||||
public boolean testMoveTo(Player player, Location from, Location to, ApplicableRegionSet toSet, MoveType moveType)
|
||||
{
|
||||
if (this.currentValue != null && player.isGliding() != this.currentValue)
|
||||
{
|
||||
player.setGliding(this.currentValue);
|
||||
}
|
||||
if (!WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().hasBypass(player, player.getWorld()))
|
||||
{
|
||||
if (this.currentValue != null && player.isGliding() != this.currentValue)
|
||||
{
|
||||
player.setGliding(this.currentValue);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -52,19 +52,18 @@ public class GodmodeFlag extends FlagValueChangeHandler<State>
|
|||
|
||||
public void updateGodmode(Player player, State newValue, World world)
|
||||
{
|
||||
if (!this.getSession().getManager().hasBypass(player, world) && newValue != null)
|
||||
this.isGodmodeEnabled = newValue == null ? null : newValue == State.ALLOW ? true : false;
|
||||
|
||||
if (!this.getSession().getManager().hasBypass(player, world) && this.isGodmodeEnabled != null)
|
||||
{
|
||||
if (this.isGodmodeEnabled == null || this.isGodmodeEnabled != (newValue == State.ALLOW ? true : false))
|
||||
if (WorldGuardExtraFlagsPlugin.isEssentialsEnabled())
|
||||
{
|
||||
if (WorldGuardExtraFlagsPlugin.isEssentialsEnabled())
|
||||
if (this.originalEssentialsGodmode == null)
|
||||
{
|
||||
if (this.originalEssentialsGodmode == null)
|
||||
{
|
||||
this.originalEssentialsGodmode = WorldGuardExtraFlagsPlugin.getEssentialsPlugin().getUser(player).isGodModeEnabledRaw();
|
||||
}
|
||||
|
||||
WorldGuardExtraFlagsPlugin.getEssentialsPlugin().getUser(player).setGodModeEnabled(newValue == State.ALLOW ? true : false);
|
||||
this.originalEssentialsGodmode = WorldGuardExtraFlagsPlugin.getEssentialsPlugin().getUser(player).isGodModeEnabledRaw();
|
||||
}
|
||||
|
||||
WorldGuardExtraFlagsPlugin.getEssentialsPlugin().getUser(player).setGodModeEnabled(this.isGodmodeEnabled);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -99,8 +98,8 @@ public class GodmodeFlag extends FlagValueChangeHandler<State>
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean shouldBlockEvent(Player player, World world)
|
||||
public Boolean getIsGodmodEnbled()
|
||||
{
|
||||
return !this.getSession().getManager().hasBypass(player, world) && this.originalEssentialsGodmode != null;
|
||||
return this.isGodmodeEnabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,12 @@ public class EssentialsListener implements Listener
|
|||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onGodStatusChangeEvent(GodStatusChangeEvent event)
|
||||
{
|
||||
if (WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().get(event.getController().getBase()).getHandler(GodmodeFlag.class).shouldBlockEvent(event.getController().getBase(), event.getController().getBase().getWorld()))
|
||||
if (!WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().hasBypass(event.getController().getBase(), event.getController().getBase().getWorld()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
if (WorldGuardExtraFlagsPlugin.getWorldGuard().getSessionManager().get(event.getController().getBase()).getHandler(GodmodeFlag.class).getIsGodmodEnbled() != null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue