Allow players to monitor joins and leaves of their faction members.
Larger servers tend to have join and leave messages disabled for the entire server. A few have requested to allow faction members to monitor join and leave messages of their own members.
This commit is contained in:
parent
d36e88f2c0
commit
8300b2ff2b
@ -32,6 +32,10 @@ public interface FPlayer extends EconomyParticipator {
|
||||
|
||||
public void setFaction(Faction faction);
|
||||
|
||||
public void setMonitorJoins(boolean monitor);
|
||||
|
||||
public boolean isMonitoringJoins();
|
||||
|
||||
public Role getRole();
|
||||
|
||||
public void setRole(Role role);
|
||||
|
25
src/main/java/com/massivecraft/factions/cmd/CmdLogins.java
Normal file
25
src/main/java/com/massivecraft/factions/cmd/CmdLogins.java
Normal file
@ -0,0 +1,25 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdLogins extends FCommand {
|
||||
|
||||
public CmdLogins() {
|
||||
super();
|
||||
this.aliases.add("login");
|
||||
this.aliases.add("logins");
|
||||
this.aliases.add("logout");
|
||||
this.aliases.add("logouts");
|
||||
this.senderMustBePlayer = true;
|
||||
this.senderMustBeMember = true;
|
||||
this.permission = Permission.MONITOR_LOGINS.node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
boolean monitor = fme.isMonitoringJoins();
|
||||
fme.msg(TL.COMMAND_LOGINS_TOGGLE, String.valueOf(!monitor));
|
||||
fme.setMonitorJoins(!monitor);
|
||||
}
|
||||
}
|
@ -61,6 +61,7 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdSetFWarp cmdSetFWarp = new CmdSetFWarp();
|
||||
public CmdDelFWarp cmdDelFWarp = new CmdDelFWarp();
|
||||
public CmdModifyPower cmdModifyPower = new CmdModifyPower();
|
||||
public CmdLogins cmdLogins = new CmdLogins();
|
||||
|
||||
public FCmdRoot() {
|
||||
super();
|
||||
@ -138,6 +139,7 @@ public class FCmdRoot extends FCommand {
|
||||
this.addSubCommand(this.cmdSetFWarp);
|
||||
this.addSubCommand(this.cmdDelFWarp);
|
||||
this.addSubCommand(this.cmdModifyPower);
|
||||
this.addSubCommand(this.cmdLogins);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -64,6 +65,15 @@ public class FactionsPlayerListener implements Listener {
|
||||
FScoreboard.get(me).setDefaultSidebar(new FDefaultSidebar(), P.p.getConfig().getInt("default-update-interval", 20));
|
||||
}
|
||||
FScoreboard.get(me).setSidebarVisibility(P.p.cmdBase.cmdSB.showBoard(me));
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
if (!myFaction.isNone()) {
|
||||
for (FPlayer player : myFaction.getFPlayersWhereOnline(true)) {
|
||||
if (player != me && player.isMonitoringJoins()) {
|
||||
player.msg(TL.FACTION_LOGIN, me.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@ -76,10 +86,18 @@ public class FactionsPlayerListener implements Listener {
|
||||
me.setLastLoginTime(System.currentTimeMillis());
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
if (myFaction != null) {
|
||||
if (!myFaction.isNone()) {
|
||||
myFaction.memberLoggedOff();
|
||||
}
|
||||
|
||||
if (!myFaction.isNone()) {
|
||||
for (FPlayer player : myFaction.getFPlayersWhereOnline(true)) {
|
||||
if (player != me && player.isMonitoringJoins()) {
|
||||
player.msg(TL.FACTION_LOGOUT, me.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FScoreboard.remove(me);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ public enum Permission {
|
||||
MONEY_F2F("money.f2f"),
|
||||
MONEY_F2P("money.f2p"),
|
||||
MONEY_P2F("money.p2f"),
|
||||
MONITOR_LOGINS("monitorlogins"),
|
||||
NO_BOOM("noboom"),
|
||||
OPEN("open"),
|
||||
OWNER("owner"),
|
||||
|
@ -66,6 +66,8 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
|
||||
protected String id;
|
||||
|
||||
protected boolean monitorJoins;
|
||||
|
||||
//private transient String playerName;
|
||||
protected transient FLocation lastStoodAt = new FLocation(); // Where did this player stand the last time we checked?
|
||||
|
||||
@ -113,6 +115,14 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
this.factionId = faction.getId();
|
||||
}
|
||||
|
||||
public void setMonitorJoins(boolean monitor) {
|
||||
this.monitorJoins = monitor;
|
||||
}
|
||||
|
||||
public boolean isMonitoringJoins() {
|
||||
return this.monitorJoins;
|
||||
}
|
||||
|
||||
public Role getRole() {
|
||||
return this.role;
|
||||
}
|
||||
|
@ -246,6 +246,8 @@ public enum TL {
|
||||
COMMAND_LOCK_LOCKED("<i>Factions is now locked"),
|
||||
COMMAND_LOCK_UNLOCKED("<i>Factions in now unlocked"),
|
||||
|
||||
COMMAND_LOGINS_TOGGLE("<i>Set login / logout notifications for Faction members to: <a>%s"),
|
||||
|
||||
COMMAND_MAP_TOSHOW("to show the map"),
|
||||
COMMAND_MAP_FORSHOW("for showing the map"),
|
||||
COMMAND_MAP_UPDATE_ENABLED("<i>Map auto update <green>ENABLED."),
|
||||
@ -453,7 +455,10 @@ public enum TL {
|
||||
SAFEZONE("safezone", "&6Safezone"),
|
||||
SAFEZONE_DESCRIPTION("safezone-description", "Free from pvp and monsters."),
|
||||
TOGGLE_SB("toggle-sb", "You now have scoreboards set to {value}"),
|
||||
DEFAULT_PREFIX("default-prefix", "{relationcolor}[{faction}] &r");
|
||||
DEFAULT_PREFIX("default-prefix", "{relationcolor}[{faction}] &r"),
|
||||
FACTION_LOGIN("faction-login", "&e%s &9logged in."),
|
||||
FACTION_LOGOUT("faction-logout", "&e%s &9logged out.."),
|
||||
;
|
||||
|
||||
private String path;
|
||||
private String def;
|
||||
|
@ -61,7 +61,7 @@ public class TextUtil {
|
||||
string = parseColorAmp(string);
|
||||
string = parseColorAcc(string);
|
||||
string = parseColorTags(string);
|
||||
return string;
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
|
||||
public static String parseColorAmp(String string) {
|
||||
|
@ -90,6 +90,7 @@ permissions:
|
||||
factions.scoreboard: true
|
||||
factions.showinvites: true
|
||||
factions.seechunk: true
|
||||
factions.monitorlogins: true
|
||||
factions.admin:
|
||||
description: hand over your admin rights
|
||||
factions.admin.any:
|
||||
@ -241,3 +242,5 @@ permissions:
|
||||
description: access your faction warps
|
||||
factions.modifypower:
|
||||
description: modify other player's power
|
||||
factions.monitorlogins:
|
||||
description: monitor join and leaves of faction members
|
||||
|
Loading…
Reference in New Issue
Block a user