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

62 lines
1.3 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.entity.MConf;
2015-02-12 12:00:55 +01:00
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARInteger;
public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2014-11-19 10:30:44 +01:00
public CmdFactionsSetXRadius(boolean claim)
{
2014-11-19 10:30:44 +01:00
// Super
super(claim);
// Args
this.addOptionalArg("radius", "1");
2014-11-19 10:30:44 +01:00
if (claim)
{
this.addOptionalArg("faction", "you");
this.setFactionArgIndex(1);
}
}
// -------------------------------------------- //
// EXTRAS
// -------------------------------------------- //
2015-02-12 12:00:55 +01:00
public Integer getRadius() throws MassiveException
{
Integer radius = this.arg(0, ARInteger.get(), 1);
if (radius == null) return radius;
// Radius Claim Min
if (radius < 1)
{
msg("<b>If you specify a radius, it must be at least 1.");
return null;
}
// Radius Claim Max
if (radius > MConf.get().setRadiusMax && ! msender.isUsingAdminMode())
{
msg("<b>The maximum radius allowed is <h>%s<b>.", MConf.get().setRadiusMax);
return null;
}
return radius;
}
2015-02-12 12:00:55 +01:00
public Integer getRadiusZero() throws MassiveException
{
Integer ret = this.getRadius();
if (ret == null) return ret;
return ret - 1;
}
}