From f679551b9955990f121c0115c9a12ae313be7382 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Mon, 4 Jul 2022 12:55:05 +0200 Subject: [PATCH] Fixed shift click profile check --- .../net/Indyuce/mmocore/gui/PlayerStats.java | 513 +++++++++--------- .../mmocore/gui/api/GeneratedInventory.java | 2 +- .../listener/option/PlayerProfileCheck.java | 11 +- 3 files changed, 265 insertions(+), 261 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java b/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java index 481c7267..16bbd451 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java +++ b/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java @@ -5,18 +5,18 @@ import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.stat.modifier.StatModifier; import io.lumine.mythic.lib.version.VersionMaterial; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; +import net.Indyuce.mmocore.api.util.math.format.DelayFormat; +import net.Indyuce.mmocore.experience.Booster; +import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.gui.api.EditableInventory; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.Placeholders; import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; -import net.Indyuce.mmocore.api.player.PlayerData; -import net.Indyuce.mmocore.player.stats.StatInfo; -import net.Indyuce.mmocore.api.util.math.format.DelayFormat; -import net.Indyuce.mmocore.experience.Booster; -import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.party.AbstractParty; +import net.Indyuce.mmocore.player.stats.StatInfo; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; @@ -28,310 +28,323 @@ import org.bukkit.inventory.meta.SkullMeta; import java.util.Objects; public class PlayerStats extends EditableInventory { - public PlayerStats() { - super("player-stats"); - } + public PlayerStats() { + super("player-stats"); + } - @Override - public InventoryItem load(String function, ConfigurationSection config) { + @Override + public InventoryItem load(String function, ConfigurationSection config) { - if (function.equals("boost")) - return new BoostItem(config); + if (function.equals("boost")) + return new BoostItem(config); - if (function.equals("boost-next")) - return new SimplePlaceholderItem(config) { + if (function.equals("boost-next")) + return new SimplePlaceholderItem(config) { - @Override - public boolean hasDifferentDisplay() { - return true; - } + @Override + public boolean hasDifferentDisplay() { + return true; + } - @Override - public boolean canDisplay(PlayerStatsInventory inv) { - InventoryItem boost = inv.getByFunction("boost"); - return boost != null && inv.boostOffset + boost.getSlots().size() < MMOCore.plugin.boosterManager.getActive().size(); - } - }; + @Override + public boolean canDisplay(PlayerStatsInventory inv) { + InventoryItem boost = inv.getByFunction("boost"); + return boost != null && inv.boostOffset + boost.getSlots().size() < MMOCore.plugin.boosterManager.getActive().size(); + } + }; - if (function.equals("boost-previous")) - return new SimplePlaceholderItem(config) { + if (function.equals("boost-previous")) + return new SimplePlaceholderItem(config) { - @Override - public boolean canDisplay(PlayerStatsInventory inv) { - return inv.boostOffset > 0; - } - }; + @Override + public boolean canDisplay(PlayerStatsInventory inv) { + return inv.boostOffset > 0; + } + }; - if (function.equals("party")) - return new PartyMoraleItem(config); + if (function.equals("party")) + return new PartyMoraleItem(config); - if (function.startsWith("profession_")) { - String id = function.substring("profession_".length()).toLowerCase(); - Validate.isTrue(MMOCore.plugin.professionManager.has(id)); - Profession profession = MMOCore.plugin.professionManager.get(id); + if (function.startsWith("profession_")) { + String id = function.substring("profession_".length()).toLowerCase(); + Validate.isTrue(MMOCore.plugin.professionManager.has(id)); + Profession profession = MMOCore.plugin.professionManager.get(id); - return new InventoryItem(config) { + return new InventoryItem(config) { - @Override - public boolean hasDifferentDisplay() { - return true; - } + @Override + public boolean hasDifferentDisplay() { + return true; + } - @Override - public Placeholders getPlaceholders(GeneratedInventory inv, int n) { + @Override + public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) { - Placeholders holders = new Placeholders(); - net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.getPlayerData().getStats(); + Placeholders holders = new Placeholders(); + net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.target.getStats(); - double ratio = inv.getPlayerData().getCollectionSkills().getExperience(profession) - / (double) inv.getPlayerData().getCollectionSkills().getLevelUpExperience(profession); + double ratio = inv.target.getCollectionSkills().getExperience(profession) + / (double) inv.target.getCollectionSkills().getLevelUpExperience(profession); - String bar = "" + ChatColor.BOLD; - int chars = (int) (ratio * 20); - for (int j = 0; j < 20; j++) - bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|"; + String bar = "" + ChatColor.BOLD; + int chars = (int) (ratio * 20); + for (int j = 0; j < 20; j++) + bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|"; - // holders.register("profession", type.getName()); - holders.register("progress", bar); - holders.register("level", "" + inv.getPlayerData().getCollectionSkills().getLevel(profession)); - holders.register("xp", inv.getPlayerData().getCollectionSkills().getExperience(profession)); - holders.register("percent", decimal.format(ratio * 100)); - for (StatInfo stat : MMOCore.plugin.statManager.getLoaded()) - if (Objects.equals(stat.profession, profession)) - holders.register(stat.name.toLowerCase(), stat.format(stats.getStat(stat.name))); + // holders.register("profession", type.getName()); + holders.register("progress", bar); + holders.register("level", "" + inv.target.getCollectionSkills().getLevel(profession)); + holders.register("xp", inv.target.getCollectionSkills().getExperience(profession)); + holders.register("percent", decimal.format(ratio * 100)); + for (StatInfo stat : MMOCore.plugin.statManager.getLoaded()) + if (Objects.equals(stat.profession, profession)) + holders.register(stat.name.toLowerCase(), stat.format(stats.getStat(stat.name))); - return holders; - } - }; - } + return holders; + } + }; + } - if (function.equals("profile")) - return new PlayerProfileItem(config); + if (function.equals("profile")) + return new PlayerProfileItem(config); - if (function.equals("stats")) - return new InventoryItem(config) { + if (function.equals("stats")) + return new InventoryItem(config) { - @Override - public boolean hasDifferentDisplay() { - return true; - } + @Override + public boolean hasDifferentDisplay() { + return true; + } - @Override - public Placeholders getPlaceholders(GeneratedInventory inv, int n) { - return new Placeholders() { - final net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.getPlayerData().getStats(); + @Override + public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) { + return new Placeholders() { + final net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.target.getStats(); - public String apply(Player player, String str) { - while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) { - String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}")); - String replaced; + public String apply(Player player, String str) { + while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) { + String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}")); + String replaced; - if (holder.endsWith("_base")) { - StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5))); - replaced = info.format(stats.getBase(info.name)); - } else if (holder.endsWith("_extra")) { - StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5))); - replaced = info.format(stats.getStat(info.name) - stats.getBase(info.name)); - } else if (holder.startsWith("attribute_")) { - PlayerAttribute attr = MMOCore.plugin.attributeManager.get(holder.substring(10).replace("_", "-").toLowerCase()); - replaced = String.valueOf(inv.getPlayerData().getAttributes().getAttribute(attr)); - } else { - StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder)); - replaced = info.format(stats.getStat(info.name)); - } + if (holder.endsWith("_base")) { + StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5))); + replaced = info.format(stats.getBase(info.name)); + } else if (holder.endsWith("_extra")) { + StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5))); + replaced = info.format(stats.getStat(info.name) - stats.getBase(info.name)); + } else if (holder.startsWith("attribute_")) { + PlayerAttribute attr = MMOCore.plugin.attributeManager.get(holder.substring(10).replace("_", "-").toLowerCase()); + replaced = String.valueOf(inv.target.getAttributes().getAttribute(attr)); + } else { + StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder)); + replaced = info.format(stats.getStat(info.name)); + } - str = str.replace("{" + holder + "}", replaced); - } + str = str.replace("{" + holder + "}", replaced); + } - // External placeholders - return MMOCore.plugin.placeholderParser.parse(player, str); - } - }; - } - }; + // External placeholders + return MMOCore.plugin.placeholderParser.parse(player, str); + } + }; + } + }; - return new SimplePlaceholderItem(config); - } + return new SimplePlaceholderItem(config); + } - public PlayerStatsInventory newInventory(PlayerData data) { - return new PlayerStatsInventory(data, this); - } + public PlayerStatsInventory newInventory(PlayerData invTarget, PlayerData opening) { + return new PlayerStatsInventory(invTarget, opening, this); + } - public class PlayerStatsInventory extends GeneratedInventory { - private int boostOffset; + public PlayerStatsInventory newInventory(PlayerData player) { + return new PlayerStatsInventory(player, player, this); + } - public PlayerStatsInventory(PlayerData playerData, EditableInventory editable) { - super(playerData, editable); - } + public class PlayerStatsInventory extends GeneratedInventory { + private final PlayerData target; - @Override - public String calculateName() { - return getName(); - } + private int boostOffset; - @Override - public void whenClicked(InventoryClickEvent event, InventoryItem item) { - if (item.hasFunction()) - if (item.getFunction().equals("boost-next")) { - boostOffset++; - open(); + /** + * @param invTarget Target player + * @param opening Player opening the inventory + * @param inv Corresponding editable inventory + */ + public PlayerStatsInventory(PlayerData invTarget, PlayerData opening, EditableInventory inv) { + super(opening, inv); - } else if (item.getFunction().equals("boost-previous")) { - boostOffset--; - open(); - } - } - } + this.target = invTarget; + } - private ItemStack amount(ItemStack item, int amount) { - item.setAmount(amount); - return item; - } + @Override + public String calculateName() { + return getName(); + } - public static class PartyMoraleItem extends InventoryItem { - public PartyMoraleItem(ConfigurationSection config) { - super(config); - } + @Override + public void whenClicked(InventoryClickEvent event, InventoryItem item) { + if (item.hasFunction()) + if (item.getFunction().equals("boost-next")) { + boostOffset++; + open(); - @Override - public Placeholders getPlaceholders(GeneratedInventory inv, int n) { - Placeholders holders = new Placeholders(); + } else if (item.getFunction().equals("boost-previous")) { + boostOffset--; + open(); + } + } + } - int count = inv.getPlayerData().getParty().getOnlineMembers().size(); - holders.register("count", "" + count); - for (StatModifier buff : MMOCore.plugin.partyManager.getBonuses()) - holders.register("buff_" + buff.getStat().toLowerCase(), buff.multiply(count - 1).toString()); + private ItemStack amount(ItemStack item, int amount) { + item.setAmount(amount); + return item; + } - return holders; - } + public static class PartyMoraleItem extends InventoryItem { + public PartyMoraleItem(ConfigurationSection config) { + super(config); + } - @Override - public boolean canDisplay(GeneratedInventory inv) { - AbstractParty party = inv.getPlayerData().getParty(); - return party != null && party.getOnlineMembers().size() > 1; - } - } + @Override + public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) { + Placeholders holders = new Placeholders(); - public static class PlayerProfileItem extends InventoryItem { - public PlayerProfileItem(ConfigurationSection config) { - super(config); - } + int count = inv.target.getParty().getOnlineMembers().size(); + holders.register("count", "" + count); + for (StatModifier buff : MMOCore.plugin.partyManager.getBonuses()) + holders.register("buff_" + buff.getStat().toLowerCase(), buff.multiply(count - 1).toString()); - @Override - public ItemStack display(GeneratedInventory inv, int n) { - ItemStack disp = super.display(inv, n); - if (disp.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) { - SkullMeta meta = (SkullMeta) disp.getItemMeta(); - inv.dynamicallyUpdateItem(this, n, disp, current -> { - meta.setOwningPlayer(inv.getPlayer()); - current.setItemMeta(meta); - }); - } - return disp; - } + return holders; + } - @Override - public Placeholders getPlaceholders(GeneratedInventory inv, int n) { - PlayerData data = inv.getPlayerData(); - Placeholders holders = new Placeholders(); + @Override + public boolean canDisplay(PlayerStatsInventory inv) { + AbstractParty party = inv.target.getParty(); + return party != null && party.getOnlineMembers().size() > 1; + } + } - int nextLevelExp = inv.getPlayerData().getLevelUpExperience(); - double ratio = (double) data.getExperience() / (double) nextLevelExp; + public static class PlayerProfileItem extends InventoryItem { + public PlayerProfileItem(ConfigurationSection config) { + super(config); + } - StringBuilder bar = new StringBuilder("" + ChatColor.BOLD); - int chars = (int) (ratio * 20); - for (int j = 0; j < 20; j++) - bar.append(j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "").append("|"); + @Override + public ItemStack display(PlayerStatsInventory inv, int n) { + ItemStack disp = super.display(inv, n); + if (disp.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) { + SkullMeta meta = (SkullMeta) disp.getItemMeta(); + inv.dynamicallyUpdateItem(this, n, disp, current -> { + meta.setOwningPlayer(inv.target.getPlayer()); + current.setItemMeta(meta); + }); + } + return disp; + } - holders.register("percent", decimal.format(ratio * 100)); - holders.register("exp", MythicLib.plugin.getMMOConfig().decimal.format(data.getExperience())); - holders.register("level", "" + data.getLevel()); - holders.register("class_points", "" + data.getClassPoints()); - holders.register("skill_points", "" + data.getSkillPoints()); - holders.register("attribute_points", "" + data.getAttributePoints()); - holders.register("progress", bar.toString()); - holders.register("next_level", "" + nextLevelExp); - if (data.isOnline()) - holders.register("player", "" + data.getPlayer().getName()); - holders.register("class", "" + data.getProfess().getName()); + @Override + public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) { + PlayerData data = inv.target; + Placeholders holders = new Placeholders(); - return holders; - } - } + int nextLevelExp = inv.target.getLevelUpExperience(); + double ratio = (double) data.getExperience() / (double) nextLevelExp; - public class BoostItem extends SimplePlaceholderItem { - private final InventoryItem noBoost, mainLevel, profession; + StringBuilder bar = new StringBuilder("" + ChatColor.BOLD); + int chars = (int) (ratio * 20); + for (int j = 0; j < 20; j++) + bar.append(j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "").append("|"); - public BoostItem(ConfigurationSection config) { - super(config); + holders.register("percent", decimal.format(ratio * 100)); + holders.register("exp", MythicLib.plugin.getMMOConfig().decimal.format(data.getExperience())); + holders.register("level", "" + data.getLevel()); + holders.register("class_points", "" + data.getClassPoints()); + holders.register("skill_points", "" + data.getSkillPoints()); + holders.register("attribute_points", "" + data.getAttributePoints()); + holders.register("progress", bar.toString()); + holders.register("next_level", "" + nextLevelExp); + if (data.isOnline()) + holders.register("player", "" + data.getPlayer().getName()); + holders.register("class", "" + data.getProfess().getName()); - ConfigurationSection noBoost = config.getConfigurationSection("no-boost"); - Validate.notNull(noBoost, "Could not load 'no-boost' config"); - this.noBoost = new SimplePlaceholderItem(noBoost); + return holders; + } + } - ConfigurationSection mainLevel = config.getConfigurationSection("main-level"); - Validate.notNull(mainLevel, "Could not load 'main-level' config"); - this.mainLevel = new InventoryItem(mainLevel) { + public class BoostItem extends SimplePlaceholderItem { + private final InventoryItem noBoost, mainLevel, profession; - @Override - public boolean hasDifferentDisplay() { - return true; - } + public BoostItem(ConfigurationSection config) { + super(config); - @Override - public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) { - Placeholders holders = new Placeholders(); - Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n); + ConfigurationSection noBoost = config.getConfigurationSection("no-boost"); + Validate.notNull(noBoost, "Could not load 'no-boost' config"); + this.noBoost = new SimplePlaceholderItem(noBoost); - holders.register("author", boost.hasAuthor() ? boost.getAuthor() : "Server"); - holders.register("value", (int) (boost.getExtra() * 100)); - holders.register("left", boost.isTimedOut() ? - MMOCore.plugin.configManager.getSimpleMessage("booster-expired").message() - : new DelayFormat(2).format(boost.getLeft())); + ConfigurationSection mainLevel = config.getConfigurationSection("main-level"); + Validate.notNull(mainLevel, "Could not load 'main-level' config"); + this.mainLevel = new InventoryItem(mainLevel) { - return holders; - } - }; + @Override + public boolean hasDifferentDisplay() { + return true; + } - ConfigurationSection profession = config.getConfigurationSection("profession"); - Validate.notNull(profession, "Could not load 'profession' config"); - this.profession = new InventoryItem(profession) { + @Override + public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) { + Placeholders holders = new Placeholders(); + Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n); - @Override - public boolean hasDifferentDisplay() { - return true; - } + holders.register("author", boost.hasAuthor() ? boost.getAuthor() : "Server"); + holders.register("value", (int) (boost.getExtra() * 100)); + holders.register("left", boost.isTimedOut() ? + MMOCore.plugin.configManager.getSimpleMessage("booster-expired").message() + : new DelayFormat(2).format(boost.getLeft())); - @Override - public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) { - Placeholders holders = new Placeholders(); - Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n); + return holders; + } + }; - holders.register("author", boost.hasAuthor() ? boost.getAuthor() : "Server"); - holders.register("profession", boost.getProfession().getName()); - holders.register("value", (int) (boost.getExtra() * 100)); - holders.register("left", boost.isTimedOut() ? - MMOCore.plugin.configManager.getSimpleMessage("booster-expired").message() - : new DelayFormat(2).format(boost.getLeft())); + ConfigurationSection profession = config.getConfigurationSection("profession"); + Validate.notNull(profession, "Could not load 'profession' config"); + this.profession = new InventoryItem(profession) { - return holders; - } - }; - } + @Override + public boolean hasDifferentDisplay() { + return true; + } - @Override - public boolean hasDifferentDisplay() { - return true; - } + @Override + public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) { + Placeholders holders = new Placeholders(); + Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n); - @Override - public ItemStack display(PlayerStatsInventory inv, int n) { - int offset = inv.boostOffset; - if (n + offset >= MMOCore.plugin.boosterManager.getActive().size()) - return noBoost.display(inv, n); + holders.register("author", boost.hasAuthor() ? boost.getAuthor() : "Server"); + holders.register("profession", boost.getProfession().getName()); + holders.register("value", (int) (boost.getExtra() * 100)); + holders.register("left", boost.isTimedOut() ? + MMOCore.plugin.configManager.getSimpleMessage("booster-expired").message() + : new DelayFormat(2).format(boost.getLeft())); - Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n); - return amount(boost.hasProfession() ? profession.display(inv, n) : mainLevel.display(inv, n), n + offset + 1); - } - } + return holders; + } + }; + } + + @Override + public boolean hasDifferentDisplay() { + return true; + } + + @Override + public ItemStack display(PlayerStatsInventory inv, int n) { + int offset = inv.boostOffset; + if (n + offset >= MMOCore.plugin.boosterManager.getActive().size()) + return noBoost.display(inv, n); + + Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n); + return amount(boost.hasProfession() ? profession.display(inv, n) : mainLevel.display(inv, n), n + offset + 1); + } + } } diff --git a/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java b/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java index 163ae7f5..85be0d26 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java +++ b/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java @@ -2,8 +2,8 @@ package net.Indyuce.mmocore.gui.api; import io.lumine.mythic.lib.MythicLib; import net.Indyuce.mmocore.MMOCore; -import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.TriggerItem; import org.bukkit.Bukkit; import org.bukkit.event.inventory.InventoryClickEvent; diff --git a/src/main/java/net/Indyuce/mmocore/listener/option/PlayerProfileCheck.java b/src/main/java/net/Indyuce/mmocore/listener/option/PlayerProfileCheck.java index eab9afe3..5ff87df0 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/option/PlayerProfileCheck.java +++ b/src/main/java/net/Indyuce/mmocore/listener/option/PlayerProfileCheck.java @@ -8,7 +8,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.inventory.Inventory; public class PlayerProfileCheck implements Listener { @@ -17,14 +16,6 @@ public class PlayerProfileCheck implements Listener { if (event.getRightClicked().getType() != EntityType.PLAYER || !event.getPlayer().isSneaking() || !MythicLib.plugin.getEntities().canTarget(event.getPlayer(), event.getRightClicked(), InteractionType.SUPPORT_ACTION)) return; - /* - * This works because the PlayerStats class DOES NOT utilize - * at all the player instance saved in the InventoryClickEvent - * - * Opening inventories like that to other players does NOT - * necessarily works for any other custom inventory. - * */ - Inventory inv = InventoryManager.PLAYER_STATS.newInventory(PlayerData.get(event.getRightClicked().getUniqueId())).getInventory(); - event.getPlayer().openInventory(inv); + InventoryManager.PLAYER_STATS.newInventory(PlayerData.get(event.getRightClicked().getUniqueId()), PlayerData.get(event.getPlayer())).open(); } }