2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-10-14 09:09:37 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2014-11-18 10:00:15 +01:00
|
|
|
import org.bukkit.Location;
|
|
|
|
|
2014-10-14 09:09:37 +02:00
|
|
|
import com.massivecraft.factions.Const;
|
2013-04-09 12:56:29 +02:00
|
|
|
import com.massivecraft.factions.Perm;
|
2014-09-17 13:17:33 +02:00
|
|
|
import com.massivecraft.factions.entity.BoardColl;
|
2015-02-12 12:00:55 +01:00
|
|
|
import com.massivecraft.massivecore.MassiveException;
|
2015-11-06 02:10:29 +01:00
|
|
|
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
|
|
|
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
2016-06-08 13:00:15 +02:00
|
|
|
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.ps.PS;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-09-18 13:41:20 +02:00
|
|
|
public class CmdFactionsMap extends FactionsCommand
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public CmdFactionsMap()
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
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
|
|
|
|
2015-10-21 19:35:41 +02:00
|
|
|
// Parameters
|
2016-06-08 13:00:15 +02:00
|
|
|
this.addParameter(TypeBooleanYes.get(), "on/off", "once");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Requirements
|
2016-05-26 10:17:44 +02:00
|
|
|
this.addRequirements(RequirementHasPerm.get(Perm.MAP));
|
2015-11-06 02:10:29 +01:00
|
|
|
this.addRequirements(RequirementIsPlayer.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
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2015-02-12 12:00:55 +01:00
|
|
|
public void perform() throws MassiveException
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2015-05-06 17:04:35 +02:00
|
|
|
if ( ! this.argIsSet())
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2014-10-14 09:09:37 +02:00
|
|
|
showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT_FULL);
|
2013-04-16 11:27:03 +02:00
|
|
|
return;
|
2011-10-09 14:53:38 +02:00
|
|
|
}
|
2013-04-16 11:27:03 +02:00
|
|
|
|
2015-05-06 17:04:35 +02:00
|
|
|
if (this.readArg(!msender.isMapAutoUpdating()))
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-04-25 12:04:01 +02:00
|
|
|
// And show the map once
|
2014-10-14 09:09:37 +02:00
|
|
|
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
|
2013-04-25 07:29:19 +02:00
|
|
|
msender.setMapAutoUpdating(true);
|
2013-04-16 11:27:03 +02:00
|
|
|
msg("<i>Map auto update <green>ENABLED.");
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
2013-04-16 11:27:03 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Turn off
|
2013-04-25 07:29:19 +02:00
|
|
|
msender.setMapAutoUpdating(false);
|
2013-04-16 11:27:03 +02:00
|
|
|
msg("<i>Map auto update <red>DISABLED.");
|
|
|
|
}
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
|
2014-10-14 09:09:37 +02:00
|
|
|
public void showMap(int width, int height)
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2014-11-18 10:00:15 +01:00
|
|
|
Location location = me.getLocation();
|
2016-03-15 20:43:54 +01:00
|
|
|
List<Object> message = BoardColl.get().getMap(msenderFaction, PS.valueOf(location), location.getYaw(), width, height);
|
2015-09-03 09:33:01 +02:00
|
|
|
message(message);
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|