Maven Attempt 1
This commit is contained in:
		@@ -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,40 +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.UConf;
 | 
			
		||||
import com.massivecraft.factions.entity.UPlayer;
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
	{
 | 
			
		||||
		// Check disabled
 | 
			
		||||
		if (UConf.isDisabled(sender)) return "";
 | 
			
		||||
 | 
			
		||||
		// Get entities
 | 
			
		||||
		UPlayer usender = UPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		// No "force"
 | 
			
		||||
		Faction faction = usender.getFaction();
 | 
			
		||||
		if (faction.isNone()) return "";
 | 
			
		||||
		
 | 
			
		||||
		return faction.getName();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,37 +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.UConf;
 | 
			
		||||
import com.massivecraft.factions.entity.UPlayer;
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
	{
 | 
			
		||||
		// Check disabled
 | 
			
		||||
		if (UConf.isDisabled(sender)) return "";
 | 
			
		||||
 | 
			
		||||
		// Get entities
 | 
			
		||||
		UPlayer usender = UPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		Faction faction = usender.getFaction();
 | 
			
		||||
		return faction.getName();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,39 +0,0 @@
 | 
			
		||||
package com.massivecraft.factions.chat.tag;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.chat.ChatTagAbstract;
 | 
			
		||||
import com.massivecraft.factions.entity.UConf;
 | 
			
		||||
import com.massivecraft.factions.entity.UPlayer;
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
	{
 | 
			
		||||
		// Check disabled
 | 
			
		||||
		if (UConf.isDisabled(sender)) return "";
 | 
			
		||||
		
 | 
			
		||||
		// Opt out if no recipient
 | 
			
		||||
		if (recipient == null) return null;
 | 
			
		||||
 | 
			
		||||
		// Get entities
 | 
			
		||||
		UPlayer usender = UPlayer.get(sender);
 | 
			
		||||
		UPlayer urecipient = UPlayer.get(recipient);
 | 
			
		||||
		
 | 
			
		||||
		return urecipient.getRelationTo(usender).getColor().toString();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -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.UConf;
 | 
			
		||||
import com.massivecraft.factions.entity.UPlayer;
 | 
			
		||||
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)
 | 
			
		||||
	{
 | 
			
		||||
		// Check disabled
 | 
			
		||||
		if (UConf.isDisabled(sender)) return "";
 | 
			
		||||
		
 | 
			
		||||
		// Get entities
 | 
			
		||||
		UPlayer usender = UPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		return Txt.upperCaseFirst(usender.getRole().toString().toLowerCase());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,40 +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.UConf;
 | 
			
		||||
import com.massivecraft.factions.entity.UPlayer;
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
	{
 | 
			
		||||
		// Check disabled
 | 
			
		||||
		if (UConf.isDisabled(sender)) return "";
 | 
			
		||||
		
 | 
			
		||||
		// Get entities
 | 
			
		||||
		UPlayer usender = UPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		// No "force"
 | 
			
		||||
		Faction faction = usender.getFaction();
 | 
			
		||||
		if (faction.isNone()) return "";
 | 
			
		||||
		
 | 
			
		||||
		return usender.getRole().getPrefix();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -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.UConf;
 | 
			
		||||
import com.massivecraft.factions.entity.UPlayer;
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
	{
 | 
			
		||||
		// Check disabled
 | 
			
		||||
		if (UConf.isDisabled(sender)) return "";
 | 
			
		||||
		
 | 
			
		||||
		// Get entities
 | 
			
		||||
		UPlayer usender = UPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		return usender.getRole().getPrefix();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -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.UConf;
 | 
			
		||||
import com.massivecraft.factions.entity.UPlayer;
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
	{
 | 
			
		||||
		// Check disabled
 | 
			
		||||
		if (UConf.isDisabled(sender)) return "";
 | 
			
		||||
		
 | 
			
		||||
		// Get entities
 | 
			
		||||
		UPlayer usender = UPlayer.get(sender);
 | 
			
		||||
		
 | 
			
		||||
		if (!usender.hasTitle()) return "";
 | 
			
		||||
		return usender.getTitle();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user