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

59 lines
1.4 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.type.TypeFaction;
import com.massivecraft.factions.entity.MConf;
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.type.primitive.TypeInteger;
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);
// Parameters
this.addParameter(1, TypeInteger.get(), "radius");
2014-11-19 10:30:44 +01:00
if (claim)
{
this.addParameter(TypeFaction.get(), "faction", "you");
2014-11-19 10:30:44 +01:00
this.setFactionArgIndex(1);
}
}
// -------------------------------------------- //
// EXTRAS
// -------------------------------------------- //
2015-02-12 12:00:55 +01:00
public Integer getRadius() throws MassiveException
{
2015-05-22 10:21:35 +02:00
int radius = this.readArgAt(0);
// Radius Claim Min
if (radius < 1)
{
throw new MassiveException().setMsg("<b>If you specify a radius, it must be at least 1.");
}
// Radius Claim Max
if (radius > MConf.get().setRadiusMax && ! msender.isOverriding())
{
throw new MassiveException().setMsg("<b>The maximum radius allowed is <h>%s<b>.", MConf.get().setRadiusMax);
}
return radius;
}
2015-02-12 12:00:55 +01:00
public Integer getRadiusZero() throws MassiveException
{
Integer ret = this.getRadius();
return ret - 1;
}
}