diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index a3695d0c5..1958205ae 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -123,6 +123,7 @@ import mineplex.core.gadget.gadgets.morph.MorphSquid; import mineplex.core.gadget.gadgets.morph.MorphTitan; import mineplex.core.gadget.gadgets.morph.MorphUncleSam; import mineplex.core.gadget.gadgets.morph.MorphVillager; +import mineplex.core.gadget.gadgets.morph.MorphWitch; import mineplex.core.gadget.gadgets.morph.MorphWither; import mineplex.core.gadget.gadgets.morph.managers.SoulManager; import mineplex.core.gadget.gadgets.morph.managers.SwimManager; @@ -362,6 +363,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphSnowman(this)); addGadget(new MorphUncleSam(this)); addGadget(new MorphSquid(this)); + addGadget(new MorphWitch(this)); addGadget(new MorphGrimReaper(this)); // Not being added in this update! //addGadget(new MorphMetalMan(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java index bbbe726ce..265cc7d3d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java @@ -110,12 +110,7 @@ public class OutfitWindUpSuitBoosterManager NoteSong song = NBSReader.loadSong(new DataInputStream(new FileInputStream(songFile)), songFile.getName().replace("_", " ").replace(".nbs", "")); if (song != null) { - NotePlayer notePlayer = new NotePlayer(_gadget.getPlugin(), song, new INoteVerifier() { - @Override - public boolean shouldPlay(Player toPlay) { - return true; - } - }, 0.5F, true, player); + NotePlayer notePlayer = new NotePlayer(_gadget.getPlugin(), song, p -> true, 0.5F, true, player); _notePlayers.put(player, notePlayer); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/noteblock/MusicManager.java b/Plugins/Mineplex.Core/src/mineplex/core/noteblock/MusicManager.java new file mode 100644 index 000000000..fc02b0f38 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/noteblock/MusicManager.java @@ -0,0 +1,106 @@ +package mineplex.core.noteblock; + +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Random; +import java.util.function.Predicate; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.noteblock.event.SongFinishEvent; + +/** + * Very basic Manager to play music across the entire server. Specifically used for Lobby Music + * + * Created by shaun on 2016-10-05. + */ +public class MusicManager extends MiniPlugin +{ + private Random _random = new Random(); + private final ArrayList _songs = new ArrayList<>(); + private int _lastSong = 0; + + private final Predicate _shouldPlay; + + public MusicManager(Predicate shouldPlay, String folderName) + { + super("Music Manager"); + + _shouldPlay = shouldPlay; + + addSongs(folderName); + playNextSong(); + } + + private void playNextSong() + { + if (_songs.isEmpty()) + return; + + int index = (_lastSong + _random.nextInt(_songs.size() - 1) + 1) % _songs.size(); + NoteSong song = _songs.get(index); + if (song != null) + { + UtilServer.getPlayersCollection().stream() + .filter(_shouldPlay) + .forEach(player -> displaySongInfo(song, player)); + + new NotePlayer(_plugin, song, _shouldPlay, 0.5F, false); + + _lastSong = index; + } + } + + private void addSongs(String folderName) + { + try + { + File songsFolder = new File(folderName); + if (songsFolder.exists()) + { + File[] files = songsFolder.listFiles(); + if (files == null) return; + + for (File file : files) + { + if (file.getName().endsWith(".nbs")) + { + System.out.println("Loading Song " + file.getPath()); + NoteSong song = NBSReader.loadSong(new DataInputStream(new FileInputStream(file)), file.getName().replace("_", " ").replace(".nbs", "")); + if (song != null) + { + _songs.add(song); + } + } + } + } + } + catch (FileNotFoundException e) + { + e.printStackTrace(); + System.out.println("FAILED TO LOAD SONG!!"); + } + } + + private void displaySongInfo(NoteSong song, Player player) + { + UtilTextBottom.display(C.cWhite + "Now Playing " + C.cYellow + song.getName(), player); + } + + @EventHandler + public void onSongFinish(SongFinishEvent event) + { + if (_lastSong < _songs.size() && event.getSong().equals(_songs.get(_lastSong))) + { + playNextSong(); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/noteblock/NotePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/noteblock/NotePlayer.java index dfe6bf995..3a0bb4059 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/noteblock/NotePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/noteblock/NotePlayer.java @@ -2,6 +2,7 @@ package mineplex.core.noteblock; import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -14,7 +15,7 @@ public class NotePlayer { private final JavaPlugin _plugin; private final NoteSong _song; - private final INoteVerifier _verifier; + private final Predicate _shouldPlay; private final long _sleepMs; private volatile float _volumeMult; private volatile boolean _loop; @@ -22,17 +23,17 @@ public class NotePlayer private volatile boolean _finished; private volatile Player[] _players = null; - public NotePlayer(JavaPlugin plugin, NoteSong song, INoteVerifier verifier, float volumeMult, boolean loop, Player... players) + public NotePlayer(JavaPlugin plugin, NoteSong song, Predicate shouldPlay, float volumeMult, boolean loop, Player... players) { - this(plugin, song, verifier, volumeMult, loop); + this(plugin, song, shouldPlay, volumeMult, loop); _players = players; } - public NotePlayer(JavaPlugin plugin, NoteSong song, INoteVerifier verifier, float volumeMult, boolean loop) + public NotePlayer(JavaPlugin plugin, NoteSong song, Predicate shouldPlay, float volumeMult, boolean loop) { _plugin = plugin; _song = song; - _verifier = verifier; + _shouldPlay = shouldPlay; _sleepMs = (long) (1000 / (song.getTempo() / 100D)); _loop = loop; _tick = 0; @@ -103,7 +104,7 @@ public class NotePlayer List players = new ArrayList<>(playerArray.length); for (Player player : playerArray) { - if (_verifier.shouldPlay(player)) + if (_shouldPlay != null && _shouldPlay.test(player)) players.add(player); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java index 182f7f136..c058974b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java @@ -156,7 +156,7 @@ public class BlockChangeAnimation extends Animation if(c.equals(b)) { _blockInfoList.add(new BlockInfo(b)); - b.setType(Material.PUMPKIN); + b.setType(Material.JACK_O_LANTERN); b.setData(getDirection(c)); } } diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index 56103deda..4b57ada5d 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -57,7 +57,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor _punish = new Punish(plugin, plugin.GetWebServerAddress(), clientManager); _purchaseManager = new PurchaseManager(plugin); - _powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager); + _powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager, donationManager); plugin.getCommand("enjin_mineplex").setExecutor(this); plugin.getCommand("pull").setExecutor(this); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index b7f9cc73b..09120e45a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -36,6 +36,7 @@ import mineplex.core.menu.MenuManager; import mineplex.core.message.PrivateMessageEvent; import mineplex.core.mount.MountManager; import mineplex.core.noteblock.INoteVerifier; +import mineplex.core.noteblock.MusicManager; import mineplex.core.noteblock.NBSReader; import mineplex.core.noteblock.NotePlayer; import mineplex.core.noteblock.NoteSong; @@ -156,12 +157,6 @@ public class HubManager extends MiniClientPlugin implements IChatMess private HashMap> _creativeAdmin = new HashMap>(); - // Christmas Songs - private Random _random = new Random(); - private int _lastSong = 0; - // private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"}; - private final ArrayList _songs; - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager) { super("Hub Manager", plugin); @@ -237,6 +232,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; + new MusicManager((player) -> _preferences.get(player).isActive(Preference.HUB_MUSIC), "../../update/songs/lobbyMusic"); // _halloweenManager = new HalloweenSpookinessManager(this); // new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); @@ -249,44 +245,12 @@ public class HubManager extends MiniClientPlugin implements IChatMess _customDataManager = Managers.get(CustomDataManager.class); - _songs = new ArrayList(); - _punishManager = punish; _valentinesManager = new ValentinesManager(plugin, clientManager, donationManager); new NonPremiumManager(plugin, clientManager); - try - { - - File songsFolder = new File("../../update/songs/"); - if (songsFolder.exists()) - { - File[] files = songsFolder.listFiles(); - - for (File file : files) - { - if (file.getName().endsWith(".nbs")) - { - System.out.println("Loading Song " + file.getPath()); - NoteSong song = NBSReader.loadSong(new DataInputStream(new FileInputStream(file)), file.getName().replace("_", " ").replace(".nbs", "")); - if (song != null) - { - _songs.add(song); - } - } - } - } - } - catch (FileNotFoundException e) - { - e.printStackTrace(); - System.out.println("FAILED TO LOAD SONG!!"); - } - - playNextSong(); - ScoreboardManager scoreboardManager = new ScoreboardManager(plugin) { @Override @@ -404,37 +368,6 @@ public class HubManager extends MiniClientPlugin implements IChatMess Managers.put(scoreboardManager, ScoreboardManager.class); } - private void playNextSong() - { - if (Type != HubType.Christmas) - return; - - if (_songs.isEmpty()) - return; - - int index = (_lastSong + _random.nextInt(_songs.size() - 1)) % _songs.size(); - NoteSong song = _songs.get(index); - if (song != null) - { - for (Player player : UtilServer.getPlayers()) - { - if (_preferences.get(player).isActive(Preference.HUB_MUSIC)) - { - UtilTextBottom.display(C.cWhite + "Now Playing " + C.cYellow + song.getName(), player); - } - } - - new NotePlayer(_plugin, song, new INoteVerifier() - { - @Override - public boolean shouldPlay(Player player) - { - return _preferences.get(player).isActive(Preference.HUB_MUSIC); - } - }, 0.5F, false); - } - } - @Override public void addCommands() { @@ -1053,12 +986,6 @@ public class HubManager extends MiniClientPlugin implements IChatMess ; } - @EventHandler - public void onSongFinish(SongFinishEvent event) - { - playNextSong(); - } - @EventHandler public void trackPortalDelayPlayers(UpdateEvent event) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 403d168db..2667a203b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -300,7 +300,7 @@ public class NewsManager extends MiniPlugin * Myst's sexy ass animation :> */ - _animationIndex = (_animationIndex + 1) % 147; + _animationIndex = (_animationIndex + 1) % 67; if (_animationIndex == 0) text = C.cGoldB + " "; if (_animationIndex == 1) text = C.cGoldB + " H"; @@ -328,9 +328,9 @@ public class NewsManager extends MiniPlugin if (_animationIndex > 22 && _animationIndex <= 42) { - if (_animationIndex % 3 == 0) text = C.cWhiteB + "2015" + C.cGoldB + " HAPPY HALLOWEEN " + C.cWhiteB + "2015"; - else if (_animationIndex % 3 == 1) text = C.cWhiteB + "2015" + C.cRedB + " HAPPY HALLOWEEN " + C.cWhiteB + "2015"; - else text = C.cWhiteB + "2015" + C.cYellowB + " HAPPY HALLOWEEN " + C.cWhiteB + "2015"; + if (_animationIndex % 3 == 0) text = C.cWhiteB + "2016" + C.cGoldB + " HAPPY HALLOWEEN " + C.cWhiteB + "2016"; + else if (_animationIndex % 3 == 1) text = C.cWhiteB + "2016" + C.cRedB + " HAPPY HALLOWEEN " + C.cWhiteB + "2016"; + else text = C.cWhiteB + "2016" + C.cYellowB + " HAPPY HALLOWEEN " + C.cWhiteB + "2016"; } if (_animationIndex == 43 || _animationIndex == 44) text = C.cGoldB + " HAPPY HALLOWEEN "; @@ -356,55 +356,6 @@ public class NewsManager extends MiniPlugin if (_animationIndex == 64) text = C.cGoldB + "EN "; if (_animationIndex == 65) text = C.cGoldB + "N "; if (_animationIndex == 66) text = C.cGoldB + " "; - - if (_animationIndex == 66) text = C.cGoldB + " S"; - if (_animationIndex == 67) text = C.cGoldB + " SP"; - if (_animationIndex == 68) text = C.cGoldB + " SPO"; - if (_animationIndex == 69) text = C.cGoldB + " SPOO"; - if (_animationIndex == 70) text = C.cGoldB + " SPOOK"; - if (_animationIndex == 71) text = C.cGoldB + " SPOOKY"; - if (_animationIndex == 72) text = C.cGoldB + " SPOOKY "; - if (_animationIndex == 73) text = C.cGoldB + " SPOOKY S"; - if (_animationIndex == 74) text = C.cGoldB + " SPOOKY SA"; - if (_animationIndex == 75) text = C.cGoldB + " SPOOKY SAL"; - if (_animationIndex == 76) text = C.cGoldB + " SPOOKY SALE"; - if (_animationIndex == 77) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 78) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 79) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 80) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 81) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 82) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 83) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 84 || _animationIndex == 85) text = C.cGoldB + " SPOOKY SALE "; - - if (_animationIndex > 84 && _animationIndex <= 124) - { - if (_animationIndex % 2 == 0) text = C.cWhiteB + "50% OFF" + C.cGoldB + " SPOOKY SALE " + C.cWhiteB + "50% OFF"; - else if (_animationIndex % 2 == 1) text = C.cWhiteB + "50% OFF" + C.cRedB + " SPOOKY SALE " + C.cWhiteB + "50% OFF"; - else text = C.cWhiteB + "50% OFF" + C.cYellowB + " SPOOKY SALE " + C.cWhiteB + "50% OFF"; - } - - if (_animationIndex == 125 || _animationIndex == 126) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 127) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 128) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 129) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 130) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 131) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 132) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 133) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 134) text = C.cGoldB + " SPOOKY SALE "; - if (_animationIndex == 135) text = C.cGoldB + "SPOOKY SALE "; - if (_animationIndex == 136) text = C.cGoldB + "POOKY SALE "; - if (_animationIndex == 137) text = C.cGoldB + "OOKY SALE "; - if (_animationIndex == 138) text = C.cGoldB + "OKY SALE "; - if (_animationIndex == 139) text = C.cGoldB + "KY SALE "; - if (_animationIndex == 140) text = C.cGoldB + "Y SALE "; - if (_animationIndex == 141) text = C.cGoldB + " SALE "; - if (_animationIndex == 142) text = C.cGoldB + "SALE "; - if (_animationIndex == 143) text = C.cGoldB + "ALE "; - if (_animationIndex == 144) text = C.cGoldB + "LE "; - if (_animationIndex == 145) text = C.cGoldB + "E "; - if (_animationIndex == 146) text = C.cGoldB + " "; } else { diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 6aa86f4aa..44251149e 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -73,7 +73,7 @@ public class StaffServer extends JavaPlugin require(PacketHandler.class); require(DisguiseManager.class); - PowerPlayClubRepository powerPlayRepo = new PowerPlayClubRepository(this, clientManager); + PowerPlayClubRepository powerPlayRepo = new PowerPlayClubRepository(this, clientManager, donationManager); new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this, clientManager), statsManager, powerPlayRepo), powerPlayRepo); //new Password(this, serverStatusManager.getCurrentServerName()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java index b1f5f327e..26b6728e2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java @@ -698,14 +698,7 @@ public class Valentines extends SoloGame } //Music! - _music = new NotePlayer(Manager.getPlugin(), noteSong, new INoteVerifier() - { - @Override - public boolean shouldPlay(Player player) - { - return Manager.getPreferences().get(player).isActive(Preference.HUB_MUSIC); - } - }, 0.7F, true); + _music = new NotePlayer(Manager.getPlugin(), noteSong, p -> Manager.getPreferences().get(p).isActive(Preference.HUB_MUSIC), 0.7F, true); } @Override