Factions/src/com/massivecraft/factions/cmd/CmdFactionsFly.java

60 lines
1.6 KiB
Java
Raw Normal View History

2019-01-27 22:30:56 +01:00
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.engine.EngineFly;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommandToggle;
2019-01-31 10:38:48 +01:00
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
2019-01-27 22:30:56 +01:00
import com.massivecraft.massivecore.engine.EngineMassiveCorePlayerUpdate;
import com.massivecraft.massivecore.ps.PS;
import org.bukkit.entity.Player;
public class CmdFactionsFly extends MassiveCommandToggle
{
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static CmdFactionsFly i = new CmdFactionsFly();
public static CmdFactionsFly get() { return i; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsFly()
{
2019-01-31 10:38:48 +01:00
this.addRequirements(RequirementIsPlayer.get());
2019-01-27 22:30:56 +01:00
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String getName()
{
return "faction flying";
}
@Override
public boolean getValue() throws MassiveException
{
return MPlayer.get(sender).isFlying();
}
public void setValue(boolean value) throws MassiveException
{
MPlayer mplayer = MPlayer.get(sender);
2019-01-31 10:38:48 +01:00
Player player = me;
2019-01-27 22:30:56 +01:00
if (player == null) throw new MassiveException().addMsg("<b>Could not find player.");
PS ps = PS.valueOf(player);
2019-01-31 10:38:48 +01:00
if (value) EngineFly.canFlyInTerritoryOrThrow(mplayer, ps);
2019-01-27 22:30:56 +01:00
mplayer.setFlying(value);
EngineMassiveCorePlayerUpdate.update(player, false);
}
}