Bug Fixing for the refacto

This commit is contained in:
Ka0rX 2023-09-12 16:12:46 +01:00
parent ed17756842
commit 4db1a93436
19 changed files with 196 additions and 173 deletions

View File

@ -34,7 +34,7 @@ public class ClassCommand extends RegisteredCommand {
if (data.getProfess().getSubclasses().stream().anyMatch(sub -> sub.getLevel() <= data.getLevel())) if (data.getProfess().getSubclasses().stream().anyMatch(sub -> sub.getLevel() <= data.getLevel()))
InventoryManager.SUBCLASS_SELECT.newInventory(data).open(); InventoryManager.SUBCLASS_SELECT.newInventory(data).open();
else else
InventoryManager.CLASS_SELECT.newInventory(data).open(); InventoryManager.CLASS_SELECT.generate(data).open();
return true; return true;
} }
} }

View File

@ -28,7 +28,7 @@ public class PlayerStatsCommand extends RegisteredCommand {
PlayerData data = PlayerData.get((Player) sender); PlayerData data = PlayerData.get((Player) sender);
MMOCommandEvent event = new MMOCommandEvent(data, "profile"); MMOCommandEvent event = new MMOCommandEvent(data, "profile");
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) InventoryManager.PLAYER_STATS.newInventory(data).open(); if (!event.isCancelled()) InventoryManager.PLAYER_STATS.generate(data).open();
return true; return true;
} }
} }

View File

@ -21,7 +21,7 @@ public class WaypointsCommand extends RegisteredCommand {
PlayerData data = PlayerData.get((Player) sender); PlayerData data = PlayerData.get((Player) sender);
MMOCommandEvent event = new MMOCommandEvent(data, "waypoints"); MMOCommandEvent event = new MMOCommandEvent(data, "waypoints");
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if(!event.isCancelled()) InventoryManager.WAYPOINTS.newInventory(data).open(); if(!event.isCancelled()) InventoryManager.WAYPOINTS.generate(data).open();
} }
return true; return true;
} }

View File

@ -28,7 +28,7 @@ public class OpenCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE; return CommandResult.FAILURE;
} }
InventoryManager.WAYPOINTS.newInventory(PlayerData.get(player)).open(); InventoryManager.WAYPOINTS.generate(PlayerData.get(player)).open();
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }
} }

View File

