Factions3/src/com/massivecraft/factions/commands/FRelationCommand.java

86 lines
2.8 KiB
Java
Raw Normal View History

2011-07-18 22:06:02 +02:00
package com.massivecraft.factions.commands;
import org.bukkit.ChatColor;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.integration.SpoutFeatures;
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.Relation;
2011-10-09 18:35:39 +02:00
public abstract class FRelationCommand extends FCommand
{
public Relation targetRelation;
2011-10-09 18:35:39 +02:00
public FRelationCommand()
{
super();
this.requiredArgs.add("faction tag");
//this.optionalArgs.put("player name", "you");
this.permission = Permission.COMMAND_RELATION.node;
2011-10-09 18:35:39 +02:00
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
}
2011-10-09 18:35:39 +02:00
@Override
public void perform()
{
if( isLocked() )
{
sendLockMessage();
return;
}
2011-10-09 18:35:39 +02:00
Faction them = this.argAsFaction(0);
2011-10-09 18:35:39 +02:00
if ( ! them.isNormal())
{
sendMessageParsed("<b>Nope! You can't.");
return;
}
2011-10-09 18:35:39 +02:00
if (them == myFaction)
{
sendMessageParsed("<b>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
2011-10-09 18:35:39 +02:00
if ( ! payForCommand(targetRelation.getRelationCost())) return;
2011-10-09 18:35:39 +02:00
myFaction.setRelationWish(them, targetRelation);
Relation currentRelation = myFaction.getRelation(them, true);
ChatColor currentRelationColor = currentRelation.getColor();
2011-10-09 18:35:39 +02:00
if (targetRelation.value == currentRelation.value)
{
them.sendMessageParsed("<i>Your faction is now "+currentRelationColor+targetRelation.toString()+"<i> to "+currentRelationColor+myFaction.getTag());
myFaction.sendMessageParsed("<i>Your faction is now "+currentRelationColor+targetRelation.toString()+"<i> to "+currentRelationColor+them.getTag());
}
2011-10-09 18:35:39 +02:00
else
{
them.sendMessageParsed(currentRelationColor+myFaction.getTag()+"<i> wishes to be your "+targetRelation.getColor()+targetRelation.toString());
them.sendMessageParsed("<i>Type <c>/"+Conf.baseCommandAliases.get(0)+" "+targetRelation+" "+myFaction.getTag()+"<i> to accept.");
myFaction.sendMessageParsed(currentRelationColor+them.getTag()+"<i> were informed that you wish to be "+targetRelation.getColor()+targetRelation);
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
if ( ! targetRelation.isNeutral() && them.isPeaceful())
{
them.sendMessageParsed("<i>This will have no effect while your faction is peaceful.");
myFaction.sendMessageParsed("<i>This will have no effect while their faction is peaceful.");
}
if ( ! targetRelation.isNeutral() && myFaction.isPeaceful())
{
them.sendMessageParsed("<i>This will have no effect while their faction is peaceful.");
myFaction.sendMessageParsed("<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
}
2011-10-09 18:35:39 +02:00
SpoutFeatures.updateAppearances(myFaction, them);
}
}