Fixed some issues with menus!
This commit is contained in:
parent
defece04a9
commit
5d2681ec97
@ -1,17 +1,19 @@
|
||||
package mineplex.core.cosmetic.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||
import mineplex.core.cosmetic.ui.page.Menu;
|
||||
import mineplex.core.cosmetic.ui.page.PetTagPage;
|
||||
import mineplex.core.cosmetic.ui.page.custompet.name.CustomPetTagPage;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMessageListener
|
||||
{
|
||||
@ -43,6 +45,16 @@ public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMes
|
||||
((PetTagPage) getPlayerPageMap().get(player.getUniqueId())).SetTagName(tagName);
|
||||
}
|
||||
}
|
||||
|
||||
if (getPlayerPageMap().containsKey(player.getUniqueId()) && getPlayerPageMap().get(player.getUniqueId()) instanceof CustomPetTagPage)
|
||||
{
|
||||
if (message != null && message.length >= 1)
|
||||
{
|
||||
String tagName = new String(message);
|
||||
|
||||
((CustomPetTagPage) getPlayerPageMap().get(player.getUniqueId())).setTagName(tagName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -41,7 +41,7 @@ public class CustomPetBasePage extends GadgetPage
|
||||
CustomPet customPet = CustomPet.getCustomPet(player);
|
||||
if (customPet == null)
|
||||
{
|
||||
customPet = customPetType.getCustomPet(player);
|
||||
customPet = customPetType.getCustomPet(getPlugin().getPetManager(), player);
|
||||
}
|
||||
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
|
||||
});
|
||||
|
@ -7,7 +7,6 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.cosmetic.ui.button.activate.ActivatePetButton;
|
||||
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.pet.custom.CustomPet;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineplex.core.cosmetic.ui.page.custompet.equipment;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -27,29 +26,21 @@ public class CustomPetHelmetPage extends GadgetPage
|
||||
protected void buildPage()
|
||||
{
|
||||
|
||||
Bukkit.broadcastMessage("A");
|
||||
|
||||
CustomPet customPet = CustomPet.getCustomPet(getPlayer());
|
||||
if (customPet == null)
|
||||
{
|
||||
Bukkit.broadcastMessage("A1");
|
||||
CustomPet.removeCustomPet(getPlayer());
|
||||
getPlayer().closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.broadcastMessage("B");
|
||||
|
||||
if (!(customPet instanceof CustomPetEquipment))
|
||||
{
|
||||
Bukkit.broadcastMessage("B1");
|
||||
CustomPet.removeCustomPet(getPlayer());
|
||||
getPlayer().closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.broadcastMessage("A");
|
||||
|
||||
CustomPetEquipment customPetEquipment = (CustomPetEquipment) customPet;
|
||||
|
||||
// Leather helmet
|
||||
@ -60,8 +51,6 @@ public class CustomPetHelmetPage extends GadgetPage
|
||||
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
|
||||
});
|
||||
|
||||
Bukkit.broadcastMessage("B");
|
||||
|
||||
addButton(22, new ShopItem(Material.CHAINMAIL_HELMET, "Chain", 1, false), (player, clickType) ->
|
||||
{
|
||||
customPetEquipment.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
|
||||
|
@ -40,9 +40,6 @@ public class CustomPetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop
|
||||
public void playerClosed()
|
||||
{
|
||||
super.playerClosed();
|
||||
|
||||
getPlayer().setLevel(0);
|
||||
CustomPet.removeCustomPet(_player);
|
||||
}
|
||||
|
||||
public void selectTag()
|
||||
|
@ -746,4 +746,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
||||
return _creatureModule;
|
||||
}
|
||||
|
||||
public DisguiseManager getDisguiseManager()
|
||||
{
|
||||
return _disguiseManager;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,20 +21,23 @@ import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
|
||||
public abstract class CustomPet
|
||||
{
|
||||
|
||||
private static Map<Player, CustomPet> _customPet = new HashMap<>();
|
||||
|
||||
protected PetManager _petManager;
|
||||
protected Player _player;
|
||||
protected EntityType _entityType;
|
||||
protected int _step = 0;
|
||||
private String _name;
|
||||
private List<String> _lines = new ArrayList<>();
|
||||
|
||||
public CustomPet(Player player, EntityType entityType)
|
||||
public CustomPet(PetManager petManager, Player player, EntityType entityType)
|
||||
{
|
||||
_petManager = petManager;
|
||||
_player = player;
|
||||
_entityType = entityType;
|
||||
_customPet.put(player, this);
|
||||
@ -151,14 +154,14 @@ public abstract class CustomPet
|
||||
return _data;
|
||||
}
|
||||
|
||||
public CustomPet getCustomPet(Player player)
|
||||
public CustomPet getCustomPet(PetManager petManager, Player player)
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case ZOMBIE:
|
||||
return new CustomPetZombie(player);
|
||||
return new CustomPetZombie(petManager, player);
|
||||
default:
|
||||
return new CustomPetZombie(player);
|
||||
return new CustomPetZombie(petManager, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,16 @@ package mineplex.core.pet.custom;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.pet.PetManager;
|
||||
|
||||
public abstract class CustomPetAgeable extends CustomPet
|
||||
{
|
||||
|
||||
private boolean _baby = false;
|
||||
|
||||
public CustomPetAgeable(Player player, EntityType entityType)
|
||||
public CustomPetAgeable(PetManager petManager, Player player, EntityType entityType)
|
||||
{
|
||||
super(player, entityType);
|
||||
super(petManager, player, entityType);
|
||||
}
|
||||
|
||||
public void setBaby(boolean baby)
|
||||
|
@ -5,6 +5,8 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.pet.PetManager;
|
||||
|
||||
public abstract class CustomPetEquipment extends CustomPetAgeable
|
||||
{
|
||||
|
||||
@ -13,9 +15,9 @@ public abstract class CustomPetEquipment extends CustomPetAgeable
|
||||
private ItemStack _leggings;
|
||||
private ItemStack _boots;
|
||||
|
||||
public CustomPetEquipment(Player player, EntityType entityType)
|
||||
public CustomPetEquipment(PetManager petManager, Player player, EntityType entityType)
|
||||
{
|
||||
super(player, entityType);
|
||||
super(petManager, player, entityType);
|
||||
}
|
||||
|
||||
public void setHelmet(ItemStack helmet)
|
||||
|
@ -20,15 +20,16 @@ import mineplex.core.cosmetic.ui.page.custompet.name.CustomPetNamePage;
|
||||
import mineplex.core.cosmetic.ui.page.custompet.zombie.CustomPetZombieTypePage;
|
||||
import mineplex.core.disguise.disguises.DisguiseZombie;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
|
||||
public class CustomPetZombie extends CustomPetEquipment
|
||||
{
|
||||
|
||||
private boolean _villager = false;
|
||||
|
||||
public CustomPetZombie(Player player)
|
||||
public CustomPetZombie(PetManager petManager, Player player)
|
||||
{
|
||||
super(player, EntityType.ZOMBIE);
|
||||
super(petManager, player, EntityType.ZOMBIE);
|
||||
addTypeLine("Zombie");
|
||||
}
|
||||
|
||||
@ -63,6 +64,7 @@ public class CustomPetZombie extends CustomPetEquipment
|
||||
{
|
||||
disguiseZombie.setCustomNameVisible(false);
|
||||
}
|
||||
_petManager.getDisguiseManager().disguise(disguiseZombie);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user