Add in a new tag {factions_roleprefixforce}

This commit is contained in:
Olof Larsson 2013-06-27 11:42:02 +02:00
parent 1952cd2999
commit e0729fbeb0
4 changed files with 44 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import com.massivecraft.factions.chat.tag.ChatTagRole;
import com.massivecraft.factions.chat.tag.ChatTagRoleprefix; import com.massivecraft.factions.chat.tag.ChatTagRoleprefix;
import com.massivecraft.factions.chat.tag.ChatTagName; import com.massivecraft.factions.chat.tag.ChatTagName;
import com.massivecraft.factions.chat.tag.ChatTagNameforce; 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.chat.tag.ChatTagTitle;
import com.massivecraft.factions.cmd.*; import com.massivecraft.factions.cmd.*;
import com.massivecraft.factions.entity.Board; import com.massivecraft.factions.entity.Board;
@ -156,6 +157,7 @@ public class Factions extends MPlugin
ChatTagRelcolor.get().register(); ChatTagRelcolor.get().register();
ChatTagRole.get().register(); ChatTagRole.get().register();
ChatTagRoleprefix.get().register(); ChatTagRoleprefix.get().register();
ChatTagRoleprefixforce.get().register();
ChatTagName.get().register(); ChatTagName.get().register();
ChatTagNameforce.get().register(); ChatTagNameforce.get().register();
ChatTagTitle.get().register(); ChatTagTitle.get().register();

View File

@ -30,8 +30,10 @@ public class ChatTagName extends ChatTagAbstract
// Get entities // Get entities
UPlayer usender = UPlayer.get(sender); UPlayer usender = UPlayer.get(sender);
// No "force"
Faction faction = usender.getFaction(); Faction faction = usender.getFaction();
if (faction.isNone()) return ""; if (faction.isNone()) return "";
return faction.getName(); return faction.getName();
} }

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.UPlayer;
@ -29,6 +30,10 @@ public class ChatTagRoleprefix extends ChatTagAbstract
// Get entities // Get entities
UPlayer usender = UPlayer.get(sender); UPlayer usender = UPlayer.get(sender);
// No "force"
Faction faction = usender.getFaction();
if (faction.isNone()) return "";
return usender.getRole().getPrefix(); return usender.getRole().getPrefix();
} }

View File

@ -0,0 +1,35 @@
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();
}
}