package com.massivecraft.factions.cmd; import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.FFlag; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Rel; public abstract class FRelationCommand extends FCommand { public Rel targetRelation; public FRelationCommand() { super(); this.requiredArgs.add("faction tag"); //this.optionalArgs.put("player name", "you"); this.permission = Permission.RELATION.node; this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; senderMustBeOfficer = true; senderMustBeLeader = false; } @Override public void perform() { Faction them = this.argAsFaction(0); if (them == null) return; /*if ( ! them.isNormal()) { msg("Nope! You can't."); return; }*/ if (them == myFaction) { msg("Nope! You can't declare a relation to yourself :)"); return; } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay if ( ! payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish")) return; myFaction.setRelationWish(them, targetRelation); Rel currentRelation = myFaction.getRelationTo(them, true); if (targetRelation == currentRelation) { them.msg("%s is now %s.", myFaction.describeTo(them, true), targetRelation.getDescFactionOne()); myFaction.msg("%s is now %s.", them.describeTo(myFaction, true), targetRelation.getDescFactionOne()); } else { them.msg("%s wishes to be %s.", myFaction.describeTo(them, true), targetRelation.getColor()+targetRelation.getDescFactionOne()); them.msg("Type /"+Conf.baseCommandAliases.get(0)+" "+targetRelation+" "+myFaction.getTag()+" to accept."); myFaction.msg("%s were informed that you wish to be %s.", them.describeTo(myFaction, true), targetRelation.getColor()+targetRelation.getDescFactionOne()); } // TODO: The ally case should work!! if ( targetRelation != Rel.TRUCE && them.getFlag(FFlag.PEACEFUL)) { them.msg("This will have no effect while your faction is peaceful."); myFaction.msg("This will have no effect while their faction is peaceful."); } if ( targetRelation != Rel.TRUCE && myFaction.getFlag(FFlag.PEACEFUL)) { them.msg("This will have no effect while their faction is peaceful."); myFaction.msg("This will have no effect while your faction is peaceful."); } SpoutFeatures.updateAppearances(myFaction, them); SpoutFeatures.updateTerritoryDisplayLoc(null); } }