new autoclaim commands for faction claims, safe zone claims, and war zone claims, which claim land as you walk around

This commit is contained in:
Brettflan
2011-06-10 14:26:12 -05:00
parent 2e1d7da50f
commit 097b555466
10 changed files with 345 additions and 73 deletions

View File

@@ -0,0 +1,67 @@
package org.mcteam.factions.commands;
import org.mcteam.factions.Conf;
import org.mcteam.factions.FLocation;
import org.mcteam.factions.Faction;
import org.mcteam.factions.struct.Role;
public class FCommandAutoClaim extends FBaseCommand {
public FCommandAutoClaim() {
aliases.add("autoclaim");
optionalParameters.add("on|off");
helpDescription = "Auto-claim land as you walk around";
}
@Override
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
sendLockMessage();
return;
}
// default: toggle existing value
boolean enable = !me.autoClaimEnabled();
// if on|off is specified, use that instead
if (parameters.size() > 0)
enable = parseBool(parameters.get(0));
me.enableAutoClaim(enable);
if (!enable) {
sendMessage("Auto-claiming of land disabled.");
return;
}
Faction myFaction = me.getFaction();
FLocation flocation = new FLocation(me);
if ( ! assertMinRole(Role.MODERATOR)) {
me.enableAutoClaim(false);
return;
}
if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
sendMessage("Sorry, this world has land claiming disabled.");
me.enableAutoClaim(false);
return;
}
if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) {
sendMessage("You can't claim more land! You need more power!");
me.enableAutoClaim(false);
return;
}
sendMessage("Auto-claiming of land enabled.");
me.attemptClaim(false);
}
}

View File

@@ -0,0 +1,54 @@
package org.mcteam.factions.commands;
import org.bukkit.command.CommandSender;
import org.mcteam.factions.Board;
import org.mcteam.factions.FLocation;
import org.mcteam.factions.Faction;
import org.mcteam.factions.Factions;
public class FCommandAutoSafeclaim extends FBaseCommand {
public FCommandAutoSafeclaim() {
aliases.add("autosafe");
optionalParameters.add("on|off");
helpDescription = "Auto-claim land for the safezone";
}
@Override
public boolean hasPermission(CommandSender sender) {
return Factions.hasPermManageSafeZone(sender);
}
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage();
return;
}
boolean enable = !me.autoSafeZoneEnabled();
if (parameters.size() > 0)
enable = parseBool(parameters.get(0));
me.enableAutoSafeZone(enable);
if (!enable) {
sendMessage("Auto-claiming of safe zone disabled.");
return;
}
sendMessage("Auto-claiming of safe zone enabled.");
FLocation playerFlocation = new FLocation(me);
if (!Board.getFactionAt(playerFlocation).isSafeZone()) {
Board.setFactionAt(Faction.getSafeZone(), playerFlocation);
sendMessage("This land is now a safe zone.");
}
}
}

View File

@@ -0,0 +1,54 @@
package org.mcteam.factions.commands;
import org.bukkit.command.CommandSender;
import org.mcteam.factions.Board;
import org.mcteam.factions.FLocation;
import org.mcteam.factions.Faction;
import org.mcteam.factions.Factions;
public class FCommandAutoWarclaim extends FBaseCommand {
public FCommandAutoWarclaim() {
aliases.add("autowar");
optionalParameters.add("on|off");
helpDescription = "Auto-claim land for the warzone";
}
@Override
public boolean hasPermission(CommandSender sender) {
return Factions.hasPermManageWarZone(sender);
}
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage();
return;
}
boolean enable = !me.autoWarZoneEnabled();
if (parameters.size() > 0)
enable = parseBool(parameters.get(0));
me.enableAutoWarZone(enable);
if (!enable) {
sendMessage("Auto-claiming of war zone disabled.");
return;
}
sendMessage("Auto-claiming of war zone enabled.");
FLocation playerFlocation = new FLocation(me);
if (!Board.getFactionAt(playerFlocation).isWarZone()) {
Board.setFactionAt(Faction.getWarZone(), playerFlocation);
sendMessage("This land is now a war zone.");
}
}
}

View File

