Merge branch 'update/ppc-items' of github.com:Mineplex-LLC/Minecraft-PC into update/ppc-items

This commit is contained in:
LCastr0 2016-10-06 14:00:46 -03:00
commit d4c5f1f5c9
24 changed files with 484 additions and 389 deletions

View File

@ -161,7 +161,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_repository = new BonusRepository(plugin, this, donationManager); _repository = new BonusRepository(plugin, this, donationManager);
_clientManager = clientManager; _clientManager = clientManager;
_donationManager = donationManager; _donationManager = donationManager;
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager); _powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager, donationManager);
System.out.print("VOTIFIER: "); System.out.print("VOTIFIER: ");
System.out.print("DONATION MANAGER - > " + _donationManager.toString()); System.out.print("DONATION MANAGER - > " + _donationManager.toString());
@ -202,7 +202,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_playWireManager = playWireManager; _playWireManager = playWireManager;
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager); _powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager, _donationManager);
_voteList = new ArrayList<>(); _voteList = new ArrayList<>();
_voteList.add("http://vote1.mineplex.com"); _voteList.add("http://vote1.mineplex.com");

View File

@ -2,10 +2,14 @@ package mineplex.core.bonuses.gui.buttons;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.YearMonth; import java.time.YearMonth;
import java.time.format.TextStyle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Comparator;
import java.util.Collections;
import java.util.List; 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.bonuses.BonusManager;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -62,7 +66,7 @@ public class PowerPlayClubButton implements GuiItem
{ {
_player.closeInventory(); _player.closeInventory();
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f); _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
PowerPlayClubRewards.giveAllItems(_player, _donationManager, _inventoryManager, _powerPlayClubRepository); PowerPlayClubRewards.giveAllItems(_player, _inventoryManager, _powerPlayClubRepository);
} }
else else
{ {
@ -88,11 +92,17 @@ public class PowerPlayClubButton implements GuiItem
{ {
final Material material; final Material material;
final String itemName; final String itemName;
final List<String> lore; final List<String> lore = new ArrayList<>();
PowerPlayData cached = _powerPlayClubRepository.getCachedData(_player); PowerPlayData cached = _powerPlayClubRepository.getCachedData(_player);
List<YearMonth> unclaimed = cached.getUnclaimedMonths(); Optional<LocalDate> maybeNextClaimDate = cached.getNextClaimDate();
Set<YearMonth> unclaimed = cached.getUnclaimedMonths();
if (!cached.getUsableCosmeticMonths().isEmpty())
{
lore.addAll(buildCosmeticsLore(cached.getUsableCosmeticMonths()));
}
if (!unclaimed.isEmpty()) if (!unclaimed.isEmpty())
{ {
@ -100,20 +110,19 @@ public class PowerPlayClubButton implements GuiItem
material = Material.GOLD_INGOT; material = Material.GOLD_INGOT;
itemName = C.cGreenB + "Power Play Club"; itemName = C.cGreenB + "Power Play Club";
lore = buildLore(unclaimed); lore.addAll(buildOtherRewardsLore(unclaimed.size()));
lore.add(" ");
lore.add(C.cGold + "Click to claim!"); 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; material = Material.REDSTONE_BLOCK;
itemName = C.cRedB + "Power Play Club"; itemName = C.cRedB + "Power Play Club";
lore = new ArrayList<>(); lore.add(C.cYellow + "Come back " + C.cGreen + nextClaimDate.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + " " + nextClaimDate.getDayOfMonth());
lore.add(C.cRed + "Already claimed!"); lore.add(C.cWhite + " " + PowerPlayClubRewards.AMPLIFIERS_PER_MONTH + " Game Amplifier");
lore.add(C.cWhite + " " + PowerPlayClubRewards.CHESTS_PER_MONTH + " Omega Chest");
// TODO: 'come back later!'
} else } else
{ {
@ -121,8 +130,10 @@ public class PowerPlayClubButton implements GuiItem
material = Material.REDSTONE_BLOCK; material = Material.REDSTONE_BLOCK;
itemName = C.cRedB + "Power Play Club"; 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.add(" ");
lore.addAll(buildOtherRewardsLore(1));
lore.add(C.cRed + "Get Power Play Club months at"); lore.add(C.cRed + "Get Power Play Club months at");
lore.add(C.cAqua + "mineplex.com/shop"); 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); _item = new ShopItem(material, (byte)0, itemName, lore.toArray(new String[lore.size()]), 1, false, false);
} }
private List<String> buildLore(List<YearMonth> unclaimed) private List<String> buildCosmeticsLore(Set<YearMonth> cosmeticsMonths)
{ {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
lore.add(C.cYellow + "Rewards"); lore.add(C.cYellow + "Unlocked cosmetics");
lore.add(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * unclaimed.size()) + " Game Amplifier"); PowerPlayClubRewards.rewards().entrySet().stream()
lore.add(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * unclaimed.size()) + " Omega Chest"); .filter(entry -> cosmeticsMonths.contains(entry.getKey()))
.sorted(Comparator.comparing(Map.Entry::getKey))
PowerPlayClubRewards.rewardsForMonths(unclaimed).forEach(prize -> .forEach(entry ->
{ {
lore.add(" " + C.cWhite + prize.getPrize()); 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;
}
private List<String> buildOtherRewardsLore(int unclaimed)
{
List<String> 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; return lore;
} }

View File

@ -123,6 +123,7 @@ import mineplex.core.gadget.gadgets.morph.MorphSquid;
import mineplex.core.gadget.gadgets.morph.MorphTitan; import mineplex.core.gadget.gadgets.morph.MorphTitan;
import mineplex.core.gadget.gadgets.morph.MorphUncleSam; import mineplex.core.gadget.gadgets.morph.MorphUncleSam;
import mineplex.core.gadget.gadgets.morph.MorphVillager; 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.MorphWither;
import mineplex.core.gadget.gadgets.morph.managers.SoulManager; import mineplex.core.gadget.gadgets.morph.managers.SoulManager;
import mineplex.core.gadget.gadgets.morph.managers.SwimManager; import mineplex.core.gadget.gadgets.morph.managers.SwimManager;
@ -362,6 +363,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphSnowman(this)); addGadget(new MorphSnowman(this));
addGadget(new MorphUncleSam(this)); addGadget(new MorphUncleSam(this));
addGadget(new MorphSquid(this)); addGadget(new MorphSquid(this));
addGadget(new MorphWitch(this));
addGadget(new MorphGrimReaper(this)); addGadget(new MorphGrimReaper(this));
// Not being added in this update! // Not being added in this update!
//addGadget(new MorphMetalMan(this)); //addGadget(new MorphMetalMan(this));

View File

@ -110,12 +110,7 @@ public class OutfitWindUpSuitBoosterManager
NoteSong song = NBSReader.loadSong(new DataInputStream(new FileInputStream(songFile)), songFile.getName().replace("_", " ").replace(".nbs", "")); NoteSong song = NBSReader.loadSong(new DataInputStream(new FileInputStream(songFile)), songFile.getName().replace("_", " ").replace(".nbs", ""));
if (song != null) if (song != null)
{ {
NotePlayer notePlayer = new NotePlayer(_gadget.getPlugin(), song, new INoteVerifier() { NotePlayer notePlayer = new NotePlayer(_gadget.getPlugin(), song, p -> true, 0.5F, true, player);
@Override
public boolean shouldPlay(Player toPlay) {
return true;
}
}, 0.5F, true, player);
_notePlayers.put(player, notePlayer); _notePlayers.put(player, notePlayer);
} }
} }

View File

@ -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<NoteSong> _songs = new ArrayList<>();
private int _lastSong = 0;
private final Predicate<Player> _shouldPlay;
public MusicManager(Predicate<Player> 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();
}
}
}

