tweaked hook functions a bit more, de-crapped server log messages for faction chat

This commit is contained in:
Brettflan 2011-06-28 20:00:08 -05:00
parent 24362d38e9
commit a8c84c5d6d
2 changed files with 20 additions and 14 deletions

View File

@ -195,7 +195,7 @@ public class Factions extends JavaPlugin {
// Simply put, should this chat event be left for Factions to handle? For now, that means players with Faction Chat // Simply put, should this chat event be left for Factions to handle? For now, that means players with Faction Chat
// enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand() // enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand()
public boolean ShouldLetFactionsHandleThisChat(PlayerChatEvent event) { public boolean shouldLetFactionsHandleThisChat(PlayerChatEvent event) {
if (event == null) if (event == null)
return false; return false;
return (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage())); return (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage()));
@ -214,9 +214,9 @@ public class Factions extends JavaPlugin {
// Is this chat message actually a Factions command, and thus should be left alone by other plugins? // Is this chat message actually a Factions command, and thus should be left alone by other plugins?
public boolean isFactionsCommand(String check) { public boolean isFactionsCommand(String check) {
if (check == null) if (check == null || check.isEmpty())
return false; return false;
return ((check.startsWith(instance.getBaseCommand()+" ") || check.equals(instance.getBaseCommand())) && Conf.allowNoSlashCommand); return (Conf.allowNoSlashCommand && (check.startsWith(instance.getBaseCommand()+" ") || check.equals(instance.getBaseCommand())));
} }
// Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat // Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat
@ -226,23 +226,29 @@ public class Factions extends JavaPlugin {
// Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag // Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag
public String getPlayerFactionTagRelation(Player speaker, Player listener) { public String getPlayerFactionTagRelation(Player speaker, Player listener) {
String tag = "~";
if (speaker == null) if (speaker == null)
return ""; return tag;
FPlayer me = FPlayer.get(speaker); FPlayer me = FPlayer.get(speaker);
if (me == null) if (me == null)
return ""; return tag;
// if listener isn't set, or config option is disabled, give back uncolored tag // if listener isn't set, or config option is disabled, give back uncolored tag
if (listener == null || !Conf.chatTagRelationColored) if (listener == null || !Conf.chatTagRelationColored) {
return me.getChatTag().trim(); tag = me.getChatTag().trim();
} else {
FPlayer you = FPlayer.get(listener);
if (you == null)
tag = me.getChatTag().trim();
else // everything checks out, give the colored tag
tag = me.getChatTag(you).trim();
}
if (tag.isEmpty())
tag = "~";
FPlayer you = FPlayer.get(listener); return tag;
if (you == null)
return me.getChatTag().trim();
// everything checks out, give the colored tag
return me.getChatTag(you).trim();
} }
// Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat // Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat

View File

@ -57,7 +57,7 @@ public class FactionsPlayerListener extends PlayerListener{
if (me.isFactionChatting()) { if (me.isFactionChatting()) {
String message = String.format(Conf.factionChatFormat, me.getNameAndRelevant(me), msg); String message = String.format(Conf.factionChatFormat, me.getNameAndRelevant(me), msg);
me.getFaction().sendMessage(message); me.getFaction().sendMessage(message);
Logger.getLogger("Minecraft").info("FactionChat "+me.getFaction().getTag()+": "+message); Logger.getLogger("Minecraft").info(ChatColor.stripColor("FactionChat "+me.getFaction().getTag()+": "+message));
event.setCancelled(true); event.setCancelled(true);
return; return;
} }