Merged Pet page into Gadget page.
Reworked gadget page.
This commit is contained in:
parent
7f87043f7b
commit
f157715174
@ -1,45 +0,0 @@
|
||||
package mineplex.core.pet;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.pet.ui.PetPage;
|
||||
import mineplex.core.pet.ui.PetTagPage;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
public class PetShop extends ShopBase<PetManager> implements PluginMessageListener
|
||||
{
|
||||
public PetShop(PetManager plugin, CoreClientManager manager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, manager, donationManager, "Pet Shop", CurrencyType.Gems);
|
||||
|
||||
plugin.GetPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.GetPlugin(), "MC|ItemName", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<PetManager, ? extends ShopBase<PetManager>> BuildPagesFor(Player player)
|
||||
{
|
||||
return new PetPage(Plugin, this, ClientManager, DonationManager, " Pets", player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message)
|
||||
{
|
||||
if (!channel.equalsIgnoreCase("MC|ItemName"))
|
||||
return;
|
||||
|
||||
if (PlayerPageMap.containsKey(player.getName()) && PlayerPageMap.get(player.getName()) instanceof PetTagPage)
|
||||
{
|
||||
if (message != null && message.length >= 1)
|
||||
{
|
||||
String tagName = new String(message);
|
||||
|
||||
((PetTagPage)PlayerPageMap.get(player.getName())).SetTagName(tagName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package mineplex.core.pet.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class CloseButton implements IButton
|
||||
{
|
||||
@Override
|
||||
public void ClickedLeft(Player player)
|
||||
{
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedRight(Player player)
|
||||
{
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package mineplex.core.pet.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.pet.Pet;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class DeactivatePetButton implements IButton
|
||||
{
|
||||
private Pet _pet;
|
||||
private PetPage _page;
|
||||
|
||||
public DeactivatePetButton(Pet pet, PetPage page)
|
||||
{
|
||||
_pet = pet;
|
||||
_page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedLeft(Player player)
|
||||
{
|
||||
_page.DeactivatePet(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedRight(Player player)
|
||||
{
|
||||
_page.DeactivatePet(player);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package mineplex.core.pet.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.pet.Pet;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class PetButton implements IButton
|
||||
{
|
||||
private Pet _pet;
|
||||
private PetPage _page;
|
||||
|
||||
public PetButton(Pet pet, PetPage page)
|
||||
{
|
||||
_pet = pet;
|
||||
_page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedLeft(Player player)
|
||||
{
|
||||
_page.PurchasePet(player, _pet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedRight(Player player)
|
||||
{
|
||||
_page.PurchasePet(player, _pet);
|
||||
}
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
package mineplex.core.pet.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_7_R3.Block;
|
||||
import net.minecraft.server.v1_7_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R3.Item;
|
||||
import net.minecraft.server.v1_7_R3.Items;
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutSetSlot;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.pet.Pet;
|
||||
import mineplex.core.pet.PetExtra;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.pet.PetShop;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.AnvilContainer;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
public class PetPage extends ShopPageBase<PetManager, PetShop>
|
||||
{
|
||||
public PetPage(PetManager plugin, PetShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, name, player, 27);
|
||||
|
||||
BuildPage();
|
||||
}
|
||||
|
||||
protected void BuildPage()
|
||||
{
|
||||
int slot = 1;
|
||||
|
||||
List<Pet> pets = new ArrayList<Pet>(Plugin.GetFactory().GetPets());
|
||||
|
||||
Collections.sort(pets, new PetSorter());
|
||||
|
||||
for (Pet pet : pets)
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
itemLore.add(C.cYellow + pet.GetCost(CurrencyType.Gems) + " Gems");
|
||||
itemLore.add(C.cBlack);
|
||||
|
||||
if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(pet.GetPetName()))
|
||||
{
|
||||
if (Plugin.hasActivePet(Player.getName()) && Plugin.getActivePet(Player.getName()).getType() == pet.GetPetType())
|
||||
{
|
||||
AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Deactivate " + Plugin.Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new DeactivatePetButton(pet, this));
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Activate " + Plugin.Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new ActivatePetButton(pet, this));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= pet.GetCost(CurrencyType.Gems))
|
||||
AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new PetButton(pet, this));
|
||||
else
|
||||
setItem(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
|
||||
}
|
||||
|
||||
slot++;
|
||||
}
|
||||
|
||||
slot = 22;
|
||||
for (PetExtra petExtra : Plugin.GetFactory().GetPetExtras())
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
if (!Plugin.hasActivePet(Player.getName()))
|
||||
{
|
||||
itemLore.add(C.cWhite + "You must have an active pet to use this!");
|
||||
getInventory().setItem(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, C.cRed + petExtra.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle());
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, "Rename " + Plugin.getActivePet(Player.getName()).getCustomName() + " for " + C.cYellow + petExtra.GetCost(CurrencyType.Gems) + C.cGreen + " Gems", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this));
|
||||
}
|
||||
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
public void PurchasePet(final Player player, final Pet pet)
|
||||
{
|
||||
renamePet(player, pet, true);
|
||||
}
|
||||
|
||||
public void renameCurrentPet(Player player)
|
||||
{
|
||||
PlayAcceptSound(player);
|
||||
Creature currentPet = Plugin.getActivePet(player.getName());
|
||||
renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false);
|
||||
}
|
||||
|
||||
public void renamePet(Player player, Pet pet, boolean petPurchase)
|
||||
{
|
||||
PlayAcceptSound(player);
|
||||
|
||||
PetTagPage petTagPage = new PetTagPage(Plugin, Shop, ClientManager, DonationManager, "Repairing", Player, pet, petPurchase);
|
||||
EntityPlayer entityPlayer = ((CraftPlayer)Player).getHandle();
|
||||
int containerCounter = entityPlayer.nextContainerCounter();
|
||||
entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerCounter, 8, "Repairing", 9, true));
|
||||
entityPlayer.activeContainer = new AnvilContainer(entityPlayer.inventory, petTagPage.getInventory());
|
||||
entityPlayer.activeContainer.windowId = containerCounter;
|
||||
entityPlayer.activeContainer.addSlotListener(entityPlayer);
|
||||
entityPlayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(containerCounter, 0, new net.minecraft.server.v1_7_R3.ItemStack(Items.NAME_TAG)));
|
||||
|
||||
Shop.SetCurrentPageForPlayer(Player, petTagPage);
|
||||
}
|
||||
|
||||
public void ActivatePet(Player player, Pet pet)
|
||||
{
|
||||
PlayAcceptSound(player);
|
||||
Plugin.AddPetOwner(player, pet.GetPetType(), player.getLocation());
|
||||
Player.closeInventory();
|
||||
}
|
||||
|
||||
public void DeactivatePet(Player player)
|
||||
{
|
||||
PlayAcceptSound(player);
|
||||
Plugin.RemovePet(player, true);
|
||||
Player.closeInventory();
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package mineplex.core.pet.ui;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import mineplex.core.pet.Pet;
|
||||
|
||||
public class PetSorter implements Comparator<Pet>
|
||||
{
|
||||
public int compare(Pet a, Pet b)
|
||||
{
|
||||
if (a.GetPetType().getTypeId() < b.GetPetType().getTypeId())
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package mineplex.core.pet.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class RenamePetButton implements IButton
|
||||
{
|
||||
private PetPage _page;
|
||||
|
||||
public RenamePetButton(PetPage page)
|
||||
{
|
||||
_page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedLeft(Player player)
|
||||
{
|
||||
_page.renameCurrentPet(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedRight(Player player)
|
||||
{
|
||||
_page.renameCurrentPet(player);
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package mineplex.core.pet.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class SelectTagButton implements IButton
|
||||
{
|
||||
private PetTagPage _page;
|
||||
|
||||
public SelectTagButton(PetTagPage page)
|
||||
{
|
||||
_page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedLeft(Player player)
|
||||
{
|
||||
_page.SelectTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedRight(Player player)
|
||||
{
|
||||
_page.SelectTag();
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@ import mineplex.core.monitor.LagMeter;
|
||||
import mineplex.core.movement.Movement;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
@ -33,6 +32,7 @@ import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.hub.modules.StackerManager;
|
||||
import mineplex.hub.party.PartyManager;
|
||||
import mineplex.hub.pet.PetManager;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
@ -85,12 +85,12 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
||||
new MessageManager(this, clientManager, preferenceManager);
|
||||
Creature creature = new Creature(this);
|
||||
NpcManager npcManager = new NpcManager(this, creature);
|
||||
new PetManager(this, clientManager, donationManager, creature, GetWebServerAddress());
|
||||
PetManager petManager = new PetManager(this, clientManager, donationManager, creature, GetWebServerAddress());
|
||||
|
||||
//Main Modules
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
|
||||
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager, preferenceManager);
|
||||
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager, preferenceManager, petManager);
|
||||
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
|
||||
|
||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager);
|
||||
|
@ -67,6 +67,7 @@ import mineplex.hub.modules.*;
|
||||
import mineplex.hub.mount.MountManager;
|
||||
import mineplex.hub.party.Party;
|
||||
import mineplex.hub.party.PartyManager;
|
||||
import mineplex.hub.pet.PetManager;
|
||||
import mineplex.hub.tutorial.TutorialManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
|
||||
@ -106,7 +107,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
//Admin
|
||||
private boolean _gadgetsEnabled = true;
|
||||
|
||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences)
|
||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager)
|
||||
{
|
||||
super("Hub Manager", plugin);
|
||||
|
||||
@ -129,7 +130,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
new NewsManager(this);
|
||||
|
||||
_mountManager = new MountManager(this);
|
||||
_gadgetManager = new GadgetManager(this, _mountManager);
|
||||
_gadgetManager = new GadgetManager(this, _mountManager, petManager);
|
||||
|
||||
_partyManager = partyManager;
|
||||
_preferences = preferences;
|
||||
|
@ -25,7 +25,6 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.commands.GadgetToggle;
|
||||
import mineplex.hub.gadget.gadgets.*;
|
||||
import mineplex.hub.gadget.types.MorphGadget;
|
||||
import mineplex.hub.gadget.types.MorphGadget.ArmorSlot;
|
||||
@ -33,22 +32,23 @@ import mineplex.hub.gadget.types.Gadget;
|
||||
import mineplex.hub.gadget.types.ItemGadget;
|
||||
import mineplex.hub.gadget.ui.GadgetShop;
|
||||
import mineplex.hub.mount.MountManager;
|
||||
import mineplex.hub.pet.PetManager;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class GadgetManager extends MiniPlugin
|
||||
{
|
||||
public HubManager Manager;
|
||||
private GadgetShop _gadgetShop;
|
||||
private PetManager _petManager;
|
||||
|
||||
private HashSet<Gadget> _gadgets;
|
||||
|
||||
|
||||
|
||||
public GadgetManager(HubManager manager, MountManager mountManager)
|
||||
public GadgetManager(HubManager manager, MountManager mountManager, PetManager petManager)
|
||||
{
|
||||
super("Gadget Manager", manager.GetPlugin());
|
||||
|
||||
Manager = manager;
|
||||
_petManager = petManager;
|
||||
|
||||
CreateGadgets();
|
||||
|
||||
@ -207,4 +207,9 @@ public class GadgetManager extends MiniPlugin
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
gadget.Disable(player);
|
||||
}
|
||||
|
||||
public PetManager getPetManager()
|
||||
{
|
||||
return _petManager;
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
package mineplex.core.pet.ui;
|
||||
package mineplex.hub.gadget.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.pet.Pet;
|
||||
import mineplex.hub.pet.Pet;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class ActivatePetButton implements IButton
|
||||
{
|
||||
private Pet _pet;
|
||||
private PetPage _page;
|
||||
private GadgetPage _page;
|
||||
|
||||
public ActivatePetButton(Pet pet, PetPage page)
|
||||
public ActivatePetButton(Pet pet, GadgetPage page)
|
||||
{
|
||||
_pet = pet;
|
||||
_page = page;
|
@ -2,27 +2,39 @@ package mineplex.hub.gadget.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import net.minecraft.server.v1_7_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R3.Items;
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutSetSlot;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.AnvilContainer;
|
||||
import mineplex.core.shop.page.ConfirmationPage;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
import mineplex.hub.gadget.types.MorphGadget;
|
||||
import mineplex.hub.gadget.types.Gadget;
|
||||
import mineplex.hub.gadget.types.ItemGadget;
|
||||
import mineplex.hub.mount.HorseMount;
|
||||
import mineplex.hub.mount.Mount;
|
||||
import mineplex.hub.mount.MountManager;
|
||||
import mineplex.hub.pet.Pet;
|
||||
import mineplex.hub.pet.PetExtra;
|
||||
import mineplex.hub.gadget.ui.DeactivatePetButton;
|
||||
import mineplex.hub.gadget.ui.PetButton;
|
||||
import mineplex.hub.gadget.ui.PetSorter;
|
||||
import mineplex.hub.gadget.ui.RenamePetButton;
|
||||
|
||||
public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
|
||||
{
|
||||
@ -41,34 +53,11 @@ public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
|
||||
{
|
||||
int activeSlot = 2;
|
||||
int headSlot = 11;
|
||||
int chestSlot = 20;
|
||||
int legSlot = 29;
|
||||
int bootSlot = 38;
|
||||
int mountSlot = 47;
|
||||
int mountSlot = 20;
|
||||
|
||||
setItem(0, new ShopItem(Material.IRON_SWORD, (byte)0, "Active Gadget", new String[] {}, 1, false, false));
|
||||
|
||||
setItem(9, new ShopItem(Material.LEATHER_HELMET, (byte)0, "Hub Helmet", new String[] {}, 1, false, false));
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta)getItem(9).getItemMeta();
|
||||
meta.setColor(Color.BLACK);
|
||||
getItem(9).setItemMeta(meta);
|
||||
|
||||
setItem(18, new ShopItem(Material.LEATHER_CHESTPLATE, (byte)0, "Hub Chestplate", new String[] {}, 1, false, false));
|
||||
meta = (LeatherArmorMeta)getItem(18).getItemMeta();
|
||||
meta.setColor(Color.BLACK);
|
||||
getItem(18).setItemMeta(meta);
|
||||
|
||||
setItem(27, new ShopItem(Material.LEATHER_LEGGINGS, (byte)0, "Hub Leggings", new String[] {}, 1, false, false));
|
||||
meta = (LeatherArmorMeta)getItem(27).getItemMeta();
|
||||
meta.setColor(Color.BLACK);
|
||||
getItem(27).setItemMeta(meta);
|
||||
|
||||
setItem(36, new ShopItem(Material.LEATHER_BOOTS, (byte)0, "Hub Boots", new String[] {}, 1, false, false));
|
||||
meta = (LeatherArmorMeta)getItem(36).getItemMeta();
|
||||
meta.setColor(Color.BLACK);
|
||||
getItem(36).setItemMeta(meta);
|
||||
|
||||
setItem(45, new ShopItem(Material.SADDLE, (byte)0, "Hub Mount", new String[] {}, 1, false, false));
|
||||
setItem(0, new ShopItem(Material.IRON_SWORD, (byte)0, "Gadgets", new String[] {}, 1, false, false));
|
||||
setItem(9, new ShopItem(Material.SKULL_ITEM, (byte)0, "Hub Morphs", new String[] {}, 1, false, false));
|
||||
setItem(18, new ShopItem(Material.DIAMOND_BARDING, (byte)0, "Hub Mounts", new String[] {}, 1, false, false));
|
||||
|
||||
for (Gadget gadget : Plugin.getGadgets())
|
||||
{
|
||||
@ -78,22 +67,10 @@ public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
|
||||
{
|
||||
switch (((MorphGadget)gadget).GetSlot())
|
||||
{
|
||||
case Boots:
|
||||
slot = bootSlot;
|
||||
bootSlot++;
|
||||
break;
|
||||
case Chest:
|
||||
slot = chestSlot;
|
||||
chestSlot++;
|
||||
break;
|
||||
case Helmet:
|
||||
slot = headSlot;
|
||||
headSlot++;
|
||||
break;
|
||||
case Legs:
|
||||
slot = legSlot;
|
||||
legSlot++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -114,6 +91,59 @@ public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
|
||||
|
||||
addMount(mount, slot);
|
||||
}
|
||||
|
||||
int slot = 38;
|
||||
|
||||
List<Pet> pets = new ArrayList<Pet>(Plugin.getPetManager().GetFactory().GetPets());
|
||||
|
||||
Collections.sort(pets, new PetSorter());
|
||||
|
||||
for (Pet pet : pets)
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
itemLore.add(C.cYellow + pet.GetCost(CurrencyType.Gems) + " Gems");
|
||||
itemLore.add(C.cBlack);
|
||||
|
||||
if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(pet.GetPetName()))
|
||||
{
|
||||
if (Plugin.getPetManager().hasActivePet(Player.getName()) && Plugin.getPetManager().getActivePet(Player.getName()).getType() == pet.GetPetType())
|
||||
{
|
||||
AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Deactivate " + Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new DeactivatePetButton(pet, this));
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Activate " + Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new ActivatePetButton(pet, this));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= pet.GetCost(CurrencyType.Gems))
|
||||
AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new PetButton(pet, this));
|
||||
else
|
||||
setItem(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
|
||||
}
|
||||
|
||||
slot++;
|
||||
}
|
||||
|
||||
slot = 36;
|
||||
for (PetExtra petExtra : Plugin.getPetManager().GetFactory().GetPetExtras())
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
if (!Plugin.getPetManager().hasActivePet(Player.getName()))
|
||||
{
|
||||
itemLore.add(C.cWhite + "You must have an active pet to use this!");
|
||||
getInventory().setItem(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, C.cRed + petExtra.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle());
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, "Rename " + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName() + " for " + C.cYellow + petExtra.GetCost(CurrencyType.Gems) + C.cGreen + " Gems", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this));
|
||||
}
|
||||
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
protected void addGadget(Gadget gadget, int slot)
|
||||
@ -229,4 +259,46 @@ public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
|
||||
_mount.Disable(player);
|
||||
Player.closeInventory();
|
||||
}
|
||||
|
||||
public void PurchasePet(final Player player, final Pet pet)
|
||||
{
|
||||
renamePet(player, pet, true);
|
||||
}
|
||||
|
||||
public void renameCurrentPet(Player player)
|
||||
{
|
||||
PlayAcceptSound(player);
|
||||
Creature currentPet = Plugin.getPetManager().getActivePet(player.getName());
|
||||
renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false);
|
||||
}
|
||||
|
||||
public void renamePet(Player player, Pet pet, boolean petPurchase)
|
||||
{
|
||||
PlayAcceptSound(player);
|
||||
|
||||
PetTagPage petTagPage = new PetTagPage(Plugin, Shop, ClientManager, DonationManager, "Repairing", Player, pet, petPurchase);
|
||||
EntityPlayer entityPlayer = ((CraftPlayer)Player).getHandle();
|
||||
int containerCounter = entityPlayer.nextContainerCounter();
|
||||
entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerCounter, 8, "Repairing", 9, true));
|
||||
entityPlayer.activeContainer = new AnvilContainer(entityPlayer.inventory, petTagPage.getInventory());
|
||||
entityPlayer.activeContainer.windowId = containerCounter;
|
||||
entityPlayer.activeContainer.addSlotListener(entityPlayer);
|
||||
entityPlayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(containerCounter, 0, new net.minecraft.server.v1_7_R3.ItemStack(Items.NAME_TAG)));
|
||||
|
||||
Shop.SetCurrentPageForPlayer(Player, petTagPage);
|
||||
}
|
||||
|
||||
public void ActivatePet(Player player, Pet pet)
|
||||
{
|
||||
PlayAcceptSound(player);
|
||||
Plugin.getPetManager().AddPetOwner(player, pet.GetPetType(), player.getLocation());
|
||||
Player.closeInventory();
|
||||
}
|
||||
|
||||
public void DeactivatePet(Player player)
|
||||
{
|
||||
PlayAcceptSound(player);
|
||||
Plugin.getPetManager().RemovePet(player, true);
|
||||
Player.closeInventory();
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package mineplex.hub.gadget.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
@ -10,7 +11,7 @@ import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
import mineplex.hub.mount.MountManager;
|
||||
|
||||
public class GadgetShop extends ShopBase<GadgetManager>
|
||||
public class GadgetShop extends ShopBase<GadgetManager> implements PluginMessageListener
|
||||
{
|
||||
private MountManager _mountManager;
|
||||
|
||||
@ -19,6 +20,8 @@ public class GadgetShop extends ShopBase<GadgetManager>
|
||||
super(plugin, manager, donationManager, "Gadget Shop", CurrencyType.Gems);
|
||||
|
||||
_mountManager = mountManager;
|
||||
|
||||
plugin.GetPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.GetPlugin(), "MC|ItemName", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,4 +29,21 @@ public class GadgetShop extends ShopBase<GadgetManager>
|
||||
{
|
||||
return new GadgetPage(Plugin, this, _mountManager, ClientManager, DonationManager, " Gadgets", player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message)
|
||||
{
|
||||
if (!channel.equalsIgnoreCase("MC|ItemName"))
|
||||
return;
|
||||
|
||||
if (PlayerPageMap.containsKey(player.getName()) && PlayerPageMap.get(player.getName()) instanceof PetTagPage)
|
||||
{
|
||||
if (message != null && message.length >= 1)
|
||||
{
|
||||
String tagName = new String(message);
|
||||
|
||||
((PetTagPage)PlayerPageMap.get(player.getName())).SetTagName(tagName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.pet.ui;
|
||||
package mineplex.hub.gadget.ui;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
@ -6,15 +6,13 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.pet.Pet;
|
||||
import mineplex.core.pet.PetExtra;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.pet.PetShop;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
import mineplex.hub.pet.Pet;
|
||||
import mineplex.hub.pet.PetExtra;
|
||||
import mineplex.core.pet.repository.token.PetChangeToken;
|
||||
import mineplex.core.pet.repository.token.PetToken;
|
||||
import mineplex.core.shop.page.ConfirmationPage;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import net.minecraft.server.v1_7_R3.Item;
|
||||
import net.minecraft.server.v1_7_R3.ItemStack;
|
||||
import net.minecraft.server.v1_7_R3.Items;
|
||||
|
||||
@ -22,13 +20,13 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PetTagPage extends ShopPageBase<PetManager, PetShop>
|
||||
public class PetTagPage extends ShopPageBase<GadgetManager, GadgetShop>
|
||||
{
|
||||
private String _tagName = "Pet Tag";
|
||||
private Pet _pet;
|
||||
private boolean _petPurchase;
|
||||
|
||||
public PetTagPage(PetManager plugin, PetShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase)
|
||||
public PetTagPage(GadgetManager plugin, GadgetShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, name, player, 3);
|
||||
|
||||
@ -72,7 +70,7 @@ public class PetTagPage extends ShopPageBase<PetManager, PetShop>
|
||||
|
||||
_pet.setDisplayName(C.cGreen + "Purchase " + _tagName);
|
||||
|
||||
Shop.OpenPageForPlayer(Player, new ConfirmationPage<PetManager, PetShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
|
||||
Shop.OpenPageForPlayer(Player, new ConfirmationPage<GadgetManager, GadgetShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
@ -86,16 +84,16 @@ public class PetTagPage extends ShopPageBase<PetManager, PetShop>
|
||||
|
||||
if (_petPurchase)
|
||||
{
|
||||
Plugin.GetRepository().AddPet(token);
|
||||
Plugin.addPetOwnerToQueue(Player.getName(), _pet.GetPetType());
|
||||
Plugin.getPetManager().GetRepository().AddPet(token);
|
||||
Plugin.getPetManager().addPetOwnerToQueue(Player.getName(), _pet.GetPetType());
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.GetRepository().UpdatePet(token);
|
||||
Plugin.addRenamePetToQueue(Player.getName(), token.PetName);
|
||||
Plugin.getPetManager().GetRepository().UpdatePet(token);
|
||||
Plugin.getPetManager().addRenamePetToQueue(Player.getName(), token.PetName);
|
||||
}
|
||||
|
||||
Plugin.Get(Player).GetPets().put(_pet.GetPetType(), token.PetName);
|
||||
Plugin.getPetManager().Get(Player).GetPets().put(_pet.GetPetType(), token.PetName);
|
||||
|
||||
Player.closeInventory();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.pet;
|
||||
package mineplex.hub.pet;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.pet.repository.token.PetSalesToken;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.pet;
|
||||
package mineplex.hub.pet;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.pet;
|
||||
package mineplex.hub.pet;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
@ -1,13 +1,13 @@
|
||||
package mineplex.core.pet;
|
||||
package mineplex.hub.pet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.pet.repository.PetRepository;
|
||||
import mineplex.core.pet.repository.token.PetExtraToken;
|
||||
import mineplex.core.pet.repository.token.PetSalesToken;
|
||||
import mineplex.hub.pet.repository.PetRepository;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
@ -1,11 +1,10 @@
|
||||
package mineplex.core.pet;
|
||||
package mineplex.hub.pet;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.pet.repository.PetRepository;
|
||||
import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -17,6 +16,7 @@ import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.hub.pet.repository.PetRepository;
|
||||
import net.minecraft.server.v1_7_R3.EntityCreature;
|
||||
import net.minecraft.server.v1_7_R3.EntityHuman;
|
||||
import net.minecraft.server.v1_7_R3.EntityInsentient;
|
||||
@ -29,6 +29,7 @@ import net.minecraft.server.v1_7_R3.PathfinderGoalSelector;
|
||||
|
||||
|
||||
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -66,8 +67,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
private NautHashMap<String, Creature> _activePetOwners;
|
||||
private NautHashMap<String, Integer> _failedAttempts;
|
||||
|
||||
private PetShop _petShop;
|
||||
|
||||
private Field _goalSelector;
|
||||
private Field _targetSelector;
|
||||
|
||||
@ -81,7 +80,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
_creatureModule = creatureModule;
|
||||
_repository = new PetRepository(webAddress);
|
||||
_petFactory = new PetFactory(_repository);
|
||||
_petShop = new PetShop(this, clientManager, donationManager);
|
||||
|
||||
_activePetOwners = new NautHashMap<String, Creature>();
|
||||
_failedAttempts = new NautHashMap<String, Integer>();
|
||||
@ -188,16 +186,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void TryToAddPetOwner(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.hasItem() && event.getItem().getType() == Material.BONE)
|
||||
{
|
||||
_petShop.attemptShopOpen(event.getPlayer());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventWolfBone(PlayerInteractEntityEvent event)
|
||||
{
|
||||
@ -208,32 +196,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void orderThatBone(final PlayerDropItemEvent event)
|
||||
{
|
||||
if (event.getItemDrop().getItemStack().getType() == Material.BONE)
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (event.getPlayer().isOnline())
|
||||
{
|
||||
event.getPlayer().getInventory().remove(Material.BONE);
|
||||
event.getPlayer().getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, 1, ChatColor.RESET + C.cGreen + "Pet Menu"));
|
||||
event.getPlayer().updateInventory();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
event.getPlayer().getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, 1, ChatColor.RESET + C.cGreen + "Pet Menu"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.pet.event;
|
||||
package mineplex.hub.pet.event;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.pet.repository;
|
||||
package mineplex.hub.pet.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user