diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 5c2769fe0..9c692c7d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -161,7 +161,7 @@ public class BonusManager extends MiniClientPlugin implements I _repository = new BonusRepository(plugin, this, donationManager); _clientManager = clientManager; _donationManager = donationManager; - _powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager); + _powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager, donationManager); System.out.print("VOTIFIER: "); System.out.print("DONATION MANAGER - > " + _donationManager.toString()); @@ -202,7 +202,7 @@ public class BonusManager extends MiniClientPlugin implements I _playWireManager = playWireManager; - _powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager); + _powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager, _donationManager); _voteList = new ArrayList<>(); _voteList.add("http://vote1.mineplex.com"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java index b96e421ff..c9eb2cd78 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java @@ -2,10 +2,14 @@ package mineplex.core.bonuses.gui.buttons; import java.time.LocalDate; import java.time.YearMonth; +import java.time.format.TextStyle; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; +import java.util.Comparator; import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import mineplex.core.bonuses.BonusManager; import mineplex.core.common.util.C; @@ -62,7 +66,7 @@ public class PowerPlayClubButton implements GuiItem { _player.closeInventory(); _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f); - PowerPlayClubRewards.giveAllItems(_player, _donationManager, _inventoryManager, _powerPlayClubRepository); + PowerPlayClubRewards.giveAllItems(_player, _inventoryManager, _powerPlayClubRepository); } else { @@ -88,11 +92,17 @@ public class PowerPlayClubButton implements GuiItem { final Material material; final String itemName; - final List lore; + final List lore = new ArrayList<>(); PowerPlayData cached = _powerPlayClubRepository.getCachedData(_player); - List unclaimed = cached.getUnclaimedMonths(); + Optional maybeNextClaimDate = cached.getNextClaimDate(); + Set unclaimed = cached.getUnclaimedMonths(); + + if (!cached.getUsableCosmeticMonths().isEmpty()) + { + lore.addAll(buildCosmeticsLore(cached.getUsableCosmeticMonths())); + } if (!unclaimed.isEmpty()) { @@ -100,20 +110,19 @@ public class PowerPlayClubButton implements GuiItem material = Material.GOLD_INGOT; itemName = C.cGreenB + "Power Play Club"; - lore = buildLore(unclaimed); - lore.add(" "); + lore.addAll(buildOtherRewardsLore(unclaimed.size())); lore.add(C.cGold + "Click to claim!"); - } else if (cached.isSubscribed()) + } else if (maybeNextClaimDate.isPresent()) // Player is still subscribed, and has claimed everything so far { - // Player is subscribed and has claimed all of his/her rewards + LocalDate nextClaimDate = maybeNextClaimDate.get(); + material = Material.REDSTONE_BLOCK; itemName = C.cRedB + "Power Play Club"; - lore = new ArrayList<>(); - lore.add(C.cRed + "Already claimed!"); - - // TODO: 'come back later!' + lore.add(C.cYellow + "Come back " + C.cGreen + nextClaimDate.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + " " + nextClaimDate.getDayOfMonth()); + lore.add(C.cWhite + " " + PowerPlayClubRewards.AMPLIFIERS_PER_MONTH + " Game Amplifier"); + lore.add(C.cWhite + " " + PowerPlayClubRewards.CHESTS_PER_MONTH + " Omega Chest"); } else { @@ -121,8 +130,10 @@ public class PowerPlayClubButton implements GuiItem material = Material.REDSTONE_BLOCK; itemName = C.cRedB + "Power Play Club"; - lore = buildLore(Collections.singletonList(YearMonth.now())); + lore.add(C.cYellow + YearMonth.now().getMonth().getDisplayName(TextStyle.FULL, Locale.US) + "'s Cosmetic"); + lore.add(C.cWhite + " " + PowerPlayClubRewards.rewards().get(YearMonth.now()).getPrize()); lore.add(" "); + lore.addAll(buildOtherRewardsLore(1)); lore.add(C.cRed + "Get Power Play Club months at"); lore.add(C.cAqua + "mineplex.com/shop"); } @@ -130,17 +141,29 @@ public class PowerPlayClubButton implements GuiItem _item = new ShopItem(material, (byte)0, itemName, lore.toArray(new String[lore.size()]), 1, false, false); } - private List buildLore(List unclaimed) + private List buildCosmeticsLore(Set cosmeticsMonths) { List lore = new ArrayList<>(); - lore.add(C.cYellow + "Rewards"); - lore.add(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * unclaimed.size()) + " Game Amplifier"); - lore.add(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * unclaimed.size()) + " Omega Chest"); + lore.add(C.cYellow + "Unlocked cosmetics"); + PowerPlayClubRewards.rewards().entrySet().stream() + .filter(entry -> cosmeticsMonths.contains(entry.getKey())) + .sorted(Comparator.comparing(Map.Entry::getKey)) + .forEach(entry -> + { + YearMonth yearMonth = entry.getKey(); + lore.add(C.cWhite + " " + entry.getValue().getPrize() + " " + C.cGold + yearMonth.getMonth().getDisplayName(TextStyle.SHORT, Locale.US) + " " + yearMonth.getYear()); + }); + lore.add(" "); + return lore; + } - PowerPlayClubRewards.rewardsForMonths(unclaimed).forEach(prize -> - { - lore.add(" " + C.cWhite + prize.getPrize()); - }); + private List buildOtherRewardsLore(int unclaimed) + { + List lore = new ArrayList<>(); + lore.add(C.cYellow + "Other Rewards"); + lore.add(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * unclaimed) + " Game Amplifier"); + lore.add(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * unclaimed) + " Omega Chest"); + lore.add(" "); return lore; } 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/powerplayclub/PowerPlayClubRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java index de013f635..195856061 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java @@ -2,11 +2,13 @@ package mineplex.core.powerplayclub; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; +import mineplex.core.donation.DonationManager; import mineplex.serverdata.database.DBPool; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -28,9 +30,11 @@ public class PowerPlayClubRepository implements Listener { private final Map _cachedPlayerData = new HashMap<>(); private final CoreClientManager _clientManager; + private final DonationManager _donationManager; - public PowerPlayClubRepository(JavaPlugin plugin, CoreClientManager clientManager) { + public PowerPlayClubRepository(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) { _clientManager = clientManager; + _donationManager = donationManager; Bukkit.getPluginManager().registerEvents(this, plugin); @@ -83,6 +87,18 @@ public class PowerPlayClubRepository implements Listener { }); } + // Add usable cosmetics to player on join + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + PowerPlayData cached = getCachedData(player); + PowerPlayClubRewards.rewardsForMonths(cached.getUsableCosmeticMonths()).stream() + .map(PowerPlayClubRewards.PowerPlayClubItem::getPrize) + .forEach(_donationManager.Get(player)::AddUnknownSalesPackagesOwned); + } + @EventHandler public void onQuit(PlayerQuitEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 96e028df1..66a2d3d5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -51,13 +51,18 @@ public class PowerPlayClubRewards } } - public static List rewardsForMonths(List months) + public static List rewardsForMonths(Set months) { - return months.stream().map(rewards::get).collect(Collectors.toList()); + return months.stream().sorted().map(rewards::get).collect(Collectors.toList()); + } + + public static Map rewards() + { + return rewards; } - public static void giveAllItems(Player player, DonationManager donationManager, InventoryManager inventoryManager, PowerPlayClubRepository repo) + public static void giveAllItems(Player player, InventoryManager inventoryManager, PowerPlayClubRepository repo) { UtilPlayer.message(player, F.main("Power Play Club", "Verifying subscription..")); @@ -70,18 +75,7 @@ public class PowerPlayClubRewards } PowerPlayData cached = repo.getCachedData(player); - List items = rewardsForMonths(cached.getUnclaimedMonths()); - - - // Give normal power play items - items.forEach(item -> - { - donationManager.PurchaseUnknownSalesPackage(null, player.getName(), - donationManager.getClientManager().Get(player).getAccountId(), item.getPrize(), - GlobalCurrency.TREASURE_SHARD, 0, true); - UtilPlayer.message(player, F.main("Power Play Club", "You received the " + - F.elem(item.getPrize()) + ".")); - }); + int unclaimed = cached.getUnclaimedMonths().size(); // Give amplifiers and chests Item gameAmplifier = inventoryManager.getItem("Game Booster"); @@ -91,8 +85,8 @@ public class PowerPlayClubRewards } else { - inventoryManager.addItemToInventory(player, gameAmplifier.Name, AMPLIFIERS_PER_MONTH * items.size()); - UtilPlayer.message(player, F.main("Power Play Club", "You received " + (AMPLIFIERS_PER_MONTH * items.size()) + "x " + F.elem("Game Amplifier") + ".")); + inventoryManager.addItemToInventory(player, gameAmplifier.Name, AMPLIFIERS_PER_MONTH * unclaimed); + UtilPlayer.message(player, F.main("Power Play Club", "You received " + (AMPLIFIERS_PER_MONTH * unclaimed) + "x " + F.elem("Game Amplifier") + ".")); } Item omegaChest = inventoryManager.getItem("Omega Chest"); if (omegaChest == null) @@ -101,8 +95,8 @@ public class PowerPlayClubRewards } else { - inventoryManager.addItemToInventory(player, omegaChest.Name, CHESTS_PER_MONTH * items.size()); - UtilPlayer.message(player, F.main("Power Play Club", "You received " + (CHESTS_PER_MONTH * items.size()) + "x " + F.elem("Omega Chest") + ".")); + inventoryManager.addItemToInventory(player, omegaChest.Name, CHESTS_PER_MONTH * unclaimed); + UtilPlayer.message(player, F.main("Power Play Club", "You received " + (CHESTS_PER_MONTH * unclaimed) + "x " + F.elem("Omega Chest") + ".")); } // Refresh Power Play data on the server diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java index 620dac03f..09b4b30f2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java @@ -9,25 +9,65 @@ import java.util.stream.Collectors; public class PowerPlayData { - private final boolean _subscribed; - private final List _unclaimedMonths; + /* If this is set, the player's subscription is planned to recur. + * + * In the case of a yearly subscription, this will be the first day of + * the next month, or the exact end-of-subscription date if it's his/her + * last month. + * + * Corollary: If this isn't Optional.empty(), the player is actively subscribed. + */ + private final Optional _nextClaimDate; + + // The months where the player hasn't claimed chests/amplifiers + private final Set _unclaimedMonths; + + /* The months of PPC cosmetics the player owns / can use. + * In the case of, e.g., a monthly subscription, this will include + * the current month's cosmetic until _nextClaimDate passes (the + * subscription expires), unless the player's subscription recurs. + */ + private final Set _cosmeticMonths; static PowerPlayData fromSubsAndClaims(List subscriptions, List claimedMonths) { if (subscriptions.isEmpty()) { - return new PowerPlayData(false, Collections.emptyList()); + return new PowerPlayData(Optional.empty(), Collections.emptySet(), Collections.emptySet()); } // Build the list of potential claim dates from subscriptions + // Note that it's a LinkedList with dates in ascending order List claimDates = subscriptions.stream() .flatMap(sub -> buildMonths(sub).stream()) .sorted() .collect(Collectors.toCollection(LinkedList::new)); - // Determine if player is subscribed - LocalDate latestSub = claimDates.get(claimDates.size() - 1); - final boolean subscribed = latestSub.plusMonths(1).isAfter(LocalDate.now()); + // Determine the player's next claim date (which will tell us whether + // they're subscribed as well) + final Optional nextClaimDate; + + // In the case of a yearly subscription, they're likely to have a claim date scheduled + // (this is not the case for the last month) + Optional nextSubClaim = claimDates.stream().filter(date -> date.isAfter(LocalDate.now())).findFirst(); + if (nextSubClaim.isPresent()) + { + nextClaimDate = nextSubClaim; + + } else + { + // In the case of a monthly subscription, we need to extrapolate the next claim date + nextClaimDate = Optional.of(claimDates.get(claimDates.size() - 1)) + .map(date -> date.plusMonths(1)) + .filter(date -> date.isAfter(LocalDate.now())); // and make sure it's after today + nextClaimDate.ifPresent(claimDates::add); + } + + // Determine the months whose cosmetics can be used by this player + Set cosmeticMonths = claimDates.stream() + .map(YearMonth::from) + .filter(yearMonth -> yearMonth.isBefore(YearMonth.now()) || yearMonth.equals(YearMonth.now())) + .collect(Collectors.toSet()); // Remove already-claimed months Optional latestClaimed = claimedMonths.stream().collect(Collectors.maxBy(YearMonth::compareTo)); @@ -48,13 +88,12 @@ public class PowerPlayData } }); - List unclaimedMonths = claimDates.stream() + Set unclaimedMonths = claimDates.stream() .filter(date -> date.isBefore(LocalDate.now()) || date.equals(LocalDate.now())) // Filter dates yet to come .map(YearMonth::from) - .distinct() - .collect(Collectors.toList()); + .collect(Collectors.toSet()); - return new PowerPlayData(subscribed, unclaimedMonths); + return new PowerPlayData(nextClaimDate, unclaimedMonths, cosmeticMonths); } private static List buildMonths(Subscription subscription) @@ -66,9 +105,16 @@ public class PowerPlayData case YEAR: List months = new ArrayList<>(); - for (int i = 0; i < 12; i++) + + // The first and last months have the exact claim dates + // The latter is to prevent premature claiming + months.add(subscription._startDate); + months.add(subscription._startDate.plusMonths(11)); + + // The middle months can claim on the first day of the month + for (int i = 1; i < 11; i++) { - months.add(subscription._startDate.plusMonths(i)); + months.add(subscription._startDate.plusMonths(i).withDayOfMonth(1)); } return months; @@ -77,7 +123,8 @@ public class PowerPlayData } } - static class Subscription { + static class Subscription + { private final LocalDate _startDate; private final SubscriptionDuration _duration; @@ -88,29 +135,45 @@ public class PowerPlayData } } - enum SubscriptionDuration { + enum SubscriptionDuration + { MONTH, YEAR } - private PowerPlayData(boolean subscribed, List unclaimedMonths) + private PowerPlayData(Optional nextClaimDate, Set unclaimedMonths, Set cosmeticMonths) { - _subscribed = subscribed; + _nextClaimDate = nextClaimDate; _unclaimedMonths = unclaimedMonths; + _cosmeticMonths = cosmeticMonths; } - public List getUnclaimedMonths() + public Optional getNextClaimDate() + { + return _nextClaimDate; + } + + public Set getUnclaimedMonths() { return _unclaimedMonths; } + public Set getUsableCosmeticMonths() + { + return _cosmeticMonths; + } + public boolean isSubscribed() { - return _subscribed; + return _nextClaimDate.isPresent(); } @Override public String toString() { - return Objects.toStringHelper(this).add("subscribed", _subscribed).add("unclaimed", _unclaimedMonths).toString(); + return Objects.toStringHelper(this) + .add("_nextClaimDate", _nextClaimDate) + .add("_unclaimedMonths", _unclaimedMonths) + .add("_cosmeticMonths", _cosmeticMonths) + .toString(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 4f5a2e263..34b92a4f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -12,7 +12,6 @@ import java.util.logging.Level; import java.util.stream.Collectors; import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -248,11 +247,8 @@ public class ReportManager checkNotNull(report); checkNotNull(reportResult); - return _reportRepository.getAccountUUID(report.getSuspectId()).thenAccept(suspectUUID -> + return _reportRepository.getAccountName(report.getSuspectId()).thenAccept(suspectName -> { - OfflinePlayer suspect = Bukkit.getOfflinePlayer(suspectUUID); - String suspectName = suspect.getName(); - if (reportCloser != null) { int closerId = _clientManager.Get(reportCloser).getAccountId(); @@ -266,64 +262,68 @@ public class ReportManager saveCompletableFuture.thenAccept(reportId -> { - if (reportResult.getType() == ReportResultType.ABUSIVE) + try { - // if report was marked abusive, check if each of the reporters - // should be banned from using the report system - report.getReporterIds().forEach(reporterId -> - _reportRepository.getAccountUUID(reporterId).thenAccept(reporterUUID -> - { - CoreClient reporterClient = _clientManager.Get(reporterUUID); - checkAbuseBan(reporterClient, reportCloser, reportId); - })); - } - - Bukkit.getScheduler().runTask(_plugin, () -> - { - String prefix = getReportPrefix(reportId); - String reason = reportResult.getReason().orElse("No reason specified."); - - if (reportCloser != null) + if (reportResult.getType() == ReportResultType.ABUSIVE) { - if (reportResult.getType() == ReportResultType.ACCEPTED) - { - // TODO: force moderator to choose a punishment (requires new punish gui) - CommandCenter.Instance.onPlayerCommandPreprocess( - new PlayerCommandPreprocessEvent(reportCloser, - String.format("/punish %s Report #%s - %s", suspectName, reportId, reason))); - } - - // TODO: send these after punishment has been decided (requires new punish gui) - reportCloser.sendMessage( - F.main(prefix, "Report marked as: " - + C.cGold + reportResult.getType().getName())); - reportCloser.sendMessage(F.main(prefix, "Reason: " + F.elem(reason))); + // if report was marked abusive, check if each of the reporters + // should be banned from using the report system + report.getReporterIds().forEach(reporterId -> + _reportRepository.getAccountUUID(reporterId).thenAccept(reporterUUID -> + { + CoreClient reporterClient = _clientManager.Get(reporterUUID); + checkAbuseBan(reporterClient, reportCloser, reportId); + })); } - getUUIDs(report.getReporterIds()).thenAccept(ids -> + Bukkit.getScheduler().runTask(_plugin, () -> { - ReportResultType resultType = reportResult.getType(); - ChildJsonMessage jsonMessage = new JsonMessage(F.main( - prefix, - "Your report against " + F.elem(suspectName) + " was marked as " + F.elem(resultType.getName()) + ".")) - .extra("\n"); + String prefix = getReportPrefix(reportId); + String reason = reportResult.getReason().orElse("No reason specified."); - if (resultType == ReportResultType.ABUSIVE) + if (reportCloser != null) { - jsonMessage = jsonMessage.add(F.main(prefix, C.cRed + "Submitting false reports may result in punishment.")) - .add("\n"); + if (reportResult.getType() == ReportResultType.ACCEPTED) + { + // TODO: force moderator to choose a punishment (requires new punish gui) + CommandCenter.Instance.onPlayerCommandPreprocess( + new PlayerCommandPreprocessEvent(reportCloser, + String.format("/punish %s Report #%d - %s", suspectName, reportId, reason))); + } + + // TODO: send these after punishment has been decided (requires new punish gui) + reportCloser.sendMessage( + F.main(prefix, "Report marked as: " + + C.cGold + reportResult.getType().getName())); + reportCloser.sendMessage(F.main(prefix, "Reason: " + F.elem(reason))); } - jsonMessage = jsonMessage.add(F.main(prefix, "Reason: " + F.elem(reason))); + getUUIDs(report.getReporterIds()).thenAccept(ids -> + { + ReportResultType resultType = reportResult.getType(); + ChildJsonMessage jsonMessage = new JsonMessage(F.main( + prefix, + "Your report against " + F.elem(suspectName) + " was marked as " + F.elem(resultType.getName()) + ".")) + .extra("\n"); - new ReportersNotification(ids, jsonMessage).publish(); + if (resultType == ReportResultType.ABUSIVE) + { + jsonMessage = jsonMessage.add(F.main(prefix, C.cRed + "Submitting false reports may result in punishment.")) + .add("\n"); + } + + jsonMessage = jsonMessage.add(F.main(prefix, "Reason: " + F.elem(reason))); + + new ReportersNotification(ids, jsonMessage).publish(); + }); }); - }); - _reportRepository.clearCache(reportId); - }).exceptionally(throwable -> { - _plugin.getLogger().log(Level.SEVERE, "Post-report save failed.", throwable); - return null; + _reportRepository.clearCache(reportId); + } + catch (Throwable throwable) + { + _plugin.getLogger().log(Level.SEVERE, "Post-report save failed.", throwable); + } }); }); } @@ -512,27 +512,12 @@ public class ReportManager */ public CompletableFuture isHandlingReport(int accountId) { - CompletableFuture> future = _reportRepository.getReportsHandling(accountId); - - return future.thenApply(reportIds -> { - // if for some reason we cannot fetch the report a user is handling - // assume the worst and return true - // this means we do not end up allowing a user to handle multiple reports simultaneously - if (reportIds == null) - { - return true; - } - - for (long reportId : reportIds) - { - if (isActiveReport(reportId).join()) - { - return true; - } - } - - return false; - }); + return _reportRepository.getReportsHandling(accountId) + .thenApply(reportIds -> reportIds.size() > 0) + .exceptionally(throwable -> true); + // ^ if for some reason we cannot fetch the report a user is handling + // assume the worst and return true + // this means we do not end up allowing a user to handle multiple reports simultaneously } /** @@ -558,28 +543,24 @@ public class ReportManager reportIds.stream().map(_reportRepository::getReport).collect(Collectors.toList()) ).thenCompose(UtilFuture::sequence) .thenApply(UtilCollections::unboxPresent) - .thenCompose(reports -> UtilFuture.filter(reports, this::isActiveReport)).thenApply(reports -> - { - Report report = null; - int size = reports.size(); + .thenApply(reports -> + { + Report report = null; + int size = reports.size(); - if (size == 1) - { - report = reports.get(0); - } - else if (size > 1) - { - throw new IllegalStateException("Account is handling multiple reports."); - } + if (size == 1) + { + report = reports.get(0); + } + else if (size > 1) + { + throw new IllegalStateException("Account is handling multiple reports."); + } - return Optional.ofNullable(report); - }); + return Optional.ofNullable(report); + }); - future.exceptionally(throwable -> - { - _plugin.getLogger().log(Level.SEVERE, "Error getting the report account is handling.", throwable); - return Optional.empty(); - }); + future.exceptionally(throwable -> Optional.empty()); return future; } @@ -632,31 +613,43 @@ public class ReportManager { int playerId = _clientManager.Get(player).getAccountId(); - getReportHandling(playerId).thenAccept(reportOptional -> + getReportHandling(playerId).whenComplete((reportOptional, throwable) -> { - if (reportOptional.isPresent()) + if (throwable == null) { - Report report = reportOptional.get(); - - if (!report.getHandlerTask().isPresent()) + if (reportOptional.isPresent()) { - long reportId = report.getId().orElseThrow(() -> new IllegalStateException("Report id is not present.")); - new ReportHandlerTask(this, reportId).start(_plugin); + Report report = reportOptional.get(); + + if (!report.getHandlerTask().isPresent()) + { + long reportId = report.getId().orElseThrow(() -> new IllegalStateException("Report id is not present.")); + new ReportHandlerTask(this, reportId).start(_plugin); + } } } + else + { + _plugin.getLogger().log(Level.SEVERE, "Error whilst checking for report being handled by " + player.getName(), throwable); + } }); - _reportRepository.getOngoingReports(playerId) - .thenAccept(reports -> - { - for (Report report : reports) - { - sendHandlerNotification(report, - F.main(getReportPrefix(report), - String.format("%s has joined %s.", player.getName(), F.elem(_serverName)))); - } - } - ); + _reportRepository.getOngoingReports(playerId).whenComplete((reports, throwable) -> + { + if (throwable == null) + { + for (Report report : reports) + { + sendHandlerNotification(report, + F.main(getReportPrefix(report), + String.format("%s has joined %s.", player.getName(), F.elem(_serverName)))); + } + } + else + { + _plugin.getLogger().log(Level.SEVERE, "Error whilst checking for on-going reports against " + player.getName(), throwable); + } + }); } protected void onPlayerQuit(Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportAbortCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportAbortCommand.java index 6230407df..67450ea61 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportAbortCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportAbortCommand.java @@ -1,5 +1,7 @@ package mineplex.core.report.command; +import java.util.logging.Level; + import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; @@ -30,19 +32,27 @@ public class ReportAbortCommand extends CommandBase { ReportManager reportManager = Plugin.getReportManager(); - reportManager.getReportHandling(player).thenApply(BukkitFuture.accept(reportOptional -> + reportManager.getReportHandling(player).whenComplete(BukkitFuture.complete((reportOptional, throwable) -> { - if (reportOptional.isPresent()) + if (throwable == null) { - Report report = reportOptional.get(); + if (reportOptional.isPresent()) + { + Report report = reportOptional.get(); - reportManager.abortReport(report).thenApply(BukkitFuture.accept(voidValue -> - UtilPlayer.message(player, F.main(ReportManager.getReportPrefix(report), - "Report has been aborted and may be handled by another staff member.")))); + reportManager.abortReport(report).thenApply(BukkitFuture.accept(voidValue -> + UtilPlayer.message(player, F.main(ReportManager.getReportPrefix(report), + "Report has been aborted and may be handled by another staff member.")))); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), "You aren't currently handling a report.")); + } } else { - UtilPlayer.message(player, F.main(Plugin.getName(), "You aren't currently handling a report.")); + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "An error occurred, please try again later.")); + Plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst aborting report for player " + player.getName(), throwable); } })); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java index 0efd2481c..cea670742 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java @@ -1,5 +1,7 @@ package mineplex.core.report.command; +import java.util.logging.Level; + import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; @@ -57,6 +59,7 @@ public class ReportCloseCommand extends CommandBase else { UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "An error occurred, please try again later.")); + Plugin.getPlugin().getLogger().log(Level.SEVERE, "An error occurred whilst fetching the report being handled by " + player.getName(), throwable); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java index ffb7f53cc..a988ab3d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.CompletableFuture; +import java.util.logging.Level; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -39,62 +40,70 @@ public class ReportHandleCommand extends CommandBase ReportRepository reportRepository = reportManager.getReportRepository(); int accountId = _commandCenter.GetClientManager().getAccountId(player); - reportManager.isHandlingReport(player).thenAccept(isHandlingReport -> + reportManager.isHandlingReport(player).whenComplete((handlingReport, throwable) -> { - if (!isHandlingReport) + if (throwable == null) { - Map reportPriorities = Collections.synchronizedMap(new HashMap<>()); - boolean devMode = reportManager.isDevMode(player.getUniqueId()); - - // the below fetches the ids of all unhandled reports and gets a Report object for each of these ids - // the priority of the report is then calculated and the results placed in a map - reportRepository.getUnhandledReports(accountId, devMode).thenCompose(reportRepository::getReports).thenAccept(reports -> - CompletableFuture.allOf(reports.stream().map(report -> - reportManager.calculatePriority(report).thenAccept(priority -> - { - if (priority > 0) - { - reportPriorities.put(report, priority); - } - else - { - // mark the report as expired to keep the database clean - // and reduce future query time - reportManager.expireReport(report); - } - } - ) - ).toArray(CompletableFuture[]::new)).join() - ).thenApply(aVoid -> + if (!handlingReport) { - Map.Entry mostImportant = null; + Map reportPriorities = Collections.synchronizedMap(new HashMap<>()); + boolean devMode = reportManager.isDevMode(player.getUniqueId()); - for (Map.Entry entry : reportPriorities.entrySet()) + // the below fetches the ids of all unhandled reports and gets a Report object for each of these ids + // the priority of the report is then calculated and the results placed in a map + reportRepository.getUnhandledReports(accountId, devMode).thenCompose(reportRepository::getReports).thenAccept(reports -> + CompletableFuture.allOf(reports.stream().map(report -> + reportManager.calculatePriority(report).thenAccept(priority -> + { + if (priority > 0) + { + reportPriorities.put(report, priority); + } + else + { + // mark the report as expired to keep the database clean + // and reduce future query time + reportManager.expireReport(report); + } + } + ) + ).toArray(CompletableFuture[]::new)).join() + ).thenApply(aVoid -> { - if (mostImportant == null || (double) entry.getValue() > mostImportant.getValue()) + Map.Entry mostImportant = null; + + for (Map.Entry entry : reportPriorities.entrySet()) { - mostImportant = entry; + if (mostImportant == null || (double) entry.getValue() > mostImportant.getValue()) + { + mostImportant = entry; + } } - } - return mostImportant == null ? null : mostImportant.getKey(); - }).thenCompose(BukkitFuture.accept(report -> + return mostImportant == null ? null : mostImportant.getKey(); + }).thenCompose(BukkitFuture.accept(report -> + { + if (report != null) + { + reportManager.handleReport(report, player); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "No report found, report queue is empty.")); + } + })); + } + else { - if (report != null) - { - reportManager.handleReport(report, player); - } - else - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "No report found, report queue is empty.")); - } - })); + Bukkit.getScheduler().runTask(Plugin.getPlugin(), () -> + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "You are already handling a report."))); + + } } else { - Bukkit.getScheduler().runTask(Plugin.getPlugin(), () -> - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "You are already handling a report."))); - + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "An error occurred, please try again later.")); + Plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst checking for reports being handled by " + player.getName(), throwable); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java index e21a29c71..2f7373bac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/data/ReportRepository.java @@ -227,11 +227,7 @@ public class ReportRepository return reportsHandling; }); - future.exceptionally(throwable -> - { - _logger.log(Level.SEVERE, "Error fetching reports being handled by specified account.", throwable); - return new ArrayList<>(); - }); + future.exceptionally(throwable -> null); return future; } 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.ReportSite/sql/hotfix.sql b/Plugins/Mineplex.ReportSite/sql/hotfix.sql new file mode 100644 index 000000000..aa902c45e --- /dev/null +++ b/Plugins/Mineplex.ReportSite/sql/hotfix.sql @@ -0,0 +1 @@ +ALTER TABLE Account.reportResults MODIFY reason VARCHAR(256); \ No newline at end of file diff --git a/Plugins/Mineplex.ReportSite/sql/upgrade.sql b/Plugins/Mineplex.ReportSite/sql/upgrade.sql index c089a9c96..e55ad6b17 100644 --- a/Plugins/Mineplex.ReportSite/sql/upgrade.sql +++ b/Plugins/Mineplex.ReportSite/sql/upgrade.sql @@ -161,4 +161,6 @@ INSERT INTO Account.reportResultTypes (id, globalStat, name) VALUES (3, 1, 'EXPI INSERT INTO Account.snapshotTypes (id, name) VALUES (0, 'CHAT'); INSERT INTO Account.snapshotTypes (id, name) VALUES (1, 'PM'); -INSERT INTO Account.snapshotTypes (id, name) VALUES (2, 'PARTY'); \ No newline at end of file +INSERT INTO Account.snapshotTypes (id, name) VALUES (2, 'PARTY'); + +INSERT INTO Account.reportTeams (id, name) VALUES (0, 'RC'); \ No newline at end of file diff --git a/Plugins/Mineplex.ReportSite/view.php b/Plugins/Mineplex.ReportSite/view.php index 8e7d50d1a..846d901f1 100644 --- a/Plugins/Mineplex.ReportSite/view.php +++ b/Plugins/Mineplex.ReportSite/view.php @@ -356,12 +356,13 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id } $validId = isset($_GET['id']); - $idError = ""; + $errorMsg = ""; $id = null; $expanded = null; $report = null; $snapshot = null; + $messages = null; if ($validId) { @@ -372,11 +373,20 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id if ($report) { $snapshot = $report->getSnapshot(); + + if ($snapshot != null) + { + $messages = $snapshot->getMessages(); + } + else + { + $errorMsg = 'No associated snapshot found for report.'; + } } else { $validId = false; - $idError = "Invalid id."; + $errorMsg = "Invalid id."; } } ?> @@ -415,12 +425,15 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id - +

What did you do?!?!?

-

Error:

-
+ + +

Error:

+
+
@@ -440,9 +453,6 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
getMessages(); $messageCount = count($messages); $displayAmount = $expanded || $messageCount <= collapsedMessageCount ? $messageCount : collapsedMessageCount; 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/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index bdda4acb5..df73cbcfc 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -339,7 +339,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); caller.sendMessage(C.cBlue + "Power Play Subscription (" + Calendar.getInstance().getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()) + "): " + (powerPlaySub ? C.cGreen + "Active" : C.cRed + "Inactive")); - caller.sendMessage(C.cBlue + "Power Play Monthly Reward (" + Calendar.getInstance().getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()) + "): " + (powerPlayClaim ? C.cGreen + "Claimed" : C.cRed + "Unclaimed")); + caller.sendMessage(C.cBlue + "Power Play Monthly Reward (" + Calendar.getInstance().getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()) + "): " + (powerPlayClaim ? C.cRed + "Unavailable" : C.cGreen + "Available")); _accountBonusLog.remove(client.getAccountId()); } 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