Factions3/src/com/massivecraft/factions/cmd/CmdFactionsMap.java

73 lines
1.8 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
import java.util.List;
import org.bukkit.Location;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.ps.PS;
2014-09-18 13:41:20 +02:00
public class CmdFactionsMap extends FactionsCommand
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2013-04-10 13:12:22 +02:00
public CmdFactionsMap()
{
2013-11-11 09:31:04 +01:00
// Aliases
2013-04-16 10:11:59 +02:00
this.addAliases("map");
2013-11-11 09:31:04 +01:00
// Args
this.addOptionalArg("on/off", "once");
2013-11-11 09:31:04 +01:00
// Requirements
2013-04-16 10:11:59 +02:00
this.addRequirements(ReqHasPerm.get(Perm.MAP.node));
this.addRequirements(ReqIsPlayer.get());
2011-03-23 17:39:56 +01:00
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
2011-03-23 17:39:56 +01:00
@Override
public void perform() throws MassiveCommandException
{
if ( ! this.argIsSet(0))
{
showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT_FULL);
2013-04-16 11:27:03 +02:00
return;
}
2013-04-16 11:27:03 +02:00
if (this.arg(0, ARBoolean.get(), !msender.isMapAutoUpdating()))
{
2013-04-25 12:04:01 +02:00
// And show the map once
showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT);
2013-04-25 12:04:01 +02:00
2013-04-16 11:27:03 +02:00
// Turn on
msender.setMapAutoUpdating(true);
2013-04-16 11:27:03 +02:00
msg("<i>Map auto update <green>ENABLED.");
}
2013-04-16 11:27:03 +02:00
else
{
// Turn off
msender.setMapAutoUpdating(false);
2013-04-16 11:27:03 +02:00
msg("<i>Map auto update <red>DISABLED.");
}
}
public void showMap(int width, int height)
{
Location location = me.getLocation();
List<String> message = BoardColl.get().getMap(msenderFaction, PS.valueOf(location), location.getYaw(), width, height);
sendMessage(message);
}
}