From ce7db289a7164b3aa19c210c86a7aba6878862a7 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 10 Feb 2015 02:31:33 +1300 Subject: [PATCH] Add commands /ignore and /unignore. Fixed mutes not working with private messaging --- .../mineplex/core/ignore/IgnoreManager.java | 244 +++++++++++ .../mineplex/core/ignore/command/Ignore.java | 38 ++ .../core/ignore/command/Unignore.java | 37 ++ .../mineplex/core/ignore/data/IgnoreData.java | 14 + .../core/ignore/data/IgnoreRepository.java | 60 +++ .../mineplex/core/message/MessageManager.java | 385 ++++++++++-------- .../src/mineplex/core/punish/Punish.java | 14 - .../Mineplex.Hub/src/mineplex/hub/Hub.java | 7 +- .../src/nautilus/game/arcade/Arcade.java | 5 +- 9 files changed, 623 insertions(+), 181 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Ignore.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Unignore.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreData.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java new file mode 100644 index 000000000..57448ad3e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java @@ -0,0 +1,244 @@ +package mineplex.core.ignore; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.jsonchat.ChildJsonMessage; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.ignore.command.Ignore; +import mineplex.core.ignore.command.Unignore; +import mineplex.core.ignore.data.IgnoreData; +import mineplex.core.ignore.data.IgnoreRepository; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.PreferencesManager; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.plugin.java.JavaPlugin; + +public class IgnoreManager extends MiniDbClientPlugin +{ + private PreferencesManager _preferenceManager; + private IgnoreRepository _repository; + private Portal _portal; + + public IgnoreManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, Portal portal) + { + super("Ignore", plugin, clientManager); + + _preferenceManager = preferences; + _repository = new IgnoreRepository(plugin); + _portal = portal; + } + + public PreferencesManager getPreferenceManager() + { + return _preferenceManager; + } + + public Portal getPortal() + { + return _portal; + } + + public boolean isIgnoring(Player caller, Player target) + { + return isIgnoring(caller, target.getName()); + } + + public boolean isIgnoring(Player caller, String target) + { + IgnoreData data = Get(caller); + + for (String ignored : data.getIgnored()) + { + if (ignored.equalsIgnoreCase(target)) + { + return true; + } + } + + return false; + } + + @Override + public void AddCommands() + { + addCommand(new Ignore(this)); + addCommand(new Unignore(this)); + } + + @Override + protected IgnoreData AddPlayer(String player) + { + return new IgnoreData(); + } + + @EventHandler + public void onChat(AsyncPlayerChatEvent event) + { + if (ClientManager.Get(event.getPlayer()).GetRank().Has(Rank.HELPER)) + return; + + Iterator itel = event.getRecipients().iterator(); + + while (itel.hasNext()) + { + Player player = itel.next(); + + IgnoreData info = Get(player); + + for (String ignored : info.getIgnored()) + { + if (ignored.equalsIgnoreCase(event.getPlayer().getName())) + { + itel.remove(); + + break; + } + } + } + } + + public void addIgnore(final Player caller, final String name) + { + if (caller.getName().equalsIgnoreCase(name)) + { + caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot ignore yourself")); + return; + } + + for (String status : Get(caller).getIgnored()) + { + if (status.equalsIgnoreCase(name)) + { + caller.sendMessage(F.main(getName(), ChatColor.GREEN + name + ChatColor.GRAY + " has already been ignored.")); + return; + + } + } + + IgnoreData ignoreData = Get(caller); + + if (ignoreData != null) + { + ignoreData.getIgnored().add(name); + } + + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() + { + public void run() + { + _repository.addIgnore(caller, name); + + Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + caller.sendMessage(F.main(getName(), "Now ignoring " + ChatColor.GREEN + name)); + } + }); + } + }); + } + + public void removeIgnore(final Player caller, final String name) + { + IgnoreData ignoreData = Get(caller); + + if (ignoreData != null) + { + Iterator itel = ignoreData.getIgnored().iterator(); + + while (itel.hasNext()) + { + String ignored = itel.next(); + + if (ignored.equalsIgnoreCase(name)) + { + itel.remove(); + break; + } + } + } + + caller.sendMessage(F.main(getName(), "No longer ignoring " + ChatColor.GREEN + name + ChatColor.GRAY + "!")); + + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() + { + public void run() + { + _repository.removeIgnore(caller.getName(), name); + } + }); + } + + public void showIgnores(Player caller) + { + List ignoredPlayers = Get(caller).getIgnored(); + + caller.sendMessage(C.cAqua + C.Strike + "=====================[" + ChatColor.RESET + C.cWhite + C.Bold + "Ignoring" + + ChatColor.RESET + C.cAqua + C.Strike + "]======================"); + + ArrayList sentLines = new ArrayList(); + + for (String ignored : ignoredPlayers) + { + + ChildJsonMessage message = new JsonMessage("").color("white").extra("").color("white"); + + message.add("Ignoring " + ignored).color("gray"); + + message.add(" - ").color("white"); + + message.add("Unignore").color("red").bold().click("run_command", "/unignore " + ignored) + .hover("show_text", "Stop ignoring " + ignored); + + sentLines.add(message); + } + + // Send In Order + for (JsonMessage msg : sentLines) + msg.sendToPlayer(caller); + + if (sentLines.isEmpty()) + { + caller.sendMessage(" "); + caller.sendMessage("Welcome to your Ignore List!"); + caller.sendMessage(" "); + caller.sendMessage("To ignore people, type " + C.cGreen + "/ignore "); + caller.sendMessage(" "); + caller.sendMessage("Type " + C.cGreen + "/ignore" + ChatColor.RESET + " at any time to view the ignored!"); + caller.sendMessage(" "); + } + + ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike + + "====================================================="); + + message.sendToPlayer(caller); + } + + @Override + public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException + { + Set(playerName, _repository.loadClientInformation(resultSet)); + } + + @Override + public String getQuery(String uuid, String name) + { + return "SELECT tA.Name FROM accountIgnore INNER Join accounts AS fA ON fA.uuid = uuidIgnorer INNER JOIN accounts AS tA ON tA.uuid = uuidIgnored LEFT JOIN playerMap ON tA.name = playerName WHERE uuidIgnorer = '" + + uuid + "';"; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Ignore.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Ignore.java new file mode 100644 index 000000000..40c975cc6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Ignore.java @@ -0,0 +1,38 @@ +package mineplex.core.ignore.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; +import mineplex.core.ignore.IgnoreManager; + +import org.bukkit.entity.Player; + +public class Ignore extends CommandBase +{ + public Ignore(IgnoreManager plugin) + { + super(plugin, Rank.ALL, "ignore"); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if (args == null) + { + Plugin.showIgnores(caller); + } + else + { + CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback() + { + public void run(String result) + { + if (result != null) + { + Plugin.addIgnore(caller, result); + } + } + }); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Unignore.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Unignore.java new file mode 100644 index 000000000..f8f97f819 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Unignore.java @@ -0,0 +1,37 @@ +package mineplex.core.ignore.command; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.ignore.IgnoreManager; + +import org.bukkit.entity.Player; + +public class Unignore extends CommandBase +{ + public Unignore(IgnoreManager plugin) + { + super(plugin, Rank.ALL, "unignore"); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if (args == null) + F.main(Plugin.getName(), "You need to include a player's name."); + else + { + CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback() + { + public void run(String result) + { + if (result != null) + { + Plugin.removeIgnore(caller, result); + } + } + }); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreData.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreData.java new file mode 100644 index 000000000..48f3e055d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreData.java @@ -0,0 +1,14 @@ +package mineplex.core.ignore.data; + +import java.util.ArrayList; + +public class IgnoreData +{ + private ArrayList _ignored = new ArrayList(); + + public ArrayList getIgnored() + { + return _ignored; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java new file mode 100644 index 000000000..05a4480c5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java @@ -0,0 +1,60 @@ +package mineplex.core.ignore.data; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.column.ColumnVarChar; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +public class IgnoreRepository extends RepositoryBase +{ + private static String ADD_IGNORE_RECORD = "INSERT INTO accountIgnore (uuidIgnorer, uuidIgnored) SELECT fA.uuid AS uuidIgnorer, tA.uuid AS uuidIgnored FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;"; + private static String DELETE_IGNORE_RECORD = "DELETE aF FROM accountIgnore AS aF INNER JOIN accounts as fA ON aF.uuidIgnorer = fA.uuid INNER JOIN accounts AS tA ON aF.uuidIgnored = tA.uuid WHERE fA.name = ? AND tA.name = ?;"; + + public IgnoreRepository(JavaPlugin plugin) + { + super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", + "root", "tAbechAk3wR7tuTh"); + } + + @Override + protected void initialize() + { + } + + @Override + protected void update() + { + } + + public boolean addIgnore(final Player caller, String name) + { + int rowsAffected = executeUpdate(ADD_IGNORE_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, + caller.getName())); + + return rowsAffected > 0; + } + + public boolean removeIgnore(String caller, String name) + { + int rowsAffected = executeUpdate(DELETE_IGNORE_RECORD, new ColumnVarChar("name", 100, caller), new ColumnVarChar("name", + 100, name)); + + return rowsAffected > 0; + } + + public IgnoreData loadClientInformation(ResultSet resultSet) throws SQLException + { + IgnoreData ignoreData = new IgnoreData(); + + while (resultSet.next()) + { + ignoreData.getIgnored().add(resultSet.getString(1)); + } + + return ignoreData; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index fa3666096..00990a922 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -15,196 +15,251 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.ignore.IgnoreManager; import mineplex.core.message.Commands.*; import mineplex.core.preferences.PreferencesManager; +import mineplex.core.punish.Punish; +import mineplex.core.punish.PunishClient; +import mineplex.core.punish.Punishment; +import mineplex.core.punish.PunishmentSentence; import mineplex.serverdata.ServerCommandManager; import mineplex.serverdata.transfers.AnnouncementCommand; public class MessageManager extends MiniClientPlugin { - private LinkedList _randomMessage; - - private CoreClientManager _clientManager; - private PreferencesManager _preferences; + private LinkedList _randomMessage; - public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences) - { - super("Message", plugin); - - _clientManager = clientManager; - _preferences = preferences; - - ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, new AnnouncementHandler()); - } + private CoreClientManager _clientManager; + private PreferencesManager _preferences; + private IgnoreManager _ignoreManager; + private Punish _punish; - //Module Functions - @Override - public void Enable() - { - _randomMessage = new LinkedList(); - _randomMessage.clear(); - _randomMessage.add("Hello, do you have any wild boars for purchase?"); - _randomMessage.add("There's a snake in my boot!"); - _randomMessage.add("Monk, I need a Monk!"); - _randomMessage.add("Hi, I'm from planet minecraft, op me plz dooooood!"); - _randomMessage.add("Somebody's poisoned the waterhole!"); - _randomMessage.add("MORE ORBZ MORE ORBZ MORE ORBZ MORE ORBZ!"); - _randomMessage.add("Chiss is a chiss and chiss chiss."); - _randomMessage.add("*_*"); - _randomMessage.add("#swag"); - _randomMessage.add("Everything went better then I thought."); - _randomMessage.add("HAVE A CHICKEN!"); - _randomMessage.add("follow me, i have xrays"); - _randomMessage.add("I'm making a java"); - _randomMessage.add("Do you talk to strangers? I have candy if it helps."); - _randomMessage.add("Solid 2.9/10"); - _randomMessage.add("close your eyes to sleep"); - _randomMessage.add("I crashed because my internet ran out."); - _randomMessage.add("I saw morgan freeman on a breaking bad ad on a bus."); - _randomMessage.add("Where is the volume control?"); - _randomMessage.add("I saw you playing on youtube with that guy and stuff."); - _randomMessage.add("Your worms must be worse than useless."); - _randomMessage.add("meow"); - _randomMessage.add("7"); - _randomMessage.add("Don't you wish your girlfriend was hot like me?"); - _randomMessage.add("how do you play mindcrafts?"); - _randomMessage.add("7 cats meow meow meow meow meow meow meow"); - _randomMessage.add("For King Jonalon!!!!!"); - _randomMessage.add("Do you like apples?"); - _randomMessage.add("I'm Happy Happy Happy."); - _randomMessage.add("kthxbye"); - _randomMessage.add("i like pie."); - _randomMessage.add("Do you play Clash of Clans?"); - _randomMessage.add("Mmm...Steak!"); - } + public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, + IgnoreManager ignoreManager, Punish punish) + { + super("Message", plugin); - - public void AddCommands() - { - addCommand(new MessageCommand(this)); - addCommand(new ResendCommand(this)); - - addCommand(new MessageAdminCommand(this)); - addCommand(new ResendAdminCommand(this)); - - addCommand(new AnnounceCommand(this)); - addCommand(new GlobalCommand(this)); - - addCommand(new AdminCommand(this)); - } - - public void Help(Player caller, String message) - { - UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + "Err...something went wrong?")); - } - - public void Help(Player caller) - { - Help(caller, null); - } + _clientManager = clientManager; + _preferences = preferences; + _ignoreManager = ignoreManager; + _punish = punish; + ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, + new AnnouncementHandler()); + } -/* XXX Incorporate this - PunishChatEvent event = new PunishChatEvent(caller); - - GetPlugin().getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) - return; -*/ + // Module Functions + @Override + public void Enable() + { + _randomMessage = new LinkedList(); + _randomMessage.clear(); + _randomMessage.add("Hello, do you have any wild boars for purchase?"); + _randomMessage.add("There's a snake in my boot!"); + _randomMessage.add("Monk, I need a Monk!"); + _randomMessage.add("Hi, I'm from planet minecraft, op me plz dooooood!"); + _randomMessage.add("Somebody's poisoned the waterhole!"); + _randomMessage.add("MORE ORBZ MORE ORBZ MORE ORBZ MORE ORBZ!"); + _randomMessage.add("Chiss is a chiss and chiss chiss."); + _randomMessage.add("*_*"); + _randomMessage.add("#swag"); + _randomMessage.add("Everything went better then I thought."); + _randomMessage.add("HAVE A CHICKEN!"); + _randomMessage.add("follow me, i have xrays"); + _randomMessage.add("I'm making a java"); + _randomMessage.add("Do you talk to strangers? I have candy if it helps."); + _randomMessage.add("Solid 2.9/10"); + _randomMessage.add("close your eyes to sleep"); + _randomMessage.add("I crashed because my internet ran out."); + _randomMessage.add("I saw morgan freeman on a breaking bad ad on a bus."); + _randomMessage.add("Where is the volume control?"); + _randomMessage.add("I saw you playing on youtube with that guy and stuff."); + _randomMessage.add("Your worms must be worse than useless."); + _randomMessage.add("meow"); + _randomMessage.add("7"); + _randomMessage.add("Don't you wish your girlfriend was hot like me?"); + _randomMessage.add("how do you play mindcrafts?"); + _randomMessage.add("7 cats meow meow meow meow meow meow meow"); + _randomMessage.add("For King Jonalon!!!!!"); + _randomMessage.add("Do you like apples?"); + _randomMessage.add("I'm Happy Happy Happy."); + _randomMessage.add("kthxbye"); + _randomMessage.add("i like pie."); + _randomMessage.add("Do you play Clash of Clans?"); + _randomMessage.add("Mmm...Steak!"); + } - public void DoMessage(Player from, Player to, String message) - { - if (!_preferences.Get(to).PrivateMessaging) - { - UtilPlayer.message(from, C.cPurple + to.getName() + " has private messaging disabled."); - return; - } - - //Inform - UtilPlayer.message(from, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message); + public void AddCommands() + { + addCommand(new MessageCommand(this)); + addCommand(new ResendCommand(this)); - //Save - Get(from).LastTo = to.getName(); + addCommand(new MessageAdminCommand(this)); + addCommand(new ResendAdminCommand(this)); - //Chiss - if (to.getName().equals("Chiss")) - { - UtilPlayer.message(from, C.cPurple + "Chiss is often AFK or minimized, due to plugin development."); - UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly."); - } + addCommand(new AnnounceCommand(this)); + addCommand(new GlobalCommand(this)); - //Defek - if (to.getName().equals("defek7")) - { - UtilPlayer.message(from, C.cPurple + "defek7 is often AFK or minimized, due to plugin development."); - UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly."); - } - - //Log - //Logger().logChat("Private Message", from, to.getName(), message); + addCommand(new AdminCommand(this)); + } - //Ignored XXX - //if (Get(to).Ignore().IsIgnored(from.getName())) - // return; - - //Sound - from.playSound(to.getLocation(), Sound.NOTE_PIANO, 1f, 1f); - to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); + public void Help(Player caller, String message) + { + UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + "Err...something went wrong?")); + } - //Send - UtilPlayer.message(to, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message); - } + public void Help(Player caller) + { + Help(caller, null); + } - public void DoMessageAdmin(Player from, Player to, String message) - { - //Inform - UtilPlayer.message(from, C.cPurple + "-> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple + message); + /* XXX Incorporate this + PunishChatEvent event = new PunishChatEvent(caller); + + GetPlugin().getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) + return; + */ - //Inform Admins - for (Player staff : UtilServer.getPlayers()) - if (!to.equals(staff)) - if (!from.equals(staff)) - if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER)) - UtilPlayer.message(staff, F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + - C.cPurple + " -> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple + message); + public boolean canMessage(Player from, Player to) + { + PunishClient client = _punish.GetClient(from.getName()); - //Save - Get(from).LastAdminTo = to.getName(); + if (client.IsMuted()) + { + Punishment punishment = client.GetPunishment(PunishmentSentence.Mute); - //Send - UtilPlayer.message(to, C.cPurple + "<- " + F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + " " + C.cPurple + message); + from.sendMessage(F.main(_punish.getName(), "Shh, you're muted because " - //Sound - from.playSound(to.getLocation(), Sound.NOTE_PIANO, 1f, 1f); - to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); - - //Log XXX - //Logger().logChat("Staff Message", from, to.getName(), message); - } + + punishment.GetReason() - @Override - protected ClientMessage AddPlayer(String player) - { - Set(player, new ClientMessage()); - return Get(player); - } + + " by " - public LinkedList GetRandomMessages() - { - return _randomMessage; - } + + punishment.GetAdmin() - public String GetRandomMessage() - { - if (_randomMessage.isEmpty()) - return "meow"; - - return _randomMessage.get(UtilMath.r(_randomMessage.size())); - } + + " for " - public CoreClientManager GetClientManager() - { - return _clientManager; - } + + C.cGreen + + + UtilTime.convertString(punishment.GetRemaining(), 1, TimeUnit.FIT) + ".")); + return false; + } + + // If the receiver has turned off private messaging and the sender isn't a mod + if (!_preferences.Get(to).PrivateMessaging && !_clientManager.Get(from).GetRank().Has(Rank.HELPER)) + { + UtilPlayer.message(from, C.cPurple + to.getName() + " has private messaging disabled."); + return false; + } + + if (_ignoreManager.isIgnoring(from, to)) + { + from.sendMessage(F.main(_ignoreManager.getName(), ChatColor.GRAY + "You are ignoring that player")); + + return false; + } + + // If the receiver is ignoring the sender, and the sender isn't a mod + if (_ignoreManager.isIgnoring(to, from) && !_clientManager.Get(from).GetRank().Has(Rank.HELPER)) + { + from.sendMessage(F.main(_ignoreManager.getName(), ChatColor.GRAY + "That player is ignoring you")); + + return false; + } + + return true; + } + + public void DoMessage(Player from, Player to, String message) + { + if (!canMessage(from, to)) + { + return; + } + + // Inform + UtilPlayer.message(from, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message); + + // Save + Get(from).LastTo = to.getName(); + + // Chiss or defek7 + if (to.getName().equals("Chiss") || to.getName().equals("defek7")) + { + UtilPlayer.message(from, C.cPurple + to.getName() + "is often AFK or minimized, due to plugin development."); + UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly."); + } + + // Log + // Logger().logChat("Private Message", from, to.getName(), message); + + // Ignored XXX + // if (Get(to).Ignore().IsIgnored(from.getName())) + // return; + + // Sound + from.playSound(to.getLocation(), Sound.NOTE_PIANO, 1f, 1f); + to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); + + // Send + UtilPlayer.message(to, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message); + } + + public void DoMessageAdmin(Player from, Player to, String message) + { + // Inform + UtilPlayer.message(from, C.cPurple + "-> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + + C.cPurple + message); + + // Inform Admins + for (Player staff : UtilServer.getPlayers()) + if (!to.equals(staff)) + if (!from.equals(staff)) + if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER)) + UtilPlayer.message(staff, F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + C.cPurple + + " -> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple + + message); + + // Save + Get(from).LastAdminTo = to.getName(); + + // Send + UtilPlayer.message(to, C.cPurple + "<- " + F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + " " + + C.cPurple + message); + + // Sound + from.playSound(to.getLocation(), Sound.NOTE_PIANO, 1f, 1f); + to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); + + // Log XXX + // Logger().logChat("Staff Message", from, to.getName(), message); + } + + @Override + protected ClientMessage AddPlayer(String player) + { + Set(player, new ClientMessage()); + return Get(player); + } + + public LinkedList GetRandomMessages() + { + return _randomMessage; + } + + public String GetRandomMessage() + { + if (_randomMessage.isEmpty()) + return "meow"; + + return _randomMessage.get(UtilMath.r(_randomMessage.size())); + } + + public CoreClientManager GetClientManager() + { + return _clientManager; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index 687720631..321d30896 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -27,7 +27,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -108,19 +107,6 @@ public class Punish extends MiniPlugin event.setCancelled(true); } } - - @EventHandler(priority = EventPriority.LOWEST) - public void PunishChatEvent(PlayerCommandPreprocessEvent event) - { - PunishClient client = GetClient(event.getPlayer().getName()); - - if (client != null && client.IsMuted() && event.getMessage().startsWith("/msg")) - { - event.getPlayer().sendMessage(F.main(getName(), "Shh, you're muted because " + client.GetPunishment(PunishmentSentence.Mute).GetReason() + " by " + client.GetPunishment(PunishmentSentence.Mute).GetAdmin() + " for " + C.cGreen + UtilTime.convertString(client.GetPunishment(PunishmentSentence.Mute).GetRemaining(), 1, TimeUnit.FIT) + ".")); - event.setMessage(" "); - event.setCancelled(true); - } - } public void Help(Player caller) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 18a4d4972..80cf2cd34 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -17,6 +17,7 @@ import mineplex.core.elo.EloManager; import mineplex.core.energy.Energy; import mineplex.core.friend.FriendManager; import mineplex.core.hologram.HologramManager; +import mineplex.core.ignore.IgnoreManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.memory.MemoryFix; import mineplex.core.message.MessageManager; @@ -89,7 +90,6 @@ public class Hub extends JavaPlugin implements IRelation DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager); preferenceManager.GiveItem = true; - new MessageManager(this, clientManager, preferenceManager); Creature creature = new Creature(this); NpcManager npcManager = new NpcManager(this, creature); PetManager petManager = new PetManager(this, clientManager, donationManager, disguiseManager, creature, blockRestore, webServerAddress); @@ -98,8 +98,13 @@ public class Hub extends JavaPlugin implements IRelation //Main Modules ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager); + Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); + + IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); + new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish); + StatsManager statsManager = new StatsManager(this, clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager); HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 4a437b540..ae3667a78 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -21,6 +21,7 @@ import mineplex.core.donation.DonationManager; import mineplex.core.friend.FriendManager; import mineplex.core.gadget.GadgetManager; import mineplex.core.hologram.HologramManager; +import mineplex.core.ignore.IgnoreManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.memory.MemoryFix; @@ -86,7 +87,6 @@ public class Arcade extends JavaPlugin _serverConfiguration = new ServerConfiguration(this); PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager); - new MessageManager(this, _clientManager, preferenceManager); Creature creature = new Creature(this); ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); @@ -104,6 +104,9 @@ public class Arcade extends JavaPlugin AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); AntiHack.Instance.setKick(false); + IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); + new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish); + BlockRestore blockRestore = new BlockRestore(this); ProjectileManager projectileManager = new ProjectileManager(this);