New command structure. Todo fix broken circle claim.
This commit is contained in:
parent
c690d33ad6
commit
8d31a0d4a0
@ -15,9 +15,6 @@ public enum Perm
|
||||
ACCESS_PLAYER("access.player"),
|
||||
ACCESS_FACTION("access.faction"),
|
||||
ADMIN("admin"),
|
||||
AUTOCLAIM("autoclaim"),
|
||||
CLAIM("claim"),
|
||||
CLAIM_RADIUS("claim.radius"),
|
||||
CREATE("create"),
|
||||
DEMOTE("demote"),
|
||||
DESCRIPTION("description"),
|
||||
@ -54,12 +51,17 @@ public enum Perm
|
||||
RELATION("relation"),
|
||||
SEECHUNK("seechunk"),
|
||||
SEECHUNKOLD("seechunkold"),
|
||||
SET("set"),
|
||||
SET_ONE("set.one"),
|
||||
SET_AUTO("set.auto"),
|
||||
SET_FILL("set.fill"),
|
||||
SET_SQUARE("set.square"),
|
||||
SET_CIRCLE("set.circle"),
|
||||
SET_TRANSFER("set.transfer"),
|
||||
SETHOME("sethome"),
|
||||
NAME("name"),
|
||||
TITLE("title"),
|
||||
TITLE_COLOR("title.color"),
|
||||
UNCLAIM("unclaim"),
|
||||
UNCLAIM_ALL("unclaimall"),
|
||||
UNSETHOME("unsethome"),
|
||||
VERSION("version"),
|
||||
|
||||
|
@ -25,6 +25,7 @@ public class CmdFactions extends FactionsCommand
|
||||
public CmdFactionsName cmdFactionsName = new CmdFactionsName();
|
||||
public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription();
|
||||
public CmdFactionsMotd cmdFactionsMotd = new CmdFactionsMotd();
|
||||
public CmdFactionsSet cmdFactionsSet = new CmdFactionsSet();
|
||||
public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome();
|
||||
public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome();
|
||||
public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite();
|
||||
@ -37,10 +38,6 @@ public class CmdFactions extends FactionsCommand
|
||||
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
|
||||
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
|
||||
public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
|
||||
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
|
||||
public CmdFactionsAutoClaim cmdFactionsAutoClaim = new CmdFactionsAutoClaim();
|
||||
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
|
||||
public CmdFactionsUnclaimall cmdFactionsUnclaimall = new CmdFactionsUnclaimall();
|
||||
public CmdFactionsAccess cmdFactionsAccess = new CmdFactionsAccess();
|
||||
public CmdFactionsRelationAlly cmdFactionsRelationAlly = new CmdFactionsRelationAlly();
|
||||
public CmdFactionsRelationTruce cmdFactionsRelationTruce = new CmdFactionsRelationTruce();
|
||||
@ -72,6 +69,7 @@ public class CmdFactions extends FactionsCommand
|
||||
this.addSubCommand(this.cmdFactionsName);
|
||||
this.addSubCommand(this.cmdFactionsDescription);
|
||||
this.addSubCommand(this.cmdFactionsMotd);
|
||||
this.addSubCommand(this.cmdFactionsSet);
|
||||
this.addSubCommand(this.cmdFactionsSethome);
|
||||
this.addSubCommand(this.cmdFactionsUnsethome);
|
||||
this.addSubCommand(this.cmdFactionsInvite);
|
||||
@ -84,10 +82,6 @@ public class CmdFactions extends FactionsCommand
|
||||
this.addSubCommand(this.cmdFactionsMoney);
|
||||
this.addSubCommand(this.cmdFactionsSeeChunk);
|
||||
this.addSubCommand(this.cmdFactionsSeeChunkOld);
|
||||
this.addSubCommand(this.cmdFactionsClaim);
|
||||
this.addSubCommand(this.cmdFactionsAutoClaim);
|
||||
this.addSubCommand(this.cmdFactionsUnclaim);
|
||||
this.addSubCommand(this.cmdFactionsUnclaimall);
|
||||
this.addSubCommand(this.cmdFactionsAccess);
|
||||
this.addSubCommand(this.cmdFactionsRelationAlly);
|
||||
this.addSubCommand(this.cmdFactionsRelationTruce);
|
||||
|
@ -1,96 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARInteger;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
|
||||
public class CmdFactionsClaim extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsClaim()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("claim");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("radius", "1");
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
this.addRequirements(ReqHasPerm.get(Perm.CLAIM.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
Integer radius = this.arg(0, ARInteger.get(), 1);
|
||||
if (radius == null) return;
|
||||
|
||||
final Faction newFaction = this.arg(1, ARFaction.get(), msenderFaction);
|
||||
if (newFaction == null) return;
|
||||
|
||||
// MPerm
|
||||
if (newFaction.isNormal() && ! MPerm.getPermTerritory().has(msender, newFaction, true)) return;
|
||||
|
||||
// Radius Claim Min
|
||||
if (radius < 1)
|
||||
{
|
||||
msg("<b>If you specify a radius, it must be at least 1.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Radius Claim Perm
|
||||
if (radius > 1 && ! Perm.CLAIM_RADIUS.has(sender, false))
|
||||
{
|
||||
msg("<b>You do not have permission to claim in a radius.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Radius Claim Max
|
||||
if (radius > MConf.get().radiusClaimRadiusLimit && ! msender.isUsingAdminMode())
|
||||
{
|
||||
msg("<b>The maximum radius allowed is <h>%s<b>.", MConf.get().radiusClaimRadiusLimit);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get Chunks
|
||||
final int radiusZero = radius -1;
|
||||
final PS chunk = PS.valueOf(me).getChunk(true);
|
||||
final int xmin = chunk.getChunkX() - radiusZero;
|
||||
final int xmax = chunk.getChunkX() + radiusZero;
|
||||
final int zmin = chunk.getChunkZ() - radiusZero;
|
||||
final int zmax = chunk.getChunkZ() + radiusZero;
|
||||
Set<PS> chunks = new LinkedHashSet<PS>();
|
||||
chunks.add(chunk); // The center should come first for pretty messages
|
||||
for (int x = xmin; x <= xmax; x++)
|
||||
{
|
||||
for (int z = zmin; z <= zmax; z++)
|
||||
{
|
||||
chunks.add(chunk.withChunkX(x).withChunkZ(z));
|
||||
}
|
||||
}
|
||||
|
||||
// Apply / Inform
|
||||
msender.tryClaim(newFaction, chunks);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
||||
|
||||
|
||||
public class CmdFactionsSet extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetOne cmdFactionsSetOne = new CmdFactionsSetOne();
|
||||
public CmdFactionsSetAuto cmdFactionsSetAuto = new CmdFactionsSetAuto();
|
||||
public CmdFactionsSetFill cmdFactionsSetFill = new CmdFactionsSetFill();
|
||||
public CmdFactionsSetSquare cmdFactionsSetSquare = new CmdFactionsSetSquare();
|
||||
public CmdFactionsSetCircle cmdFactionsSetCircle = new CmdFactionsSetCircle();
|
||||
public CmdFactionsSetTransfer cmdFactionsSetTransfer = new CmdFactionsSetTransfer();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSet()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("s", "set");
|
||||
|
||||
// Add SubCommands
|
||||
this.addSubCommand(this.cmdFactionsSetOne);
|
||||
this.addSubCommand(this.cmdFactionsSetAuto);
|
||||
this.addSubCommand(this.cmdFactionsSetFill);
|
||||
this.addSubCommand(this.cmdFactionsSetSquare);
|
||||
this.addSubCommand(this.cmdFactionsSetCircle);
|
||||
this.addSubCommand(this.cmdFactionsSetTransfer);
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SET.node));
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
@ -10,23 +11,24 @@ import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
public class CmdFactionsAutoClaim extends FactionsCommand
|
||||
|
||||
public class CmdFactionsSetAuto extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsAutoClaim()
|
||||
public CmdFactionsSetAuto()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("autoclaim");
|
||||
this.addAliases("a", "auto");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.AUTOCLAIM.node));
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SET_AUTO.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -37,23 +39,29 @@ public class CmdFactionsAutoClaim extends FactionsCommand
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
Faction forFaction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
final Faction newFaction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
|
||||
if (forFaction == null || forFaction == msender.getAutoClaimFaction())
|
||||
// Disable?
|
||||
if (newFaction == null || newFaction == msender.getAutoClaimFaction())
|
||||
{
|
||||
msender.setAutoClaimFaction(null);
|
||||
msg("<i>Auto-claiming of land disabled.");
|
||||
msg("<i>Disabled auto-setting as you walk around.");
|
||||
return;
|
||||
}
|
||||
|
||||
// MPerm
|
||||
if (forFaction.isNormal() && !MPerm.getPermTerritory().has(msender, forFaction, true)) return;
|
||||
// MPerm Preemptive Check
|
||||
if (newFaction.isNormal() && ! MPerm.getPermTerritory().has(msender, newFaction, true)) return;
|
||||
|
||||
msender.setAutoClaimFaction(forFaction);
|
||||
// Apply / Inform
|
||||
msender.setAutoClaimFaction(newFaction);
|
||||
msg("<i>Now auto-setting <h>%s<i> land.", newFaction.describeTo(msender));
|
||||
|
||||
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(msender));
|
||||
// Chunks
|
||||
final PS chunk = PS.valueOf(me).getChunk(true);
|
||||
Set<PS> chunks = Collections.singleton(chunk);
|
||||
|
||||
msender.tryClaim(forFaction, Collections.singletonList(PS.valueOf(me).getChunk(true)));
|
||||
// Apply / Inform
|
||||
msender.tryClaim(newFaction, chunks);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
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>();
|
||||
|
||||
Integer radiusZero = this.getRadiusZero();
|
||||
if (radiusZero == null) return null;
|
||||
|
||||
double radius = radiusZero + 1.5; // Tweak ze magic constant to get ze requested behavior.
|
||||
double radiusSquared = radius * radius;
|
||||
|
||||
chunks.add(chunk); // The center should come first for pretty messages
|
||||
|
||||
final int xmin = chunk.getChunkX() - radiusZero;
|
||||
final int xmax = chunk.getChunkX() + radiusZero;
|
||||
final int zmin = chunk.getChunkZ() - radiusZero;
|
||||
final int zmax = chunk.getChunkZ() + radiusZero;
|
||||
|
||||
for (int x = xmin; x <= xmax; x++)
|
||||
{
|
||||
for (int z = zmin; z <= zmax; z++)
|
||||
{
|
||||
double dx = x - chunk.getChunkX();
|
||||
double dz = z - chunk.getChunkZ();
|
||||
if (dx*dx + dz*dz > radiusSquared) continue;
|
||||
chunks.add(chunk.withChunkX(x).withChunkZ(z));
|
||||
}
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
|
||||
|
||||
public class CmdFactionsSetFill extends CmdFactionsSetXSimple
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetFill()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("f", "fill");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SET_FILL.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Set<PS> getChunks()
|
||||
{
|
||||
// Common Startup
|
||||
final PS chunk = PS.valueOf(me).getChunk(true);
|
||||
final Set<PS> chunks = new LinkedHashSet<PS>();
|
||||
|
||||
// What faction (aka color) resides there?
|
||||
// NOTE: Wilderness/None is valid.
|
||||
final Faction color = BoardColl.get().getFactionAt(chunk);
|
||||
|
||||
// We start where we are!
|
||||
chunks.add(chunk);
|
||||
|
||||
// Flood!
|
||||
int max = MConf.get().setFillMax;
|
||||
floodSearch(chunks, color, max);
|
||||
|
||||
// Limit Reached?
|
||||
if (chunks.size() >= max)
|
||||
{
|
||||
msg("<b>Fill limit of <h>%d <b>reached.", max);
|
||||
return null;
|
||||
}
|
||||
|
||||
// OK!
|
||||
return chunks;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FLOOD FILL
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static void floodSearch(Set<PS> set, Faction color, int max)
|
||||
{
|
||||
// Clean
|
||||
if (set == null) throw new NullPointerException("set");
|
||||
if (color == null) throw new NullPointerException("color");
|
||||
|
||||
// Expand
|
||||
Set<PS> expansion = new LinkedHashSet<PS>();
|
||||
for (PS chunk : set)
|
||||
{
|
||||
Set<PS> neighbours = MUtil.set(
|
||||
chunk.withChunkX(chunk.getChunkX() + 1),
|
||||
chunk.withChunkX(chunk.getChunkX() - 1),
|
||||
chunk.withChunkZ(chunk.getChunkZ() + 1),
|
||||
chunk.withChunkZ(chunk.getChunkZ() - 1)
|
||||
);
|
||||
|
||||
for (PS neighbour : neighbours)
|
||||
{
|
||||
if (set.contains(neighbour)) continue;
|
||||
Faction faction = BoardColl.get().getFactionAt(neighbour);
|
||||
if (faction == null) continue;
|
||||
if (faction != color) continue;
|
||||
expansion.add(neighbour);
|
||||
}
|
||||
}
|
||||
set.addAll(expansion);
|
||||
|
||||
// No Expansion?
|
||||
if (expansion.isEmpty()) return;
|
||||
|
||||
// Reached Max?
|
||||
if (set.size() >= max) return;
|
||||
|
||||
// Recurse
|
||||
floodSearch(set, color, max);
|
||||
}
|
||||
|
||||
}
|
@ -1,30 +1,28 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
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 CmdFactionsUnclaim extends FactionsCommand
|
||||
|
||||
public class CmdFactionsSetOne extends CmdFactionsSetXSimple
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsUnclaim()
|
||||
public CmdFactionsSetOne()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("unclaim");
|
||||
this.addAliases("o", "one");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node));
|
||||
this.addRequirements(ReqHasFaction.get());
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SET_ONE.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -32,14 +30,11 @@ public class CmdFactionsUnclaim extends FactionsCommand
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
public Set<PS> getChunks()
|
||||
{
|
||||
// Args
|
||||
PS chunk = PS.valueOf(me).getChunk(true);
|
||||
Faction newFaction = FactionColl.get().getNone();
|
||||
|
||||
// Apply
|
||||
if (msender.tryClaim(newFaction, Collections.singletonList(chunk))) return;
|
||||
final PS chunk = PS.valueOf(me).getChunk(true);
|
||||
final Set<PS> chunks = Collections.singleton(chunk);
|
||||
return chunks;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
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 CmdFactionsSetSquare extends CmdFactionsSetXRadius
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetSquare()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("s", "square");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SET_SQUARE.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Set<PS> getChunks()
|
||||
{
|
||||
// Common Startup
|
||||
final PS chunk = PS.valueOf(me).getChunk(true);
|
||||
final Set<PS> chunks = new LinkedHashSet<PS>();
|
||||
|
||||
Integer radiusZero = this.getRadiusZero();
|
||||
if (radiusZero == null) return null;
|
||||
|
||||
chunks.add(chunk); // The center should come first for pretty messages
|
||||
|
||||
final int xmin = chunk.getChunkX() - radiusZero;
|
||||
final int xmax = chunk.getChunkX() + radiusZero;
|
||||
final int zmin = chunk.getChunkZ() - radiusZero;
|
||||
final int zmax = chunk.getChunkZ() + radiusZero;
|
||||
|
||||
for (int x = xmin; x <= xmax; x++)
|
||||
{
|
||||
for (int z = zmin; z <= zmax; z++)
|
||||
{
|
||||
chunks.add(chunk.withChunkX(x).withChunkZ(z));
|
||||
}
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.entity.Board;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARWorldId;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
|
||||
|
||||
public class CmdFactionsSetTransfer extends CmdFactionsSetXTransfer
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetTransfer()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("t", "transfer");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SET_TRANSFER.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Set<PS> getChunks()
|
||||
{
|
||||
// Create Ret
|
||||
Set<PS> chunks = null;
|
||||
|
||||
// Args
|
||||
Faction oldFaction = this.getOldFaction();
|
||||
if (oldFaction == null) return null;
|
||||
|
||||
if (MUtil.list("a", "al", "all").contains(this.arg(0).toLowerCase()))
|
||||
{
|
||||
chunks = BoardColl.get().getChunks(oldFaction);
|
||||
}
|
||||
else
|
||||
{
|
||||
String worldId = null;
|
||||
if (MUtil.list("map").contains(this.arg(0).toLowerCase()))
|
||||
{
|
||||
if (me != null)
|
||||
{
|
||||
worldId = me.getWorld().getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("<b>You must specify which map from console.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
worldId = this.arg(0, ARWorldId.get());
|
||||
if (worldId == null) return null;
|
||||
}
|
||||
Board board = BoardColl.get().get(worldId);
|
||||
chunks = board.getChunks(oldFaction);
|
||||
}
|
||||
|
||||
// Return Ret
|
||||
return chunks;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
|
||||
public abstract class CmdFactionsSetX extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
final Faction newFaction = this.getNewFaction();
|
||||
if (newFaction == null) return;
|
||||
|
||||
final Set<PS> chunks = this.getChunks();
|
||||
if (chunks == null) return;
|
||||
|
||||
// Apply / Inform
|
||||
msender.tryClaim(newFaction, chunks);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ABSTRACT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public abstract int getFactionArgIndex();
|
||||
|
||||
public abstract Set<PS> getChunks();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXTRAS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Faction getNewFaction()
|
||||
{
|
||||
return this.arg(this.getFactionArgIndex(), ARFaction.get(), msenderFaction);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARInteger;
|
||||
|
||||
|
||||
public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetXRadius()
|
||||
{
|
||||
// Args
|
||||
this.addOptionalArg("radius", "1");
|
||||
this.addOptionalArg("faction", "you");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public int getFactionArgIndex()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXTRAS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Integer getRadius()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public Integer getRadiusZero()
|
||||
{
|
||||
Integer ret = this.getRadius();
|
||||
if (ret == null) return ret;
|
||||
return ret - 1;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public abstract class CmdFactionsSetXSimple extends CmdFactionsSetX
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetXSimple()
|
||||
{
|
||||
// Args
|
||||
this.addOptionalArg("faction", "you");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public int getFactionArgIndex()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
|
||||
public abstract class CmdFactionsSetXTransfer extends CmdFactionsSetX
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetXTransfer()
|
||||
{
|
||||
// Args
|
||||
this.addRequiredArg("all|map");
|
||||
this.addRequiredArg("old");
|
||||
this.addRequiredArg("new");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public int getFactionArgIndex()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXTRAS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Faction getOldFaction()
|
||||
{
|
||||
return this.arg(1, ARFaction.get());
|
||||
}
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
|
||||
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
public class CmdFactionsUnclaimall extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsUnclaimall()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("unclaimall");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node));
|
||||
this.addRequirements(ReqHasFaction.get());
|
||||
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
Faction faction = msenderFaction;
|
||||
Faction newFaction = FactionColl.get().getNone();
|
||||
|
||||
// MPerm
|
||||
if ( ! MPerm.getPermTerritory().has(msender, faction, true)) return;
|
||||
|
||||
// Apply
|
||||
Set<PS> chunks = BoardColl.get().getChunks(faction);
|
||||
msender.tryClaim(newFaction, chunks);
|
||||
|
||||
/*
|
||||
int countTotal = chunks.size();
|
||||
int countSuccess = 0;
|
||||
int countFail = 0;
|
||||
for (PS chunk : chunks)
|
||||
{
|
||||
EventFactionsChunksChange event = new EventFactionsChunksChange(sender, chunk, newFaction);
|
||||
event.run();
|
||||
if (event.isCancelled())
|
||||
{
|
||||
countFail++;
|
||||
}
|
||||
else
|
||||
{
|
||||
countSuccess++;
|
||||
BoardColl.get().setFactionAt(chunk, newFaction);
|
||||
}
|
||||
}
|
||||
|
||||
// Inform
|
||||
msenderFaction.msg("%s<i> unclaimed <h>%d <i>of your <h>%d <i>faction land. You now have <h>%d <i>land claimed.", msender.describeTo(msenderFaction, true), countSuccess, countTotal, countFail);
|
||||
|
||||
// Log
|
||||
if (MConf.get().logLandUnclaims)
|
||||
{
|
||||
Factions.get().log(msender.getName()+" unclaimed everything for the faction: "+msenderFaction.getName());
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -148,11 +148,11 @@ public class MConf extends Entity<MConf>
|
||||
public boolean factionNameForceUpperCase = false;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CLAIM LIMITS
|
||||
// SET LIMITS
|
||||
// -------------------------------------------- //
|
||||
|
||||
// the maximum radius allowed when using the claim command.
|
||||
public int radiusClaimRadiusLimit = 5;
|
||||
public int setRadiusMax = 5;
|
||||
public int setFillMax = 1000;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CLAIMS
|
||||
|
@ -15,9 +15,6 @@ permissions:
|
||||
factions.access.player: {description: grant player access, with the proper fperm, default: false}
|
||||
factions.access.view: {description: view access, default: false}
|
||||
factions.admin: {description: enable adminmode, default: false}
|
||||
factions.autoclaim: {description: autoclaim when walking, default: false}
|
||||
factions.claim: {description: claim land where you stand, default: false}
|
||||
factions.claim.radius: {description: claim land with radius, default: false}
|
||||
factions.create: {description: create new faction, default: false}
|
||||
factions.demote: {description: demote lesser members in your faction, default: false}
|
||||
factions.description: {description: change faction description, default: false}
|
||||
@ -54,12 +51,17 @@ permissions:
|
||||
factions.relation: {description: set relation wish to another faction, default: false}
|
||||
factions.seechunk: {description: see the chunk you stand in, default: false}
|
||||
factions.seechunkold: {description: see the chunk you stand in, default: false}
|
||||
factions.set: {description: set faction territory, default: false}
|
||||
factions.set.one: {description: set faction for a single chunk, default: false}
|
||||
factions.set.auto: {description: set faction as you walk around, default: false}
|
||||
factions.set.fill: {description: set faction by filling, default: false}
|
||||
factions.set.square: {description: set faction by square and radius, default: false}
|
||||
factions.set.circle: {description: set faction by circle and radius, default: false}
|
||||
factions.set.transfer: {description: set faction by transfer, default: false}
|
||||
factions.sethome: {description: set the faction home, default: false}
|
||||
factions.name: {description: set faction name, default: false}
|
||||
factions.title: {description: set player title, default: false}
|
||||
factions.title.color: {description: set player title with color, default: false}
|
||||
factions.unclaim: {description: unclaim land where you stand, default: false}
|
||||
factions.unclaimall: {description: unclaim all land, default: false}
|
||||
factions.unsethome: {description: unset faction home, default: false}
|
||||
factions.version: {description: see plugin version, default: false}
|
||||
# -------------------------------------------- #
|
||||
@ -72,9 +74,6 @@ permissions:
|
||||
factions.access.player: true
|
||||
factions.access.view: true
|
||||
factions.admin: true
|
||||
factions.autoclaim: true
|
||||
factions.claim: true
|
||||
factions.claim.radius: true
|
||||
factions.create: true
|
||||
factions.demote: true
|
||||
factions.description: true
|
||||
@ -111,12 +110,17 @@ permissions:
|
||||
factions.relation: true
|
||||
factions.seechunk: true
|
||||
factions.seechunkold: true
|
||||
factions.set: true
|
||||
factions.set.one: true
|
||||
factions.set.auto: true
|
||||
factions.set.fill: true
|
||||
factions.set.square: true
|
||||
factions.set.circle: true
|
||||
factions.set.transfer: true
|
||||
factions.sethome: true
|
||||
factions.name: true
|
||||
factions.title: true
|
||||
factions.title.color: true
|
||||
factions.unclaim: true
|
||||
factions.unclaimall: true
|
||||
factions.unsethome: true
|
||||
factions.version: true
|
||||
# -------------------------------------------- #
|
||||
@ -152,9 +156,6 @@ permissions:
|
||||
factions.access.faction: true
|
||||
factions.access.player: true
|
||||
factions.access.view: true
|
||||
factions.autoclaim: true
|
||||
factions.claim: true
|
||||
factions.claim.radius: true
|
||||
factions.create: true
|
||||
factions.demote: true
|
||||
factions.description: true
|
||||
@ -186,12 +187,17 @@ permissions:
|
||||
factions.relation: true
|
||||
factions.seechunk: true
|
||||
factions.seechunkold: true
|
||||
factions.set: true
|
||||
factions.set.one: true
|
||||
factions.set.auto: true
|
||||
factions.set.fill: true
|
||||
factions.set.square: true
|
||||
factions.set.circle: true
|
||||
factions.set.transfer: true
|
||||
factions.sethome: true
|
||||
factions.name: true
|
||||
factions.title: true
|
||||
factions.title.color: true
|
||||
factions.unclaim: true
|
||||
factions.unclaimall: true
|
||||
factions.unsethome: true
|
||||
factions.version: true
|
||||
factions.kit.default:
|
||||
|
Loading…
Reference in New Issue
Block a user