F Notification, allows to not see claim notifications in chat

This commit is contained in:
Driftay 2019-07-30 00:31:26 -04:00
parent 02eddb9c26
commit fab2a3bba0
7 changed files with 64 additions and 6 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.massivecraft</groupId> <groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId> <artifactId>Factions</artifactId>
<version>1.6.9.5-U0.2.1-1.4.1-BETA</version> <version>1.6.9.5-U0.2.1-1.4.2-BETA</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SaberFactions</name> <name>SaberFactions</name>
@ -86,7 +86,8 @@
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.13-R0.1-SNAPSHOT</version> <version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions> <exclusion> <exclusions>
<exclusion>
<artifactId>bungeecord-chat</artifactId> <artifactId>bungeecord-chat</artifactId>
<groupId>net.md-5</groupId> <groupId>net.md-5</groupId>
</exclusion> </exclusion>

View File

@ -26,8 +26,9 @@ import java.util.List;
public interface FPlayer extends EconomyParticipator { public interface FPlayer extends EconomyParticipator {
void setNotificationsEnabled(boolean notifications);
boolean hasNotificationsEnabled();
void setAlt(boolean alt); void setAlt(boolean alt);

View File

@ -0,0 +1,37 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.zcore.util.TL;
public class CmdNotifications extends FCommand {
public CmdNotifications() {
this.aliases.add("notifications");
this.aliases.add("messages");
this.optionalArgs.put("on/off", "flip");
this.senderMustBeMember = true;
this.senderMustBeModerator = false;
}
@Override
public void perform() {
if (args.size() == 0) {
toggleNotifications(!fme.hasNotificationsEnabled());
} else if (args.size() == 1) {
toggleNotifications(argAsBool(0));
}
}
private void toggleNotifications(boolean toggle) {
fme.setNotificationsEnabled(toggle);
if (toggle) {
fme.msg(TL.COMMAND_NOTIFICATIONS_TOGGLED_ON);
} else {
fme.msg(TL.COMMAND_NOTIFICATIONS_TOGGLED_OFF);
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_NOTIFICATIONS_DESCRIPTION;
}
}

View File

@ -126,6 +126,7 @@ public class FCmdRoot extends FCommand {
public CmdViewChest cmdViewChest = new CmdViewChest(); public CmdViewChest cmdViewChest = new CmdViewChest();
public CmdPoints cmdPoints = new CmdPoints(); public CmdPoints cmdPoints = new CmdPoints();
public CmdLogout cmdLogout = new CmdLogout(); public CmdLogout cmdLogout = new CmdLogout();
public CmdNotifications cmdNotifications = new CmdNotifications();
@ -175,6 +176,7 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdMap); this.addSubCommand(this.cmdMap);
this.addSubCommand(this.cmdMod); this.addSubCommand(this.cmdMod);
this.addSubCommand(this.cmdMoney); this.addSubCommand(this.cmdMoney);
this.addSubCommand(this.cmdNotifications);
this.addSubCommand(this.cmdOpen); this.addSubCommand(this.cmdOpen);
this.addSubCommand(this.cmdOwner); this.addSubCommand(this.cmdOwner);
this.addSubCommand(this.cmdOwnerList); this.addSubCommand(this.cmdOwnerList);

View File

@ -593,12 +593,12 @@ public class FactionsPlayerListener implements Listener {
String ownersTo = myFaction.getOwnerListString(to); String ownersTo = myFaction.getOwnerListString(to);
if (changedFaction) { if (changedFaction) {
me.sendFactionHereMessage(factionFrom); me.sendFactionHereMessage(factionFrom);
if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) { if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty() && me.hasNotificationsEnabled()) {
me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo)); me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo));
} }
} else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && myFaction == factionTo && !myFaction.isWilderness()) { } else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && myFaction == factionTo && !myFaction.isWilderness()) {
String ownersFrom = myFaction.getOwnerListString(from); String ownersFrom = myFaction.getOwnerListString(from);
if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) { if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo) && me.hasNotificationsEnabled()) {
if (!ownersTo.isEmpty()) { if (!ownersTo.isEmpty()) {
me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo)); me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo));
} else if (!TL.GENERIC_PUBLICLAND.toString().isEmpty()) { } else if (!TL.GENERIC_PUBLICLAND.toString().isEmpty()) {

View File

@ -75,7 +75,7 @@ public abstract class MemoryFPlayer implements FPlayer {
protected transient long lastFrostwalkerMessage; protected transient long lastFrostwalkerMessage;
protected transient boolean shouldTakeFallDamage = true; protected transient boolean shouldTakeFallDamage = true;
protected boolean isStealthEnabled = false; protected boolean isStealthEnabled = false;
boolean playerAlerts = false; protected boolean notificationsEnabled = true;
boolean inspectMode = false; boolean inspectMode = false;
protected boolean isAlt = false; protected boolean isAlt = false;
@ -99,6 +99,7 @@ public abstract class MemoryFPlayer implements FPlayer {
this.lastLoginTime = System.currentTimeMillis(); this.lastLoginTime = System.currentTimeMillis();
this.mapAutoUpdating = false; this.mapAutoUpdating = false;
this.autoClaimFor = null; this.autoClaimFor = null;
this.notificationsEnabled = true;
this.autoSafeZoneEnabled = false; this.autoSafeZoneEnabled = false;
this.autoWarZoneEnabled = false; this.autoWarZoneEnabled = false;
this.loginPvpDisabled = Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0; this.loginPvpDisabled = Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0;
@ -124,6 +125,7 @@ public abstract class MemoryFPlayer implements FPlayer {
this.autoSafeZoneEnabled = other.autoSafeZoneEnabled; this.autoSafeZoneEnabled = other.autoSafeZoneEnabled;
this.autoWarZoneEnabled = other.autoWarZoneEnabled; this.autoWarZoneEnabled = other.autoWarZoneEnabled;
this.loginPvpDisabled = other.loginPvpDisabled; this.loginPvpDisabled = other.loginPvpDisabled;
this.notificationsEnabled = true;
this.powerBoost = other.powerBoost; this.powerBoost = other.powerBoost;
this.role = other.role; this.role = other.role;
this.title = other.title; this.title = other.title;
@ -133,6 +135,7 @@ public abstract class MemoryFPlayer implements FPlayer {
this.getKills(); this.getKills();
this.getDeaths(); this.getDeaths();
this.isAdminBypassing = other.isAdminBypassing; this.isAdminBypassing = other.isAdminBypassing;
this.notificationsEnabled = other.notificationsEnabled;
this.showScoreboard = SaberFactions.plugin.getConfig().getBoolean("scoreboard.default-enabled", true); this.showScoreboard = SaberFactions.plugin.getConfig().getBoolean("scoreboard.default-enabled", true);
this.mapHeight = Conf.mapHeight; this.mapHeight = Conf.mapHeight;
} }
@ -208,6 +211,16 @@ public abstract class MemoryFPlayer implements FPlayer {
this.factionId = faction.getId(); this.factionId = faction.getId();
} }
@Override
public void setNotificationsEnabled(boolean enabled) {
this.notificationsEnabled = enabled;
}
@Override
public boolean hasNotificationsEnabled() {
return this.notificationsEnabled;
}
public String getFactionId() { public String getFactionId() {
return this.factionId; return this.factionId;
} }

View File

@ -700,6 +700,10 @@ public enum TL {
COMMAND_LOGOUT_DAMAGE_TAKEN("&c&l[!] &7Your logout was cancelled because you were damaged!"), COMMAND_LOGOUT_DAMAGE_TAKEN("&c&l[!] &7Your logout was cancelled because you were damaged!"),
COMMAND_LOGOUT_TELEPORTED("&c&l[!] &7Your logout was cancelled because you teleported!"), COMMAND_LOGOUT_TELEPORTED("&c&l[!] &7Your logout was cancelled because you teleported!"),
COMMAND_NOTIFICATIONS_TOGGLED_ON("&c&l[!] &7You will now see claimed land notifications!"),
COMMAND_NOTIFICATIONS_TOGGLED_OFF("&c&l[!] &7You will no longer see claimed land notifications!"),
COMMAND_NOTIFICATIONS_DESCRIPTION("Toggle notifications for land claiming"),
COMMAND_SHOW_NOFACTION_SELF("You are not in a faction"), COMMAND_SHOW_NOFACTION_SELF("You are not in a faction"),
COMMAND_SHOW_NOFACTION_OTHER("That's not a faction"), COMMAND_SHOW_NOFACTION_OTHER("That's not a faction"),
COMMAND_SHOW_TOSHOW("to show faction information"), COMMAND_SHOW_TOSHOW("to show faction information"),