Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,16 @@ public enum MenusLocale implements IDataAccessor {
DIVISIONS_FILTER("DIVISIONS.FILTER-TYPE", "FILL, BORDER, NONE", DataType.STRING, "FILL"),
DIVISIONS_ITEM_NAME("DIVISIONS.ITEM.NAME", DataType.STRING, "<division>"),
DIVISIONS_LORE("DIVISIONS.LORE", DataType.STRING_LIST,
"&7To reach this this rank you", "&7need <elo> elo."),
"&7To reach this rank, you", "&7need <elo> elo."),
PASSED_DIVISIONS_ITEM_NAME("DIVISIONS.PASSED.ITEM.NAME", DataType.STRING, "&a✅ <division>"),
PASSED_DIVISIONS_LORE("DIVISIONS.PASSED.LORE", DataType.STRING_LIST,
"&7You have already reached", "&7this rank."),
DIVISIONS_ELO_BUTTON_ENABLED("DIVISIONS.ELO_BUTTON.ENABLED", DataType.BOOLEAN, "true"),
DIVISIONS_ELO_BUTTON_MATERIAL("DIVISIONS.ELO_BUTTON.MATERIAL", DataType.STRING, "COAL_BLOCK"),
DIVISIONS_ELO_BUTTON_SLOT("DIVISIONS.ELO_BUTTON.SLOT", DataType.INT, "31"),
DIVISIONS_ELO_BUTTON_NAME("DIVISIONS.ELO_BUTTON.NAME", DataType.STRING, "&aYour Elo: &b<elo>"),
DIVISIONS_ELO_BUTTON_LORE("DIVISIONS.ELO_BUTTON.LORE", DataType.STRING_LIST,
""),
SETTINGS_TITLE("SETTINGS.TITLE", DataType.STRING, "&7Profile Settings"),
SETTINGS_SIZE("SETTINGS.SIZE", DataType.INT, "27"),
SETTINGS_FILTER("SETTINGS.FILTER-TYPE", "FILL, BORDER, NONE", DataType.STRING, "FILL"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.lrxh.neptune.feature.divisions.menu;

import dev.lrxh.neptune.API;
import dev.lrxh.neptune.configs.impl.MenusLocale;
import dev.lrxh.neptune.feature.divisions.DivisionService;
import dev.lrxh.neptune.feature.divisions.impl.Division;
Expand All @@ -10,6 +11,8 @@
import dev.lrxh.neptune.utils.menu.Filter;
import dev.lrxh.neptune.utils.menu.Menu;
import dev.lrxh.neptune.utils.menu.impl.DisplayButton;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

Expand All @@ -32,15 +35,26 @@ public List<Button> getButtons(Player player) {
for (Division division : divisions) {
buttons.add(new DisplayButton(division.getSlot(), getItemStack(player, division)));
}
if (MenusLocale.DIVISIONS_ELO_BUTTON_ENABLED.getBoolean()) {
buttons.add(new DisplayButton(MenusLocale.DIVISIONS_ELO_BUTTON_SLOT.getInt(), new ItemBuilder(MenusLocale.DIVISIONS_ELO_BUTTON_MATERIAL.getString()).name(MenusLocale.DIVISIONS_ELO_BUTTON_NAME.getString().replace("<elo>", String.valueOf(API.getProfile(player).getGameData().getGlobalStats().getElo())))
.lore(ItemUtils.getLore(MenusLocale.DIVISIONS_ELO_BUTTON_LORE.getStringList(), new Replacement("<elo>", String.valueOf(API.getProfile(player).getGameData().getGlobalStats().getElo()))), player)
.build()));
}

return buttons;
}

public ItemStack getItemStack(Player player, Division division) {
return new ItemBuilder(division.getMaterial())
.name(MenusLocale.DIVISIONS_ITEM_NAME.getString().replace("<division>", division.getDisplayName()))
.lore(ItemUtils.getLore(MenusLocale.DIVISIONS_LORE.getStringList(), new Replacement("<elo>", String.valueOf(division.getEloRequired()))), player)

.build();
Division playerDivision = DivisionService.get().getDivisionByElo(API.getProfile(player).getGameData().getGlobalStats().getElo());
ItemBuilder builder = new ItemBuilder(division.getMaterial());
if (playerDivision.getEloRequired() >= division.getEloRequired()) {
builder = builder.name(MenusLocale.PASSED_DIVISIONS_ITEM_NAME.getString().replace("<division>", division.getDisplayName()).replace("<elo>", String.valueOf(division.getEloRequired())))
.lore(ItemUtils.getLore(MenusLocale.PASSED_DIVISIONS_LORE.getStringList(), new Replacement("<division>", division.getDisplayName()), new Replacement("<elo>", String.valueOf(division.getEloRequired()))), player)
.addEnchantedGlow();
} else {
builder = builder.name(MenusLocale.DIVISIONS_ITEM_NAME.getString().replace("<division>", division.getDisplayName()).replace("<elo>", String.valueOf(division.getEloRequired())))
.lore(ItemUtils.getLore(MenusLocale.DIVISIONS_LORE.getStringList(), new Replacement("<division>", division.getDisplayName()), new Replacement("<elo>", String.valueOf(division.getEloRequired()))), player);
}
return builder.build();
}
}
13 changes: 12 additions & 1 deletion Plugin/src/main/java/dev/lrxh/neptune/utils/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.kyori.adventure.text.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
Expand Down Expand Up @@ -134,9 +135,19 @@ public ItemBuilder amount(int amount) {
item.setAmount(amount <= 0 ? 1 : Math.min(amount, 64));
return this;
}


public ItemBuilder addEnchantedGlow() {
ItemMeta meta = item.getItemMeta();
if (meta != null) {
meta.addEnchant(Enchantment.UNBREAKING, 1, true);
item.setItemMeta(meta);
}
return this;
}

public ItemStack build() {
clearFlags();
return item;
}

}