From ab9bf2f405dced16206e49c394aee857cee1c750 Mon Sep 17 00:00:00 2001 From: TadahTech Date: Thu, 28 Jul 2016 03:40:24 -0500 Subject: [PATCH] Fixes possible bug with party leaders not seeing chat. Adds pling when you received an invite. --- .../party/manager/PartyInviteManager.java | 2 + .../core/party/manager/PartyRedisManager.java | 37 +++++++++---------- .../src/mineplex/core/portal/Portal.java | 6 +++ .../src/mineplex/hub/HubManager.java | 10 +---- .../arcade/managers/chat/GameChatManager.java | 16 +++----- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java index b05477683..bfff39b40 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java @@ -17,6 +17,7 @@ import net.md_5.bungee.api.chat.ClickEvent.Action; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; @@ -124,6 +125,7 @@ public class PartyInviteManager inviteTo(player.getUniqueId(), sender, sender, serverFrom); Lang.INVITE_RECEIVED.send(player, sender); sendAcceptOrDeny(player, sender); + player.playSound(player.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java index 4f1d01473..993fe1a5f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java @@ -139,12 +139,7 @@ public class PartyRedisManager case PLAYER_FIND_RESPONSE: UUID uuid = UUID.fromString(third); - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); if (_plugin.getInviteManager().isInvitedTo(uuid, inviter.getName())) @@ -177,12 +172,7 @@ public class PartyRedisManager private void handleNotAccepting(String second, String[] contents) { - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); inviter.sendMessage(F.main("Party", F.name(second) + " is not accepting invites at this time.")); @@ -190,13 +180,7 @@ public class PartyRedisManager private void handleAlreadyIn(String second, String[] contents) { - BukkitTask task = TASKS.remove(second); - - if (task != null) - { - task.cancel(); - } - + cancelTask(second); Player inviter = Bukkit.getPlayerExact(contents[3]); Lang.ALREADY_IN.send(inviter, second); } @@ -215,6 +199,11 @@ public class PartyRedisManager @Override public void run() { + if(!TASKS.containsKey(player)) + { + cancel(); + return; + } TASKS.remove(player); Player senderPlayer = Bukkit.getPlayerExact(sender); if (senderPlayer == null) @@ -293,4 +282,14 @@ public class PartyRedisManager { return FIND_PLAYERS_CHANNEL; } + + public void cancelTask(String player) + { + BukkitTask task = TASKS.remove(player); + + if (task != null) + { + task.cancel(); + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 1b02de296..0e872a0c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -9,6 +9,7 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTabTitle; +import mineplex.core.party.Lang; import mineplex.core.party.Party; import mineplex.core.party.event.PartySendToServerEvent; import mineplex.core.portal.Commands.SendCommand; @@ -101,6 +102,11 @@ public class Portal extends MiniPlugin if (event.getParty() != null && override) { Party party = event.getParty(); + if(!party.getOwner().equalsIgnoreCase(player.getName())) + { + Lang.NOT_OWNER_SERVER.send(player); + return; + } sendParty(party); return; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index c983c9cbb..88fc33b11 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -102,6 +102,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Random; +import java.util.stream.Collectors; public class HubManager extends MiniClientPlugin { @@ -601,14 +602,7 @@ public class HubManager extends MiniClientPlugin event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); - - for (String name : party.getMembers()) - { - Player other = UtilPlayer.searchExact(name); - - if (other != null) - event.getRecipients().add(other); - } + event.getRecipients().addAll(party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList())); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 368746c24..00beb0a37 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -11,6 +11,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -25,6 +26,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; +import java.util.stream.Collectors; public class GameChatManager implements Listener { @@ -131,20 +133,14 @@ public class GameChatManager implements Listener event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + event.getPlayer().getName() + " " + C.cPurple + "%2$s"); - - for (String member : party.getMembers()) - { - Player other = UtilPlayer.searchExact(member); - - if (other != null) - event.getRecipients().add(other); - } + event.getRecipients().addAll(party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList())); } else { - UtilPlayer.message(sender, F.main("Party", "You are not in a Party.")); + UtilPlayer.message(event.getPlayer(), F.main("Party", "You are not in a Party.")); event.setCancelled(true); } + return; } @@ -156,7 +152,7 @@ public class GameChatManager implements Listener format = event.getFormat().split(rankStr)[0]; name = _manager.GetColor(sender) + sender.getName() + C.Reset; - if (event.getMessage().charAt(0) == '@') + if (event.getMessage().charAt(0) == '#') message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage().substring(1, event.getMessage().length())); else message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage());