Finish off the tip system

This commit is contained in:
Shaun Bennett 2016-05-30 12:02:12 -05:00
parent e380354bad
commit 4e9a48ab4f
17 changed files with 469 additions and 60 deletions

View File

@ -1,26 +1,37 @@
package mineplex.core.common;
import mineplex.core.common.util.C;
import org.bukkit.Material;
public enum CurrencyType
{
TOKEN("Tokens", Material.EMERALD),
TREASURE_SHARD("Treasure Shards", Material.PRISMARINE_SHARD),
GEM("Gems", Material.EMERALD),
GOLD("Gold", Material.GOLD_NUGGET);
private String _prefix;
TOKEN("Tokens", "Token", C.cWhite, Material.EMERALD),
TREASURE_SHARD("Treasure Shards", "Treasure Shard", C.cAqua, Material.PRISMARINE_SHARD),
GEM("Gems", "Gem", C.cGreen, Material.EMERALD),
GOLD("Gold", "Gold", C.cGold, Material.GOLD_NUGGET);
private String _plural;
private String _single;
private String _color;
private Material _displayMaterial;
CurrencyType(String prefix, Material displayMaterial)
CurrencyType(String plural, String single, String color, Material displayMaterial)
{
_prefix = prefix;
_plural = plural;
_single = single;
_color = color;
_displayMaterial = displayMaterial;
}
@Deprecated
public String getPrefix()
{
return _prefix;
return _plural;
}
public String getString(int amount)
{
return _color + amount + " " + (amount == 1 ? _single : _plural);
}
public Material getDisplayMaterial()

View File

@ -1,5 +1,6 @@
package mineplex.core.common.util;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.Rank;
import java.util.LinkedList;
@ -200,6 +201,11 @@ public class F
return out;
}
public static String currency(CurrencyType type, int amount)
{
return type.getString(amount) + ChatColor.RESET + C.mBody;
}
public static String vowelAN(String word)
{
return word.toLowerCase().startsWith("a")

View File

@ -15,6 +15,7 @@ import mineplex.core.bonuses.gui.BonusGui;
import mineplex.core.bonuses.gui.SpinGui;
import mineplex.core.bonuses.redis.VoteHandler;
import mineplex.core.bonuses.redis.VotifierCommand;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilParticle.ParticleType;
@ -121,6 +122,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
private RewardManager _rewardManager;
private StatsManager _statsManager;
private FacebookManager _facebookManager;
private BoosterManager _boosterManager;
public boolean _enabled;
private Npc _carlNpc;
private AnimationCarl _animation;
@ -159,7 +161,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
updateOffSet();
}
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, GadgetManager gadgetManager)
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, GadgetManager gadgetManager, BoosterManager boosterManager)
{
super("Bonus", plugin);
_repository = new BonusRepository(plugin, this, donationManager);
@ -168,6 +170,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_npcManager = npcManager;
_hologramManager = hologramManager;
_inventoryManager = inventoryManager;
_boosterManager = boosterManager;
_rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, statsManager, gadgetManager);
@ -822,7 +825,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (entity.equals(_carlNpc.getEntity()))
{
updateDailyStreak(event.getPlayer());
new BonusGui(_plugin, event.getPlayer(), this, _rewardManager, _facebookManager).openInventory();
new BonusGui(_plugin, event.getPlayer(), this, _rewardManager, _facebookManager, _boosterManager).openInventory();
}
}
@ -838,7 +841,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (event.getEntity().equals(_carlNpc.getEntity()))
{
updateDailyStreak(player);
new BonusGui(_plugin, player, this, _rewardManager, _facebookManager).openInventory();
new BonusGui(_plugin, player, this, _rewardManager, _facebookManager, _boosterManager).openInventory();
}
}
}
@ -904,6 +907,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (canDaily(player)) availableRewards++;
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++;
if (!_facebookManager.hasRedeemed(player)) availableRewards++;
if (_boosterManager.getTipManager().Get(player).getTips() > 0) availableRewards++;
Hologram hologram;
@ -1002,6 +1006,11 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return _rewardManager;
}
public BoosterManager getBoosterManager()
{
return _boosterManager;
}
@Override
@EventHandler
public void UnloadPlayer(final ClientUnloadEvent event)

View File

