Added rank-based win effects

This commit is contained in:
LCastr0 2017-04-30 11:28:40 -03:00
parent f8566437d5
commit 08150b2c0f
9 changed files with 327 additions and 3 deletions

View File

@ -78,6 +78,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
} }
protected void addGadget(Gadget gadget, int slot) protected void addGadget(Gadget gadget, int slot)
{
addGadget(gadget, slot, false);
}
protected void addGadget(Gadget gadget, int slot, boolean locked)
{ {
List<String> itemLore = new ArrayList<String>(); List<String> itemLore = new ArrayList<String>();
@ -102,7 +107,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(" " + (gadget.getSet().isActive(getPlayer()) ? C.cGreen : C.cGray) + bonus); itemLore.add(" " + (gadget.getSet().isActive(getPlayer()) ? C.cGreen : C.cGray) + bonus);
} }
if (!gadget.ownsGadget(getPlayer())) if (!gadget.ownsGadget(getPlayer()) || locked)
{ {
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1) if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1)
{ {
@ -261,7 +266,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
ItemMeta im = item.getItemMeta(); ItemMeta im = item.getItemMeta();
im.setDisplayName(C.cGreen + C.Bold + gadget.getName()); im.setDisplayName(C.cGreen + C.Bold + gadget.getName());
if (gadget.ownsGadget(getPlayer())) if (gadget.ownsGadget(getPlayer()) && !locked)
{ {
if (gadget.getActive().contains(getPlayer())) if (gadget.getActive().contains(getPlayer()))
{ {
@ -320,7 +325,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
} }
//Standard //Standard
if (gadget.ownsGadget(getPlayer())) if (gadget.ownsGadget(getPlayer()) && !locked)
{ {
ItemStack gadgetItemStack; ItemStack gadgetItemStack;
/*if (gadget instanceof MorphWitch) /*if (gadget instanceof MorphWitch)

View File

@ -5,10 +5,12 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.GadgetType;
import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.IButton;
@ -30,6 +32,9 @@ public class WinEffectPage extends GadgetPage
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.WIN_EFFECT)) for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.WIN_EFFECT))
{ {
if (gadget instanceof WinEffectRankBased)
continue;
addGadget(gadget, slot); addGadget(gadget, slot);
if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.WIN_EFFECT) == gadget) if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.WIN_EFFECT) == gadget)
@ -41,6 +46,31 @@ public class WinEffectPage extends GadgetPage
slot += 2; slot += 2;
} }
// Adds rank based win effects
Rank maxRank = WinEffectRankBased.getHighestRankForPlayer(getPlayer());
for (WinEffectRankBased.WinEffectType winEffectType : WinEffectRankBased.WinEffectType.values())
{
Rank originalRank = maxRank;
if (maxRank.equals(Rank.ALL))
maxRank = Rank.ULTRA;
WinEffectRankBased winEffectRankBased = getPlugin().getGadgetManager().getRankBasedWinEffect(winEffectType, maxRank);
if (winEffectRankBased != null)
{
addGadget(winEffectRankBased, slot, (originalRank.equals(Rank.ALL)));
if (winEffectRankBased.isActive(getPlayer()))
addGlow(slot);
slot++;
if (slot == 17)
slot += 2;
}
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
{ {
public void onClick(Player player, ClickType clickType) public void onClick(Player player, ClickType clickType)

View File

@ -29,6 +29,7 @@ import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
@ -208,6 +209,12 @@ import mineplex.core.gadget.gadgets.wineffect.WinEffectPodium;
import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian; import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian;
import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails; import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails;
import mineplex.core.gadget.gadgets.wineffect.WinEffectWinterWarfare; import mineplex.core.gadget.gadgets.wineffect.WinEffectWinterWarfare;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankEternal;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankHero;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankLegend;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankTitan;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankUltra;
import mineplex.core.gadget.persistence.UserGadgetPersistence; import mineplex.core.gadget.persistence.UserGadgetPersistence;
import mineplex.core.gadget.set.SetCandyCane; import mineplex.core.gadget.set.SetCandyCane;
import mineplex.core.gadget.set.SetCupidsLove; import mineplex.core.gadget.set.SetCupidsLove;
@ -276,6 +283,7 @@ public class GadgetManager extends MiniPlugin
private SoulManager _soulManager; private SoulManager _soulManager;
private Map<GadgetType, List<Gadget>> _gadgets; private Map<GadgetType, List<Gadget>> _gadgets;
private List<WinEffectRankBased> _rankBasedWinEffects;
private final Map<Player, Long> _lastMove = new HashMap<>(); private final Map<Player, Long> _lastMove = new HashMap<>();
private final Map<Player, Map<GadgetType, Gadget>> _playerActiveGadgetMap = new HashMap<>(); private final Map<Player, Map<GadgetType, Gadget>> _playerActiveGadgetMap = new HashMap<>();
@ -357,6 +365,7 @@ public class GadgetManager extends MiniPlugin
private void createGadgets() private void createGadgets()
{ {
_gadgets = new HashMap<>(); _gadgets = new HashMap<>();
_rankBasedWinEffects = new ArrayList<>();
// Items // Items
addGadget(new ItemEtherealPearl(this)); addGadget(new ItemEtherealPearl(this));
@ -538,6 +547,13 @@ public class GadgetManager extends MiniPlugin
addGadget(new WinEffectWinterWarfare(this)); addGadget(new WinEffectWinterWarfare(this));
addGadget(new WinEffectLoveIsABattlefield(this)); addGadget(new WinEffectLoveIsABattlefield(this));
// Rank based win effects
addGadget(new WinEffectRankUltra(this));
addGadget(new WinEffectRankHero(this));
addGadget(new WinEffectRankLegend(this));
addGadget(new WinEffectRankTitan(this));
addGadget(new WinEffectRankEternal(this));
// Music // Music
addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, -2, 2256, 178000)); addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, -2, 2256, 178000));
addGadget(new MusicGadget(this, "Cat Disc", new String[] {""}, -2, 2257, 185000)); addGadget(new MusicGadget(this, "Cat Disc", new String[] {""}, -2, 2257, 185000));
@ -669,6 +685,9 @@ public class GadgetManager extends MiniPlugin
_gadgets.put(gadget.getGadgetType(), new ArrayList<>()); _gadgets.put(gadget.getGadgetType(), new ArrayList<>());
_gadgets.get(gadget.getGadgetType()).add(gadget); _gadgets.get(gadget.getGadgetType()).add(gadget);
if (gadget instanceof WinEffectRankBased)
_rankBasedWinEffects.add((WinEffectRankBased) gadget);
} }
@EventHandler @EventHandler
@ -816,6 +835,18 @@ public class GadgetManager extends MiniPlugin
return null; return null;
} }
public WinEffectRankBased getRankBasedWinEffect(WinEffectRankBased.WinEffectType winEffectType, Rank rank)
{
for (WinEffectRankBased winEffectRankBased : _rankBasedWinEffects)
{
if (winEffectRankBased.getWinEffectType().equals(winEffectType) && winEffectRankBased.getRank().equals(rank))
{
return winEffectRankBased;
}
}
return null;
}
// Disallows two armor gadgets in same slot. // Disallows two armor gadgets in same slot.
public void removeOutfit(Player player, ArmorSlot slot) public void removeOutfit(Player player, ArmorSlot slot)
{ {

View File

@ -0,0 +1,113 @@
package mineplex.core.gadget.gadgets.wineffect.rankrooms;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.Managers;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.WinEffectGadget;
/**
* Helper class to create win effects based on ranks
*/
public abstract class WinEffectRankBased extends WinEffectGadget
{
private Rank _rank;
private WinEffectType _winEffectType;
/**
* @param manager The gadget manager
* @param rank The rank needed for the win room
* @param winEffectType The win effect type, used to display in menus
* @param alternativeSalepackageNames
*/
public WinEffectRankBased(GadgetManager manager, Rank rank, WinEffectType winEffectType, String... alternativeSalepackageNames)
{
super(manager, winEffectType.getName() + " " + rank.getRawTag(), winEffectType.getLore(),
(rank.equals(Rank.ETERNAL) ? -15 : (rank.equals(Rank.TITAN) ? -13 : (rank.equals(Rank.LEGEND) ? -12 : (rank.equals(Rank.HERO) ? -11 : -10)))),
winEffectType.getMaterial(), winEffectType.getData(), true, alternativeSalepackageNames);
_rank = rank;
_winEffectType = winEffectType;
_schematicName = winEffectType.getSchematic().replace("%r%", rank.getRawTag());
}
public Rank getRank()
{
return _rank;
}
public WinEffectType getWinEffectType()
{
return _winEffectType;
}
/**
* Gets the highest possible rank for the player
* @param player The player
* @return The highest rank for that player or null if GadgetManager isn't loaded
*/
public static Rank getHighestRankForPlayer(Player player)
{
GadgetManager gadgetManager = Managers.get(GadgetManager.class);
if (gadgetManager != null)
{
Rank rank = gadgetManager.getClientManager().Get(player).GetRank();
if (rank.has(Rank.ETERNAL))
return Rank.ETERNAL;
else
return rank;
}
return null;
}
public enum WinEffectType
{
RANK_WIN_EFFECT("Rank Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), Material.GLASS, (byte) 0, "WinRank%r%");
private String _name;
private String[] _lore;
private Material _material;
private byte _data;
private String _schematic;
WinEffectType(String name, String[] lore, Material material, byte data, String schematic)
{
_name = name;
_lore = lore;
_material = material;
_data = data;
_schematic = schematic;
}
public String getName()
{
return _name;
}
public String[] getLore()
{
return _lore;
}
public Material getMaterial()
{
return _material;
}
public byte getData()
{
return _data;
}
public String getSchematic()
{
return _schematic;
}
}
}

View File

@ -0,0 +1,29 @@
package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects;
import org.bukkit.Bukkit;
import mineplex.core.common.Rank;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased;
public class WinEffectRankEternal extends WinEffectRankBased
{
public WinEffectRankEternal(GadgetManager manager)
{
super(manager, Rank.ETERNAL, WinEffectType.RANK_WIN_EFFECT);
}
@Override
public void play()
{
Bukkit.broadcastMessage("Playing effect win effect eternal: " + getName());
}
@Override
public void finish()
{
Bukkit.broadcastMessage("Playing effect win effect eternal: " + getName());
}
}

View File

@ -0,0 +1,29 @@
package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects;
import org.bukkit.Bukkit;
import mineplex.core.common.Rank;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased;
public class WinEffectRankHero extends WinEffectRankBased
{
public WinEffectRankHero(GadgetManager manager)
{
super(manager, Rank.HERO, WinEffectType.RANK_WIN_EFFECT);
}
@Override
public void play()
{
Bukkit.broadcastMessage("Playing effect win effect hero: " + getName());
}
@Override
public void finish()
{
Bukkit.broadcastMessage("Playing effect win effect hero: " + getName());
}
}

View File

@ -0,0 +1,29 @@
package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects;
import org.bukkit.Bukkit;
import mineplex.core.common.Rank;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased;
public class WinEffectRankLegend extends WinEffectRankBased
{
public WinEffectRankLegend(GadgetManager manager)
{
super(manager, Rank.LEGEND, WinEffectType.RANK_WIN_EFFECT);
}
@Override
public void play()
{
Bukkit.broadcastMessage("Playing effect win effect legend: " + getName());
}
@Override
public void finish()
{
Bukkit.broadcastMessage("Playing effect win effect legend: " + getName());
}
}

View File

@ -0,0 +1,29 @@
package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects;
import org.bukkit.Bukkit;
import mineplex.core.common.Rank;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased;
public class WinEffectRankTitan extends WinEffectRankBased
{
public WinEffectRankTitan(GadgetManager manager)
{
super(manager, Rank.TITAN, WinEffectType.RANK_WIN_EFFECT);
}
@Override
public void play()
{
Bukkit.broadcastMessage("Playing effect win effect titan: " + getName());
}
@Override
public void finish()
{
Bukkit.broadcastMessage("Playing effect win effect titan: " + getName());
}
}

View File

@ -0,0 +1,29 @@
package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects;
import org.bukkit.Bukkit;
import mineplex.core.common.Rank;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased;
public class WinEffectRankUltra extends WinEffectRankBased
{
public WinEffectRankUltra(GadgetManager manager)
{
super(manager, Rank.ULTRA, WinEffectType.RANK_WIN_EFFECT);
}
@Override
public void play()
{
Bukkit.broadcastMessage("Playing effect win effect ultra: " + getName());
}
@Override
public void finish()
{
Bukkit.broadcastMessage("Playing effect win effect ultra: " + getName());
}
}