From 7e3b9b4b3a668f3d7629779a8c00315bd7e1d0cc Mon Sep 17 00:00:00 2001 From: Chiss Date: Sun, 14 Sep 2014 14:10:40 +1000 Subject: [PATCH 1/2] some 1.8 title stuff --- .../mineplex/core/common/util/UtilTitle.java | 40 +++++++++++++++++-- .../src/mineplex/hub/HubManager.java | 3 +- .../src/mineplex/hub/modules/NewsManager.java | 29 ++++++++++++-- .../src/nautilus/game/arcade/game/Game.java | 22 +++++++++- .../common/dominate_data/CapturePoint.java | 1 + .../game/games/minestrike/MineStrike.java | 3 ++ .../game/arcade/game/games/quiver/Quiver.java | 6 +-- 7 files changed, 91 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTitle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTitle.java index 185e7ea5e..9111afc9d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTitle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTitle.java @@ -13,13 +13,44 @@ import org.spigotmc.ProtocolInjector.PacketTitle.Action; */ public class UtilTitle { + public static void display(String text, String subtitle, Player... players) + { + setSubtitle(subtitle, players); + + showTitle(text, players); + } + + public static void display(String text, String subtitle) + { + setSubtitle(subtitle, UtilServer.getPlayers()); + + showTitle(text, UtilServer.getPlayers()); + } + + public static void display(String text, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks, Player... players) + { + setTimings(fadeInTicks, stayTicks, fadeOutTicks, players); + + display(text, subtitle, players); + } + + public static void display(String text, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) + { + setTimings(fadeInTicks, stayTicks, fadeOutTicks, UtilServer.getPlayers()); + + display(text, subtitle, UtilServer.getPlayers()); + } + /** * Show Title text for a player with their current set timings. * * Default timings are 20, 60, 20 (in ticks) */ - public static void showTitle(String text, Player... players) + private static void showTitle(String text, Player... players) { + if (text == null) + text = ""; + ChatMessage message = new ChatMessage(text); PacketTitle packet = new PacketTitle(Action.TITLE, message); sendPacket(packet, players); @@ -30,8 +61,11 @@ public class UtilTitle * * This stays unless reset or cleared, and doesn't appear unless a title is showing */ - public static void setSubtitle(String text, Player... players) + private static void setSubtitle(String text, Player... players) { + if (text == null) + text = ""; + ChatMessage message = new ChatMessage(text); PacketTitle packet = new PacketTitle(Action.SUBTITLE, message); sendPacket(packet, players); @@ -42,7 +76,7 @@ public class UtilTitle * * Remember these are in ticks */ - public static void setTimings(int fadeInTicks, int stayTicks, int fadeOutTicks, Player... players) + private static void setTimings(int fadeInTicks, int stayTicks, int fadeOutTicks, Player... players) { PacketTitle packet = new PacketTitle(Action.TIMES, fadeInTicks, stayTicks, fadeOutTicks); sendPacket(packet, players); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 6ac1234ba..35cb9a92b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -53,6 +53,7 @@ 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.UtilTitle; import mineplex.core.common.util.UtilWorld; import mineplex.core.treasure.TreasureManager; import mineplex.minecraft.game.core.condition.ConditionManager; @@ -945,6 +946,4 @@ public class HubManager extends MiniClientPlugin { } - - } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index b7488de85..38793e994 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -7,6 +7,8 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.server.ServerListPingEvent; import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; @@ -17,6 +19,7 @@ import mineplex.core.common.util.UtilDisplay; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTitle; import mineplex.core.mount.Mount; import mineplex.core.mount.types.MountDragon; import mineplex.core.updater.UpdateType; @@ -46,8 +49,10 @@ public class NewsManager extends MiniPlugin _news = new String[] { - "Champions: " + C.cYellow + C.Bold + "Team Deathmatch Beta", - "Survival: " + C.cGreen + C.Bold + "UHC Alpha", + "News Line 1", + "News Line 2", + "News Line 3", + "News Line 4", }; RefreshNews(); @@ -216,7 +221,7 @@ public class NewsManager extends MiniPlugin } @EventHandler - public void FlightUpdate(UpdateEvent event) + public void DragonBarUpdate(UpdateEvent event) { if (event.getType() != UpdateType.FASTEST) return; @@ -260,4 +265,22 @@ public class NewsManager extends MiniPlugin } } } + + @EventHandler + public void joinNewsOverlay(final PlayerJoinEvent event) + { + for (int i=0 ; i<_news.length ; i++) + { + final int count = i; + + UtilServer.getServer().getScheduler().runTaskLater(Manager.GetPlugin(), new Runnable() + { + @Override + public void run() + { + UtilTitle.display(C.cGold + C.Bold + "MINEPLEX" + ChatColor.RESET, _news[_news.length - 1 - count] + ChatColor.RESET, (count == 0) ? 20 : 0, 60, 20, event.getPlayer()); + } + }, 60 * i + (i != 0 ? 20 : 0)); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 34a5108a4..a8803dd93 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -902,6 +902,8 @@ public abstract class Game implements Listener if (!IsLive()) return; + String winnerText = ChatColor.WHITE + "§lNobody won the game..."; + for (Player player : UtilServer.getPlayers()) { player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f); @@ -917,11 +919,13 @@ public abstract class Game implements Listener { WinnerTeam = team; Winner = team.GetName() + " Team"; - UtilPlayer.message(player, team.GetColor() + C.Bold + team.GetName() + " won the game!"); + + winnerText = team.GetColor() + C.Bold + team.GetName() + " won the game!"; + UtilPlayer.message(player, winnerText); } else { - UtilPlayer.message(player, ChatColor.WHITE + "§lNobody won the game..."); + UtilPlayer.message(player, winnerText); } @@ -931,6 +935,8 @@ public abstract class Game implements Listener UtilPlayer.message(player, ArcadeFormat.Line); } + + UtilTitle.display(winnerText, _customWinLine, 20, 120, 20); if (AnnounceSilence) Manager.GetChat().Silence(5000, false); @@ -938,6 +944,8 @@ public abstract class Game implements Listener public void AnnounceEnd(List places) { + String winnerText = ChatColor.WHITE + "§lNobody won the game..."; + for (Player player : UtilServer.getPlayers()) { player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f); @@ -959,15 +967,23 @@ public abstract class Game implements Listener if (places.size() >= 1) { Winner = places.get(0).getName(); + + winnerText = C.cYellow + C.Bold + places.get(0).getName() + " won the game!"; + UtilPlayer.message(player, C.cRed + C.Bold + "1st Place" + C.cWhite + " - " + places.get(0).getName()); } if (places.size() >= 2) + { UtilPlayer.message(player, C.cGold + C.Bold + "2nd Place" + C.cWhite + " - " + places.get(1).getName()); + } + if (places.size() >= 3) + { UtilPlayer.message(player, C.cYellow + C.Bold + "3rd Place" + C.cWhite + " - " + places.get(2).getName()); + } } UtilPlayer.message(player, ""); @@ -976,6 +992,8 @@ public abstract class Game implements Listener UtilPlayer.message(player, ArcadeFormat.Line); } + UtilTitle.display(winnerText, null, 20, 120, 20); + if (AnnounceSilence) Manager.GetChat().Silence(5000, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/dominate_data/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/dominate_data/CapturePoint.java index c18a3c150..776da4d4d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/dominate_data/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/dominate_data/CapturePoint.java @@ -8,6 +8,7 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTitle; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.common.Domination; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java index 4b1f93434..ee9b5504f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java @@ -62,6 +62,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTitle; import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -1720,6 +1721,8 @@ public class MineStrike extends TeamGame for (Player player : UtilServer.getPlayers()) player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + + UtilTitle.display(winnerLine, _winText, 20, 120, 20); //Check for total game win EndCheck(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java index f474e2847..b374fcc58 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java @@ -90,7 +90,7 @@ public class Quiver extends SoloGame for (Player player : GetPlayers(true)) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)1, 1, F.item("Super Arrow"))); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow"))); player.playSound(player.getLocation(), Sound.PISTON_EXTEND, 3f, 2f); } } @@ -124,7 +124,7 @@ public class Quiver extends SoloGame public void run() { if (!player.getInventory().contains(Material.ARROW)) - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)1, 1, F.item("Super Arrow"))); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow"))); } }, 10); @@ -148,7 +148,7 @@ public class Quiver extends SoloGame if (player == null) return; //New Arrow - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)1, 1, F.item("Super Arrow"))); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow"))); player.playSound(player.getLocation(), Sound.PISTON_EXTEND, 3f, 2f); //Score From 26a51f4ef2ecf3b9855f9b870d9af9b517d2f23a Mon Sep 17 00:00:00 2001 From: Chiss Date: Sun, 14 Sep 2014 15:28:43 +1000 Subject: [PATCH 2/2] Re-allowed opening of chests (for GUIs) during games. --- .../game/arcade/managers/GameFlagManager.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index 2a6c3738c..560aaa26a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -261,14 +261,14 @@ public class GameFlagManager implements Listener } - if (!game.InventoryOpenChest) - { - if (event.getInventory().getType() == InventoryType.CHEST) - { - event.setCancelled(true); - event.getPlayer().closeInventory(); - } - } +// if (!game.InventoryOpenChest) +// { +// if (event.getInventory().getType() == InventoryType.CHEST) +// { +// event.setCancelled(true); +// event.getPlayer().closeInventory(); +// } +// } } @EventHandler(priority = EventPriority.LOWEST)