Remove Maven
This commit is contained in:
		@@ -1,47 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
public class Const
 | 
			
		||||
{
 | 
			
		||||
	// Collections & Aspects
 | 
			
		||||
	public static final String BASENAME = "factions";
 | 
			
		||||
	public static final String BASENAME_ = BASENAME+"_";
 | 
			
		||||
	
 | 
			
		||||
	public static final String COLLECTION_BOARD = BASENAME_+"board";
 | 
			
		||||
	public static final String COLLECTION_FACTION = BASENAME_+"faction";
 | 
			
		||||
	public static final String COLLECTION_MFLAG = BASENAME_+"mflag";
 | 
			
		||||
	public static final String COLLECTION_MPERM = BASENAME_+"mperm";
 | 
			
		||||
	public static final String COLLECTION_MPLAYER = BASENAME_+"mplayer";
 | 
			
		||||
	public static final String COLLECTION_MCONF = BASENAME_+"mconf";
 | 
			
		||||
	
 | 
			
		||||
	public static final String ASPECT = BASENAME;
 | 
			
		||||
	
 | 
			
		||||
	// ASCII Map
 | 
			
		||||
	public static final int MAP_WIDTH = 48;
 | 
			
		||||
	public static final int MAP_HEIGHT = 8;
 | 
			
		||||
	public static final int MAP_HEIGHT_FULL = 17;
 | 
			
		||||
	
 | 
			
		||||
	public static final char[] MAP_KEY_CHARS = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray();
 | 
			
		||||
	
 | 
			
		||||
	// SHOW
 | 
			
		||||
	
 | 
			
		||||
	public static final String SHOW_ID_FACTION_ID = BASENAME_ + "id";
 | 
			
		||||
	public static final String SHOW_ID_FACTION_DESCRIPTION = BASENAME_ + "description";
 | 
			
		||||
	public static final String SHOW_ID_FACTION_AGE = BASENAME_ + "age";
 | 
			
		||||
	public static final String SHOW_ID_FACTION_FLAGS = BASENAME_ + "flags";
 | 
			
		||||
	public static final String SHOW_ID_FACTION_POWER = BASENAME_ + "power";
 | 
			
		||||
	public static final String SHOW_ID_FACTION_LANDVALUES = BASENAME_ + "landvalue";
 | 
			
		||||
	public static final String SHOW_ID_FACTION_BANK = BASENAME_ + "bank";
 | 
			
		||||
	public static final String SHOW_ID_FACTION_RELATIONS = BASENAME_ + "relations";
 | 
			
		||||
	public static final String SHOW_ID_FACTION_FOLLOWERS = BASENAME_ + "followers";
 | 
			
		||||
	
 | 
			
		||||
	public static final int SHOW_PRIORITY_FACTION_ID = 1000;
 | 
			
		||||
	public static final int SHOW_PRIORITY_FACTION_DESCRIPTION = 2000;
 | 
			
		||||
	public static final int SHOW_PRIORITY_FACTION_AGE = 3000;
 | 
			
		||||
	public static final int SHOW_PRIORITY_FACTION_FLAGS = 4000;
 | 
			
		||||
	public static final int SHOW_PRIORITY_FACTION_POWER = 5000;
 | 
			
		||||
	public static final int SHOW_PRIORITY_FACTION_LANDVALUES = 6000;
 | 
			
		||||
	public static final int SHOW_PRIORITY_FACTION_BANK = 7000;
 | 
			
		||||
	public static final int SHOW_PRIORITY_FACTION_RELATIONS = 8000;
 | 
			
		||||
	public static final int SHOW_PRIORITY_FACTION_FOLLOWERS = 9000;
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public interface EconomyParticipator extends RelationParticipator
 | 
			
		||||
{
 | 
			
		||||
	public boolean msg(String msg, Object... args);
 | 
			
		||||
}
 | 
			
		||||
@@ -1,32 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.massivecore.util.extractor.Extractor;
 | 
			
		||||
 | 
			
		||||
public class ExtractorFactionAccountId implements Extractor
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static ExtractorFactionAccountId i = new ExtractorFactionAccountId();
 | 
			
		||||
	public static ExtractorFactionAccountId get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE: EXTRACTOR
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Object extract(Object o)
 | 
			
		||||
	{
 | 
			
		||||
		if (o instanceof Faction)
 | 
			
		||||
		{
 | 
			
		||||
			String factionId = ((Faction)o).getId();
 | 
			
		||||
			if (factionId == null) return null;
 | 
			
		||||
			return Factions.FACTION_MONEY_ACCOUNT_ID_PREFIX + factionId;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,42 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.massivecore.Predictate;
 | 
			
		||||
 | 
			
		||||
public class FactionEqualsPredictate implements Predictate<CommandSender>, Serializable
 | 
			
		||||
{
 | 
			
		||||
	private static final long serialVersionUID = 1L;
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private final String factionId;
 | 
			
		||||
	public String getFactionId() { return this.factionId; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public FactionEqualsPredictate(Faction faction)
 | 
			
		||||
	{
 | 
			
		||||
		this.factionId = faction.getId();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean apply(CommandSender sender)
 | 
			
		||||
	{
 | 
			
		||||
		MPlayer mplayer = MPlayer.get(sender);
 | 
			
		||||
		return this.factionId.equals(mplayer.getFactionId());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,50 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.massivecore.util.MUtil;
 | 
			
		||||
 | 
			
		||||
public class FactionListComparator implements Comparator<Faction>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static FactionListComparator i = new FactionListComparator();
 | 
			
		||||
	public static FactionListComparator get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE: COMPARATOR
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public int compare(Faction f1, Faction f2)
 | 
			
		||||
	{
 | 
			
		||||
		int ret = 0;
 | 
			
		||||
		
 | 
			
		||||
		// Null
 | 
			
		||||
		if (f1 == null && f2 == null) ret = 0;
 | 
			
		||||
		if (f1 == null) ret = -1;
 | 
			
		||||
		if (f2 == null) ret = +1;
 | 
			
		||||
		if (ret != 0) return ret;
 | 
			
		||||
		
 | 
			
		||||
		// None a.k.a. Wilderness
 | 
			
		||||
		if (f1.isNone() && f2.isNone()) ret = 0;
 | 
			
		||||
		if (f1.isNone()) ret = -1;
 | 
			
		||||
		if (f2.isNone()) ret = +1;
 | 
			
		||||
		if (ret != 0) return ret;
 | 
			
		||||
		
 | 
			
		||||
		// Players Online
 | 
			
		||||
		ret = f2.getMPlayersWhereOnline(true).size() - f1.getMPlayersWhereOnline(true).size();
 | 
			
		||||
		if (ret != 0) return ret;
 | 
			
		||||
		
 | 
			
		||||
		// Players Total
 | 
			
		||||
		ret = f2.getMPlayers().size() - f1.getMPlayers().size();
 | 
			
		||||
		if (ret != 0) return ret;
 | 
			
		||||
		
 | 
			
		||||
		// Tie by Id
 | 
			
		||||
		return MUtil.compare(f1.getId(), f2.getId());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,209 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.adapter.BoardAdapter;
 | 
			
		||||
import com.massivecraft.factions.adapter.BoardMapAdapter;
 | 
			
		||||
import com.massivecraft.factions.adapter.FactionPreprocessAdapter;
 | 
			
		||||
import com.massivecraft.factions.adapter.RelAdapter;
 | 
			
		||||
import com.massivecraft.factions.adapter.TerritoryAccessAdapter;
 | 
			
		||||
import com.massivecraft.factions.chat.modifier.ChatModifierLc;
 | 
			
		||||
import com.massivecraft.factions.chat.modifier.ChatModifierLp;
 | 
			
		||||
import com.massivecraft.factions.chat.modifier.ChatModifierParse;
 | 
			
		||||
import com.massivecraft.factions.chat.modifier.ChatModifierRp;
 | 
			
		||||
import com.massivecraft.factions.chat.modifier.ChatModifierUc;
 | 
			
		||||
import com.massivecraft.factions.chat.modifier.ChatModifierUcf;
 | 
			
		||||
import com.massivecraft.factions.chat.tag.ChatTagRelcolor;
 | 
			
		||||
import com.massivecraft.factions.chat.tag.ChatTagRole;
 | 
			
		||||
import com.massivecraft.factions.chat.tag.ChatTagRoleprefix;
 | 
			
		||||
import com.massivecraft.factions.chat.tag.ChatTagName;
 | 
			
		||||
import com.massivecraft.factions.chat.tag.ChatTagNameforce;
 | 
			
		||||
import com.massivecraft.factions.chat.tag.ChatTagRoleprefixforce;
 | 
			
		||||
import com.massivecraft.factions.chat.tag.ChatTagTitle;
 | 
			
		||||
import com.massivecraft.factions.cmd.*;
 | 
			
		||||
import com.massivecraft.factions.engine.EngineChat;
 | 
			
		||||
import com.massivecraft.factions.engine.EngineEcon;
 | 
			
		||||
import com.massivecraft.factions.engine.EngineExploit;
 | 
			
		||||
import com.massivecraft.factions.engine.EngineIdUpdate;
 | 
			
		||||
import com.massivecraft.factions.engine.EngineMain;
 | 
			
		||||
import com.massivecraft.factions.engine.EngineSeeChunk;
 | 
			
		||||
import com.massivecraft.factions.entity.Board;
 | 
			
		||||
import com.massivecraft.factions.entity.BoardColl;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MFlagColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MPermColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayerColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MConfColl;
 | 
			
		||||
import com.massivecraft.factions.integration.herochat.IntegrationHerochat;
 | 
			
		||||
import com.massivecraft.factions.integration.lwc.IntegrationLwc;
 | 
			
		||||
import com.massivecraft.factions.mixin.PowerMixin;
 | 
			
		||||
import com.massivecraft.factions.mixin.PowerMixinDefault;
 | 
			
		||||
import com.massivecraft.factions.spigot.SpigotFeatures;
 | 
			
		||||
import com.massivecraft.factions.task.TaskFlagPermCreate;
 | 
			
		||||
import com.massivecraft.factions.task.TaskPlayerDataRemove;
 | 
			
		||||
import com.massivecraft.factions.task.TaskEconLandReward;
 | 
			
		||||
import com.massivecraft.factions.task.TaskPlayerPowerUpdate;
 | 
			
		||||
import com.massivecraft.factions.update.UpdateUtil;
 | 
			
		||||
import com.massivecraft.massivecore.Aspect;
 | 
			
		||||
import com.massivecraft.massivecore.AspectColl;
 | 
			
		||||
import com.massivecraft.massivecore.MassivePlugin;
 | 
			
		||||
import com.massivecraft.massivecore.Multiverse;
 | 
			
		||||
import com.massivecraft.massivecore.util.MUtil;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.Gson;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.GsonBuilder;
 | 
			
		||||
 | 
			
		||||
public class Factions extends MassivePlugin
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTANTS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public final static String FACTION_MONEY_ACCOUNT_ID_PREFIX = "faction-"; 
 | 
			
		||||
	
 | 
			
		||||
	public final static String ID_NONE = "none";
 | 
			
		||||
	public final static String ID_SAFEZONE = "safezone";
 | 
			
		||||
	public final static String ID_WARZONE = "warzone";
 | 
			
		||||
	
 | 
			
		||||
	public final static String NAME_NONE_DEFAULT = ChatColor.DARK_GREEN.toString() + "Wilderness";
 | 
			
		||||
	public final static String NAME_SAFEZONE_DEFAULT = "SafeZone";
 | 
			
		||||
	public final static String NAME_WARZONE_DEFAULT = "WarZone";
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static Factions i;
 | 
			
		||||
	public static Factions get() { return i; }
 | 
			
		||||
	public Factions() { Factions.i = this; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	// Commands
 | 
			
		||||
	private CmdFactions outerCmdFactions;
 | 
			
		||||
	public CmdFactions getOuterCmdFactions() { return this.outerCmdFactions; }
 | 
			
		||||
	
 | 
			
		||||
	// Aspects
 | 
			
		||||
	// TODO: Remove in the future when the update has been removed.
 | 
			
		||||
	private Aspect aspect;
 | 
			
		||||
	public Aspect getAspect() { return this.aspect; }
 | 
			
		||||
	public Multiverse getMultiverse() { return this.getAspect().getMultiverse(); }
 | 
			
		||||
	
 | 
			
		||||
	// Database Initialized
 | 
			
		||||
	private boolean databaseInitialized;
 | 
			
		||||
	public boolean isDatabaseInitialized() { return this.databaseInitialized; }
 | 
			
		||||
	
 | 
			
		||||
	// Mixins
 | 
			
		||||
	private PowerMixin powerMixin = null;
 | 
			
		||||
	public PowerMixin getPowerMixin() { return this.powerMixin == null ? PowerMixinDefault.get() : this.powerMixin; }
 | 
			
		||||
	public void setPowerMixin(PowerMixin powerMixin) { this.powerMixin = powerMixin; }
 | 
			
		||||
	
 | 
			
		||||
	// Gson without preprocessors
 | 
			
		||||
	public final Gson gsonWithoutPreprocessors = this.getGsonBuilderWithoutPreprocessors().create();
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void onEnable()
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! preEnable()) return;
 | 
			
		||||
		
 | 
			
		||||
		// Initialize Aspects
 | 
			
		||||
		this.aspect = AspectColl.get().get(Const.ASPECT, true);
 | 
			
		||||
		this.aspect.register();
 | 
			
		||||
		this.aspect.setDesc(
 | 
			
		||||
			"<i>If the factions system even is enabled and how it's configured.",
 | 
			
		||||
			"<i>What factions exists and what players belong to them."
 | 
			
		||||
		);
 | 
			
		||||
		
 | 
			
		||||
		// Register Faction accountId Extractor
 | 
			
		||||
		// TODO: Perhaps this should be placed in the econ integration somewhere?
 | 
			
		||||
		MUtil.registerExtractor(String.class, "accountId", ExtractorFactionAccountId.get());
 | 
			
		||||
 | 
			
		||||
		// Initialize Database
 | 
			
		||||
		this.databaseInitialized = false;
 | 
			
		||||
		MFlagColl.get().init();
 | 
			
		||||
		MPermColl.get().init();
 | 
			
		||||
		MConfColl.get().init();
 | 
			
		||||
		
 | 
			
		||||
		UpdateUtil.update();
 | 
			
		||||
		
 | 
			
		||||
		MPlayerColl.get().init();
 | 
			
		||||
		FactionColl.get().init();
 | 
			
		||||
		BoardColl.get().init();
 | 
			
		||||
		
 | 
			
		||||
		UpdateUtil.updateSpecialIds();
 | 
			
		||||
		
 | 
			
		||||
		FactionColl.get().reindexMPlayers();
 | 
			
		||||
		this.databaseInitialized = true;
 | 
			
		||||
		
 | 
			
		||||
		// Commands
 | 
			
		||||
		this.outerCmdFactions = new CmdFactions();
 | 
			
		||||
		this.outerCmdFactions.register(this);
 | 
			
		||||
 | 
			
		||||
		// Engines
 | 
			
		||||
		EngineMain.get().activate();
 | 
			
		||||
		EngineChat.get().activate();
 | 
			
		||||
		EngineExploit.get().activate();
 | 
			
		||||
		EngineIdUpdate.get().activate();
 | 
			
		||||
		EngineSeeChunk.get().activate();
 | 
			
		||||
		EngineEcon.get().activate(); // TODO: Take an extra look and make sure all economy stuff is handled using events. 
 | 
			
		||||
		
 | 
			
		||||
		// Integrate
 | 
			
		||||
		this.integrate(
 | 
			
		||||
			IntegrationHerochat.get(),
 | 
			
		||||
			IntegrationLwc.get()
 | 
			
		||||
		);
 | 
			
		||||
		
 | 
			
		||||
		// Spigot
 | 
			
		||||
		SpigotFeatures.activate();
 | 
			
		||||
		
 | 
			
		||||
		// Modulo Repeat Tasks
 | 
			
		||||
		TaskPlayerPowerUpdate.get().activate(this);
 | 
			
		||||
		TaskPlayerDataRemove.get().activate(this);
 | 
			
		||||
		TaskEconLandReward.get().activate(this);
 | 
			
		||||
		TaskFlagPermCreate.get().activate(this);
 | 
			
		||||
		
 | 
			
		||||
		// Register built in chat modifiers
 | 
			
		||||
		ChatModifierLc.get().register();
 | 
			
		||||
		ChatModifierLp.get().register();
 | 
			
		||||
		ChatModifierParse.get().register();
 | 
			
		||||
		ChatModifierRp.get().register();
 | 
			
		||||
		ChatModifierUc.get().register();
 | 
			
		||||
		ChatModifierUcf.get().register();
 | 
			
		||||
		
 | 
			
		||||
		// Register built in chat tags
 | 
			
		||||
		ChatTagRelcolor.get().register();
 | 
			
		||||
		ChatTagRole.get().register();
 | 
			
		||||
		ChatTagRoleprefix.get().register();
 | 
			
		||||
		ChatTagRoleprefixforce.get().register();
 | 
			
		||||
		ChatTagName.get().register();
 | 
			
		||||
		ChatTagNameforce.get().register();
 | 
			
		||||
		ChatTagTitle.get().register();
 | 
			
		||||
		
 | 
			
		||||
		postEnable();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public GsonBuilder getGsonBuilderWithoutPreprocessors()
 | 
			
		||||
	{
 | 
			
		||||
		return super.getGsonBuilder()
 | 
			
		||||
		.registerTypeAdapter(TerritoryAccess.class, TerritoryAccessAdapter.get())
 | 
			
		||||
		.registerTypeAdapter(Board.class, BoardAdapter.get())
 | 
			
		||||
		.registerTypeAdapter(Board.MAP_TYPE, BoardMapAdapter.get())
 | 
			
		||||
		.registerTypeAdapter(Rel.class, RelAdapter.get())
 | 
			
		||||
		;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public GsonBuilder getGsonBuilder()
 | 
			
		||||
	{
 | 
			
		||||
		return this.getGsonBuilderWithoutPreprocessors()
 | 
			
		||||
		.registerTypeAdapter(Faction.class, FactionPreprocessAdapter.get())
 | 
			
		||||
		;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,10 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class Lang
 | 
			
		||||
{
 | 
			
		||||
	public static final String FACTION_NODESCRIPTION = Txt.parse("<em><silver>no description set");
 | 
			
		||||
	public static final String FACTION_NOMOTD = Txt.parse("<em><silver>no message of the day set");
 | 
			
		||||
	public static final String PLAYER_NOTITLE = Txt.parse("<em><silver>no title set");
 | 
			
		||||
}
 | 
			
		||||
@@ -1,105 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.permissions.Permissible;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.massivecore.util.PermUtil;
 | 
			
		||||
 | 
			
		||||
public enum Perm
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// ENUM
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	ACCESS("access"),
 | 
			
		||||
	ACCESS_VIEW("access.view"),
 | 
			
		||||
	ACCESS_PLAYER("access.player"),
 | 
			
		||||
	ACCESS_FACTION("access.faction"),
 | 
			
		||||
	ADMIN("admin"),
 | 
			
		||||
	CLAIM("claim"),
 | 
			
		||||
	CLAIM_ONE("claim.one"),
 | 
			
		||||
	CLAIM_AUTO("claim.auto"),
 | 
			
		||||
	CLAIM_FILL("claim.fill"),
 | 
			
		||||
	CLAIM_SQUARE("claim.square"),
 | 
			
		||||
	CLAIM_CIRCLE("claim.circle"),
 | 
			
		||||
	CLAIM_ALL("claim.all"),
 | 
			
		||||
	CREATE("create"),
 | 
			
		||||
	DESCRIPTION("description"),
 | 
			
		||||
	DISBAND("disband"),
 | 
			
		||||
	EXPANSIONS("expansions"),
 | 
			
		||||
	FACTION("faction"),
 | 
			
		||||
	FLAG("flag"),
 | 
			
		||||
	HOME("home"),
 | 
			
		||||
	INVITE("invite"),
 | 
			
		||||
	JOIN("join"),
 | 
			
		||||
	JOIN_ANY("join.any"),
 | 
			
		||||
	JOIN_OTHERS("join.others"),
 | 
			
		||||
	KICK("kick"),
 | 
			
		||||
	LEAVE("leave"),
 | 
			
		||||
	LIST("list"),
 | 
			
		||||
	MAP("map"),
 | 
			
		||||
	MONEY("money"),
 | 
			
		||||
	MONEY_BALANCE("money.balance"),
 | 
			
		||||
	MONEY_BALANCE_ANY("money.balance.any"),
 | 
			
		||||
	MONEY_DEPOSIT("money.deposit"),
 | 
			
		||||
	MONEY_F2F("money.f2f"),
 | 
			
		||||
	MONEY_F2P("money.f2p"),
 | 
			
		||||
	MONEY_P2F("money.p2f"),
 | 
			
		||||
	MONEY_WITHDRAW("money.withdraw"),
 | 
			
		||||
	MOTD("motd"),
 | 
			
		||||
	OPEN("open"),
 | 
			
		||||
	PERM("perm"),
 | 
			
		||||
	PLAYER("player"),
 | 
			
		||||
	POWERBOOST("powerboost"),
 | 
			
		||||
	RANK("rank"),
 | 
			
		||||
	RANK_SHOW("rank.show"),
 | 
			
		||||
	RANK_ACTION("rank.action"),
 | 
			
		||||
	RELATION("relation"),
 | 
			
		||||
	SEECHUNK("seechunk"),
 | 
			
		||||
	SEECHUNKOLD("seechunkold"),
 | 
			
		||||
	SETHOME("sethome"),
 | 
			
		||||
	NAME("name"),
 | 
			
		||||
	TITLE("title"),
 | 
			
		||||
	TITLE_COLOR("title.color"),
 | 
			
		||||
	UNCLAIM("unclaim"),
 | 
			
		||||
	UNCLAIM_ONE("unclaim.one"),
 | 
			
		||||
	UNCLAIM_AUTO("unclaim.auto"),
 | 
			
		||||
	UNCLAIM_FILL("unclaim.fill"),
 | 
			
		||||
	UNCLAIM_SQUARE("unclaim.square"),
 | 
			
		||||
	UNCLAIM_CIRCLE("unclaim.circle"),
 | 
			
		||||
	UNCLAIM_ALL("unclaim.all"),
 | 
			
		||||
	UNSETHOME("unsethome"),
 | 
			
		||||
	VERSION("version"),
 | 
			
		||||
	
 | 
			
		||||
	// END OF LIST
 | 
			
		||||
	;
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public final String node;
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	Perm(final String node)
 | 
			
		||||
	{
 | 
			
		||||
		this.node = "factions."+node;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// HAS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public boolean has(Permissible permissible, boolean informSenderIfNot)
 | 
			
		||||
	{
 | 
			
		||||
		return PermUtil.has(permissible, this.node, informSenderIfNot);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean has(Permissible permissible)
 | 
			
		||||
	{
 | 
			
		||||
		return has(permissible, false);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
 | 
			
		||||
public class PlayerRoleComparator implements Comparator<MPlayer>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static PlayerRoleComparator i = new PlayerRoleComparator();
 | 
			
		||||
	public static PlayerRoleComparator get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE: COMPARATOR
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public int compare(MPlayer o1, MPlayer o2)
 | 
			
		||||
	{
 | 
			
		||||
		int ret = 0;
 | 
			
		||||
		
 | 
			
		||||
		// Null
 | 
			
		||||
		if (o1 == null && o2 == null) ret = 0;
 | 
			
		||||
		if (o1 == null) ret = -1;
 | 
			
		||||
		if (o2 == null) ret = +1;
 | 
			
		||||
		if (ret != 0) return ret;
 | 
			
		||||
		
 | 
			
		||||
		// Rank
 | 
			
		||||
		Rel r1 = o1.getRole();
 | 
			
		||||
		Rel r2 = o2.getRole();
 | 
			
		||||
		return r2.getValue() - r1.getValue();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,158 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public enum Rel
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// ENUM
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	LEADER (70, true, "your faction leader", "your faction leader", "", ""),
 | 
			
		||||
	OFFICER (60, true, "an officer in your faction", "officers in your faction", "", ""),
 | 
			
		||||
	MEMBER (50, true, "a member in your faction", "members in your faction", "your faction", "your factions"),
 | 
			
		||||
	RECRUIT (45, true, "a recruit in your faction", "recruits in your faction", "", ""),
 | 
			
		||||
	ALLY (40, true, "an ally", "allies", "an allied faction", "allied factions"),
 | 
			
		||||
	TRUCE (30, true, "someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce"),
 | 
			
		||||
	NEUTRAL (20, false, "someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions"),
 | 
			
		||||
	ENEMY (10, false, "an enemy", "enemies", "an enemy faction", "enemy factions"),
 | 
			
		||||
	
 | 
			
		||||
	// END OF LIST
 | 
			
		||||
	;
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	// TODO: Are not enums sorted without this?
 | 
			
		||||
	private final int value;
 | 
			
		||||
	public int getValue() { return this.value; }
 | 
			
		||||
	
 | 
			
		||||
	// Used for friendly fire.
 | 
			
		||||
	private final boolean friend;
 | 
			
		||||
	public boolean isFriend() { return this.friend; }
 | 
			
		||||
	
 | 
			
		||||
	private final String descPlayerOne;
 | 
			
		||||
	public String getDescPlayerOne() { return this.descPlayerOne; }
 | 
			
		||||
	
 | 
			
		||||
	private final String descPlayerMany;
 | 
			
		||||
	public String getDescPlayerMany() { return this.descPlayerMany; }
 | 
			
		||||
	
 | 
			
		||||
	private final String descFactionOne;
 | 
			
		||||
	public String getDescFactionOne() { return this.descFactionOne; }
 | 
			
		||||
	
 | 
			
		||||
	private final String descFactionMany;
 | 
			
		||||
	public String getDescFactionMany() { return this.descFactionMany; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private Rel(final int value, final boolean friend, final String descPlayerOne, final String descPlayerMany, final String descFactionOne, final String descFactionMany)
 | 
			
		||||
	{
 | 
			
		||||
		this.value = value;
 | 
			
		||||
		this.friend = friend;
 | 
			
		||||
		this.descPlayerOne = descPlayerOne;
 | 
			
		||||
		this.descPlayerMany = descPlayerMany;
 | 
			
		||||
		this.descFactionOne = descFactionOne;
 | 
			
		||||
		this.descFactionMany = descFactionMany;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// UTIL
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static Rel parse(String str)
 | 
			
		||||
	{
 | 
			
		||||
		if (str == null || str.length() < 1) return null;
 | 
			
		||||
		
 | 
			
		||||
		str = str.toLowerCase();
 | 
			
		||||
		
 | 
			
		||||
		// These are to allow conversion from the old system.
 | 
			
		||||
		if (str.equals("admin"))
 | 
			
		||||
		{
 | 
			
		||||
			return LEADER;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (str.equals("moderator"))
 | 
			
		||||
		{
 | 
			
		||||
			return OFFICER;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (str.equals("normal"))
 | 
			
		||||
		{
 | 
			
		||||
			return MEMBER;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// NOTE: This assumes the first char is different for all.
 | 
			
		||||
		for (Rel rel : values())
 | 
			
		||||
		{
 | 
			
		||||
			String relStr = rel.toString().toLowerCase();
 | 
			
		||||
			if (relStr.startsWith(str)) return rel;
 | 
			
		||||
		}
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean isAtLeast(Rel rel)
 | 
			
		||||
	{
 | 
			
		||||
		return this.value >= rel.value;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean isAtMost(Rel rel)
 | 
			
		||||
	{
 | 
			
		||||
		return this.value <= rel.value;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean isLessThan(Rel rel)
 | 
			
		||||
	{
 | 
			
		||||
		return this.value < rel.value;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean isMoreThan(Rel rel)
 | 
			
		||||
	{
 | 
			
		||||
		return this.value > rel.value;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public ChatColor getColor()
 | 
			
		||||
	{
 | 
			
		||||
		if (this.isAtLeast(RECRUIT))
 | 
			
		||||
			return MConf.get().colorMember;
 | 
			
		||||
		else if (this == ALLY)
 | 
			
		||||
			return MConf.get().colorAlly;
 | 
			
		||||
		else if (this == NEUTRAL)
 | 
			
		||||
			return MConf.get().colorNeutral;
 | 
			
		||||
		else if (this == TRUCE)
 | 
			
		||||
			return MConf.get().colorTruce;
 | 
			
		||||
		else
 | 
			
		||||
			return MConf.get().colorEnemy;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public String getPrefix()
 | 
			
		||||
	{
 | 
			
		||||
		if (this == LEADER)
 | 
			
		||||
		{
 | 
			
		||||
			return MConf.get().prefixLeader;
 | 
			
		||||
		} 
 | 
			
		||||
		
 | 
			
		||||
		if (this == OFFICER)
 | 
			
		||||
		{
 | 
			
		||||
			return MConf.get().prefixOfficer;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (this == MEMBER)
 | 
			
		||||
		{
 | 
			
		||||
			return MConf.get().prefixMember;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (this == RECRUIT)
 | 
			
		||||
		{
 | 
			
		||||
			return MConf.get().prefixRecruit;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return "";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,15 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public interface RelationParticipator
 | 
			
		||||
{
 | 
			
		||||
	public String describeTo(RelationParticipator observer);
 | 
			
		||||
	public String describeTo(RelationParticipator observer, boolean ucfirst);
 | 
			
		||||
	
 | 
			
		||||
	public Rel getRelationTo(RelationParticipator observer);
 | 
			
		||||
	public Rel getRelationTo(RelationParticipator observer, boolean ignorePeaceful);
 | 
			
		||||
	
 | 
			
		||||
	public ChatColor getColorTo(RelationParticipator observer);
 | 
			
		||||
}
 | 
			
		||||
@@ -1,217 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.LinkedHashSet;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.TreeSet;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
 | 
			
		||||
public class TerritoryAccess
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS: RAW
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	// TODO: remake private final
 | 
			
		||||
	// no default value, can't be null
 | 
			
		||||
	public String hostFactionId;
 | 
			
		||||
	public String getHostFactionId() { return this.hostFactionId; }
 | 
			
		||||
	
 | 
			
		||||
	// default is true
 | 
			
		||||
	private final boolean hostFactionAllowed;
 | 
			
		||||
	public boolean isHostFactionAllowed() { return this.hostFactionAllowed; }
 | 
			
		||||
	
 | 
			
		||||
	// TODO: remake private final
 | 
			
		||||
	// default is empty
 | 
			
		||||
	public Set<String> factionIds;
 | 
			
		||||
	public Set<String> getFactionIds() { return this.factionIds; }
 | 
			
		||||
	
 | 
			
		||||
	// TODO: remake private final
 | 
			
		||||
	// default is empty
 | 
			
		||||
	public Set<String> playerIds;
 | 
			
		||||
	public Set<String> getPlayerIds() { return this.playerIds; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS: DELTA
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	// The simple ones
 | 
			
		||||
	public TerritoryAccess withHostFactionId(String hostFactionId) { return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds); }
 | 
			
		||||
	public TerritoryAccess withHostFactionAllowed(Boolean hostFactionAllowed) { return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds); }
 | 
			
		||||
	public TerritoryAccess withFactionIds(Collection<String> factionIds) { return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds); }
 | 
			
		||||
	public TerritoryAccess withPlayerIds(Collection<String> playerIds) { return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds); }
 | 
			
		||||
	
 | 
			
		||||
	// The intermediate ones
 | 
			
		||||
	public TerritoryAccess withFactionId(String factionId, boolean with)
 | 
			
		||||
	{
 | 
			
		||||
		if (this.getHostFactionId().equals(factionId))
 | 
			
		||||
		{
 | 
			
		||||
			return valueOf(hostFactionId, with, factionIds, playerIds);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		Set<String> factionIds = new HashSet<String>(this.getFactionIds());
 | 
			
		||||
		if (with)
 | 
			
		||||
		{
 | 
			
		||||
			factionIds.add(factionId);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			factionIds.remove(factionId);
 | 
			
		||||
		}
 | 
			
		||||
		return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public TerritoryAccess withPlayerId(String playerId, boolean with)
 | 
			
		||||
	{
 | 
			
		||||
		playerId = playerId.toLowerCase();
 | 
			
		||||
		Set<String> playerIds = new HashSet<String>(this.getPlayerIds());
 | 
			
		||||
		if (with)
 | 
			
		||||
		{
 | 
			
		||||
			playerIds.add(playerId);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			playerIds.remove(playerId);
 | 
			
		||||
		}
 | 
			
		||||
		return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// The complex ones
 | 
			
		||||
	public TerritoryAccess toggleFactionId(String factionId)
 | 
			
		||||
	{
 | 
			
		||||
		return this.withFactionId(factionId, !this.isFactionIdGranted(factionId));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public TerritoryAccess togglePlayerId(String playerId)
 | 
			
		||||
	{
 | 
			
		||||
		return this.withPlayerId(playerId, !this.isPlayerIdGranted(playerId));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS: DIRECT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public Faction getHostFaction()
 | 
			
		||||
	{
 | 
			
		||||
		return FactionColl.get().get(this.getHostFactionId());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public LinkedHashSet<MPlayer> getGrantedMPlayers()
 | 
			
		||||
	{
 | 
			
		||||
		LinkedHashSet<MPlayer> ret = new LinkedHashSet<MPlayer>();
 | 
			
		||||
		for (String playerId : this.getPlayerIds())
 | 
			
		||||
		{
 | 
			
		||||
			ret.add(MPlayer.get(playerId));
 | 
			
		||||
		}
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public LinkedHashSet<Faction> getGrantedFactions()
 | 
			
		||||
	{
 | 
			
		||||
		LinkedHashSet<Faction> ret = new LinkedHashSet<Faction>();
 | 
			
		||||
		for (String factionId : this.getFactionIds())
 | 
			
		||||
		{
 | 
			
		||||
			ret.add(FactionColl.get().get(factionId));
 | 
			
		||||
		}
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// PRIVATE CONSTRUCTOR
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private TerritoryAccess(String hostFactionId, Boolean hostFactionAllowed, Collection<String> factionIds, Collection<String> playerIds)
 | 
			
		||||
	{
 | 
			
		||||
		if (hostFactionId == null) throw new IllegalArgumentException("hostFactionId was null");
 | 
			
		||||
		this.hostFactionId = hostFactionId;
 | 
			
		||||
		
 | 
			
		||||
		Set<String> factionIdsInner = new TreeSet<String>();
 | 
			
		||||
		if (factionIds != null)
 | 
			
		||||
		{
 | 
			
		||||
			factionIdsInner.addAll(factionIds);
 | 
			
		||||
			if (factionIdsInner.remove(hostFactionId))
 | 
			
		||||
			{
 | 
			
		||||
				hostFactionAllowed = true;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		this.factionIds = Collections.unmodifiableSet(factionIdsInner);
 | 
			
		||||
		
 | 
			
		||||
		Set<String> playerIdsInner = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
 | 
			
		||||
		if (playerIds != null)
 | 
			
		||||
		{
 | 
			
		||||
			for (String playerId : playerIds)
 | 
			
		||||
			{
 | 
			
		||||
				playerIdsInner.add(playerId.toLowerCase());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		this.playerIds = Collections.unmodifiableSet(playerIdsInner);
 | 
			
		||||
		
 | 
			
		||||
		this.hostFactionAllowed = (hostFactionAllowed == null || hostFactionAllowed);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FACTORY: VALUE OF
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static TerritoryAccess valueOf(String hostFactionId, Boolean hostFactionAllowed, Collection<String> factionIds, Collection<String> playerIds)
 | 
			
		||||
	{
 | 
			
		||||
		return new TerritoryAccess(hostFactionId, hostFactionAllowed, factionIds, playerIds);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static TerritoryAccess valueOf(String hostFactionId)
 | 
			
		||||
	{
 | 
			
		||||
		return valueOf(hostFactionId, null, null, null);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE METHODS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public boolean isFactionIdGranted(String factionId)
 | 
			
		||||
	{
 | 
			
		||||
		if (this.getHostFactionId().equals(factionId))
 | 
			
		||||
		{
 | 
			
		||||
			return this.isHostFactionAllowed();
 | 
			
		||||
		}
 | 
			
		||||
		return this.getFactionIds().contains(factionId);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// Note that the player can have access without being specifically granted.
 | 
			
		||||
	// The player could for example be a member of a granted faction. 
 | 
			
		||||
	public boolean isPlayerIdGranted(String playerId)
 | 
			
		||||
	{
 | 
			
		||||
		return this.getPlayerIds().contains(playerId);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// A "default" TerritoryAccess could be serialized as a simple string only.
 | 
			
		||||
	// The host faction is still allowed (default) and no faction or player has been granted explicit access (default).
 | 
			
		||||
	public boolean isDefault()
 | 
			
		||||
	{
 | 
			
		||||
		return this.isHostFactionAllowed() && this.getFactionIds().isEmpty() && this.getPlayerIds().isEmpty(); 
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// HAS CHECK
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	// true means elevated access
 | 
			
		||||
	// false means decreased access
 | 
			
		||||
	// null means standard access
 | 
			
		||||
	public Boolean hasTerritoryAccess(MPlayer mplayer)
 | 
			
		||||
	{
 | 
			
		||||
		if (this.getPlayerIds().contains(mplayer.getId())) return true;
 | 
			
		||||
		
 | 
			
		||||
		String factionId = mplayer.getFactionId();
 | 
			
		||||
		if (this.getFactionIds().contains(factionId)) return true;
 | 
			
		||||
		
 | 
			
		||||
		if (this.getHostFactionId().equals(factionId) && !this.isHostFactionAllowed()) return false;
 | 
			
		||||
		
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,42 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.adapter;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Type;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializationContext;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializer;
 | 
			
		||||
import com.massivecraft.factions.TerritoryAccess;
 | 
			
		||||
import com.massivecraft.factions.entity.Board;
 | 
			
		||||
 | 
			
		||||
public class BoardAdapter implements JsonDeserializer<Board>, JsonSerializer<Board>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static BoardAdapter i = new BoardAdapter();
 | 
			
		||||
	public static BoardAdapter get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@SuppressWarnings("unchecked")
 | 
			
		||||
	@Override
 | 
			
		||||
	public Board deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
 | 
			
		||||
	{
 | 
			
		||||
		return new Board((Map<PS, TerritoryAccess>) context.deserialize(json, Board.MAP_TYPE));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public JsonElement serialize(Board src, Type typeOfSrc, JsonSerializationContext context)
 | 
			
		||||
	{
 | 
			
		||||
		return context.serialize(src.getMap(), Board.MAP_TYPE);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,69 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.adapter;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Type;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
import java.util.concurrent.ConcurrentSkipListMap;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonObject;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializationContext;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializer;
 | 
			
		||||
import com.massivecraft.factions.TerritoryAccess;
 | 
			
		||||
 | 
			
		||||
public class BoardMapAdapter implements JsonDeserializer<Map<PS, TerritoryAccess>>, JsonSerializer<Map<PS, TerritoryAccess>>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static BoardMapAdapter i = new BoardMapAdapter();
 | 
			
		||||
	public static BoardMapAdapter get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Map<PS, TerritoryAccess> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
 | 
			
		||||
	{
 | 
			
		||||
		Map<PS, TerritoryAccess> ret = new ConcurrentSkipListMap<PS, TerritoryAccess>();
 | 
			
		||||
		
 | 
			
		||||
		JsonObject jsonObject = json.getAsJsonObject();
 | 
			
		||||
		
 | 
			
		||||
		for (Entry<String, JsonElement> entry : jsonObject.entrySet())
 | 
			
		||||
		{
 | 
			
		||||
			String[] ChunkCoordParts = entry.getKey().split("[,\\s]+");
 | 
			
		||||
			int chunkX = Integer.parseInt(ChunkCoordParts[0]);
 | 
			
		||||
			int chunkZ = Integer.parseInt(ChunkCoordParts[1]);
 | 
			
		||||
			PS chunk = PS.valueOf(chunkX, chunkZ);
 | 
			
		||||
			
 | 
			
		||||
			TerritoryAccess territoryAccess = context.deserialize(entry.getValue(), TerritoryAccess.class);
 | 
			
		||||
			
 | 
			
		||||
			ret.put(chunk, territoryAccess);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public JsonElement serialize(Map<PS, TerritoryAccess> src, Type typeOfSrc, JsonSerializationContext context)
 | 
			
		||||
	{
 | 
			
		||||
		JsonObject ret = new JsonObject();
 | 
			
		||||
		
 | 
			
		||||
		for (Entry<PS, TerritoryAccess> entry : src.entrySet())
 | 
			
		||||
		{
 | 
			
		||||
			PS ps = entry.getKey();
 | 
			
		||||
			TerritoryAccess territoryAccess = entry.getValue();
 | 
			
		||||
			
 | 
			
		||||
			ret.add(ps.getChunkX().toString() + "," + ps.getChunkZ().toString(), context.serialize(territoryAccess, TerritoryAccess.class));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,56 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.adapter;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Type;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonObject;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
 | 
			
		||||
 | 
			
		||||
public class FactionPreprocessAdapter implements JsonDeserializer<Faction>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static FactionPreprocessAdapter i = new FactionPreprocessAdapter();
 | 
			
		||||
	public static FactionPreprocessAdapter get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Faction deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
 | 
			
		||||
	{
 | 
			
		||||
		preprocess(json);
 | 
			
		||||
		return Factions.get().gsonWithoutPreprocessors.fromJson(json, typeOfT);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void preprocess(JsonElement json)
 | 
			
		||||
	{
 | 
			
		||||
		JsonObject jsonObject = json.getAsJsonObject();
 | 
			
		||||
		
 | 
			
		||||
		// Renamed fields
 | 
			
		||||
		// 1.8.X --> 2.0.0
 | 
			
		||||
		rename(jsonObject, "tag", "name");
 | 
			
		||||
		rename(jsonObject, "invites", "invitedPlayerIds");
 | 
			
		||||
		rename(jsonObject, "relationWish", "relationWishes");
 | 
			
		||||
		rename(jsonObject, "flagOverrides", "flags");
 | 
			
		||||
		rename(jsonObject, "permOverrides", "perms");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// UTIL
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static void rename(final JsonObject jsonObject, final String from, final String to)
 | 
			
		||||
	{
 | 
			
		||||
		JsonElement element = jsonObject.remove(from);
 | 
			
		||||
		if (element != null) jsonObject.add(to, element);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,30 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.adapter;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Type;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
 | 
			
		||||
 | 
			
		||||
public class RelAdapter implements JsonDeserializer<Rel>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static RelAdapter i = new RelAdapter();
 | 
			
		||||
	public static RelAdapter get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Rel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
 | 
			
		||||
	{
 | 
			
		||||
		return Rel.parse(json.getAsString());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,116 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.adapter;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Type;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.TerritoryAccess;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonObject;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonPrimitive;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializationContext;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializer;
 | 
			
		||||
import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken;
 | 
			
		||||
 | 
			
		||||
public class TerritoryAccessAdapter implements JsonDeserializer<TerritoryAccess>, JsonSerializer<TerritoryAccess>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTANTS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	public static final String HOST_FACTION_ID = "hostFactionId";
 | 
			
		||||
	public static final String HOST_FACTION_ALLOWED = "hostFactionAllowed";
 | 
			
		||||
	public static final String FACTION_IDS = "factionIds";
 | 
			
		||||
	public static final String PLAYER_IDS = "playerIds";
 | 
			
		||||
	
 | 
			
		||||
	public static final Type SET_OF_STRING_TYPE = new TypeToken<Set<String>>(){}.getType();
 | 
			
		||||
			
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static TerritoryAccessAdapter i = new TerritoryAccessAdapter();
 | 
			
		||||
	public static TerritoryAccessAdapter get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	//----------------------------------------------//
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	//----------------------------------------------//
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public TerritoryAccess deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
 | 
			
		||||
	{
 | 
			
		||||
		// isDefault <=> simple hostFactionId string
 | 
			
		||||
		if (json.isJsonPrimitive())
 | 
			
		||||
		{
 | 
			
		||||
			String hostFactionId = json.getAsString();
 | 
			
		||||
			return TerritoryAccess.valueOf(hostFactionId);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Otherwise object
 | 
			
		||||
		JsonObject obj = json.getAsJsonObject();
 | 
			
		||||
 | 
			
		||||
		// Prepare variables
 | 
			
		||||
		String hostFactionId = null;
 | 
			
		||||
		Boolean hostFactionAllowed = null;
 | 
			
		||||
		Set<String> factionIds = null;
 | 
			
		||||
		Set<String> playerIds = null;
 | 
			
		||||
		
 | 
			
		||||
		// Read variables (test old values first)
 | 
			
		||||
		JsonElement element = null;
 | 
			
		||||
		
 | 
			
		||||
		element = obj.get("ID");
 | 
			
		||||
		if (element == null) element = obj.get(HOST_FACTION_ID);
 | 
			
		||||
		hostFactionId = element.getAsString();
 | 
			
		||||
		
 | 
			
		||||
		element = obj.get("open");
 | 
			
		||||
		if (element == null) element = obj.get(HOST_FACTION_ALLOWED);
 | 
			
		||||
		if (element != null) hostFactionAllowed = element.getAsBoolean();
 | 
			
		||||
		
 | 
			
		||||
		element = obj.get("factions");
 | 
			
		||||
		if (element == null) element = obj.get(FACTION_IDS);
 | 
			
		||||
		if (element != null) factionIds = context.deserialize(element, SET_OF_STRING_TYPE);
 | 
			
		||||
		
 | 
			
		||||
		element = obj.get("fplayers");
 | 
			
		||||
		if (element == null) element = obj.get(PLAYER_IDS);
 | 
			
		||||
		if (element != null) playerIds = context.deserialize(element, SET_OF_STRING_TYPE);
 | 
			
		||||
		
 | 
			
		||||
		return TerritoryAccess.valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public JsonElement serialize(TerritoryAccess src, Type typeOfSrc, JsonSerializationContext context)
 | 
			
		||||
	{
 | 
			
		||||
		if (src == null) return null;
 | 
			
		||||
 | 
			
		||||
		// isDefault <=> simple hostFactionId string
 | 
			
		||||
		if (src.isDefault())
 | 
			
		||||
		{
 | 
			
		||||
			return new JsonPrimitive(src.getHostFactionId());
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Otherwise object
 | 
			
		||||
		JsonObject obj = new JsonObject();
 | 
			
		||||
		
 | 
			
		||||
		obj.addProperty(HOST_FACTION_ID, src.getHostFactionId());
 | 
			
		||||
		
 | 
			
		||||
		if (!src.isHostFactionAllowed())
 | 
			
		||||
		{
 | 
			
		||||
			obj.addProperty(HOST_FACTION_ALLOWED, src.isHostFactionAllowed());
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (!src.getFactionIds().isEmpty())
 | 
			
		||||
		{
 | 
			
		||||
			obj.add(FACTION_IDS, context.serialize(src.getFactionIds(), SET_OF_STRING_TYPE));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (!src.getPlayerIds().isEmpty())
 | 
			
		||||
		{
 | 
			
		||||
			obj.add(PLAYER_IDS, context.serialize(src.getPlayerIds(), SET_OF_STRING_TYPE));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return obj;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,184 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.regex.Matcher;
 | 
			
		||||
import java.util.regex.Pattern;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The ChatFormater is a system offered by factions for tag parsing.
 | 
			
		||||
 * 
 | 
			
		||||
 * Note that every tag and modifier id must be lowercase.
 | 
			
		||||
 * A tag with id "derp" is allowed but not with id "Derp". For that reason the tag {sender} will work but {Sender} wont.  
 | 
			
		||||
 */
 | 
			
		||||
public class ChatFormatter
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTANTS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public final static String START = "{";
 | 
			
		||||
	public final static String END = "}";
 | 
			
		||||
	public final static String SEPARATOR = "|";
 | 
			
		||||
	
 | 
			
		||||
	public final static String ESC_START = "\\"+START;
 | 
			
		||||
	public final static String ESC_END = "\\"+END;
 | 
			
		||||
	public final static String ESC_SEPARATOR = "\\"+SEPARATOR;
 | 
			
		||||
	
 | 
			
		||||
	public final static Pattern pattern = Pattern.compile(ESC_START+"([^"+ESC_START+ESC_END+"]+)"+ESC_END);
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// TAG REGISTER
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private final static Map<String, ChatTag> idToTag = new HashMap<String, ChatTag>();
 | 
			
		||||
	public static ChatTag getTag(String tagId) { return idToTag.get(tagId); }
 | 
			
		||||
	public static boolean registerTag(ChatTag tag)
 | 
			
		||||
	{
 | 
			
		||||
		if (tag == null) throw new NullPointerException("tag");
 | 
			
		||||
		
 | 
			
		||||
		String id = tag.getId();
 | 
			
		||||
		if (id == null) throw new NullPointerException("tag id");
 | 
			
		||||
		if (!id.equals(id.toLowerCase()))
 | 
			
		||||
		{
 | 
			
		||||
			throw new IllegalArgumentException("tag id must be lowercase");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		ChatTag current = idToTag.get(id);
 | 
			
		||||
		if (current != null)
 | 
			
		||||
		{
 | 
			
		||||
			return current.equals(tag);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		idToTag.put(id, tag);
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static boolean unregisterTag(ChatTag tag)
 | 
			
		||||
	{
 | 
			
		||||
		if (tag == null) return false;
 | 
			
		||||
		return idToTag.remove(tag.getId()) != null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// MODIFIER REGISTER
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private final static Map<String, ChatModifier> idToModifier = new HashMap<String, ChatModifier>();
 | 
			
		||||
	public static ChatModifier getModifier(String modifierId) { return idToModifier.get(modifierId); }
 | 
			
		||||
	public static boolean registerModifier(ChatModifier modifier)
 | 
			
		||||
	{
 | 
			
		||||
		if (modifier == null) throw new NullPointerException("modifier");
 | 
			
		||||
		
 | 
			
		||||
		String id = modifier.getId();
 | 
			
		||||
		if (id == null) throw new NullPointerException("modifier id");
 | 
			
		||||
		if (!id.equals(id.toLowerCase()))
 | 
			
		||||
		{
 | 
			
		||||
			throw new IllegalArgumentException("modifier id must be lowercase");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		ChatModifier current = idToModifier.get(id);
 | 
			
		||||
		if (current != null)
 | 
			
		||||
		{
 | 
			
		||||
			return current.equals(modifier);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		idToModifier.put(id, modifier);
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static boolean unregisterModifier(ChatModifier modifier)
 | 
			
		||||
	{
 | 
			
		||||
		if (modifier == null) return false;
 | 
			
		||||
		return idToModifier.remove(modifier.getId()) != null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FORMAT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static String format(String msg, CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		// We build the return value in this string buffer
 | 
			
		||||
		StringBuffer ret = new StringBuffer();
 | 
			
		||||
		
 | 
			
		||||
		// A matcher to match all the tags in the msg
 | 
			
		||||
		Matcher matcher = pattern.matcher(msg);
 | 
			
		||||
 | 
			
		||||
		// For each tag we find
 | 
			
		||||
		while (matcher.find())
 | 
			
		||||
		{
 | 
			
		||||
			// The fullmatch is something like "{sender|lp|rp}"
 | 
			
		||||
			String fullmatch = matcher.group(0);
 | 
			
		||||
			
 | 
			
		||||
			// The submatch is something like "sender|lp|rp"
 | 
			
		||||
			String submatch = matcher.group(1);
 | 
			
		||||
			
 | 
			
		||||
			// The parts are something like ["sender", "lp", "rp"]
 | 
			
		||||
			String[] parts = submatch.split(ESC_SEPARATOR);
 | 
			
		||||
 | 
			
		||||
			// The modifier ids are something like ["lp", "rp"] and tagId something like "sender"
 | 
			
		||||
			List<String> modifierIds = new ArrayList<String>(Arrays.asList(parts));
 | 
			
		||||
			String tagId = modifierIds.remove(0);
 | 
			
		||||
			
 | 
			
		||||
			// Fetch tag for the id
 | 
			
		||||
			ChatTag tag = getTag(tagId);
 | 
			
		||||
			
 | 
			
		||||
			String replacement;
 | 
			
		||||
			if (tag == null)
 | 
			
		||||
			{
 | 
			
		||||
				// No change if tag wasn't found
 | 
			
		||||
				replacement = fullmatch;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				replacement = compute(tag, modifierIds, sender, recipient);
 | 
			
		||||
				if (replacement == null)
 | 
			
		||||
				{
 | 
			
		||||
					// If a tag or modifier returns null it's the same as opting out.
 | 
			
		||||
					replacement = fullmatch;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			matcher.appendReplacement(ret, replacement);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Append the rest
 | 
			
		||||
		matcher.appendTail(ret);
 | 
			
		||||
		
 | 
			
		||||
		// And finally we return the string value of the buffer we built
 | 
			
		||||
		return ret.toString();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// TAG COMPUTE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static String compute(ChatTag tag, List<String> modifierIds, CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		String ret = tag.getReplacement(sender, recipient);
 | 
			
		||||
		if (ret == null) return null;
 | 
			
		||||
		
 | 
			
		||||
		for (String modifierId : modifierIds)
 | 
			
		||||
		{
 | 
			
		||||
			// Find the modifier or skip
 | 
			
		||||
			ChatModifier modifier = getModifier(modifierId);
 | 
			
		||||
			if (modifier == null) continue;
 | 
			
		||||
			
 | 
			
		||||
			// Modify and ignore change if null.
 | 
			
		||||
			// Modifier can't get or return null.
 | 
			
		||||
			String modified = modifier.getModified(ret, sender, recipient);
 | 
			
		||||
			if (modified == null) continue;
 | 
			
		||||
			
 | 
			
		||||
			ret = modified;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,11 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
public interface ChatModifier
 | 
			
		||||
{
 | 
			
		||||
	public String getId();
 | 
			
		||||
	public String getModified(String subject, CommandSender sender, CommandSender recipient);
 | 
			
		||||
	public boolean register();
 | 
			
		||||
	public boolean unregister();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat;
 | 
			
		||||
 | 
			
		||||
public abstract class ChatModifierAbstract implements ChatModifier
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS & RAWDATA GET/SET
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private final String id;
 | 
			
		||||
	@Override public String getId() { return this.id; }
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDES
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean register()
 | 
			
		||||
	{
 | 
			
		||||
		return ChatFormatter.registerModifier(this);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean unregister()
 | 
			
		||||
	{
 | 
			
		||||
		return ChatFormatter.unregisterModifier(this);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public ChatModifierAbstract(final String id)
 | 
			
		||||
	{
 | 
			
		||||
		this.id = id.toLowerCase();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,11 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
public interface ChatTag
 | 
			
		||||
{
 | 
			
		||||
	public String getId();
 | 
			
		||||
	public String getReplacement(CommandSender sender, CommandSender recipient);
 | 
			
		||||
	public boolean register();
 | 
			
		||||
	public boolean unregister();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat;
 | 
			
		||||
 | 
			
		||||
public abstract class ChatTagAbstract implements ChatTag
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS & RAWDATA GET/SET
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private final String id;
 | 
			
		||||
	@Override public String getId() { return this.id; }
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDES
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean register()
 | 
			
		||||
	{
 | 
			
		||||
		return ChatFormatter.registerTag(this);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean unregister()
 | 
			
		||||
	{
 | 
			
		||||
		return ChatFormatter.unregisterTag(this);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public ChatTagAbstract(final String id)
 | 
			
		||||
	{
 | 
			
		||||
		this.id = id.toLowerCase();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.modifier;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
 | 
			
		||||
 | 
			
		||||
public class ChatModifierLc extends ChatModifierAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatModifierLc() { super("lc"); }
 | 
			
		||||
	private static ChatModifierLc i = new ChatModifierLc();
 | 
			
		||||
	public static ChatModifierLc get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getModified(String subject, CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		return subject.toLowerCase();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,29 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.modifier;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class ChatModifierLp extends ChatModifierAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatModifierLp() { super("lp"); }
 | 
			
		||||
	private static ChatModifierLp i = new ChatModifierLp();
 | 
			
		||||
	public static ChatModifierLp get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getModified(String subject, CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		if (subject.equals("")) return subject;
 | 
			
		||||
		return " "+subject;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,28 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.modifier;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class ChatModifierParse extends ChatModifierAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatModifierParse() { super("parse"); }
 | 
			
		||||
	private static ChatModifierParse i = new ChatModifierParse();
 | 
			
		||||
	public static ChatModifierParse get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getModified(String subject, CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		return Txt.parse(subject);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,28 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.modifier;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
 | 
			
		||||
 | 
			
		||||
public class ChatModifierRp extends ChatModifierAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatModifierRp() { super("rp"); }
 | 
			
		||||
	private static ChatModifierRp i = new ChatModifierRp();
 | 
			
		||||
	public static ChatModifierRp get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getModified(String subject, CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		if (subject.equals("")) return subject;
 | 
			
		||||
		return subject+" ";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.modifier;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
 | 
			
		||||
 | 
			
		||||
public class ChatModifierUc extends ChatModifierAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatModifierUc() { super("uc"); }
 | 
			
		||||
	private static ChatModifierUc i = new ChatModifierUc();
 | 
			
		||||
	public static ChatModifierUc get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getModified(String subject, CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		return subject.toUpperCase();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,28 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.modifier;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class ChatModifierUcf extends ChatModifierAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatModifierUcf() { super("ucf"); }
 | 
			
		||||
	private static ChatModifierUcf i = new ChatModifierUcf();
 | 
			
		||||
	public static ChatModifierUcf get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getModified(String subject, CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		return Txt.upperCaseFirst(subject);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,36 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.tag;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatTagAbstract;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
 | 
			
		||||
public class ChatTagName extends ChatTagAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatTagName() { super("factions_name"); }
 | 
			
		||||
	private static ChatTagName i = new ChatTagName();
 | 
			
		||||
	public static ChatTagName get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getReplacement(CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		// Get entities
 | 
			
		||||
		MPlayer usender = MPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		// No "force"
 | 
			
		||||
		Faction faction = usender.getFaction();
 | 
			
		||||
		if (faction.isNone()) return "";
 | 
			
		||||
		
 | 
			
		||||
		return faction.getName();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,33 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.tag;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatTagAbstract;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
 | 
			
		||||
public class ChatTagNameforce extends ChatTagAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatTagNameforce() { super("factions_nameforce"); }
 | 
			
		||||
	private static ChatTagNameforce i = new ChatTagNameforce();
 | 
			
		||||
	public static ChatTagNameforce get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getReplacement(CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		// Get entities
 | 
			
		||||
		MPlayer usender = MPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		Faction faction = usender.getFaction();
 | 
			
		||||
		return faction.getName();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,35 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.tag;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatTagAbstract;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
 | 
			
		||||
public class ChatTagRelcolor extends ChatTagAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatTagRelcolor() { super("factions_relcolor"); }
 | 
			
		||||
	private static ChatTagRelcolor i = new ChatTagRelcolor();
 | 
			
		||||
	public static ChatTagRelcolor get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getReplacement(CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		// Opt out if no recipient
 | 
			
		||||
		if (recipient == null) return null;
 | 
			
		||||
 | 
			
		||||
		// Get entities
 | 
			
		||||
		MPlayer usender = MPlayer.get(sender);
 | 
			
		||||
		MPlayer urecipient = MPlayer.get(recipient);
 | 
			
		||||
		
 | 
			
		||||
		return urecipient.getRelationTo(usender).getColor().toString();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,32 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.tag;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatTagAbstract;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class ChatTagRole extends ChatTagAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatTagRole() { super("factions_role"); }
 | 
			
		||||
	private static ChatTagRole i = new ChatTagRole();
 | 
			
		||||
	public static ChatTagRole get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getReplacement(CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		// Get entities
 | 
			
		||||
		MPlayer usender = MPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		return Txt.upperCaseFirst(usender.getRole().toString().toLowerCase());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,36 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.tag;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatTagAbstract;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
 | 
			
		||||
public class ChatTagRoleprefix extends ChatTagAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatTagRoleprefix() { super("factions_roleprefix"); }
 | 
			
		||||
	private static ChatTagRoleprefix i = new ChatTagRoleprefix();
 | 
			
		||||
	public static ChatTagRoleprefix get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getReplacement(CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		// Get entities
 | 
			
		||||
		MPlayer usender = MPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		// No "force"
 | 
			
		||||
		Faction faction = usender.getFaction();
 | 
			
		||||
		if (faction.isNone()) return "";
 | 
			
		||||
		
 | 
			
		||||
		return usender.getRole().getPrefix();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,31 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.tag;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatTagAbstract;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
 | 
			
		||||
public class ChatTagRoleprefixforce extends ChatTagAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatTagRoleprefixforce() { super("factions_roleprefix"); }
 | 
			
		||||
	private static ChatTagRoleprefixforce i = new ChatTagRoleprefixforce();
 | 
			
		||||
	public static ChatTagRoleprefixforce get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getReplacement(CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		// Get entities
 | 
			
		||||
		MPlayer usender = MPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		return usender.getRole().getPrefix();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,32 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.tag;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatTagAbstract;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
 | 
			
		||||
public class ChatTagTitle extends ChatTagAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private ChatTagTitle() { super("factions_title"); }
 | 
			
		||||
	private static ChatTagTitle i = new ChatTagTitle();
 | 
			
		||||
	public static ChatTagTitle get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getReplacement(CommandSender sender, CommandSender recipient)
 | 
			
		||||
	{
 | 
			
		||||
		// Get entities
 | 
			
		||||
		MPlayer usender = MPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		if (!usender.hasTitle()) return "";
 | 
			
		||||
		return usender.getTitle();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,124 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.HelpCommand;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.VersionCommand;
 | 
			
		||||
 | 
			
		||||
public class CmdFactions extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsList cmdFactionsList = new CmdFactionsList();
 | 
			
		||||
	public CmdFactionsFaction cmdFactionsFaction = new CmdFactionsFaction();
 | 
			
		||||
	public CmdFactionsPlayer cmdFactionsPlayer = new CmdFactionsPlayer();
 | 
			
		||||
	public CmdFactionsJoin cmdFactionsJoin = new CmdFactionsJoin();
 | 
			
		||||
	public CmdFactionsLeave cmdFactionsLeave = new CmdFactionsLeave();
 | 
			
		||||
	public CmdFactionsHome cmdFactionsHome = new CmdFactionsHome();
 | 
			
		||||
	public CmdFactionsMap cmdFactionsMap = new CmdFactionsMap();
 | 
			
		||||
	public CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate();
 | 
			
		||||
	public CmdFactionsName cmdFactionsName = new CmdFactionsName();
 | 
			
		||||
	public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription();
 | 
			
		||||
	public CmdFactionsMotd cmdFactionsMotd = new CmdFactionsMotd();
 | 
			
		||||
	public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome();
 | 
			
		||||
	public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome();
 | 
			
		||||
	public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite();
 | 
			
		||||
	public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick();
 | 
			
		||||
	public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle();
 | 
			
		||||
	public CmdFactionsRank cmdFactionsRank = new CmdFactionsRank();
 | 
			
		||||
	public CmdFactionsRankOld cmdFactionsRankOldLeader = new CmdFactionsRankOld("leader");
 | 
			
		||||
	public CmdFactionsRankOld cmdFactionsRankOldOfficer = new CmdFactionsRankOld("officer");
 | 
			
		||||
	public CmdFactionsRankOld cmdFactionsRankOldPromote = new CmdFactionsRankOld("promote");
 | 
			
		||||
	public CmdFactionsRankOld cmdFactionsRankOldDemote = new CmdFactionsRankOld("demote");
 | 
			
		||||
	public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
 | 
			
		||||
	public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
 | 
			
		||||
	public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
 | 
			
		||||
	public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
 | 
			
		||||
	public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
 | 
			
		||||
	public CmdFactionsAccess cmdFactionsAccess = new CmdFactionsAccess();
 | 
			
		||||
	public CmdFactionsRelationAlly cmdFactionsRelationAlly = new CmdFactionsRelationAlly();
 | 
			
		||||
	public CmdFactionsRelationTruce cmdFactionsRelationTruce = new CmdFactionsRelationTruce();
 | 
			
		||||
	public CmdFactionsRelationNeutral cmdFactionsRelationNeutral = new CmdFactionsRelationNeutral();
 | 
			
		||||
	public CmdFactionsRelationEnemy cmdFactionsRelationEnemy = new CmdFactionsRelationEnemy();
 | 
			
		||||
	public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm();
 | 
			
		||||
	public CmdFactionsFlag cmdFactionsFlag = new CmdFactionsFlag();
 | 
			
		||||
	public CmdFactionsExpansions cmdFactionsExpansions = new CmdFactionsExpansions();
 | 
			
		||||
	public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax");
 | 
			
		||||
	public CmdFactionsXPlaceholder cmdFactionsDynmap = new CmdFactionsXPlaceholder("FactionsDynmap", "dynmap");
 | 
			
		||||
	public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin();
 | 
			
		||||
	public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband();
 | 
			
		||||
	public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost();
 | 
			
		||||
	public VersionCommand cmdFactionsVersion = new VersionCommand(Factions.get(), Perm.VERSION.node, "v", "version");
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactions()
 | 
			
		||||
	{
 | 
			
		||||
		// SubCommands
 | 
			
		||||
		this.addSubCommand(HelpCommand.get());
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsList);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsFaction);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsPlayer);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsJoin);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsLeave);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsHome);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsMap);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsCreate);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsName);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsDescription);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsMotd);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsSethome);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsUnsethome);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsInvite);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsKick);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsTitle);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsRank);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsRankOldLeader);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsRankOldOfficer);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsRankOldPromote);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsRankOldDemote);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsMoney);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsSeeChunk);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsSeeChunkOld);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsClaim);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsUnclaim);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsAccess);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsRelationAlly);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsRelationTruce);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsRelationNeutral);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsRelationEnemy);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsPerm);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsFlag);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsExpansions);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsTax);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsDynmap);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsAdmin);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsDisband);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsPowerBoost);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsVersion);
 | 
			
		||||
		
 | 
			
		||||
		// Deprecated Commands
 | 
			
		||||
		this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsClaim.cmdFactionsClaimAuto, "autoclaim"));
 | 
			
		||||
		this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsUnclaim.cmdFactionsUnclaimAll, "unclaimall"));
 | 
			
		||||
		this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsFlag, "open"));
 | 
			
		||||
		this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsFaction, "show", "who"));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public List<String> getAliases()
 | 
			
		||||
	{
 | 
			
		||||
		return MConf.get().aliasesF;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsAccess extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsAccessView cmdFactionsAccessView = new CmdFactionsAccessView();
 | 
			
		||||
	public CmdFactionsAccessPlayer cmdFactionsAccessPlayer = new CmdFactionsAccessPlayer();
 | 
			
		||||
	public CmdFactionsAccessFaction cmdFactionsAccessFaction = new CmdFactionsAccessFaction();
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsAccess()
 | 
			
		||||
	{
 | 
			
		||||
		// Add SubCommands
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsAccessView);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsAccessPlayer);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsAccessFaction);
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("access");
 | 
			
		||||
		
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.ACCESS.node));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,73 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.RelationParticipator;
 | 
			
		||||
import com.massivecraft.factions.TerritoryAccess;
 | 
			
		||||
import com.massivecraft.factions.entity.BoardColl;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public abstract class CmdFactionsAccessAbstract extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public PS chunk;
 | 
			
		||||
	public TerritoryAccess ta;
 | 
			
		||||
	public Faction hostFaction;
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsAccessAbstract()
 | 
			
		||||
	{
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		chunk = PS.valueOf(me.getLocation()).getChunk(true);
 | 
			
		||||
		ta = BoardColl.get().getTerritoryAccessAt(chunk);
 | 
			
		||||
		hostFaction = ta.getHostFaction();
 | 
			
		||||
		
 | 
			
		||||
		this.innerPerform();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public abstract void innerPerform();
 | 
			
		||||
 | 
			
		||||
	public void sendAccessInfo()
 | 
			
		||||
	{
 | 
			
		||||
		sendMessage(Txt.titleize("Access at " + chunk.toString(PSFormatHumanSpace.get())));
 | 
			
		||||
		msg("<k>Host Faction: %s", hostFaction.describeTo(msender, true));
 | 
			
		||||
		msg("<k>Host Faction Allowed: %s", ta.isHostFactionAllowed() ? Txt.parse("<lime>TRUE") : Txt.parse("<rose>FALSE"));
 | 
			
		||||
		msg("<k>Granted Players: %s", describeRelationParticipators(ta.getGrantedMPlayers(), msender));
 | 
			
		||||
		msg("<k>Granted Factions: %s", describeRelationParticipators(ta.getGrantedFactions(), msender));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static String describeRelationParticipators(Collection<? extends RelationParticipator> relationParticipators, RelationParticipator observer)
 | 
			
		||||
	{
 | 
			
		||||
		if (relationParticipators.size() == 0) return Txt.parse("<silver><em>none");
 | 
			
		||||
		List<String> descriptions = new ArrayList<String>();
 | 
			
		||||
		for (RelationParticipator relationParticipator : relationParticipators)
 | 
			
		||||
		{
 | 
			
		||||
			descriptions.add(relationParticipator.describeTo(observer));
 | 
			
		||||
		}
 | 
			
		||||
		return Txt.implodeCommaAnd(descriptions, Txt.parse("<i>, "), Txt.parse(" <i>and "));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,55 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.BoardColl;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsAccessFaction()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("f", "faction");
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("faction");
 | 
			
		||||
		this.addOptionalArg("yes/no", "toggle");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.ACCESS_FACTION.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void innerPerform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		Faction faction = this.arg(0, ARFaction.get());
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isFactionIdGranted(faction.getId()));
 | 
			
		||||
		if (newValue == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		ta = ta.withFactionId(faction.getId(), newValue);
 | 
			
		||||
		BoardColl.get().setTerritoryAccessAt(chunk, ta);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		this.sendAccessInfo();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,55 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.BoardColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsAccessPlayer()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("p", "player");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("player");
 | 
			
		||||
		this.addOptionalArg("yes/no", "toggle");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.ACCESS_PLAYER.node));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void innerPerform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		MPlayer mplayer = this.arg(0, ARMPlayer.getAny());
 | 
			
		||||
		if (mplayer == null) return;
 | 
			
		||||
		
 | 
			
		||||
		Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(mplayer.getId()));
 | 
			
		||||
		if (newValue == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		ta = ta.withPlayerId(mplayer.getId(), newValue);
 | 
			
		||||
		BoardColl.get().setTerritoryAccessAt(chunk, ta);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		this.sendAccessInfo();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,31 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsAccessView extends CmdFactionsAccessAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsAccessView()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("v", "view");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.ACCESS_VIEW.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void innerPerform()
 | 
			
		||||
	{
 | 
			
		||||
		this.sendAccessInfo();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,52 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.util.IdUtil;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsAdmin extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsAdmin()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("admin");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("on/off", "flip");
 | 
			
		||||
		
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.ADMIN.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		Boolean target = this.arg(0, ARBoolean.get(), !msender.isUsingAdminMode());
 | 
			
		||||
		if (target == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		msender.setUsingAdminMode(target);		
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		String desc = Txt.parse(msender.isUsingAdminMode() ? "<g>ENABLED" : "<b>DISABLED");
 | 
			
		||||
		
 | 
			
		||||
		String messageYou = Txt.parse("<i>%s %s <i>admin bypass mode.", msender.getDisplayName(msender), desc);
 | 
			
		||||
		String messageLog = Txt.parse("<i>%s %s <i>admin bypass mode.", msender.getDisplayName(IdUtil.getConsole()), desc);
 | 
			
		||||
		
 | 
			
		||||
		msender.sendMessage(messageYou);
 | 
			
		||||
		Factions.get().log(messageLog);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,41 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsClaim extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetOne cmdFactionsClaimOne = new CmdFactionsSetOne(true);
 | 
			
		||||
	public CmdFactionsSetAuto cmdFactionsClaimAuto = new CmdFactionsSetAuto(true);
 | 
			
		||||
	public CmdFactionsSetFill cmdFactionsClaimFill = new CmdFactionsSetFill(true);
 | 
			
		||||
	public CmdFactionsSetSquare cmdFactionsClaimSquare = new CmdFactionsSetSquare(true);
 | 
			
		||||
	public CmdFactionsSetCircle cmdFactionsClaimCircle = new CmdFactionsSetCircle(true);
 | 
			
		||||
	public CmdFactionsSetAll cmdFactionsClaimAll = new CmdFactionsSetAll(true);
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsClaim()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("claim");
 | 
			
		||||
		
 | 
			
		||||
		// Add SubCommands
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsClaimOne);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsClaimAuto);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsClaimFill);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsClaimSquare);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsClaimCircle);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsClaimAll);
 | 
			
		||||
		
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.CLAIM.node));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,91 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqHasntFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsCreate;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.store.MStore;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsCreate extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsCreate()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("create");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("name");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasntFaction.get());
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.CREATE.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		String newName = this.arg(0);
 | 
			
		||||
		
 | 
			
		||||
		// Verify
 | 
			
		||||
		if (FactionColl.get().isNameTaken(newName))
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>That name is already in use.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		ArrayList<String> nameValidationErrors = FactionColl.get().validateName(newName);
 | 
			
		||||
		if (nameValidationErrors.size() > 0)
 | 
			
		||||
		{
 | 
			
		||||
			sendMessage(nameValidationErrors);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Pre-Generate Id
 | 
			
		||||
		String factionId = MStore.createId();
 | 
			
		||||
		
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsCreate createEvent = new EventFactionsCreate(sender, factionId, newName);
 | 
			
		||||
		createEvent.run();
 | 
			
		||||
		if (createEvent.isCancelled()) return;
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		Faction faction = FactionColl.get().create(factionId);
 | 
			
		||||
		faction.setName(newName);
 | 
			
		||||
		
 | 
			
		||||
		msender.setRole(Rel.LEADER);
 | 
			
		||||
		msender.setFaction(faction);
 | 
			
		||||
		
 | 
			
		||||
		EventFactionsMembershipChange joinEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.CREATE);
 | 
			
		||||
		joinEvent.run();
 | 
			
		||||
		// NOTE: join event cannot be cancelled or you'll have an empty faction
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		msg("<i>You created the faction %s", faction.getName(msender));
 | 
			
		||||
		msg("<i>You should now: %s", Factions.get().getOuterCmdFactions().cmdFactionsDescription.getUseageTemplate());
 | 
			
		||||
 | 
			
		||||
		// Log
 | 
			
		||||
		if (MConf.get().logFactionCreate)
 | 
			
		||||
		{
 | 
			
		||||
			Factions.get().log(msender.getName()+" created a new faction: "+newName);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsDescriptionChange;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.mixin.Mixin;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsDescription extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsDescription()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("desc");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("desc");
 | 
			
		||||
		this.setErrorOnToManyArgs(false);
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node));
 | 
			
		||||
		this.addRequirements(ReqHasFaction.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{	
 | 
			
		||||
		// Args
 | 
			
		||||
		String newDescription = this.argConcatFrom(0);
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		if ( ! MPerm.getPermDesc().has(msender, msenderFaction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsDescriptionChange event = new EventFactionsDescriptionChange(sender, msenderFaction, newDescription);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
		newDescription = event.getNewDescription();
 | 
			
		||||
 | 
			
		||||
		// Apply
 | 
			
		||||
		msenderFaction.setDescription(newDescription);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		for (MPlayer follower : msenderFaction.getMPlayers())
 | 
			
		||||
		{
 | 
			
		||||
			follower.msg("<i>%s <i>set your faction description to:\n%s", Mixin.getDisplayName(sender, follower), msenderFaction.getDescription());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,93 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MFlag;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsDisband;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.util.IdUtil;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsDisband extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsDisband()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("disband");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.DISBAND.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		if ( ! MPerm.getPermDisband().has(msender, faction, true)) return;
 | 
			
		||||
 | 
			
		||||
		// Verify
 | 
			
		||||
		if (faction.getFlag(MFlag.getFlagPermanent()))
 | 
			
		||||
		{
 | 
			
		||||
			msg("<i>This faction is designated as permanent, so you cannot disband it.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsDisband event = new EventFactionsDisband(me, faction);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
 | 
			
		||||
		// Merged Apply and Inform
 | 
			
		||||
		
 | 
			
		||||
		// Run event for each player in the faction
 | 
			
		||||
		for (MPlayer mplayer : faction.getMPlayers())
 | 
			
		||||
		{
 | 
			
		||||
			EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, mplayer, FactionColl.get().getNone(), MembershipChangeReason.DISBAND);
 | 
			
		||||
			membershipChangeEvent.run();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Inform
 | 
			
		||||
		for (MPlayer mplayer : faction.getMPlayersWhereOnline(true))
 | 
			
		||||
		{
 | 
			
		||||
			mplayer.msg("<h>%s<i> disbanded your faction.", msender.describeTo(mplayer));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (msenderFaction != faction)
 | 
			
		||||
		{
 | 
			
		||||
			msender.msg("<i>You disbanded <h>%s<i>." , faction.describeTo(msender));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Log
 | 
			
		||||
		if (MConf.get().logFactionDisband)
 | 
			
		||||
		{
 | 
			
		||||
			Factions.get().log(Txt.parse("<i>The faction <h>%s <i>(<h>%s<i>) was disbanded by <h>%s<i>.", faction.getName(), faction.getId(), msender.getDisplayName(IdUtil.getConsole())));
 | 
			
		||||
		}		
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		faction.detach();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,53 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsExpansions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsExpansions extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsExpansions()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("e", "expansions");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.EXPANSIONS.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsExpansions event = new EventFactionsExpansions(sender);
 | 
			
		||||
		event.run();
 | 
			
		||||
		
 | 
			
		||||
		// Title
 | 
			
		||||
		msg(Txt.titleize("Factions Expansions"));
 | 
			
		||||
		
 | 
			
		||||
		// Lines
 | 
			
		||||
		for (Entry<String, Boolean> entry : event.getExpansions().entrySet())
 | 
			
		||||
		{
 | 
			
		||||
			String name = entry.getKey();
 | 
			
		||||
			Boolean installed = entry.getValue();
 | 
			
		||||
			String format = (installed ? "<g>[X] <h>%s" : "<b>[ ] <h>%s");
 | 
			
		||||
			msg(format, name);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// URL Suggestion
 | 
			
		||||
		msg("<i>Learn all about expansions in the online documentation:");
 | 
			
		||||
		msg("<aqua>http://www.massivecraft.com/factions");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,73 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.TreeSet;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsFactionShowAsync;
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.PriorityLines;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.mixin.Mixin;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsFaction extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsFaction()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("f", "faction");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.FACTION.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		final Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		final CommandSender sender = this.sender;
 | 
			
		||||
		
 | 
			
		||||
		Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
 | 
			
		||||
		{
 | 
			
		||||
			@Override
 | 
			
		||||
			public void run()
 | 
			
		||||
			{
 | 
			
		||||
				// Event
 | 
			
		||||
				EventFactionsFactionShowAsync event = new EventFactionsFactionShowAsync(sender, faction);
 | 
			
		||||
				event.run();
 | 
			
		||||
				if (event.isCancelled()) return;
 | 
			
		||||
				
 | 
			
		||||
				// Title
 | 
			
		||||
				Mixin.messageOne(sender, Txt.titleize("Faction " + faction.getName(msender)));
 | 
			
		||||
				
 | 
			
		||||
				// Lines
 | 
			
		||||
				TreeSet<PriorityLines> priorityLiness = new TreeSet<PriorityLines>(event.getIdPriorityLiness().values());
 | 
			
		||||
				for (PriorityLines priorityLines : priorityLiness)
 | 
			
		||||
				{
 | 
			
		||||
					Mixin.messageOne(sender, priorityLines.getLines());
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,104 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMFlag;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MFlag;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsFlagChange;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsFlag extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsFlag()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("flag");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
		this.addOptionalArg("flag", "all");
 | 
			
		||||
		this.addOptionalArg("yes/no", "read");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.FLAG.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{	
 | 
			
		||||
		// Arg: Faction
 | 
			
		||||
		Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Case: Show All
 | 
			
		||||
		if ( ! this.argIsSet(1))
 | 
			
		||||
		{
 | 
			
		||||
			msg(Txt.titleize("Flags for " + faction.describeTo(msender, true)));
 | 
			
		||||
			for (MFlag mflag : MFlag.getAll())
 | 
			
		||||
			{
 | 
			
		||||
				if (!mflag.isVisible() && !msender.isUsingAdminMode()) continue;
 | 
			
		||||
				msg(mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, false));
 | 
			
		||||
			}
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Arg: MFlag
 | 
			
		||||
		MFlag mflag = this.arg(1, ARMFlag.get());
 | 
			
		||||
		if (mflag == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Case: Show One
 | 
			
		||||
		if ( ! this.argIsSet(2))
 | 
			
		||||
		{
 | 
			
		||||
			msg(Txt.titleize("Flag for " + faction.describeTo(msender, true)));
 | 
			
		||||
			msg(mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, false));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Do the sender have the right to change flags for this faction?
 | 
			
		||||
		if ( ! MPerm.getPermFlags().has(msender, faction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Is this flag editable?
 | 
			
		||||
		if (!msender.isUsingAdminMode() && !mflag.isEditable())
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>The flag <h>%s <b>is not editable.", mflag.getName());
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Arg: Target Value
 | 
			
		||||
		Boolean targetValue = this.arg(2, ARBoolean.get());
 | 
			
		||||
		if (targetValue == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsFlagChange event = new EventFactionsFlagChange(sender, faction, mflag, targetValue);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
		targetValue = event.isNewValue();
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		faction.setFlag(mflag, targetValue);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		String stateInfo = mflag.getStateDesc(faction.getFlag(mflag), true, false, true, true, true);
 | 
			
		||||
		if (msender.getFaction() != faction)
 | 
			
		||||
		{
 | 
			
		||||
			// Send message to sender
 | 
			
		||||
			msg("<h>%s <i>set a flag for <h>%s", msender.describeTo(msender, true), faction.describeTo(msender, true));
 | 
			
		||||
			msg(stateInfo);
 | 
			
		||||
		}
 | 
			
		||||
		faction.msg("<h>%s <i>set a flag for <h>%s", msender.describeTo(faction, true), faction.describeTo(faction, true));
 | 
			
		||||
		faction.msg(stateInfo);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,158 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.BoardColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.entity.MFlag;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsHomeTeleport;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.mixin.Mixin;
 | 
			
		||||
import com.massivecraft.massivecore.mixin.TeleporterException;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsHome extends FactionsCommandHome
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsHome()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("home");
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.HOME.node));
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! MConf.get().homesTeleportCommandEnabled)
 | 
			
		||||
		{
 | 
			
		||||
			msender.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
		PS home = faction.getHome();
 | 
			
		||||
		String homeDesc = "home for " + faction.describeTo(msender, false);
 | 
			
		||||
		
 | 
			
		||||
		// Any and MPerm
 | 
			
		||||
		if ( ! MPerm.getPermHome().has(msender, faction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		if (home == null)
 | 
			
		||||
		{
 | 
			
		||||
			msender.msg("<b>%s <b>does not have a home.", faction.describeTo(msender, true));
 | 
			
		||||
			
 | 
			
		||||
			if (MPerm.getPermSethome().has(msender, faction, false))
 | 
			
		||||
			{
 | 
			
		||||
				msender.msg("<i>You should:");
 | 
			
		||||
				msender.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsSethome.getUseageTemplate());
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if ( ! MConf.get().homesTeleportAllowedFromEnemyTerritory && msender.isInEnemyTerritory())
 | 
			
		||||
		{
 | 
			
		||||
			msender.msg("<b>You cannot teleport to %s <b>while in the territory of an enemy faction.", homeDesc);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if ( ! MConf.get().homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(home.getWorld()))
 | 
			
		||||
		{
 | 
			
		||||
			msender.msg("<b>You cannot teleport to %s <b>while in a different world.", homeDesc);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		
 | 
			
		||||
		Faction factionHere = BoardColl.get().getFactionAt(PS.valueOf(me.getLocation()));
 | 
			
		||||
		Location locationHere = me.getLocation().clone();
 | 
			
		||||
		
 | 
			
		||||
		// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
 | 
			
		||||
		if
 | 
			
		||||
		(
 | 
			
		||||
			MConf.get().homesTeleportAllowedEnemyDistance > 0
 | 
			
		||||
			&&
 | 
			
		||||
			factionHere.getFlag(MFlag.getFlagPvp())
 | 
			
		||||
			&&
 | 
			
		||||
			(
 | 
			
		||||
				! msender.isInOwnTerritory()
 | 
			
		||||
				||
 | 
			
		||||
				(
 | 
			
		||||
					msender.isInOwnTerritory()
 | 
			
		||||
					&&
 | 
			
		||||
					! MConf.get().homesTeleportIgnoreEnemiesIfInOwnTerritory
 | 
			
		||||
				)
 | 
			
		||||
			)
 | 
			
		||||
		)
 | 
			
		||||
		{
 | 
			
		||||
			World w = locationHere.getWorld();
 | 
			
		||||
			double x = locationHere.getX();
 | 
			
		||||
			double y = locationHere.getY();
 | 
			
		||||
			double z = locationHere.getZ();
 | 
			
		||||
 | 
			
		||||
			for (Player p : me.getServer().getOnlinePlayers())
 | 
			
		||||
			{
 | 
			
		||||
				if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
 | 
			
		||||
					continue;
 | 
			
		||||
 | 
			
		||||
				MPlayer fp = MPlayer.get(p);
 | 
			
		||||
				if (msender.getRelationTo(fp) != Rel.ENEMY)
 | 
			
		||||
					continue;
 | 
			
		||||
 | 
			
		||||
				Location l = p.getLocation();
 | 
			
		||||
				double dx = Math.abs(x - l.getX());
 | 
			
		||||
				double dy = Math.abs(y - l.getY());
 | 
			
		||||
				double dz = Math.abs(z - l.getZ());
 | 
			
		||||
				double max = MConf.get().homesTeleportAllowedEnemyDistance;
 | 
			
		||||
 | 
			
		||||
				// box-shaped distance check
 | 
			
		||||
				if (dx > max || dy > max || dz > max)
 | 
			
		||||
					continue;
 | 
			
		||||
 | 
			
		||||
				msender.msg("<b>You cannot teleport to %s <b>while an enemy is within %f blocks of you.", homeDesc, MConf.get().homesTeleportAllowedEnemyDistance);
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsHomeTeleport event = new EventFactionsHomeTeleport(sender);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			Mixin.teleport(me, home, homeDesc, sender);
 | 
			
		||||
		}
 | 
			
		||||
		catch (TeleporterException e)
 | 
			
		||||
		{
 | 
			
		||||
			me.sendMessage(e.getMessage());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,82 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsInvitedChange;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsInvite extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsInvite()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("inv", "invite");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("player");
 | 
			
		||||
		this.addOptionalArg("yes/no", "toggle");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.INVITE.node));
 | 
			
		||||
		this.addRequirements(ReqHasFaction.get());
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		MPlayer mplayer = this.arg(0, ARMPlayer.getAny());
 | 
			
		||||
		if (mplayer == null) return;
 | 
			
		||||
		
 | 
			
		||||
		Boolean newInvited = this.arg(1, ARBoolean.get(), !msenderFaction.isInvited(mplayer));
 | 
			
		||||
		if (newInvited == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Allready member?
 | 
			
		||||
		if (mplayer.getFaction() == msenderFaction)
 | 
			
		||||
		{
 | 
			
		||||
			msg("%s<i> is already a member of %s", mplayer.getName(), msenderFaction.getName());
 | 
			
		||||
			msg("<i>You might want to: " + Factions.get().getOuterCmdFactions().cmdFactionsKick.getUseageTemplate(false));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, newInvited);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
		newInvited = event.isNewInvited();
 | 
			
		||||
 | 
			
		||||
		// Apply
 | 
			
		||||
		msenderFaction.setInvited(mplayer, newInvited);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		if (newInvited)
 | 
			
		||||
		{
 | 
			
		||||
			mplayer.msg("%s<i> invited you to %s", msender.describeTo(mplayer, true), msenderFaction.describeTo(mplayer));
 | 
			
		||||
			msenderFaction.msg("%s<i> invited %s<i> to your faction.", msender.describeTo(msenderFaction, true), mplayer.describeTo(msenderFaction));
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			mplayer.msg("%s<i> revoked your invitation to <h>%s<i>.", msender.describeTo(mplayer), msenderFaction.describeTo(mplayer));
 | 
			
		||||
			msenderFaction.msg("%s<i> revoked %s's<i> invitation.", msender.describeTo(msenderFaction), mplayer.describeTo(msenderFaction));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,126 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.entity.MFlag;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsJoin extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsJoin()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("join");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("faction");
 | 
			
		||||
		this.addOptionalArg("player", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.JOIN.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		Faction faction = this.arg(0, ARFaction.get());
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
 | 
			
		||||
		MPlayer mplayer = this.arg(1, ARMPlayer.getAny(), msender);
 | 
			
		||||
		if (mplayer == null) return;
 | 
			
		||||
		Faction mplayerFaction = mplayer.getFaction();
 | 
			
		||||
		
 | 
			
		||||
		boolean samePlayer = mplayer == msender;
 | 
			
		||||
		
 | 
			
		||||
		// Validate
 | 
			
		||||
		if (!samePlayer  && ! Perm.JOIN_OTHERS.has(sender, false))
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>You do not have permission to move other players into a faction.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (faction == mplayerFaction)
 | 
			
		||||
		{
 | 
			
		||||
			msg("<i>%s <i>%s already a member of %s<i>.", mplayer.describeTo(msender, true), (samePlayer ? "are" : "is"), faction.getName(msender));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (MConf.get().factionMemberLimit > 0 && faction.getMPlayers().size() >= MConf.get().factionMemberLimit)
 | 
			
		||||
		{
 | 
			
		||||
			msg(" <b>!<white> The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(msender), MConf.get().factionMemberLimit, mplayer.describeTo(msender, false));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (mplayerFaction.isNormal())
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>%s must leave %s current faction first.", mplayer.describeTo(msender, true), (samePlayer ? "your" : "their"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0)
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>%s cannot join a faction with a negative power level.", mplayer.describeTo(msender, true));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if( ! (faction.getFlag(MFlag.getFlagOpen()) || faction.isInvited(mplayer) || msender.isUsingAdminMode() || Perm.JOIN_ANY.has(sender, false)))
 | 
			
		||||
		{
 | 
			
		||||
			msg("<i>This faction requires invitation.");
 | 
			
		||||
			if (samePlayer)
 | 
			
		||||
			{
 | 
			
		||||
				faction.msg("%s<i> tried to join your faction.", mplayer.describeTo(faction, true));
 | 
			
		||||
			}
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.JOIN);
 | 
			
		||||
		membershipChangeEvent.run();
 | 
			
		||||
		if (membershipChangeEvent.isCancelled()) return;
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		if (!samePlayer)
 | 
			
		||||
		{
 | 
			
		||||
			mplayer.msg("<i>%s <i>moved you into the faction %s<i>.", msender.describeTo(mplayer, true), faction.getName(mplayer));
 | 
			
		||||
		}
 | 
			
		||||
		faction.msg("<i>%s <i>joined <lime>your faction<i>.", mplayer.describeTo(faction, true));
 | 
			
		||||
		msender.msg("<i>%s <i>successfully joined %s<i>.", mplayer.describeTo(msender, true), faction.getName(msender));
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		mplayer.resetFactionData();
 | 
			
		||||
		mplayer.setFaction(faction);
 | 
			
		||||
	    
 | 
			
		||||
		faction.setInvited(mplayer, false);
 | 
			
		||||
 | 
			
		||||
		// Derplog
 | 
			
		||||
		if (MConf.get().logFactionJoin)
 | 
			
		||||
		{
 | 
			
		||||
			if (samePlayer)
 | 
			
		||||
			{
 | 
			
		||||
				Factions.get().log(Txt.parse("%s joined the faction %s.", mplayer.getName(), faction.getName()));
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				Factions.get().log(Txt.parse("%s moved the player %s into the faction %s.", msender.getName(), mplayer.getName(), faction.getName()));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,97 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.util.IdUtil;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsKick extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsKick()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("kick");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("player");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.KICK.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Arg
 | 
			
		||||
		MPlayer mplayer = this.arg(0, ARMPlayer.getAny());
 | 
			
		||||
		if (mplayer == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Validate
 | 
			
		||||
		if (msender == mplayer)
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>You cannot kick yourself.");
 | 
			
		||||
			msg("<i>You might want to: %s", Factions.get().getOuterCmdFactions().cmdFactionsLeave.getUseageTemplate(false));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (mplayer.getRole() == Rel.LEADER && !(this.senderIsConsole || msender.isUsingAdminMode()))
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>The leader can not be kicked.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0)
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>You cannot kick that member until their power is positive.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		Faction mplayerFaction = mplayer.getFaction();
 | 
			
		||||
		if ( ! MPerm.getPermKick().has(msender, mplayerFaction, true)) return;
 | 
			
		||||
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, mplayer, FactionColl.get().getNone(), MembershipChangeReason.KICK);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
 | 
			
		||||
		// Inform
 | 
			
		||||
		mplayerFaction.msg("%s<i> kicked %s<i> from the faction! :O", msender.describeTo(mplayerFaction, true), mplayer.describeTo(mplayerFaction, true));
 | 
			
		||||
		mplayer.msg("%s<i> kicked you from %s<i>! :O", msender.describeTo(mplayer, true), mplayerFaction.describeTo(mplayer));
 | 
			
		||||
		if (mplayerFaction != msenderFaction)
 | 
			
		||||
		{
 | 
			
		||||
			msender.msg("<i>You kicked %s<i> from the faction %s<i>!", mplayer.describeTo(msender), mplayerFaction.describeTo(msender));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (MConf.get().logFactionKick)
 | 
			
		||||
		{
 | 
			
		||||
			Factions.get().log(msender.getDisplayName(IdUtil.getConsole()) + " kicked " + mplayer.getName() + " from the faction " + mplayerFaction.getName());
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Apply
 | 
			
		||||
		if (mplayer.getRole() == Rel.LEADER)
 | 
			
		||||
		{
 | 
			
		||||
			mplayerFaction.promoteNewLeader();
 | 
			
		||||
		}
 | 
			
		||||
		mplayerFaction.setInvited(mplayer, false);
 | 
			
		||||
		mplayer.resetFactionData();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,33 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsLeave extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsLeave()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("leave");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node));
 | 
			
		||||
		this.addRequirements(ReqHasFaction.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		msender.leave();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,90 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.FactionListComparator;
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARInteger;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.mixin.Mixin;
 | 
			
		||||
import com.massivecraft.massivecore.pager.PagerSimple;
 | 
			
		||||
import com.massivecraft.massivecore.pager.Stringifier;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsList extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsList()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("l", "list");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("page", "1");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.LIST.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		final Integer pageHumanBased = this.arg(0, ARInteger.get(), 1);
 | 
			
		||||
		if (pageHumanBased == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// NOTE: The faction list is quite slow and mostly thread safe.
 | 
			
		||||
		// We run it asynchronously to spare the primary server thread.
 | 
			
		||||
		final CommandSender sender = this.sender;
 | 
			
		||||
		Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
 | 
			
		||||
		{
 | 
			
		||||
			@Override
 | 
			
		||||
			public void run()
 | 
			
		||||
			{
 | 
			
		||||
				// Create Pager
 | 
			
		||||
				final List<Faction> factions = FactionColl.get().getAll(null, FactionListComparator.get());
 | 
			
		||||
				final PagerSimple<Faction> pager = new PagerSimple<Faction>(factions, sender);
 | 
			
		||||
				
 | 
			
		||||
				// Use Pager
 | 
			
		||||
				List<String> messages = pager.getPageTxt(pageHumanBased, "Faction List", new Stringifier<Faction>() {
 | 
			
		||||
					@Override
 | 
			
		||||
					public String toString(Faction faction)
 | 
			
		||||
					{
 | 
			
		||||
						if (faction.isNone())
 | 
			
		||||
						{
 | 
			
		||||
							return Txt.parse("<i>Factionless<i> %d online", FactionColl.get().getNone().getMPlayersWhereOnline(true).size());
 | 
			
		||||
						}
 | 
			
		||||
						else
 | 
			
		||||
						{
 | 
			
		||||
							return Txt.parse("%s<i> %d/%d online, %d/%d/%d",
 | 
			
		||||
								faction.getName(msender),
 | 
			
		||||
								faction.getMPlayersWhereOnline(true).size(),
 | 
			
		||||
								faction.getMPlayers().size(),
 | 
			
		||||
								faction.getLandCount(),
 | 
			
		||||
								faction.getPowerRounded(),
 | 
			
		||||
								faction.getPowerMaxRounded()
 | 
			
		||||
							);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
				
 | 
			
		||||
				// Send Messages
 | 
			
		||||
				Mixin.messageOne(sender, messages);
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,71 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Const;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.entity.BoardColl;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsMap extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsMap()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("map");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("on/off", "once");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.MAP.node));
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! this.argIsSet(0))
 | 
			
		||||
		{
 | 
			
		||||
			showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT_FULL);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (this.arg(0, ARBoolean.get(), !msender.isMapAutoUpdating()))
 | 
			
		||||
		{
 | 
			
		||||
			// And show the map once
 | 
			
		||||
			showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT);
 | 
			
		||||
			
 | 
			
		||||
			// Turn on
 | 
			
		||||
			msender.setMapAutoUpdating(true);
 | 
			
		||||
			msg("<i>Map auto update <green>ENABLED.");
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			// Turn off
 | 
			
		||||
			msender.setMapAutoUpdating(false);
 | 
			
		||||
			msg("<i>Map auto update <red>DISABLED.");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void showMap(int width, int height)
 | 
			
		||||
	{
 | 
			
		||||
		Location location = me.getLocation();
 | 
			
		||||
		List<String> message = BoardColl.get().getMap(msenderFaction, PS.valueOf(location), location.getYaw(), width, height);
 | 
			
		||||
		sendMessage(message);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,42 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsMoney extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsMoneyBalance cmdMoneyBalance = new CmdFactionsMoneyBalance();
 | 
			
		||||
	public CmdFactionsMoneyDeposit cmdMoneyDeposit = new CmdFactionsMoneyDeposit();
 | 
			
		||||
	public CmdFactionsMoneyWithdraw cmdMoneyWithdraw = new CmdFactionsMoneyWithdraw();
 | 
			
		||||
	public CmdFactionsMoneyTransferFf cmdMoneyTransferFf = new CmdFactionsMoneyTransferFf();
 | 
			
		||||
	public CmdFactionsMoneyTransferFp cmdMoneyTransferFp = new CmdFactionsMoneyTransferFp();
 | 
			
		||||
	public CmdFactionsMoneyTransferPf cmdMoneyTransferPf = new CmdFactionsMoneyTransferPf();
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsMoney()
 | 
			
		||||
	{
 | 
			
		||||
		// Add SubCommands
 | 
			
		||||
		this.addSubCommand(this.cmdMoneyBalance);
 | 
			
		||||
		this.addSubCommand(this.cmdMoneyDeposit);
 | 
			
		||||
		this.addSubCommand(this.cmdMoneyWithdraw);
 | 
			
		||||
		this.addSubCommand(this.cmdMoneyTransferFf);
 | 
			
		||||
		this.addSubCommand(this.cmdMoneyTransferFp);
 | 
			
		||||
		this.addSubCommand(this.cmdMoneyTransferPf);
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("money");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqBankCommandsEnabled.get());
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.MONEY.node));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,44 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.integration.Econ;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsMoneyBalance extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsMoneyBalance()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("b", "balance");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node));
 | 
			
		||||
		this.addRequirements(ReqBankCommandsEnabled.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
			
 | 
			
		||||
		if (faction != msenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		Econ.sendBalanceInfo(msender, faction);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,58 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.integration.Econ;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARDouble;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.money.Money;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsMoneyDeposit extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsMoneyDeposit()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("d", "deposit");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("amount");
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node));
 | 
			
		||||
		this.addRequirements(ReqBankCommandsEnabled.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		Double amount = this.arg(0, ARDouble.get());
 | 
			
		||||
		if (amount == null) return;
 | 
			
		||||
		
 | 
			
		||||
		Faction faction = this.arg(1, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		boolean success = Econ.transferMoney(msender, msender, faction, amount);
 | 
			
		||||
		
 | 
			
		||||
		if (success && MConf.get().logMoneyTransactions)
 | 
			
		||||
		{
 | 
			
		||||
			Factions.get().log(ChatColor.stripColor(Txt.parse("%s deposited %s in the faction bank: %s", msender.getName(), Money.format(amount), faction.describeTo(null))));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,63 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.integration.Econ;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARDouble;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.money.Money;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsMoneyTransferFf extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsMoneyTransferFf()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("ff");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("amount");
 | 
			
		||||
		this.addRequiredArg("faction");
 | 
			
		||||
		this.addRequiredArg("faction");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node));
 | 
			
		||||
		this.addRequirements(ReqBankCommandsEnabled.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		Double amount = this.arg(0, ARDouble.get());
 | 
			
		||||
		if (amount == null) return;
 | 
			
		||||
		
 | 
			
		||||
		Faction from = this.arg(1, ARFaction.get());
 | 
			
		||||
		if (from == null) return;
 | 
			
		||||
		
 | 
			
		||||
		Faction to = this.arg(2, ARFaction.get());
 | 
			
		||||
		if (to == null) return;
 | 
			
		||||
		
 | 
			
		||||
		boolean success = Econ.transferMoney(msender, from, to, amount);
 | 
			
		||||
 | 
			
		||||
		if (success && MConf.get().logMoneyTransactions)
 | 
			
		||||
		{
 | 
			
		||||
			Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,65 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.integration.Econ;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARDouble;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.money.Money;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsMoneyTransferFp extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsMoneyTransferFp()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("fp");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("amount");
 | 
			
		||||
		this.addRequiredArg("faction");
 | 
			
		||||
		this.addRequiredArg("player");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node));
 | 
			
		||||
		this.addRequirements(ReqBankCommandsEnabled.get());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		Double amount = this.arg(0, ARDouble.get());
 | 
			
		||||
		if (amount == null) return;
 | 
			
		||||
		
 | 
			
		||||
		Faction from = this.arg(1, ARFaction.get());
 | 
			
		||||
		if (from == null) return;
 | 
			
		||||
		
 | 
			
		||||
		MPlayer to = this.arg(2, ARMPlayer.getAny());
 | 
			
		||||
		if (to == null) return;
 | 
			
		||||
		
 | 
			
		||||
		boolean success = Econ.transferMoney(msender, from, to, amount);
 | 
			
		||||
 | 
			
		||||
		if (success && MConf.get().logMoneyTransactions)
 | 
			
		||||
		{
 | 
			
		||||
			Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,65 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.integration.Econ;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARDouble;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.money.Money;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsMoneyTransferPf extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsMoneyTransferPf()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("pf");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("amount");
 | 
			
		||||
		this.addRequiredArg("player");
 | 
			
		||||
		this.addRequiredArg("faction");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node));
 | 
			
		||||
		this.addRequirements(ReqBankCommandsEnabled.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		Double amount = this.arg(0, ARDouble.get());
 | 
			
		||||
		if (amount == null) return;
 | 
			
		||||
		
 | 
			
		||||
		MPlayer from = this.arg(1, ARMPlayer.getAny());
 | 
			
		||||
		if (from == null) return;
 | 
			
		||||
		
 | 
			
		||||
		Faction to = this.arg(2, ARFaction.get());
 | 
			
		||||
		if (to == null) return;
 | 
			
		||||
		
 | 
			
		||||
		boolean success = Econ.transferMoney(msender, from, to, amount);
 | 
			
		||||
 | 
			
		||||
		if (success && MConf.get().logMoneyTransactions)
 | 
			
		||||
		{
 | 
			
		||||
			Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,62 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.integration.Econ;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARDouble;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.money.Money;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsMoneyWithdraw extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsMoneyWithdraw()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("w", "withdraw");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("amount");
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node));
 | 
			
		||||
		this.addRequirements(ReqBankCommandsEnabled.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		Double amount = this.arg(0, ARDouble.get());
 | 
			
		||||
		if (amount == null) return;
 | 
			
		||||
		
 | 
			
		||||
		Faction from = this.arg(1, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (from == null) return;
 | 
			
		||||
		
 | 
			
		||||
		MPlayer to = msender;
 | 
			
		||||
		
 | 
			
		||||
		boolean success = Econ.transferMoney(msender, from, to, amount);
 | 
			
		||||
 | 
			
		||||
		if (success && MConf.get().logMoneyTransactions)
 | 
			
		||||
		{
 | 
			
		||||
			Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", msender.getName(), Money.format(amount), from.describeTo(null))));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,94 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsMotdChange;
 | 
			
		||||
import com.massivecraft.massivecore.MassiveCore;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.mixin.Mixin;
 | 
			
		||||
import com.massivecraft.massivecore.util.MUtil;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsMotd extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsMotd()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("motd");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("new", "read");
 | 
			
		||||
		this.setErrorOnToManyArgs(false);
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.MOTD.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{	
 | 
			
		||||
		// Read
 | 
			
		||||
		if ( ! this.argIsSet(0))
 | 
			
		||||
		{
 | 
			
		||||
			sendMessage(msenderFaction.getMotdMessages());
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		if ( ! MPerm.getPermMotd().has(msender, msenderFaction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		String target = this.argConcatFrom(0);
 | 
			
		||||
		target = target.trim();
 | 
			
		||||
		target = Txt.parse(target);
 | 
			
		||||
		
 | 
			
		||||
		// Removal
 | 
			
		||||
		if (target != null && MassiveCore.NOTHING_REMOVE.contains(target))
 | 
			
		||||
		{
 | 
			
		||||
			target = null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Get Old
 | 
			
		||||
		String old = null;
 | 
			
		||||
		if (msenderFaction.hasMotd())
 | 
			
		||||
		{
 | 
			
		||||
			old = msenderFaction.getMotd();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Target Desc
 | 
			
		||||
		String targetDesc = target;
 | 
			
		||||
		if (targetDesc == null) targetDesc = Txt.parse("<silver>nothing");
 | 
			
		||||
		
 | 
			
		||||
		// NoChange
 | 
			
		||||
		if (MUtil.equals(old, target))
 | 
			
		||||
		{
 | 
			
		||||
			msg("<i>The motd for %s <i>is already: <h>%s", msenderFaction.describeTo(msender, true), target);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsMotdChange event = new EventFactionsMotdChange(sender, msenderFaction, target);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
		target = event.getNewMotd();
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		msenderFaction.setMotd(target);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		for (MPlayer follower : msenderFaction.getMPlayers())
 | 
			
		||||
		{
 | 
			
		||||
			follower.msg("<i>%s <i>set your faction motd to:\n%s", Mixin.getDisplayName(sender, follower), msenderFaction.getMotd());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,81 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsNameChange;
 | 
			
		||||
import com.massivecraft.factions.util.MiscUtil;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsName extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsName()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("name");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("new name");
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.NAME.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		String newName = this.arg(0);
 | 
			
		||||
		
 | 
			
		||||
		Faction faction = this.arg(1, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		if ( ! MPerm.getPermName().has(msender, faction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// TODO does not first test cover selfcase?
 | 
			
		||||
		if (FactionColl.get().isNameTaken(newName) && ! MiscUtil.getComparisonString(newName).equals(faction.getComparisonName()))
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>That name is already taken");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		ArrayList<String> errors = new ArrayList<String>();
 | 
			
		||||
		errors.addAll(FactionColl.get().validateName(newName));
 | 
			
		||||
		if (errors.size() > 0)
 | 
			
		||||
		{
 | 
			
		||||
			sendMessage(errors);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsNameChange event = new EventFactionsNameChange(sender, faction, newName);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
		newName = event.getNewName();
 | 
			
		||||
 | 
			
		||||
		// Apply
 | 
			
		||||
		faction.setName(newName);
 | 
			
		||||
 | 
			
		||||
		// Inform
 | 
			
		||||
		faction.msg("%s<i> changed your faction name to %s", msender.describeTo(faction, true), faction.getName(faction));
 | 
			
		||||
		if (msenderFaction != faction)
 | 
			
		||||
		{
 | 
			
		||||
			msg("<i>You changed the faction name to %s", faction.getName(msender));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,111 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPerm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARRel;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsPerm extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsPerm()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("perm");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
		this.addOptionalArg("perm", "all");
 | 
			
		||||
		this.addOptionalArg("relation", "read");
 | 
			
		||||
		this.addOptionalArg("yes/no", "read");
 | 
			
		||||
		this.setErrorOnToManyArgs(false);
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.PERM.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Arg: Faction
 | 
			
		||||
		Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Case: Show All
 | 
			
		||||
		if ( ! this.argIsSet(1))
 | 
			
		||||
		{
 | 
			
		||||
			msg(Txt.titleize("Perms for " + faction.describeTo(msender, true)));
 | 
			
		||||
			msg(MPerm.getStateHeaders());
 | 
			
		||||
			for (MPerm perm : MPerm.getAll())
 | 
			
		||||
			{
 | 
			
		||||
				msg(perm.getStateInfo(faction.getPermitted(perm), true));
 | 
			
		||||
			}
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Arg: MPerm
 | 
			
		||||
		MPerm mperm = this.arg(1, ARMPerm.get());
 | 
			
		||||
		if (mperm == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Case: Show One
 | 
			
		||||
		if ( ! this.argIsSet(2))
 | 
			
		||||
		{
 | 
			
		||||
			msg(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
 | 
			
		||||
			msg(MPerm.getStateHeaders());
 | 
			
		||||
			msg(mperm.getStateInfo(faction.getPermitted(mperm), true));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Do the sender have the right to change perms for this faction?
 | 
			
		||||
		if ( ! MPerm.getPermPerms().has(msender, faction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Is this perm editable?
 | 
			
		||||
		if (!msender.isUsingAdminMode() && !mperm.isEditable())
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>The perm <h>%s <b>is not editable.", mperm.getName());
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Arg: Rel
 | 
			
		||||
		Rel rel = this.arg(2, ARRel.get());
 | 
			
		||||
		if (rel == null) return;
 | 
			
		||||
		
 | 
			
		||||
		if ( ! this.argIsSet(3))
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>Should <h>%s <b>have the <h>%s <b>permission or not?\nYou must <h>add \"yes\" or \"no\" <b>at the end.", Txt.getNicedEnum(rel), Txt.upperCaseFirst(mperm.getName()));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Arg: Target Value
 | 
			
		||||
		Boolean targetValue = this.arg(3, ARBoolean.get(), null);
 | 
			
		||||
		if (targetValue == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		faction.setRelationPermitted(mperm, rel, targetValue);
 | 
			
		||||
		
 | 
			
		||||
		// The following is to make sure the leader always has the right to change perms if that is our goal.
 | 
			
		||||
		if (mperm == MPerm.getPermPerms() && MPerm.getPermPerms().getStandard().contains(Rel.LEADER))
 | 
			
		||||
		{
 | 
			
		||||
			faction.setRelationPermitted(MPerm.getPermPerms(), Rel.LEADER, true);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		msg(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
 | 
			
		||||
		msg(MPerm.getStateHeaders());
 | 
			
		||||
		msg(mperm.getStateInfo(faction.getPermitted(mperm), true));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,114 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.LinkedHashMap;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsRemovePlayerMillis;
 | 
			
		||||
import com.massivecraft.massivecore.Progressbar;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.util.TimeDiffUtil;
 | 
			
		||||
import com.massivecraft.massivecore.util.TimeUnit;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsPlayer extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsPlayer()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("p", "player");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("player", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.PLAYER.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		MPlayer mplayer = this.arg(0, ARMPlayer.getAny(), msender);
 | 
			
		||||
		if (mplayer == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// INFO: Title
 | 
			
		||||
		msg(Txt.titleize("Player " + mplayer.describeTo(msender)));
 | 
			
		||||
		
 | 
			
		||||
		// INFO: Power (as progress bar)
 | 
			
		||||
		double progressbarQuota = 0;
 | 
			
		||||
		double playerPowerMax = mplayer.getPowerMax();
 | 
			
		||||
		if (playerPowerMax != 0)
 | 
			
		||||
		{
 | 
			
		||||
			progressbarQuota = mplayer.getPower() / playerPowerMax;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		int progressbarWidth = (int) Math.round(mplayer.getPowerMax() / mplayer.getPowerMaxUniversal() * 100);
 | 
			
		||||
		msg("<a>Power: <v>%s", Progressbar.HEALTHBAR_CLASSIC.withQuota(progressbarQuota).withWidth(progressbarWidth).render());
 | 
			
		||||
				
 | 
			
		||||
		// INFO: Power (as digits)
 | 
			
		||||
		msg("<a>Power: <v>%.2f / %.2f", mplayer.getPower(), mplayer.getPowerMax());
 | 
			
		||||
		
 | 
			
		||||
		// INFO: Power Boost
 | 
			
		||||
		if (mplayer.hasPowerBoost())
 | 
			
		||||
		{
 | 
			
		||||
			double powerBoost = mplayer.getPowerBoost();
 | 
			
		||||
			String powerBoostType = (powerBoost > 0 ? "bonus" : "penalty");
 | 
			
		||||
			msg("<a>Power Boost: <v>%f <i>(a manually granted %s)", powerBoost, powerBoostType);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// INFO: Power per Hour
 | 
			
		||||
		// If the player is not at maximum we wan't to display how much time left.
 | 
			
		||||
		
 | 
			
		||||
		String stringTillMax = "";
 | 
			
		||||
		double powerTillMax = mplayer.getPowerMax() - mplayer.getPower();
 | 
			
		||||
		if (powerTillMax > 0)
 | 
			
		||||
		{
 | 
			
		||||
			long millisTillMax = (long) (powerTillMax * TimeUnit.MILLIS_PER_HOUR / mplayer.getPowerPerHour());
 | 
			
		||||
			LinkedHashMap<TimeUnit, Long> unitcountsTillMax = TimeDiffUtil.unitcounts(millisTillMax, TimeUnit.getAllButMillis());
 | 
			
		||||
			unitcountsTillMax = TimeDiffUtil.limit(unitcountsTillMax, 2);
 | 
			
		||||
			String unitcountsTillMaxFormated = TimeDiffUtil.formatedVerboose(unitcountsTillMax, "<i>");
 | 
			
		||||
			stringTillMax = Txt.parse(" <i>(%s <i>left till max)", unitcountsTillMaxFormated);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		msg("<a>Power per Hour: <v>%.2f%s", mplayer.getPowerPerHour(), stringTillMax);
 | 
			
		||||
		
 | 
			
		||||
		// INFO: Power per Death
 | 
			
		||||
		msg("<a>Power per Death: <v>%.2f", mplayer.getPowerPerDeath());
 | 
			
		||||
		
 | 
			
		||||
		// Display automatic kick / remove info if the system is in use
 | 
			
		||||
		if (MConf.get().removePlayerMillisDefault <= 0) return;
 | 
			
		||||
		
 | 
			
		||||
		EventFactionsRemovePlayerMillis event = new EventFactionsRemovePlayerMillis(false, mplayer);
 | 
			
		||||
		event.run();
 | 
			
		||||
		msg("<i>Automatic removal after %s <i>of inactivity:", format(event.getMillis()));
 | 
			
		||||
		for (Entry<String, Long> causeMillis : event.getCauseMillis().entrySet())
 | 
			
		||||
		{
 | 
			
		||||
			String cause = causeMillis.getKey();
 | 
			
		||||
			long millis = causeMillis.getValue();
 | 
			
		||||
			msg("<a>%s<a>: <v>%s", cause, format(millis));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// TIME FORMAT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static String format(long millis)
 | 
			
		||||
	{
 | 
			
		||||
		LinkedHashMap<TimeUnit, Long> unitcounts = TimeDiffUtil.unitcounts(millis, TimeUnit.getAllBut(TimeUnit.MILLISECOND, TimeUnit.WEEK, TimeUnit.MONTH));
 | 
			
		||||
		return TimeDiffUtil.formatedVerboose(unitcounts);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,78 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARDouble;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsPowerBoost extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsPowerBoost()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("powerboost");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("p|f|player|faction");
 | 
			
		||||
		this.addRequiredArg("name");
 | 
			
		||||
		this.addRequiredArg("#");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		String type = this.arg(0).toLowerCase();
 | 
			
		||||
		boolean doPlayer = true;
 | 
			
		||||
		if (type.equals("f") || type.equals("faction"))
 | 
			
		||||
		{
 | 
			
		||||
			doPlayer = false;
 | 
			
		||||
		}
 | 
			
		||||
		else if (!type.equals("p") && !type.equals("player"))
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>You must specify \"p\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction.");
 | 
			
		||||
			msg("<b>ex. /f powerboost p SomePlayer 0.5  -or-  /f powerboost f SomeFaction -5");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		Double targetPower = this.arg(2, ARDouble.get());
 | 
			
		||||
		if (targetPower == null) return;
 | 
			
		||||
 | 
			
		||||
		String target;
 | 
			
		||||
 | 
			
		||||
		if (doPlayer)
 | 
			
		||||
		{
 | 
			
		||||
			MPlayer targetPlayer = this.arg(1, ARMPlayer.getAny());
 | 
			
		||||
			if (targetPlayer == null) return;
 | 
			
		||||
			
 | 
			
		||||
			targetPlayer.setPowerBoost(targetPower);
 | 
			
		||||
			target = "Player \""+targetPlayer.getName()+"\"";
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			Faction targetFaction = this.arg(1, ARFaction.get());
 | 
			
		||||
			if (targetFaction == null) return;
 | 
			
		||||
			
 | 
			
		||||
			targetFaction.setPowerBoost(targetPower);
 | 
			
		||||
			target = "Faction \""+targetFaction.getName()+"\"";
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		msg("<i>"+target+" now has a power bonus/penalty of "+targetPower+" to min and max power levels.");
 | 
			
		||||
		Factions.get().log(msender.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+".");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,346 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARRank;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.entity.MFlag;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayerColl;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsRankChange;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.util.IdUtil;
 | 
			
		||||
import com.massivecraft.massivecore.util.MUtil;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsRank extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTANTS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	// The rank required to do any rank changes.
 | 
			
		||||
	final static Rel rankReq = Rel.OFFICER;
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// These fields are set upon perform() and unset afterwards.
 | 
			
		||||
	
 | 
			
		||||
	// Target
 | 
			
		||||
	private Faction targetFaction = null;
 | 
			
		||||
	private MPlayer target = null;
 | 
			
		||||
	
 | 
			
		||||
	// Roles
 | 
			
		||||
	private Rel senderRank = null;
 | 
			
		||||
	private Rel targetRank = null;
 | 
			
		||||
	private Rel rank = null;
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsRank()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("rank");
 | 
			
		||||
	
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("player", "you");
 | 
			
		||||
		this.addOptionalArg("action", "show");
 | 
			
		||||
	
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.RANK.node));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// This sets target and much other. Returns false if not succeeded.
 | 
			
		||||
		if ( ! this.registerFields())
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
			
 | 
			
		||||
		// Sometimes we just want to show the rank.
 | 
			
		||||
		if ( ! this.argIsSet(1))
 | 
			
		||||
		{
 | 
			
		||||
			if ( ! Perm.RANK_SHOW.has(sender, true))
 | 
			
		||||
			{
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			this.showRank();
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Permission check.
 | 
			
		||||
		if ( ! Perm.RANK_ACTION.has(sender, true))
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Is the player allowed or not. Method can be found later down.
 | 
			
		||||
		if ( ! this.isPlayerAllowed())
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Does the change make sense.
 | 
			
		||||
		if ( ! this.isChangeRequired())
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		EventFactionsRankChange event = new EventFactionsRankChange(sender, target, rank);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
		rank = event.getNewRank();
 | 
			
		||||
		
 | 
			
		||||
		// Change the rank.
 | 
			
		||||
		this.changeRank();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// This is always run after performing a MassiveCommand.
 | 
			
		||||
	@Override
 | 
			
		||||
	public void unsetSenderVars()
 | 
			
		||||
	{
 | 
			
		||||
		super.unsetSenderVars();
 | 
			
		||||
		this.unregisterFields();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// PRIVATE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	private boolean registerFields()
 | 
			
		||||
	{
 | 
			
		||||
		// Getting the target and faction.
 | 
			
		||||
		target = this.arg(0, ARMPlayer.getAny(), msender);
 | 
			
		||||
		if (null == target) return false;
 | 
			
		||||
		targetFaction = target.getFaction();
 | 
			
		||||
		
 | 
			
		||||
		// Rank if any passed.
 | 
			
		||||
		if (this.argIsSet(1))
 | 
			
		||||
		{
 | 
			
		||||
			rank = this.arg(1, ARRank.get(target.getRole()));
 | 
			
		||||
			if (null == rank) return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Ranks
 | 
			
		||||
		senderRank = msender.getRole();
 | 
			
		||||
		targetRank = target.getRole();
 | 
			
		||||
		
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void unregisterFields()
 | 
			
		||||
	{
 | 
			
		||||
		targetFaction = null;
 | 
			
		||||
		target = null;
 | 
			
		||||
		
 | 
			
		||||
		senderRank = null;
 | 
			
		||||
		targetRank = null;
 | 
			
		||||
		rank = null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void showRank()
 | 
			
		||||
	{
 | 
			
		||||
		String targetName = target.describeTo(msender, true);
 | 
			
		||||
		String isAre = target == msender ? "are" : "is";
 | 
			
		||||
		String theAan = targetRank == Rel.LEADER ? "the" : Txt.aan(targetRank.name());
 | 
			
		||||
		String rankName = Txt.getNicedEnum(targetRank).toLowerCase();
 | 
			
		||||
		String ofIn = targetRank == Rel.LEADER ? "of" : "in";
 | 
			
		||||
		String factionName = targetFaction.describeTo(msender, true);
 | 
			
		||||
		if (targetFaction == msenderFaction)
 | 
			
		||||
		{
 | 
			
		||||
			factionName = factionName.toLowerCase();
 | 
			
		||||
		}
 | 
			
		||||
		msg("%s <i>%s %s <h>%s <i>%s %s<i>.", targetName, isAre, theAan, rankName, ofIn, factionName);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private boolean isPlayerAllowed()
 | 
			
		||||
	{
 | 
			
		||||
		// People with permission don't follow the normal rules.
 | 
			
		||||
		if (msender.isUsingAdminMode())
 | 
			
		||||
		{
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// If somone gets the leadership of wilderness (Which has happened before).
 | 
			
		||||
		// We can at least try to limit their powers.
 | 
			
		||||
		if (targetFaction.isNone())
 | 
			
		||||
		{
 | 
			
		||||
			msg("%s <b>doesn't use ranks sorry :(", targetFaction.getName() );
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (targetFaction != msenderFaction)
 | 
			
		||||
		{
 | 
			
		||||
			// Don't change ranks outside of your faction.
 | 
			
		||||
			msg("%s <b>is not in the same faction as you.", target.describeTo(msender));
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (target == msender)
 | 
			
		||||
		{
 | 
			
		||||
			// Don't change your own rank.
 | 
			
		||||
			msg("<b>The target player mustn't be yourself.");
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		if (senderRank.isLessThan(rankReq))
 | 
			
		||||
		{
 | 
			
		||||
			// You need a specific rank to change ranks.
 | 
			
		||||
			msg("<b>You must be %s or higher to change ranks.", Txt.getNicedEnum(rankReq).toLowerCase());
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// The following two if statements could be merged. 
 | 
			
		||||
		// But isn't for the sake of nicer error messages.
 | 
			
		||||
		if (senderRank == targetRank)
 | 
			
		||||
		{
 | 
			
		||||
			// You can't change someones rank if it is equal to yours.
 | 
			
		||||
			msg("<b>%s can't manage eachother.", Txt.getNicedEnum(rankReq)+"s");
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (senderRank.isLessThan(targetRank))
 | 
			
		||||
		{
 | 
			
		||||
			// You can't change someones rank if it is higher than yours.
 | 
			
		||||
			msg("<b>You can't manage people of higher rank.");
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (senderRank.isAtMost(rank) && senderRank != Rel.LEADER)
 | 
			
		||||
		{
 | 
			
		||||
			// You can't set ranks equal to or higer than your own. Unless you are the leader.
 | 
			
		||||
			msg("<b>You can't set ranks higher than or equal to your own.");
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// If it wasn't cancelled above, player is allowed.
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private boolean isChangeRequired()
 | 
			
		||||
	{
 | 
			
		||||
		// Just a nice msg. It would however be caught by an if statement below.
 | 
			
		||||
		if (target.getRole() == Rel.RECRUIT && arg(1).equalsIgnoreCase("demote"))
 | 
			
		||||
		{
 | 
			
		||||
			msg("%s <b>is already recruit.", target.describeTo(msender));
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Just a nice msg. It would however be caught by an if statement below.
 | 
			
		||||
		if (target.getRole() == Rel.LEADER && arg(1).equalsIgnoreCase("promote"))
 | 
			
		||||
		{
 | 
			
		||||
			msg("%s <b>is already leader.", target.describeTo(msender));
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// There must be a change, else it is all waste of time.
 | 
			
		||||
		if (target.getRole() == rank)
 | 
			
		||||
		{
 | 
			
		||||
			msg("%s <b>already has that rank.", target.describeTo(msender));
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void changeRank()
 | 
			
		||||
	{
 | 
			
		||||
		// In case of leadership change, we do special things not done in other rank changes.
 | 
			
		||||
		if (rank == Rel.LEADER)
 | 
			
		||||
		{
 | 
			
		||||
			this.changeRankLeader();
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			this.changeRankOther();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void changeRankLeader()
 | 
			
		||||
	{
 | 
			
		||||
		// If there is a current leader. Demote & inform them.
 | 
			
		||||
		MPlayer targetFactionCurrentLeader = targetFaction.getLeader();
 | 
			
		||||
		if (targetFactionCurrentLeader != null)
 | 
			
		||||
		{
 | 
			
		||||
			// Inform & demote the old leader.
 | 
			
		||||
			targetFactionCurrentLeader.setRole(Rel.OFFICER);
 | 
			
		||||
			if (targetFactionCurrentLeader != msender)
 | 
			
		||||
			{
 | 
			
		||||
				// They kinda know if they fired the command themself.
 | 
			
		||||
				targetFactionCurrentLeader.msg("<i>You have been demoted from the position of faction leader by %s<i>.", msender.describeTo(targetFactionCurrentLeader, true));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Inform & promote the new leader.
 | 
			
		||||
		target.setRole(Rel.LEADER);
 | 
			
		||||
		if (target != msender)
 | 
			
		||||
		{
 | 
			
		||||
			// They kinda know if they fired the command themself.
 | 
			
		||||
			target.msg("<i>You have been promoted to the position of faction leader by %s<i>.", msender.describeTo(target, true));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Inform the msg sender
 | 
			
		||||
		msg("<i>You have promoted %s<i> to the position of faction leader.", target.describeTo(msender, true));
 | 
			
		||||
		
 | 
			
		||||
		// Inform everyone
 | 
			
		||||
		for (MPlayer recipient : MPlayerColl.get().getAllOnline())
 | 
			
		||||
		{
 | 
			
		||||
			String changerName = senderIsConsole ? "A server admin" : msender.describeTo(recipient);
 | 
			
		||||
			recipient.msg("%s<i> gave %s<i> the leadership of %s<i>.", changerName, target.describeTo(recipient), targetFaction.describeTo(recipient));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void changeRankOther()
 | 
			
		||||
	{
 | 
			
		||||
		// If the target is currently the leader and faction isn't permanent...
 | 
			
		||||
		if (targetRank == Rel.LEADER && !MConf.get().permanentFactionsDisableLeaderPromotion && targetFaction.getFlag(MFlag.ID_PERMANENT))
 | 
			
		||||
		{
 | 
			
		||||
			// ...we must promote a new one.
 | 
			
		||||
			targetFaction.promoteNewLeader();
 | 
			
		||||
		}
 | 
			
		||||
		// But if still no leader exists...
 | 
			
		||||
		if (targetFaction.getLeader() == null && ! targetFaction.getFlag(MFlag.ID_PERMANENT))
 | 
			
		||||
		{
 | 
			
		||||
			// ...we will disband it.
 | 
			
		||||
			// I'm kinda lazy, so I just make the console perform the command.
 | 
			
		||||
			Factions.get().getOuterCmdFactions().cmdFactionsDisband.execute(IdUtil.getConsole(), MUtil.list( targetFaction.getName() ));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		List<MPlayer> recipients = targetFaction.getMPlayers();
 | 
			
		||||
		if ( ! recipients.contains(msender))
 | 
			
		||||
		{
 | 
			
		||||
			recipients.add(msender);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Were they demoted or promoted?
 | 
			
		||||
		String change = (rank.isLessThan(targetRank) ? "demoted" : "promoted");
 | 
			
		||||
		
 | 
			
		||||
		// The rank will be set before the msg, so they have the appropriate prefix.
 | 
			
		||||
		target.setRole(rank);
 | 
			
		||||
		String oldRankName = Txt.getNicedEnum(targetRank).toLowerCase();
 | 
			
		||||
		String rankName = Txt.getNicedEnum(rank).toLowerCase();
 | 
			
		||||
 | 
			
		||||
		for(MPlayer recipient : recipients)
 | 
			
		||||
		{
 | 
			
		||||
			String targetName = target.describeTo(recipient, true);
 | 
			
		||||
			String wasWere = recipient == target ? "were" : "was";
 | 
			
		||||
			recipient.msg("%s<i> %s %s from %s to <h>%s <i>in %s<i>.", targetName, wasWere, change, oldRankName, rankName, targetFaction.describeTo(msender));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,44 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.VisibilityMode;
 | 
			
		||||
import com.massivecraft.massivecore.util.MUtil;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsRankOld extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
		
 | 
			
		||||
	public final String rankName;
 | 
			
		||||
		
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsRankOld(String rank)
 | 
			
		||||
	{
 | 
			
		||||
		// Fields
 | 
			
		||||
		this.rankName = rank.toLowerCase();
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases(rankName);
 | 
			
		||||
	
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("player");
 | 
			
		||||
		
 | 
			
		||||
		// VisibilityMode
 | 
			
		||||
		this.setVisibilityMode(VisibilityMode.INVISIBLE);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		Factions.get().getOuterCmdFactions().cmdFactionsRank.execute(sender, MUtil.list(this.arg(0), this.rankName));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,107 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.factions.entity.MFlag;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsRelationChange;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
public abstract class CmdFactionsRelationAbstract extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	public Rel targetRelation;
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsRelationAbstract()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addRequiredArg("faction");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
 | 
			
		||||
		this.addRequirements(ReqHasFaction.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		Faction otherFaction = this.arg(0, ARFaction.get());
 | 
			
		||||
		if (otherFaction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		Rel newRelation = targetRelation;
 | 
			
		||||
		
 | 
			
		||||
		/*if ( ! them.isNormal())
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>Nope! You can't.");
 | 
			
		||||
			return;
 | 
			
		||||
		}*/
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		if ( ! MPerm.getPermRel().has(msender, msenderFaction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Verify
 | 
			
		||||
		
 | 
			
		||||
		if (otherFaction == msenderFaction)
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>Nope! You can't declare a relation to yourself :)");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (msenderFaction.getRelationWish(otherFaction) == newRelation)
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>You already have that relation wish set with %s.", otherFaction.getName());
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsRelationChange event = new EventFactionsRelationChange(sender, msenderFaction, otherFaction, newRelation);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
		newRelation = event.getNewRelation();
 | 
			
		||||
 | 
			
		||||
		// try to set the new relation
 | 
			
		||||
		msenderFaction.setRelationWish(otherFaction, newRelation);
 | 
			
		||||
		Rel currentRelation = msenderFaction.getRelationTo(otherFaction, true);
 | 
			
		||||
 | 
			
		||||
		// if the relation change was successful
 | 
			
		||||
		if (newRelation == currentRelation)
 | 
			
		||||
		{
 | 
			
		||||
			otherFaction.msg("%s<i> is now %s.", msenderFaction.describeTo(otherFaction, true), newRelation.getDescFactionOne());
 | 
			
		||||
			msenderFaction.msg("%s<i> is now %s.", otherFaction.describeTo(msenderFaction, true), newRelation.getDescFactionOne());
 | 
			
		||||
		}
 | 
			
		||||
		// inform the other faction of your request
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			otherFaction.msg("%s<i> wishes to be %s.", msenderFaction.describeTo(otherFaction, true), newRelation.getColor()+newRelation.getDescFactionOne());
 | 
			
		||||
			otherFaction.msg("<i>Type <c>/"+MConf.get().aliasesF.get(0)+" "+newRelation+" "+msenderFaction.getName()+"<i> to accept.");
 | 
			
		||||
			msenderFaction.msg("%s<i> were informed that you wish to be %s<i>.", otherFaction.describeTo(msenderFaction, true), newRelation.getColor()+newRelation.getDescFactionOne());
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// TODO: The ally case should work!!
 | 
			
		||||
		//   * this might have to be bumped up to make that happen, & allow ALLY,NEUTRAL only
 | 
			
		||||
		if ( newRelation != Rel.TRUCE && otherFaction.getFlag(MFlag.getFlagPeaceful()))
 | 
			
		||||
		{
 | 
			
		||||
			otherFaction.msg("<i>This will have no effect while your faction is peaceful.");
 | 
			
		||||
			msenderFaction.msg("<i>This will have no effect while their faction is peaceful.");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if ( newRelation != Rel.TRUCE && msenderFaction.getFlag(MFlag.getFlagPeaceful()))
 | 
			
		||||
		{
 | 
			
		||||
			otherFaction.msg("<i>This will have no effect while their faction is peaceful.");
 | 
			
		||||
			msenderFaction.msg("<i>This will have no effect while your faction is peaceful.");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,20 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsRelationAlly extends CmdFactionsRelationAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsRelationAlly()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("ally");
 | 
			
		||||
		
 | 
			
		||||
		// Misc
 | 
			
		||||
		this.targetRelation = Rel.ALLY;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,20 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsRelationEnemy extends CmdFactionsRelationAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsRelationEnemy()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("enemy");
 | 
			
		||||
		
 | 
			
		||||
		// Misc
 | 
			
		||||
		this.targetRelation = Rel.ENEMY;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,20 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsRelationNeutral extends CmdFactionsRelationAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsRelationNeutral()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("neutral");
 | 
			
		||||
		
 | 
			
		||||
		// Misc
 | 
			
		||||
		this.targetRelation = Rel.NEUTRAL;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,20 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsRelationTruce extends CmdFactionsRelationAbstract
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsRelationTruce()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("truce");
 | 
			
		||||
		
 | 
			
		||||
		// Misc
 | 
			
		||||
		this.targetRelation = Rel.TRUCE;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,56 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsSeeChunk extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSeeChunk()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("sc", "seechunk");
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("active", "toggle");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.SEECHUNK.node));
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		boolean old = msender.isSeeingChunk();
 | 
			
		||||
		boolean targetDefault = !old;
 | 
			
		||||
		Boolean target = this.arg(0, ARBoolean.get(), targetDefault);
 | 
			
		||||
		if (target == null) return;
 | 
			
		||||
		String targetDesc = Txt.parse(target ? "<g>ON": "<b>OFF");
 | 
			
		||||
		
 | 
			
		||||
		// NoChange
 | 
			
		||||
		if (target.equals(old))
 | 
			
		||||
		{
 | 
			
		||||
			msg("<i>See Chunk is already %s<i>.", targetDesc);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		msender.setSeeingChunk(target);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		msg("<i>See Chunk is now %s<i>.", targetDesc);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,80 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.util.VisualizeUtil;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsSeeChunkOld extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSeeChunkOld()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("sco", "seechunkold");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.SEECHUNKOLD.node));
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		World world = me.getWorld();
 | 
			
		||||
		PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
 | 
			
		||||
		int chunkX = chunk.getChunkX();
 | 
			
		||||
		int chunkZ = chunk.getChunkZ();
 | 
			
		||||
		
 | 
			
		||||
		// Apply
 | 
			
		||||
		int blockX;
 | 
			
		||||
		int blockZ;
 | 
			
		||||
		
 | 
			
		||||
		blockX = chunkX*16;
 | 
			
		||||
		blockZ = chunkZ*16;
 | 
			
		||||
		showPillar(me, world, blockX, blockZ);
 | 
			
		||||
		
 | 
			
		||||
		blockX = chunkX*16 + 15;
 | 
			
		||||
		blockZ = chunkZ*16;
 | 
			
		||||
		showPillar(me, world, blockX, blockZ);
 | 
			
		||||
		
 | 
			
		||||
		blockX = chunkX*16;
 | 
			
		||||
		blockZ = chunkZ*16 + 15;
 | 
			
		||||
		showPillar(me, world, blockX, blockZ);
 | 
			
		||||
		
 | 
			
		||||
		blockX = chunkX*16 + 15;
 | 
			
		||||
		blockZ = chunkZ*16 + 15;
 | 
			
		||||
		showPillar(me, world, blockX, blockZ);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		msg("<i>Visualized %s", chunk.toString(PSFormatHumanSpace.get()));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@SuppressWarnings("deprecation")
 | 
			
		||||
	public static void showPillar(Player player, World world, int blockX, int blockZ)
 | 
			
		||||
	{
 | 
			
		||||
		for (int blockY = 0; blockY < world.getMaxHeight(); blockY++)
 | 
			
		||||
		{
 | 
			
		||||
			Location loc = new Location(world, blockX, blockY, blockZ);
 | 
			
		||||
			if (loc.getBlock().getType() != Material.AIR) continue;
 | 
			
		||||
			int typeId = blockY % 5 == 0 ? Material.GLOWSTONE.getId() : Material.GLASS.getId();
 | 
			
		||||
			VisualizeUtil.addLocation(player, loc, typeId);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,91 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.entity.Board;
 | 
			
		||||
import com.massivecraft.factions.entity.BoardColl;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARWorldId;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.mixin.Mixin;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
import com.massivecraft.massivecore.util.MUtil;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsSetAll extends CmdFactionsSetXAll
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetAll(boolean claim)
 | 
			
		||||
	{
 | 
			
		||||
		// Super
 | 
			
		||||
		super(claim);
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("all");
 | 
			
		||||
		
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
		String node = claim ? Perm.CLAIM_ALL.node : Perm.UNCLAIM_ALL.node;
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Set<PS> getChunks()
 | 
			
		||||
	{
 | 
			
		||||
		// World
 | 
			
		||||
		String word = (this.isClaim() ? "claim" : "unclaim");
 | 
			
		||||
		
 | 
			
		||||
		// Create Ret
 | 
			
		||||
		Set<PS> chunks = null;
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		Faction oldFaction = this.getOldFaction();
 | 
			
		||||
		if (oldFaction == null) return null;
 | 
			
		||||
		
 | 
			
		||||
		if (MUtil.list("a", "al", "all").contains(this.arg(0).toLowerCase()))
 | 
			
		||||
		{
 | 
			
		||||
			chunks = BoardColl.get().getChunks(oldFaction);
 | 
			
		||||
			this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using " + word + " all.");
 | 
			
		||||
			this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks using " + word + " all.");
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			String worldId = null;
 | 
			
		||||
			if (MUtil.list("map").contains(this.arg(0).toLowerCase()))
 | 
			
		||||
			{
 | 
			
		||||
				if (me != null)
 | 
			
		||||
				{
 | 
			
		||||
					worldId = me.getWorld().getName();
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					msg("<b>You must specify which map from console.");
 | 
			
		||||
					return null;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				worldId = this.arg(0, ARWorldId.get());
 | 
			
		||||
				if (worldId == null) return null;
 | 
			
		||||
			}
 | 
			
		||||
			Board board = BoardColl.get().get(worldId);
 | 
			
		||||
			chunks = board.getChunks(oldFaction);
 | 
			
		||||
			String worldDisplayName = Mixin.getWorldDisplayName(worldId);
 | 
			
		||||
			this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using " + word + " <h>" + worldDisplayName + "<i>.");
 | 
			
		||||
			this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks using " + word + " <h>" + worldDisplayName + "<i>.");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Return Ret
 | 
			
		||||
		return chunks;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,91 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsSetAuto extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private boolean claim = true;
 | 
			
		||||
	public boolean isClaim() { return this.claim; }
 | 
			
		||||
	public void setClaim(boolean claim) { this.claim = claim; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetAuto(boolean claim)
 | 
			
		||||
	{
 | 
			
		||||
		// Fields
 | 
			
		||||
		this.setClaim(claim);
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("a", "auto");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		if (claim)
 | 
			
		||||
		{
 | 
			
		||||
			this.addOptionalArg("faction", "you");
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
		String node = claim ? Perm.CLAIM_AUTO.node : Perm.UNCLAIM_AUTO.node;
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{	
 | 
			
		||||
		// Args
 | 
			
		||||
		final Faction newFaction;
 | 
			
		||||
		if (claim)
 | 
			
		||||
		{
 | 
			
		||||
			newFaction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			newFaction = FactionColl.get().getNone();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Disable?
 | 
			
		||||
		if (newFaction == null || newFaction == msender.getAutoClaimFaction())
 | 
			
		||||
		{
 | 
			
		||||
			msender.setAutoClaimFaction(null);
 | 
			
		||||
			msg("<i>Disabled auto-setting as you walk around.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// MPerm Preemptive Check
 | 
			
		||||
		if (newFaction.isNormal() && ! MPerm.getPermTerritory().has(msender, newFaction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Apply / Inform
 | 
			
		||||
		msender.setAutoClaimFaction(newFaction);
 | 
			
		||||
		msg("<i>Now auto-setting <h>%s<i> land.", newFaction.describeTo(msender));
 | 
			
		||||
		
 | 
			
		||||
		// Chunks
 | 
			
		||||
		final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
 | 
			
		||||
		Set<PS> chunks = Collections.singleton(chunk);		
 | 
			
		||||
		
 | 
			
		||||
		// Apply / Inform
 | 
			
		||||
		msender.tryClaim(newFaction, chunks);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,70 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.LinkedHashSet;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsSetCircle extends CmdFactionsSetXRadius
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetCircle(boolean claim)
 | 
			
		||||
	{
 | 
			
		||||
		// Super
 | 
			
		||||
		super(claim);
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("c", "circle");
 | 
			
		||||
 | 
			
		||||
		// Format
 | 
			
		||||
		this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk %s<i> using circle.");
 | 
			
		||||
		this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks near %s<i> using circle.");
 | 
			
		||||
		
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
		String node = claim ? Perm.CLAIM_CIRCLE.node : Perm.UNCLAIM_CIRCLE.node;
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Set<PS> getChunks()
 | 
			
		||||
	{
 | 
			
		||||
		// Common Startup
 | 
			
		||||
		final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
 | 
			
		||||
		final Set<PS> chunks = new LinkedHashSet<PS>();
 | 
			
		||||
		
 | 
			
		||||
		chunks.add(chunk); // The center should come first for pretty messages
 | 
			
		||||
		
 | 
			
		||||
		Integer radiusZero = this.getRadiusZero();
 | 
			
		||||
		if (radiusZero == null) return null;
 | 
			
		||||
		
 | 
			
		||||
		double radiusSquared = radiusZero * radiusZero;
 | 
			
		||||
		
 | 
			
		||||
		for (int dx = -radiusZero; dx <= radiusZero; dx++)
 | 
			
		||||
		{
 | 
			
		||||
			for (int dz = -radiusZero; dz <= radiusZero; dz++)
 | 
			
		||||
			{
 | 
			
		||||
				if (dx*dx + dz*dz > radiusSquared) continue;
 | 
			
		||||
				
 | 
			
		||||
				int x = chunk.getChunkX() + dx;
 | 
			
		||||
				int z = chunk.getChunkZ() + dz;
 | 
			
		||||
				
 | 
			
		||||
				chunks.add(chunk.withChunkX(x).withChunkZ(z));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return chunks;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,115 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.LinkedHashSet;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.entity.BoardColl;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
import com.massivecraft.massivecore.util.MUtil;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsSetFill extends CmdFactionsSetXSimple
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetFill(boolean claim)
 | 
			
		||||
	{
 | 
			
		||||
		// Super
 | 
			
		||||
		super(claim);
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("f", "fill");
 | 
			
		||||
 | 
			
		||||
		// Format
 | 
			
		||||
		this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk %s<i> using fill.");
 | 
			
		||||
		this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks near %s<i> using fill.");
 | 
			
		||||
		
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
		String node = claim ? Perm.CLAIM_FILL.node : Perm.UNCLAIM_FILL.node;
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Set<PS> getChunks()
 | 
			
		||||
	{
 | 
			
		||||
		// Common Startup
 | 
			
		||||
		final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
 | 
			
		||||
		final Set<PS> chunks = new LinkedHashSet<PS>();
 | 
			
		||||
		
 | 
			
		||||
		// What faction (aka color) resides there?
 | 
			
		||||
		// NOTE: Wilderness/None is valid. 
 | 
			
		||||
		final Faction color = BoardColl.get().getFactionAt(chunk);
 | 
			
		||||
		
 | 
			
		||||
		// We start where we are!
 | 
			
		||||
		chunks.add(chunk);
 | 
			
		||||
		
 | 
			
		||||
		// Flood!
 | 
			
		||||
		int max = MConf.get().setFillMax;
 | 
			
		||||
		floodSearch(chunks, color, max);
 | 
			
		||||
		
 | 
			
		||||
		// Limit Reached?
 | 
			
		||||
		if (chunks.size() >= max)
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>Fill limit of <h>%d <b>reached.", max);
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// OK!
 | 
			
		||||
		return chunks;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FLOOD FILL
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static void floodSearch(Set<PS> set, Faction color, int max)
 | 
			
		||||
	{
 | 
			
		||||
		// Clean
 | 
			
		||||
		if (set == null) throw new NullPointerException("set");
 | 
			
		||||
		if (color == null) throw new NullPointerException("color");
 | 
			
		||||
		
 | 
			
		||||
		// Expand
 | 
			
		||||
		Set<PS> expansion = new LinkedHashSet<PS>();
 | 
			
		||||
		for (PS chunk : set)
 | 
			
		||||
		{
 | 
			
		||||
			Set<PS> neighbours = MUtil.set(
 | 
			
		||||
				chunk.withChunkX(chunk.getChunkX() + 1),
 | 
			
		||||
				chunk.withChunkX(chunk.getChunkX() - 1),
 | 
			
		||||
				chunk.withChunkZ(chunk.getChunkZ() + 1),
 | 
			
		||||
				chunk.withChunkZ(chunk.getChunkZ() - 1)
 | 
			
		||||
			);
 | 
			
		||||
			
 | 
			
		||||
			for (PS neighbour : neighbours)
 | 
			
		||||
			{
 | 
			
		||||
				if (set.contains(neighbour)) continue;
 | 
			
		||||
				Faction faction = BoardColl.get().getFactionAt(neighbour);
 | 
			
		||||
				if (faction == null) continue;
 | 
			
		||||
				if (faction != color) continue;
 | 
			
		||||
				expansion.add(neighbour);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		set.addAll(expansion);
 | 
			
		||||
		
 | 
			
		||||
		// No Expansion?
 | 
			
		||||
		if (expansion.isEmpty()) return;
 | 
			
		||||
		
 | 
			
		||||
		// Reached Max?
 | 
			
		||||
		if (set.size() >= max) return;
 | 
			
		||||
		
 | 
			
		||||
		// Recurse
 | 
			
		||||
		floodSearch(set, color, max);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,44 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsSetOne extends CmdFactionsSetXSimple
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetOne(boolean claim)
 | 
			
		||||
	{
 | 
			
		||||
		// Super
 | 
			
		||||
		super(claim);
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("o", "one");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
		String node = claim ? Perm.CLAIM_ONE.node : Perm.UNCLAIM_ONE.node;
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public Set<PS> getChunks()
 | 
			
		||||
	{
 | 
			
		||||
		final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
 | 
			
		||||
		final Set<PS> chunks = Collections.singleton(chunk);
 | 
			
		||||
		return chunks;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,66 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.LinkedHashSet;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsSetSquare extends CmdFactionsSetXRadius
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetSquare(boolean claim)
 | 
			
		||||
	{
 | 
			
		||||
		// Super
 | 
			
		||||
		super(claim);
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("s", "square");
 | 
			
		||||
 | 
			
		||||
		// Format
 | 
			
		||||
		this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk %s<i> using square.");
 | 
			
		||||
		this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks near %s<i> using square.");
 | 
			
		||||
		
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
		String node = claim ? Perm.CLAIM_SQUARE.node : Perm.UNCLAIM_SQUARE.node;
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(node));		
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Set<PS> getChunks()
 | 
			
		||||
	{
 | 
			
		||||
		// Common Startup
 | 
			
		||||
		final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
 | 
			
		||||
		final Set<PS> chunks = new LinkedHashSet<PS>();
 | 
			
		||||
		
 | 
			
		||||
		chunks.add(chunk); // The center should come first for pretty messages
 | 
			
		||||
		
 | 
			
		||||
		Integer radiusZero = this.getRadiusZero();
 | 
			
		||||
		if (radiusZero == null) return null;
 | 
			
		||||
		
 | 
			
		||||
		for (int dx = -radiusZero; dx <= radiusZero; dx++)
 | 
			
		||||
		{
 | 
			
		||||
			for (int dz = -radiusZero; dz <= radiusZero; dz++)
 | 
			
		||||
			{
 | 
			
		||||
				int x = chunk.getChunkX() + dx;
 | 
			
		||||
				int z = chunk.getChunkZ() + dz;
 | 
			
		||||
				
 | 
			
		||||
				chunks.add(chunk.withChunkX(x).withChunkZ(z));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return chunks;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,82 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public abstract class CmdFactionsSetX extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private String formatOne = null;
 | 
			
		||||
	public String getFormatOne() { return this.formatOne; }
 | 
			
		||||
	public void setFormatOne(String formatOne) { this.formatOne = formatOne; }
 | 
			
		||||
	
 | 
			
		||||
	private String formatMany = null;
 | 
			
		||||
	public String getFormatMany() { return this.formatMany; }
 | 
			
		||||
	public void setFormatMany(String formatMany) { this.formatMany = formatMany; }
 | 
			
		||||
	
 | 
			
		||||
	private boolean claim = true;
 | 
			
		||||
	public boolean isClaim() { return this.claim; }
 | 
			
		||||
	public void setClaim(boolean claim) { this.claim = claim; }
 | 
			
		||||
	
 | 
			
		||||
	private int factionArgIndex = 0;
 | 
			
		||||
	public int getFactionArgIndex() { return this.factionArgIndex; }
 | 
			
		||||
	public void setFactionArgIndex(int factionArgIndex) { this.factionArgIndex = factionArgIndex; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetX(boolean claim)
 | 
			
		||||
	{
 | 
			
		||||
		this.setClaim(claim);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{	
 | 
			
		||||
		// Args
 | 
			
		||||
		final Faction newFaction = this.getNewFaction();
 | 
			
		||||
		if (newFaction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		final Set<PS> chunks = this.getChunks();
 | 
			
		||||
		if (chunks == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Apply / Inform
 | 
			
		||||
		msender.tryClaim(newFaction, chunks, this.getFormatOne(), this.getFormatMany());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// ABSTRACT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public abstract Set<PS> getChunks();
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// EXTRAS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public Faction getNewFaction()
 | 
			
		||||
	{
 | 
			
		||||
		if (this.isClaim())
 | 
			
		||||
		{
 | 
			
		||||
			return this.arg(this.getFactionArgIndex(), ARFaction.get(), msenderFaction);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			return FactionColl.get().getNone();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,36 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
 | 
			
		||||
public abstract class CmdFactionsSetXAll extends CmdFactionsSetX
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetXAll(boolean claim)
 | 
			
		||||
	{
 | 
			
		||||
		// Super
 | 
			
		||||
		super(claim);
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("all|map");
 | 
			
		||||
		this.addRequiredArg("faction");
 | 
			
		||||
		if (claim)
 | 
			
		||||
		{
 | 
			
		||||
			this.addRequiredArg("newfaction");
 | 
			
		||||
			this.setFactionArgIndex(2);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// EXTRAS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public Faction getOldFaction()
 | 
			
		||||
	{
 | 
			
		||||
		return this.arg(1, ARFaction.get());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARInteger;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetXRadius(boolean claim)
 | 
			
		||||
	{
 | 
			
		||||
		// Super
 | 
			
		||||
		super(claim);
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("radius", "1");
 | 
			
		||||
		if (claim)
 | 
			
		||||
		{
 | 
			
		||||
			this.addOptionalArg("faction", "you");
 | 
			
		||||
			this.setFactionArgIndex(1);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// EXTRAS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public Integer getRadius()
 | 
			
		||||
	{
 | 
			
		||||
		Integer radius = this.arg(0, ARInteger.get(), 1);
 | 
			
		||||
		if (radius == null) return radius;
 | 
			
		||||
		
 | 
			
		||||
		// Radius Claim Min
 | 
			
		||||
		if (radius < 1)
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>If you specify a radius, it must be at least 1.");
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Radius Claim Max
 | 
			
		||||
		if (radius > MConf.get().setRadiusMax && ! msender.isUsingAdminMode())
 | 
			
		||||
		{
 | 
			
		||||
			msg("<b>The maximum radius allowed is <h>%s<b>.", MConf.get().setRadiusMax);
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return radius;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public Integer getRadiusZero()
 | 
			
		||||
	{
 | 
			
		||||
		Integer ret = this.getRadius();
 | 
			
		||||
		if (ret == null) return ret;
 | 
			
		||||
		return ret - 1;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,22 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
public abstract class CmdFactionsSetXSimple extends CmdFactionsSetX
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetXSimple(boolean claim)
 | 
			
		||||
	{
 | 
			
		||||
		// Super
 | 
			
		||||
		super(claim);
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		if (claim)
 | 
			
		||||
		{
 | 
			
		||||
			this.addOptionalArg("faction", "you");
 | 
			
		||||
			this.setFactionArgIndex(0);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,73 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsHomeChange;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsSethome extends FactionsCommandHome
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSethome()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("sethome");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node));
 | 
			
		||||
		this.addRequirements(ReqIsPlayer.get());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		PS newHome = PS.valueOf(me.getLocation());
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Verify
 | 
			
		||||
		if (!msender.isUsingAdminMode() && !faction.isValidHome(newHome))
 | 
			
		||||
		{
 | 
			
		||||
			msender.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsHomeChange event = new EventFactionsHomeChange(sender, faction, newHome);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
		newHome = event.getNewHome();
 | 
			
		||||
 | 
			
		||||
		// Apply
 | 
			
		||||
		faction.setHome(newHome);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		faction.msg("%s<i> set the home for your faction. You can now use:", msender.describeTo(msenderFaction, true));
 | 
			
		||||
		faction.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsHome.getUseageTemplate());
 | 
			
		||||
		if (faction != msenderFaction)
 | 
			
		||||
		{
 | 
			
		||||
			msender.msg("<i>You have set the home for " + faction.getName(msender) + "<i>.");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,72 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsTitleChange;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARString;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsTitle extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsTitle()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("title");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addRequiredArg("player");
 | 
			
		||||
		this.addOptionalArg("title", "");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.TITLE.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		MPlayer you = this.arg(0, ARMPlayer.getAny());
 | 
			
		||||
		if (you == null) return;
 | 
			
		||||
		
 | 
			
		||||
		String newTitle = this.argConcatFrom(1, ARString.get(), "");
 | 
			
		||||
		if (newTitle == null) return;
 | 
			
		||||
		
 | 
			
		||||
		newTitle = Txt.parse(newTitle);
 | 
			
		||||
		if (!Perm.TITLE_COLOR.has(sender, false))
 | 
			
		||||
		{
 | 
			
		||||
			newTitle = ChatColor.stripColor(newTitle);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// MPerm
 | 
			
		||||
		if ( ! MPerm.getPermTitle().has(msender, you.getFaction(), true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// Verify
 | 
			
		||||
		if ( ! canIAdministerYou(msender, you)) return;
 | 
			
		||||
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
		newTitle = event.getNewTitle();
 | 
			
		||||
 | 
			
		||||
		// Apply
 | 
			
		||||
		you.setTitle(newTitle);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		msenderFaction.msg("%s<i> changed a title: %s", msender.describeTo(msenderFaction, true), you.describeTo(msenderFaction, true));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,41 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsUnclaim extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsSetOne cmdFactionsUnclaimOne = new CmdFactionsSetOne(false);
 | 
			
		||||
	public CmdFactionsSetAuto cmdFactionsUnclaimAuto = new CmdFactionsSetAuto(false);
 | 
			
		||||
	public CmdFactionsSetFill cmdFactionsUnclaimFill = new CmdFactionsSetFill(false);
 | 
			
		||||
	public CmdFactionsSetSquare cmdFactionsUnclaimSquare = new CmdFactionsSetSquare(false);
 | 
			
		||||
	public CmdFactionsSetCircle cmdFactionsUnclaimCircle = new CmdFactionsSetCircle(false);
 | 
			
		||||
	public CmdFactionsSetAll cmdFactionsUnclaimAll = new CmdFactionsSetAll(false);
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsUnclaim()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("unclaim");
 | 
			
		||||
		
 | 
			
		||||
		// Add SubCommands
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsUnclaimOne);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsUnclaimAuto);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsUnclaimFill);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsUnclaimSquare);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsUnclaimCircle);
 | 
			
		||||
		this.addSubCommand(this.cmdFactionsUnclaimAll);
 | 
			
		||||
		
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,65 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Perm;
 | 
			
		||||
import com.massivecraft.factions.cmd.arg.ARFaction;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsHomeChange;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsUnsethome extends FactionsCommandHome
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsUnsethome()
 | 
			
		||||
	{
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases("unsethome");
 | 
			
		||||
 | 
			
		||||
		// Args
 | 
			
		||||
		this.addOptionalArg("faction", "you");
 | 
			
		||||
 | 
			
		||||
		// Requirements
 | 
			
		||||
		this.addRequirements(ReqHasPerm.get(Perm.UNSETHOME.node));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		// Args
 | 
			
		||||
		Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
 | 
			
		||||
		if (faction == null) return;
 | 
			
		||||
		
 | 
			
		||||
		// Any and MPerm
 | 
			
		||||
		if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;
 | 
			
		||||
		
 | 
			
		||||
		// NoChange
 | 
			
		||||
		if ( ! faction.hasHome())
 | 
			
		||||
		{
 | 
			
		||||
			msender.msg("<i>%s <i>does already not have a home.", faction.describeTo(msender));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Event
 | 
			
		||||
		EventFactionsHomeChange event = new EventFactionsHomeChange(sender, faction, null);
 | 
			
		||||
		event.run();
 | 
			
		||||
		if (event.isCancelled()) return;
 | 
			
		||||
 | 
			
		||||
		// Apply
 | 
			
		||||
		faction.setHome(null);
 | 
			
		||||
		
 | 
			
		||||
		// Inform
 | 
			
		||||
		faction.msg("%s<i> unset the home for your faction.", msender.describeTo(msenderFaction, true));
 | 
			
		||||
		if (faction != msenderFaction)
 | 
			
		||||
		{
 | 
			
		||||
			msender.msg("<i>You have unset the home for " + faction.getName(msender) + "<i>.");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,45 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.massivecore.cmd.MassiveCommand;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.VisibilityMode;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsXDeprecated extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public MassiveCommand target;
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsXDeprecated(MassiveCommand target, String... aliases)
 | 
			
		||||
	{
 | 
			
		||||
		// Fields
 | 
			
		||||
		this.target = target;
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases(aliases);
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		this.setErrorOnToManyArgs(false);
 | 
			
		||||
		
 | 
			
		||||
		// Visibility
 | 
			
		||||
		this.setVisibilityMode(VisibilityMode.INVISIBLE);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{	
 | 
			
		||||
		msg("<i>Use this new command instead:");
 | 
			
		||||
		sendMessage(target.getUseageTemplate(true));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,42 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsXPlaceholder extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public String extensionName;
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public CmdFactionsXPlaceholder(String extensionName, String... aliases)
 | 
			
		||||
	{
 | 
			
		||||
		// Fields
 | 
			
		||||
		this.extensionName = extensionName;
 | 
			
		||||
		
 | 
			
		||||
		// Aliases
 | 
			
		||||
		this.addAliases(aliases);
 | 
			
		||||
		
 | 
			
		||||
		// Desc
 | 
			
		||||
		this.setDesc("Use " + extensionName);
 | 
			
		||||
		
 | 
			
		||||
		// Args
 | 
			
		||||
		this.setErrorOnToManyArgs(false);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void perform()
 | 
			
		||||
	{
 | 
			
		||||
		msg("<b>The extension <h>%s <b>isn't installed.", this.extensionName);
 | 
			
		||||
		msg("<g>Learn more and download the extension here:");
 | 
			
		||||
		msg("<aqua>http://www.massivecraft.com/%s", this.extensionName.toLowerCase());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,77 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.MassiveCommand;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class FactionsCommand extends MassiveCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public MPlayer msender;
 | 
			
		||||
	public Faction msenderFaction;
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void fixSenderVars()
 | 
			
		||||
	{
 | 
			
		||||
		this.msender = MPlayer.get(sender);
 | 
			
		||||
		this.msenderFaction = this.msender.getFaction();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void unsetSenderVars()
 | 
			
		||||
	{
 | 
			
		||||
		this.msender = null;
 | 
			
		||||
		this.msenderFaction = null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// COMMONLY USED LOGIC
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public boolean canIAdministerYou(MPlayer i, MPlayer you)
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! i.getFaction().equals(you.getFaction()))
 | 
			
		||||
		{
 | 
			
		||||
			i.sendMessage(Txt.parse("%s <b>is not in the same faction as you.",you.describeTo(i, true)));
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (i.getRole().isMoreThan(you.getRole()) || i.getRole().equals(Rel.LEADER) )
 | 
			
		||||
		{
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (you.getRole().equals(Rel.LEADER))
 | 
			
		||||
		{
 | 
			
		||||
			i.sendMessage(Txt.parse("<b>Only the faction leader can do that."));
 | 
			
		||||
		}
 | 
			
		||||
		else if (i.getRole().equals(Rel.OFFICER))
 | 
			
		||||
		{
 | 
			
		||||
			if ( i == you )
 | 
			
		||||
			{
 | 
			
		||||
				return true; //Moderators can control themselves
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				i.sendMessage(Txt.parse("<b>Officers can't control each other..."));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			i.sendMessage(Txt.parse("<b>You must be a faction officer to do that."));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,28 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.cmd.req.ReqFactionHomesEnabled;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.VisibilityMode;
 | 
			
		||||
 | 
			
		||||
public class FactionsCommandHome extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public FactionsCommandHome()
 | 
			
		||||
	{
 | 
			
		||||
		this.addRequirements(ReqFactionHomesEnabled.get());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public VisibilityMode getVisibilityMode()
 | 
			
		||||
	{
 | 
			
		||||
		return MConf.get().homesEnabled ? super.getVisibilityMode() : VisibilityMode.INVISIBLE;  
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,63 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd.arg;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.massivecore.MassiveCore;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ArgReaderAbstract;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ArgResult;
 | 
			
		||||
import com.massivecraft.massivecore.util.IdUtil;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class ARFaction extends ArgReaderAbstract<Faction>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static ARFaction i = new ARFaction();
 | 
			
		||||
	public static ARFaction get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public ArgResult<Faction> read(String str, CommandSender sender)
 | 
			
		||||
	{
 | 
			
		||||
		ArgResult<Faction> result = new ArgResult<Faction>();
 | 
			
		||||
		
 | 
			
		||||
		// Nothing/Remove targets Wilderness
 | 
			
		||||
		if (MassiveCore.NOTHING_REMOVE.contains(str))
 | 
			
		||||
		{
 | 
			
		||||
			result.setResult(FactionColl.get().getNone());
 | 
			
		||||
			return result;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Faction Id Exact
 | 
			
		||||
		if (FactionColl.get().containsId(str))
 | 
			
		||||
		{
 | 
			
		||||
			result.setResult(FactionColl.get().get(str));
 | 
			
		||||
			if (result.hasResult()) return result;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Faction Name Exact
 | 
			
		||||
		result.setResult(FactionColl.get().getByName(str));
 | 
			
		||||
		if (result.hasResult()) return result;
 | 
			
		||||
		
 | 
			
		||||
		// MPlayer Name Exact
 | 
			
		||||
		String id = IdUtil.getId(str);
 | 
			
		||||
		MPlayer mplayer = MPlayer.get(id);
 | 
			
		||||
		if (mplayer != null)
 | 
			
		||||
		{
 | 
			
		||||
			result.setResult(mplayer.getFaction());
 | 
			
		||||
			return result;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		result.setErrors(Txt.parse("<b>No faction or player matching \"<p>%s<b>\".", str));
 | 
			
		||||
		return result;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,88 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd.arg;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.MFlag;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class ARMFlag extends ARAbstractSelect<MFlag>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static ARMFlag i = new ARMFlag();
 | 
			
		||||
	public static ARMFlag get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String typename()
 | 
			
		||||
	{
 | 
			
		||||
		return "faction flag";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public MFlag select(String arg, CommandSender sender)
 | 
			
		||||
	{
 | 
			
		||||
		if (arg == null) return null;
 | 
			
		||||
		arg = getComparable(arg);
 | 
			
		||||
		
 | 
			
		||||
		// Algorithmic General Detection
 | 
			
		||||
		int startswithCount = 0;
 | 
			
		||||
		MFlag startswith = null;
 | 
			
		||||
		for (MFlag mflag : MFlag.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			String comparable = getComparable(mflag);
 | 
			
		||||
			if (comparable.equals(arg)) return mflag;
 | 
			
		||||
			if (comparable.startsWith(arg))
 | 
			
		||||
			{
 | 
			
		||||
				startswith = mflag;
 | 
			
		||||
				startswithCount++;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (startswithCount == 1)
 | 
			
		||||
		{
 | 
			
		||||
			return startswith;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Nothing found
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public Collection<String> altNames(CommandSender sender)
 | 
			
		||||
	{
 | 
			
		||||
		List<String> ret = new ArrayList<String>(); 
 | 
			
		||||
		
 | 
			
		||||
		for (MFlag mflag : MFlag.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			ret.add(Txt.upperCaseFirst(mflag.getName()));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// UTIL
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static String getComparable(String string)
 | 
			
		||||
	{
 | 
			
		||||
		return string.toLowerCase();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static String getComparable(MFlag mflag)
 | 
			
		||||
	{
 | 
			
		||||
		return getComparable(mflag.getName());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,88 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd.arg;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class ARMPerm extends ARAbstractSelect<MPerm>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private static ARMPerm i = new ARMPerm();
 | 
			
		||||
	public static ARMPerm get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String typename()
 | 
			
		||||
	{
 | 
			
		||||
		return "faction permission";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public MPerm select(String arg, CommandSender sender)
 | 
			
		||||
	{
 | 
			
		||||
		if (arg == null) return null;
 | 
			
		||||
		arg = getComparable(arg);
 | 
			
		||||
		
 | 
			
		||||
		// Algorithmic General Detection
 | 
			
		||||
		int startswithCount = 0;
 | 
			
		||||
		MPerm startswith = null;
 | 
			
		||||
		for (MPerm mperm : MPerm.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			String comparable = getComparable(mperm);
 | 
			
		||||
			if (comparable.equals(arg)) return mperm;
 | 
			
		||||
			if (comparable.startsWith(arg))
 | 
			
		||||
			{
 | 
			
		||||
				startswith = mperm;
 | 
			
		||||
				startswithCount++;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (startswithCount == 1)
 | 
			
		||||
		{
 | 
			
		||||
			return startswith;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Nothing found
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public Collection<String> altNames(CommandSender sender)
 | 
			
		||||
	{
 | 
			
		||||
		List<String> ret = new ArrayList<String>(); 
 | 
			
		||||
		
 | 
			
		||||
		for (MPerm mperm : MPerm.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			ret.add(Txt.upperCaseFirst(mperm.getName()));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// UTIL
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static String getComparable(String string)
 | 
			
		||||
	{
 | 
			
		||||
		return string.toLowerCase();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static String getComparable(MPerm mperm)
 | 
			
		||||
	{
 | 
			
		||||
		return getComparable(mperm.getName());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,23 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd.arg;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayerColl;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ArgReader;
 | 
			
		||||
 | 
			
		||||
public class ARMPlayer
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	public static ArgReader<MPlayer> getAny()
 | 
			
		||||
	{
 | 
			
		||||
		return MPlayerColl.get().getAREntity();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static ArgReader<MPlayer> getOnline()
 | 
			
		||||
	{
 | 
			
		||||
		return MPlayerColl.get().getAREntity(true);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@@ -1,144 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.cmd.arg;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Rel;
 | 
			
		||||
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
 | 
			
		||||
import com.massivecraft.massivecore.mixin.Mixin;
 | 
			
		||||
import com.massivecraft.massivecore.util.MUtil;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
public class ARRank extends ARAbstractSelect<Rel>
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// INSTANCE & CONSTRUCT
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	// Default constructor. Can't use promote and demote.
 | 
			
		||||
	private static ARRank i = new ARRank();
 | 
			
		||||
	public static ARRank get() { return i; }
 | 
			
		||||
	
 | 
			
		||||
	public ARRank()
 | 
			
		||||
	{
 | 
			
		||||
		this.startRank = null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// Fancy constructor. Can use promote and demote.
 | 
			
		||||
	public static ARRank get(Rel rank) { return new ARRank(rank); }
 | 
			
		||||
	
 | 
			
		||||
	public ARRank(Rel rank)
 | 
			
		||||
	{
 | 
			
		||||
		this.startRank = rank;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// FIELDS
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private final Rel startRank;
 | 
			
		||||
	public Rel getStartRank() { return this.startRank; }
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// OVERRIDE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String typename()
 | 
			
		||||
	{
 | 
			
		||||
		return "rank";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public Rel select(String arg, CommandSender sender)
 | 
			
		||||
	{
 | 
			
		||||
		// This is especially useful when one rank can have aliases.
 | 
			
		||||
		// In the case of promote/demote, 
 | 
			
		||||
		// that would require 10 lines of code repeated for each alias.
 | 
			
		||||
		arg = this.prepareArg(arg);
 | 
			
		||||
		
 | 
			
		||||
		// All the normal ranks
 | 
			
		||||
		if (arg.equals("leader")) return Rel.LEADER;
 | 
			
		||||
		if (arg.equals("officer")) return Rel.OFFICER;
 | 
			
		||||
		if (arg.equals("member")) return Rel.MEMBER;
 | 
			
		||||
		if (arg.equals("recruit")) return Rel.RECRUIT;
 | 
			
		||||
		
 | 
			
		||||
		// No start rank?
 | 
			
		||||
		if (startRank == null)
 | 
			
		||||
		{
 | 
			
		||||
			// This might happen of the default constructor is used
 | 
			
		||||
			Mixin.msgOne(sender, Txt.parse("<b>You can't use promote & demote"));
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Promote
 | 
			
		||||
		if (arg.equals("promote"))
 | 
			
		||||
		{
 | 
			
		||||
			if (Rel.LEADER.equals(startRank)) return Rel.LEADER;
 | 
			
		||||
			if (Rel.OFFICER.equals(startRank)) return Rel.LEADER;
 | 
			
		||||
			if (Rel.MEMBER.equals(startRank)) return Rel.OFFICER;
 | 
			
		||||
			if (Rel.RECRUIT.equals(startRank)) return Rel.MEMBER;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Demote
 | 
			
		||||
		if (arg.equals("demote"))
 | 
			
		||||
		{
 | 
			
		||||
			if (Rel.LEADER.equals(startRank)) return Rel.OFFICER;
 | 
			
		||||
			if (Rel.OFFICER.equals(startRank)) return Rel.MEMBER;
 | 
			
		||||
			if (Rel.MEMBER.equals(startRank)) return Rel.RECRUIT;
 | 
			
		||||
			if (Rel.RECRUIT.equals(startRank)) return Rel.RECRUIT;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public Collection<String> altNames(CommandSender sender)
 | 
			
		||||
	{
 | 
			
		||||
		return MUtil.list(
 | 
			
		||||
			Txt.getNicedEnum(Rel.LEADER),
 | 
			
		||||
			Txt.getNicedEnum(Rel.OFFICER),
 | 
			
		||||
			Txt.getNicedEnum(Rel.MEMBER),
 | 
			
		||||
			Txt.getNicedEnum(Rel.RECRUIT),
 | 
			
		||||
			"Promote",
 | 
			
		||||
			"Demote"
 | 
			
		||||
		);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	// PRIVATE
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
	
 | 
			
		||||
	private String prepareArg(String str)
 | 
			
		||||
	{
 | 
			
		||||
		String ret = str.toLowerCase();
 | 
			
		||||
		
 | 
			
		||||
		if (ret.startsWith("admin") || ret.startsWith("lea"))
 | 
			
		||||
		{
 | 
			
		||||
			ret = "leader";
 | 
			
		||||
		}
 | 
			
		||||
		else if (ret.startsWith("mod") || ret.startsWith("off"))
 | 
			
		||||
		{
 | 
			
		||||
			ret = "officer";
 | 
			
		||||
		}
 | 
			
		||||
		else if (ret.startsWith("mem"))
 | 
			
		||||
		{
 | 
			
		||||
			ret = "member";
 | 
			
		||||
		}
 | 
			
		||||
		else if (ret.startsWith("rec"))
 | 
			
		||||
		{
 | 
			
		||||
			ret = "recruit";
 | 
			
		||||
		}
 | 
			
		||||
		else if (ret.startsWith("+") || ret.startsWith("plus") || ret.startsWith("up"))
 | 
			
		||||
		{
 | 
			
		||||
			ret = "promote";
 | 
			
		||||
		}
 | 
			
		||||
		else if (ret.startsWith("-") || ret.startsWith("minus") || ret.startsWith("down"))
 | 
			
		||||
		{
 | 
			
		||||
			ret = "demote";
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user