2011-04-08 15:51:07 +02:00
|
|
|
package org.mcteam.factions.commands;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-04-08 15:51:07 +02:00
|
|
|
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;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
|
|
|
public class FCommandClaim extends FBaseCommand {
|
|
|
|
|
|
|
|
public FCommandClaim() {
|
2011-03-22 18:48:09 +01:00
|
|
|
aliases.add("claim");
|
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
helpDescription = "Claim the land where you are standing";
|
|
|
|
}
|
|
|
|
|
|
|
|
public void perform() {
|
|
|
|
if ( ! assertHasFaction()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-08 17:16:43 +02:00
|
|
|
if( isLocked() ) {
|
|
|
|
sendLockMessage();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-29 23:28:29 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
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;
|
|
|
|
}
|
2011-03-23 17:39:56 +01:00
|
|
|
|
|
|
|
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
|
2011-03-22 15:45:41 +01:00
|
|
|
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;
|
|
|
|
}
|
2011-03-23 17:39:56 +01:00
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|