@ -1,5 +1,6 @@
package mineplex.core.bonuses.commands;
import mineplex.core.boosters.BoosterManager;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
@ -7,8 +8,8 @@ import mineplex.core.common.Rank;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.bonuses.gui.BonusGui;
public class GuiCommand extends CommandBase<BonusManager>{
public class GuiCommand extends CommandBase<BonusManager>
{
public GuiCommand(BonusManager plugin)
{
super(plugin, Rank.DEVELOPER, "bonus");
@ -17,7 +18,7 @@ public class GuiCommand extends CommandBase<BonusManager>{
@Override
public void Execute(Player caller, String[] args)
{
new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager()).openInventory();
new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getBoosterManager()).openInventory();
}
}

View File

@ -1,15 +1,11 @@
package mineplex.core.bonuses.gui;
import mineplex.core.bonuses.gui.buttons.FacebookButton;
import mineplex.core.bonuses.gui.buttons.*;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.facebook.FacebookManager;
import mineplex.core.gui.SimpleGui;
import mineplex.core.reward.RewardManager;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.bonuses.gui.buttons.CarlSpinButton;
import mineplex.core.bonuses.gui.buttons.DailyBonusButton;
import mineplex.core.bonuses.gui.buttons.PollButton;
import mineplex.core.bonuses.gui.buttons.RankBonusButton;
import mineplex.core.bonuses.gui.buttons.VoteButton;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -19,7 +15,7 @@ public class BonusGui extends SimpleGui
private BonusManager manager;
public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager)
public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager, BoosterManager boosterManager)
{
super(plugin, player, player.getName() + "'s Bonuses", 5 * 9);
@ -34,6 +30,8 @@ public class BonusGui extends SimpleGui
setItem(15, new PollButton(getPlugin(), player, manager.getPollManager(), manager.getClientManager(), this, manager));
setItem(17, new FacebookButton(player, facebookManager));
setItem(19, new ClaimTipsButton(getPlugin(), player, this, manager, boosterManager));
setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
}

View File

@ -0,0 +1,190 @@
package mineplex.core.bonuses.gui.buttons;
import java.util.ArrayList;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.gui.GuiItem;
import mineplex.core.gui.ItemRefresher;
import mineplex.core.gui.pages.LoadingWindow;
import mineplex.core.gui.pages.TimedMessageWindow;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.bonuses.BonusAmount;
import mineplex.core.bonuses.BonusClientData;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.bonuses.StreakRecord;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
public class ClaimTipsButton implements GuiItem, Listener
{
private ItemStack _item;
private Player _player;
private Plugin _plugin;
private ItemRefresher _gui;
private BonusManager _bonusManager;
private BoosterManager _boosterManager;
public ClaimTipsButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager, BoosterManager boosterManager)
{
_bonusManager = bonusManager;
_boosterManager = boosterManager;
_player = player;
_plugin = plugin;
_gui = gui;
}
@Override
public void setup()
{
Bukkit.getPluginManager().registerEvents(this, getPlugin());
setItem();
}
@Override
public void close()
{
HandlerList.unregisterAll(this);
}
@Override
public void click(ClickType clickType)
{
if (isAvailable()) {
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
refreshItem();
new LoadingWindow(getPlugin(), getPlayer(), 6*9);
_boosterManager.getTipManager().claimTips(getPlayer(), claimed -> {
if (claimed > 0)
{
// Woo, success!
setItem();
if (getPlayer().getOpenInventory() != null)
{
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Booster Tips Collected"), "Tips Collected", 6*9, 20*3, getGui()).openInventory();
}
UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(CurrencyType.TREASURE_SHARD, claimed) + " from Booster Tips!"));
// Pending explosions are strange.. Not sure why we are using strings. Either way, lets display a rank reward effect
_bonusManager.addPendingExplosion(getPlayer(), "RANK");
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
}
else if (claimed == 0)
{
// No tips to claim
if (getPlayer().getOpenInventory() != null)
{
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "No Tips to Claim!"), "You have no tips to claim!", 6*9, 20*3, getGui()).openInventory();
}
UtilPlayer.message(getPlayer(), F.main("Carl", "You have no tips to claim!"));
getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10);
}
else
{
// Failed to claim
if (getPlayer().getOpenInventory() != null)
{
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.RED.getData(), 1, ChatColor.RED + "Error collecting tips. Try again later."), "Error", 6*9, 20*3, getGui()).openInventory();
}
UtilPlayer.message(getPlayer(), F.main("Carl", "Error collecting tips. Try again later."));
getPlayer().playSound(getPlayer().getLocation(), Sound.ENDERDRAGON_GROWL, 1, 10);
}
getPlayer().closeInventory();
});
}
else
{
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10);
}
}
private void setItem()
{
ArrayList<String> lore = new ArrayList<String>();
Material material;
String itemName;
if (isAvailable())
{
material = Material.EMERALD;
itemName = C.cGreen + C.Bold + "Booster Tips";
lore.add(" ");
lore.add(C.cYellow + "Your Tips");
lore.add(" " + C.cWhite + getTips() + " Treasure Shards");
lore.add(" ");
lore.add(ChatColor.RESET + "Click to Claim!");
}
else
{
material = Material.REDSTONE_BLOCK;
itemName = C.cRed + C.Bold + "Booster Tips";
lore.add(" ");
lore.add(C.Reset + "Activate Game Boosters to receive tips");
}
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
}
@Override
public ItemStack getObject()
{
return _item;
}
public void refreshItem()
{
getGui().refreshItem(this);
}
private int getTips()
{
return _boosterManager.getTipManager().Get(getPlayer()).getTips();
}
private boolean isAvailable()
{
return getTips() > 0;
}
public Plugin getPlugin()
{
return _plugin;
}
public Player getPlayer()
{
return _player;
}
public ItemRefresher getGui()
{
return _gui;
}
}

