Moved GearManager back to it's original package, and stopped using it in GearPage. Removed commented code from GearCommand, as the gui is now finished and it is not needed anymore.

This commit is contained in:
NewGarbo 2015-10-26 07:57:00 +00:00
parent 7eab57c5dd
commit 63406e9ce1
17 changed files with 117 additions and 125 deletions

View File

@ -27,7 +27,7 @@ import mineplex.core.memory.MemoryFix;
import mineplex.core.message.MessageManager;
import mineplex.core.monitor.LagMeter;
import mineplex.game.clans.clans.observer.ObserverManager;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.game.clans.items.GearManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;

View File

@ -89,7 +89,7 @@ import mineplex.game.clans.fields.Field;
import mineplex.game.clans.gameplay.Gameplay;
import mineplex.game.clans.gameplay.safelog.LoggingManager;
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorials.TutorialManager;
import mineplex.minecraft.game.classcombat.Class.ClassManager;

View File

@ -29,10 +29,10 @@ import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.items.CustomItem;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.attributes.weapon.FlamingAttribute;
import mineplex.game.clans.items.attributes.weapon.FrostedAttribute;
import mineplex.game.clans.items.attributes.weapon.SharpAttribute;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.game.clans.items.legendaries.LegendaryItem;
import mineplex.game.clans.items.legendaries.WindBlade;

View File

