Factions/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java

99 lines
3.4 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
import org.bukkit.Bukkit;
2013-04-09 13:15:25 +02:00
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FFlag;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.event.FactionRelationEvent;
import com.massivecraft.factions.integration.SpoutFeatures;
2013-04-16 10:11:59 +02:00
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
2013-04-10 13:12:22 +02:00
public abstract class CmdFactionsRelationAbstract extends FCommand
2011-10-09 18:35:39 +02:00
{
public Rel targetRelation;
2013-04-10 13:12:22 +02:00
public CmdFactionsRelationAbstract()
2011-10-09 18:35:39 +02:00
{
super();
2013-04-16 10:11:59 +02:00
this.addAliases("faction");
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
2011-10-23 17:55:53 +02:00
senderMustBeOfficer = true;
}
2011-10-09 18:35:39 +02:00
@Override
public void perform()
{
Faction them = this.argAsFaction(0);
2011-10-10 01:21:05 +02:00
if (them == null) return;
/*if ( ! them.isNormal())
2011-10-09 18:35:39 +02:00
{
2011-10-10 13:40:24 +02:00
msg("<b>Nope! You can't.");
return;
}*/
2011-10-09 18:35:39 +02:00
if (them == myFaction)
{
2011-10-10 13:40:24 +02:00
msg("<b>Nope! You can't declare a relation to yourself :)");
return;
}
if (myFaction.getRelationWish(them) == targetRelation)
{
msg("<b>You already have that relation wish set with %s.", them.getTag());
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
2011-10-12 18:48:47 +02:00
if ( ! payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish")) return;
// try to set the new relation
Rel oldRelation = myFaction.getRelationTo(them, true);
2011-10-09 18:35:39 +02:00
myFaction.setRelationWish(them, targetRelation);
Rel currentRelation = myFaction.getRelationTo(them, true);
// if the relation change was successful
2011-10-24 11:07:06 +02:00
if (targetRelation == currentRelation)
2011-10-09 18:35:39 +02:00
{
2012-03-13 13:47:54 +01:00
// trigger the faction relation event
FactionRelationEvent relationEvent = new FactionRelationEvent(myFaction, them, oldRelation, currentRelation);
Bukkit.getServer().getPluginManager().callEvent(relationEvent);
2011-10-24 11:07:06 +02:00
them.msg("%s<i> is now %s.", myFaction.describeTo(them, true), targetRelation.getDescFactionOne());
myFaction.msg("%s<i> is now %s.", them.describeTo(myFaction, true), targetRelation.getDescFactionOne());
}
// inform the other faction of your request
2011-10-09 18:35:39 +02:00
else
{
2011-10-24 11:07:06 +02:00
them.msg("%s<i> wishes to be %s.", myFaction.describeTo(them, true), targetRelation.getColor()+targetRelation.getDescFactionOne());
2013-04-09 13:15:25 +02:00
them.msg("<i>Type <c>/"+ConfServer.baseCommandAliases.get(0)+" "+targetRelation+" "+myFaction.getTag()+"<i> to accept.");
2011-10-24 11:07:06 +02:00
myFaction.msg("%s<i> were informed that you wish to be %s<i>.", them.describeTo(myFaction, true), targetRelation.getColor()+targetRelation.getDescFactionOne());
New "peaceful" status for factions which can only be set by server admins/moderators. Members of peaceful factions cannot deal or receive PvP damage (unless in a war zone which has friendly fire enabled), cannot claim land from another faction and likewise can't have their land claimed, and cannot be considered as ally or enemy of any other faction. Faction admins and moderators of peaceful factions can enable/disable all explosions inside their faction's territory at will. The main purpose of this is to provide a way for more peaceful players who don't want to take part in faction wars (or just want to take a break from them) to still have fun on the server. It is also meant to allow groups of players to make protected buildings, monuments, grand constructions, and so forth without having to worry about another faction destroying them. New conf.json settings: "peacefulTerritoryDisablePVP" (default true) prevents PvP damage for anyone inside a peaceful faction's territory "peacefulTerritoryDisableMonsters" (default false) provides protection against monsters spawning or attacking inside a peaceful faction's territory "peacefulMembersDisablePowerLoss" (default true) which keeps members of peaceful factions from suffering power loss when they die. New commands: /f peaceful [faction tag] - toggle the indicated faction's "peaceful" status /f noboom - enable/disable explosions inside your faction's territory; only available to faction admin and faction moderators for peaceful factions New permission nodes: factions.setPeaceful - ability to use the /f peaceful command (admins) factions.peacefulExplosionToggle - ability to use /f noboom (everyone)
2011-08-05 10:50:47 +02:00
}
2011-10-09 18:35:39 +02:00
2011-10-24 11:07:06 +02:00
// TODO: The ally case should work!!
// * this might have to be bumped up to make that happen, & allow ALLY,NEUTRAL only
2011-10-24 11:07:06 +02:00
if ( targetRelation != Rel.TRUCE && them.getFlag(FFlag.PEACEFUL))
2011-10-09 18:35:39 +02:00
{
2011-10-10 13:40:24 +02:00
them.msg("<i>This will have no effect while your faction is peaceful.");
myFaction.msg("<i>This will have no effect while their faction is peaceful.");
2011-10-09 18:35:39 +02:00
}
2011-10-24 11:07:06 +02:00
if ( targetRelation != Rel.TRUCE && myFaction.getFlag(FFlag.PEACEFUL))
2011-10-09 18:35:39 +02:00
{
2011-10-10 13:40:24 +02:00
them.msg("<i>This will have no effect while their faction is peaceful.");
myFaction.msg("<i>This will have no effect while your faction is peaceful.");
New "peaceful" status for factions which can only be set by server admins/moderators. Members of peaceful factions cannot deal or receive PvP damage (unless in a war zone which has friendly fire enabled), cannot claim land from another faction and likewise can't have their land claimed, and cannot be considered as ally or enemy of any other faction. Faction admins and moderators of peaceful factions can enable/disable all explosions inside their faction's territory at will. The main purpose of this is to provide a way for more peaceful players who don't want to take part in faction wars (or just want to take a break from them) to still have fun on the server. It is also meant to allow groups of players to make protected buildings, monuments, grand constructions, and so forth without having to worry about another faction destroying them. New conf.json settings: "peacefulTerritoryDisablePVP" (default true) prevents PvP damage for anyone inside a peaceful faction's territory "peacefulTerritoryDisableMonsters" (default false) provides protection against monsters spawning or attacking inside a peaceful faction's territory "peacefulMembersDisablePowerLoss" (default true) which keeps members of peaceful factions from suffering power loss when they die. New commands: /f peaceful [faction tag] - toggle the indicated faction's "peaceful" status /f noboom - enable/disable explosions inside your faction's territory; only available to faction admin and faction moderators for peaceful factions New permission nodes: factions.setPeaceful - ability to use the /f peaceful command (admins) factions.peacefulExplosionToggle - ability to use /f noboom (everyone)
2011-08-05 10:50:47 +02:00
}
SpoutFeatures.updateTitle(myFaction, them);
SpoutFeatures.updateTitle(them, myFaction);
SpoutFeatures.updateTerritoryDisplayLoc(null);
}
}