From 80a1b3949ec02e5e330035dbb5135cb6f4d29176 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 21 Jan 2021 14:31:11 -0800 Subject: [PATCH] Add permission node 'mcmmo.broadcast.levelup' for level up broadcasts --- Changelog.txt | 5 +++++ src/main/java/com/gmail/nossr50/util/Permissions.java | 1 + .../com/gmail/nossr50/util/player/NotificationManager.java | 7 ++++++- src/main/resources/plugin.yml | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 8a20191a7..bba9f0b04 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,5 @@ Version 2.1.172 + Added 'mcmmo.broadcast.levelup' permission node, if a player lacks this node they will not have their level up milestones broadcast to chat Updated german locale (thanks TheBusyBiscuit) Changed Fists to not be capitalized (en_US) when lowering/readying berserk SkillActivationPerkEvent can now be called in async threads (thanks electronicboy) @@ -6,6 +7,10 @@ Version 2.1.172 Added 'Skills.Woodcutting.TreeFeller.Knock_On_Wood.Add_XP_Orbs_To_Drops' to advanced.yml Removed a few never implemented settings from Skills.Woodcutting.TreeFeller in advanced.yml + NOTES: + The new 'mcmmo.broadcast.levelup' node is a default node included under the 'mcmmo.defaults' node umbrella, you shouldn't have to give this to your players unless they don't have access to 'mcmmo.defaults' + If you don't have a permission plugin you don't need to worry, players will have this node by default in that case + Version 2.1.171 Fixed a bug where arrows shot by infinite bow enchant would duplicate Fixed a bug where Archery XP would calculate incorrectly diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index 3f804b363..c72b048b9 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -25,6 +25,7 @@ public final class Permissions { * GENERAL */ public static boolean motd(Permissible permissible) { return permissible.hasPermission("mcmmo.motd"); } + public static boolean levelUpBroadcast(Permissible permissible) { return permissible.hasPermission("mcmmo.broadcast.levelup"); } public static boolean mobHealthDisplay(Permissible permissible) { return permissible.hasPermission("mcmmo.mobhealthdisplay"); } public static boolean updateNotifications(Permissible permissible) {return permissible.hasPermission("mcmmo.tools.updatecheck"); } public static boolean chimaeraWing(Permissible permissible) { return permissible.hasPermission("mcmmo.item.chimaerawing"); } diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index 94b00513b..64bedc286 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -272,13 +272,18 @@ public class NotificationManager { //Check if broadcasting is enabled if(Config.getInstance().shouldLevelUpBroadcasts()) { + //Permission check + if(!Permissions.levelUpBroadcast(mmoPlayer.getPlayer())) { + return; + } + int levelInterval = Config.getInstance().getLevelUpBroadcastInterval(); int remainder = level % levelInterval; if(remainder == 0) { //Grab appropriate audience Audience audience = mcMMO.getAudiences().filter(getLevelUpBroadcastPredicate(mmoPlayer.getPlayer())); - //TODO: Make prettier+ + //TODO: Make prettier HoverEvent levelMilestoneHover = Component.text(mmoPlayer.getPlayer().getName()) .append(Component.newline()) .append(Component.text(LocalDate.now().toString())) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 03dbf7856..70499738e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -195,6 +195,7 @@ permissions: mcmmo.motd: true mcmmo.skills.all: true mcmmo.chat.colors: true + mcmmo.broadcast.levelup: true mcmmo.defaultsop: default: op description: mcmmo permissions that default to op @@ -219,6 +220,8 @@ permissions: mcmmo.defaultsop: true mcmmo.party.all: true mcmmo.perks.all: true + mcmmo.broadcast.levelup: + description: when the player reaches certain level milestones their achievement will be broadcast in chat to other plays mcmmo.ability.*: default: false description: Implies all mcmmo.ability permissions.