2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
2011-07-18 22:06:02 +02:00
|
|
|
|
|
|
|
import com.massivecraft.factions.Conf;
|
|
|
|
import com.massivecraft.factions.Faction;
|
2011-10-05 12:13:54 +02:00
|
|
|
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-03-22 15:45:41 +01:00
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
public abstract class FRelationCommand extends FCommand
|
|
|
|
{
|
|
|
|
public Relation targetRelation;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
public FRelationCommand()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.requiredArgs.add("faction tag");
|
|
|
|
//this.optionalArgs.put("player name", "you");
|
|
|
|
|
2011-10-09 21:57:43 +02:00
|
|
|
this.permission = Permission.RELATION.node;
|
|
|
|
this.disableOnLock = true;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = true;
|
|
|
|
senderMustBeAdmin = false;
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
|
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;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
if ( ! them.isNormal())
|
|
|
|
{
|
2011-10-10 13:40:24 +02:00
|
|
|
msg("<b>Nope! You can't.");
|
2011-03-22 15:45:41 +01:00
|
|
|
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 :)");
|
2011-03-22 15:45:41 +01:00
|
|
|
return;
|
|
|
|
}
|
Added basic support for iConomy, where most Factions commands can be made to cost (or give) money. For claiming land, there are some extra features. Each additional land claimed by default costs more than the last, with the multiplier being configurable. For example, the first claim might cost $30, the 2nd $45, the third $60, and so forth. When land is claimed from a weakened faction, there is a configurable bonus amount of money deducted from the cost of claiming the land, as an incentive; this number can be changed to a negative value to instead make it cost more to claim such land. When land is unclaimed, a configurable percentage of the cost of claiming the land can be refunded (defaults to 70% of the cost). The total value of a faction's claimed land is now shown in the info given by /f who [faction tag], along with the depreciated (refund) value.
2011-08-02 01:05:01 +02:00
|
|
|
|
|
|
|
// 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;
|
Added basic support for iConomy, where most Factions commands can be made to cost (or give) money. For claiming land, there are some extra features. Each additional land claimed by default costs more than the last, with the multiplier being configurable. For example, the first claim might cost $30, the 2nd $45, the third $60, and so forth. When land is claimed from a weakened faction, there is a configurable bonus amount of money deducted from the cost of claiming the land, as an incentive; this number can be changed to a negative value to instead make it cost more to claim such land. When land is unclaimed, a configurable percentage of the cost of claiming the land can be refunded (defaults to 70% of the cost). The total value of a faction's claimed land is now shown in the info given by /f who [faction tag], along with the depreciated (refund) value.
2011-08-02 01:05:01 +02:00
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
myFaction.setRelationWish(them, targetRelation);
|
2011-10-12 17:25:01 +02:00
|
|
|
Relation currentRelation = myFaction.getRelationTo(them, true);
|
2011-03-22 15:45:41 +01:00
|
|
|
ChatColor currentRelationColor = currentRelation.getColor();
|
2011-10-09 18:35:39 +02:00
|
|
|
if (targetRelation.value == currentRelation.value)
|
|
|
|
{
|
2011-10-10 13:40:24 +02:00
|
|
|
them.msg("<i>Your faction is now "+currentRelationColor+targetRelation.toString()+"<i> to "+currentRelationColor+myFaction.getTag());
|
|
|
|
myFaction.msg("<i>Your faction is now "+currentRelationColor+targetRelation.toString()+"<i> to "+currentRelationColor+them.getTag());
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
2011-10-09 18:35:39 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-10 13:40:24 +02:00
|
|
|
them.msg(currentRelationColor+myFaction.getTag()+"<i> wishes to be your "+targetRelation.getColor()+targetRelation.toString());
|
|
|
|
them.msg("<i>Type <c>/"+Conf.baseCommandAliases.get(0)+" "+targetRelation+" "+myFaction.getTag()+"<i> to accept.");
|
|
|
|
myFaction.msg(currentRelationColor+them.getTag()+"<i> were informed that you wish to be "+targetRelation.getColor()+targetRelation);
|
2011-08-05 10:50:47 +02:00
|
|
|
}
|
2011-10-09 18:35:39 +02:00
|
|
|
|
|
|
|
if ( ! targetRelation.isNeutral() && them.isPeaceful())
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! targetRelation.isNeutral() && myFaction.isPeaceful())
|
|
|
|
{
|
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.");
|
2011-08-05 10:50:47 +02:00
|
|
|
}
|
2011-08-20 03:36:23 +02:00
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
SpoutFeatures.updateAppearances(myFaction, them);
|
2011-10-23 16:03:28 +02:00
|
|
|
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
}
|