More universe disabled checks.
This commit is contained in:
@@ -8,7 +8,7 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* The ChatFormater is a system offered by factions for tag parsing.
|
||||
@@ -102,7 +102,7 @@ public class ChatFormatter
|
||||
// FORMAT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static String format(String msg, UPlayer fsender, UPlayer frecipient)
|
||||
public static String format(String msg, CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
// We build the return value in this string buffer
|
||||
StringBuffer ret = new StringBuffer();
|
||||
@@ -137,7 +137,7 @@ public class ChatFormatter
|
||||
}
|
||||
else
|
||||
{
|
||||
replacement = compute(tag, modifierIds, fsender, frecipient);
|
||||
replacement = compute(tag, modifierIds, sender, recipient);
|
||||
if (replacement == null)
|
||||
{
|
||||
// If a tag or modifier returns null it's the same as opting out.
|
||||
@@ -159,9 +159,9 @@ public class ChatFormatter
|
||||
// TAG COMPUTE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static String compute(ChatTag tag, List<String> modifierIds, UPlayer fsender, UPlayer frecipient)
|
||||
public static String compute(ChatTag tag, List<String> modifierIds, CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
String ret = tag.getReplacement(fsender, frecipient);
|
||||
String ret = tag.getReplacement(sender, recipient);
|
||||
if (ret == null) return null;
|
||||
|
||||
for (String modifierId : modifierIds)
|
||||
@@ -172,7 +172,7 @@ public class ChatFormatter
|
||||
|
||||
// Modify and ignore change if null.
|
||||
// Modifier can't get or return null.
|
||||
String modified = modifier.getModified(ret, fsender, frecipient);
|
||||
String modified = modifier.getModified(ret, sender, recipient);
|
||||
if (modified == null) continue;
|
||||
|
||||
ret = modified;
|
||||
|
@@ -1,12 +1,11 @@
|
||||
package com.massivecraft.factions.chat;
|
||||
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public interface ChatModifier
|
||||
{
|
||||
public String getId();
|
||||
public String getModified(String subject, UPlayer fsender, UPlayer frecipient);
|
||||
public String getModified(String subject, CommandSender sender, CommandSender recipient);
|
||||
public boolean register();
|
||||
public boolean unregister();
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package com.massivecraft.factions.chat;
|
||||
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public interface ChatTag
|
||||
{
|
||||
public String getId();
|
||||
public String getReplacement(UPlayer fsender, UPlayer frecipient);
|
||||
public String getReplacement(CommandSender sender, CommandSender recipient);
|
||||
public boolean register();
|
||||
public boolean unregister();
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
|
||||
public class ChatModifierLc extends ChatModifierAbstract
|
||||
{
|
||||
@@ -18,7 +19,7 @@ public class ChatModifierLc extends ChatModifierAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
|
||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
return subject.toLowerCase();
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
|
||||
|
||||
public class ChatModifierLp extends ChatModifierAbstract
|
||||
@@ -19,7 +20,7 @@ public class ChatModifierLp extends ChatModifierAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
|
||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
if (subject.equals("")) return subject;
|
||||
return " "+subject;
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class ChatModifierParse extends ChatModifierAbstract
|
||||
@@ -19,7 +20,7 @@ public class ChatModifierParse extends ChatModifierAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
|
||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
return Txt.parse(subject);
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
|
||||
public class ChatModifierRp extends ChatModifierAbstract
|
||||
{
|
||||
@@ -18,7 +19,7 @@ public class ChatModifierRp extends ChatModifierAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
|
||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
if (subject.equals("")) return subject;
|
||||
return subject+" ";
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
|
||||
public class ChatModifierUc extends ChatModifierAbstract
|
||||
{
|
||||
@@ -18,7 +19,7 @@ public class ChatModifierUc extends ChatModifierAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
|
||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
return subject.toUpperCase();
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package com.massivecraft.factions.chat.modifier;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.chat.ChatModifierAbstract;
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class ChatModifierUcf extends ChatModifierAbstract
|
||||
@@ -19,7 +20,7 @@ public class ChatModifierUcf extends ChatModifierAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
|
||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
return Txt.upperCaseFirst(subject);
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -20,10 +22,15 @@ public class ChatTagName extends ChatTagAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(UPlayer fsender, UPlayer frecipient)
|
||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
if (!UConf.get(fsender).enabled) return "";
|
||||
Faction faction = fsender.getFaction();
|
||||
// Check disabled
|
||||
if (UConf.isDisabled(sender)) return "";
|
||||
|
||||
// Get entities
|
||||
UPlayer usender = UPlayer.get(sender);
|
||||
|
||||
Faction faction = usender.getFaction();
|
||||
if (faction.isNone()) return "";
|
||||
return faction.getName();
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -20,10 +22,15 @@ public class ChatTagNameforce extends ChatTagAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(UPlayer fsender, UPlayer frecipient)
|
||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
if (!UConf.get(fsender).enabled) return "";
|
||||
Faction faction = fsender.getFaction();
|
||||
// Check disabled
|
||||
if (UConf.isDisabled(sender)) return "";
|
||||
|
||||
// Get entities
|
||||
UPlayer usender = UPlayer.get(sender);
|
||||
|
||||
Faction faction = usender.getFaction();
|
||||
return faction.getName();
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -19,13 +21,18 @@ public class ChatTagRelcolor extends ChatTagAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(UPlayer fsender, UPlayer frecipient)
|
||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
if (!UConf.get(fsender).enabled) return "";
|
||||
if (recipient == null) return "";
|
||||
|
||||
if (frecipient == null) return "";
|
||||
// Check disabled
|
||||
if (UConf.isDisabled(sender)) return "";
|
||||
|
||||
// Get entities
|
||||
UPlayer usender = UPlayer.get(sender);
|
||||
UPlayer urecipient = UPlayer.get(recipient);
|
||||
|
||||
return frecipient.getRelationTo(fsender).getColor().toString();
|
||||
return urecipient.getRelationTo(usender).getColor().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -20,11 +22,15 @@ public class ChatTagRole extends ChatTagAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(UPlayer fsender, UPlayer frecipient)
|
||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
if (!UConf.get(fsender).enabled) return "";
|
||||
// Check disabled
|
||||
if (UConf.isDisabled(sender)) return "";
|
||||
|
||||
return Txt.upperCaseFirst(fsender.getRole().toString().toLowerCase());
|
||||
// Get entities
|
||||
UPlayer usender = UPlayer.get(sender);
|
||||
|
||||
return Txt.upperCaseFirst(usender.getRole().toString().toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -19,11 +21,15 @@ public class ChatTagRoleprefix extends ChatTagAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(UPlayer fsender, UPlayer frecipient)
|
||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
if (!UConf.get(fsender).enabled) return "";
|
||||
// Check disabled
|
||||
if (UConf.isDisabled(sender)) return "";
|
||||
|
||||
return fsender.getRole().getPrefix();
|
||||
// Get entities
|
||||
UPlayer usender = UPlayer.get(sender);
|
||||
|
||||
return usender.getRole().getPrefix();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -19,12 +21,16 @@ public class ChatTagTitle extends ChatTagAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getReplacement(UPlayer fsender, UPlayer frecipient)
|
||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
||||
{
|
||||
if (!UConf.get(fsender).enabled) return "";
|
||||
// Check disabled
|
||||
if (UConf.isDisabled(sender)) return "";
|
||||
|
||||
if (!fsender.hasTitle()) return "";
|
||||
return fsender.getTitle();
|
||||
// Get entities
|
||||
UPlayer usender = UPlayer.get(sender);
|
||||
|
||||
if (!usender.hasTitle()) return "";
|
||||
return usender.getTitle();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user