mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-21 07:59:19 +00:00
Redo getItem method
This commit is contained in:
@@ -2,6 +2,8 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public class Cosmetic {
|
||||
@@ -9,7 +11,6 @@ public class Cosmetic {
|
||||
private String id;
|
||||
private String permission;
|
||||
private CosmeticSlot slot;
|
||||
private boolean equipable; // This simply means if a player can put it on their body.
|
||||
private boolean dyable;
|
||||
|
||||
protected Cosmetic(String id, ConfigurationNode config) {
|
||||
@@ -18,7 +19,6 @@ public class Cosmetic {
|
||||
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
|
||||
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
|
||||
|
||||
setEquipable(false);
|
||||
setDyable(config.node("dyeable").getBoolean(false));
|
||||
|
||||
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
|
||||
@@ -53,14 +53,6 @@ public class Cosmetic {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setEquipable(boolean equipable) {
|
||||
this.equipable = equipable;
|
||||
}
|
||||
|
||||
public boolean isEquipable() {
|
||||
return equipable;
|
||||
}
|
||||
|
||||
public void setDyable(boolean dyable) {
|
||||
this.dyable = dyable;
|
||||
}
|
||||
@@ -73,4 +65,9 @@ public class Cosmetic {
|
||||
public void update(CosmeticUser user) {
|
||||
// Override
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getItem() {
|
||||
return null; // Override
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ public class CosmeticArmorType extends Cosmetic {
|
||||
|
||||
this.itemStack = generateItemStack(config.node("item"));
|
||||
this.equipSlot = InventoryUtils.getEquipmentSlot(getSlot());
|
||||
|
||||
setEquipable(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,7 +35,8 @@ public class CosmeticArmorType extends Cosmetic {
|
||||
PacketManager.equipmentSlotUpdate(player, getSlot(), PlayerUtils.getNearbyPlayers(player));
|
||||
}
|
||||
|
||||
public ItemStack getCosmeticItem() {
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return this.itemStack.clone();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -56,7 +57,16 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
|
||||
}
|
||||
|
||||
public ItemStack getBackpackItem() {
|
||||
public void rotateEntity(int entityId, Location location) {
|
||||
//PacketManager.sendRotationPacket(entityId, location, true);
|
||||
}
|
||||
|
||||
public void moveEntity(int entityId, Location location) {
|
||||
//PacketManager.sendTeleportPacket();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
if (this.backpackItem == null ) {
|
||||
MessagesUtil.sendDebugMessages("Backpack item was null for " + getId());
|
||||
this.backpackItem = generateItemStack(config.node("item"));
|
||||
|
||||
@@ -23,7 +23,6 @@ public class CosmeticMainhandType extends Cosmetic {
|
||||
|
||||
this.itemStack = generateItemStack(config.node("item"));
|
||||
|
||||
setEquipable(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +47,8 @@ public class CosmeticMainhandType extends Cosmetic {
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return itemStack.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,19 +149,8 @@ public class CosmeticUser {
|
||||
if (hideCosmetics) {
|
||||
return getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
|
||||
}
|
||||
if (cosmetic instanceof CosmeticArmorType) {
|
||||
CosmeticArmorType cosmetic1 = (CosmeticArmorType) cosmetic;
|
||||
item = cosmetic1.getCosmeticItem();
|
||||
MessagesUtil.sendDebugMessages("GetUserCosemticUser Armor");
|
||||
}
|
||||
if (cosmetic instanceof CosmeticMainhandType) {
|
||||
CosmeticMainhandType cosmetic1 = (CosmeticMainhandType) cosmetic;
|
||||
item = cosmetic1.getItemStack();
|
||||
}
|
||||
if (cosmetic instanceof CosmeticBackpackType) {
|
||||
CosmeticBackpackType cosmetic1 = (CosmeticBackpackType) cosmetic;
|
||||
item = cosmetic1.getBackpackItem();
|
||||
MessagesUtil.sendDebugMessages("GetUserCosemticUser Backpack");
|
||||
if (cosmetic instanceof CosmeticArmorType || cosmetic instanceof CosmeticMainhandType || cosmetic instanceof CosmeticBackpackType) {
|
||||
item = cosmetic.getItem();
|
||||
}
|
||||
if (cosmetic instanceof CosmeticBalloonType) {
|
||||
item = new ItemStack(Material.LEATHER_HORSE_ARMOR);
|
||||
|
||||
Reference in New Issue
Block a user