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-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2014-04-04 20:55:21 +02:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
|
|
|
public class CmdUnclaim extends FCommand {
|
2014-08-05 17:17:27 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public CmdUnclaim() {
|
2014-07-01 22:10:18 +02:00
|
|
|
this.aliases.add("unclaim");
|
|
|
|
this.aliases.add("declaim");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
|
|
|
//this.optionalArgs.put("", "");
|
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.permission = Permission.UNCLAIM.node;
|
|
|
|
this.disableOnLock = true;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeAdmin = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
2014-07-01 22:10:18 +02:00
|
|
|
FLocation flocation = new FLocation(fme);
|
2014-10-19 07:37:25 +02:00
|
|
|
Faction otherFaction = Board.getInstance().getFactionAt(flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
if (otherFaction.isSafeZone()) {
|
|
|
|
if (Permission.MANAGE_SAFE_ZONE.has(sender)) {
|
2014-10-19 07:37:25 +02:00
|
|
|
Board.getInstance().removeAt(flocation);
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_UNCLAIM_SAFEZONE_SUCCESS);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 21:49:42 +02:00
|
|
|
if (Conf.logLandUnclaims) {
|
2014-12-11 17:05:04 +01:00
|
|
|
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), flocation.getCoordString(), otherFaction.getTag()));
|
2014-07-01 21:49:42 +02:00
|
|
|
}
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_UNCLAIM_SAFEZONE_NOPERM);
|
2014-07-01 22:10:18 +02:00
|
|
|
}
|
|
|
|
return;
|
2014-07-01 21:52:40 +02:00
|
|
|
} else if (otherFaction.isWarZone()) {
|
2014-04-04 20:55:21 +02:00
|
|
|
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
|
2014-10-19 07:37:25 +02:00
|
|
|
Board.getInstance().removeAt(flocation);
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_UNCLAIM_WARZONE_SUCCESS);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 21:49:42 +02:00
|
|
|
if (Conf.logLandUnclaims) {
|
2014-12-11 17:05:04 +01:00
|
|
|
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), flocation.getCoordString(), otherFaction.getTag()));
|
2014-07-01 21:49:42 +02:00
|
|
|
}
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_UNCLAIM_WARZONE_NOPERM);
|
2014-07-01 22:10:18 +02:00
|
|
|
}
|
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fme.isAdminBypassing()) {
|
2014-10-19 07:37:25 +02:00
|
|
|
Board.getInstance().removeAt(flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-12-08 00:12:52 +01:00
|
|
|
otherFaction.msg(TL.COMMAND_UNCLAIM_UNCLAIMED, fme.describeTo(otherFaction, true));
|
|
|
|
msg(TL.COMMAND_UNCLAIM_UNCLAIMS);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 21:49:42 +02:00
|
|
|
if (Conf.logLandUnclaims) {
|
2014-12-11 17:05:04 +01:00
|
|
|
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), flocation.getCoordString(), 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) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_UNCLAIM_WRONGFACTION);
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
|
2014-07-01 22:10:18 +02:00
|
|
|
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
|
|
|
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-12-08 00:12:52 +01:00
|
|
|
if (!Econ.modifyMoney(myFaction, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) {
|
2014-07-01 21:49:42 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2014-12-08 00:12:52 +01:00
|
|
|
if (!Econ.modifyMoney(fme, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) {
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
Board.getInstance().removeAt(flocation);
|
2014-12-08 00:12:52 +01:00
|
|
|
myFaction.msg(TL.COMMAND_UNCLAIM_FACTIONUNCLAIMED, fme.describeTo(myFaction, true));
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 21:49:42 +02:00
|
|
|
if (Conf.logLandUnclaims) {
|
2014-12-11 17:05:04 +01:00
|
|
|
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), flocation.getCoordString(), 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
|
|
|
|
|
|
|
}
|