2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-23 17:39:56 +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-16 11:05:49 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
2013-04-25 17:00:22 +02:00
|
|
|
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
|
2013-04-22 09:37:53 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2013-04-23 18:07:17 +02:00
|
|
|
import com.massivecraft.factions.entity.UConf;
|
2013-04-19 12:27:39 +02:00
|
|
|
import com.massivecraft.factions.event.FactionsEventHomeChange;
|
2013-04-16 10:11:59 +02:00
|
|
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
2013-04-16 09:48:57 +02:00
|
|
|
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
2013-04-11 11:11:31 +02:00
|
|
|
import com.massivecraft.mcore.ps.PS;
|
2011-03-23 17:39:56 +01:00
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public class CmdFactionsSethome extends FCommand
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public CmdFactionsSethome()
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// Aliases
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addAliases("sethome");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Args
|
2013-04-16 10:30:21 +02:00
|
|
|
this.addOptionalArg("faction", "you");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Requirements
|
2013-04-25 17:00:22 +02:00
|
|
|
this.addRequirements(ReqFactionsEnabled.get());
|
2013-04-16 09:48:57 +02:00
|
|
|
this.addRequirements(ReqIsPlayer.get());
|
2013-04-16 10:30:21 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node));
|
2011-03-23 17:39:56 +01:00
|
|
|
}
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
2011-03-23 17:39:56 +01:00
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-10-09 18:35:39 +02:00
|
|
|
public void perform()
|
|
|
|
{
|
2013-04-19 12:44:28 +02:00
|
|
|
// Args
|
2013-04-25 07:29:19 +02:00
|
|
|
Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction);
|
2011-10-09 18:35:39 +02:00
|
|
|
if (faction == null) return;
|
2011-07-20 22:42:51 +02:00
|
|
|
|
2013-04-19 09:50:33 +02:00
|
|
|
PS newHome = PS.valueOf(me.getLocation());
|
2013-04-17 11:47:48 +02:00
|
|
|
|
2013-04-23 18:07:17 +02:00
|
|
|
// Validate
|
|
|
|
if ( ! UConf.get(faction).homesEnabled)
|
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
usender.msg("<b>Sorry, Faction homes are disabled on this server.");
|
2013-04-23 18:07:17 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-19 12:44:28 +02:00
|
|
|
// FPerm
|
2013-04-29 12:48:11 +02:00
|
|
|
if ( ! FPerm.SETHOME.has(usender, faction, true)) return;
|
2013-04-19 12:44:28 +02:00
|
|
|
|
|
|
|
// Verify
|
2013-04-25 07:29:19 +02:00
|
|
|
if (!usender.isUsingAdminMode() && !faction.isValidHome(newHome))
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
usender.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
|
2011-06-19 10:56:21 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-04-19 09:50:33 +02:00
|
|
|
|
2013-04-19 12:44:28 +02:00
|
|
|
// Event
|
2013-04-19 12:27:39 +02:00
|
|
|
FactionsEventHomeChange event = new FactionsEventHomeChange(sender, faction, newHome);
|
2013-04-19 09:50:33 +02:00
|
|
|
event.run();
|
|
|
|
if (event.isCancelled()) return;
|
|
|
|
newHome = event.getNewHome();
|
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:44:28 +02:00
|
|
|
// Apply
|
2013-04-19 09:50:33 +02:00
|
|
|
faction.setHome(newHome);
|
2011-03-23 17:39:56 +01:00
|
|
|
|
2013-04-19 12:44:28 +02:00
|
|
|
// Inform
|
2013-04-25 07:29:19 +02:00
|
|
|
faction.msg("%s<i> set the home for your faction. You can now use:", usender.describeTo(usenderFaction, true));
|
2013-04-16 11:27:03 +02:00
|
|
|
faction.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsHome.getUseageTemplate());
|
2013-04-25 07:29:19 +02:00
|
|
|
if (faction != usenderFaction)
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
usender.msg("<b>You have set the home for the "+faction.getName(usender)+"<i> faction.");
|
2011-07-20 22:42:51 +02:00
|
|
|
}
|
2011-03-23 17:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|