mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-25 05:07:46 +01:00
Fixed shift click profile check
This commit is contained in:
parent
80b0455fed
commit
f679551b99
@ -5,18 +5,18 @@ import io.lumine.mythic.lib.UtilityMethods;
|
|||||||
import io.lumine.mythic.lib.api.stat.modifier.StatModifier;
|
import io.lumine.mythic.lib.api.stat.modifier.StatModifier;
|
||||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
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.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.EditableInventory;
|
||||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||||
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
|
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.party.AbstractParty;
|
||||||
|
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.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -28,310 +28,323 @@ import org.bukkit.inventory.meta.SkullMeta;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class PlayerStats extends EditableInventory {
|
public class PlayerStats extends EditableInventory {
|
||||||
public PlayerStats() {
|
public PlayerStats() {
|
||||||
super("player-stats");
|
super("player-stats");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryItem load(String function, ConfigurationSection config) {
|
public InventoryItem load(String function, ConfigurationSection config) {
|
||||||
|
|
||||||
if (function.equals("boost"))
|
if (function.equals("boost"))
|
||||||
return new BoostItem(config);
|
return new BoostItem(config);
|
||||||
|
|
||||||
if (function.equals("boost-next"))
|
if (function.equals("boost-next"))
|
||||||
return new SimplePlaceholderItem<PlayerStatsInventory>(config) {
|
return new SimplePlaceholderItem<PlayerStatsInventory>(config) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasDifferentDisplay() {
|
public boolean hasDifferentDisplay() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canDisplay(PlayerStatsInventory inv) {
|
public boolean canDisplay(PlayerStatsInventory inv) {
|
||||||
InventoryItem boost = inv.getByFunction("boost");
|
InventoryItem boost = inv.getByFunction("boost");
|
||||||
return boost != null && inv.boostOffset + boost.getSlots().size() < MMOCore.plugin.boosterManager.getActive().size();
|
return boost != null && inv.boostOffset + boost.getSlots().size() < MMOCore.plugin.boosterManager.getActive().size();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (function.equals("boost-previous"))
|
if (function.equals("boost-previous"))
|
||||||
return new SimplePlaceholderItem<PlayerStatsInventory>(config) {
|
return new SimplePlaceholderItem<PlayerStatsInventory>(config) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canDisplay(PlayerStatsInventory inv) {
|
public boolean canDisplay(PlayerStatsInventory inv) {
|
||||||
return inv.boostOffset > 0;
|
return inv.boostOffset > 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (function.equals("party"))
|
if (function.equals("party"))
|
||||||
return new PartyMoraleItem(config);
|
return new PartyMoraleItem(config);
|
||||||
|
|
||||||
if (function.startsWith("profession_")) {
|
if (function.startsWith("profession_")) {
|
||||||
String id = function.substring("profession_".length()).toLowerCase();
|
String id = function.substring("profession_".length()).toLowerCase();
|
||||||
Validate.isTrue(MMOCore.plugin.professionManager.has(id));
|
Validate.isTrue(MMOCore.plugin.professionManager.has(id));
|
||||||
Profession profession = MMOCore.plugin.professionManager.get(id);
|
Profession profession = MMOCore.plugin.professionManager.get(id);
|
||||||
|
|
||||||
return new InventoryItem(config) {
|
return new InventoryItem<PlayerStatsInventory>(config) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasDifferentDisplay() {
|
public boolean hasDifferentDisplay() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Placeholders getPlaceholders(GeneratedInventory inv, int n) {
|
public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) {
|
||||||
|
|
||||||
Placeholders holders = new Placeholders();
|
Placeholders holders = new Placeholders();
|
||||||
net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.getPlayerData().getStats();
|
net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.target.getStats();
|
||||||
|
|
||||||
double ratio = inv.getPlayerData().getCollectionSkills().getExperience(profession)
|
double ratio = inv.target.getCollectionSkills().getExperience(profession)
|
||||||
/ (double) inv.getPlayerData().getCollectionSkills().getLevelUpExperience(profession);
|
/ (double) inv.target.getCollectionSkills().getLevelUpExperience(profession);
|
||||||
|
|
||||||
String bar = "" + ChatColor.BOLD;
|
String bar = "" + ChatColor.BOLD;
|
||||||
int chars = (int) (ratio * 20);
|
int chars = (int) (ratio * 20);
|
||||||
for (int j = 0; j < 20; j++)
|
for (int j = 0; j < 20; j++)
|
||||||
bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|";
|
bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|";
|
||||||
|
|
||||||
// holders.register("profession", type.getName());
|
// holders.register("profession", type.getName());
|
||||||
holders.register("progress", bar);
|
holders.register("progress", bar);
|
||||||
holders.register("level", "" + inv.getPlayerData().getCollectionSkills().getLevel(profession));
|
holders.register("level", "" + inv.target.getCollectionSkills().getLevel(profession));
|
||||||
holders.register("xp", inv.getPlayerData().getCollectionSkills().getExperience(profession));
|
holders.register("xp", inv.target.getCollectionSkills().getExperience(profession));
|
||||||
holders.register("percent", decimal.format(ratio * 100));
|
holders.register("percent", decimal.format(ratio * 100));
|
||||||
for (StatInfo stat : MMOCore.plugin.statManager.getLoaded())
|
for (StatInfo stat : MMOCore.plugin.statManager.getLoaded())
|
||||||
if (Objects.equals(stat.profession, profession))
|
if (Objects.equals(stat.profession, profession))
|
||||||
holders.register(stat.name.toLowerCase(), stat.format(stats.getStat(stat.name)));
|
holders.register(stat.name.toLowerCase(), stat.format(stats.getStat(stat.name)));
|
||||||
|
|
||||||
return holders;
|
return holders;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function.equals("profile"))
|
if (function.equals("profile"))
|
||||||
return new PlayerProfileItem(config);
|
return new PlayerProfileItem(config);
|
||||||
|
|
||||||
if (function.equals("stats"))
|
if (function.equals("stats"))
|
||||||
return new InventoryItem(config) {
|
return new InventoryItem<PlayerStatsInventory>(config) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasDifferentDisplay() {
|
public boolean hasDifferentDisplay() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Placeholders getPlaceholders(GeneratedInventory inv, int n) {
|
public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) {
|
||||||
return new Placeholders() {
|
return new Placeholders() {
|
||||||
final net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.getPlayerData().getStats();
|
final net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.target.getStats();
|
||||||
|
|
||||||
public String apply(Player player, String str) {
|
public String apply(Player player, String str) {
|
||||||
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
|
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
|
||||||
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
|
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
|
||||||
String replaced;
|
String replaced;
|
||||||
|
|
||||||
if (holder.endsWith("_base")) {
|
if (holder.endsWith("_base")) {
|
||||||
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5)));
|
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5)));
|
||||||
replaced = info.format(stats.getBase(info.name));
|
replaced = info.format(stats.getBase(info.name));
|
||||||
} else if (holder.endsWith("_extra")) {
|
} else if (holder.endsWith("_extra")) {
|
||||||
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5)));
|
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5)));
|
||||||
replaced = info.format(stats.getStat(info.name) - stats.getBase(info.name));
|
replaced = info.format(stats.getStat(info.name) - stats.getBase(info.name));
|
||||||
} else if (holder.startsWith("attribute_")) {
|
} else if (holder.startsWith("attribute_")) {
|
||||||
PlayerAttribute attr = MMOCore.plugin.attributeManager.get(holder.substring(10).replace("_", "-").toLowerCase());
|
PlayerAttribute attr = MMOCore.plugin.attributeManager.get(holder.substring(10).replace("_", "-").toLowerCase());
|
||||||
replaced = String.valueOf(inv.getPlayerData().getAttributes().getAttribute(attr));
|
replaced = String.valueOf(inv.target.getAttributes().getAttribute(attr));
|
||||||
} else {
|
} else {
|
||||||
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder));
|
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder));
|
||||||
replaced = info.format(stats.getStat(info.name));
|
replaced = info.format(stats.getStat(info.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
str = str.replace("{" + holder + "}", replaced);
|
str = str.replace("{" + holder + "}", replaced);
|
||||||
}
|
}
|
||||||
|
|
||||||
// External placeholders
|
// External placeholders
|
||||||
return MMOCore.plugin.placeholderParser.parse(player, str);
|
return MMOCore.plugin.placeholderParser.parse(player, str);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return new SimplePlaceholderItem(config);
|
return new SimplePlaceholderItem(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerStatsInventory newInventory(PlayerData data) {
|
public PlayerStatsInventory newInventory(PlayerData invTarget, PlayerData opening) {
|
||||||
return new PlayerStatsInventory(data, this);
|
return new PlayerStatsInventory(invTarget, opening, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerStatsInventory extends GeneratedInventory {
|
public PlayerStatsInventory newInventory(PlayerData player) {
|
||||||
private int boostOffset;
|
return new PlayerStatsInventory(player, player, this);
|
||||||
|
}
|
||||||
|
|
||||||
public PlayerStatsInventory(PlayerData playerData, EditableInventory editable) {
|
public class PlayerStatsInventory extends GeneratedInventory {
|
||||||
super(playerData, editable);
|
private final PlayerData target;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private int boostOffset;
|
||||||
public String calculateName() {
|
|
||||||
return getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void whenClicked(InventoryClickEvent event, InventoryItem item) {
|
* @param invTarget Target player
|
||||||
if (item.hasFunction())
|
* @param opening Player opening the inventory
|
||||||
if (item.getFunction().equals("boost-next")) {
|
* @param inv Corresponding editable inventory
|
||||||
boostOffset++;
|
*/
|
||||||
open();
|
public PlayerStatsInventory(PlayerData invTarget, PlayerData opening, EditableInventory inv) {
|
||||||
|
super(opening, inv);
|
||||||
|
|
||||||
} else if (item.getFunction().equals("boost-previous")) {
|
this.target = invTarget;
|
||||||
boostOffset--;
|
}
|
||||||
open();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ItemStack amount(ItemStack item, int amount) {
|
@Override
|
||||||
item.setAmount(amount);
|
public String calculateName() {
|
||||||
return item;
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PartyMoraleItem extends InventoryItem {
|
@Override
|
||||||
public PartyMoraleItem(ConfigurationSection config) {
|
public void whenClicked(InventoryClickEvent event, InventoryItem item) {
|
||||||
super(config);
|
if (item.hasFunction())
|
||||||
}
|
if (item.getFunction().equals("boost-next")) {
|
||||||
|
boostOffset++;
|
||||||
|
open();
|
||||||
|
|
||||||
@Override
|
} else if (item.getFunction().equals("boost-previous")) {
|
||||||
public Placeholders getPlaceholders(GeneratedInventory inv, int n) {
|
boostOffset--;
|
||||||
Placeholders holders = new Placeholders();
|
open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int count = inv.getPlayerData().getParty().getOnlineMembers().size();
|
private ItemStack amount(ItemStack item, int amount) {
|
||||||
holders.register("count", "" + count);
|
item.setAmount(amount);
|
||||||
for (StatModifier buff : MMOCore.plugin.partyManager.getBonuses())
|
return item;
|
||||||
holders.register("buff_" + buff.getStat().toLowerCase(), buff.multiply(count - 1).toString());
|
}
|
||||||
|
|
||||||
return holders;
|
public static class PartyMoraleItem extends InventoryItem<PlayerStatsInventory> {
|
||||||
}
|
public PartyMoraleItem(ConfigurationSection config) {
|
||||||
|
super(config);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canDisplay(GeneratedInventory inv) {
|
public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) {
|
||||||
AbstractParty party = inv.getPlayerData().getParty();
|
Placeholders holders = new Placeholders();
|
||||||
return party != null && party.getOnlineMembers().size() > 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PlayerProfileItem extends InventoryItem {
|
int count = inv.target.getParty().getOnlineMembers().size();
|
||||||
public PlayerProfileItem(ConfigurationSection config) {
|
holders.register("count", "" + count);
|
||||||
super(config);
|
for (StatModifier buff : MMOCore.plugin.partyManager.getBonuses())
|
||||||
}
|
holders.register("buff_" + buff.getStat().toLowerCase(), buff.multiply(count - 1).toString());
|
||||||
|
|
||||||
@Override
|
return holders;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Placeholders getPlaceholders(GeneratedInventory inv, int n) {
|
public boolean canDisplay(PlayerStatsInventory inv) {
|
||||||
PlayerData data = inv.getPlayerData();
|
AbstractParty party = inv.target.getParty();
|
||||||
Placeholders holders = new Placeholders();
|
return party != null && party.getOnlineMembers().size() > 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int nextLevelExp = inv.getPlayerData().getLevelUpExperience();
|
public static class PlayerProfileItem extends InventoryItem<PlayerStatsInventory> {
|
||||||
double ratio = (double) data.getExperience() / (double) nextLevelExp;
|
public PlayerProfileItem(ConfigurationSection config) {
|
||||||
|
super(config);
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder bar = new StringBuilder("" + ChatColor.BOLD);
|
@Override
|
||||||
int chars = (int) (ratio * 20);
|
public ItemStack display(PlayerStatsInventory inv, int n) {
|
||||||
for (int j = 0; j < 20; j++)
|
ItemStack disp = super.display(inv, n);
|
||||||
bar.append(j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "").append("|");
|
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));
|
@Override
|
||||||
holders.register("exp", MythicLib.plugin.getMMOConfig().decimal.format(data.getExperience()));
|
public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) {
|
||||||
holders.register("level", "" + data.getLevel());
|
PlayerData data = inv.target;
|
||||||
holders.register("class_points", "" + data.getClassPoints());
|
Placeholders holders = new Placeholders();
|
||||||
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());
|
|
||||||
|
|
||||||
return holders;
|
int nextLevelExp = inv.target.getLevelUpExperience();
|
||||||
}
|
double ratio = (double) data.getExperience() / (double) nextLevelExp;
|
||||||
}
|
|
||||||
|
|
||||||
public class BoostItem extends SimplePlaceholderItem<PlayerStatsInventory> {
|
StringBuilder bar = new StringBuilder("" + ChatColor.BOLD);
|
||||||
private final InventoryItem noBoost, mainLevel, profession;
|
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) {
|
holders.register("percent", decimal.format(ratio * 100));
|
||||||
super(config);
|
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");
|
return holders;
|
||||||
Validate.notNull(noBoost, "Could not load 'no-boost' config");
|
}
|
||||||
this.noBoost = new SimplePlaceholderItem(noBoost);
|
}
|
||||||
|
|
||||||
ConfigurationSection mainLevel = config.getConfigurationSection("main-level");
|
public class BoostItem extends SimplePlaceholderItem<PlayerStatsInventory> {
|
||||||
Validate.notNull(mainLevel, "Could not load 'main-level' config");
|
private final InventoryItem noBoost, mainLevel, profession;
|
||||||
this.mainLevel = new InventoryItem<PlayerStatsInventory>(mainLevel) {
|
|
||||||
|
|
||||||
@Override
|
public BoostItem(ConfigurationSection config) {
|
||||||
public boolean hasDifferentDisplay() {
|
super(config);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
ConfigurationSection noBoost = config.getConfigurationSection("no-boost");
|
||||||
public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) {
|
Validate.notNull(noBoost, "Could not load 'no-boost' config");
|
||||||
Placeholders holders = new Placeholders();
|
this.noBoost = new SimplePlaceholderItem(noBoost);
|
||||||
Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n);
|
|
||||||
|
|
||||||
holders.register("author", boost.hasAuthor() ? boost.getAuthor() : "Server");
|
ConfigurationSection mainLevel = config.getConfigurationSection("main-level");
|
||||||
holders.register("value", (int) (boost.getExtra() * 100));
|
Validate.notNull(mainLevel, "Could not load 'main-level' config");
|
||||||
holders.register("left", boost.isTimedOut() ?
|
this.mainLevel = new InventoryItem<PlayerStatsInventory>(mainLevel) {
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("booster-expired").message()
|
|
||||||
: new DelayFormat(2).format(boost.getLeft()));
|
|
||||||
|
|
||||||
return holders;
|
@Override
|
||||||
}
|
public boolean hasDifferentDisplay() {
|
||||||
};
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ConfigurationSection profession = config.getConfigurationSection("profession");
|
@Override
|
||||||
Validate.notNull(profession, "Could not load 'profession' config");
|
public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) {
|
||||||
this.profession = new InventoryItem<PlayerStatsInventory>(profession) {
|
Placeholders holders = new Placeholders();
|
||||||
|
Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n);
|
||||||
|
|
||||||
@Override
|
holders.register("author", boost.hasAuthor() ? boost.getAuthor() : "Server");
|
||||||
public boolean hasDifferentDisplay() {
|
holders.register("value", (int) (boost.getExtra() * 100));
|
||||||
return true;
|
holders.register("left", boost.isTimedOut() ?
|
||||||
}
|
MMOCore.plugin.configManager.getSimpleMessage("booster-expired").message()
|
||||||
|
: new DelayFormat(2).format(boost.getLeft()));
|
||||||
|
|
||||||
@Override
|
return holders;
|
||||||
public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) {
|
}
|
||||||
Placeholders holders = new Placeholders();
|
};
|
||||||
Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n);
|
|
||||||
|
|
||||||
holders.register("author", boost.hasAuthor() ? boost.getAuthor() : "Server");
|
ConfigurationSection profession = config.getConfigurationSection("profession");
|
||||||
holders.register("profession", boost.getProfession().getName());
|
Validate.notNull(profession, "Could not load 'profession' config");
|
||||||
holders.register("value", (int) (boost.getExtra() * 100));
|
this.profession = new InventoryItem<PlayerStatsInventory>(profession) {
|
||||||
holders.register("left", boost.isTimedOut() ?
|
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("booster-expired").message()
|
|
||||||
: new DelayFormat(2).format(boost.getLeft()));
|
|
||||||
|
|
||||||
return holders;
|
@Override
|
||||||
}
|
public boolean hasDifferentDisplay() {
|
||||||
};
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasDifferentDisplay() {
|
public Placeholders getPlaceholders(PlayerStatsInventory inv, int n) {
|
||||||
return true;
|
Placeholders holders = new Placeholders();
|
||||||
}
|
Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n);
|
||||||
|
|
||||||
@Override
|
holders.register("author", boost.hasAuthor() ? boost.getAuthor() : "Server");
|
||||||
public ItemStack display(PlayerStatsInventory inv, int n) {
|
holders.register("profession", boost.getProfession().getName());
|
||||||
int offset = inv.boostOffset;
|
holders.register("value", (int) (boost.getExtra() * 100));
|
||||||
if (n + offset >= MMOCore.plugin.boosterManager.getActive().size())
|
holders.register("left", boost.isTimedOut() ?
|
||||||
return noBoost.display(inv, n);
|
MMOCore.plugin.configManager.getSimpleMessage("booster-expired").message()
|
||||||
|
: new DelayFormat(2).format(boost.getLeft()));
|
||||||
|
|
||||||
Booster boost = MMOCore.plugin.boosterManager.get(inv.boostOffset + n);
|
return holders;
|
||||||
return amount(boost.hasProfession() ? profession.display(inv, n) : mainLevel.display(inv, n), n + offset + 1);
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package net.Indyuce.mmocore.gui.api;
|
|||||||
|
|
||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.TriggerItem;
|
import net.Indyuce.mmocore.gui.api.item.TriggerItem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
@ -8,7 +8,6 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
|
|
||||||
public class PlayerProfileCheck implements Listener {
|
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))
|
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(event.getRightClicked().getUniqueId()), PlayerData.get(event.getPlayer())).open();
|
||||||
* 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user