2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd ;
2011-03-22 15:45:41 +01:00
2013-04-09 13:24:55 +02:00
import com.massivecraft.factions.FFlag ;
2013-04-09 12:56:29 +02:00
import com.massivecraft.factions.Perm ;
2013-04-09 13:24:55 +02:00
import com.massivecraft.factions.Rel ;
2013-04-16 11:05:49 +02:00
import com.massivecraft.factions.cmd.arg.ARFaction ;
2013-04-25 13:25:15 +02:00
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled ;
2013-04-25 13:53:22 +02:00
import com.massivecraft.factions.cmd.req.ReqHasFaction ;
2013-04-16 12:04:12 +02:00
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast ;
2013-04-22 09:37:53 +02:00
import com.massivecraft.factions.entity.Faction ;
2013-11-11 09:31:04 +01:00
import com.massivecraft.factions.entity.MConf ;
2013-04-19 12:27:39 +02:00
import com.massivecraft.factions.event.FactionsEventRelationChange ;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.cmd.req.ReqHasPerm ;
2011-03-22 15:45:41 +01:00
2013-04-10 13:12:22 +02:00
public abstract class CmdFactionsRelationAbstract extends FCommand
2011-10-09 18:35:39 +02:00
{
2011-10-23 17:30:41 +02:00
public Rel targetRelation ;
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2011-03-22 15:45:41 +01:00
2013-04-10 13:12:22 +02:00
public CmdFactionsRelationAbstract ( )
2011-10-09 18:35:39 +02:00
{
2013-11-11 09:31:04 +01:00
// Aliases
2013-04-26 10:32:02 +02:00
this . addRequiredArg ( " faction " ) ;
2013-11-11 09:31:04 +01:00
// Requirements
2013-04-25 13:25:15 +02:00
this . addRequirements ( ReqFactionsEnabled . get ( ) ) ;
2013-04-16 10:11:59 +02:00
this . addRequirements ( ReqHasPerm . get ( Perm . RELATION . node ) ) ;
2013-04-25 13:53:22 +02:00
this . addRequirements ( ReqHasFaction . get ( ) ) ;
2013-04-16 12:04:12 +02:00
this . addRequirements ( ReqRoleIsAtLeast . get ( Rel . OFFICER ) ) ;
2011-03-22 15:45:41 +01:00
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
2011-03-22 15:45:41 +01:00
2011-10-09 18:35:39 +02:00
@Override
public void perform ( )
{
2013-04-19 12:27:39 +02:00
// Args
2013-04-22 13:03:21 +02:00
Faction otherFaction = this . arg ( 0 , ARFaction . get ( sender ) ) ;
2013-04-19 12:27:39 +02:00
if ( otherFaction = = null ) return ;
Rel newRelation = targetRelation ;
2011-03-22 15:45:41 +01:00
2011-10-24 02:33:30 +02:00
/ * 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. " ) ;
2011-03-22 15:45:41 +01:00
return ;
2011-10-24 02:33:30 +02:00
} * /
2011-03-22 15:45:41 +01:00
2013-04-19 12:27:39 +02:00
// Verify
2013-04-25 07:29:19 +02:00
if ( otherFaction = = usenderFaction )
2011-10-09 18:35:39 +02:00
{
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
2013-04-25 07:29:19 +02:00
if ( usenderFaction . getRelationWish ( otherFaction ) = = newRelation )
2012-04-06 20:27:23 +02:00
{
2013-04-24 19:01:17 +02:00
msg ( " <b>You already have that relation wish set with %s. " , otherFaction . getName ( ) ) ;
2012-04-06 20:27:23 +02:00
return ;
}
2013-04-19 12:27:39 +02:00
// Event
2013-04-25 07:29:19 +02:00
FactionsEventRelationChange event = new FactionsEventRelationChange ( sender , usenderFaction , otherFaction , newRelation ) ;
2013-04-19 12:27:39 +02:00
event . run ( ) ;
if ( event . isCancelled ( ) ) return ;
newRelation = event . getNewRelation ( ) ;
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
2012-03-09 23:09:33 +01:00
// try to set the new relation
2013-04-25 07:29:19 +02:00
usenderFaction . setRelationWish ( otherFaction , newRelation ) ;
Rel currentRelation = usenderFaction . getRelationTo ( otherFaction , true ) ;
2012-03-09 23:09:33 +01:00
// if the relation change was successful
2013-04-19 12:27:39 +02:00
if ( newRelation = = currentRelation )
2011-10-09 18:35:39 +02:00
{
2013-04-25 07:29:19 +02:00
otherFaction . msg ( " %s<i> is now %s. " , usenderFaction . describeTo ( otherFaction , true ) , newRelation . getDescFactionOne ( ) ) ;
usenderFaction . msg ( " %s<i> is now %s. " , otherFaction . describeTo ( usenderFaction , true ) , newRelation . getDescFactionOne ( ) ) ;
2011-03-22 15:45:41 +01:00
}
2012-03-09 23:09:33 +01:00
// inform the other faction of your request
2011-10-09 18:35:39 +02:00
else
{
2013-04-25 07:29:19 +02:00
otherFaction . msg ( " %s<i> wishes to be %s. " , usenderFaction . describeTo ( otherFaction , true ) , newRelation . getColor ( ) + newRelation . getDescFactionOne ( ) ) ;
2013-11-11 09:31:04 +01:00
otherFaction . msg ( " <i>Type <c>/ " + MConf . get ( ) . aliasesF . get ( 0 ) + " " + newRelation + " " + usenderFaction . getName ( ) + " <i> to accept. " ) ;
2013-04-25 07:29:19 +02:00
usenderFaction . msg ( " %s<i> were informed that you wish to be %s<i>. " , otherFaction . describeTo ( usenderFaction , true ) , newRelation . getColor ( ) + newRelation . getDescFactionOne ( ) ) ;
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!!
2012-03-09 23:09:33 +01:00
// * this might have to be bumped up to make that happen, & allow ALLY,NEUTRAL only
2013-04-19 12:27:39 +02:00
if ( newRelation ! = Rel . TRUCE & & otherFaction . getFlag ( FFlag . PEACEFUL ) )
2011-10-09 18:35:39 +02:00
{
2013-04-19 12:27:39 +02:00
otherFaction . msg ( " <i>This will have no effect while your faction is peaceful. " ) ;
2013-04-25 07:29:19 +02:00
usenderFaction . msg ( " <i>This will have no effect while their faction is peaceful. " ) ;
2011-10-09 18:35:39 +02:00
}
2013-04-25 07:29:19 +02:00
if ( newRelation ! = Rel . TRUCE & & usenderFaction . getFlag ( FFlag . PEACEFUL ) )
2011-10-09 18:35:39 +02:00
{
2013-04-19 12:27:39 +02:00
otherFaction . msg ( " <i>This will have no effect while their faction is peaceful. " ) ;
2013-04-25 07:29:19 +02:00
usenderFaction . msg ( " <i>This will have no effect while your faction is peaceful. " ) ;
2011-08-05 10:50:47 +02:00
}
2011-03-22 15:45:41 +01:00
}
2013-11-11 09:31:04 +01:00
2011-03-22 15:45:41 +01:00
}