diff --git a/pom.xml b/pom.xml index 769d2c31..1f1c30e2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.massivecraft Factions - 1.6.9.5-U0.2.1-1.4.1-BETA + 1.6.9.5-U0.2.1-1.4.2-BETA jar SaberFactions @@ -86,7 +86,8 @@ spigot-api 1.13-R0.1-SNAPSHOT provided - + + bungeecord-chat net.md-5 diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index 7e7b164d..555ee118 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -26,8 +26,9 @@ import java.util.List; public interface FPlayer extends EconomyParticipator { + void setNotificationsEnabled(boolean notifications); - + boolean hasNotificationsEnabled(); void setAlt(boolean alt); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdNotifications.java b/src/main/java/com/massivecraft/factions/cmd/CmdNotifications.java new file mode 100644 index 00000000..a80d5d91 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdNotifications.java @@ -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; + } +} diff --git a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java index 439dc906..0e28b3c0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java @@ -126,6 +126,7 @@ public class FCmdRoot extends FCommand { public CmdViewChest cmdViewChest = new CmdViewChest(); public CmdPoints cmdPoints = new CmdPoints(); 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.cmdMod); this.addSubCommand(this.cmdMoney); + this.addSubCommand(this.cmdNotifications); this.addSubCommand(this.cmdOpen); this.addSubCommand(this.cmdOwner); this.addSubCommand(this.cmdOwnerList); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index dcf6061a..f6116c4d 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -593,12 +593,12 @@ public class FactionsPlayerListener implements Listener { String ownersTo = myFaction.getOwnerListString(to); if (changedFaction) { 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)); } } else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && myFaction == factionTo && !myFaction.isWilderness()) { String ownersFrom = myFaction.getOwnerListString(from); - if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) { + if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo) && me.hasNotificationsEnabled()) { if (!ownersTo.isEmpty()) { me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo)); } else if (!TL.GENERIC_PUBLICLAND.toString().isEmpty()) { diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index aed43f19..7a466b5f 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -75,7 +75,7 @@ public abstract class MemoryFPlayer implements FPlayer { protected transient long lastFrostwalkerMessage; protected transient boolean shouldTakeFallDamage = true; protected boolean isStealthEnabled = false; - boolean playerAlerts = false; + protected boolean notificationsEnabled = true; boolean inspectMode = false; protected boolean isAlt = false; @@ -99,6 +99,7 @@ public abstract class MemoryFPlayer implements FPlayer { this.lastLoginTime = System.currentTimeMillis(); this.mapAutoUpdating = false; this.autoClaimFor = null; + this.notificationsEnabled = true; this.autoSafeZoneEnabled = false; this.autoWarZoneEnabled = false; this.loginPvpDisabled = Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0; @@ -124,6 +125,7 @@ public abstract class MemoryFPlayer implements FPlayer { this.autoSafeZoneEnabled = other.autoSafeZoneEnabled; this.autoWarZoneEnabled = other.autoWarZoneEnabled; this.loginPvpDisabled = other.loginPvpDisabled; + this.notificationsEnabled = true; this.powerBoost = other.powerBoost; this.role = other.role; this.title = other.title; @@ -133,6 +135,7 @@ public abstract class MemoryFPlayer implements FPlayer { this.getKills(); this.getDeaths(); this.isAdminBypassing = other.isAdminBypassing; + this.notificationsEnabled = other.notificationsEnabled; this.showScoreboard = SaberFactions.plugin.getConfig().getBoolean("scoreboard.default-enabled", true); this.mapHeight = Conf.mapHeight; } @@ -208,6 +211,16 @@ public abstract class MemoryFPlayer implements FPlayer { this.factionId = faction.getId(); } + @Override + public void setNotificationsEnabled(boolean enabled) { + this.notificationsEnabled = enabled; + } + + @Override + public boolean hasNotificationsEnabled() { + return this.notificationsEnabled; + } + public String getFactionId() { return this.factionId; } diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index 69567acb..ae918f94 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -700,6 +700,10 @@ public enum TL { 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_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_OTHER("That's not a faction"), COMMAND_SHOW_TOSHOW("to show faction information"),