Update UI to reflect allowing upgrades to be shown, per kit.

This commit is contained in:
TadahTech 2016-07-24 16:05:19 -05:00
parent 4728a50ca9
commit a23c2c4e1c
5 changed files with 80 additions and 19 deletions

View File

@ -1,18 +1,17 @@
package mineplex.core.progression;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.progression.data.KitAbilityDetail;
import mineplex.core.progression.math.Calculations;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* The API class all kits with the new system must use
@ -57,6 +56,16 @@ public interface ProgressiveKit
*/
Map<Integer, List<KitAbilityDetail>> getAbilityDetails();
/**
* Determines whether or not the kit UI is displayed with "Coming Soon" or actual upgrade details.
*
* @return <code>true</code> if the menu should populate from {@code getAbilityDetails}
*/
default boolean showUpgrades()
{
return false;
}
/**
* Retrieve the current level of this kit
*

View File

@ -1,6 +1,7 @@
package mineplex.core.progression.gui.buttons;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.data.KitAbilityDetail;
import mineplex.core.progression.gui.buttons.misc.IconButton;
@ -23,7 +24,7 @@ public class KitAbilityButton extends IconButton
ItemBuilder builder = new ItemBuilder(detail.getIcon());
builder.setTitle(detail.getDisplayName());
builder.setTitle(C.cYellow + detail.getDisplayName());
List<String> lore = Lists.newArrayList(" ");

View File

@ -50,13 +50,18 @@ public class KitUpgradeMenuButton extends KitButton
//This ONLY flashes if their next upgrade level isn't their same one.
_flash = Calculations.isUpgradeLevelEligible(level) && (nextUpgradeLevel > upgradeLevel);
ChatColor color = Calculations.getColor(level, nextUpgradeLevelPlayer);
if(kit.showUpgrades())
{
ItemBuilder builder = lore(new ItemBuilder(Material.ENCHANTMENT_TABLE), upgradeLevel, color, diff);
_item = builder.build();
}
if (_flash)
{
flash();
}
ChatColor color = Calculations.getColor(level, nextUpgradeLevelPlayer);
}
@Override
@ -73,7 +78,7 @@ public class KitUpgradeMenuButton extends KitButton
private void flash()
{
this._task = new BukkitRunnable()
_task = new BukkitRunnable()
{
private ItemStack itemClone = ITEM_STACK.clone();
@ -109,11 +114,11 @@ public class KitUpgradeMenuButton extends KitButton
@Override
public void onClick(Player player)
{
this._flash = false;
_flash = false;
if (_task != null)
{
this._task.cancel();
_task.cancel();
}
KitMenu menu = new KitInformationTrackerMenu(getKit());

View File

@ -1,11 +1,19 @@
package mineplex.core.progression.gui.guis;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.data.KitAbilityDetail;
import mineplex.core.progression.gui.Button;
import mineplex.core.progression.gui.buttons.*;
import mineplex.core.progression.gui.buttons.KitAbilityButton;
import mineplex.core.progression.gui.buttons.KitIconButton;
import mineplex.core.progression.gui.buttons.KitPermanentDefaultButton;
import mineplex.core.progression.gui.buttons.KitSelectButton;
import mineplex.core.progression.gui.buttons.KitUpgradeMenuButton;
import mineplex.core.progression.gui.buttons.KitXPButton;
import mineplex.core.progression.gui.buttons.misc.IconButton;
import org.bukkit.entity.Player;
import java.util.List;
/**
* This is the main menu a player sees when we selects an NPC Kit
* Displays the most important information about this kit
@ -39,7 +47,7 @@ public class KitDisplayMenu extends KitMenu
setUpIcon(buttons, player);
setUpDetails(buttons);
setUpDetails(buttons, player);
setUpNextMenuButtons(buttons, player);
@ -74,8 +82,19 @@ public class KitDisplayMenu extends KitMenu
*
* @param buttons The array of buttons we're modifying
*/
private void setUpDetails(Button[] buttons)
private void setUpDetails(Button[] buttons, Player player)
{
if(getKit().showUpgrades())
{
List<KitAbilityDetail> details = getKit().getAbilityDetails().get(getKit().getUpgradeLevel(player.getUniqueId()));
int index = 0;
for(int i : UPGRADE_SLOTS)
{
buttons[i] = new KitAbilityButton(details.get(index++));
}
return;
}
for (int i : UPGRADE_SLOTS)
{
buttons[i] = new IconButton(COMING_SOON);

View File

@ -4,7 +4,9 @@ import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.data.KitAbilityDetail;
import mineplex.core.progression.gui.Button;
import mineplex.core.progression.gui.buttons.KitUpgradeButton;
import mineplex.core.progression.gui.buttons.misc.BackButton;
import mineplex.core.progression.gui.buttons.misc.IconButton;
import mineplex.core.progression.math.Calculations;
@ -15,6 +17,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
@ -144,6 +147,30 @@ public class KitInformationTrackerMenu extends KitMenu
*/
private void setUpUpgrade(Button[] buttons, Player player)
{
if(getKit().showUpgrades())
{
int upgradeLevel = getKit().getUpgradeLevel(player.getUniqueId());
Map<Integer, List<KitAbilityDetail>> details = getKit().getAbilityDetails();
List<KitAbilityDetail> list = details.get(upgradeLevel);
if(list == null)
{
throw new IllegalArgumentException("No upgrades for player upgrade level " + upgradeLevel);
}
int index = 0;
for(int i : UPGRADE_SLOTS)
{
KitAbilityDetail detail = list.get(index++);
ItemBuilder itemStack = new ItemBuilder(detail.getIcon()).setTitle(C.cYellow + detail.getDisplayName()).setLore(getKit().getDescription());
if(getKit().canPurchaseUpgrade(player.getUniqueId(), upgradeLevel) && !getKit().ownsUpgrade(player.getUniqueId(), upgradeLevel))
{
itemStack.setGlow(true);
}
KitUpgradeButton button = new KitUpgradeButton(getKit(), itemStack.build(), upgradeLevel, detail.getDisplayName());
buttons[i] = button;
}
return;
}
for (int i : UPGRADE_SLOTS)
{
buttons[i] = new IconButton(COMING_SOON);