View File

@ -71,7 +71,7 @@ public class Booster
public long getTimeRemaining()
{
return getEndTime().getTime() - System.currentTimeMillis();
return Math.max(0, getEndTime().getTime() - System.currentTimeMillis());
}
public String getTimeRemainingString()

View File

@ -48,10 +48,20 @@ public class BoosterTipManager extends MiniDbClientPlugin<PlayerTipData>
return;
}
// You can't tip yourself, silly!
if (accountId == booster.getAccountId())
{
callback.run(TipAddResult.CANNOT_TIP_SELF);
return;
}
runAsync(() -> {
TipAddResult result;
if (_repository.addTip(accountId, booster.getAccountId(), booster.getBoosterId()))
if (_repository.addTip(accountId, booster.getAccountId(), booster.getBoosterId(), TIP_FOR_SPONSOR))
{
_donationManager.rewardCoinsUntilSuccess(null, "Tips", player.getName(), accountId, TIP_FOR_TIPPER);
result = TipAddResult.SUCCESS;
}
else
result = TipAddResult.ALREADY_TIPPED_BOOSTER;
@ -86,6 +96,8 @@ public class BoosterTipManager extends MiniDbClientPlugin<PlayerTipData>
_donationManager.rewardCoinsUntilSuccess(null, "Tips", playerName, accountId, tips);
}
// Reset tips back to 0
if (Get(player) != null) Get(player).setTips(0);
if (callback != null) callback.run(tips);
});
});
@ -94,7 +106,7 @@ public class BoosterTipManager extends MiniDbClientPlugin<PlayerTipData>
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT tips FROM Account.tips WHERE Account.tips.accountId = " + accountId;
return "SELECT tips FROM Account.accountTip WHERE accountTip.accountId = " + accountId + ";";
}
@Override

View File

@ -1,6 +1,7 @@
package mineplex.core.boosters.tips;
import mineplex.core.database.MinecraftRepository;
import mineplex.database.routines.AddTip;
import mineplex.database.routines.ClaimTips;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
@ -21,12 +22,15 @@ public class BoosterTipRepository extends MinecraftRepository
super(plugin, DBPool.getAccount());
}
public boolean addTip(int tipperId, int recieverId, int boosterId)
public boolean addTip(int tipperId, int receiverId, int boosterId, int tipAmount)
{
// Add tip to recieverId
// Log tip
return false;
AddTip addTip = new AddTip();
addTip.setTipperAccountId(tipperId);
addTip.setBoosterAccountId(receiverId);
addTip.setBoosterId(boosterId);
addTip.setTipAmount(tipAmount);
addTip.execute(jooq().configuration());
return addTip.getSuccess() == 1;
}
public int claimTips(int accountId)

