package com.massivecraft.factions.commands; import com.massivecraft.factions.Board; import com.massivecraft.factions.Conf; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; public class FCommandUnclaim extends FCommand { public FCommandUnclaim() { this.aliases.add("unclaim"); this.aliases.add("declaim"); //this.requiredArgs.add(""); //this.optionalArgs.put("", ""); this.permission = Permission.COMMAND_UNCLAIM.node; senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; } @Override public void perform() { if( isLocked() ) { sendLockMessage(); return; } FLocation flocation = new FLocation(fme); Faction otherFaction = Board.getFactionAt(flocation); if (otherFaction.isSafeZone()) { if (Permission.MANAGE_SAFE_ZONE.has(sender)) { Board.removeAt(flocation); sendMessageParsed("Safe zone was unclaimed."); } else { sendMessageParsed("This is a safe zone. You lack permissions to unclaim."); } return; } else if (otherFaction.isWarZone()) { if (Permission.MANAGE_WAR_ZONE.has(sender)) { Board.removeAt(flocation); sendMessageParsed("War zone was unclaimed."); } else { sendMessageParsed("This is a war zone. You lack permissions to unclaim."); } return; } if (fme.isAdminBypassing()) { Board.removeAt(flocation); otherFaction.sendMessageParsed("%s unclaimed some of your land.", fme.getNameAndRelevant(otherFaction)); sendMessageParsed("You unclaimed this land."); return; } if ( ! assertHasFaction()) { return; } if ( ! assertMinRole(Role.MODERATOR)) { return; } if ( myFaction != otherFaction) { sendMessageParsed("You don't own this land."); return; } String moneyBack = ""; if (Econ.enabled()) { double refund = Econ.calculateClaimRefund(myFaction.getLandRounded()); // a real refund if (refund > 0.0) { if(Conf.bankFactionPaysLandCosts) { Faction faction = myFaction; faction.addMoney(refund); moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+"."; } else { Econ.addMoney(fme.getName(), refund); moneyBack = " They received a refund of "+Econ.moneyString(refund)+"."; } } // wait, you're charging people to unclaim land? outrageous else if (refund < 0.0) { if(Conf.bankFactionPaysLandCosts) { Faction faction = myFaction; if(!faction.removeMoney(-refund)) { sendMessageParsed("Unclaiming this land will cost %s which your faction can't currently afford.", Econ.moneyString(-refund)); return; } moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+"."; } else { if (!Econ.deductMoney(fme.getName(), -refund)) { sendMessageParsed("Unclaiming this land will cost %s which you can't currently afford.", Econ.moneyString(-refund)); return; } moneyBack = " It cost them "+Econ.moneyString(refund)+"."; } } // no refund else { moneyBack = ""; } } Board.removeAt(flocation); myFaction.sendMessageParsed("%s unclaimed some land."+moneyBack, fme.getNameAndRelevant(myFaction)); } }