Merge pull request #60 from eXeC64/spy

Added chat spy feature for admins
This commit is contained in:
Brett Flannigan 2012-01-14 22:58:39 -08:00
commit 9ff68301e5
6 changed files with 65 additions and 3 deletions

View File

@ -26,10 +26,11 @@ permissions:
factions.kit.halfmod: true factions.kit.halfmod: true
factions.flag.set: true factions.flag.set: true
factions.kit.halfmod: factions.kit.halfmod:
description: Can use adminmode description: Can use adminmode and chat spy
children: children:
factions.kit.fullplayer: true factions.kit.fullplayer: true
factions.adminmode: true factions.adminmode: true
factions.chatspy: true
factions.kit.fullplayer: factions.kit.fullplayer:
default: true default: true
description: Can also create new factions. description: Can also create new factions.
@ -71,6 +72,8 @@ permissions:
factions.version: true factions.version: true
factions.adminmode: factions.adminmode:
description: enable admin bypass mode description: enable admin bypass mode
factions.chatspy:
description: enable admin chat spy mode
factions.autoclaim: factions.autoclaim:
description: auto-claim land as you walk around description: auto-claim land as you walk around
factions.chat: factions.chat:

View File

@ -102,6 +102,11 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
return chatMode; return chatMode;
} }
// FIELD: chatSpy
private transient boolean spyingChat = false;
public void setSpyingChat(boolean chatSpying) { this.spyingChat = chatSpying; }
public boolean isSpyingChat() { return spyingChat; }
// FIELD: account // FIELD: account
public MethodAccount getAccount() public MethodAccount getAccount()
{ {

View File

@ -0,0 +1,40 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class CmdChatSpy extends FCommand
{
public CmdChatSpy()
{
super();
this.aliases.add("chatspy");
this.optionalArgs.put("on/off", "flip");
this.permission = Permission.CHATSPY.node;
this.disableOnLock = false;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeOfficer = false;
senderMustBeLeader = false;
}
@Override
public void perform()
{
fme.setSpyingChat(this.argAsBool(0, ! fme.isSpyingChat()));
if ( fme.isSpyingChat())
{
fme.msg("<i>You have enabled chat spying mode.");
P.p.log(fme.getName() + " has ENABLED chat spying mode.");
}
else
{
fme.msg("<i>You have disabled chat spying mode.");
P.p.log(fme.getName() + " DISABLED chat spying mode.");
}
}
}

View File

@ -10,6 +10,7 @@ public class FCmdRoot extends FCommand
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim(); public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
public CmdAdmin cmdBypass = new CmdAdmin(); public CmdAdmin cmdBypass = new CmdAdmin();
public CmdChat cmdChat = new CmdChat(); public CmdChat cmdChat = new CmdChat();
public CmdChatSpy cmdChatSpy = new CmdChatSpy();
public CmdClaim cmdClaim = new CmdClaim(); public CmdClaim cmdClaim = new CmdClaim();
public CmdConfig cmdConfig = new CmdConfig(); public CmdConfig cmdConfig = new CmdConfig();
public CmdCreate cmdCreate = new CmdCreate(); public CmdCreate cmdCreate = new CmdCreate();
@ -72,6 +73,7 @@ public class FCmdRoot extends FCommand
this.addSubCommand(this.cmdAutoClaim); this.addSubCommand(this.cmdAutoClaim);
this.addSubCommand(this.cmdBypass); this.addSubCommand(this.cmdBypass);
this.addSubCommand(this.cmdChat); this.addSubCommand(this.cmdChat);
this.addSubCommand(this.cmdChatSpy);
this.addSubCommand(this.cmdClaim); this.addSubCommand(this.cmdClaim);
this.addSubCommand(this.cmdConfig); this.addSubCommand(this.cmdConfig);
this.addSubCommand(this.cmdCreate); this.addSubCommand(this.cmdCreate);

View File

@ -52,6 +52,13 @@ public class FactionsChatEarlyListener extends PlayerListener
P.p.log(Level.INFO, ChatColor.stripColor("FactionChat "+me.getFaction().getTag()+": "+message)); P.p.log(Level.INFO, ChatColor.stripColor("FactionChat "+me.getFaction().getTag()+": "+message));
//Send to any players who are spying chat
for (FPlayer fplayer : FPlayers.i.getOnline())
{
if( fplayer.isSpyingChat() )
fplayer.sendMessage("FactionChat "+me.getFaction().getTag()+": "+message);
}
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -70,9 +77,13 @@ public class FactionsChatEarlyListener extends PlayerListener
{ {
if(myFaction.getRelationTo(fplayer) == Rel.ALLY) if(myFaction.getRelationTo(fplayer) == Rel.ALLY)
fplayer.sendMessage(message); fplayer.sendMessage(message);
//Send to any players who are spying chat
if( fplayer.isSpyingChat() )
fplayer.sendMessage("AllianceChat " + message);
} }
P.p.log(Level.INFO, ChatColor.stripColor("AllianceChat: "+message)); P.p.log(Level.INFO, ChatColor.stripColor("AllianceChat "+message));
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -8,6 +8,7 @@ public enum Permission
ADMIN("adminmode"), ADMIN("adminmode"),
AUTOCLAIM("autoclaim"), AUTOCLAIM("autoclaim"),
CHAT("chat"), CHAT("chat"),
CHATSPY("chatspy"),
CLAIM("claim"), CLAIM("claim"),
CONFIG("config"), CONFIG("config"),
CREATE("create"), CREATE("create"),