2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
2013-04-09 12:56:29 +02:00
|
|
|
import com.massivecraft.factions.Perm;
|
2015-10-21 19:35:41 +02:00
|
|
|
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
2014-10-03 09:01:36 +02:00
|
|
|
import com.massivecraft.factions.entity.MPerm;
|
2014-09-17 13:17:33 +02:00
|
|
|
import com.massivecraft.factions.entity.MPlayer;
|
2014-06-04 16:47:01 +02:00
|
|
|
import com.massivecraft.factions.event.EventFactionsTitleChange;
|
2015-02-12 12:00:55 +01:00
|
|
|
import com.massivecraft.massivecore.MassiveException;
|
2015-11-06 02:10:29 +01:00
|
|
|
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
|
|
|
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.util.Txt;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-09-18 13:41:20 +02:00
|
|
|
public class CmdFactionsTitle extends FactionsCommand
|
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 CmdFactionsTitle()
|
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("title");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
2015-10-21 19:35:41 +02:00
|
|
|
// Parameters
|
|
|
|
this.addParameter(TypeMPlayer.get(), "player");
|
|
|
|
this.addParameter(TypeString.get(), "title", "", true);
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Requirements
|
2015-11-06 02:10:29 +01:00
|
|
|
this.addRequirements(RequirementHasPerm.get(Perm.TITLE.node));
|
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
|
2015-02-12 12:00:55 +01:00
|
|
|
public void perform() throws MassiveException
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-04-19 12:27:39 +02:00
|
|
|
// Args
|
2015-05-06 17:04:35 +02:00
|
|
|
MPlayer you = this.readArg();
|
|
|
|
String newTitle = this.readArg("");
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
newTitle = Txt.parse(newTitle);
|
|
|
|
if (!Perm.TITLE_COLOR.has(sender, false))
|
|
|
|
{
|
|
|
|
newTitle = ChatColor.stripColor(newTitle);
|
|
|
|
}
|
|
|
|
|
2014-10-03 09:01:36 +02:00
|
|
|
// MPerm
|
|
|
|
if ( ! MPerm.getPermTitle().has(msender, you.getFaction(), true)) return;
|
|
|
|
|
2015-08-26 08:23:08 +02:00
|
|
|
// Rank Check
|
2016-02-02 19:03:11 +01:00
|
|
|
if (!msender.isOverriding() && you.getRole().isMoreThan(msender.getRole()))
|
2015-08-26 08:23:08 +02:00
|
|
|
{
|
|
|
|
msg("<b>You can not edit titles for higher ranks.");
|
|
|
|
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-19 12:27:39 +02:00
|
|
|
// Event
|
2014-06-04 16:47:01 +02:00
|
|
|
EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle);
|
2013-04-19 12:27:39 +02:00
|
|
|
event.run();
|
|
|
|
if (event.isCancelled()) return;
|
|
|
|
newTitle = event.getNewTitle();
|
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
|
|
|
|
you.setTitle(newTitle);
|
2011-03-22 15:45:41 +01:00
|
|
|
|
|
|
|
// Inform
|
2014-09-18 13:41:20 +02:00
|
|
|
msenderFaction.msg("%s<i> changed a title: %s", msender.describeTo(msenderFaction, true), you.describeTo(msenderFaction, true));
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|