Pass 1 at adding in better chat formating
This commit is contained in:
182
src/com/massivecraft/factions/chat/ChatFormatter.java
Normal file
182
src/com/massivecraft/factions/chat/ChatFormatter.java
Normal file
@@ -0,0 +1,182 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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) != 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) != null;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FORMAT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static String format(String msg, String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
// 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, senderId, sendeeId, recipientId);
|
||||
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, String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
String ret = tag.getReplacement(senderId, sendeeId, recipientId);
|
||||
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, senderId, sendeeId, recipientId);
|
||||
if (modified == null) continue;
|
||||
|
||||
ret = modified;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
10
src/com/massivecraft/factions/chat/ChatModifier.java
Normal file
10
src/com/massivecraft/factions/chat/ChatModifier.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.massivecraft.factions.chat;
|
||||
|
||||
|
||||
public interface ChatModifier
|
||||
{
|
||||
public String getId();
|
||||
public String getModified(String subject, String senderId, String sendeeId, String recipientId);
|
||||
public boolean register();
|
||||
public boolean unregister();
|
||||
}
|
37
src/com/massivecraft/factions/chat/ChatModifierAbstract.java
Normal file
37
src/com/massivecraft/factions/chat/ChatModifierAbstract.java
Normal file
@@ -0,0 +1,37 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
9
src/com/massivecraft/factions/chat/ChatTag.java
Normal file
9
src/com/massivecraft/factions/chat/ChatTag.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.massivecraft.factions.chat;
|
||||
|
||||
public interface ChatTag
|
||||
{
|
||||
public String getId();
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId);
|
||||
public boolean register();
|
||||
public boolean unregister();
|
||||
}
|
37
src/com/massivecraft/factions/chat/ChatTagAbstract.java
Normal file
37
src/com/massivecraft/factions/chat/ChatTagAbstract.java
Normal file
@@ -0,0 +1,37 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
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, String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
return subject.toLowerCase();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
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, String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
if (subject.equals("")) return subject;
|
||||
return " "+subject;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
|
||||
import com.massivecraft.mcore.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, String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
return Txt.parse(subject);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
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, String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
if (subject.equals("")) return subject;
|
||||
return subject+" ";
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
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, String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
return subject.toUpperCase();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
|
||||
import com.massivecraft.mcore.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, String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
return Txt.upperCaseFirst(subject);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package com.massivecraft.factions.chat.tag;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.chat.ChatTagAbstract;
|
||||
|
||||
public class ChatTagFactionRelcolor extends ChatTagAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private ChatTagFactionRelcolor() { super("factions_relcolor"); }
|
||||
private static ChatTagFactionRelcolor i = new ChatTagFactionRelcolor();
|
||||
public static ChatTagFactionRelcolor get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
if (senderId == null) return "";
|
||||
if (recipientId == null) return "";
|
||||
|
||||
FPlayer fsender = FPlayerColl.get().get(senderId);
|
||||
FPlayer frecipient = FPlayerColl.get().get(recipientId);
|
||||
|
||||
if (fsender == null) return "";
|
||||
if (frecipient == null) return "";
|
||||
|
||||
return frecipient.getRelationTo(fsender).getColor().toString();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package com.massivecraft.factions.chat.tag;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.chat.ChatTagAbstract;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class ChatTagFactionRole extends ChatTagAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private ChatTagFactionRole() { super("factions_role"); }
|
||||
private static ChatTagFactionRole i = new ChatTagFactionRole();
|
||||
public static ChatTagFactionRole get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
FPlayer fsender = FPlayerColl.get().get(senderId);
|
||||
return Txt.upperCaseFirst(fsender.getRole().toString().toLowerCase());
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.massivecraft.factions.chat.tag;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.chat.ChatTagAbstract;
|
||||
|
||||
public class ChatTagFactionRoleprefix extends ChatTagAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private ChatTagFactionRoleprefix() { super("factions_roleprefix"); }
|
||||
private static ChatTagFactionRoleprefix i = new ChatTagFactionRoleprefix();
|
||||
public static ChatTagFactionRoleprefix get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
FPlayer fsender = FPlayerColl.get().get(senderId);
|
||||
return fsender.getRole().getPrefix();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package com.massivecraft.factions.chat.tag;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.chat.ChatTagAbstract;
|
||||
|
||||
public class ChatTagFactionTag extends ChatTagAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private ChatTagFactionTag() { super("factions_tag"); }
|
||||
private static ChatTagFactionTag i = new ChatTagFactionTag();
|
||||
public static ChatTagFactionTag get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
FPlayer fsender = FPlayerColl.get().get(senderId);
|
||||
if (!fsender.hasFaction()) return "";
|
||||
return fsender.getFaction().getTag();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.massivecraft.factions.chat.tag;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.chat.ChatTagAbstract;
|
||||
|
||||
public class ChatTagFactionTagforce extends ChatTagAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private ChatTagFactionTagforce() { super("factions_tagforce"); }
|
||||
private static ChatTagFactionTagforce i = new ChatTagFactionTagforce();
|
||||
public static ChatTagFactionTagforce get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
FPlayer fsender = FPlayerColl.get().get(senderId);
|
||||
return fsender.getFaction().getTag();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.massivecraft.factions.chat.tag;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayerColl;
|
||||
import com.massivecraft.factions.chat.ChatTagAbstract;
|
||||
|
||||
public class ChatTagFactionTitle extends ChatTagAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private ChatTagFactionTitle() { super("factions_title"); }
|
||||
private static ChatTagFactionTitle i = new ChatTagFactionTitle();
|
||||
public static ChatTagFactionTitle get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
FPlayer fsender = FPlayerColl.get().get(sendeeId);
|
||||
return fsender.getTitle();
|
||||
}
|
||||
|
||||
}
|
26
src/com/massivecraft/factions/chat/tag/ChatTagSendee.java
Normal file
26
src/com/massivecraft/factions/chat/tag/ChatTagSendee.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.massivecraft.factions.chat.tag;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatTagAbstract;
|
||||
import com.massivecraft.mcore.mixin.Mixin;
|
||||
|
||||
public class ChatTagSendee extends ChatTagAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private ChatTagSendee() { super("sendee"); }
|
||||
private static ChatTagSendee i = new ChatTagSendee();
|
||||
public static ChatTagSendee get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
return Mixin.getDisplayName(sendeeId);
|
||||
}
|
||||
|
||||
}
|
26
src/com/massivecraft/factions/chat/tag/ChatTagSendeeId.java
Normal file
26
src/com/massivecraft/factions/chat/tag/ChatTagSendeeId.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.massivecraft.factions.chat.tag;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatTagAbstract;
|
||||
import com.massivecraft.mcore.mixin.Mixin;
|
||||
|
||||
public class ChatTagSendeeId extends ChatTagAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private ChatTagSendeeId() { super("sendeeid"); }
|
||||
private static ChatTagSendeeId i = new ChatTagSendeeId();
|
||||
public static ChatTagSendeeId get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
return Mixin.tryFix(sendeeId);
|
||||
}
|
||||
|
||||
}
|
26
src/com/massivecraft/factions/chat/tag/ChatTagSender.java
Normal file
26
src/com/massivecraft/factions/chat/tag/ChatTagSender.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.massivecraft.factions.chat.tag;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatTagAbstract;
|
||||
import com.massivecraft.mcore.mixin.Mixin;
|
||||
|
||||
public class ChatTagSender extends ChatTagAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private ChatTagSender() { super("sender"); }
|
||||
private static ChatTagSender i = new ChatTagSender();
|
||||
public static ChatTagSender get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
return Mixin.getDisplayName(senderId);
|
||||
}
|
||||
|
||||
}
|
26
src/com/massivecraft/factions/chat/tag/ChatTagSenderId.java
Normal file
26
src/com/massivecraft/factions/chat/tag/ChatTagSenderId.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.massivecraft.factions.chat.tag;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatTagAbstract;
|
||||
import com.massivecraft.mcore.mixin.Mixin;
|
||||
|
||||
public class ChatTagSenderId extends ChatTagAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private ChatTagSenderId() { super("senderid"); }
|
||||
private static ChatTagSenderId i = new ChatTagSenderId();
|
||||
public static ChatTagSenderId get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(String senderId, String sendeeId, String recipientId)
|
||||
{
|
||||
return Mixin.tryFix(senderId);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user