mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-28 15:41:04 +01:00
fixed an issue with citizens
This commit is contained in:
parent
3e90285fdd
commit
d555fe71b4
@ -1,15 +1,13 @@
|
|||||||
package net.Indyuce.mmoitems.api.event;
|
package net.Indyuce.mmoitems.api.event;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class ItemBuildEvent extends Event implements Cancellable {
|
public class ItemBuildEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private ItemStack itemStack;
|
private ItemStack itemStack;
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
public ItemBuildEvent(ItemStack itemStack) {
|
public ItemBuildEvent(ItemStack itemStack) {
|
||||||
this.itemStack = itemStack;
|
this.itemStack = itemStack;
|
||||||
@ -19,6 +17,29 @@ public class ItemBuildEvent extends Event implements Cancellable {
|
|||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemBuildEvent setItemStack(ItemStack itemStack) {
|
||||||
|
this.itemStack = itemStack;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated See {@link #setCancelled(boolean)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return itemStack == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Set the generated item stack to null instead. Cancelling
|
||||||
|
* the build event does not cancel the process that generated the item
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
if (cancel)
|
||||||
|
itemStack = null;
|
||||||
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
@ -26,19 +47,4 @@ public class ItemBuildEvent extends Event implements Cancellable {
|
|||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuildEvent setItemStack(ItemStack itemStack) {
|
|
||||||
this.itemStack = itemStack;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
this.cancelled = cancel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import io.lumine.mythic.lib.api.item.ItemTag;
|
|||||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||||
import io.lumine.mythic.lib.api.util.LegacyComponent;
|
import io.lumine.mythic.lib.api.util.LegacyComponent;
|
||||||
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
|
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
|
||||||
import io.lumine.mythicenchants.enchants.MythicEnchant;
|
|
||||||
import net.Indyuce.mmoitems.ItemStats;
|
import net.Indyuce.mmoitems.ItemStats;
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import net.Indyuce.mmoitems.api.Type;
|
import net.Indyuce.mmoitems.api.Type;
|
||||||
@ -15,7 +14,6 @@ import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
|||||||
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
|
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
|
||||||
import net.Indyuce.mmoitems.stat.DisplayName;
|
import net.Indyuce.mmoitems.stat.DisplayName;
|
||||||
import net.Indyuce.mmoitems.stat.Enchants;
|
import net.Indyuce.mmoitems.stat.Enchants;
|
||||||
import net.Indyuce.mmoitems.stat.data.EnchantListData;
|
|
||||||
import net.Indyuce.mmoitems.stat.data.MaterialData;
|
import net.Indyuce.mmoitems.stat.data.MaterialData;
|
||||||
import net.Indyuce.mmoitems.stat.data.StringListData;
|
import net.Indyuce.mmoitems.stat.data.StringListData;
|
||||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||||
@ -26,7 +24,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeModifier;
|
import org.bukkit.attribute.AttributeModifier;
|
||||||
import org.bukkit.attribute.AttributeModifier.Operation;
|
import org.bukkit.attribute.AttributeModifier.Operation;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
@ -261,19 +258,18 @@ public class ItemStackBuilder {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public ItemStack build() {
|
public ItemStack build() {
|
||||||
ItemBuildEvent itemBuildEvent = new ItemBuildEvent(buildNBT().toItem());
|
ItemBuildEvent event = new ItemBuildEvent(buildNBT().toItem());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(itemBuildEvent);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (itemBuildEvent.isCancelled()) {
|
return event.getItemStack();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return itemBuildEvent.getItemStack();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack displayBuild() {
|
/**
|
||||||
|
* Builds the item without calling a build event
|
||||||
|
*/
|
||||||
|
public ItemStack buildSilently() {
|
||||||
return buildNBT().toItem();
|
return buildNBT().toItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Builds the item
|
* @return Builds the item
|
||||||
*/
|
*/
|
||||||
|
@ -483,25 +483,30 @@ public class PlayerData {
|
|||||||
return get(player.getUniqueId());
|
return get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See {@link #has(UUID)}
|
||||||
|
*
|
||||||
|
* @return If player data is loaded for a player
|
||||||
|
*/
|
||||||
|
public static boolean has(Player player) {
|
||||||
|
return has(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to check if the UUID is associated to a real player
|
||||||
|
* or a Citizens/Sentinel NPC. Citizens NPCs do not have
|
||||||
|
* a player data associated to them so it's an easy O(1) way
|
||||||
|
* to check instead of checking for an entity metadta.
|
||||||
|
*
|
||||||
|
* @return If player data is loaded for a player UUID
|
||||||
|
*/
|
||||||
|
public static boolean has(UUID uuid) {
|
||||||
|
return data.containsKey(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static PlayerData get(@NotNull UUID uuid) {
|
public static PlayerData get(@NotNull UUID uuid) {
|
||||||
|
return Objects.requireNonNull(data.get(uuid), "Player data not loaded");
|
||||||
// Already loaded? lets gooo
|
|
||||||
PlayerData pd = data.get(uuid);
|
|
||||||
|
|
||||||
// Attempt to load now
|
|
||||||
if (pd == null) {
|
|
||||||
load(uuid);
|
|
||||||
pd = data.get(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Um shit
|
|
||||||
if (pd == null) {
|
|
||||||
MMOItems.print(Level.SEVERE, "Incomplete initialization of PlayerData. This error is only a result of another one caused EARLIER (probably during server startup).", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
//noinspection ConstantConditions
|
|
||||||
return pd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,6 @@ import io.lumine.mythic.lib.MythicLib;
|
|||||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||||
import io.lumine.mythic.lib.api.util.AltChar;
|
import io.lumine.mythic.lib.api.util.AltChar;
|
||||||
import io.lumine.mythic.lib.api.util.LegacyComponent;
|
|
||||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||||
import io.lumine.mythic.utils.adventure.text.Component;
|
import io.lumine.mythic.utils.adventure.text.Component;
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
@ -24,13 +23,8 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ItemBrowser extends PluginInventory {
|
public class ItemBrowser extends PluginInventory {
|
||||||
private final Map<String, ItemStack> cached = new LinkedHashMap<>();
|
private final Map<String, ItemStack> cached = new LinkedHashMap<>();
|
||||||
@ -38,9 +32,9 @@ public class ItemBrowser extends PluginInventory {
|
|||||||
private final Type type;
|
private final Type type;
|
||||||
private boolean deleteMode;
|
private boolean deleteMode;
|
||||||
|
|
||||||
private static final int[] slots = { 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34 };
|
// Slots used to display items based on the item type explored
|
||||||
//private static final int[] slotsAlt = { 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43 };
|
private static final int[] slots = {10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34};
|
||||||
private static final int[] slotsAlt = { 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34 };
|
private static final int[] slotsAlt = {1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34};
|
||||||
|
|
||||||
public ItemBrowser(Player player) {
|
public ItemBrowser(Player player) {
|
||||||
this(player, null);
|
this(player, null);
|
||||||
@ -52,18 +46,17 @@ public class ItemBrowser extends PluginInventory {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] getUsedSlots(@Nullable Type forType) { return forType == null ? slots : forType.isFourGUIMode() ? slotsAlt : slots; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
int[] usedSlots = getUsedSlots(type);
|
int[] usedSlots = type != null && type.isFourGUIMode() ? slotsAlt : slots;
|
||||||
int min = (page - 1) * usedSlots.length;
|
int min = (page - 1) * usedSlots.length;
|
||||||
int max = page * usedSlots.length;
|
int max = page * usedSlots.length;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* displays all possible item types if no type was previously selected
|
* Displays all possible item types if no
|
||||||
* by the player
|
* type was previously selected by the player
|
||||||
*/
|
*/
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
Inventory inv = Bukkit.createInventory(this, 54, "Item Explorer");
|
Inventory inv = Bukkit.createInventory(this, 54, "Item Explorer");
|
||||||
@ -122,7 +115,7 @@ public class ItemBrowser extends PluginInventory {
|
|||||||
List<MMOItemTemplate> templates = new ArrayList<>(MMOItems.plugin.getTemplates().getTemplates(type));
|
List<MMOItemTemplate> templates = new ArrayList<>(MMOItems.plugin.getTemplates().getTemplates(type));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* displays every item in a specific type. items are cached inside the
|
* Displays every item in a specific type. Items are cached inside the
|
||||||
* map at the top to reduce performance impact and are directly rendered
|
* map at the top to reduce performance impact and are directly rendered
|
||||||
*/
|
*/
|
||||||
Inventory inv = Bukkit.createInventory(this, 54, (deleteMode ? ("Delete Mode: ") : ("Item Explorer: ")) + type.getName());
|
Inventory inv = Bukkit.createInventory(this, 54, (deleteMode ? ("Delete Mode: ") : ("Item Explorer: ")) + type.getName());
|
||||||
@ -134,25 +127,21 @@ public class ItemBrowser extends PluginInventory {
|
|||||||
inv.setItem(usedSlots[n++], error);
|
inv.setItem(usedSlots[n++], error);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NBTItem nbtItem = NBTItem.get(item);
|
|
||||||
List<Component> lore = nbtItem.getLoreComponents();
|
|
||||||
|
|
||||||
lore.add(Component.empty());
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
List<String> lore = meta.getLore();
|
||||||
|
lore.add("");
|
||||||
|
|
||||||
if (deleteMode) {
|
if (deleteMode) {
|
||||||
lore.add(LegacyComponent.parse(
|
lore.add(ChatColor.RED + AltChar.cross + " CLICK TO DELETE " + AltChar.cross);
|
||||||
ChatColor.RED + AltChar.cross + " CLICK TO DELETE " + AltChar.cross));
|
meta.setDisplayName(ChatColor.RED + "DELETE: " + (meta.hasDisplayName() ? meta.getDisplayName() : MMOUtils.getDisplayName(item)));
|
||||||
nbtItem.setDisplayNameComponent(Component.text()
|
} else {
|
||||||
.append(LegacyComponent.parse(ChatColor.RED + "DELETE: "))
|
lore.add(ChatColor.YELLOW + AltChar.smallListDash + " Left click to obtain this item.");
|
||||||
.append(nbtItem.getDisplayNameComponent())
|
lore.add(ChatColor.YELLOW + AltChar.smallListDash + " Right click to edit this item.");
|
||||||
.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lore.add(LegacyComponent.parse(ChatColor.YELLOW + AltChar.smallListDash + " Left click to obtain this item."));
|
item.setItemMeta(meta);
|
||||||
lore.add(LegacyComponent.parse(ChatColor.YELLOW + AltChar.smallListDash + " Right click to edit this item."));
|
cached.put(template.getId(), item);
|
||||||
|
|
||||||
nbtItem.setLoreComponents(lore);
|
|
||||||
|
|
||||||
cached.put(template.getId(), nbtItem.toItem());
|
|
||||||
|
|
||||||
inv.setItem(usedSlots[n++], cached.get(template.getId()));
|
inv.setItem(usedSlots[n++], cached.get(template.getId()));
|
||||||
}
|
}
|
||||||
@ -224,36 +213,26 @@ public class ItemBrowser extends PluginInventory {
|
|||||||
if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Next Page")) {
|
if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Next Page")) {
|
||||||
page++;
|
page++;
|
||||||
open();
|
open();
|
||||||
}
|
} else if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Previous Page")) {
|
||||||
|
|
||||||
else if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Previous Page")) {
|
|
||||||
page--;
|
page--;
|
||||||
open();
|
open();
|
||||||
}
|
} else if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + AltChar.rightArrow + " Back"))
|
||||||
|
|
||||||
else if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + AltChar.rightArrow + " Back"))
|
|
||||||
new ItemBrowser(getPlayer()).open();
|
new ItemBrowser(getPlayer()).open();
|
||||||
|
|
||||||
else if (item.getItemMeta().getDisplayName().equals(ChatColor.RED + "Cancel Deletion")) {
|
else if (item.getItemMeta().getDisplayName().equals(ChatColor.RED + "Cancel Deletion")) {
|
||||||
deleteMode = false;
|
deleteMode = false;
|
||||||
open();
|
open();
|
||||||
}
|
} else if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Create New"))
|
||||||
|
|
||||||
else if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Create New"))
|
|
||||||
new NewItemEdition(this).enable("Write in the chat the text you want.");
|
new NewItemEdition(this).enable("Write in the chat the text you want.");
|
||||||
|
|
||||||
else if (type != null && item.getItemMeta().getDisplayName().equals(ChatColor.RED + "Delete Item")) {
|
else if (type != null && item.getItemMeta().getDisplayName().equals(ChatColor.RED + "Delete Item")) {
|
||||||
deleteMode = true;
|
deleteMode = true;
|
||||||
open();
|
open();
|
||||||
}
|
} else if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Download Default Resourcepack")) {
|
||||||
|
|
||||||
else if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Download Default Resourcepack")) {
|
|
||||||
MythicLib.plugin.getVersion().getWrapper().sendJson(getPlayer(),
|
MythicLib.plugin.getVersion().getWrapper().sendJson(getPlayer(),
|
||||||
"[{\"text\":\"Click to download!\",\"color\":\"green\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://drive.google.com/uc?id=1FjV7y-2cn8qzSiktZ2CUXmkdjepXdj5N\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":[\"\",{\"text\":\"https://drive.google.com/uc?id=1FjV7y-2cn8qzSiktZ2CUXmkdjepXdj5N\",\"italic\":true,\"color\":\"white\"}]}}]");
|
"[{\"text\":\"Click to download!\",\"color\":\"green\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://drive.google.com/uc?id=1FjV7y-2cn8qzSiktZ2CUXmkdjepXdj5N\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":[\"\",{\"text\":\"https://drive.google.com/uc?id=1FjV7y-2cn8qzSiktZ2CUXmkdjepXdj5N\",\"italic\":true,\"color\":\"white\"}]}}]");
|
||||||
getPlayer().closeInventory();
|
getPlayer().closeInventory();
|
||||||
}
|
} else if (type == null && !item.getItemMeta().getDisplayName().equals(ChatColor.RED + "- No type -"))
|
||||||
|
|
||||||
else if (type == null && !item.getItemMeta().getDisplayName().equals(ChatColor.RED + "- No type -"))
|
|
||||||
new ItemBrowser(getPlayer(), MMOItems.plugin.getTypes().get(NBTItem.get(item).getString("typeId"))).open();
|
new ItemBrowser(getPlayer(), MMOItems.plugin.getTypes().get(NBTItem.get(item).getString("typeId"))).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ public abstract class EditionInventory extends PluginInventory {
|
|||||||
* can reroll the stats.
|
* can reroll the stats.
|
||||||
*/
|
*/
|
||||||
public void updateCachedItem() {
|
public void updateCachedItem() {
|
||||||
cachedItem = template.newBuilder(PlayerData.get(getPlayer()).getRPG()).build().newBuilder().displayBuild();
|
cachedItem = template.newBuilder(PlayerData.get(getPlayer()).getRPG()).build().newBuilder().buildSilently();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getCachedItem() {
|
public ItemStack getCachedItem() {
|
||||||
|
@ -13,7 +13,6 @@ import net.Indyuce.mmoitems.api.Type;
|
|||||||
import net.Indyuce.mmoitems.api.interaction.util.InteractItem;
|
import net.Indyuce.mmoitems.api.interaction.util.InteractItem;
|
||||||
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
|
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
|
||||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -136,11 +135,12 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onArmorEquip(ArmorEquipEvent event) {
|
public void onArmorEquip(ArmorEquipEvent event) {
|
||||||
Player p = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
RPGPlayer rpgPlayer = PlayerData.get(p.getUniqueId()).getRPG();
|
if (!PlayerData.has(player))
|
||||||
NBTItem item = NBTItem.get(event.getNewArmorPiece());
|
return;
|
||||||
|
|
||||||
if (!rpgPlayer.canUse(item, true))
|
NBTItem item = NBTItem.get(event.getNewArmorPiece());
|
||||||
|
if (!PlayerData.get(player).getRPG().canUse(item, true))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user