From 0d7e404da88508c2a2c24954b94598fd6d836baf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 12 Aug 2017 23:50:43 -0400 Subject: [PATCH] Add mute awareness message feature for t3 Tested by t3hero --- .../mineplex/core/message/ClientMessage.java | 2 +- .../mineplex/core/message/MessageManager.java | 51 +++++++++++-------- .../core/message/redis/RedisMessage.java | 2 +- .../message/redis/RedisMessageCallback.java | 12 +++-- .../mineplex/core/preferences/Preference.java | 8 +-- 5 files changed, 46 insertions(+), 29 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java index c27e778fa..64956db8f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java @@ -6,4 +6,4 @@ public class ClientMessage public String LastAdminTo; public long LastToTime; public int SpamCounter; -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index cbb4950e9..0096f0486 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -1,5 +1,17 @@ package mineplex.core.message; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.chat.Chat; @@ -33,18 +45,6 @@ import mineplex.core.punish.Punishment; import mineplex.core.punish.PunishmentSentence; import mineplex.serverdata.commands.AnnouncementCommand; import mineplex.serverdata.commands.ServerCommandManager; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; public class MessageManager extends MiniClientPlugin { @@ -263,6 +263,10 @@ public class MessageManager extends MiniClientPlugin // Send UtilPlayer.message(to, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message); + if (_punish.GetClient(to.getName()).IsMuted() && _preferences.get(to).isActive(Preference.INFORM_MUTED)) + { + UtilPlayer.message(from, F.main(getName(), F.elem(to.getName()) + " is currently muted and cannot reply to you!")); + } } public void DoMessageAdmin(Player from, Player to, String message) @@ -345,7 +349,8 @@ public class MessageManager extends MiniClientPlugin "Mmm...Steak!", "Poop! Poop everywhere!", "I'm so forgetful. Like I was going to say somethin...wait what were we talking about?", - "Mmm...Steak!" + "Mmm...Steak!", + "#BlameAlex" ); } @@ -359,7 +364,7 @@ public class MessageManager extends MiniClientPlugin if (_randomMessage.isEmpty()) return "meow"; - return _randomMessage.get(UtilMath.r(_randomMessage.size())); + return UtilMath.randomElement(_randomMessage); } public void Help(Player caller) @@ -392,7 +397,7 @@ public class MessageManager extends MiniClientPlugin // Message the sender RedisMessageCallback message = new RedisMessageCallback(globalMessage, true, to.getName(), - C.cPurple + "-> " + toRank + " " + to.getName() + " " + C.cPurple + globalMessage.getMessage()); + C.cPurple + "-> " + toRank + " " + to.getName() + " " + C.cPurple + globalMessage.getMessage(), false); // Inform Admins for (Player staff : UtilServer.getPlayers()) @@ -416,8 +421,7 @@ public class MessageManager extends MiniClientPlugin if (canMessage != null) { - - RedisMessageCallback message = new RedisMessageCallback(globalMessage, false, null, canMessage); + RedisMessageCallback message = new RedisMessageCallback(globalMessage, false, null, canMessage, false); message.publish(); @@ -431,9 +435,11 @@ public class MessageManager extends MiniClientPlugin UtilPlayer.message(to, message); to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); + + boolean informMuted = _punish.GetClient(to.getName()).IsMuted() && _preferences.get(to).isActive(Preference.INFORM_MUTED); // Message the sender - RedisMessageCallback redisMessage = new RedisMessageCallback(globalMessage, false, to.getName(), message); + RedisMessageCallback redisMessage = new RedisMessageCallback(globalMessage, false, to.getName(), message, informMuted); redisMessage.publish(); } @@ -453,6 +459,11 @@ public class MessageManager extends MiniClientPlugin if (target != null) { target.sendMessage(message.getMessage()); + + if (message.informMuted()) + { + UtilPlayer.message(target, F.main(getName(), F.elem(message.getLastReplied()) + " is currently muted and cannot reply to you!")); + } target.playSound(target.getLocation(), Sound.NOTE_PIANO, 2f, 2f); @@ -647,6 +658,6 @@ public class MessageManager extends MiniClientPlugin public PreferencesManager getPreferences() { - return this._preferences; + return _preferences; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessage.java index 941ea76e5..2cd47cc02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessage.java @@ -70,4 +70,4 @@ public class RedisMessage extends ServerCommand { // Utilitizes a callback functionality to seperate dependencies } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessageCallback.java b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessageCallback.java index 11a634d37..e5218ebe0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessageCallback.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessageCallback.java @@ -12,16 +12,17 @@ public class RedisMessageCallback extends ServerCommand private String _message; private String _setLastMessage; private String _target; - private boolean _staffMessage; + private boolean _staffMessage, _informMuted; private UUID _uuid; - public RedisMessageCallback(RedisMessage globalMessage, boolean staffMessage, String receivedPlayer, String message) + public RedisMessageCallback(RedisMessage globalMessage, boolean staffMessage, String receivedPlayer, String message, boolean informMuted) { _target = globalMessage.getSender(); _message = message; _setLastMessage = receivedPlayer; _uuid = globalMessage.getUUID(); _staffMessage = staffMessage; + _informMuted = informMuted; if (globalMessage.getSendingServer() != null) { @@ -33,6 +34,11 @@ public class RedisMessageCallback extends ServerCommand { return _staffMessage; } + + public boolean informMuted() + { + return _informMuted; + } public String getLastReplied() { @@ -59,4 +65,4 @@ public class RedisMessageCallback extends ServerCommand { // Utilitizes a callback functionality to seperate dependencies } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java index 66c0f116c..20fc14901 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java @@ -48,7 +48,9 @@ public enum Preference PARTY_DISPLAY_INVENTORY_UI(true, PreferenceCategory.SOCIAL, Material.CHEST, "Display Parties GUI"), - RANDOM_MESSAGES(true, PreferenceCategory.USER, Material.COMMAND, "Send random messages", "Got nothing to say? We got you covered!") + RANDOM_MESSAGES(true, PreferenceCategory.USER, Material.COMMAND, "Send Random Messages", "Got nothing to say? We got you covered!"), + + INFORM_MUTED(false, PreferenceCategory.USER, Material.BARRIER, "Inform When Muted", "Inform people who message you if you are muted!") ; private static final Map PREFERENCE_MAP = Maps.newHashMap(); @@ -118,6 +120,4 @@ public enum Preference { return PREFERENCE_MAP.get(id); } - - -} +} \ No newline at end of file