Add boosters to inventory menu
This commit is contained in:
parent
184d247fc9
commit
93c2886601
@ -1,5 +1,6 @@
|
||||
package mineplex.core.cosmetic.ui;
|
||||
|
||||
import mineplex.core.cosmetic.ui.page.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
@ -7,10 +8,6 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||
import mineplex.core.cosmetic.ui.page.Menu;
|
||||
import mineplex.core.cosmetic.ui.page.PetTagPage;
|
||||
import mineplex.core.cosmetic.ui.page.TreasurePage;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
@ -57,15 +54,15 @@ public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMes
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateTreasure(UpdateEvent event)
|
||||
public void updatePages(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
for (ShopPageBase<CosmeticManager, ? extends ShopBase<CosmeticManager>> shop : getPlayerPageMap().values())
|
||||
{
|
||||
if (shop instanceof TreasurePage)
|
||||
((TreasurePage) shop).update();
|
||||
if (shop instanceof BoosterPage)
|
||||
((BoosterPage) shop).updatePage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,11 @@ import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -16,9 +19,13 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class BoosterPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
private int _count = 0;
|
||||
|
||||
public BoosterPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, "Game Boosters", player, 9);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,10 +34,14 @@ public class BoosterPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
|
||||
lore.add(" ");
|
||||
lore.add("You Own: ");
|
||||
|
||||
ShopItem booster = new ShopItem(Material.SUGAR, "Game Booster",);
|
||||
lore.add("You Own: " + _count++);
|
||||
|
||||
ShopItem booster = new ShopItem(Material.SUGAR, "Game Booster", lore.toArray(new String[0]), 0, false, false);
|
||||
setItem(4, booster);
|
||||
}
|
||||
|
||||
public void updatePage()
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
@ -71,19 +71,20 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
addItem(4, shards);
|
||||
|
||||
// Cosmetic Items
|
||||
// int[] slots = UtilUI.getIndicesFor(12, 2);
|
||||
int particleSlot = 10;//slots[0];
|
||||
int arrowSlot = 12;//slots[1];
|
||||
int jumpSlot = 14;//slots[2];
|
||||
int deathSlot = 16;//slots[3];
|
||||
int gadgetSlot = 28;//slots[4];
|
||||
int morphSlot = 30;//slots[5];
|
||||
int mountSlot = 32;//slots[6];
|
||||
int petSlot = 34;//slots[7];
|
||||
int hatSlot = 46;//slots[8];
|
||||
int costumeSlot = 48;//slots[9];
|
||||
int musicSlot = 50;//slots[10];
|
||||
int tauntSlot = 52;//slots[11];
|
||||
int[] slots = UtilUI.getIndicesFor(13, 2);
|
||||
int particleSlot = slots[0];
|
||||
int arrowSlot = slots[1];
|
||||
int jumpSlot = slots[2];
|
||||
int deathSlot = slots[3];
|
||||
int gadgetSlot = slots[4];
|
||||
int morphSlot = slots[5];
|
||||
int mountSlot = slots[6];
|
||||
int petSlot = slots[7];
|
||||
int hatSlot = slots[8];
|
||||
int costumeSlot = slots[9];
|
||||
int musicSlot = slots[10];
|
||||
int tauntSlot = slots[11];
|
||||
int boosterSlot = slots[12];
|
||||
|
||||
EnumMap<GadgetType, Integer> ownedCount = new EnumMap<GadgetType, Integer>(GadgetType.class);
|
||||
EnumMap<GadgetType, Integer> maxCount = new EnumMap<GadgetType, Integer>(GadgetType.class);
|
||||
@ -200,6 +201,10 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
player.sendMessage(F.main("Shop", "Coming soon!"));
|
||||
}
|
||||
});
|
||||
|
||||
addButton(boosterSlot, new ShopItem(Material.EMERALD, "Game Boosters",
|
||||
new String[]{C.Bold + "", C.cDGreen + C.Italics + "Coming soon!"}, 1, false),
|
||||
(player, clickType) -> openBoosters(player));
|
||||
}
|
||||
|
||||
private String[] getLore(int ownedCount, int maxCount, String info, String visibility, Gadget enabled)
|
||||
@ -247,4 +252,9 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
getShop().openPageForPlayer(player, new MusicPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Music", player));
|
||||
}
|
||||
|
||||
public void openBoosters(Player player)
|
||||
{
|
||||
getShop().openPageForPlayer(player, new BoosterPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,20 @@ package mineplex.core.gamebooster;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.data.Data;
|
||||
|
||||
public class BoosterData implements Data
|
||||
{
|
||||
private BoostGame _game;
|
||||
private long _timeRemaining;
|
||||
private List<BoostedGame> _boostQueue = new ArrayList<>();
|
||||
|
||||
public BoosterData(BoostGame game)
|
||||
{
|
||||
_game = game;
|
||||
_timeRemaining = 1000 * 60 * 60;
|
||||
}
|
||||
|
||||
public List<BoostedGame> getBoostQueue()
|
||||
@ -19,6 +23,11 @@ public class BoosterData implements Data
|
||||
return _boostQueue;
|
||||
}
|
||||
|
||||
public long getTimeRemaining()
|
||||
{
|
||||
return _timeRemaining;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataId()
|
||||
{
|
||||
@ -27,24 +36,23 @@ public class BoosterData implements Data
|
||||
|
||||
public static class BoostedGame
|
||||
{
|
||||
private String _playerName;
|
||||
private UUID _playerUUID;
|
||||
|
||||
private String _server;
|
||||
private String _player;
|
||||
|
||||
public BoostedGame(String _server, String _player)
|
||||
public BoostedGame(String playerName, UUID playerUUID)
|
||||
{
|
||||
this._server = _server;
|
||||
this._player = _player;
|
||||
_playerName = playerName;
|
||||
_playerUUID = playerUUID;
|
||||
}
|
||||
|
||||
public String getServer()
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _server;
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
public UUID getPlayerUUID()
|
||||
{
|
||||
return _player;
|
||||
return _playerUUID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mineplex.core.gamebooster;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.cosmetic.ui.page.BoosterPage;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.serverdata.Region;
|
||||
@ -10,6 +11,9 @@ import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Handles activation of GameBoosters
|
||||
*
|
||||
@ -18,13 +22,14 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
public class GameBoosterManager extends MiniPlugin
|
||||
{
|
||||
// The item name used for InventoryManager
|
||||
private static final String BOOSTER_ITEM = "Global.GameBooster";
|
||||
private static final String BOOSTER_INVENTORY_ITEM = "Global.GameBooster";
|
||||
|
||||
private final CoreClientManager _clientManager;
|
||||
private final DonationManager _donationManager;
|
||||
private final InventoryManager _inventoryManager;
|
||||
|
||||
private final DataRepository<BoosterData> _boosterRepository;
|
||||
private BoostGame _activeBoostGame;
|
||||
|
||||
public GameBoosterManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager)
|
||||
{
|
||||
@ -49,7 +54,7 @@ public class GameBoosterManager extends MiniPlugin
|
||||
*/
|
||||
public int getAvailableBoosters(Player player, BoostGame game)
|
||||
{
|
||||
return _inventoryManager.Get(player).getItemCount(BOOSTER_ITEM);
|
||||
return _inventoryManager.Get(player).getItemCount(BOOSTER_INVENTORY_ITEM);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,10 +72,16 @@ public class GameBoosterManager extends MiniPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
public BoosterData getBoostData(BoostGame game)
|
||||
/**
|
||||
* Return the BoosterData for a specific BoostGame
|
||||
* @param game The BoostGame we want data for
|
||||
* @return The BoosterData instance for that game
|
||||
*/
|
||||
public BoosterData getBoosterData(BoostGame game)
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
BoosterData data = new BoosterData(game);
|
||||
data.getBoostQueue().add(new BoosterData.BoostedGame("Phinary", UUID.randomUUID()));
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -296,7 +296,6 @@ public abstract class Game implements Listener
|
||||
public final ChatStatData BlankLine = new ChatStatData().blankLine();
|
||||
|
||||
// Gems
|
||||
private final DataRepository<BoosterData> _boosterRepository = new RedisDataRepository(Region.currentRegion(), BoosterData.class, "gemBooster");
|
||||
public double GemMultiplier = 1;
|
||||
public boolean GemHunterEnabled = true;
|
||||
public boolean GemBoosterEnabled = true;
|
||||
@ -1364,22 +1363,6 @@ public abstract class Game implements Listener
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void GameStateChange(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Dead)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BoosterData data = _boosterRepository.getElement(Manager.GetServerConfig().ServerType);
|
||||
if (data != null)
|
||||
{
|
||||
data.getBoostQueue().remove(0);
|
||||
_boosterRepository.addElement(data, 60 * 30); // 30 minutes
|
||||
}
|
||||
}
|
||||
|
||||
public void AddGemBooster(Player player)
|
||||
{
|
||||
if (!GemBoosterEnabled)
|
||||
@ -1394,6 +1377,7 @@ public abstract class Game implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
BoosterData data = _boosterRepository.getElement(Manager.GetServerConfig().ServerType);
|
||||
if (data == null)
|
||||
{
|
||||
@ -1418,6 +1402,7 @@ public abstract class Game implements Listener
|
||||
|
||||
Bukkit.broadcastMessage(F.main("Game", "Gem boosters are now active on this server thanks to " + F.elem(player.getName()) + "! Use /tip " + player.getName() + " to give three shards as thanks!"));
|
||||
GemBoosters.add(player.getName());
|
||||
*/
|
||||
}
|
||||
|
||||
public String getBoosters()
|
||||
|
Loading…
Reference in New Issue
Block a user