From e4d798e9d6e622a2f7314c2c0eec8bbf655a01ba Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 8 Apr 2011 16:22:00 +0200 Subject: [PATCH] New command unclaim all --- plugin.yml | 2 +- src/org/mcteam/factions/Board.java | 10 ++++++ src/org/mcteam/factions/Factions.java | 2 ++ .../factions/commands/FCommandHelp.java | 2 +- .../factions/commands/FCommandUnclaimall.java | 32 +++++++++++++++++++ 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/org/mcteam/factions/commands/FCommandUnclaimall.java diff --git a/plugin.yml b/plugin.yml index 04f2c2e5..513e0671 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,5 @@ name: Factions -version: 1.1.6 +version: 1.1.7 main: com.bukkit.mcteam.factions.Factions commands: f: diff --git a/src/org/mcteam/factions/Board.java b/src/org/mcteam/factions/Board.java index 6c4cad00..9fbf044d 100644 --- a/src/org/mcteam/factions/Board.java +++ b/src/org/mcteam/factions/Board.java @@ -55,6 +55,16 @@ public class Board { public static void removeAt(FLocation flocation) { flocationIds.remove(flocation); } + + public static void unclaimAll(int factionId) { + Iterator> iter = flocationIds.entrySet().iterator(); + while (iter.hasNext()) { + Entry entry = iter.next(); + if (entry.getValue().equals(factionId)) { + iter.remove(); + } + } + } // Is this coord NOT completely surrounded by coords claimed by the same faction? // Simpler: Is there any nearby coord with a faction other than the faction here? diff --git a/src/org/mcteam/factions/Factions.java b/src/org/mcteam/factions/Factions.java index 9906a7b9..7553d417 100644 --- a/src/org/mcteam/factions/Factions.java +++ b/src/org/mcteam/factions/Factions.java @@ -45,6 +45,7 @@ import org.mcteam.factions.commands.FCommandShow; import org.mcteam.factions.commands.FCommandTag; import org.mcteam.factions.commands.FCommandTitle; import org.mcteam.factions.commands.FCommandUnclaim; +import org.mcteam.factions.commands.FCommandUnclaimall; import org.mcteam.factions.commands.FCommandVersion; import org.mcteam.factions.gson.Gson; import org.mcteam.factions.gson.GsonBuilder; @@ -120,6 +121,7 @@ public class Factions extends JavaPlugin { commands.add(new FCommandTag()); commands.add(new FCommandTitle()); commands.add(new FCommandUnclaim()); + commands.add(new FCommandUnclaimall()); commands.add(new FCommandVersion()); // Ensure basefolder exists! diff --git a/src/org/mcteam/factions/commands/FCommandHelp.java b/src/org/mcteam/factions/commands/FCommandHelp.java index 10510d06..45370229 100644 --- a/src/org/mcteam/factions/commands/FCommandHelp.java +++ b/src/org/mcteam/factions/commands/FCommandHelp.java @@ -76,9 +76,9 @@ public class FCommandHelp extends FBaseCommand { helpPages.add(pageLines); pageLines = new ArrayList(); - pageLines.add( "Faction can claim land that will be protected." ); pageLines.add( new FCommandClaim().getUseageTemplate() ); pageLines.add( new FCommandUnclaim().getUseageTemplate() ); + pageLines.add( new FCommandUnclaimall().getUseageTemplate() ); pageLines.add( new FCommandTag().getUseageTemplate() ); pageLines.add( new FCommandKick().getUseageTemplate() ); pageLines.add( new FCommandMod().getUseageTemplate() ); diff --git a/src/org/mcteam/factions/commands/FCommandUnclaimall.java b/src/org/mcteam/factions/commands/FCommandUnclaimall.java new file mode 100644 index 00000000..8162dc9f --- /dev/null +++ b/src/org/mcteam/factions/commands/FCommandUnclaimall.java @@ -0,0 +1,32 @@ +package org.mcteam.factions.commands; + +import org.mcteam.factions.Board; +import org.mcteam.factions.Conf; +import org.mcteam.factions.Faction; +import org.mcteam.factions.struct.Role; + +public class FCommandUnclaimall extends FBaseCommand { + + public FCommandUnclaimall() { + aliases.add("unclaimall"); + aliases.add("declaimall"); + + helpDescription = "Unclaim all of your factions land"; + } + + public void perform() { + if ( ! assertHasFaction()) { + return; + } + + if ( ! assertMinRole(Role.MODERATOR)) { + return; + } + + Faction myFaction = me.getFaction(); + + Board.unclaimAll(myFaction.getId()); + myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed ALL of your factions land."); + } + +}