Added equipment pages

This commit is contained in:
LCastr0 2017-03-14 09:40:11 -03:00
parent e297f844e6
commit 13238eb4ad
16 changed files with 821 additions and 18 deletions

View File

@ -37,7 +37,7 @@ public class CustomPetBasePage extends GadgetPage
{
customPet = customPetType.getCustomPet(player);
}
getShop().openPageForPlayer(getPlayer(), customPet.createNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
slot++;

View File

@ -0,0 +1,61 @@
package mineplex.core.cosmetic.ui.page.custompet;
import org.bukkit.Material;
import org.bukkit.entity.Player;
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.page.GadgetPage;
import mineplex.core.donation.DonationManager;
import mineplex.core.pet.custom.CustomPet;
import mineplex.core.shop.item.ShopItem;
public class CustomPetConfirmPage extends GadgetPage
{
public CustomPetConfirmPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}
@Override
protected void buildPage()
{
CustomPet customPet = CustomPet.getCustomPet(getPlayer());
if (customPet == null)
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
int[] confirm = {19, 20, 21, 28, 29, 30, 37, 38, 39};
int[] cancel = {23, 24, 25, 32, 33, 34, 41, 42, 43};
ShopItem confirmItem = new ShopItem(Material.WOOL, (byte) 5, "Confirm", new String[]{}, 1, false, false);
ShopItem cancelItem = new ShopItem(Material.WOOL, (byte) 14, "Cancel", new String[]{}, 1, false, false);
for (int aConfirm : confirm)
{
addButton(aConfirm, confirmItem, (player, clickType) ->
{
// TODO
});
}
for (int aCancel : cancel)
{
addButton(aCancel, cancelItem, (player, clickType) ->
{
// TODO
});
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) ->
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())));
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.cosmetic.ui.page.custompet;
package mineplex.core.cosmetic.ui.page.custompet.age;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -8,7 +8,6 @@ import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.donation.DonationManager;
import mineplex.core.pet.custom.CustomPet;
import mineplex.core.pet.custom.CustomPetAgeable;
@ -26,8 +25,6 @@ public class CustomPetAgePage extends GadgetPage
protected void buildPage()
{
// 20
// 24
CustomPet customPet = CustomPet.getCustomPet(getPlayer());
if (customPet == null)
{
@ -45,18 +42,20 @@ public class CustomPetAgePage extends GadgetPage
CustomPetAgeable customPetAgeable = (CustomPetAgeable) customPet;
addButton(20, new ShopItem(Material.SEEDS, "Baby", 1, false), (player, clickType) ->
addButton(29, new ShopItem(Material.SEEDS, "Baby", 1, false), (player, clickType) ->
{
customPetAgeable.setBaby(true);
getShop().openPageForPlayer(getPlayer(), customPet.createNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(33, new ShopItem(Material.WHEAT, "Adult", 1, false), (player, clickType) ->
{
customPetAgeable.setBaby(false);
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) ->
{
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
CustomPet.removeCustomPet(player);
});
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())));
}
}

View File

@ -0,0 +1,89 @@
package mineplex.core.cosmetic.ui.page.custompet.equipment;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.page.GadgetPage;
import mineplex.core.donation.DonationManager;
import mineplex.core.pet.custom.CustomPet;
import mineplex.core.pet.custom.CustomPetEquipment;
import mineplex.core.shop.item.ShopItem;
public class CustomPetBootsPage extends GadgetPage
{
public CustomPetBootsPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}
@Override
protected void buildPage()
{
CustomPet customPet = CustomPet.getCustomPet(getPlayer());
if (customPet == null)
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
if (!(customPet instanceof CustomPetEquipment))
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
CustomPetEquipment customPetEquipment = (CustomPetEquipment) customPet;
// Leather helmet
addButton(19, new ShopItem(Material.LEATHER_BOOTS, "Leather", 1, false), (player, clickType) ->
{
// TODO COLORED ARMOR
customPetEquipment.setBoots(new ItemStack(Material.LEATHER_BOOTS));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(22, new ShopItem(Material.CHAINMAIL_BOOTS, "Chain", 1, false), (player, clickType) ->
{
customPetEquipment.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(25, new ShopItem(Material.IRON_BOOTS, "Iron", 1, false), (player, clickType) ->
{
customPetEquipment.setBoots(new ItemStack(Material.IRON_HELMET));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(38, new ShopItem(Material.GOLD_BOOTS, "Gold", 1, false), (player, clickType) ->
{
customPetEquipment.setBoots(new ItemStack(Material.GOLD_BOOTS));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(40, new ShopItem(Material.BARRIER, "None", 1, false), (player, clickType) ->
{
customPetEquipment.setBoots(new ItemStack(Material.AIR));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(42, new ShopItem(Material.DIAMOND_BOOTS, "Diamond", 1, false), (player, clickType) ->
{
customPetEquipment.setBoots(new ItemStack(Material.DIAMOND_BOOTS));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) ->
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())));
}
}

View File

@ -0,0 +1,88 @@
package mineplex.core.cosmetic.ui.page.custompet.equipment;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.page.GadgetPage;
import mineplex.core.donation.DonationManager;
import mineplex.core.pet.custom.CustomPet;
import mineplex.core.pet.custom.CustomPetEquipment;
import mineplex.core.shop.item.ShopItem;
public class CustomPetChestplatePage extends GadgetPage
{
public CustomPetChestplatePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}
@Override
protected void buildPage()
{
CustomPet customPet = CustomPet.getCustomPet(getPlayer());
if (customPet == null)
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
if (!(customPet instanceof CustomPetEquipment))
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
CustomPetEquipment customPetEquipment = (CustomPetEquipment) customPet;
// Leather helmet
addButton(19, new ShopItem(Material.LEATHER_CHESTPLATE, "Leather", 1, false), (player, clickType) ->
{
// TODO COLORED ARMOR
customPetEquipment.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(22, new ShopItem(Material.CHAINMAIL_CHESTPLATE, "Chain", 1, false), (player, clickType) ->
{
customPetEquipment.setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(25, new ShopItem(Material.IRON_CHESTPLATE, "Iron", 1, false), (player, clickType) ->
{
customPetEquipment.setChestplate(new ItemStack(Material.IRON_HELMET));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(38, new ShopItem(Material.GOLD_CHESTPLATE, "Gold", 1, false), (player, clickType) ->
{
customPetEquipment.setChestplate(new ItemStack(Material.GOLD_CHESTPLATE));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(40, new ShopItem(Material.BARRIER, "None", 1, false), (player, clickType) ->
{
customPetEquipment.setChestplate(new ItemStack(Material.AIR));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(42, new ShopItem(Material.DIAMOND_CHESTPLATE, "Diamond", 1, false), (player, clickType) ->
{
customPetEquipment.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) ->
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())));
}
}

View File

@ -0,0 +1,88 @@
package mineplex.core.cosmetic.ui.page.custompet.equipment;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.page.GadgetPage;
import mineplex.core.donation.DonationManager;
import mineplex.core.pet.custom.CustomPet;
import mineplex.core.pet.custom.CustomPetEquipment;
import mineplex.core.shop.item.ShopItem;
public class CustomPetHelmetPage extends GadgetPage
{
public CustomPetHelmetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}
@Override
protected void buildPage()
{
CustomPet customPet = CustomPet.getCustomPet(getPlayer());
if (customPet == null)
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
if (!(customPet instanceof CustomPetEquipment))
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
CustomPetEquipment customPetEquipment = (CustomPetEquipment) customPet;
// Leather helmet
addButton(19, new ShopItem(Material.LEATHER_HELMET, "Leather", 1, false), (player, clickType) ->
{
// TODO COLORED ARMOR
customPetEquipment.setHelmet(new ItemStack(Material.LEATHER_HELMET));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(22, new ShopItem(Material.CHAINMAIL_HELMET, "Chain", 1, false), (player, clickType) ->
{
customPetEquipment.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(25, new ShopItem(Material.IRON_HELMET, "Iron", 1, false), (player, clickType) ->
{
customPetEquipment.setHelmet(new ItemStack(Material.IRON_HELMET));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(38, new ShopItem(Material.GOLD_HELMET, "Gold", 1, false), (player, clickType) ->
{
customPetEquipment.setHelmet(new ItemStack(Material.GOLD_HELMET));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(40, new ShopItem(Material.BARRIER, "None", 1, false), (player, clickType) ->
{
customPetEquipment.setHelmet(new ItemStack(Material.AIR));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(42, new ShopItem(Material.DIAMOND_HELMET, "Diamond", 1, false), (player, clickType) ->
{
customPetEquipment.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) ->
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())));
}
}

View File

@ -0,0 +1,88 @@
package mineplex.core.cosmetic.ui.page.custompet.equipment;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.page.GadgetPage;
import mineplex.core.donation.DonationManager;
import mineplex.core.pet.custom.CustomPet;
import mineplex.core.pet.custom.CustomPetEquipment;
import mineplex.core.shop.item.ShopItem;
public class CustomPetLeggingsPage extends GadgetPage
{
public CustomPetLeggingsPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}
@Override
protected void buildPage()
{
CustomPet customPet = CustomPet.getCustomPet(getPlayer());
if (customPet == null)
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
if (!(customPet instanceof CustomPetEquipment))
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
CustomPetEquipment customPetEquipment = (CustomPetEquipment) customPet;
// Leather helmet
addButton(19, new ShopItem(Material.LEATHER_LEGGINGS, "Leather", 1, false), (player, clickType) ->
{
// TODO COLORED ARMOR
customPetEquipment.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(22, new ShopItem(Material.CHAINMAIL_LEGGINGS, "Chain", 1, false), (player, clickType) ->
{
customPetEquipment.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(25, new ShopItem(Material.IRON_LEGGINGS, "Iron", 1, false), (player, clickType) ->
{
customPetEquipment.setLeggings(new ItemStack(Material.IRON_HELMET));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(38, new ShopItem(Material.GOLD_LEGGINGS, "Gold", 1, false), (player, clickType) ->
{
customPetEquipment.setLeggings(new ItemStack(Material.GOLD_LEGGINGS));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(40, new ShopItem(Material.BARRIER, "None", 1, false), (player, clickType) ->
{
customPetEquipment.setLeggings(new ItemStack(Material.AIR));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(42, new ShopItem(Material.DIAMOND_LEGGINGS, "Diamond", 1, false), (player, clickType) ->
{
customPetEquipment.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) ->
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())));
}
}

View File

@ -0,0 +1,16 @@
package mineplex.core.cosmetic.ui.page.custompet.name;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.pet.custom.CustomPet;
import mineplex.core.shop.item.IButton;
public class CloseCustomPetButton implements IButton
{
public void onClick(Player player, ClickType clickType)
{
player.closeInventory();
CustomPet.removeCustomPet(player);
}
}

View File

@ -0,0 +1,63 @@
package mineplex.core.cosmetic.ui.page.custompet.name;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.ChatMessage;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.Items;
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
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.custom.CustomPet;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.AnvilContainer;
public class CustomPetNamePage extends GadgetPage
{
public CustomPetNamePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}
@Override
protected void buildPage()
{
CustomPet customPet = CustomPet.getCustomPet(getPlayer());
if (customPet == null)
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
addButton(31, new ShopItem(Material.NAME_TAG, "Name", 1, false), (player, clickType) ->
{
CustomPetTagPage customPetTagPage = new CustomPetTagPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Pet Name", getPlayer());
EntityPlayer entityPlayer = ((CraftPlayer) getPlayer()).getHandle();
int containerCounter = entityPlayer.nextContainerCounter();
UtilPlayer.sendPacket(player, new PacketPlayOutOpenWindow(containerCounter, "minecraft:anvil", new ChatMessage(Blocks.ANVIL.a() + ".name", new Object[0])));
entityPlayer.activeContainer = new AnvilContainer(entityPlayer.inventory, customPetTagPage.getInventory());
entityPlayer.activeContainer.windowId = containerCounter;
entityPlayer.activeContainer.addSlotListener(entityPlayer);
UtilPlayer.sendPacket(player, new PacketPlayOutSetSlot(containerCounter, 0, new net.minecraft.server.v1_8_R3.ItemStack(Items.NAME_TAG)));
getShop().setCurrentPageForPlayer(getPlayer(), customPetTagPage);
});
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) ->
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())));
}
}

View File

@ -0,0 +1,98 @@
package mineplex.core.cosmetic.ui.page.custompet.name;
import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.Items;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager;
import mineplex.core.pet.custom.CustomPet;
import mineplex.core.shop.page.ShopPageBase;
public class CustomPetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
private String _tagName = "Pet Name";
public CustomPetTagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player, 3);
buildPage();
}
@Override
protected void buildPage()
{
inventory.setItem(0, new ItemStack(Items.NAME_TAG));
getButtonMap().put(0, new CloseCustomPetButton());
getButtonMap().put(1, new CloseCustomPetButton());
getButtonMap().put(2, new SelectCustomPetTagButton(this));
}
@Override
public void playerClosed()
{
super.playerClosed();
getPlayer().setLevel(0);
CustomPet.removeCustomPet(_player);
}
public void selectTag()
{
CustomPet customPet = CustomPet.getCustomPet(_player);
if (customPet == null)
{
_player.closeInventory();
CustomPet.removeCustomPet(_player);
return;
}
_tagName = ChatColor.stripColor(_tagName);
_tagName = _tagName.replaceAll("[^A-Za-z0-9]", "");
System.out.println("Pet name: " + _tagName + ".");
if (_tagName.length() == 0)
{
UtilPlayer.message(getPlayer(), F.main(getPlugin().getName(), ChatColor.RED + "Supplied pet name contains invalid characters."));
playDenySound(getPlayer());
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
return;
}
if (_tagName.length() > 16)
{
UtilPlayer.message(getPlayer(), F.main(getPlugin().getName(), ChatColor.RED + "Pet name cannot be longer than 16 characters."));
playDenySound(getPlayer());
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
return;
}
if (_tagName.toLowerCase().contains("ultra"))
{
UtilPlayer.message(getPlayer(), F.main(getPlugin().getName(), ChatColor.RED + _tagName + " is a restricted name."));
playDenySound(getPlayer());
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
return;
}
customPet.setName(_tagName);
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
}
public void setTagName(String tagName)
{
_tagName = tagName;
}
}

View File

@ -0,0 +1,21 @@
package mineplex.core.cosmetic.ui.page.custompet.name;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
public class SelectCustomPetTagButton implements IButton
{
private CustomPetTagPage _page;
public SelectCustomPetTagButton(CustomPetTagPage page)
{
_page = page;
}
public void onClick(Player player, ClickType clickType)
{
_page.selectTag();
}
}

View File

@ -0,0 +1,61 @@
package mineplex.core.cosmetic.ui.page.custompet.zombie;
import org.bukkit.Material;
import org.bukkit.entity.Player;
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.page.GadgetPage;
import mineplex.core.donation.DonationManager;
import mineplex.core.pet.custom.CustomPet;
import mineplex.core.pet.custom.CustomPetZombie;
import mineplex.core.shop.item.ShopItem;
public class CustomPetZombieTypePage extends GadgetPage
{
public CustomPetZombieTypePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}
@Override
protected void buildPage()
{
CustomPet customPet = CustomPet.getCustomPet(getPlayer());
if (customPet == null)
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
if (!(customPet instanceof CustomPetZombie))
{
CustomPet.removeCustomPet(getPlayer());
getPlayer().closeInventory();
return;
}
CustomPetZombie customPetZombie = (CustomPetZombie) customPet;
addButton(29, new ShopItem(Material.BARRIER, "Zombie", 1, false), (player, clickType) ->
{
customPetZombie.setVillager(false);
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(33, new ShopItem(Material.WHEAT, "Zombie Villager", 1, false), (player, clickType) ->
{
customPetZombie.setVillager(true);
getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager()));
});
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) ->
getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())));
}
}

View File

@ -1,14 +1,21 @@
package mineplex.core.pet.custom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.page.GadgetPage;
@ -25,6 +32,7 @@ public abstract class CustomPet
protected DisguiseBase _disguiseBase;
protected int _step = 0;
private String _name;
private List<String> _lines = new ArrayList<>();
public CustomPet(Player player, EntityType entityType)
{
@ -41,7 +49,9 @@ public abstract class CustomPet
public abstract void onSpawn(Entity entity);
public abstract GadgetPage createNextStep(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager);
public abstract GadgetPage getNextStep(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager);
public abstract GadgetPage getPreviousStep(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager);
public DisguiseBase getDisguiseBase()
{
@ -58,6 +68,43 @@ public abstract class CustomPet
return _name;
}
public void addLine(String lineKey, String lineValue)
{
_lines.add(C.cGray + lineKey + ": " + F.name(lineValue));
}
public void addLine(String lineKey, String lineValue, int i)
{
_lines.add(i, C.cGray + lineKey + ": " + F.name(lineValue));
}
protected void addTypeLine(String type)
{
addLine("Type", type);
}
public List<String> getLines()
{
return _lines;
}
public ItemStack getCustomPetDescription()
{
ItemStack itemStack = new ItemStack(Material.PAPER);
ItemMeta meta = itemStack.getItemMeta();
if (_name != null)
{
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', _name));
}
else
{
meta.setDisplayName("Custom Pet");
}
meta.setLore(_lines);
itemStack.setItemMeta(meta);
return itemStack;
}
public static CustomPet getCustomPet(Player player)
{
if (_customPet.containsKey(player))

View File

@ -16,6 +16,7 @@ public abstract class CustomPetAgeable extends CustomPet
public void setBaby(boolean baby)
{
_baby = baby;
addLine("Age", (baby) ? "Baby" : "Adult");
}
protected boolean isBaby()

View File

@ -1,5 +1,6 @@
package mineplex.core.pet.custom;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -20,21 +21,25 @@ public abstract class CustomPetEquipment extends CustomPetAgeable
public void setHelmet(ItemStack helmet)
{
_helmet = helmet;
addLine("Helmet", (helmet.getType() == Material.AIR) ? "None" : helmet.getItemMeta().getDisplayName());
}
public void setChestplate(ItemStack chestplate)
{
_chestplate = chestplate;
addLine("Chestplate", (chestplate.getType() == Material.AIR) ? "None" : chestplate.getItemMeta().getDisplayName());
}
public void setLeggings(ItemStack leggings)
{
_leggings = leggings;
addLine("Leggings", (leggings.getType() == Material.AIR) ? "None" : leggings.getItemMeta().getDisplayName());
}
public void setBoots(ItemStack boots)
{
_boots = boots;
addLine("Boots", (boots.getType() == Material.AIR) ? "None" : boots.getItemMeta().getDisplayName());
}
public ItemStack getHelmet()

View File

@ -1,5 +1,6 @@
package mineplex.core.pet.custom;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -8,7 +9,15 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.cosmetic.ui.page.custompet.CustomPetAgePage;
import mineplex.core.cosmetic.ui.page.custompet.CustomPetBasePage;
import mineplex.core.cosmetic.ui.page.custompet.CustomPetConfirmPage;
import mineplex.core.cosmetic.ui.page.custompet.age.CustomPetAgePage;
import mineplex.core.cosmetic.ui.page.custompet.equipment.CustomPetBootsPage;
import mineplex.core.cosmetic.ui.page.custompet.equipment.CustomPetChestplatePage;
import mineplex.core.cosmetic.ui.page.custompet.equipment.CustomPetHelmetPage;
import mineplex.core.cosmetic.ui.page.custompet.equipment.CustomPetLeggingsPage;
import mineplex.core.cosmetic.ui.page.custompet.name.CustomPetNamePage;
import mineplex.core.cosmetic.ui.page.custompet.zombie.CustomPetZombieTypePage;
import mineplex.core.disguise.DisguiseFactory;
import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.donation.DonationManager;
@ -16,9 +25,12 @@ import mineplex.core.donation.DonationManager;
public class CustomPetZombie extends CustomPetEquipment
{
private boolean _villager = false;
public CustomPetZombie(Player player)
{
super(player, EntityType.ZOMBIE);
addTypeLine("Zombie");
}
@Override
@ -47,7 +59,7 @@ public class CustomPetZombie extends CustomPetEquipment
if (getName() != null)
{
disguiseZombie.setCustomNameVisible(true);
disguiseZombie.setName(getName());
disguiseZombie.setName(ChatColor.translateAlternateColorCodes('&', getName()));
}
else
{
@ -56,16 +68,82 @@ public class CustomPetZombie extends CustomPetEquipment
}
@Override
public GadgetPage createNextStep(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager)
public GadgetPage getNextStep(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager)
{
switch (_step)
{
case 0:
_step++;
return new CustomPetNamePage(plugin, shop, clientManager, donationManager, "Zombie Name", _player);
case 1:
_step++;
return new CustomPetAgePage(plugin, shop, clientManager, donationManager, "Zombie Age", _player);
case 2:
_step++;
return new CustomPetHelmetPage(plugin, shop, clientManager, donationManager, "Zombie Helmet", _player);
case 3:
_step++;
return new CustomPetChestplatePage(plugin, shop, clientManager, donationManager, "Zombie Chestplate", _player);
case 4:
_step++;
return new CustomPetLeggingsPage(plugin, shop, clientManager, donationManager, "Zombie Leggings", _player);
case 5:
_step++;
return new CustomPetBootsPage(plugin, shop, clientManager, donationManager, "Zombie Boots", _player);
case 6:
_step++;
return new CustomPetZombieTypePage(plugin, shop, clientManager, donationManager, "Zombie Type", _player);
case 7:
_step++;
return new CustomPetConfirmPage(plugin, shop, clientManager, donationManager, "Confirm", _player);
default:
_step++;
return new CustomPetAgePage(plugin, shop, clientManager, donationManager, "Zombie Age", _player);
}
}
@Override
public GadgetPage getPreviousStep(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager)
{
switch (_step)
{
case 1:
_step--;
return new CustomPetBasePage(plugin, shop, clientManager, donationManager, "Custom Pet", _player);
case 2:
_step--;
return new CustomPetNamePage(plugin, shop, clientManager, donationManager, "Zombie Name", _player);
case 3:
_step--;
return new CustomPetAgePage(plugin, shop, clientManager, donationManager, "Zombie Age", _player);
case 4:
_step--;
return new CustomPetHelmetPage(plugin, shop, clientManager, donationManager, "Zombie Helmet", _player);
case 5:
_step--;
return new CustomPetChestplatePage(plugin, shop, clientManager, donationManager, "Zombie Chestplate", _player);
case 6:
_step--;
return new CustomPetLeggingsPage(plugin, shop, clientManager, donationManager, "Zombie Leggings", _player);
case 7:
_step--;
return new CustomPetBootsPage(plugin, shop, clientManager, donationManager, "Zombie Boots", _player);
case 8:
_step--;
return new CustomPetZombieTypePage(plugin, shop, clientManager, donationManager, "Zombie Type", _player);
default:
_step--;
return new CustomPetBasePage(plugin, shop, clientManager, donationManager, "Custom Pet", _player);
}
}
public void setVillager(boolean villager)
{
_villager = villager;
}
public boolean isVillager()
{
return _villager;
}
}