@@ -1,12 +1,5 @@
package org.mcteam.factions.commands;
import org.mcteam.factions.Board;
import org.mcteam.factions.Conf;
import org.mcteam.factions.FLocation;
import org.mcteam.factions.Faction;
import org.mcteam.factions.struct.Relation;
import org.mcteam.factions.struct.Role;
public class FCommandClaim extends FBaseCommand {
public FCommandClaim() {
@@ -25,66 +18,7 @@ public class FCommandClaim extends FBaseCommand {
return;
}
Faction myFaction = me.getFaction();
FLocation flocation = new FLocation(me);
Faction otherFaction = Board.getFactionAt(flocation);
if (myFaction == otherFaction) {
sendMessage("You already own this land.");
return;
}
if ( ! assertMinRole(Role.MODERATOR)) {
return;
}
if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
sendMessage("Sorry, this world has land claiming disabled.");
return;
}
if (otherFaction.isSafeZone()) {
sendMessage("You can not claim a Safe Zone.");
return;
}
else if (otherFaction.isWarZone()) {
sendMessage("You can not claim a War Zone.");
return;
}
if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) {
sendMessage("You can't claim more land! You need more power!");
return;
}
if (otherFaction.getRelation(me) == Relation.ALLY) {
sendMessage("You can't claim the land of your allies.");
return;
}
if (otherFaction.isNone()) {
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" claimed some new land :D");
} else { //if (otherFaction.isNormal()) {
if ( ! otherFaction.hasLandInflation()) {
// TODO more messages WARN current faction most importantly
sendMessage(me.getRelationColor(otherFaction)+otherFaction.getTag()+Conf.colorSystem+" owns this land and is strong enough to keep it.");
return;
}
if ( ! Board.isBorderLocation(flocation)) {
sendMessage("You must start claiming land at the border of the territory.");
return;
}
// ASDF claimed some of your land 450 blocks NNW of you.
// ASDf claimed some land from FACTION NAME
otherFaction.sendMessage(me.getNameAndRelevant(otherFaction)+Conf.colorSystem+" stole some of your land :O");
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" claimed some land from "+otherFaction.getTag(myFaction));
}
Board.setFactionAt(myFaction, flocation);
me.attemptClaim(true);
}
}

View File

@@ -64,9 +64,9 @@ public class FCommandHelp extends FBaseCommand {
helpPages.add(pageLines);
pageLines = new ArrayList<String>();
pageLines.add( "Create a faction using these two commands:" );
pageLines.add( new FCommandCreate().getUseageTemplate() );
pageLines.add( new FCommandDescription().getUseageTemplate() );
pageLines.add( new FCommandTag().getUseageTemplate() );
pageLines.add( "You might want to close it and use invitations:" );
pageLines.add( new FCommandOpen().getUseageTemplate() );
pageLines.add( new FCommandInvite().getUseageTemplate() );
@@ -77,9 +77,9 @@ public class FCommandHelp extends FBaseCommand {
pageLines = new ArrayList<String>();
pageLines.add( new FCommandClaim().getUseageTemplate() );
pageLines.add( new FCommandAutoClaim().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() );
pageLines.add( new FCommandAdmin().getUseageTemplate() );
@@ -127,16 +127,18 @@ public class FCommandHelp extends FBaseCommand {
pageLines.add("Finally some commands for the server admins:");
pageLines.add( new FCommandVersion().getUseageTemplate() );
pageLines.add( new FCommandSafeclaim().getUseageTemplate() );
pageLines.add( new FCommandAutoSafeclaim().getUseageTemplate() );
pageLines.add( new FCommandSafeunclaimall().getUseageTemplate() );
pageLines.add( new FCommandWarclaim().getUseageTemplate() );
pageLines.add( new FCommandAutoWarclaim().getUseageTemplate() );
pageLines.add( new FCommandWarunclaimall().getUseageTemplate() );
pageLines.add( new FCommandWorldNoClaim().getUseageTemplate() );
pageLines.add( new FCommandWorldNoPowerLoss().getUseageTemplate() );
pageLines.add( new FCommandBypass().getUseageTemplate() );
helpPages.add(pageLines);
pageLines = new ArrayList<String>();
pageLines.add("More commands for server admins:");
pageLines.add( new FCommandWorldNoClaim().getUseageTemplate() );
pageLines.add( new FCommandWorldNoPowerLoss().getUseageTemplate() );
pageLines.add( new FCommandLock().getUseageTemplate() );
pageLines.add( new FCommandReload().getUseageTemplate() );
pageLines.add( new FCommandSaveAll().getUseageTemplate() );

View File

@@ -47,7 +47,7 @@ public class FCommandSafeclaim extends FBaseCommand {
} else {
Board.setFactionAt(Faction.getSafeZone(), playerFlocation);
sendMessage("This land is now a safe zone");
sendMessage("This land is now a safe zone.");
}
}

View File

@@ -47,7 +47,7 @@ public class FCommandWarclaim extends FBaseCommand {
} else {
Board.setFactionAt(Faction.getWarZone(), playerFlocation);
sendMessage("This land is now a war zone");
sendMessage("This land is now a war zone.");
}
}