@ -47,7 +47,7 @@ public class ForceClassProfileDataModule implements ProfileDataModule, Listener
} }
final PlayerData playerData = PlayerData.get(event.getPlayerData().getPlayer()); final PlayerData playerData = PlayerData.get(event.getPlayerData().getPlayer());
InventoryManager.CLASS_SELECT.newInventory(playerData, () -> event.validate(this)).open(); InventoryManager.CLASS_SELECT.generate(playerData, () -> event.validate(this)).open();
} }
/** /**
@ -62,7 +62,7 @@ public class ForceClassProfileDataModule implements ProfileDataModule, Listener
if (!event.hasProfileEvent()) { if (!event.hasProfileEvent()) {
Validate.isTrue(MythicLib.plugin.getProfileMode() == ProfileMode.PROXY, "Listened to a data load event with no profile event attached but proxy-based profiles are disabled"); Validate.isTrue(MythicLib.plugin.getProfileMode() == ProfileMode.PROXY, "Listened to a data load event with no profile event attached but proxy-based profiles are disabled");
if (playerData.getProfess().equals(MMOCore.plugin.classManager.getDefaultClass())) if (playerData.getProfess().equals(MMOCore.plugin.classManager.getDefaultClass()))
InventoryManager.CLASS_SELECT.newInventory(playerData, () -> { InventoryManager.CLASS_SELECT.generate(playerData, () -> {
}).open(); }).open();
return; return;
} }
@ -71,7 +71,7 @@ public class ForceClassProfileDataModule implements ProfileDataModule, Listener
// Validate if necessary // Validate if necessary
if (playerData.getProfess().equals(MMOCore.plugin.classManager.getDefaultClass())) if (playerData.getProfess().equals(MMOCore.plugin.classManager.getDefaultClass()))
InventoryManager.CLASS_SELECT.newInventory(playerData, () -> event1.validate(this)).open(); InventoryManager.CLASS_SELECT.generate(playerData, () -> event1.validate(this)).open();
else event1.validate(this); else event1.validate(this);
} }
} }

View File

@ -1,5 +1,10 @@
package net.Indyuce.mmocore.gui; package net.Indyuce.mmocore.gui;
import io.lumine.mythic.lib.gui.framework.EditableInventory;
import io.lumine.mythic.lib.gui.framework.GeneratedInventory;
import io.lumine.mythic.lib.gui.framework.item.InventoryItem;
import io.lumine.mythic.lib.gui.framework.item.Placeholders;
import io.lumine.mythic.lib.gui.framework.item.SimpleItem;
import io.lumine.mythic.lib.manager.StatManager; import io.lumine.mythic.lib.manager.StatManager;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
@ -9,19 +14,23 @@ import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
import net.Indyuce.mmocore.api.SoundEvent; import net.Indyuce.mmocore.api.SoundEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.Nullable;
public class AttributeView extends EditableInventory { public class AttributeView extends EditableInventory<PlayerData> {
public AttributeView() { public AttributeView() {
super("attribute-view"); super("attribute-view");
} }
@Override @Override
public InventoryItem loadItem(String function, ConfigurationSection config) { public InventoryItem loadItem(String function, ConfigurationSection config) {
if (function.equalsIgnoreCase("reallocation")) if (function.equalsIgnoreCase("reallocation"))
return new InventoryItem(config) { return new InventoryItem<AttributeViewerInventory>(config) {
@Override @Override
public Placeholders getPlaceholders(GeneratedInventory inv, int n) { public Placeholders getPlaceholders(AttributeViewerInventory inv, int n) {
Placeholders holders = new Placeholders(); Placeholders holders = new Placeholders();
holders.register("attribute_points", inv.getPlayerData().getAttributePoints()); holders.register("attribute_points", inv.getPlayerData().getAttributePoints());
holders.register("points", inv.getPlayerData().getAttributeReallocationPoints()); holders.register("points", inv.getPlayerData().getAttributeReallocationPoints());
@ -33,11 +42,12 @@ public class AttributeView extends EditableInventory {
return function.startsWith("attribute_") ? new AttributeItem(function, config) : new SimpleItem(config); return function.startsWith("attribute_") ? new AttributeItem(function, config) : new SimpleItem(config);
} }
public GeneratedInventory newInventory(PlayerData data) { @Override
return new AttributeViewerInventory(data, this); public GeneratedInventory generate(PlayerData playerData, @Nullable GeneratedInventory generatedInventory) {
return new AttributeViewerInventory(playerData, this);
} }
public static class AttributeItem extends InventoryItem { public static class AttributeItem extends InventoryItem<AttributeViewerInventory> {
private final PlayerAttribute attribute; private final PlayerAttribute attribute;
private final int shiftCost; private final int shiftCost;
@ -50,7 +60,7 @@ public class AttributeView extends EditableInventory {
} }
@Override @Override
public Placeholders getPlaceholders(GeneratedInventory inv, int n) { public Placeholders getPlaceholders(AttributeViewerInventory inv, int n) {
int total = inv.getPlayerData().getAttributes().getInstance(attribute).getTotal(); int total = inv.getPlayerData().getAttributes().getInstance(attribute).getTotal();
Placeholders holders = new Placeholders(); Placeholders holders = new Placeholders();
@ -71,7 +81,7 @@ public class AttributeView extends EditableInventory {
} }
} }
public class AttributeViewerInventory extends GeneratedInventory { public class AttributeViewerInventory extends GeneratedInventory<PlayerData> {
public AttributeViewerInventory(PlayerData playerData, EditableInventory editable) { public AttributeViewerInventory(PlayerData playerData, EditableInventory editable) {
super(playerData, editable); super(playerData, editable);
@ -79,8 +89,8 @@ public class AttributeView extends EditableInventory {
} }
@Override @Override
public String calculateName() { public String applyNamePlaceholders(String s) {
return getName(); return s;
} }
@Override @Override

View File

@ -89,7 +89,7 @@ public class ClassConfirmation extends EditableInventory<PlayerData> {
private final InventoryItem unlocked, locked; private final InventoryItem unlocked, locked;
public YesItem(ConfigurationSection config) { public YesItem(ConfigurationSection config) {
super(Material.BARRIER, config); super(config, Material.BARRIER);
Validate.isTrue(config.contains("unlocked"), "Could not load 'unlocked' config"); Validate.isTrue(config.contains("unlocked"), "Could not load 'unlocked' config");
Validate.isTrue(config.contains("locked"), "Could not load 'locked' config"); Validate.isTrue(config.contains("locked"), "Could not load 'locked' config");
@ -170,8 +170,9 @@ public class ClassConfirmation extends EditableInventory<PlayerData> {
} }
@Override @Override
public String calculateName() { public String applyNamePlaceholders(String s) {
return getName().replace("{class}", profess.getName()); return s.replace("{class}", profess.getName());
} }
} }
} }

View File

@ -41,12 +41,12 @@ public class ClassSelect extends EditableInventory<PlayerData> {
return function.startsWith("class") ? new ClassItem(config) : new SimpleItem(config); return function.startsWith("class") ? new ClassItem(config) : new SimpleItem(config);
} }
public GeneratedInventory newInventory(PlayerData data) { public GeneratedInventory generate(PlayerData playerData, @Nullable GeneratedInventory generatedInventory) {
return newInventory(data, null); return generate(playerData, null, null);
} }
public GeneratedInventory newInventory(PlayerData data, @Nullable Runnable profileRunnable) { public GeneratedInventory generate(PlayerData playerData, @Nullable GeneratedInventory generatedInventory, @Nullable Runnable profileRunnable) {
return new ProfessSelectionInventory(data, this, profileRunnable); return new ProfessSelectionInventory(playerData, this, profileRunnable);
} }
public class ClassItem extends SimpleItem<ProfessSelectionInventory> { public class ClassItem extends SimpleItem<ProfessSelectionInventory> {
@ -55,7 +55,7 @@ public class ClassSelect extends EditableInventory<PlayerData> {
private final PlayerClass playerClass; private final PlayerClass playerClass;
public ClassItem(ConfigurationSection config) { public ClassItem(ConfigurationSection config) {
super(config.contains("item") ? Material.valueOf(UtilityMethods.enumName(config.getString("item"))) : Material.BARRIER, config); super(config, config.contains("item") ? Material.valueOf(UtilityMethods.enumName(config.getString("item"))) : Material.BARRIER);
Validate.isTrue(config.getString("function").length() > 6, "Couldn't find the class associated to: " + config.getString("function")); Validate.isTrue(config.getString("function").length() > 6, "Couldn't find the class associated to: " + config.getString("function"));
String classId = UtilityMethods.enumName(config.getString("function").substring(6)); String classId = UtilityMethods.enumName(config.getString("function").substring(6));
@ -152,7 +152,6 @@ public class ClassSelect extends EditableInventory<PlayerData> {
} }
@Override @Override
public void whenClosed(InventoryCloseEvent event) { public void whenClosed(InventoryCloseEvent event) {
if (profileRunnable != null && !canClose) if (profileRunnable != null && !canClose)

View File

@ -20,22 +20,23 @@ import net.Indyuce.mmocore.party.AbstractParty;
import net.Indyuce.mmocore.player.stats.StatInfo; import net.Indyuce.mmocore.player.stats.StatInfo;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.Nullable;
import java.util.Objects; import java.util.Objects;
public class PlayerStats extends EditableInventory { public class PlayerStats extends EditableInventory<PlayerData> {
public PlayerStats() { public PlayerStats() {
super("player-stats"); super("player-stats");
} }
@Override @Override
public InventoryItem loadItemItem(String function, ConfigurationSection config) { public InventoryItem loadItem(String function, ConfigurationSection config) {
if (function.equals("boost")) if (function.equals("boost"))
return new BoostItem(config); return new BoostItem(config);
@ -124,7 +125,7 @@ public class PlayerStats extends EditableInventory {
final net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.target.getStats(); final net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.target.getStats();
@Override @Override
public String apply(OfflinePlayer player, String str) { public String apply(Player player, String str) {
String explored = str; String explored = str;
// Internal placeholders // Internal placeholders
while (explored.contains("{") && explored.substring(explored.indexOf("{")).contains("}")) { while (explored.contains("{") && explored.substring(explored.indexOf("{")).contains("}")) {
@ -161,11 +162,12 @@ public class PlayerStats extends EditableInventory {
return new SimpleItem(config); return new SimpleItem(config);
} }
public PlayerStatsInventory newInventory(PlayerData invTarget, PlayerData opening) { public PlayerStatsInventory generate(PlayerData invTarget, PlayerData opening, @Nullable GeneratedInventory previousInventory) {
return new PlayerStatsInventory(invTarget, opening, this); return new PlayerStatsInventory(invTarget, opening, this);
} }
public PlayerStatsInventory newInventory(PlayerData player) { @Override
public PlayerStatsInventory generate(PlayerData player, @Nullable GeneratedInventory previousInventory) {
return new PlayerStatsInventory(player, player, this); return new PlayerStatsInventory(player, player, this);
} }
@ -186,8 +188,8 @@ public class PlayerStats extends EditableInventory {
} }
@Override @Override
public String calculateName() { public String applyNamePlaceholders(String s) {
return getName(); return s;
} }
@Override @Override

View File

@ -2,7 +2,6 @@ package net.Indyuce.mmocore.gui;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.data.SynchronizedDataHolder;
import io.lumine.mythic.lib.gui.framework.EditableInventory; import io.lumine.mythic.lib.gui.framework.EditableInventory;
import io.lumine.mythic.lib.gui.framework.GeneratedInventory; import io.lumine.mythic.lib.gui.framework.GeneratedInventory;
import io.lumine.mythic.lib.gui.framework.item.InventoryItem; import io.lumine.mythic.lib.gui.framework.item.InventoryItem;
@ -35,7 +34,7 @@ public class SubclassSelect extends EditableInventory<PlayerData> {
} }
@Override @Override
public InventoryItem loadItemItem(String function, ConfigurationSection config) { public InventoryItem loadItem(String function, ConfigurationSection config) {
return function.startsWith("sub-class") ? new ClassItem(config) : new SimpleItem(config); return function.startsWith("sub-class") ? new ClassItem(config) : new SimpleItem(config);
} }
@ -51,7 +50,7 @@ public class SubclassSelect extends EditableInventory<PlayerData> {
private final PlayerClass playerClass; private final PlayerClass playerClass;
public ClassItem(ConfigurationSection config) { public ClassItem(ConfigurationSection config) {
super(config.contains("item") ? Material.valueOf(UtilityMethods.enumName(config.getString("item"))) : Material.BARRIER, config); super(config, config.contains("item") ? Material.valueOf(UtilityMethods.enumName(config.getString("item"))) : Material.BARRIER);
Validate.isTrue(config.getString("function").length() > 10, "Couldn't find the class associated to: " + config.getString("function")); Validate.isTrue(config.getString("function").length() > 10, "Couldn't find the class associated to: " + config.getString("function"));
String classId = UtilityMethods.enumName(config.getString("function").substring(10)); String classId = UtilityMethods.enumName(config.getString("function").substring(10));
this.playerClass = Objects.requireNonNull(MMOCore.plugin.classManager.get(classId), classId + " does not correspond to any classId."); this.playerClass = Objects.requireNonNull(MMOCore.plugin.classManager.get(classId), classId + " does not correspond to any classId.");
@ -116,7 +115,7 @@ public class SubclassSelect extends EditableInventory<PlayerData> {
@Override @Override
public void whenClicked(InventoryClickEvent event, InventoryItem item) { public void whenClicked(InventoryClickEvent event, InventoryItem item) {
if (item.getFunction().equals("back")) if (item.getFunction().equals("back"))
InventoryManager.CLASS_SELECT.newInventory(playerData).open(); InventoryManager.CLASS_SELECT.generate(playerData,this).open();
if (item.getFunction().startsWith("sub-class")) { if (item.getFunction().startsWith("sub-class")) {
String classId = UtilityMethods.ymlName(item.getFunction().substring(10)); String classId = UtilityMethods.ymlName(item.getFunction().substring(10));

View File

@ -58,11 +58,12 @@ public class WaypointViewer extends EditableInventory<PlayerData> {
return new SimpleItem(config); return new SimpleItem(config);
} }
public GeneratedInventory newInventory(PlayerData data) { @Override
return newInventory(data, null); public GeneratedInventory generate(PlayerData data, @Nullable GeneratedInventory generatedInventory) {
return newInventory(data, null, null);
} }
public GeneratedInventory newInventory(PlayerData data, Waypoint waypoint) { public GeneratedInventory newInventory(PlayerData data, Waypoint waypoint, @Nullable GeneratedInventory generatedInventory) {
return new WaypointViewerInventory(data, this, waypoint); return new WaypointViewerInventory(data, this, waypoint);
} }
@ -71,7 +72,7 @@ public class WaypointViewer extends EditableInventory<PlayerData> {
private final WaypointItemHandler availWaypoint, noStellium, notLinked, notDynamic, currentWayPoint; private final WaypointItemHandler availWaypoint, noStellium, notLinked, notDynamic, currentWayPoint;
public WaypointItem(ConfigurationSection config) { public WaypointItem(ConfigurationSection config) {
super(Material.BARRIER, config); super(config, Material.BARRIER);
Validate.notNull(config.getConfigurationSection("no-waypoint"), "Could not load 'no-waypoint' config"); Validate.notNull(config.getConfigurationSection("no-waypoint"), "Could not load 'no-waypoint' config");
Validate.notNull(config.getConfigurationSection("locked"), "Could not load 'locked' config"); Validate.notNull(config.getConfigurationSection("locked"), "Could not load 'locked' config");
@ -211,10 +212,11 @@ public class WaypointViewer extends EditableInventory<PlayerData> {
} }
@Override @Override
public String calculateName() { public String applyNamePlaceholders(String s) {
return getName(); return s;
} }
public boolean isDynamicUse() { public boolean isDynamicUse() {
return current == null; return current == null;
} }

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmocore.gui.api.packets; package net.Indyuce.mmocore.gui.api.packets;
import io.lumine.mythic.lib.gui.framework.PluginInventory;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -2,22 +2,25 @@ package net.Indyuce.mmocore.gui.eco;
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.gui.framework.PluginInventory;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class GoldPouch extends PluginInventory { public class GoldPouch extends PluginInventory<PlayerData> {
private final boolean mob; private final boolean mob;
private final NBTItem nbt; private final NBTItem nbt;
public GoldPouch(Player player, NBTItem nbt) { public GoldPouch(Player player, NBTItem nbt) {
super(player); super(PlayerData.get(player));
this.nbt = nbt; this.nbt = nbt;
this.mob = nbt.getBoolean("RpgPouchMob"); this.mob = nbt.getBoolean("RpgPouchMob");

View File

@ -57,8 +57,12 @@ public class SkillTreeViewer extends EditableInventory<PlayerData> {
this.defaultSkillTree = initialSkillTree; this.defaultSkillTree = initialSkillTree;
} }
public SkillTreeInventory generate(PlayerData playerData, @Nullable GeneratedInventory previousInventory) {
return new SkillTreeInventory(playerData, this, defaultSkillTree);
}
@Override @Override
public void reload(FileConfiguration config) { public void reload(ConfigurationSection config) {
super.reload(config); super.reload(config);
if (config.contains("status-names")) if (config.contains("status-names"))
for (SkillTreeStatus skillTreeStatus : SkillTreeStatus.values()) for (SkillTreeStatus skillTreeStatus : SkillTreeStatus.values())
@ -127,16 +131,11 @@ public class SkillTreeViewer extends EditableInventory<PlayerData> {
} }
public SkillTreeInventory generate(PlayerData playerData) {
return new SkillTreeInventory(playerData, this, defaultSkillTree);
}
public class SkillTreeItem extends InventoryItem<SkillTreeInventory> { public class SkillTreeItem extends InventoryItem<SkillTreeInventory> {
public SkillTreeItem(ConfigurationSection config) { public SkillTreeItem(ConfigurationSection config) {
//We must use this constructor to show that there are not specified material //We must use this constructor to show that there are not specified material
super(Material.BARRIER, config); super(config, Material.BARRIER);
} }
@ -223,7 +222,7 @@ public class SkillTreeViewer extends EditableInventory<PlayerData> {
public SkillTreeNodeItem(ConfigurationSection config) { public SkillTreeNodeItem(ConfigurationSection config) {
super(Material.AIR, config); super(config, Material.AIR);
if (config.isList("path-lore")) if (config.isList("path-lore"))
pathLore.addAll(config.getStringList("path-lore")); pathLore.addAll(config.getStringList("path-lore"));
} }
@ -409,10 +408,11 @@ public class SkillTreeViewer extends EditableInventory<PlayerData> {
} }
@Override @Override
public String calculateName() { public String applyNamePlaceholders(String s) {
return getEditable().getName().replace("{skill-tree-name}", skillTree.getName()).replace("{skill-tree-id}", skillTree.getId()); return s.replace("{skill-tree-name}", skillTree.getName()).replace("{skill-tree-id}", skillTree.getId());
} }
public IntegerCoordinates getCoordinates(int n) { public IntegerCoordinates getCoordinates(int n) {
int slot = slots.get(n); int slot = slots.get(n);
int deltaX = (slot - getMinSlot()) % 9; int deltaX = (slot - getMinSlot()) % 9;

View File

@ -242,7 +242,7 @@ public class EditableFriendList extends EditableInventory<PlayerData> {
if (tag == null || tag.isEmpty()) if (tag == null || tag.isEmpty())
return; return;
InventoryManager.FRIEND_REMOVAL.newInventory(playerData, Bukkit.getOfflinePlayer(UUID.fromString(tag)), this).open(); InventoryManager.FRIEND_REMOVAL.generate(playerData, Bukkit.getOfflinePlayer(UUID.fromString(tag)), this).open();
} }
} }
} }

View File

@ -11,6 +11,7 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.Nullable;
public class EditableFriendRemoval extends EditableInventory<PlayerData> { public class EditableFriendRemoval extends EditableInventory<PlayerData> {
public EditableFriendRemoval() { public EditableFriendRemoval() {
@ -31,7 +32,17 @@ public class EditableFriendRemoval extends EditableInventory<PlayerData> {
}; };
} }
public GeneratedInventory newInventory(PlayerData data, OfflinePlayer friend, GeneratedInventory last) { /**
* Do not use this method but rather use {@link #generate(PlayerData, OfflinePlayer, GeneratedInventory)}
*/
@Deprecated
@Override
public GeneratedInventory generate(PlayerData playerData, @Nullable GeneratedInventory generatedInventory) {
throw new RuntimeException("Unsupported method");
}
public GeneratedInventory generate(PlayerData data, OfflinePlayer friend, GeneratedInventory last) {
return new ClassConfirmationInventory(data, this, friend, last); return new ClassConfirmationInventory(data, this, friend, last);
} }
@ -65,9 +76,5 @@ public class EditableFriendRemoval extends EditableInventory<PlayerData> {
last.open(); last.open();
} }
@Override
public String calculateName() {
return getName();
}
} }
} }