@ -3,7 +3,7 @@ package mineplex.game.clans.clans.loot;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.game.clans.items.GearManager;
public class GearLoot implements ILoot
{

View File

@ -5,7 +5,7 @@ import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.generation.WeightSet;
public class LootManager

View File

@ -27,10 +27,10 @@ import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.items.CustomItem;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.attributes.weapon.FlamingAttribute;
import mineplex.game.clans.items.attributes.weapon.FrostedAttribute;
import mineplex.game.clans.items.attributes.weapon.SharpAttribute;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.game.clans.items.legendaries.LegendaryItem;
import mineplex.game.clans.items.legendaries.WindBlade;

View File

@ -8,7 +8,6 @@ import java.util.UUID;
import mineplex.game.clans.items.attributes.AttributeContainer;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.ChatColor;

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.items.gear;
package mineplex.game.clans.items;
import java.util.ArrayList;
import java.util.HashMap;
@ -29,10 +29,6 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.game.clans.items.CustomItem;
import mineplex.game.clans.items.ItemListener;
import mineplex.game.clans.items.ItemType;
import mineplex.game.clans.items.PlayerGear;
import mineplex.game.clans.items.attributes.AttributeContainer;
import mineplex.game.clans.items.attributes.AttributeType;
import mineplex.game.clans.items.attributes.ItemAttribute;
@ -56,6 +52,7 @@ import mineplex.game.clans.items.attributes.weapon.JaggedAttribute;
import mineplex.game.clans.items.attributes.weapon.SharpAttribute;
import mineplex.game.clans.items.commands.GearCommand;
import mineplex.game.clans.items.economy.GoldToken;
import mineplex.game.clans.items.gear.GearShop;
import mineplex.game.clans.items.generation.Weight;
import mineplex.game.clans.items.generation.WeightSet;
import mineplex.game.clans.items.legendaries.AlligatorsTooth;
@ -78,31 +75,31 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutWindowItems;
*/
public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
{
protected static final String ITEM_SERIALIZATION_TAG = "-JSON-";
protected static Gson _gson;
protected static GearManager _instance; // Singleton instance
private static final String ITEM_SERIALIZATION_TAG = "-JSON-";
private static Gson _gson;
private static GearManager _instance; // Singleton instance
protected Map<String, PlayerGear> _playerGears; // Mapping of player names (key) to cached gear set (value).
protected WeightSet<Integer> _attributeWeights; // Weightings for randomly selecting number of attributes (1, 2, 3)
protected WeightSet<ItemType> _typeWeights; // Weightings for randomly selecting item type (legendary/weapon/armour/bow)
protected Set<String> _creativePlayers; // Set of names for all players currently in Creative gamemode
private Map<String, PlayerGear> _playerGears; // Mapping of player names (key) to cached gear set (value).
private WeightSet<Integer> _attributeWeights; // Weightings for randomly selecting number of attributes (1, 2, 3)
private WeightSet<ItemType> _typeWeights; // Weightings for randomly selecting item type (legendary/weapon/armour/bow)
private Set<String> _creativePlayers; // Set of names for all players currently in Creative gamemode
// Legendary generation
protected WeightSet<Class<? extends LegendaryItem>> _legendaryWeights;
private WeightSet<Class<? extends LegendaryItem>> _legendaryWeights;
// Weapon generation
protected WeightSet<Material> _weaponTypes;
private WeightSet<Material> _weaponTypes;
// Armour generation
protected WeightSet<Material> _armourTypes;
private WeightSet<Material> _armourTypes;
// Attribute generation
protected WeightSet<Class<? extends ItemAttribute>> _weaponAttributes;
protected WeightSet<Class<? extends ItemAttribute>> _armourAttributes;
protected WeightSet<Class<? extends ItemAttribute>> _bowAttributes;
private WeightSet<Class<? extends ItemAttribute>> _weaponAttributes;
private WeightSet<Class<? extends ItemAttribute>> _armourAttributes;
private WeightSet<Class<? extends ItemAttribute>> _bowAttributes;
protected GearShop _shop;
private GearShop _shop;
public GearManager(JavaPlugin plugin, PacketHandler packetHandler, CoreClientManager clientManager, DonationManager donationManager)
{
@ -261,7 +258,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
return item;
}
protected CustomItem generateItem(ItemType itemType)
private CustomItem generateItem(ItemType itemType)
{
switch(itemType)
{
@ -280,7 +277,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
}
}
protected void generateAttributes(AttributeContainer container, ItemType type, int count)
private void generateAttributes(AttributeContainer container, ItemType type, int count)
{
for (int i = 0; i < count; i++)
{
@ -366,7 +363,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
* @param type - the class-type of the object to be instantiated. (must have zero-argument constructor)
* @return a newly instantiated instance of {@code type} class-type. Instantied with zero argument constructor.
*/
protected static <T> T instantiate(Class<T> type)
private static <T> T instantiate(Class<T> type)
{
try
{
@ -378,7 +375,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
}
}
protected static String getItemSerialization(ItemStack item)
private static String getItemSerialization(ItemStack item)
{
if (item == null || item.getItemMeta() == null
|| item.getItemMeta().getLore() == null) return null;
@ -437,7 +434,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
* masked on CustomGear items.
* @return true, if the player should have their gear lore masked, false otherwise.
*/
protected boolean maskGearPacket(Player player)
private boolean maskGearPacket(Player player)
{
return player.getGameMode() != GameMode.CREATIVE && !_creativePlayers.contains(player.getName());
}
@ -466,7 +463,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
}
}
protected net.minecraft.server.v1_7_R4.ItemStack maskItem(net.minecraft.server.v1_7_R4.ItemStack item)
private net.minecraft.server.v1_7_R4.ItemStack maskItem(net.minecraft.server.v1_7_R4.ItemStack item)
{
if (item == null) return null; // Cannot mask a null item

View File

@ -2,7 +2,6 @@ package mineplex.game.clans.items;
import mineplex.game.clans.items.attributes.AttributeContainer;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import net.minecraft.server.v1_7_R4.Material;

View File

@ -3,7 +3,6 @@ package mineplex.game.clans.items;
import java.util.HashSet;
import java.util.Set;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.game.clans.items.legendaries.LegendaryItem;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;

View File

@ -1,13 +1,10 @@
package mineplex.game.clans.items.commands;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.game.clans.items.GearManager;
public class GearCommand extends CommandBase<GearManager>
{
@ -15,28 +12,20 @@ public class GearCommand extends CommandBase<GearManager>
public GearCommand(GearManager plugin)
{
// Rank change is temporary, because I need to be able to test it.
super(plugin, Rank.ALL, "gear", "custom-gear");
super(plugin, Rank.ADMIN, "gear", "custom-gear");
_gearManager = plugin;
}
@Override
public void Execute(Player caller, String[] args)
{
// UtilPlayer.message(caller, F.main("Gear", "Spawning a random piece of custom gear!"));
if (args == null || args.length == 0)
{
// Vector direction = caller.getLocation().getDirection().normalize();
// _gearManager.spawnItem(caller.getEyeLocation().add(direction));
_gearManager.openShop(caller);
}
else
{
caller.updateInventory();
// caller.setFoodLevel(10);
// return;
}
}

View File

@ -16,6 +16,7 @@ import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.items.CustomItem;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.ItemType;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.attributes.armor.ConqueringArmorAttribute;
@ -248,71 +249,78 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
String stageTitle = "Fatal Error";
Material stageMaterial = Material.WOOL;
if (_stage == 0)
try
{
Pair<String, Material> stage1 = doStageOne();
stageTitle = stage1.getLeft();
if (stage1.getRight() != null)
if (_stage == 0)
{
stageMaterial = stage1.getRight();
Pair<String, Material> stage1 = doStageOne();
stageTitle = stage1.getLeft();
if (stage1.getRight() != null)
{
stageMaterial = stage1.getRight();
}
}
else if (_stage == 1)
{
Triple<Boolean, String, Material> stage2 = doStageTwo();
if (stage2.getLeft())
{
return;
}
stageTitle = stage2.getMiddle();
if (stage2.getRight() != null)
{
stageMaterial = stage2.getRight();
}
}
else if (_stage == 2)
{
Triple<Boolean, String, Material> stage3 = doStageThree();
if (stage3.getLeft())
{
return;
}
stageTitle = stage3.getMiddle();
if (stage3.getRight() != null)
{
stageMaterial = stage3.getRight();
}
}
else if (_stage == 3)
{
Pair<String, Material> stage4 = doStageFour();
stageTitle = stage4.getLeft();
if (stage4.getRight() != null)
{
stageMaterial = stage4.getRight();
}
}
else if (_stage == 4)
{
Pair<String, Material> stage5 = doStageFive();
stageTitle = stage5.getLeft();
if (stage5.getRight() != null)
{
stageMaterial = stage5.getRight();
}
}
else
{
finish();
stageTitle = "The End";
}
}
else if (_stage == 1)
catch (InstantiationException | IllegalAccessException e)
{
Triple<Boolean, String, Material> stage2 = doStageTwo();
if (stage2.getLeft())
{
return;
}
stageTitle = stage2.getMiddle();
if (stage2.getRight() != null)
{
stageMaterial = stage2.getRight();
}
}
else if (_stage == 2)
{
Triple<Boolean, String, Material> stage3 = doStageThree();
if (stage3.getLeft())
{
return;
}
stageTitle = stage3.getMiddle();
if (stage3.getRight() != null)
{
stageMaterial = stage3.getRight();
}
}
else if (_stage == 3)
{
Pair<String, Material> stage4 = doStageFour();
stageTitle = stage4.getLeft();
if (stage4.getRight() != null)
{
stageMaterial = stage4.getRight();
}
}
else if (_stage == 4)
{
Pair<String, Material> stage5 = doStageFive();
stageTitle = stage5.getLeft();
if (stage5.getRight() != null)
{
stageMaterial = stage5.getRight();
}
}
else
{
finish();
stageTitle = "The End";
e.printStackTrace();
}
addButton(4, stageMaterial, 0, stageTitle, new IButton()
@ -371,7 +379,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
return Pair.create(stageTitle, null);
}
private Triple<Boolean, String, Material> doStageTwo()
private Triple<Boolean, String, Material> doStageTwo() throws InstantiationException, IllegalAccessException
{
String stageTitle = "Fatal Error";
Material stageMaterial = null;
@ -393,7 +401,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
int index = 0;
for (Class<? extends LegendaryItem> legendary : _legendaryItems)
{
final LegendaryItem item = GearManager.instantiate(legendary);
final LegendaryItem item = legendary.newInstance();
addButton(indices[index], item.toItemStack().getType(), 0, C.cGold + item.getDisplayName(), new IButton()
{
@ -472,7 +480,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
return Triple.of(_return, stageTitle, stageMaterial);
}
private Triple<Boolean, String, Material> doStageThree()
private Triple<Boolean, String, Material> doStageThree() throws InstantiationException, IllegalAccessException
{
String stageTitle;
@ -501,7 +509,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
int index = 0;
for (final Class<? extends ItemAttribute> attribute : _weaponSuperPrefixes)
{
final ItemAttribute attrib = GearManager.instantiate(attribute);
final ItemAttribute attrib = attribute.newInstance();
addButton(indices[index], Material.DIAMOND_SWORD, 0, C.cGold + attrib.getDisplayName(), new IButton()
{
@ -525,7 +533,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
int index = 0;
for (final Class<? extends ItemAttribute> attribute : _armourSuperPrefixes)
{
final ItemAttribute attrib = GearManager.instantiate(attribute);
final ItemAttribute attrib = attribute.newInstance();
addButton(indices[index], Material.DIAMOND_CHESTPLATE, 0, C.cGold + attrib.getDisplayName(), new IButton()
{
@ -550,7 +558,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
int index = 0;
for (final Class<? extends ItemAttribute> attribute : _bowSuperPrefixes)
{
final ItemAttribute attrib = GearManager.instantiate(attribute);
final ItemAttribute attrib = attribute.newInstance();
addButton(indices[index], Material.BOW, 0, C.cGold + attrib.getDisplayName(), new IButton()
{
@ -577,7 +585,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
return Triple.of(false, stageTitle, stageMaterial);
}
private Pair<String, Material> doStageFour()
private Pair<String, Material> doStageFour() throws InstantiationException, IllegalAccessException
{
String stageTitle;
Material stageMaterial = _item.toItemStack().getType();
@ -600,7 +608,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
int index = 0;
for (final Class<? extends ItemAttribute> attribute : _weaponPrefixes)
{
final ItemAttribute attrib = GearManager.instantiate(attribute);
final ItemAttribute attrib = attribute.newInstance();
addButton(indices[index], Material.DIAMOND_SWORD, 0, C.cGold + attrib.getDisplayName(), new IButton()
{
@ -625,7 +633,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
int index = 0;
for (final Class<? extends ItemAttribute> attribute : _armourPrefixes)
{
final ItemAttribute attrib = GearManager.instantiate(attribute);
final ItemAttribute attrib = attribute.newInstance();
addButton(indices[index], Material.DIAMOND_CHESTPLATE, 0, C.cGold + attrib.getDisplayName(), new IButton()
{
@ -650,7 +658,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
int index = 0;
for (final Class<? extends ItemAttribute> attribute : _bowPrefixes)
{
final ItemAttribute attrib = GearManager.instantiate(attribute);
final ItemAttribute attrib = attribute.newInstance();
addButton(indices[index], Material.BOW, 0, C.cGold + attrib.getDisplayName(), new IButton()
{
@ -677,7 +685,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
return Pair.create(stageTitle, stageMaterial);
}
private Pair<String, Material> doStageFive()
private Pair<String, Material> doStageFive() throws InstantiationException, IllegalAccessException
{
String stageTitle;
Material stageMaterial = _item.toItemStack().getType();
@ -700,7 +708,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
int index = 0;
for (final Class<? extends ItemAttribute> attribute : _weaponSuffixes)
{
final ItemAttribute attrib = GearManager.instantiate(attribute);
final ItemAttribute attrib = attribute.newInstance();
addButton(indices[index], Material.DIAMOND_SWORD, 0, C.cGold + attrib.getDisplayName(), new IButton()
{
@ -725,7 +733,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
int index = 0;
for (final Class<? extends ItemAttribute> attribute : _armourSuffixes)
{
final ItemAttribute attrib = GearManager.instantiate(attribute);
final ItemAttribute attrib = attribute.newInstance();
addButton(indices[index], Material.DIAMOND_CHESTPLATE, 0, C.cGold + attrib.getDisplayName(), new IButton()
{
@ -749,7 +757,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
int index = 0;
for (final Class<? extends ItemAttribute> attribute : _bowSuffixes)
{
final ItemAttribute attrib = GearManager.instantiate(attribute);
final ItemAttribute attrib = attribute.newInstance();
addButton(indices[index], Material.BOW, 0, C.cGold + attrib.getDisplayName(), new IButton()
{

View File

@ -6,6 +6,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.items.GearManager;
public class GearShop extends ShopBase<GearManager>
{

View File

@ -2,7 +2,7 @@ package mineplex.game.clans.items.smelting;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.game.clans.items.GearManager;
import org.bukkit.Material;
import org.bukkit.entity.Player;

View File

@ -12,8 +12,8 @@ import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.items.CustomItem;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.economy.GoldToken;
import mineplex.game.clans.items.gear.GearManager;
public class CashInButton implements IButton
{

View File

@ -12,8 +12,8 @@ import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.items.CustomItem;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.economy.GoldToken;
import mineplex.game.clans.items.gear.GearManager;
public class GemTransferButton implements IButton
{

View File

@ -22,8 +22,8 @@ import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.items.CustomItem;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.economy.GoldToken;
import mineplex.game.clans.items.gear.GearManager;
import mineplex.game.clans.shop.PvpItem;
public class TravelButton implements IButton