2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
import com.massivecraft.factions.*;
|
2012-03-13 13:58:51 +01:00
|
|
|
import com.massivecraft.factions.event.LandUnclaimEvent;
|
2011-10-05 12:13:54 +02:00
|
|
|
import com.massivecraft.factions.integration.Econ;
|
2011-10-09 18:35:39 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.struct.Role;
|
2014-04-04 20:55:21 +02:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
|
|
|
public class CmdUnclaim extends FCommand {
|
|
|
|
public CmdUnclaim() {
|
|
|
|
this.aliases.add("unclaim");
|
|
|
|
this.aliases.add("declaim");
|
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
|
|
|
//this.optionalArgs.put("", "");
|
|
|
|
|
|
|
|
this.permission = Permission.UNCLAIM.node;
|
|
|
|
this.disableOnLock = true;
|
|
|
|
|
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeAdmin = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
|
|
|
FLocation flocation = new FLocation(fme);
|
|
|
|
Faction otherFaction = Board.getFactionAt(flocation);
|
|
|
|
|
|
|
|
if (otherFaction.isSafeZone()) {
|
|
|
|
if (Permission.MANAGE_SAFE_ZONE.has(sender)) {
|
|
|
|
Board.removeAt(flocation);
|
|
|
|
msg("<i>Safe zone was unclaimed.");
|
|
|
|
|
2014-07-01 21:49:42 +02:00
|
|
|
if (Conf.logLandUnclaims) {
|
2014-04-04 20:55:21 +02:00
|
|
|
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
2014-07-01 21:49:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-04-04 20:55:21 +02:00
|
|
|
msg("<b>This is a safe zone. You lack permissions to unclaim.");
|
|
|
|
}
|
|
|
|
return;
|
2014-07-01 21:49:42 +02:00
|
|
|
}
|
|
|
|
else if (otherFaction.isWarZone()) {
|
2014-04-04 20:55:21 +02:00
|
|
|
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
|
|
|
|
Board.removeAt(flocation);
|
|
|
|
msg("<i>War zone was unclaimed.");
|
|
|
|
|
2014-07-01 21:49:42 +02:00
|
|
|
if (Conf.logLandUnclaims) {
|
2014-04-04 20:55:21 +02:00
|
|
|
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
2014-07-01 21:49:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-04-04 20:55:21 +02:00
|
|
|
msg("<b>This is a war zone. You lack permissions to unclaim.");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fme.isAdminBypassing()) {
|
|
|
|
Board.removeAt(flocation);
|
|
|
|
|
|
|
|
otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true));
|
|
|
|
msg("<i>You unclaimed this land.");
|
|
|
|
|
2014-07-01 21:49:42 +02:00
|
|
|
if (Conf.logLandUnclaims) {
|
2014-04-04 20:55:21 +02:00
|
|
|
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
2014-07-01 21:49:42 +02:00
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!assertHasFaction()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!assertMinRole(Role.MODERATOR)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (myFaction != otherFaction) {
|
|
|
|
msg("<b>You don't own this land.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
|
|
|
|
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
2014-07-01 21:49:42 +02:00
|
|
|
if (unclaimEvent.isCancelled()) { return; }
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
if (Econ.shouldBeUsed()) {
|
|
|
|
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
|
|
|
|
|
|
|
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
2014-07-01 21:49:42 +02:00
|
|
|
if (!Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!Econ.modifyMoney(fme, refund, "to unclaim this land", "for unclaiming this land")) { return; }
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Board.removeAt(flocation);
|
|
|
|
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
|
|
|
|
2014-07-01 21:49:42 +02:00
|
|
|
if (Conf.logLandUnclaims) {
|
2014-04-04 20:55:21 +02:00
|
|
|
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
2014-07-01 21:49:42 +02:00
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2011-03-22 15:45:41 +01:00
|
|
|
|
|
|
|
}
|