View File

@ -2,6 +2,7 @@ package mineplex.core.noteblock;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Predicate;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -14,7 +15,7 @@ public class NotePlayer
{ {
private final JavaPlugin _plugin; private final JavaPlugin _plugin;
private final NoteSong _song; private final NoteSong _song;
private final INoteVerifier _verifier; private final Predicate<Player> _shouldPlay;
private final long _sleepMs; private final long _sleepMs;
private volatile float _volumeMult; private volatile float _volumeMult;
private volatile boolean _loop; private volatile boolean _loop;
@ -22,17 +23,17 @@ public class NotePlayer
private volatile boolean _finished; private volatile boolean _finished;
private volatile Player[] _players = null; 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<Player> shouldPlay, float volumeMult, boolean loop, Player... players)
{ {
this(plugin, song, verifier, volumeMult, loop); this(plugin, song, shouldPlay, volumeMult, loop);
_players = players; _players = players;
} }
public NotePlayer(JavaPlugin plugin, NoteSong song, INoteVerifier verifier, float volumeMult, boolean loop) public NotePlayer(JavaPlugin plugin, NoteSong song, Predicate<Player> shouldPlay, float volumeMult, boolean loop)
{ {
_plugin = plugin; _plugin = plugin;
_song = song; _song = song;
_verifier = verifier; _shouldPlay = shouldPlay;
_sleepMs = (long) (1000 / (song.getTempo() / 100D)); _sleepMs = (long) (1000 / (song.getTempo() / 100D));
_loop = loop; _loop = loop;
_tick = 0; _tick = 0;
@ -103,7 +104,7 @@ public class NotePlayer
List<Player> players = new ArrayList<>(playerArray.length); List<Player> players = new ArrayList<>(playerArray.length);
for (Player player : playerArray) for (Player player : playerArray)
{ {
if (_verifier.shouldPlay(player)) if (_shouldPlay != null && _shouldPlay.test(player))
players.add(player); players.add(player);
} }

View File

@ -2,11 +2,13 @@ package mineplex.core.powerplayclub;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor; import mineplex.core.account.ILoginProcessor;
import mineplex.core.donation.DonationManager;
import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.DBPool;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -28,9 +30,11 @@ public class PowerPlayClubRepository implements Listener {
private final Map<UUID, PowerPlayData> _cachedPlayerData = new HashMap<>(); private final Map<UUID, PowerPlayData> _cachedPlayerData = new HashMap<>();
private final CoreClientManager _clientManager; private final CoreClientManager _clientManager;
private final DonationManager _donationManager;
public PowerPlayClubRepository(JavaPlugin plugin, CoreClientManager clientManager) { public PowerPlayClubRepository(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) {
_clientManager = clientManager; _clientManager = clientManager;
_donationManager = donationManager;
Bukkit.getPluginManager().registerEvents(this, plugin); 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 @EventHandler
public void onQuit(PlayerQuitEvent event) public void onQuit(PlayerQuitEvent event)
{ {

View File

@ -51,13 +51,18 @@ public class PowerPlayClubRewards
} }
} }
public static List<PowerPlayClubItem> rewardsForMonths(List<YearMonth> months) public static List<PowerPlayClubItem> rewardsForMonths(Set<YearMonth> months)
{ {
return months.stream().map(rewards::get).collect(Collectors.toList()); return months.stream().sorted().map(rewards::get).collect(Collectors.toList());
}
public static Map<YearMonth, PowerPlayClubItem> 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..")); UtilPlayer.message(player, F.main("Power Play Club", "Verifying subscription.."));
@ -70,18 +75,7 @@ public class PowerPlayClubRewards
} }
PowerPlayData cached = repo.getCachedData(player); PowerPlayData cached = repo.getCachedData(player);
List<PowerPlayClubItem> items = rewardsForMonths(cached.getUnclaimedMonths()); int unclaimed = cached.getUnclaimedMonths().size();
// 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()) + "."));
});
// Give amplifiers and chests // Give amplifiers and chests
Item gameAmplifier = inventoryManager.getItem("Game Booster"); Item gameAmplifier = inventoryManager.getItem("Game Booster");
@ -91,8 +85,8 @@ public class PowerPlayClubRewards
} }
else else
{ {
inventoryManager.addItemToInventory(player, gameAmplifier.Name, AMPLIFIERS_PER_MONTH * items.size()); inventoryManager.addItemToInventory(player, gameAmplifier.Name, AMPLIFIERS_PER_MONTH * unclaimed);
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (AMPLIFIERS_PER_MONTH * items.size()) + "x " + F.elem("Game Amplifier") + ".")); 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"); Item omegaChest = inventoryManager.getItem("Omega Chest");
if (omegaChest == null) if (omegaChest == null)
@ -101,8 +95,8 @@ public class PowerPlayClubRewards
} }
else else
{ {
inventoryManager.addItemToInventory(player, omegaChest.Name, CHESTS_PER_MONTH * items.size()); inventoryManager.addItemToInventory(player, omegaChest.Name, CHESTS_PER_MONTH * unclaimed);
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (CHESTS_PER_MONTH * items.size()) + "x " + F.elem("Omega Chest") + ".")); 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 // Refresh Power Play data on the server