View File

@ -43,7 +43,7 @@ public class EditablePartyCreation extends EditableInventory<PlayerData> {
if (item.getFunction().equals("create")) { if (item.getFunction().equals("create")) {
((MMOCorePartyModule) MMOCore.plugin.partyModule).newRegisteredParty(playerData); ((MMOCorePartyModule) MMOCore.plugin.partyModule).newRegisteredParty(playerData);
InventoryManager.PARTY_VIEW.newInventory(playerData).open(); InventoryManager.PARTY_VIEW.generate(playerData, this).open();
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
} }

View File

@ -87,8 +87,7 @@ public class EditablePartyView extends EditableInventory<PlayerData> {
if (meta instanceof SkullMeta) if (meta instanceof SkullMeta)
inv.dynamicallyUpdateItem(this, n, disp, current -> { inv.dynamicallyUpdateItem(this, n, disp, current -> {
((SkullMeta) meta).setOwningPlayer(member); ((SkullMeta) meta).setOwningPlayer(member);
current.47 current.setItemMeta(meta);
setItemMeta(meta);
}); });
disp.setItemMeta(meta); disp.setItemMeta(meta);
@ -101,7 +100,7 @@ public class EditablePartyView extends EditableInventory<PlayerData> {
private final MemberDisplayItem member; private final MemberDisplayItem member;
public MemberItem(ConfigurationSection config) { public MemberItem(ConfigurationSection config) {
super(Material.BARRIER, config); super(config, Material.BARRIER);
Validate.notNull(config.contains("empty"), "Could not load empty config"); Validate.notNull(config.contains("empty"), "Could not load empty config");
Validate.notNull(config.contains("member"), "Could not load member config"); Validate.notNull(config.contains("member"), "Could not load member config");

View File

@ -17,6 +17,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)) if (event.getRightClicked().getType() != EntityType.PLAYER || !event.getPlayer().isSneaking() || !MythicLib.plugin.getEntities().canTarget(event.getPlayer(), event.getRightClicked(), InteractionType.SUPPORT_ACTION))
return; return;
InventoryManager.PLAYER_STATS.newInventory(PlayerData.get((Player) event.getRightClicked()), PlayerData.get(event.getPlayer())).open(); InventoryManager.PLAYER_STATS.generate(PlayerData.get((Player) event.getRightClicked()), PlayerData.get(event.getPlayer())).open();
} }
} }