Implement power play logging and initial rewards
This commit is contained in:
parent
8e8719070c
commit
71b880793f
@ -1,11 +1,5 @@
|
||||
package mineplex.core.bonuses;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -17,11 +11,9 @@ import mineplex.core.bonuses.commands.GuiCommand;
|
||||
import mineplex.core.bonuses.commands.PowerPlayCommand;
|
||||
import mineplex.core.bonuses.commands.TicketCommand;
|
||||
import mineplex.core.bonuses.event.CarlSpinnerEvent;
|
||||
import mineplex.core.bonuses.event.PowerPlayClubClaimEvent;
|
||||
import mineplex.core.bonuses.gui.BonusGui;
|
||||
import mineplex.core.bonuses.gui.SpinGui;
|
||||
import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton;
|
||||
import mineplex.core.bonuses.powerplay.ClaimRegister;
|
||||
import mineplex.core.bonuses.redis.VoteHandler;
|
||||
import mineplex.core.bonuses.redis.VotifierCommand;
|
||||
import mineplex.core.common.Rank;
|
||||
@ -40,7 +32,7 @@ import mineplex.core.npc.Npc;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.poll.PollManager;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubManager;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubRepository;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
@ -72,6 +64,12 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
|
||||
{
|
||||
|
||||
@ -128,13 +126,12 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
private StatsManager _statsManager;
|
||||
private FacebookManager _facebookManager;
|
||||
private YoutubeManager _youtubeManager;
|
||||
private PowerPlayClubManager _powerPlayClubManager;
|
||||
private PowerPlayClubRepository _powerPlayClubRepository;
|
||||
private ThankManager _thankManager;
|
||||
public boolean _enabled;
|
||||
private Npc _carlNpc;
|
||||
private AnimationCarl _animation;
|
||||
private int _visualTick;
|
||||
private ClaimRegister _claimRegister;
|
||||
|
||||
// Streak
|
||||
// private StreakRecord _dailyStreak;
|
||||
@ -157,7 +154,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_repository = new BonusRepository(plugin, this, donationManager);
|
||||
_clientManager = clientManager;
|
||||
_donationManager = donationManager;
|
||||
_powerPlayClubManager = donationManager.getPowerPlayClubManager();
|
||||
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager);
|
||||
|
||||
System.out.print("VOTIFIER: ");
|
||||
System.out.print("DONATION MANAGER - > " + _donationManager.toString());
|
||||
@ -170,8 +167,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_coinQueue = new LinkedList<GiveDonorData>();
|
||||
_gemQueue = new LinkedList<GiveDonorData>();
|
||||
|
||||
_claimRegister = new ClaimRegister();
|
||||
|
||||
updateOffSet();
|
||||
}
|
||||
|
||||
@ -198,7 +193,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_facebookManager = facebookManager;
|
||||
_youtubeManager = youtubeManager;
|
||||
|
||||
_powerPlayClubManager = donationManager.getPowerPlayClubManager();
|
||||
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager);
|
||||
|
||||
_voteList = new ArrayList<String>();
|
||||
_voteList.add("http://vote1.mineplex.com");
|
||||
@ -209,8 +204,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_coinQueue = new LinkedList<GiveDonorData>();
|
||||
_gemQueue = new LinkedList<GiveDonorData>();
|
||||
|
||||
_claimRegister = new ClaimRegister();
|
||||
|
||||
|
||||
if (npcManager != null)
|
||||
{
|
||||
@ -932,7 +925,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++;
|
||||
if (!_facebookManager.hasRedeemed(player)) availableRewards++;
|
||||
if (_thankManager.Get(player).getThankToClaim() > 0) availableRewards++;
|
||||
if (PowerPlayClubButton.isAvailable(player, _powerPlayClubManager)) availableRewards++;
|
||||
if (PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) availableRewards++;
|
||||
|
||||
Hologram hologram;
|
||||
|
||||
@ -1115,7 +1108,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
|
||||
{
|
||||
if(_pollManager.hasPoll(player) || canVote(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubManager))
|
||||
if(_pollManager.hasPoll(player) || canVote(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
|
||||
{
|
||||
if(_showCarl.containsKey(player.getName()))
|
||||
{
|
||||
@ -1124,40 +1117,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Recharge.Instance.use(player, "Power Play Inform", 400000, false, false))
|
||||
{
|
||||
if (PowerPlayClubButton.isAvailable(player, _powerPlayClubManager) && PowerPlayClubButton.getMonthsLeft(player, true, _powerPlayClubManager) == 1)
|
||||
{
|
||||
if (_showCarl.containsKey(player.getName()))
|
||||
{
|
||||
if (_plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Lobby") || _plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "This is your last month of Power Play Club! Resubscribe at" + C.cAqua + " www.mineplex.com/shop" + C.Reset + " before you lose your subscription!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void removeClaims(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC_05)
|
||||
return;
|
||||
|
||||
_claimRegister.removeAll();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void addClaims(PowerPlayClubClaimEvent event)
|
||||
{
|
||||
if (!event.isSuccessful())
|
||||
return;
|
||||
|
||||
_claimRegister.registerEvent(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void processQueue(UpdateEvent event)
|
||||
{
|
||||
@ -1259,9 +1221,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
return _donationManager;
|
||||
}
|
||||
|
||||
public PowerPlayClubManager getPowerPlayClubManager()
|
||||
public PowerPlayClubRepository getPowerPlayClubRepository()
|
||||
{
|
||||
return _powerPlayClubManager;
|
||||
return _powerPlayClubRepository;
|
||||
}
|
||||
|
||||
public InventoryManager getInventoryManager()
|
||||
@ -1269,9 +1231,4 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
return _inventoryManager;
|
||||
}
|
||||
|
||||
public ClaimRegister getClaimRegister()
|
||||
{
|
||||
return _claimRegister;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,19 @@
|
||||
package mineplex.core.bonuses.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class PowerPlayCommand extends CommandBase<BonusManager>
|
||||
{
|
||||
|
||||
/**
|
||||
* Examples:
|
||||
* /powerplay LCastr0 5 -> Adds 5 months to player's power play club months
|
||||
* /powerplay LCastr0 5 false -> same as above
|
||||
* /powerplay LCastr0 5 true -> Sets the last claimed month as June
|
||||
*/
|
||||
|
||||
private BonusManager _bonusManager;
|
||||
|
||||
public PowerPlayCommand(BonusManager manager)
|
||||
@ -31,53 +25,21 @@ public class PowerPlayCommand extends CommandBase<BonusManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Power Play Club", "Missing Args: " + F.elem("/powerplay <player> <month(s)> [setLastClaimed:true/false]")));
|
||||
UtilPlayer.message(caller, F.main("Power Play Club", "Missing Args: " + F.elem("/powerplay <player>")));
|
||||
return;
|
||||
}
|
||||
|
||||
final String targetName = args[0];
|
||||
final String months = args[1];
|
||||
boolean setLastClaimed = false;
|
||||
if (args.length >= 3)
|
||||
{
|
||||
setLastClaimed = Boolean.valueOf(args[2]);
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
if (player == null) {
|
||||
caller.sendMessage(ChatColor.RED + "Couldn't find player");
|
||||
return;
|
||||
}
|
||||
Player target = UtilPlayer.searchExact(targetName);
|
||||
|
||||
_bonusManager.getPowerPlayClubRepository().Get(player).setSubscribed(true);
|
||||
_bonusManager.getPowerPlayClubRepository().addSubscription(_bonusManager.getClientManager().Get(player).getAccountId(), LocalDate.now(), "month");
|
||||
|
||||
rewardPowerPlay(caller, target, target.getName(), months, setLastClaimed);
|
||||
caller.sendMessage(ChatColor.GREEN + "Gave a month's subscription to " + player.getName());
|
||||
}
|
||||
|
||||
private void rewardPowerPlay(Player caller, Player target, String targetName, String months, boolean setLastClaimed)
|
||||
{
|
||||
try
|
||||
{
|
||||
final int iMonths = Integer.parseInt(months);
|
||||
UUID targetUuid = target.getUniqueId();
|
||||
String messageCaller = "You gave " + F.elem(iMonths + UtilText.plural(" Month", iMonths)) + " to " + F.name(targetName) + ".";
|
||||
String messageTarget = F.name(caller.getName()) + " gave you " + F.elem(iMonths + UtilText.plural(" Month", iMonths)) + ".";
|
||||
if (setLastClaimed)
|
||||
{
|
||||
_bonusManager.getPowerPlayClubManager().setLastClaimedMonth(targetUuid, iMonths);
|
||||
messageCaller = "You have set the last claimed month from " + F.name(targetName) + " to " + iMonths + ".";
|
||||
messageTarget = F.name(caller.getName()) + " have set your last claimed month to " + iMonths + ".";
|
||||
}
|
||||
else
|
||||
{
|
||||
_bonusManager.getPowerPlayClubManager().addPlayerMonths(target.getUniqueId(), iMonths);
|
||||
}
|
||||
UtilPlayer.message(caller, F.main("Power Play Club", messageCaller));
|
||||
if (target != null && !target.equals(caller))
|
||||
{
|
||||
UtilPlayer.message(target, F.main("Power Play Club", messageTarget));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Power Play Club", "Invalid Month Amount"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
package mineplex.core.bonuses.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PowerPlayClubClaimEvent extends Event
|
||||
{
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private long _time;
|
||||
private boolean _successful;
|
||||
|
||||
public PowerPlayClubClaimEvent(Player player, boolean successful)
|
||||
{
|
||||
_player = player;
|
||||
_successful = successful;
|
||||
_time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public boolean isSuccessful()
|
||||
{
|
||||
return _successful;
|
||||
}
|
||||
|
||||
public long getTime()
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -1,33 +1,28 @@
|
||||
package mineplex.core.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.event.PowerPlayClubClaimEvent;
|
||||
import mineplex.core.bonuses.powerplay.PowerPlayAnimation;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubManager;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubRepository;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubRewards;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PowerPlayClubButton implements GuiItem
|
||||
{
|
||||
|
||||
private ItemStack _item;
|
||||
private Player _player;
|
||||
private PowerPlayClubManager _powerPlayClubManager;
|
||||
private PowerPlayClubRepository _powerPlayClubRepository;
|
||||
private InventoryManager _inventoryManager;
|
||||
private BonusManager _bonusManager;
|
||||
|
||||
@ -35,7 +30,7 @@ public class PowerPlayClubButton implements GuiItem
|
||||
{
|
||||
_player = player;
|
||||
_bonusManager = manager;
|
||||
_powerPlayClubManager = manager.getPowerPlayClubManager();
|
||||
_powerPlayClubRepository = manager.getPowerPlayClubRepository();
|
||||
_inventoryManager = manager.getInventoryManager();
|
||||
}
|
||||
|
||||
@ -54,18 +49,16 @@ public class PowerPlayClubButton implements GuiItem
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
if (isAvailable() && !_bonusManager.getClaimRegister().alreadyClaimed(_player.getUniqueId()))
|
||||
if (isAvailable() && !_bonusManager.getPowerPlayClubRepository().alreadyClaimed(_player))
|
||||
{
|
||||
_player.closeInventory();
|
||||
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
getMonthlyRewards().giveAllItems(_player, _inventoryManager);
|
||||
updateLastClaimedMonth();
|
||||
Bukkit.getPluginManager().callEvent(new PowerPlayClubClaimEvent(_player, true));
|
||||
PowerPlayClubRewards.giveAllItems(_player, _inventoryManager, _powerPlayClubRepository);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.playSound(_player.getLocation(), Sound.ITEM_BREAK, 1, 10);
|
||||
if (getMonthsLeft(true) > 0)
|
||||
if (_powerPlayClubRepository.alreadyClaimed(_player))
|
||||
{
|
||||
UtilPlayer.message(_player, F.main("Power Play Club", "Already claimed!"));
|
||||
}
|
||||
@ -73,7 +66,6 @@ public class PowerPlayClubButton implements GuiItem
|
||||
{
|
||||
UtilPlayer.message(_player, F.main("Power Play Club", "You have no months left! Buy more months at " + C.cAqua + "www.mineplex.com/shop" + C.Reset + "!"));
|
||||
}
|
||||
Bukkit.getPluginManager().callEvent(new PowerPlayClubClaimEvent(_player, false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,16 +98,16 @@ public class PowerPlayClubButton implements GuiItem
|
||||
lore.add(C.cYellow + "Rewards");
|
||||
lore.add(" " + C.cWhite + "2 Game Amplifiers");
|
||||
lore.add(" " + C.cWhite + "1 Omega Chest");
|
||||
for (PowerPlayClubManager.PowerPlayClubItem prize : getMonthlyRewards().getItems())
|
||||
for (PowerPlayClubRewards.PowerPlayClubItem prize : PowerPlayClubRewards.septemberItems())
|
||||
{
|
||||
lore.add(" " + C.cWhite + prize.getAmount() + " " + prize.getPrize());
|
||||
}
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Months left: " + C.cWhite + getMonthsLeft(true));
|
||||
//lore.add(" ");
|
||||
//lore.add(C.cYellow + "Months left: " + C.cWhite + getMonthsLeft(true)); //TODO: figure this out
|
||||
if (!isAvailable())
|
||||
{
|
||||
lore.add(" ");
|
||||
if (getMonthsLeft(true) > 0)
|
||||
if (_powerPlayClubRepository.alreadyClaimed(_player))
|
||||
{
|
||||
lore.add(C.cRed + "Already claimed!");
|
||||
}
|
||||
@ -131,71 +123,12 @@ public class PowerPlayClubButton implements GuiItem
|
||||
|
||||
private boolean isAvailable()
|
||||
{
|
||||
int monthsLeft = getMonthsLeft(true);
|
||||
int lastClaimed = _powerPlayClubManager.getLastClaimedMonth(_player.getUniqueId(), true);
|
||||
int month = Calendar.getInstance().get(Calendar.MONTH);
|
||||
int actualYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||
int lastClaimedYear = _powerPlayClubManager.getLastClaimedYear(_player.getUniqueId(), true);
|
||||
if (monthsLeft > 0)
|
||||
{
|
||||
if (lastClaimed == -1)
|
||||
return true;
|
||||
if (lastClaimedYear < actualYear)
|
||||
return true;
|
||||
return lastClaimed != month;
|
||||
}
|
||||
return false;
|
||||
return _powerPlayClubRepository.canClaim(_player);
|
||||
}
|
||||
|
||||
private PowerPlayClubManager.PowerPlayClubRewards getMonthlyRewards()
|
||||
public static boolean isAvailable(Player player, PowerPlayClubRepository repo)
|
||||
{
|
||||
String month = Calendar.getInstance().getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.ENGLISH);
|
||||
return PowerPlayClubManager.PowerPlayClubRewards.valueOf(month.toUpperCase());
|
||||
}
|
||||
|
||||
private void updateLastClaimedMonth()
|
||||
{
|
||||
// Send carl animation
|
||||
List<ItemStack> animationItems = new ArrayList<>();
|
||||
for (PowerPlayClubManager.PowerPlayClubItem prize : getMonthlyRewards().getItems())
|
||||
{
|
||||
animationItems.add(prize.getDisplay());
|
||||
}
|
||||
PowerPlayAnimation powerPlayAnimation = new PowerPlayAnimation(_player, animationItems);
|
||||
_bonusManager.addPendingExplosion(_player, powerPlayAnimation);
|
||||
int month = Calendar.getInstance().get(Calendar.MONTH);
|
||||
int year = Calendar.getInstance().get(Calendar.YEAR);
|
||||
_powerPlayClubManager.setLastClaimedMonth(_player.getUniqueId(), month);
|
||||
_powerPlayClubManager.decreasePlayerMonth(_player.getUniqueId());
|
||||
_powerPlayClubManager.setLastClaimedYear(_player.getUniqueId(), year);
|
||||
}
|
||||
|
||||
private int getMonthsLeft(boolean update)
|
||||
{
|
||||
return _powerPlayClubManager.getPlayerMonths(_player.getUniqueId(), update);
|
||||
}
|
||||
|
||||
public static int getMonthsLeft(Player player, boolean update, PowerPlayClubManager manager)
|
||||
{
|
||||
return manager.getPlayerMonths(player.getUniqueId(), update);
|
||||
}
|
||||
|
||||
public static boolean isAvailable(Player player, PowerPlayClubManager manager)
|
||||
{
|
||||
int monthsLeft = getMonthsLeft(player, true, manager);
|
||||
int lastClaimed = manager.getLastClaimedMonth(player.getUniqueId(), true);
|
||||
int month = Calendar.getInstance().get(Calendar.MONTH);
|
||||
int actualYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||
int lastClaimedYear = manager.getLastClaimedYear(player.getUniqueId(), true);
|
||||
if (monthsLeft > 0)
|
||||
{
|
||||
if (lastClaimed == -1)
|
||||
return true;
|
||||
if (lastClaimedYear < actualYear)
|
||||
return true;
|
||||
return lastClaimed != month;
|
||||
}
|
||||
return false;
|
||||
return repo.canClaim(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
package mineplex.core.bonuses.powerplay;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import mineplex.core.bonuses.event.PowerPlayClubClaimEvent;
|
||||
|
||||
public class ClaimRegister
|
||||
{
|
||||
|
||||
/**
|
||||
* Fixes the problem where the database isn't sync'd with the server so the player can still claim it if they try
|
||||
* to click really quickly after it was already claimed.
|
||||
* This stores the player information for 5 seconds, so if they try to claim again they won't be able to.
|
||||
*/
|
||||
|
||||
private Map<UUID, PowerPlayClubClaimEvent> _events = new HashMap<>();
|
||||
|
||||
public void registerEvent(PowerPlayClubClaimEvent event)
|
||||
{
|
||||
_events.put(event.getPlayer().getUniqueId(), event);
|
||||
}
|
||||
|
||||
public void removeAll()
|
||||
{
|
||||
List<UUID> toRemove = new ArrayList<>();
|
||||
long currentTime = System.currentTimeMillis();
|
||||
for (Map.Entry<UUID, PowerPlayClubClaimEvent> eventEntry : _events.entrySet())
|
||||
{
|
||||
PowerPlayClubClaimEvent event = eventEntry.getValue();
|
||||
if (currentTime - event.getTime() >= 5000)
|
||||
{
|
||||
toRemove.add(eventEntry.getKey());
|
||||
}
|
||||
}
|
||||
for (UUID uuid : toRemove)
|
||||
{
|
||||
_events.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean alreadyClaimed(UUID uuid)
|
||||
{
|
||||
return _events.containsKey(uuid);
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,5 @@
|
||||
package mineplex.core.donation;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import mineplex.cache.player.PlayerCache;
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
@ -16,7 +12,6 @@ import mineplex.core.donation.command.GemCommand;
|
||||
import mineplex.core.donation.command.ShardCommand;
|
||||
import mineplex.core.donation.repository.DonationRepository;
|
||||
import mineplex.core.donation.repository.token.DonorTokenWrapper;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubManager;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -25,6 +20,10 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DonationManager extends MiniClientPlugin<Donor>
|
||||
{
|
||||
private final int MAX_GIVE_ATTEMPTS = 10;
|
||||
@ -36,7 +35,6 @@ public class DonationManager extends MiniClientPlugin<Donor>
|
||||
|
||||
private Queue<GiveDonorData> _coinAttemptQueue;
|
||||
|
||||
private PowerPlayClubManager _powerPlayClubManager;
|
||||
private final CoreClientManager _clientManager;
|
||||
|
||||
public DonationManager(JavaPlugin plugin, CoreClientManager clientManager, String webAddress)
|
||||
@ -47,7 +45,6 @@ public class DonationManager extends MiniClientPlugin<Donor>
|
||||
|
||||
_coinAttemptQueue = new LinkedList<>();
|
||||
|
||||
_powerPlayClubManager = new PowerPlayClubManager();
|
||||
_clientManager = clientManager;
|
||||
}
|
||||
|
||||
@ -381,9 +378,4 @@ public class DonationManager extends MiniClientPlugin<Donor>
|
||||
{
|
||||
return new Donor();
|
||||
}
|
||||
|
||||
public PowerPlayClubManager getPowerPlayClubManager()
|
||||
{
|
||||
return _powerPlayClubManager;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package mineplex.core.powerplayclub;
|
||||
|
||||
public class PPCPlayerData {
|
||||
private boolean _subscribed;
|
||||
private boolean _claimed;
|
||||
|
||||
public void setSubscribed(boolean subscribed)
|
||||
{
|
||||
_subscribed = subscribed;
|
||||
}
|
||||
|
||||
public void setClaimed(boolean claimed)
|
||||
{
|
||||
_claimed = claimed;
|
||||
}
|
||||
|
||||
public boolean hasClaimed()
|
||||
{
|
||||
return _claimed;
|
||||
}
|
||||
|
||||
public boolean hasSubscribed()
|
||||
{
|
||||
return _subscribed;
|
||||
}
|
||||
}
|
@ -1,301 +0,0 @@
|
||||
package mineplex.core.powerplayclub;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.*;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.database.PlayerKeyValueRepository;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.inventory.data.Item;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PowerPlayClubManager implements Listener
|
||||
{
|
||||
|
||||
/**
|
||||
* Manager for the Power Play Club system
|
||||
* Sends and receives information from/to the database
|
||||
*/
|
||||
|
||||
private PlayerKeyValueRepository<Integer> _repository;
|
||||
private Map<UUID, PlayerMonths> _playerMonths = new HashMap<>();
|
||||
|
||||
public PowerPlayClubManager()
|
||||
{
|
||||
Bukkit.getPluginManager().registerEvents(this, UtilServer.getPlugin());
|
||||
_repository = new PlayerKeyValueRepository<>("powerPlayClub", PreparedStatement::setInt, ResultSet::getInt);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
updatePlayer(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
public int getLastClaimedMonth(UUID uuid, boolean update)
|
||||
{
|
||||
if (update)
|
||||
{
|
||||
updatePlayer(uuid);
|
||||
}
|
||||
if (_playerMonths.containsKey(uuid))
|
||||
{
|
||||
return _playerMonths.get(uuid).getLastClaimed();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setLastClaimedMonth(UUID uuid, int month)
|
||||
{
|
||||
_repository.put(uuid, "lastClaimed", month);
|
||||
updatePlayer(uuid);
|
||||
PlayerMonths playerMonths = _playerMonths.get(uuid);
|
||||
playerMonths.setLastClaimed(month);
|
||||
_playerMonths.put(uuid, playerMonths);
|
||||
}
|
||||
|
||||
public int getLastClaimedYear(UUID uuid, boolean update)
|
||||
{
|
||||
if (update)
|
||||
{
|
||||
updatePlayer(uuid);
|
||||
}
|
||||
if (_playerMonths.containsKey(uuid))
|
||||
{
|
||||
return _playerMonths.get(uuid).getYear();
|
||||
}
|
||||
return Calendar.getInstance().get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
public void setLastClaimedYear(UUID uuid, int year)
|
||||
{
|
||||
_repository.put(uuid, "year", year);
|
||||
updatePlayer(uuid);
|
||||
PlayerMonths playerMonths = _playerMonths.get(uuid);
|
||||
playerMonths.setYear(year);
|
||||
_playerMonths.put(uuid, playerMonths);
|
||||
}
|
||||
|
||||
public int getPlayerMonths(UUID uuid, boolean update)
|
||||
{
|
||||
if (update)
|
||||
{
|
||||
updatePlayer(uuid);
|
||||
}
|
||||
if (_playerMonths.containsKey(uuid))
|
||||
{
|
||||
return _playerMonths.get(uuid).getMonths();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void addPlayerMonths(UUID uuid, int months)
|
||||
{
|
||||
int currentMonths = getPlayerMonths(uuid, true);
|
||||
_repository.put(uuid, "monthsLeft", currentMonths + months);
|
||||
updatePlayer(uuid);
|
||||
PlayerMonths playerMonths = _playerMonths.get(uuid);
|
||||
playerMonths.setMonths(currentMonths + months);
|
||||
_playerMonths.put(uuid, playerMonths);
|
||||
}
|
||||
|
||||
public void decreasePlayerMonth(UUID uuid)
|
||||
{
|
||||
addPlayerMonths(uuid, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates player's months and last claimed month
|
||||
* @param uuid the player's UUID
|
||||
*/
|
||||
private void updatePlayer(UUID uuid)
|
||||
{
|
||||
_repository.getAll(uuid).thenCompose(BukkitFuture.accept(values ->
|
||||
{
|
||||
int year = Calendar.getInstance().get(Calendar.YEAR);
|
||||
int lastClaimed = -1;
|
||||
int months = 0;
|
||||
if (values.containsKey("claimedYear"))
|
||||
{
|
||||
year = values.get("claimedYear");
|
||||
}
|
||||
if (values.containsKey("lastClaimed"))
|
||||
{
|
||||
lastClaimed = values.get("lastClaimed");
|
||||
}
|
||||
|
||||
if (values.containsKey("monthsLeft"))
|
||||
{
|
||||
months = values.get("monthsLeft");
|
||||
}
|
||||
|
||||
PlayerMonths playerMonths = new PlayerMonths(months, lastClaimed, year);
|
||||
_playerMonths.put(uuid, playerMonths);
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Monthly rewards, based on each month, a different reward
|
||||
*/
|
||||
public enum PowerPlayClubRewards
|
||||
{
|
||||
JANUARY,
|
||||
FEBRUARY,
|
||||
MARCH,
|
||||
APRIL,
|
||||
MAY,
|
||||
JUNE,
|
||||
JULY(new PowerPlayClubItem("Squid Morph", 1, new ItemStack(Material.INK_SACK))),
|
||||
AUGUST(new PowerPlayClubItem("Squid Morph", 1, new ItemStack(Material.INK_SACK))),
|
||||
SEPTEMBER,
|
||||
OCTOBER,
|
||||
NOVEMBER,
|
||||
DECEMBER;
|
||||
|
||||
private PowerPlayClubItem[] _items;
|
||||
|
||||
PowerPlayClubRewards(PowerPlayClubItem... items)
|
||||
{
|
||||
_items = items;
|
||||
}
|
||||
|
||||
public PowerPlayClubItem[] getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the player the specific items for that month, plus
|
||||
* 2x Game Boosters
|
||||
* 1x Omega Chest
|
||||
* @param player
|
||||
* @param manager
|
||||
*/
|
||||
public void giveAllItems(Player player, InventoryManager manager)
|
||||
{
|
||||
for (PowerPlayClubItem item : _items)
|
||||
{
|
||||
Item fItem = manager.getItem(item.getPrize());
|
||||
if (fItem == null)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.addItemToInventory(player, fItem.Name, 1);
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received " + item.getAmount() + "x " + F.elem(item.getPrize()) + "."));
|
||||
}
|
||||
}
|
||||
Item gameAmplifier = manager.getItem("Game Booster");
|
||||
if (gameAmplifier == null)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.addItemToInventory(player, gameAmplifier.Name, 2);
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received 2x " + F.elem("Game Boosters") + "."));
|
||||
}
|
||||
Item omegaChest = manager.getItem("Omega Chest");
|
||||
if (omegaChest == null)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.addItemToInventory(player, omegaChest.Name, 1);
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received 1x " + F.elem("Omega Chest") + "."));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to help on monthly bonuses
|
||||
*/
|
||||
public static class PowerPlayClubItem
|
||||
{
|
||||
private final String _prize;
|
||||
private final int _amount;
|
||||
private final ItemStack _display;
|
||||
|
||||
public PowerPlayClubItem(String prize, int amount, ItemStack display)
|
||||
{
|
||||
_prize = prize;
|
||||
_amount = amount;
|
||||
_display = display;
|
||||
}
|
||||
|
||||
public String getPrize()
|
||||
{
|
||||
return _prize;
|
||||
}
|
||||
|
||||
public int getAmount()
|
||||
{
|
||||
return _amount;
|
||||
}
|
||||
|
||||
public ItemStack getDisplay()
|
||||
{
|
||||
return _display;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class that stores player's months and last claimed month
|
||||
*/
|
||||
protected class PlayerMonths
|
||||
{
|
||||
|
||||
private int _months;
|
||||
private int _lastClaimed;
|
||||
private int _year;
|
||||
|
||||
public PlayerMonths(int months, int lastClaimed, int year)
|
||||
{
|
||||
_months = months;
|
||||
_lastClaimed = lastClaimed;
|
||||
_year = year;
|
||||
}
|
||||
|
||||
public int getMonths()
|
||||
{
|
||||
return _months;
|
||||
}
|
||||
|
||||
public int getLastClaimed()
|
||||
{
|
||||
return _lastClaimed;
|
||||
}
|
||||
|
||||
public int getYear()
|
||||
{
|
||||
return _year;
|
||||
}
|
||||
|
||||
public void setMonths(int months)
|
||||
{
|
||||
_months = months;
|
||||
}
|
||||
|
||||
public void setLastClaimed(int lastClaimed)
|
||||
{
|
||||
_lastClaimed = lastClaimed;
|
||||
}
|
||||
|
||||
public void setYear(int year)
|
||||
{
|
||||
_year = year;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package mineplex.core.powerplayclub;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class PowerPlayClubRepository extends MiniClientPlugin<PPCPlayerData> {
|
||||
|
||||
private final CoreClientManager _clientManager;
|
||||
|
||||
public PowerPlayClubRepository(JavaPlugin plugin, CoreClientManager clientManager) {
|
||||
super("PowerPlayClubRepository", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
|
||||
clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PPC Claim Grabber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException {
|
||||
PowerPlayClubRepository.this.Get(uuid).setClaimed(resultSet.next());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name) {
|
||||
return "SELECT * FROM powerPlayClaims WHERE accountId = " + accountId + ";";
|
||||
}
|
||||
});
|
||||
|
||||
clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PPC Subscription Grabber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException {
|
||||
PowerPlayClubRepository.this.Get(uuid).setSubscribed(resultSet.next());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name) {
|
||||
return "SELECT * FROM powerPlaySubs WHERE accountId = " + accountId + ";";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> addSubscription(int accountId, LocalDate date, String duration)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
try (Connection connection = DBPool.getAccount().getConnection())
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO powerPlaySubs (accountId, startDate, duration) VALUES (?, ?, ?)");
|
||||
statement.setInt(1, accountId);
|
||||
statement.setDate(2, Date.valueOf(date));
|
||||
statement.setString(3, duration);
|
||||
statement.executeUpdate();
|
||||
|
||||
} catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Boolean> attemptClaim(Player player)
|
||||
{
|
||||
int accountId = _clientManager.Get(player).getAccountId();
|
||||
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
try (Connection connection = DBPool.getAccount().getConnection())
|
||||
{
|
||||
LocalDate date = LocalDate.now();
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT IGNORE INTO powerPlayClaims (accountId, claimMonth, claimYear) VALUES (?, ?, ?)");
|
||||
statement.setInt(1, accountId);
|
||||
statement.setInt(2, date.getMonthValue());
|
||||
statement.setInt(3, date.getYear());
|
||||
|
||||
return statement.executeUpdate() == 1;
|
||||
|
||||
} catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public boolean alreadyClaimed(Player player)
|
||||
{
|
||||
return Get(player).hasClaimed();
|
||||
}
|
||||
|
||||
public boolean canClaim(Player player)
|
||||
{
|
||||
return Get(player).hasSubscribed() && !Get(player).hasClaimed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PPCPlayerData addPlayer(UUID uuid) {
|
||||
return new PPCPlayerData();
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package mineplex.core.powerplayclub;
|
||||
|
||||
import mineplex.core.common.util.BukkitFuture;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.inventory.data.Item;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.time.Month;
|
||||
import java.time.Year;
|
||||
import java.util.*;
|
||||
|
||||
public class PowerPlayClubRewards
|
||||
{
|
||||
private static final Map<RewardMonth, List<PowerPlayClubItem>> rewards = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
setRewards(2016, Month.SEPTEMBER, new PowerPlayClubItem("Squid Morph", 1, new ItemStack(Material.INK_SACK)));
|
||||
}
|
||||
|
||||
public static List<PowerPlayClubItem> septemberItems() // TODO: figure this out
|
||||
{
|
||||
return rewards.values().iterator().next();
|
||||
}
|
||||
|
||||
private static void setRewards(int year, Month month, PowerPlayClubItem... items)
|
||||
{
|
||||
rewards.put(new RewardMonth(Year.of(year), month), Arrays.asList(items));
|
||||
}
|
||||
|
||||
private static class RewardMonth
|
||||
{
|
||||
private final Year year;
|
||||
private final Month month;
|
||||
|
||||
static RewardMonth of(Year year, Month month)
|
||||
{
|
||||
return new RewardMonth(year, month);
|
||||
}
|
||||
|
||||
RewardMonth(Year year, Month month)
|
||||
{
|
||||
this.year = year;
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
|
||||
RewardMonth that = (RewardMonth) obj;
|
||||
|
||||
return Objects.equals(this.year, that.year) && Objects.equals(this.month, that.month);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(year, month);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PowerPlayClubItem
|
||||
{
|
||||
private final String _prize;
|
||||
private final int _amount;
|
||||
private final ItemStack _display;
|
||||
|
||||
public PowerPlayClubItem(String prize, int amount, ItemStack display)
|
||||
{
|
||||
_prize = prize;
|
||||
_amount = amount;
|
||||
_display = display;
|
||||
}
|
||||
|
||||
public String getPrize()
|
||||
{
|
||||
return _prize;
|
||||
}
|
||||
|
||||
public int getAmount()
|
||||
{
|
||||
return _amount;
|
||||
}
|
||||
|
||||
public ItemStack getDisplay()
|
||||
{
|
||||
return _display;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void giveAllItems(Player player, InventoryManager manager, PowerPlayClubRepository repo)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "Verifying subscription.."));
|
||||
|
||||
repo.attemptClaim(player).thenCompose(BukkitFuture.accept(success ->
|
||||
{
|
||||
|
||||
if (!success)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
|
||||
return;
|
||||
}
|
||||
|
||||
repo.Get(player).setClaimed(true);
|
||||
|
||||
for (PowerPlayClubItem item : septemberItems()) // TODO: figure this out
|
||||
{
|
||||
Item fItem = manager.getItem(item.getPrize());
|
||||
if (fItem == null)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.addItemToInventory(player, fItem.Name, 1);
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received " + item.getAmount() + "x " + F.elem(item.getPrize()) + "."));
|
||||
}
|
||||
}
|
||||
Item gameAmplifier = manager.getItem("Game Booster");
|
||||
if (gameAmplifier == null)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.addItemToInventory(player, gameAmplifier.Name, 2);
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received 2x " + F.elem("Game Boosters") + "."));
|
||||
}
|
||||
Item omegaChest = manager.getItem("Omega Chest");
|
||||
if (omegaChest == null)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.addItemToInventory(player, omegaChest.Name, 1);
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received 1x " + F.elem("Omega Chest") + "."));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,5 @@
|
||||
package mineplex.enjinTranslator;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -14,10 +7,9 @@ import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubManager;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubRepository;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -29,13 +21,21 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
private PurchaseManager _purchaseManager;
|
||||
private PowerPlayClubManager _powerPlayClubManager;
|
||||
private PowerPlayClubRepository _powerPlayClubRepository;
|
||||
|
||||
private NautHashMap<String, Entry<UUID, Long>> _cachedUUIDs = new NautHashMap<String, Entry<UUID, Long>>();
|
||||
private static Object _commandLock = new Object();
|
||||
@ -53,7 +53,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
_inventoryManager = inventoryManager;
|
||||
|
||||
_purchaseManager = new PurchaseManager(plugin);
|
||||
_powerPlayClubManager = donationManager.getPowerPlayClubManager();
|
||||
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager);
|
||||
|
||||
plugin.getCommand("enjin_mineplex").setExecutor(this);
|
||||
plugin.getCommand("pull").setExecutor(this);
|
||||
@ -287,18 +287,24 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
|
||||
protected boolean checkForPowerPlayClub(String[] args, final String name, final UUID playerUUID, final CoreClient client)
|
||||
{
|
||||
if (args.length != 3 || !args[0].equalsIgnoreCase("powerplayclub"))
|
||||
if (args.length < 3 || !args[0].equalsIgnoreCase("powerplayclub"))
|
||||
return false;
|
||||
|
||||
if (args[2].equalsIgnoreCase("month"))
|
||||
if (args[2].equalsIgnoreCase("add"))
|
||||
{
|
||||
_powerPlayClubManager.addPlayerMonths(playerUUID, 1);
|
||||
} else
|
||||
String[] splitDate = args[3].split("/");
|
||||
LocalDate date = LocalDate.of(Integer.parseInt(splitDate[2]), Integer.parseInt(splitDate[0]), Integer.parseInt(splitDate[1]));
|
||||
|
||||
String duration = args[4];
|
||||
|
||||
_powerPlayClubRepository.addSubscription(client.getAccountId(), date, duration);
|
||||
|
||||
} else if (args[2].equalsIgnoreCase("cancel"))
|
||||
{
|
||||
_powerPlayClubManager.addPlayerMonths(playerUUID, 12);
|
||||
// TODO: cancel it in our logs? I don't think this is necessary.
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean checkForClansPurchase(String[] args, final String name, final CoreClient client)
|
||||
|
Loading…
Reference in New Issue
Block a user