Final touches to the gear gui, making it now completely finished. hooray!
This commit is contained in:
parent
327c129f46
commit
cc2aae9726
@ -1,11 +1,12 @@
|
||||
package mineplex.game.clans.items.gear;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Pair;
|
||||
@ -16,9 +17,33 @@ import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.items.CustomItem;
|
||||
import mineplex.game.clans.items.ItemType;
|
||||
import mineplex.game.clans.items.attributes.AttributeType;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.attributes.armor.ConqueringArmorAttribute;
|
||||
import mineplex.game.clans.items.attributes.armor.LavaAttribute;
|
||||
import mineplex.game.clans.items.attributes.armor.PaddedAttribute;
|
||||
import mineplex.game.clans.items.attributes.armor.ReinforcedAttribute;
|
||||
import mineplex.game.clans.items.attributes.armor.SlantedAttribute;
|
||||
import mineplex.game.clans.items.attributes.bow.HeavyArrowsAttribute;
|
||||
import mineplex.game.clans.items.attributes.bow.HuntingAttribute;
|
||||
import mineplex.game.clans.items.attributes.bow.InverseAttribute;
|
||||
import mineplex.game.clans.items.attributes.bow.LeechingAttribute;
|
||||
import mineplex.game.clans.items.attributes.bow.RecursiveAttribute;
|
||||
import mineplex.game.clans.items.attributes.bow.ScorchingAttribute;
|
||||
import mineplex.game.clans.items.attributes.bow.SlayingAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.ConqueringAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.FlamingAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.FrostedAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.HasteAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.HeavyAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.JaggedAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.SharpAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.VampiricAttribute;
|
||||
import mineplex.game.clans.items.legendaries.AlligatorsTooth;
|
||||
import mineplex.game.clans.items.legendaries.GiantsBroadsword;
|
||||
import mineplex.game.clans.items.legendaries.HyperBlade;
|
||||
import mineplex.game.clans.items.legendaries.LegendaryItem;
|
||||
import mineplex.game.clans.items.legendaries.MagneticBlade;
|
||||
import mineplex.game.clans.items.legendaries.WindBlade;
|
||||
import net.minecraft.util.org.apache.commons.lang3.text.WordUtils;
|
||||
import net.minecraft.util.org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
@ -32,7 +57,26 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
private final IButton _nextButton;
|
||||
private final IButton _backButton;
|
||||
|
||||
private final List<Class<? extends ItemAttribute>> _attributes;
|
||||
private Class<? extends ItemAttribute> _superPrefix;
|
||||
private Class<? extends ItemAttribute> _prefix;
|
||||
private Class<? extends ItemAttribute> _suffix;
|
||||
|
||||
private Set<Class<? extends ItemAttribute>> _armourSuperPrefixes;
|
||||
private Set<Class<? extends ItemAttribute>> _armourPrefixes;
|
||||
private Set<Class<? extends ItemAttribute>> _armourSuffixes;
|
||||
|
||||
private Set<Class<? extends ItemAttribute>> _weaponSuperPrefixes;
|
||||
private Set<Class<? extends ItemAttribute>> _weaponPrefixes;
|
||||
private Set<Class<? extends ItemAttribute>> _weaponSuffixes;
|
||||
|
||||
private Set<Class<? extends ItemAttribute>> _bowSuperPrefixes;
|
||||
private Set<Class<? extends ItemAttribute>> _bowPrefixes;
|
||||
private Set<Class<? extends ItemAttribute>> _bowSuffixes;
|
||||
|
||||
private Set<Class<? extends LegendaryItem>> _legendaryItems;
|
||||
|
||||
private Set<Material> _weaponTypes;
|
||||
private Set<Material> _armourTypes;
|
||||
|
||||
public GearPage(final GearManager gearManager, final GearShop shop, final CoreClientManager clientManager, final DonationManager donationManager, final String name, final Player player)
|
||||
{
|
||||
@ -54,7 +98,145 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
}
|
||||
};
|
||||
|
||||
_attributes = new ArrayList<>();
|
||||
_armourSuperPrefixes = new HashSet<Class<? extends ItemAttribute>>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(LavaAttribute.class);
|
||||
}
|
||||
};
|
||||
|
||||
_armourPrefixes = new HashSet<Class<? extends ItemAttribute>>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(PaddedAttribute.class);
|
||||
add(ReinforcedAttribute.class);
|
||||
add(SlantedAttribute.class);
|
||||
}
|
||||
};
|
||||
|
||||
_armourSuffixes = new HashSet<Class<? extends ItemAttribute>>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(ConqueringArmorAttribute.class);
|
||||
}
|
||||
};
|
||||
|
||||
_weaponSuperPrefixes = new HashSet<Class<? extends ItemAttribute>>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(FlamingAttribute.class);
|
||||
add(FrostedAttribute.class);
|
||||
}
|
||||
};
|
||||
|
||||
_weaponPrefixes = new HashSet<Class<? extends ItemAttribute>>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(HeavyAttribute.class);
|
||||
add(JaggedAttribute.class);
|
||||
add(SharpAttribute.class);
|
||||
}
|
||||
};
|
||||
|
||||
_legendaryItems = new HashSet<Class<? extends LegendaryItem>>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(AlligatorsTooth.class);
|
||||
add(WindBlade.class);
|
||||
add(GiantsBroadsword.class);
|
||||
add(HyperBlade.class);
|
||||
add(MagneticBlade.class);
|
||||
}
|
||||
};
|
||||
|
||||
_weaponSuffixes = new HashSet<Class<? extends ItemAttribute>>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(ConqueringAttribute.class);
|
||||
add(HasteAttribute.class);
|
||||
}
|
||||
};
|
||||
|
||||
_bowSuperPrefixes = new HashSet<Class<? extends ItemAttribute>>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(LeechingAttribute.class);
|
||||
add(ScorchingAttribute.class);
|
||||
}
|
||||
};
|
||||
|
||||
_bowPrefixes = new HashSet<Class<? extends ItemAttribute>>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(HeavyArrowsAttribute.class);
|
||||
add(HuntingAttribute.class);
|
||||
add(InverseAttribute.class);
|
||||
add(RecursiveAttribute.class);
|
||||
}
|
||||
};
|
||||
|
||||
_bowSuffixes = new HashSet<Class<? extends ItemAttribute>>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(SlayingAttribute.class);
|
||||
}
|
||||
};
|
||||
|
||||
_armourTypes = new HashSet<Material>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(Material.DIAMOND_HELMET);
|
||||
add(Material.DIAMOND_CHESTPLATE);
|
||||
add(Material.DIAMOND_LEGGINGS);
|
||||
add(Material.DIAMOND_BOOTS);
|
||||
add(Material.IRON_HELMET);
|
||||
add(Material.IRON_CHESTPLATE);
|
||||
add(Material.IRON_LEGGINGS);
|
||||
add(Material.IRON_BOOTS);
|
||||
add(Material.GOLD_HELMET);
|
||||
add(Material.GOLD_CHESTPLATE);
|
||||
add(Material.GOLD_LEGGINGS);
|
||||
add(Material.GOLD_BOOTS);
|
||||
}
|
||||
};
|
||||
|
||||
_weaponTypes = new HashSet<Material>()
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add(Material.DIAMOND_SWORD);
|
||||
add(Material.IRON_SWORD);
|
||||
add(Material.GOLD_SWORD);
|
||||
add(Material.STONE_SWORD);
|
||||
add(Material.DIAMOND_AXE);
|
||||
add(Material.IRON_AXE);
|
||||
add(Material.GOLD_AXE);
|
||||
add(Material.STONE_AXE);
|
||||
}
|
||||
};
|
||||
|
||||
buildPage();
|
||||
}
|
||||
@ -93,13 +275,19 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
}
|
||||
else if (_stage == 2)
|
||||
{
|
||||
Pair<String, Material> stage3 = doStageThree();
|
||||
Triple<Boolean, String, Material> stage3 = doStageThree();
|
||||
|
||||
stageTitle = stage3.getLeft();
|
||||
if (stage3.getLeft())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
stageTitle = stage3.getMiddle();
|
||||
if (stage3.getRight() != null)
|
||||
{
|
||||
stageMaterial = stage3.getRight();
|
||||
}
|
||||
|
||||
}
|
||||
else if (_stage == 3)
|
||||
{
|
||||
@ -192,7 +380,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
if (_itemType == null)
|
||||
{
|
||||
performBack();
|
||||
_return = true;
|
||||
return Triple.of(true, stageTitle, stageMaterial);
|
||||
}
|
||||
|
||||
if (_itemType.equals(ItemType.LEGENDARY))
|
||||
@ -200,12 +388,14 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
stageTitle = "2. Select Legendary Item";
|
||||
stageMaterial = _item == null ? stageMaterial : _item.toItemStack().getType();
|
||||
|
||||
int[] indices = getIndicesFor(_legendaryItems.size());
|
||||
|
||||
int index = 0;
|
||||
for (Class<? extends LegendaryItem> legendary : getPlugin()._legendaryWeights.elements())
|
||||
for (Class<? extends LegendaryItem> legendary : _legendaryItems)
|
||||
{
|
||||
final LegendaryItem item = GearManager.instantiate(legendary);
|
||||
|
||||
addButton(9 + (index++ * 2), item.toItemStack().getType(), 0, C.cGold + item.getDisplayName(), new IButton()
|
||||
addButton(indices[index], item.toItemStack().getType(), 0, C.cGold + item.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
@ -213,6 +403,8 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { C.cWhite + item.getDescription(), "", item.getDisplayName().equals(_item == null ? null : _item.getDisplayName()) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -223,10 +415,12 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
stageTitle = "Select Weapon Type";
|
||||
|
||||
int[] indices = getIndicesFor(_weaponTypes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Material type : getPlugin()._weaponTypes.elements())
|
||||
for (final Material type : _weaponTypes)
|
||||
{
|
||||
addButton(9 + (index++ * 2), type, 0, C.cGold + WordUtils.capitalizeFully(type.toString()), new IButton()
|
||||
addButton(indices[index], type, 0, C.cGold + WordUtils.capitalizeFully(type.toString()), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
@ -234,6 +428,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { _item == null ? C.cRed + "Not Selected" : (_item.toItemStack().getType().equals(type) ? C.cGreen + "Selected" : C.cRed + "Not Selected") });
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -241,10 +436,12 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
stageTitle = "Select Armour Type";
|
||||
|
||||
int[] indices = getIndicesFor(_armourTypes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Material type : getPlugin()._armourTypes.elements())
|
||||
for (final Material type : _armourTypes)
|
||||
{
|
||||
addButton(9 + (index++ * 2), type, 0, C.cGold + WordUtils.capitalizeFully(type.toString()), new IButton()
|
||||
addButton(indices[index], type, 0, C.cGold + WordUtils.capitalizeFully(type.toString()), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
@ -252,11 +449,20 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { _item == null ? C.cRed + "Not Selected" : (_item.toItemStack().getType().equals(type) ? C.cGreen + "Selected" : C.cRed + "Not Selected") });
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
/**
|
||||
* The only time this code block should be reached is when
|
||||
* _itemType is BOW, or if there are ever new item types
|
||||
* added which don't have a case, since LEGENDARY is checked
|
||||
* seperately, and ARMOUR, and WEAPON have their own cases.
|
||||
*/
|
||||
|
||||
_item = new CustomItem(Material.BOW);
|
||||
_stage = 2;
|
||||
buildPage();
|
||||
_return = true;
|
||||
@ -266,9 +472,15 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
return Triple.of(_return, stageTitle, stageMaterial);
|
||||
}
|
||||
|
||||
private Pair<String, Material> doStageThree()
|
||||
private Triple<Boolean, String, Material> doStageThree()
|
||||
{
|
||||
String stageTitle;
|
||||
|
||||
if (_item == null)
|
||||
{
|
||||
return Triple.of(true, null, null);
|
||||
}
|
||||
|
||||
Material stageMaterial = _item.toItemStack().getType();
|
||||
|
||||
if (_item != null && _itemType.equals(ItemType.LEGENDARY))
|
||||
@ -284,49 +496,46 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
stageTitle = "Select Super Prefix";
|
||||
|
||||
int[] indices = getIndicesFor(_weaponSuperPrefixes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends ItemAttribute> attribute : getPlugin()._weaponAttributes.elements())
|
||||
for (final Class<? extends ItemAttribute> attribute : _weaponSuperPrefixes)
|
||||
{
|
||||
final ItemAttribute attrib = GearManager.instantiate(attribute);
|
||||
|
||||
if (!attrib.getType().equals(AttributeType.SUPER_PREFIX))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addButton(9 + (index++ * 2), Material.DIAMOND_SWORD, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
addButton(indices[index], Material.DIAMOND_SWORD, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_attributes.add(attribute);
|
||||
_superPrefix = (attribute.equals(_superPrefix) ? null : attribute);
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", _attributes.contains(attribute) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", attribute.equals(_superPrefix) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ARMOUR:
|
||||
{
|
||||
stageTitle = "Select Super Prefix";
|
||||
int[] indices = getIndicesFor(_armourSuperPrefixes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends ItemAttribute> attribute : getPlugin()._armourAttributes.elements())
|
||||
for (final Class<? extends ItemAttribute> attribute : _armourSuperPrefixes)
|
||||
{
|
||||
final ItemAttribute attrib = GearManager.instantiate(attribute);
|
||||
|
||||
if (!attrib.getType().equals(AttributeType.SUPER_PREFIX))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addButton(9 + (index++ * 2), Material.DIAMOND_CHESTPLATE, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
addButton(indices[index], Material.DIAMOND_CHESTPLATE, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_attributes.add(attribute);
|
||||
_superPrefix = (attribute.equals(_superPrefix) ? null : attribute);
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", _attributes.contains(attribute) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", attribute.equals(_superPrefix) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -334,24 +543,23 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
stageTitle = "Select Super Prefix";
|
||||
|
||||
int[] indices = getIndicesFor(_bowSuperPrefixes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends ItemAttribute> attribute : getPlugin()._bowAttributes.elements())
|
||||
for (final Class<? extends ItemAttribute> attribute : _bowSuperPrefixes)
|
||||
{
|
||||
final ItemAttribute attrib = GearManager.instantiate(attribute);
|
||||
|
||||
if (!attrib.getType().equals(AttributeType.SUPER_PREFIX))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addButton(9 + (index++ * 2), Material.BOW, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
addButton(indices[index], Material.BOW, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_attributes.add(attribute);
|
||||
_superPrefix = (attribute.equals(_superPrefix) ? null : attribute);
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", _attributes.contains(attribute) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", attribute.equals(_superPrefix) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -363,7 +571,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
}
|
||||
}
|
||||
|
||||
return Pair.create(stageTitle, stageMaterial);
|
||||
return Triple.of(false, stageTitle, stageMaterial);
|
||||
}
|
||||
|
||||
private Pair<String, Material> doStageFour()
|
||||
@ -384,24 +592,23 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
stageTitle = "Select Prefix";
|
||||
|
||||
int[] indices = getIndicesFor(_weaponPrefixes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends ItemAttribute> attribute : getPlugin()._weaponAttributes.elements())
|
||||
for (final Class<? extends ItemAttribute> attribute : _weaponPrefixes)
|
||||
{
|
||||
final ItemAttribute attrib = GearManager.instantiate(attribute);
|
||||
|
||||
if (!attrib.getType().equals(AttributeType.PREFIX))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addButton(9 + (index++ * 2), Material.DIAMOND_SWORD, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
addButton(indices[index], Material.DIAMOND_SWORD, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_attributes.add(attribute);
|
||||
_prefix = (attribute.equals(_prefix) ? null : attribute);
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", _attributes.contains(attribute) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", attribute.equals(_prefix) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -409,24 +616,23 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
stageTitle = "Select Prefix";
|
||||
|
||||
int[] indices = getIndicesFor(_armourPrefixes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends ItemAttribute> attribute : getPlugin()._armourAttributes.elements())
|
||||
for (final Class<? extends ItemAttribute> attribute : _armourPrefixes)
|
||||
{
|
||||
final ItemAttribute attrib = GearManager.instantiate(attribute);
|
||||
|
||||
if (!attrib.getType().equals(AttributeType.PREFIX))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addButton(9 + (index++ * 2), Material.DIAMOND_CHESTPLATE, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
addButton(indices[index], Material.DIAMOND_CHESTPLATE, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_attributes.add(attribute);
|
||||
_prefix = (attribute.equals(_prefix) ? null : attribute);
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", _attributes.contains(attribute) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", attribute.equals(_prefix) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -434,24 +640,23 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
stageTitle = "Select Prefix";
|
||||
|
||||
int[] indices = getIndicesFor(_bowPrefixes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends ItemAttribute> attribute : getPlugin()._bowAttributes.elements())
|
||||
for (final Class<? extends ItemAttribute> attribute : _bowPrefixes)
|
||||
{
|
||||
final ItemAttribute attrib = GearManager.instantiate(attribute);
|
||||
|
||||
if (!attrib.getType().equals(AttributeType.PREFIX))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addButton(9 + (index++ * 2), Material.BOW, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
addButton(indices[index], Material.BOW, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_attributes.add(attribute);
|
||||
_prefix = (attribute.equals(_prefix) ? null : attribute);
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", _attributes.contains(attribute) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", attribute.equals(_prefix) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -484,24 +689,23 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
stageTitle = "Select Suffix";
|
||||
|
||||
int[] indices = getIndicesFor(_weaponSuffixes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends ItemAttribute> attribute : getPlugin()._weaponAttributes.elements())
|
||||
for (final Class<? extends ItemAttribute> attribute : _weaponSuffixes)
|
||||
{
|
||||
final ItemAttribute attrib = GearManager.instantiate(attribute);
|
||||
|
||||
if (!attrib.getType().equals(AttributeType.SUFFIX))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addButton(9 + (index++ * 2), Material.DIAMOND_SWORD, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
addButton(indices[index], Material.DIAMOND_SWORD, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_attributes.add(attribute);
|
||||
_suffix = (attribute.equals(_suffix) ? null : attribute);
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", _attributes.contains(attribute) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", attribute.equals(_suffix) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -509,24 +713,22 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
stageTitle = "Select Suffix";
|
||||
|
||||
int[] indices = getIndicesFor(_armourSuffixes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends ItemAttribute> attribute : getPlugin()._armourAttributes.elements())
|
||||
for (final Class<? extends ItemAttribute> attribute : _armourSuffixes)
|
||||
{
|
||||
final ItemAttribute attrib = GearManager.instantiate(attribute);
|
||||
|
||||
if (!attrib.getType().equals(AttributeType.SUFFIX))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addButton(9 + (index++ * 2), Material.DIAMOND_CHESTPLATE, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
addButton(indices[index], Material.DIAMOND_CHESTPLATE, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_attributes.add(attribute);
|
||||
_suffix = (attribute.equals(_suffix) ? null : attribute);
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", _attributes.contains(attribute) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", attribute.equals(_suffix) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -534,24 +736,23 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
stageTitle = "Select Suffix";
|
||||
|
||||
int[] indices = getIndicesFor(_bowSuffixes.size());
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends ItemAttribute> attribute : getPlugin()._bowAttributes.elements())
|
||||
for (final Class<? extends ItemAttribute> attribute : _bowSuffixes)
|
||||
{
|
||||
final ItemAttribute attrib = GearManager.instantiate(attribute);
|
||||
|
||||
if (!attrib.getType().equals(AttributeType.SUFFIX))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addButton(9 + (index++ * 2), Material.BOW, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
addButton(indices[index], Material.BOW, 0, C.cGold + attrib.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_attributes.add(attribute);
|
||||
_suffix = (attribute.equals(_suffix) ? null : attribute);
|
||||
buildPage();
|
||||
}
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", _attributes.contains(attribute) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
}, new String[] { C.cWhite + attrib.getDescription(), "", attribute.equals(_suffix) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -566,11 +767,36 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
return Pair.create(stageTitle, stageMaterial);
|
||||
}
|
||||
|
||||
private static int[] getIndicesFor(int size)
|
||||
{
|
||||
int[] indices = new int[size];
|
||||
|
||||
int lines = (int) Math.ceil(size / 5D);
|
||||
|
||||
for (int line = 0; line < lines; line++)
|
||||
{
|
||||
int itemsInLine = line == lines - 1 ? size - (line * 5) : 5;
|
||||
int startingPoint = 9 + (line * 9) + (4 - (itemsInLine - 1));
|
||||
|
||||
for (int i = 0; i < itemsInLine; i++)
|
||||
{
|
||||
indices[line * 5 + i] = startingPoint + (i * 2);
|
||||
}
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
private void addButton(final int index, final Material type, final int data, final String name, final IButton ibutton, final String... description)
|
||||
{
|
||||
addButton(index, new ShopItem(type, (byte) data, name, description, 1, ibutton == null, false), ibutton);
|
||||
}
|
||||
|
||||
private void addButton(final int index, final ItemStack stack, final IButton ibutton, final String... description)
|
||||
{
|
||||
addButton(index, new ShopItem(stack, ibutton == null, false), ibutton);
|
||||
}
|
||||
|
||||
private void performBack()
|
||||
{
|
||||
if (_stage > 0)
|
||||
@ -584,25 +810,32 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
clearPage();
|
||||
|
||||
addButton(9 + 4, _item.toItemStack().getType(), 0, C.cGold + _item.getDisplayName(), new IButton()
|
||||
try
|
||||
{
|
||||
if (_superPrefix != null)
|
||||
{
|
||||
_item.getAttributes().addAttribute(_superPrefix.newInstance());
|
||||
}
|
||||
|
||||
if (_prefix != null)
|
||||
{
|
||||
_item.getAttributes().addAttribute(_prefix.newInstance());
|
||||
}
|
||||
|
||||
if (_suffix != null)
|
||||
{
|
||||
_item.getAttributes().addAttribute(_suffix.newInstance());
|
||||
}
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
addButton(9 + 4, _item.toItemStack(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
for (Class<? extends ItemAttribute> attributeClass : _attributes)
|
||||
{
|
||||
try
|
||||
{
|
||||
_item.getAttributes().addAttribute(attributeClass.newInstance());
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
player.getInventory().addItem(_item.toItemStack());
|
||||
}
|
||||
}, new String[] { C.cWhite + "Click to get item" });
|
||||
@ -610,7 +843,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
|
||||
protected void performNext()
|
||||
{
|
||||
if (_stage < 4)
|
||||
if (_stage <= 4)
|
||||
{
|
||||
_stage++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user