2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions.commands;
|
2011-06-10 21:26:12 +02:00
|
|
|
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.Board;
|
|
|
|
import com.massivecraft.factions.FLocation;
|
2011-10-09 14:53:38 +02:00
|
|
|
import com.massivecraft.factions.Factions;
|
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2011-06-10 21:26:12 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
public class FCommandAutoSafeclaim extends FCommand
|
|
|
|
{
|
2011-06-10 21:26:12 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
public FCommandAutoSafeclaim()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.aliases.add("autosafe");
|
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
|
|
|
this.optionalArgs.put("on/off", "flipp");
|
|
|
|
|
|
|
|
this.permission = Permission.MANAGE_SAFE_ZONE.node;
|
|
|
|
|
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = true;
|
|
|
|
senderMustBeAdmin = false;
|
|
|
|
|
|
|
|
this.setHelpShort("Auto-claim land for the safezone");
|
2011-06-10 21:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-10-09 14:53:38 +02:00
|
|
|
public void perform()
|
|
|
|
{
|
|
|
|
if( isLocked() )
|
|
|
|
{
|
2011-06-10 21:26:12 +02:00
|
|
|
sendLockMessage();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
boolean enabled = this.argAsBool(0, ! fme.isAutoSafeClaimEnabled());
|
|
|
|
|
|
|
|
fme.setIsAutoSafeClaimEnabled(enabled);
|
2011-06-10 21:26:12 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
if ( ! enabled)
|
|
|
|
{
|
|
|
|
sendMessageParsed("<i>Auto-claiming of safe zone disabled.");
|
2011-06-10 21:26:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
sendMessageParsed("<i>Auto-claiming of safe zone enabled.");
|
2011-06-10 21:26:12 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
FLocation playerFlocation = new FLocation(fme);
|
2011-06-10 21:26:12 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
if (!Board.getFactionAt(playerFlocation).isSafeZone())
|
|
|
|
{
|
|
|
|
Board.setFactionAt(Factions.i.getSafeZone(), playerFlocation);
|
|
|
|
sendMessageParsed("<i>This land is now a safe zone.");
|
2011-06-10 21:26:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|