View File

@ -5,8 +5,21 @@ package mineplex.core.boosters.tips;
*/
public enum TipAddResult
{
ALREADY_TIPPED_BOOSTER,
INVALID_ACCOUNT_ID,
ON_COOLDOWN,
SUCCESS
ALREADY_TIPPED_BOOSTER("You have already tipped!"),
INVALID_ACCOUNT_ID("Uh oh, something went wrong. Try relogging"),
CANNOT_TIP_SELF("You can't tip yourself, silly!"),
ON_COOLDOWN(null),
SUCCESS(null);
private String _friendlyMessage;
TipAddResult(String friendlyMessage)
{
_friendlyMessage = friendlyMessage;
}
public String getFriendlyMessage()
{
return _friendlyMessage;
}
}

View File

@ -28,6 +28,20 @@ public class Routines {
return p.getSuccess();
}
/**
* Call <code>Account.addTip</code>
*/
public static java.lang.Byte callAddtip(org.jooq.Configuration configuration, java.lang.Integer tipperAccountId, java.lang.Integer boosterAccountId, java.lang.Integer boosterId, java.lang.Integer tipAmount) {
mineplex.database.routines.AddTip p = new mineplex.database.routines.AddTip();
p.setTipperAccountId(tipperAccountId);
p.setBoosterAccountId(boosterAccountId);
p.setBoosterId(boosterId);
p.setTipAmount(tipAmount);
p.execute(configuration);
return p.getSuccess();
}
/**
* Call <code>Account.check_daily</code>
*/

View File

@ -0,0 +1,93 @@
/**
* This class is generated by jOOQ
*/
package mineplex.database.routines;
/**
* This class is generated by jOOQ.
*/
@javax.annotation.Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.5.2"
},
comments = "This class is generated by jOOQ"
)
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class AddTip extends org.jooq.impl.AbstractRoutine<java.lang.Void> implements java.io.Serializable, java.lang.Cloneable {
private static final long serialVersionUID = 2072534961;
/**
* The parameter <code>Account.addTip.tipperAccountId</code>.
*/
public static final org.jooq.Parameter<java.lang.Integer> tipperAccountId = createParameter("tipperAccountId", org.jooq.impl.SQLDataType.INTEGER, false);
/**
* The parameter <code>Account.addTip.boosterAccountId</code>.
*/
public static final org.jooq.Parameter<java.lang.Integer> boosterAccountId = createParameter("boosterAccountId", org.jooq.impl.SQLDataType.INTEGER, false);
/**
* The parameter <code>Account.addTip.boosterId</code>.
*/
public static final org.jooq.Parameter<java.lang.Integer> boosterId = createParameter("boosterId", org.jooq.impl.SQLDataType.INTEGER, false);
/**
* The parameter <code>Account.addTip.tipAmount</code>.
*/
public static final org.jooq.Parameter<java.lang.Integer> tipAmount = createParameter("tipAmount", org.jooq.impl.SQLDataType.INTEGER, false);
/**
* The parameter <code>Account.addTip.success</code>.
*/
public static final org.jooq.Parameter<java.lang.Byte> success = createParameter("success", org.jooq.impl.SQLDataType.TINYINT, false);
/**
* Create a new routine call instance
*/
public AddTip() {
super("addTip", mineplex.database.Account.Account);
addInParameter(tipperAccountId);
addInParameter(boosterAccountId);
addInParameter(boosterId);
addInParameter(tipAmount);
addOutParameter(success);
}
/**
* Set the <code>tipperAccountId</code> parameter IN value to the routine
*/
public void setTipperAccountId(java.lang.Integer value) {
setValue(mineplex.database.routines.AddTip.tipperAccountId, value);
}
/**
* Set the <code>boosterAccountId</code> parameter IN value to the routine
*/
public void setBoosterAccountId(java.lang.Integer value) {
setValue(mineplex.database.routines.AddTip.boosterAccountId, value);
}
/**
* Set the <code>boosterId</code> parameter IN value to the routine
*/
public void setBoosterId(java.lang.Integer value) {
setValue(mineplex.database.routines.AddTip.boosterId, value);
}
/**
* Set the <code>tipAmount</code> parameter IN value to the routine
*/
public void setTipAmount(java.lang.Integer value) {
setValue(mineplex.database.routines.AddTip.tipAmount, value);
}
/**
* Get the <code>success</code> parameter OUT value from the routine
*/
public java.lang.Byte getSuccess() {
return getValue(success);
}
}

