New command unclaim all

This commit is contained in:
Olof Larsson 2011-04-08 16:22:00 +02:00
parent 6e00b16f38
commit e4d798e9d6
5 changed files with 46 additions and 2 deletions

View File

@ -1,5 +1,5 @@
name: Factions
version: 1.1.6
version: 1.1.7
main: com.bukkit.mcteam.factions.Factions
commands:
f:

View File

@ -55,6 +55,16 @@ public class Board {
public static void removeAt(FLocation flocation) {
flocationIds.remove(flocation);
}
public static void unclaimAll(int factionId) {
Iterator<Entry<FLocation, Integer>> iter = flocationIds.entrySet().iterator();
while (iter.hasNext()) {
Entry<FLocation, Integer> 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?

View File

@ -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!

View File

@ -76,9 +76,9 @@ public class FCommandHelp extends FBaseCommand {
helpPages.add(pageLines);
pageLines = new ArrayList<String>();
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() );

View File

@ -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.");
}
}