Allow naming of chunks
This commit is contained in:
@@ -46,6 +46,7 @@ public class CmdFactions extends FactionsCommand
|
||||
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
|
||||
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
|
||||
public CmdFactionsAccess cmdFactionsAccess = new CmdFactionsAccess();
|
||||
public CmdFactionsChunkname cmdFactionsChunkname = new CmdFactionsChunkname();
|
||||
public CmdFactionsRelation cmdFactionsRelation = new CmdFactionsRelation();
|
||||
public CmdFactionsRelationOld cmdFactionsRelationOldAlly = new CmdFactionsRelationOld("ally");
|
||||
public CmdFactionsRelationOld cmdFactionsRelationOldTruce = new CmdFactionsRelationOld("truce");
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.massivecraft.factions.entity.MPerm.MPermable;
|
||||
import com.massivecraft.factions.util.AsciiMap;
|
||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -59,7 +58,7 @@ public abstract class CmdFactionsAccessAbstract extends FactionsCommand
|
||||
|
||||
public void sendAccessInfo()
|
||||
{
|
||||
String chunkDesc = AsciiMap.showChunkCoords(chunk) ? " at " + chunk.toString(PSFormatHumanSpace.get()) : "";
|
||||
String chunkDesc = AsciiMap.getChunkDescWithName(chunk, ta);
|
||||
Object title = "Access" + chunkDesc;
|
||||
title = Txt.titleize(title);
|
||||
message(title);
|
||||
@@ -80,7 +79,7 @@ public abstract class CmdFactionsAccessAbstract extends FactionsCommand
|
||||
Faction faction = ta.getHostFaction();
|
||||
|
||||
|
||||
String chunkDesc = AsciiMap.showChunkCoords(chunk) ? " at " + chunk.toString(PSFormatHumanSpace.get()) : "";
|
||||
String chunkDesc = AsciiMap.getChunkDescWithName(chunk, ta);
|
||||
String grantedDenied = granted ? "granted" : "denied";
|
||||
String mpermableDesc = mpermable.getDisplayName(msender);
|
||||
|
||||
|
||||
81
src/com/massivecraft/factions/cmd/CmdFactionsChunkname.java
Normal file
81
src/com/massivecraft/factions/cmd/CmdFactionsChunkname.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.TerritoryAccess;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.util.AsciiMap;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
||||
import com.massivecraft.massivecore.command.type.TypeNullable;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CmdFactionsChunkname extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsChunkname()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeNullable.get(TypeString.get()), "name", "read");
|
||||
|
||||
this.addRequirements(RequirementIsPlayer.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
||||
TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(chunk);
|
||||
|
||||
if (!this.argIsSet(0))
|
||||
{
|
||||
String name = ta.getChunkName();
|
||||
if (name == null)
|
||||
{
|
||||
msg("<i>This chunk has no name.");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("<i>This chunk is called <h>%s<i>.", name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// MPerm
|
||||
if (!MPerm.getPermTerritory().has(msender, msenderFaction, true)) return;
|
||||
|
||||
// Args
|
||||
String target = this.readArg();
|
||||
|
||||
target = target.trim();
|
||||
target = Txt.parse(target);
|
||||
|
||||
String old = ta.getChunkName();
|
||||
|
||||
// NoChange
|
||||
if (MUtil.equals(old, target))
|
||||
{
|
||||
if (old == null)
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>This chunk already has no name.");
|
||||
}
|
||||
throw new MassiveException().addMsg("<b>The name for this chunk is already <h>%s<b>.", old);
|
||||
}
|
||||
|
||||
ta = ta.withChunkName(target);
|
||||
BoardColl.get().setTerritoryAccessAt(chunk, ta);
|
||||
|
||||
String chunkDesc = AsciiMap.getChunkDesc(chunk);
|
||||
msg("<i>The chunk name%s<i> is now %s.", chunkDesc, target);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user