Faction chat is now something you turn on and off

This commit is contained in:
Olof Larsson 2011-02-13 09:08:20 +01:00
parent da1c0d6142
commit 14ad1299b2
5 changed files with 41 additions and 12 deletions

View File

@ -28,7 +28,7 @@ public class Commands {
pageLines.add(TextUtil.commandHelp(Conf.aliasMap, "*[on|off]", "Show territory map, set optional auto update."));
pageLines.add(TextUtil.commandHelp(Conf.aliasJoin, "[faction name]", "Join a faction"));
pageLines.add(TextUtil.commandHelp(Conf.aliasLeave, "", "Leave your faction"));
pageLines.add(TextUtil.commandHelp(Conf.aliasChat, "[message]", "Send message to your faction only."));
pageLines.add(TextUtil.commandHelp(Conf.aliasChat, "", "Switch faction only chat on and off."));
pageLines.add(TextUtil.commandHelp(Conf.aliasCreate, "[faction tag]", "Create new faction"));
pageLines.add(TextUtil.commandHelp(Conf.aliasTag, "[faction tag]", "Change the faction tag"));
pageLines.add(TextUtil.commandHelp(Conf.aliasDescription, "[description]", "Change the faction description"));
@ -87,7 +87,7 @@ public class Commands {
helpPages.add(pageLines);
pageLines = new ArrayList<String>();
pageLines.add(TextUtil.commandHelp(Conf.aliasVersion, "", "Wich version are you using"));
pageLines.add(TextUtil.commandHelp(Conf.aliasVersion, "", "Which version are you using?"));
helpPages.add(pageLines);
}
@ -760,10 +760,16 @@ public class Commands {
me.sendMessage(Conf.colorSystem+"You are not part of any faction");
return;
}
String message = String.format(Conf.factionChatFormat, me.getNameAndRelevant(me), msg);
me.getFaction().sendMessage(message, false);
Logger.getLogger("Minecraft").info("FactionChat "+me.getFaction().getTag()+": "+message);
if ( ! me.isFactionChatting()) {
// Turn on
me.setFactionChatting(true);
me.sendMessage(Conf.colorSystem + "Faction only chat ENABLED.");
} else {
// Turn off
me.setFactionChatting(false);
me.sendMessage(Conf.colorSystem + "Faction only chat DISABLED.");
}
}
public static void version(Follower me) {

View File

@ -90,10 +90,6 @@ public class Conf {
aliasBase.add("/f");
aliasBase.add("f");
aliasBase.add("/faction");
aliasBase.add("faction");
aliasBase.add("/factions");
aliasBase.add("factions");
aliasHelp.add("help");
aliasHelp.add("h");

View File

@ -18,8 +18,20 @@ public class Follower {
private String title;
private double power;
private long lastPowerUpdateTime;
private boolean mapAutoUpdating;
private boolean mapAutoUpdating;
private boolean factionChatting;
public boolean isFactionChatting() {
if (this.factionId == 0) {
return false;
}
return factionChatting;
}
public void setFactionChatting(boolean factionChatting) {
this.factionChatting = factionChatting;
}
public Follower() {
this.resetFactionData();
this.power = this.getPowerMax();
@ -29,6 +41,7 @@ public class Follower {
protected void resetFactionData() {
this.factionId = 0; // The default neutral faction
this.factionChatting = false;
this.role = Role.NORMAL;
this.title = "";
}

View File

@ -6,6 +6,7 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityListener;
@ -95,4 +96,9 @@ public class FactionsEntityListener extends EntityListener {
}
}
/*@Override
public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
event.
}*/
}

View File

@ -52,6 +52,16 @@ public class FactionsPlayerListener extends PlayerListener{
}
// ... it was not a command. This means that it is a chat message!
Follower me = Follower.get(talkingPlayer);
// Is it a faction chat message?
if (me.isFactionChatting()) {
String message = String.format(Conf.factionChatFormat, me.getNameAndRelevant(me), msg);
me.getFaction().sendMessage(message, false);
Logger.getLogger("Minecraft").info("FactionChat "+me.getFaction().getTag()+": "+message);
event.setCancelled(true);
return;
}
// Are we to insert the Faction tag into the format?
// If we are not to insert it - we are done.
@ -59,8 +69,6 @@ public class FactionsPlayerListener extends PlayerListener{
return;
}
Follower me = Follower.get(talkingPlayer);
String formatStart = event.getFormat().substring(0, Conf.chatTagInsertIndex);
String formatEnd = event.getFormat().substring(Conf.chatTagInsertIndex);