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.FPerm;
|
2013-04-16 11:27:03 +02:00
|
|
|
import com.massivecraft.factions.Factions;
|
2013-04-09 12:56:29 +02:00
|
|
|
import com.massivecraft.factions.Perm;
|
2013-04-22 17:59:51 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARUPlayer;
|
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-22 17:59:51 +02:00
|
|
|
import com.massivecraft.factions.entity.UPlayer;
|
2014-06-04 16:47:01 +02:00
|
|
|
import com.massivecraft.factions.event.EventFactionsInvitedChange;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
|
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public class CmdFactionsInvite extends FCommand
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public CmdFactionsInvite()
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// Aliases
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addAliases("inv", "invite");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Args
|
2013-04-16 10:30:21 +02:00
|
|
|
this.addRequiredArg("player");
|
2013-04-19 12:27:39 +02:00
|
|
|
this.addOptionalArg("yes/no", "toggle");
|
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.INVITE.node));
|
2013-04-25 13:53:22 +02:00
|
|
|
this.addRequirements(ReqHasFaction.get());
|
2013-04-16 09:48:57 +02:00
|
|
|
this.addRequirements(ReqIsPlayer.get());
|
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-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-10-09 14:53:38 +02:00
|
|
|
public void perform()
|
|
|
|
{
|
2013-04-19 12:27:39 +02:00
|
|
|
// Args
|
2013-04-22 17:59:51 +02:00
|
|
|
UPlayer uplayer = this.arg(0, ARUPlayer.getStartAny(sender));
|
|
|
|
if (uplayer == null) return;
|
2013-04-17 10:34:48 +02:00
|
|
|
|
2013-04-25 07:29:19 +02:00
|
|
|
Boolean newInvited = this.arg(1, ARBoolean.get(), !usenderFaction.isInvited(uplayer));
|
2013-04-19 12:27:39 +02:00
|
|
|
if (newInvited == null) return;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2013-04-19 12:27:39 +02:00
|
|
|
// Allready member?
|
2013-04-25 07:29:19 +02:00
|
|
|
if (uplayer.getFaction() == usenderFaction)
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
msg("%s<i> is already a member of %s", uplayer.getName(), usenderFaction.getName());
|
2013-04-16 11:27:03 +02:00
|
|
|
msg("<i>You might want to: " + Factions.get().getOuterCmdFactions().cmdFactionsKick.getUseageTemplate(false));
|
2011-03-22 15:45:41 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-05-09 03:24:07 +02:00
|
|
|
|
2013-04-19 12:27:39 +02:00
|
|
|
// FPerm
|
2013-04-29 12:48:11 +02:00
|
|
|
if ( ! FPerm.INVITE.has(usender, usenderFaction, true)) return;
|
2013-04-19 12:27:39 +02:00
|
|
|
|
|
|
|
// Event
|
2014-06-04 16:47:01 +02:00
|
|
|
EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, uplayer, usenderFaction, newInvited);
|
2013-04-19 12:27:39 +02:00
|
|
|
event.run();
|
|
|
|
if (event.isCancelled()) return;
|
|
|
|
newInvited = event.isNewInvited();
|
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-19 12:27:39 +02:00
|
|
|
// Apply
|
2013-04-25 07:29:19 +02:00
|
|
|
usenderFaction.setInvited(uplayer, newInvited);
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2013-04-19 12:27:39 +02:00
|
|
|
// Inform
|
|
|
|
if (newInvited)
|
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
uplayer.msg("%s<i> invited you to %s", usender.describeTo(uplayer, true), usenderFaction.describeTo(uplayer));
|
|
|
|
usenderFaction.msg("%s<i> invited %s<i> to your faction.", usender.describeTo(usenderFaction, true), uplayer.describeTo(usenderFaction));
|
2013-04-19 12:27:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
uplayer.msg("%s<i> revoked your invitation to <h>%s<i>.", usender.describeTo(uplayer), usenderFaction.describeTo(uplayer));
|
|
|
|
usenderFaction.msg("%s<i> revoked %s's<i> invitation.", usender.describeTo(usenderFaction), uplayer.describeTo(usenderFaction));
|
2013-04-19 12:27:39 +02:00
|
|
|
}
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|