mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-22 04:37:46 +01:00
Bug Fixing for the refacto
This commit is contained in:
parent
ed17756842
commit
4db1a93436
@ -34,7 +34,7 @@ public class ClassCommand extends RegisteredCommand {
|
||||
if (data.getProfess().getSubclasses().stream().anyMatch(sub -> sub.getLevel() <= data.getLevel()))
|
||||
InventoryManager.SUBCLASS_SELECT.newInventory(data).open();
|
||||
else
|
||||
InventoryManager.CLASS_SELECT.newInventory(data).open();
|
||||
InventoryManager.CLASS_SELECT.generate(data).open();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class PlayerStatsCommand extends RegisteredCommand {
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "profile");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class WaypointsCommand extends RegisteredCommand {
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "waypoints");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled()) InventoryManager.WAYPOINTS.newInventory(data).open();
|
||||
if(!event.isCancelled()) InventoryManager.WAYPOINTS.generate(data).open();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class OpenCommandTreeNode extends CommandTreeNode {
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
InventoryManager.WAYPOINTS.newInventory(PlayerData.get(player)).open();
|
||||
InventoryManager.WAYPOINTS.generate(PlayerData.get(player)).open();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class ForceClassProfileDataModule implements ProfileDataModule, Listener
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()))
|
||||
InventoryManager.CLASS_SELECT.newInventory(playerData, () -> {
|
||||
InventoryManager.CLASS_SELECT.generate(playerData, () -> {
|
||||
}).open();
|
||||
return;
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class ForceClassProfileDataModule implements ProfileDataModule, Listener
|
||||
|
||||
// Validate if necessary
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
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 net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
@ -9,149 +14,154 @@ import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
||||
import net.Indyuce.mmocore.api.SoundEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AttributeView extends EditableInventory {
|
||||
public AttributeView() {
|
||||
super("attribute-view");
|
||||
}
|
||||
public class AttributeView extends EditableInventory<PlayerData> {
|
||||
public AttributeView() {
|
||||
super("attribute-view");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryItem loadItem(String function, ConfigurationSection config) {
|
||||
if (function.equalsIgnoreCase("reallocation"))
|
||||
return new InventoryItem(config) {
|
||||
|
||||
@Override
|
||||
public Placeholders getPlaceholders(GeneratedInventory inv, int n) {
|
||||
Placeholders holders = new Placeholders();
|
||||
holders.register("attribute_points", inv.getPlayerData().getAttributePoints());
|
||||
holders.register("points", inv.getPlayerData().getAttributeReallocationPoints());
|
||||
holders.register("total", inv.getPlayerData().getAttributes().countPoints());
|
||||
return holders;
|
||||
}
|
||||
};
|
||||
|
||||
return function.startsWith("attribute_") ? new AttributeItem(function, config) : new SimpleItem(config);
|
||||
}
|
||||
@Override
|
||||
public InventoryItem loadItem(String function, ConfigurationSection config) {
|
||||
if (function.equalsIgnoreCase("reallocation"))
|
||||
return new InventoryItem<AttributeViewerInventory>(config) {
|
||||
|
||||
public GeneratedInventory newInventory(PlayerData data) {
|
||||
return new AttributeViewerInventory(data, this);
|
||||
}
|
||||
@Override
|
||||
public Placeholders getPlaceholders(AttributeViewerInventory inv, int n) {
|
||||
Placeholders holders = new Placeholders();
|
||||
holders.register("attribute_points", inv.getPlayerData().getAttributePoints());
|
||||
holders.register("points", inv.getPlayerData().getAttributeReallocationPoints());
|
||||
holders.register("total", inv.getPlayerData().getAttributes().countPoints());
|
||||
return holders;
|
||||
}
|
||||
};
|
||||
|
||||
public static class AttributeItem extends InventoryItem {
|
||||
private final PlayerAttribute attribute;
|
||||
private final int shiftCost;
|
||||
return function.startsWith("attribute_") ? new AttributeItem(function, config) : new SimpleItem(config);
|
||||
}
|
||||
|
||||
public AttributeItem(String function, ConfigurationSection config) {
|
||||
super(config);
|
||||
@Override
|
||||
public GeneratedInventory generate(PlayerData playerData, @Nullable GeneratedInventory generatedInventory) {
|
||||
return new AttributeViewerInventory(playerData, this);
|
||||
}
|
||||
|
||||
attribute = MMOCore.plugin.attributeManager
|
||||
.get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-"));
|
||||
shiftCost = Math.max(config.getInt("shift-cost"), 1);
|
||||
}
|
||||
public static class AttributeItem extends InventoryItem<AttributeViewerInventory> {
|
||||
private final PlayerAttribute attribute;
|
||||
private final int shiftCost;
|
||||
|
||||
@Override
|
||||
public Placeholders getPlaceholders(GeneratedInventory inv, int n) {
|
||||
int total = inv.getPlayerData().getAttributes().getInstance(attribute).getTotal();
|
||||
public AttributeItem(String function, ConfigurationSection config) {
|
||||
super(config);
|
||||
|
||||
Placeholders holders = new Placeholders();
|
||||
holders.register("name", attribute.getName());
|
||||
holders.register("buffs", attribute.getBuffs().size());
|
||||
holders.register("spent", inv.getPlayerData().getAttributes().getInstance(attribute).getBase());
|
||||
holders.register("max", attribute.getMax());
|
||||
holders.register("current", total);
|
||||
holders.register("attribute_points", inv.getPlayerData().getAttributePoints());
|
||||
holders.register("shift_points", shiftCost);
|
||||
attribute.getBuffs().forEach(buff -> {
|
||||
final String stat = buff.getStat();
|
||||
holders.register("buff_" + buff.getStat().toLowerCase(), StatManager.format(stat, buff.getValue()));
|
||||
holders.register("total_" + buff.getStat().toLowerCase(), StatManager.format(stat, buff.multiply(total).getValue()));
|
||||
});
|
||||
attribute = MMOCore.plugin.attributeManager
|
||||
.get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-"));
|
||||
shiftCost = Math.max(config.getInt("shift-cost"), 1);
|
||||
}
|
||||
|
||||
return holders;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Placeholders getPlaceholders(AttributeViewerInventory inv, int n) {
|
||||
int total = inv.getPlayerData().getAttributes().getInstance(attribute).getTotal();
|
||||
|
||||
public class AttributeViewerInventory extends GeneratedInventory {
|
||||
Placeholders holders = new Placeholders();
|
||||
holders.register("name", attribute.getName());
|
||||
holders.register("buffs", attribute.getBuffs().size());
|
||||
holders.register("spent", inv.getPlayerData().getAttributes().getInstance(attribute).getBase());
|
||||
holders.register("max", attribute.getMax());
|
||||
holders.register("current", total);
|
||||
holders.register("attribute_points", inv.getPlayerData().getAttributePoints());
|
||||
holders.register("shift_points", shiftCost);
|
||||
attribute.getBuffs().forEach(buff -> {
|
||||
final String stat = buff.getStat();
|
||||
holders.register("buff_" + buff.getStat().toLowerCase(), StatManager.format(stat, buff.getValue()));
|
||||
holders.register("total_" + buff.getStat().toLowerCase(), StatManager.format(stat, buff.multiply(total).getValue()));
|
||||
});
|
||||
|
||||
public AttributeViewerInventory(PlayerData playerData, EditableInventory editable) {
|
||||
super(playerData, editable);
|
||||
return holders;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public class AttributeViewerInventory extends GeneratedInventory<PlayerData> {
|
||||
|
||||
@Override
|
||||
public String calculateName() {
|
||||
return getName();
|
||||
}
|
||||
public AttributeViewerInventory(PlayerData playerData, EditableInventory editable) {
|
||||
super(playerData, editable);
|
||||
|
||||
@Override
|
||||
public void whenClicked(InventoryClickEvent event, InventoryItem item) {
|
||||
}
|
||||
|
||||
if (item.getFunction().equalsIgnoreCase("reallocation")) {
|
||||
int spent = playerData.getAttributes().countPoints();
|
||||
if (spent < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("no-attribute-points-spent").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public String applyNamePlaceholders(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
if (playerData.getAttributeReallocationPoints() < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-reallocation-point").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void whenClicked(InventoryClickEvent event, InventoryItem item) {
|
||||
|
||||
playerData.getAttributes().getInstances().forEach(ins -> ins.setBase(0));
|
||||
playerData.giveAttributePoints(spent);
|
||||
playerData.giveAttributeReallocationPoints(-1);
|
||||
MMOCore.plugin.configManager.getSimpleMessage("attribute-points-reallocated", "points", "" + playerData.getAttributePoints()).send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.RESET_ATTRIBUTES).playTo(getPlayer());
|
||||
open();
|
||||
}
|
||||
if (item.getFunction().equalsIgnoreCase("reallocation")) {
|
||||
int spent = playerData.getAttributes().countPoints();
|
||||
if (spent < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("no-attribute-points-spent").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getFunction().startsWith("attribute_")) {
|
||||
PlayerAttribute attribute = ((AttributeItem) item).attribute;
|
||||
if (playerData.getAttributeReallocationPoints() < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-reallocation-point").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerData.getAttributePoints() < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
playerData.getAttributes().getInstances().forEach(ins -> ins.setBase(0));
|
||||
playerData.giveAttributePoints(spent);
|
||||
playerData.giveAttributeReallocationPoints(-1);
|
||||
MMOCore.plugin.configManager.getSimpleMessage("attribute-points-reallocated", "points", "" + playerData.getAttributePoints()).send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.RESET_ATTRIBUTES).playTo(getPlayer());
|
||||
open();
|
||||
}
|
||||
|
||||
PlayerAttributes.AttributeInstance ins = playerData.getAttributes().getInstance(attribute);
|
||||
if (attribute.hasMax() && ins.getBase() >= attribute.getMax()) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("attribute-max-points-hit").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
if (item.getFunction().startsWith("attribute_")) {
|
||||
PlayerAttribute attribute = ((AttributeItem) item).attribute;
|
||||
|
||||
// Amount of points spent
|
||||
final boolean shiftClick = event.getClick().isShiftClick();
|
||||
int pointsSpent = shiftClick ? ((AttributeItem) item).shiftCost : 1;
|
||||
if (attribute.hasMax())
|
||||
pointsSpent = Math.min(pointsSpent, attribute.getMax() - ins.getBase());
|
||||
if (playerData.getAttributePoints() < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
if (shiftClick && playerData.getAttributePoints() < pointsSpent) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point-shift", "shift_points", String.valueOf(pointsSpent)).send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
PlayerAttributes.AttributeInstance ins = playerData.getAttributes().getInstance(attribute);
|
||||
if (attribute.hasMax() && ins.getBase() >= attribute.getMax()) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("attribute-max-points-hit").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
ins.addBase(pointsSpent);
|
||||
playerData.giveAttributePoints(-pointsSpent);
|
||||
// Amount of points spent
|
||||
final boolean shiftClick = event.getClick().isShiftClick();
|
||||
int pointsSpent = shiftClick ? ((AttributeItem) item).shiftCost : 1;
|
||||
if (attribute.hasMax())
|
||||
pointsSpent = Math.min(pointsSpent, attribute.getMax() - ins.getBase());
|
||||
|
||||
// Apply exp table as many times as required
|
||||
if (attribute.hasExperienceTable())
|
||||
while (pointsSpent-- > 0)
|
||||
attribute.getExperienceTable().claim(playerData, ins.getBase(), attribute);
|
||||
if (shiftClick && playerData.getAttributePoints() < pointsSpent) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point-shift", "shift_points", String.valueOf(pointsSpent)).send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
MMOCore.plugin.configManager.getSimpleMessage("attribute-level-up", "attribute", attribute.getName(), "level", String.valueOf(ins.getBase())).send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.LEVEL_ATTRIBUTE).playTo(getPlayer());
|
||||
ins.addBase(pointsSpent);
|
||||
playerData.giveAttributePoints(-pointsSpent);
|
||||
|
||||
PlayerAttributeUseEvent playerAttributeUseEvent = new PlayerAttributeUseEvent(playerData, attribute);
|
||||
Bukkit.getServer().getPluginManager().callEvent(playerAttributeUseEvent);
|
||||
// Apply exp table as many times as required
|
||||
if (attribute.hasExperienceTable())
|
||||
while (pointsSpent-- > 0)
|
||||
attribute.getExperienceTable().claim(playerData, ins.getBase(), attribute);
|
||||
|
||||
open();
|
||||
}
|
||||
}
|
||||
}
|
||||
MMOCore.plugin.configManager.getSimpleMessage("attribute-level-up", "attribute", attribute.getName(), "level", String.valueOf(ins.getBase())).send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.LEVEL_ATTRIBUTE).playTo(getPlayer());
|
||||
|
||||
PlayerAttributeUseEvent playerAttributeUseEvent = new PlayerAttributeUseEvent(playerData, attribute);
|
||||
Bukkit.getServer().getPluginManager().callEvent(playerAttributeUseEvent);
|
||||
|
||||
open();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -89,7 +89,7 @@ public class ClassConfirmation extends EditableInventory<PlayerData> {
|
||||
private final InventoryItem unlocked, locked;
|
||||
|
||||
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("locked"), "Could not load 'locked' config");
|
||||
@ -170,8 +170,9 @@ public class ClassConfirmation extends EditableInventory<PlayerData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateName() {
|
||||
return getName().replace("{class}", profess.getName());
|
||||
public String applyNamePlaceholders(String s) {
|
||||
return s.replace("{class}", profess.getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ public class ClassSelect extends EditableInventory<PlayerData> {
|
||||
return function.startsWith("class") ? new ClassItem(config) : new SimpleItem(config);
|
||||
}
|
||||
|
||||
public GeneratedInventory newInventory(PlayerData data) {
|
||||
return newInventory(data, null);
|
||||
public GeneratedInventory generate(PlayerData playerData, @Nullable GeneratedInventory generatedInventory) {
|
||||
return generate(playerData, null, null);
|
||||
}
|
||||
|
||||
public GeneratedInventory newInventory(PlayerData data, @Nullable Runnable profileRunnable) {
|
||||
return new ProfessSelectionInventory(data, this, profileRunnable);
|
||||
public GeneratedInventory generate(PlayerData playerData, @Nullable GeneratedInventory generatedInventory, @Nullable Runnable profileRunnable) {
|
||||
return new ProfessSelectionInventory(playerData, this, profileRunnable);
|
||||
}
|
||||
|
||||
public class ClassItem extends SimpleItem<ProfessSelectionInventory> {
|
||||
@ -55,7 +55,7 @@ public class ClassSelect extends EditableInventory<PlayerData> {
|
||||
private final PlayerClass playerClass;
|
||||
|
||||
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"));
|
||||
String classId = UtilityMethods.enumName(config.getString("function").substring(6));
|
||||
@ -152,7 +152,6 @@ public class ClassSelect extends EditableInventory<PlayerData> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void whenClosed(InventoryCloseEvent event) {
|
||||
if (profileRunnable != null && !canClose)
|
||||
|
@ -20,22 +20,23 @@ 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.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PlayerStats extends EditableInventory {
|
||||
public class PlayerStats extends EditableInventory<PlayerData> {
|
||||
public PlayerStats() {
|
||||
super("player-stats");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InventoryItem loadItemItem(String function, ConfigurationSection config) {
|
||||
public InventoryItem loadItem(String function, ConfigurationSection config) {
|
||||
|
||||
if (function.equals("boost"))
|
||||
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();
|
||||
|
||||
@Override
|
||||
public String apply(OfflinePlayer player, String str) {
|
||||
public String apply(Player player, String str) {
|
||||
String explored = str;
|
||||
// Internal placeholders
|
||||
while (explored.contains("{") && explored.substring(explored.indexOf("{")).contains("}")) {
|
||||
@ -161,11 +162,12 @@ public class PlayerStats extends EditableInventory {
|
||||
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);
|
||||
}
|
||||
|
||||
public PlayerStatsInventory newInventory(PlayerData player) {
|
||||
@Override
|
||||
public PlayerStatsInventory generate(PlayerData player, @Nullable GeneratedInventory previousInventory) {
|
||||
return new PlayerStatsInventory(player, player, this);
|
||||
}
|
||||
|
||||
@ -186,8 +188,8 @@ public class PlayerStats extends EditableInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateName() {
|
||||
return getName();
|
||||
public String applyNamePlaceholders(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,7 +2,6 @@ package net.Indyuce.mmocore.gui;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
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.GeneratedInventory;
|
||||
import io.lumine.mythic.lib.gui.framework.item.InventoryItem;
|
||||
@ -35,7 +34,7 @@ public class SubclassSelect extends EditableInventory<PlayerData> {
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -51,7 +50,7 @@ public class SubclassSelect extends EditableInventory<PlayerData> {
|
||||
private final PlayerClass playerClass;
|
||||
|
||||
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"));
|
||||
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.");
|
||||
@ -116,7 +115,7 @@ public class SubclassSelect extends EditableInventory<PlayerData> {
|
||||
@Override
|
||||
public void whenClicked(InventoryClickEvent event, InventoryItem item) {
|
||||
if (item.getFunction().equals("back"))
|
||||
InventoryManager.CLASS_SELECT.newInventory(playerData).open();
|
||||
InventoryManager.CLASS_SELECT.generate(playerData,this).open();
|
||||
|
||||
if (item.getFunction().startsWith("sub-class")) {
|
||||
String classId = UtilityMethods.ymlName(item.getFunction().substring(10));
|
||||
|
@ -58,11 +58,12 @@ public class WaypointViewer extends EditableInventory<PlayerData> {
|
||||
return new SimpleItem(config);
|
||||
}
|
||||
|
||||
public GeneratedInventory newInventory(PlayerData data) {
|
||||
return newInventory(data, null);
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
@ -71,7 +72,7 @@ public class WaypointViewer extends EditableInventory<PlayerData> {
|
||||
private final WaypointItemHandler availWaypoint, noStellium, notLinked, notDynamic, currentWayPoint;
|
||||
|
||||
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("locked"), "Could not load 'locked' config");
|
||||
@ -211,10 +212,11 @@ public class WaypointViewer extends EditableInventory<PlayerData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateName() {
|
||||
return getName();
|
||||
public String applyNamePlaceholders(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDynamicUse() {
|
||||
return current == null;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmocore.gui.api.packets;
|
||||
|
||||
|
||||
import io.lumine.mythic.lib.gui.framework.PluginInventory;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -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.NBTItem;
|
||||
import io.lumine.mythic.lib.gui.framework.PluginInventory;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class GoldPouch extends PluginInventory {
|
||||
public class GoldPouch extends PluginInventory<PlayerData> {
|
||||
private final boolean mob;
|
||||
private final NBTItem nbt;
|
||||
|
||||
public GoldPouch(Player player, NBTItem nbt) {
|
||||
super(player);
|
||||
super(PlayerData.get(player));
|
||||
|
||||
this.nbt = nbt;
|
||||
this.mob = nbt.getBoolean("RpgPouchMob");
|
||||
|
@ -57,8 +57,12 @@ public class SkillTreeViewer extends EditableInventory<PlayerData> {
|
||||
this.defaultSkillTree = initialSkillTree;
|
||||
}
|
||||
|
||||
public SkillTreeInventory generate(PlayerData playerData, @Nullable GeneratedInventory previousInventory) {
|
||||
return new SkillTreeInventory(playerData, this, defaultSkillTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload(FileConfiguration config) {
|
||||
public void reload(ConfigurationSection config) {
|
||||
super.reload(config);
|
||||
if (config.contains("status-names"))
|
||||
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 SkillTreeItem(ConfigurationSection config) {
|
||||
//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) {
|
||||
super(Material.AIR, config);
|
||||
super(config, Material.AIR);
|
||||
if (config.isList("path-lore"))
|
||||
pathLore.addAll(config.getStringList("path-lore"));
|
||||
}
|
||||
@ -409,10 +408,11 @@ public class SkillTreeViewer extends EditableInventory<PlayerData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateName() {
|
||||
return getEditable().getName().replace("{skill-tree-name}", skillTree.getName()).replace("{skill-tree-id}", skillTree.getId());
|
||||
public String applyNamePlaceholders(String s) {
|
||||
return s.replace("{skill-tree-name}", skillTree.getName()).replace("{skill-tree-id}", skillTree.getId());
|
||||
}
|
||||
|
||||
|
||||
public IntegerCoordinates getCoordinates(int n) {
|
||||
int slot = slots.get(n);
|
||||
int deltaX = (slot - getMinSlot()) % 9;
|
||||
|
@ -242,7 +242,7 @@ public class EditableFriendList extends EditableInventory<PlayerData> {
|
||||
if (tag == null || tag.isEmpty())
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class EditableFriendRemoval extends EditableInventory<PlayerData> {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -65,9 +76,5 @@ public class EditableFriendRemoval extends EditableInventory<PlayerData> {
|
||||
last.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateName() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class EditablePartyCreation extends EditableInventory<PlayerData> {
|
||||
|
||||
if (item.getFunction().equals("create")) {
|
||||
((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);
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,7 @@ public class EditablePartyView extends EditableInventory<PlayerData> {
|
||||
if (meta instanceof SkullMeta)
|
||||
inv.dynamicallyUpdateItem(this, n, disp, current -> {
|
||||
((SkullMeta) meta).setOwningPlayer(member);
|
||||
current.47
|
||||
setItemMeta(meta);
|
||||
current.setItemMeta(meta);
|
||||
});
|
||||
|
||||
disp.setItemMeta(meta);
|
||||
@ -101,7 +100,7 @@ public class EditablePartyView extends EditableInventory<PlayerData> {
|
||||
private final MemberDisplayItem member;
|
||||
|
||||
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("member"), "Could not load member config");
|
||||
|
@ -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))
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user