View File

@ -9,25 +9,65 @@ import java.util.stream.Collectors;
public class PowerPlayData public class PowerPlayData
{ {
private final boolean _subscribed; /* If this is set, the player's subscription is planned to recur.
private final List<YearMonth> _unclaimedMonths; *
* 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<LocalDate> _nextClaimDate;
// The months where the player hasn't claimed chests/amplifiers
private final Set<YearMonth> _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<YearMonth> _cosmeticMonths;
static PowerPlayData fromSubsAndClaims(List<Subscription> subscriptions, List<YearMonth> claimedMonths) static PowerPlayData fromSubsAndClaims(List<Subscription> subscriptions, List<YearMonth> claimedMonths)
{ {
if (subscriptions.isEmpty()) 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 // Build the list of potential claim dates from subscriptions
// Note that it's a LinkedList with dates in ascending order
List<LocalDate> claimDates = subscriptions.stream() List<LocalDate> claimDates = subscriptions.stream()
.flatMap(sub -> buildMonths(sub).stream()) .flatMap(sub -> buildMonths(sub).stream())
.sorted() .sorted()
.collect(Collectors.toCollection(LinkedList::new)); .collect(Collectors.toCollection(LinkedList::new));
// Determine if player is subscribed // Determine the player's next claim date (which will tell us whether
LocalDate latestSub = claimDates.get(claimDates.size() - 1); // they're subscribed as well)
final boolean subscribed = latestSub.plusMonths(1).isAfter(LocalDate.now()); final Optional<LocalDate> 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<LocalDate> 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<YearMonth> cosmeticMonths = claimDates.stream()
.map(YearMonth::from)
.filter(yearMonth -> yearMonth.isBefore(YearMonth.now()) || yearMonth.equals(YearMonth.now()))
.collect(Collectors.toSet());
// Remove already-claimed months // Remove already-claimed months
Optional<YearMonth> latestClaimed = claimedMonths.stream().collect(Collectors.maxBy(YearMonth::compareTo)); Optional<YearMonth> latestClaimed = claimedMonths.stream().collect(Collectors.maxBy(YearMonth::compareTo));
@ -48,13 +88,12 @@ public class PowerPlayData
} }
}); });
List<YearMonth> unclaimedMonths = claimDates.stream() Set<YearMonth> unclaimedMonths = claimDates.stream()
.filter(date -> date.isBefore(LocalDate.now()) || date.equals(LocalDate.now())) // Filter dates yet to come .filter(date -> date.isBefore(LocalDate.now()) || date.equals(LocalDate.now())) // Filter dates yet to come
.map(YearMonth::from) .map(YearMonth::from)
.distinct() .collect(Collectors.toSet());
.collect(Collectors.toList());
return new PowerPlayData(subscribed, unclaimedMonths); return new PowerPlayData(nextClaimDate, unclaimedMonths, cosmeticMonths);
} }
private static List<LocalDate> buildMonths(Subscription subscription) private static List<LocalDate> buildMonths(Subscription subscription)
@ -66,9 +105,16 @@ public class PowerPlayData
case YEAR: case YEAR:
List<LocalDate> months = new ArrayList<>(); List<LocalDate> 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; return months;
@ -77,7 +123,8 @@ public class PowerPlayData
} }
} }
static class Subscription { static class Subscription
{
private final LocalDate _startDate; private final LocalDate _startDate;
private final SubscriptionDuration _duration; private final SubscriptionDuration _duration;
@ -88,29 +135,45 @@ public class PowerPlayData
} }
} }
enum SubscriptionDuration { enum SubscriptionDuration
{
MONTH, YEAR MONTH, YEAR
} }
private PowerPlayData(boolean subscribed, List<YearMonth> unclaimedMonths) private PowerPlayData(Optional<LocalDate> nextClaimDate, Set<YearMonth> unclaimedMonths, Set<YearMonth> cosmeticMonths)
{ {
_subscribed = subscribed; _nextClaimDate = nextClaimDate;
_unclaimedMonths = unclaimedMonths; _unclaimedMonths = unclaimedMonths;
_cosmeticMonths = cosmeticMonths;
} }
public List<YearMonth> getUnclaimedMonths() public Optional<LocalDate> getNextClaimDate()
{
return _nextClaimDate;
}
public Set<YearMonth> getUnclaimedMonths()
{ {
return _unclaimedMonths; return _unclaimedMonths;
} }
public Set<YearMonth> getUsableCosmeticMonths()
{
return _cosmeticMonths;
}
public boolean isSubscribed() public boolean isSubscribed()
{ {
return _subscribed; return _nextClaimDate.isPresent();
} }
@Override @Override
public String toString() 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();
} }
} }

View File

@ -12,7 +12,6 @@ import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -248,11 +247,8 @@ public class ReportManager
checkNotNull(report); checkNotNull(report);
checkNotNull(reportResult); 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) if (reportCloser != null)
{ {
int closerId = _clientManager.Get(reportCloser).getAccountId(); int closerId = _clientManager.Get(reportCloser).getAccountId();
@ -265,6 +261,8 @@ public class ReportManager
CompletableFuture<Long> saveCompletableFuture = saveReport(report); CompletableFuture<Long> saveCompletableFuture = saveReport(report);
saveCompletableFuture.thenAccept(reportId -> saveCompletableFuture.thenAccept(reportId ->
{
try
{ {
if (reportResult.getType() == ReportResultType.ABUSIVE) if (reportResult.getType() == ReportResultType.ABUSIVE)
{ {
@ -290,7 +288,7 @@ public class ReportManager
// TODO: force moderator to choose a punishment (requires new punish gui) // TODO: force moderator to choose a punishment (requires new punish gui)
CommandCenter.Instance.onPlayerCommandPreprocess( CommandCenter.Instance.onPlayerCommandPreprocess(
new PlayerCommandPreprocessEvent(reportCloser, new PlayerCommandPreprocessEvent(reportCloser,
String.format("/punish %s Report #%s - %s", suspectName, reportId, reason))); String.format("/punish %s Report #%d - %s", suspectName, reportId, reason)));
} }
// TODO: send these after punishment has been decided (requires new punish gui) // TODO: send these after punishment has been decided (requires new punish gui)
@ -321,9 +319,11 @@ public class ReportManager
}); });
_reportRepository.clearCache(reportId); _reportRepository.clearCache(reportId);
}).exceptionally(throwable -> { }
catch (Throwable throwable)
{
_plugin.getLogger().log(Level.SEVERE, "Post-report save failed.", throwable); _plugin.getLogger().log(Level.SEVERE, "Post-report save failed.", throwable);
return null; }
}); });
}); });
} }
@ -512,27 +512,12 @@ public class ReportManager
*/ */
public CompletableFuture<Boolean> isHandlingReport(int accountId) public CompletableFuture<Boolean> isHandlingReport(int accountId)
{ {
CompletableFuture<List<Long>> future = _reportRepository.getReportsHandling(accountId); return _reportRepository.getReportsHandling(accountId)
.thenApply(reportIds -> reportIds.size() > 0)
return future.thenApply(reportIds -> { .exceptionally(throwable -> true);
// if for some reason we cannot fetch the report a user is handling // ^ if for some reason we cannot fetch the report a user is handling
// assume the worst and return true // assume the worst and return true
// this means we do not end up allowing a user to handle multiple reports simultaneously // 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;
});
} }
/** /**
@ -558,7 +543,7 @@ public class ReportManager
reportIds.stream().map(_reportRepository::getReport).collect(Collectors.toList()) reportIds.stream().map(_reportRepository::getReport).collect(Collectors.toList())
).thenCompose(UtilFuture::sequence) ).thenCompose(UtilFuture::sequence)
.thenApply(UtilCollections::unboxPresent) .thenApply(UtilCollections::unboxPresent)
.thenCompose(reports -> UtilFuture.filter(reports, this::isActiveReport)).thenApply(reports -> .thenApply(reports ->
{ {
Report report = null; Report report = null;
int size = reports.size(); int size = reports.size();
@ -575,11 +560,7 @@ public class ReportManager
return Optional.ofNullable(report); return Optional.ofNullable(report);
}); });
future.exceptionally(throwable -> future.exceptionally(throwable -> Optional.empty());
{
_plugin.getLogger().log(Level.SEVERE, "Error getting the report account is handling.", throwable);
return Optional.empty();
});
return future; return future;
} }
@ -632,7 +613,9 @@ public class ReportManager
{ {
int playerId = _clientManager.Get(player).getAccountId(); int playerId = _clientManager.Get(player).getAccountId();
getReportHandling(playerId).thenAccept(reportOptional -> getReportHandling(playerId).whenComplete((reportOptional, throwable) ->
{
if (throwable == null)
{ {
if (reportOptional.isPresent()) if (reportOptional.isPresent())
{ {
@ -644,10 +627,16 @@ public class ReportManager
new ReportHandlerTask(this, reportId).start(_plugin); 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) _reportRepository.getOngoingReports(playerId).whenComplete((reports, throwable) ->
.thenAccept(reports -> {
if (throwable == null)
{ {
for (Report report : reports) for (Report report : reports)
{ {
@ -656,7 +645,11 @@ public class ReportManager
String.format("%s has joined %s.", player.getName(), F.elem(_serverName)))); 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) protected void onPlayerQuit(Player player)

View File

@ -1,5 +1,7 @@
package mineplex.core.report.command; package mineplex.core.report.command;
import java.util.logging.Level;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
@ -30,7 +32,9 @@ public class ReportAbortCommand extends CommandBase<ReportPlugin>
{ {
ReportManager reportManager = Plugin.getReportManager(); ReportManager reportManager = Plugin.getReportManager();
reportManager.getReportHandling(player).thenApply(BukkitFuture.accept(reportOptional -> reportManager.getReportHandling(player).whenComplete(BukkitFuture.complete((reportOptional, throwable) ->
{
if (throwable == null)
{ {
if (reportOptional.isPresent()) if (reportOptional.isPresent())
{ {
@ -44,6 +48,12 @@ public class ReportAbortCommand extends CommandBase<ReportPlugin>
{ {
UtilPlayer.message(player, F.main(Plugin.getName(), "You aren't currently handling a report.")); UtilPlayer.message(player, F.main(Plugin.getName(), "You aren't currently handling a report."));
} }
}
else
{
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);
}
})); }));
} }
else else

View File

@ -1,5 +1,7 @@
package mineplex.core.report.command; package mineplex.core.report.command;
import java.util.logging.Level;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
@ -57,6 +59,7 @@ public class ReportCloseCommand extends CommandBase<ReportPlugin>
else else
{ {
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "An error occurred, please try again later.")); 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);
} }
}); });
} }

View File

@ -4,6 +4,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -39,9 +40,11 @@ public class ReportHandleCommand extends CommandBase<ReportPlugin>
ReportRepository reportRepository = reportManager.getReportRepository(); ReportRepository reportRepository = reportManager.getReportRepository();
int accountId = _commandCenter.GetClientManager().getAccountId(player); int accountId = _commandCenter.GetClientManager().getAccountId(player);
reportManager.isHandlingReport(player).thenAccept(isHandlingReport -> reportManager.isHandlingReport(player).whenComplete((handlingReport, throwable) ->
{ {
if (!isHandlingReport) if (throwable == null)
{
if (!handlingReport)
{ {
Map<Report, Double> reportPriorities = Collections.synchronizedMap(new HashMap<>()); Map<Report, Double> reportPriorities = Collections.synchronizedMap(new HashMap<>());
boolean devMode = reportManager.isDevMode(player.getUniqueId()); boolean devMode = reportManager.isDevMode(player.getUniqueId());
@ -96,6 +99,12 @@ public class ReportHandleCommand extends CommandBase<ReportPlugin>
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "You are already handling a report."))); UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "You are already handling a report.")));
} }
}
else
{
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);
}
}); });
} }
else else

View File

@ -227,11 +227,7 @@ public class ReportRepository
return reportsHandling; return reportsHandling;
}); });
future.exceptionally(throwable -> future.exceptionally(throwable -> null);
{
_logger.log(Level.SEVERE, "Error fetching reports being handled by specified account.", throwable);
return new ArrayList<>();
});
return future; return future;
} }

View File

@ -156,7 +156,7 @@ public class BlockChangeAnimation extends Animation
if(c.equals(b)) if(c.equals(b))
{ {
_blockInfoList.add(new BlockInfo(b)); _blockInfoList.add(new BlockInfo(b));
b.setType(Material.PUMPKIN); b.setType(Material.JACK_O_LANTERN);
b.setData(getDirection(c)); b.setData(getDirection(c));
} }
} }

View File

@ -57,7 +57,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
_punish = new Punish(plugin, plugin.GetWebServerAddress(), clientManager); _punish = new Punish(plugin, plugin.GetWebServerAddress(), clientManager);
_purchaseManager = new PurchaseManager(plugin); _purchaseManager = new PurchaseManager(plugin);
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager); _powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager, donationManager);
plugin.getCommand("enjin_mineplex").setExecutor(this); plugin.getCommand("enjin_mineplex").setExecutor(this);
plugin.getCommand("pull").setExecutor(this); plugin.getCommand("pull").setExecutor(this);

View File

@ -36,6 +36,7 @@ import mineplex.core.menu.MenuManager;
import mineplex.core.message.PrivateMessageEvent; import mineplex.core.message.PrivateMessageEvent;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.noteblock.INoteVerifier; import mineplex.core.noteblock.INoteVerifier;
import mineplex.core.noteblock.MusicManager;
import mineplex.core.noteblock.NBSReader; import mineplex.core.noteblock.NBSReader;
import mineplex.core.noteblock.NotePlayer; import mineplex.core.noteblock.NotePlayer;
import mineplex.core.noteblock.NoteSong; import mineplex.core.noteblock.NoteSong;
@ -156,12 +157,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>(); private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>();
// 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<NoteSong> _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) 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); super("Hub Manager", plugin);
@ -237,6 +232,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; ((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); // _halloweenManager = new HalloweenSpookinessManager(this);
// new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); // new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager);
@ -249,44 +245,12 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
_customDataManager = Managers.get(CustomDataManager.class); _customDataManager = Managers.get(CustomDataManager.class);
_songs = new ArrayList<NoteSong>();
_punishManager = punish; _punishManager = punish;
_valentinesManager = new ValentinesManager(plugin, clientManager, donationManager); _valentinesManager = new ValentinesManager(plugin, clientManager, donationManager);
new NonPremiumManager(plugin, clientManager); 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) ScoreboardManager scoreboardManager = new ScoreboardManager(plugin)
{ {
@Override @Override
@ -404,37 +368,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
Managers.put(scoreboardManager, ScoreboardManager.class); 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 @Override
public void addCommands() public void addCommands()
{ {
@ -1053,12 +986,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
; ;
} }
@EventHandler
public void onSongFinish(SongFinishEvent event)
{
playNextSong();
}
@EventHandler @EventHandler
public void trackPortalDelayPlayers(UpdateEvent event) public void trackPortalDelayPlayers(UpdateEvent event)
{ {

View File

@ -300,7 +300,7 @@ public class NewsManager extends MiniPlugin
* Myst's sexy ass animation :> * Myst's sexy ass animation :>
*/ */
_animationIndex = (_animationIndex + 1) % 147; _animationIndex = (_animationIndex + 1) % 67;
if (_animationIndex == 0) text = C.cGoldB + " "; if (_animationIndex == 0) text = C.cGoldB + " ";
if (_animationIndex == 1) text = C.cGoldB + " H"; if (_animationIndex == 1) text = C.cGoldB + " H";
@ -328,9 +328,9 @@ public class NewsManager extends MiniPlugin
if (_animationIndex > 22 && _animationIndex <= 42) if (_animationIndex > 22 && _animationIndex <= 42)
{ {
if (_animationIndex % 3 == 0) text = C.cWhiteB + "2015" + C.cGoldB + " 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 + "2015" + C.cRedB + " HAPPY HALLOWEEN " + C.cWhiteB + "2015"; else if (_animationIndex % 3 == 1) text = C.cWhiteB + "2016" + C.cRedB + " HAPPY HALLOWEEN " + C.cWhiteB + "2016";
else text = C.cWhiteB + "2015" + C.cYellowB + " HAPPY HALLOWEEN " + C.cWhiteB + "2015"; else text = C.cWhiteB + "2016" + C.cYellowB + " HAPPY HALLOWEEN " + C.cWhiteB + "2016";
} }
if (_animationIndex == 43 || _animationIndex == 44) text = C.cGoldB + " HAPPY HALLOWEEN "; 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 == 64) text = C.cGoldB + "EN ";
if (_animationIndex == 65) text = C.cGoldB + "N "; if (_animationIndex == 65) text = C.cGoldB + "N ";
if (_animationIndex == 66) text = C.cGoldB + " "; 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 else
{ {

View File

@ -0,0 +1 @@
ALTER TABLE Account.reportResults MODIFY reason VARCHAR(256);

View File

@ -162,3 +162,5 @@ 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 (0, 'CHAT');
INSERT INTO Account.snapshotTypes (id, name) VALUES (1, 'PM'); INSERT INTO Account.snapshotTypes (id, name) VALUES (1, 'PM');
INSERT INTO Account.snapshotTypes (id, name) VALUES (2, 'PARTY'); INSERT INTO Account.snapshotTypes (id, name) VALUES (2, 'PARTY');
INSERT INTO Account.reportTeams (id, name) VALUES (0, 'RC');

View File

@ -356,12 +356,13 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
} }
$validId = isset($_GET['id']); $validId = isset($_GET['id']);
$idError = ""; $errorMsg = "";
$id = null; $id = null;
$expanded = null; $expanded = null;
$report = null; $report = null;
$snapshot = null; $snapshot = null;
$messages = null;
if ($validId) if ($validId)
{ {
@ -372,11 +373,20 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
if ($report) if ($report)
{ {
$snapshot = $report->getSnapshot(); $snapshot = $report->getSnapshot();
if ($snapshot != null)
{
$messages = $snapshot->getMessages();
}
else
{
$errorMsg = 'No associated snapshot found for report.';
}
} }
else else
{ {
$validId = false; $validId = false;
$idError = "Invalid id."; $errorMsg = "Invalid id.";
} }
} }
?> ?>
@ -415,12 +425,15 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
</form> </form>
</div> </div>
<?php if (isset($_GET['id']) && !$validId && !empty($idError)): ?> <?php if ((isset($_GET['id']) && !$validId) || !empty($errorMsg)): ?>
<div id="content" class="center-block" style="text-align: center; background-color: rgba(204, 34, 42, 0.52);"> <div id="content" class="center-block" style="text-align: center; background-color: rgba(204, 34, 42, 0.52);">
<p class="error-oh-no" style="font-size: 60px;">What did you do?!?!?</p> <p class="error-oh-no" style="font-size: 60px;">What did you do?!?!?</p>
<img src="img/shaun.gif" /> <img src="img/shaun.gif" />
<p class="error-oh-no" style="font-size: 40px;">Error: <?= $idError ?></p>
<br> <?php if (!empty($errorMsg)): ?>
<p class="error-oh-no" style="font-size: 40px;">Error: <?= $errorMsg ?></p>
<br />
<?php endif; ?>
</div> </div>
<?php else: ?> <?php else: ?>
<?php if (!isset($_GET['id'])) exit(); ?> <?php if (!isset($_GET['id'])) exit(); ?>
@ -440,9 +453,6 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
<div id="log"> <div id="log">
<?php <?php
// INITIALIZE // INITIALIZE
// Get messages and the amount that we are going to display
$messages = $snapshot->getMessages();
$messageCount = count($messages); $messageCount = count($messages);
$displayAmount = $expanded || $messageCount <= collapsedMessageCount ? $messageCount : collapsedMessageCount; $displayAmount = $expanded || $messageCount <= collapsedMessageCount ? $messageCount : collapsedMessageCount;

View File

@ -73,7 +73,7 @@ public class StaffServer extends JavaPlugin
require(PacketHandler.class); require(PacketHandler.class);
require(DisguiseManager.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 CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this, clientManager), statsManager, powerPlayRepo), powerPlayRepo);
//new Password(this, serverStatusManager.getCurrentServerName()); //new Password(this, serverStatusManager.getCurrentServerName());

View File

@ -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.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor"));
caller.sendMessage(C.cDGreen + C.Strike + "============================================="); 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 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()); _accountBonusLog.remove(client.getAccountId());
} }

View File

@ -698,14 +698,7 @@ public class Valentines extends SoloGame
} }
//Music! //Music!
_music = new NotePlayer(Manager.getPlugin(), noteSong, new INoteVerifier() _music = new NotePlayer(Manager.getPlugin(), noteSong, p -> Manager.getPreferences().get(p).isActive(Preference.HUB_MUSIC), 0.7F, true);
{
@Override
public boolean shouldPlay(Player player)
{
return Manager.getPreferences().get(player).isActive(Preference.HUB_MUSIC);
}
}, 0.7F, true);
} }
@Override @Override