2014-10-13 15:14:34 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import java.util.LinkedHashSet;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.Perm;
|
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
|
|
|
import com.massivecraft.massivecore.ps.PS;
|
|
|
|
|
|
|
|
|
|
|
|
public class CmdFactionsSetCircle extends CmdFactionsSetXRadius
|
|
|
|
{
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
public CmdFactionsSetCircle()
|
|
|
|
{
|
|
|
|
// Aliases
|
|
|
|
this.addAliases("c", "circle");
|
|
|
|
|
|
|
|
// Requirements
|
|
|
|
this.addRequirements(ReqIsPlayer.get());
|
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.SET_CIRCLE.node));
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Set<PS> getChunks()
|
|
|
|
{
|
|
|
|
// Common Startup
|
|
|
|
final PS chunk = PS.valueOf(me).getChunk(true);
|
|
|
|
final Set<PS> chunks = new LinkedHashSet<PS>();
|
|
|
|
|
2014-10-14 08:19:00 +02:00
|
|
|
chunks.add(chunk); // The center should come first for pretty messages
|
|
|
|
|
2014-10-13 15:14:34 +02:00
|
|
|
Integer radiusZero = this.getRadiusZero();
|
|
|
|
if (radiusZero == null) return null;
|
|
|
|
|
2014-10-14 08:19:00 +02:00
|
|
|
double radiusSquared = radiusZero * radiusZero;
|
2014-10-13 15:14:34 +02:00
|
|
|
|
2014-10-14 08:19:00 +02:00
|
|
|
for (int dx = -radiusZero; dx <= radiusZero; dx++)
|
2014-10-13 15:14:34 +02:00
|
|
|
{
|
2014-10-14 08:19:00 +02:00
|
|
|
for (int dz = -radiusZero; dz <= radiusZero; dz++)
|
2014-10-13 15:14:34 +02:00
|
|
|
{
|
|
|
|
if (dx*dx + dz*dz > radiusSquared) continue;
|
2014-10-14 08:19:00 +02:00
|
|
|
|
|
|
|
int x = chunk.getChunkX() + dx;
|
|
|
|
int z = chunk.getChunkZ() + dz;
|
|
|
|
|
2014-10-13 15:14:34 +02:00
|
|
|
chunks.add(chunk.withChunkX(x).withChunkZ(z));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return chunks;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|