View File

@ -154,12 +154,11 @@ public class Hub extends JavaPlugin implements IRelation
CustomDataManager customDataManager = new CustomDataManager(this, clientManager);
PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager);
BoosterManager boosterManager = new BoosterManager(this, clientManager, donationManager, inventoryManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, boosterManager);
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
BoosterManager boosterManager = new BoosterManager(this, clientManager, donationManager);
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager, boosterManager);
Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat);

View File

@ -191,7 +191,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
// 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)
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, BoosterManager boosterManager)
{
super("Hub Manager", plugin);
@ -227,10 +227,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler, hologramManager);
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
_bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, _gadgetManager);
_bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, _gadgetManager, boosterManager);
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager());
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager);
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager);
new SoccerManager(this, _gadgetManager);
new KothManager(this, _gadgetManager);

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade;
import java.io.File;
import mineplex.core.boosters.BoosterManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -163,7 +164,8 @@ public class Arcade extends JavaPlugin
PetManager petManager = new PetManager(this, _clientManager, _donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress);
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager);
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null);
BoosterManager boosterManager = new BoosterManager(this, _clientManager, _donationManager, inventoryManager);
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager);
cosmeticManager.setInterfaceSlot(7);
cosmeticManager.disableTeamArmor();
@ -171,7 +173,7 @@ public class Arcade extends JavaPlugin
//Arcade Manager
PollManager pollManager = new PollManager(this, _clientManager, _donationManager);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish, eloManager);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish, eloManager, boosterManager);
new GlobalPacketManager(this, _clientManager, serverStatusManager, inventoryManager, _donationManager, petManager, statsManager, _gameManager.getBonusManager().getRewardManager());

View File

@ -226,7 +226,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
StatsManager statsManager, IncognitoManager incognitoManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat,
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager,
NpcManager npcManager, CustomDataManager customDataManager, Punish punish, EloManager eloManager)
NpcManager npcManager, CustomDataManager customDataManager, Punish punish, EloManager eloManager, BoosterManager boosterManager)
{
super("Game Manager", plugin);
@ -246,6 +246,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_conditionManager = new SkillConditionManager(plugin);
_brandingManager = new BrandingManager(plugin);
_boosterManager = boosterManager;
//Dont see a reason to ever just use the normal one
// if (serverConfig.GameList.contains(GameType.ChampionsDominate)
@ -287,9 +288,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_cosmeticManager = cosmeticManager;
_portal = portal;
_petManager = petManager;
_hologramManager = hologramManager;
_eventManager = new EventModule(this, getPlugin());
_resourcePackManager = new ResourcePackManager(plugin, portal);
_boosterManager = new BoosterManager(plugin, clientManager, donationManager);
_customDataManager = customDataManager;
@ -309,12 +310,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_gameTournamentManager = new GameTournamentManager(this);
new GameStatManager(this);
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
_bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, _cosmeticManager.getGadgetManager());
_bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, _cosmeticManager.getGadgetManager(), _boosterManager);
new GameLootManager(this, petManager, _bonusManager.getRewardManager());
new GameSpectatorManager(this);
_gameWorldManager = new GameWorldManager(this);
new MiscManager(this);
_hologramManager = hologramManager;
_idleManager = new IdleManager(this);
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
// new HolidayManager(this, titanGiveaway);

View File

@ -11,13 +11,17 @@ import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.*;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
@ -36,6 +40,7 @@ public class BoosterPodium extends MiniPlugin
private Booster _activeBooster;
private ArmorStand _activeArmorStand;
private Hologram _hologram;
public BoosterPodium(JavaPlugin plugin, String serverGroup, BoosterManager boosterManager, DisguiseManager disguiseManager, HologramManager hologramManager, Location podiumLocation)
{
@ -72,7 +77,7 @@ public class BoosterPodium extends MiniPlugin
_activeArmorStand.remove();
}
Location armorStandLocation = _podiumLocation;
Location armorStandLocation = _podiumLocation.clone();
ArmorStand armorStand = _podiumLocation.getWorld().spawn(armorStandLocation, ArmorStand.class);
armorStand.setVisible(true);
armorStand.setCustomNameVisible(true);
@ -83,12 +88,18 @@ public class BoosterPodium extends MiniPlugin
armorStand.setRemoveWhenFarAway(false);
armorStand.setHelmet(UtilSkull.getPlayerHead(activeBooster.getPlayerName(), activeBooster.getPlayerName(), null));
armorStand.setChestplate(new ItemStack(Material.GOLD_CHESTPLATE));
armorStand.setLeggings(new ItemStack(Material.GOLD_LEGGINGS));
armorStand.setBoots(new ItemStack(Material.GOLD_BOOTS));
// armorStand.setHelmet(UtilSkull.getPlayerHead(activeBooster.getPlayerName(), activeBooster.getPlayerName(), null));
// armorStand.setChestplate(new ItemStack(Material.GOLD_CHESTPLATE));
// armorStand.setLeggings(new ItemStack(Material.GOLD_LEGGINGS));
// armorStand.setBoots(new ItemStack(Material.GOLD_BOOTS));
armorStand.setItemInHand(new ItemStack(Material.EMERALD));
if (_hologram == null)
{
_hologram = new Hologram(_hologramManager, armorStandLocation.clone().add(0, 2, 0), getHologramText(activeBooster));
_hologram.start();
}
runAsync(() -> {
ProfileLoader loader = new ProfileLoader(activeBooster.getUuid().toString(), activeBooster.getPlayerName());
GameProfile profile = new GameProfile(activeBooster.getUuid(), "");
@ -104,13 +115,27 @@ public class BoosterPodium extends MiniPlugin
_activeBooster = activeBooster;
_activeArmorStand = armorStand;
}
else
{
// Active booster null!
if (_activeArmorStand != null)
{
_activeArmorStand.remove();
_activeArmorStand = null;
}
if (_hologram != null)
{
_hologram.stop();
_hologram = null;
}
}
}
public void updateNpcName()
{
if (_activeBooster != null && _activeArmorStand != null)
if (_activeBooster != null && _hologram != null)
{
_activeArmorStand.setCustomName(getNameString(_activeBooster));
_hologram.setText(getHologramText(_activeBooster));
}
}
@ -119,6 +144,15 @@ public class BoosterPodium extends MiniPlugin
return C.cGreen + "Boosted by " + C.cWhite + booster.getPlayerName() + C.cGreen + " - " + C.cWhite + booster.getTimeRemainingString();
}
private String[] getHologramText(Booster booster)
{
return new String[] {
C.cGreen + "Boosted by " + C.cWhite + booster.getPlayerName(),
C.cWhite + booster.getTimeRemainingString() + " Remaining",
C.cAqua + "Right Click to Tip. You get " + BoosterTipManager.TIP_FOR_TIPPER + " Treasure Shards"
};
}
@EventHandler
public void update(UpdateEvent event)
{
@ -146,13 +180,36 @@ public class BoosterPodium extends MiniPlugin
{
if (event.getRightClicked().equals(_activeArmorStand))
{
_boosterManager.getTipManager().addTip(event.getPlayer(), _activeBooster, result -> {
if (result == TipAddResult.SUCCESS)
{
UtilPlayer.message(event.getPlayer(), F.main("Tip", "Thanks for your tip! You earned " + CurrencyType.TREASURE_SHARD.getPrefix() + BoosterTipManager.TIP_FOR_TIPPER + " Treasure Shards"));
}
});
attemptTip(event.getPlayer(), _activeBooster);
event.setCancelled(true);
}
}
@EventHandler
public void onDamage(EntityDamageByEntityEvent event)
{
if (event.getDamager() instanceof Player && event.getEntity().equals(_activeArmorStand))
{
attemptTip(((Player) event.getDamager()), _activeBooster);
event.setCancelled(true);
}
}
private void attemptTip(Player player, Booster booster)
{
_boosterManager.getTipManager().addTip(player, booster, result -> {
if (result == TipAddResult.SUCCESS)
{
UtilPlayer.message(player, F.main("Tip", "Thanks for your tip! You earned "
+ F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)));
}
else
{
if (result.getFriendlyMessage() != null)
{
UtilPlayer.message(player, F.main("Tip", result.getFriendlyMessage()));
}
}
});
}
}