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 @@ -61,7 +61,7 @@ public void build() {

@Override
public void update() {
// ── Read config ────────────────────────────────────────
// Read config
String rawTitle = GUIFile.getString("GUIS.MATCH-HISTORY.TITLE");
if (rawTitle == null || rawTitle.isEmpty())
rawTitle = "<dark_gray>Match History <gray>- <gold>%player%";
Expand All @@ -73,14 +73,14 @@ public void update() {
boolean centerItems = getBooleanOrDefault("GUIS.MATCH-HISTORY.CENTER-ITEMS", true);
int configuredStart = GUIFile.getInt("GUIS.MATCH-HISTORY.START-SLOT"); // -1 means auto

// ── Build inventory ────────────────────────────────────
// Build inventory
Inventory inventory = InventoryUtil.createInventory(rawTitle, size / 9);

// Fill with configurable glass pane
ItemStack filler = buildFillerItem();
for (int i = 0; i < size; i++) inventory.setItem(i, filler);

// ── Determine where to place the match items ───────────
// Determine where to place the match items
int startSlot;
if (configuredStart >= 0) {
startSlot = configuredStart;
Expand All @@ -90,7 +90,7 @@ public void update() {
startSlot = 0;
}

// ── Place match items ──────────────────────────────────
// Place match items
String materialStr = GUIFile.getString("GUIS.MATCH-HISTORY.MATCH-ITEM.MATERIAL");
Material material = Material.PAPER;
if (materialStr != null && !materialStr.isBlank()) {
Expand All @@ -110,8 +110,7 @@ public void update() {
gui.put(1, inventory);
}

// ── Item builders ────────────────────────────────────────────

// Item builders
private ItemStack buildMatchItem(MatchHistoryEntry entry,
Material fallbackMaterial,
boolean usePlayerHead) {
Expand All @@ -138,14 +137,14 @@ private ItemStack buildMatchItem(MatchHistoryEntry entry,
int myScore = getMyScore(entry);
int oppScore = getOpponentScore(entry);

// ── Name ──────────────────────────────────────────────
// Name
String rawName = GUIFile.getString("GUIS.MATCH-HISTORY.MATCH-ITEM.NAME");
if (rawName == null || rawName.isBlank())
rawName = "<yellow>Match vs <white>%opponent%";
String displayName = applyPlaceholders(rawName, entry, oppName,
result, myScore, oppScore, myHealth, oppHealth, won, draw);

// ── Lore ──────────────────────────────────────────────
// Lore
List<String> loreCfg = GUIFile.getStringList("GUIS.MATCH-HISTORY.MATCH-ITEM.LORE");
if (loreCfg == null || loreCfg.isEmpty()) {
loreCfg = defaultLore();
Expand All @@ -156,7 +155,7 @@ private ItemStack buildMatchItem(MatchHistoryEntry entry,
.map(line -> Common.legacyToComponent(StringUtil.CC(line)))
.collect(Collectors.toList());

// ── ItemStack ─────────────────────────────────────────
// ItemStack
ItemStack item;
if (usePlayerHead) {
item = buildSkull(oppUuid, oppName);
Expand Down Expand Up @@ -218,8 +217,7 @@ private ItemStack buildFillerItem() {
return item;
}

// ── Centering logic ──────────────────────────────────────────

// Centering logic
/**
* Computes the first slot so that {@code count} items are centred
* inside the inventory. Works row-by-row:
Expand All @@ -242,8 +240,7 @@ private int computeCenterStart(int size, int count) {
return startRow * 9 + startCol;
}

// ── Placeholder helpers ──────────────────────────────────────

// Placeholder helpers
private String applyPlaceholders(String text, MatchHistoryEntry entry,
String oppName, String result,
int myScore, int oppScore,
Expand All @@ -266,8 +263,7 @@ private String formatHealth(double raw) {
return String.format("%.1f❤", raw / 2.0);
}

// ── Perspective helpers ──────────────────────────────────────

// Perspective helpers
private boolean isViewer(MatchHistoryEntry e) {
return viewerUuid != null && e.getPlayerUuid().equals(viewerUuid);
}
Expand Down Expand Up @@ -296,8 +292,7 @@ private int getOpponentScore(MatchHistoryEntry e) {
return isViewer(e) ? e.getOpponentScore() : e.getPlayerScore();
}

// ── Default lore ─────────────────────────────────────────────

// Default lore
private List<String> defaultLore() {
List<String> lore = new ArrayList<>();
lore.add("<dark_gray><st>--------------------");
Expand All @@ -313,8 +308,7 @@ private List<String> defaultLore() {
return lore;
}

// ── Utility ─────────────────────────────────────────────────

// Utility
private boolean getBooleanOrDefault(String path, boolean def) {
if (GUIFile.getConfig().isSet(path.toUpperCase()))
return GUIFile.getConfig().getBoolean(path.toUpperCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ public void handleClickEvent(InventoryClickEvent e) {
}
}

// ── Button builders ──────────────────────────────────────────────

// Button builders
private ItemStack buildTrimsButton() {
String name = GUIFile.getConfig().getString(
"GUIS.COSMETICS.HUB.BUTTONS.ARMOR-TRIMS.NAME", "<gold>✦ Armor Trims");
Expand Down Expand Up @@ -161,8 +160,7 @@ private ItemStack buildLobbyItemsButton() {
return item.get();
}

// ── Helpers ──────────────────────────────────────────────────────

// Helpers
private List<String> getOrDefaultLore(String key, List<String> defaults) {
List<String> lore = GUIFile.getConfig().getStringList(key);
return lore.isEmpty() ? defaults : lore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ public void handleClickEvent(InventoryClickEvent e) {
}
}

// ── Apply / unapply ──────────────────────────────────────────────

// Apply / unapply
private void handleApply(Player player) {
int current = profile.getCosmeticsData().getActiveShieldLayoutIndex();
if (current == layoutIndex) {
Expand All @@ -204,8 +203,7 @@ private void handleApply(Player player) {
update(true);
}

// ── Item builders ────────────────────────────────────────────────

// Item builders
private ItemStack buildPreviewShield(ShieldLayout layout) {
ItemStack shield = new ItemStack(Material.SHIELD);
ShieldCosmeticsUtil.applyLayoutToItem(shield, layout);
Expand Down Expand Up @@ -272,8 +270,7 @@ private ItemStack buildLayerItem(ShieldLayout.PatternLayer layer, int index) {
return stack;
}

// ── Helpers ──────────────────────────────────────────────────────

// Helpers
private ShieldLayout getLayout() {
List<ShieldLayout> layouts = profile.getCosmeticsData().getShieldLayouts();
if (layoutIndex < 0 || layoutIndex >= layouts.size()) return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ private void handleRename(Player player, int index) {
.open(player);
}

// ── Builders ─────────────────────────────────────────────────────

// Builders
private ItemStack buildLayoutItem(ShieldLayout layout, int index, boolean active) {
ItemStack shield = new ItemStack(Material.SHIELD);
ShieldCosmeticsUtil.applyLayoutToItem(shield, layout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ private void handlePatternPick(Player player, PatternType pattern) {
backToGui.open(player);
}

// ── Item builder ─────────────────────────────────────────────────

// Item builder
private ItemStack buildPatternItem(PatternType pattern) {
// Material already encodes the base colour (e.g. RED_BANNER for RED).
// In 1.21.1 BannerMeta no longer has setBaseColor(); the colour is the Material.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ public static ItemStack getCacheInfoItem() {
return buildItem(Material.CLOCK, "<yellow>Auto-Update Info", lore);
}

// ── Item building helpers ────────────────────────────────────────────────

// Item building helpers
/** Builds an ItemStack from an existing icon with a parsed name and lore. */
private static ItemStack buildItem(ItemStack icon, String name, List<String> lore) {
ItemStack item = icon != null ? icon.clone() : new ItemStack(Material.BARRIER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class NametagManager {
private static final boolean LOW_HEALTH_RATIO = dev.nandi0813.practice.manager.backend.ConfigManager.getBoolean("MATCH-SETTINGS.HEALTH-BELOW-NAME.DECIMAL-HEART-INDICATOR.LOW-HEALTH-DECIMAL-RATIO");
private static final double LOW_HEALTH_THRESHOLD = dev.nandi0813.practice.manager.backend.ConfigManager.getDouble("MATCH-SETTINGS.HEALTH-BELOW-NAME.LOW-HEALTH-THRESHOLD") * 2.0;
private static final double CONFIG_SCALE = dev.nandi0813.practice.manager.backend.ConfigManager.getDouble("MATCH-SETTINGS.HEALTH-BELOW-NAME.SCALE");
private static final String HEALTH_SYMBOL = dev.nandi0813.practice.manager.backend.ConfigManager.getString("MATCH-SETTINGS.HEALTH-BELOW-NAME.SYMBOL");

private static final String BELOW_NAME_OBJECTIVE = "ZPP_BELOW";

Expand Down Expand Up @@ -485,11 +486,11 @@ private Component formatHealth(Player player, double health) {

if (DECIMAL_ALWAYS_SHOW || (LOW_HEALTH_RATIO && health < LOW_HEALTH_THRESHOLD)) {
return Component.text(String.format(java.util.Locale.US, "%.1f", displayHealth), NamedTextColor.WHITE)
.append(Component.text("♥", heartColor));
.append(Component.text(HEALTH_SYMBOL, heartColor));
}

return Component.text((int) Math.ceil(displayHealth) + " ", NamedTextColor.WHITE)
.append(Component.text("♥", heartColor));
return Component.text((int) Math.ceil(displayHealth), NamedTextColor.WHITE)
.append(Component.text(HEALTH_SYMBOL, heartColor));
}

private boolean isSaturated(Player player) {
Expand Down Expand Up @@ -609,18 +610,6 @@ private void stopBelowNameRefreshTask() {
}
}

private void reapplyHideTeamLater(Player player) {
if (player == null) {
return;
}

Bukkit.getScheduler().runTaskLater(ZonePractice.getInstance(), () -> {
if (player.isOnline()) {
hideVanillaNametag(player);
}
}, 1L);
}

private void hideVanillaNametag(Player player) {
if (!PermanentConfig.NAMETAG_MANAGEMENT_ENABLED) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void handleClickEvent(InventoryClickEvent e) {
KitItem kitItem = editing.getKitItem();
GUI mainGUI = editing.getCustomLadder().getMainGUI();

// ── Back ──────────────────────────────────────────────────────
// Back
if (icon.equals(StaticItems.CATEGORY_GUI_BACK_ICON)) {
if (editing.isEditingShulker()) {
dev.nandi0813.practice.manager.playerkit.guis.ShulkerBoxEditorGUI editor = editing.getShulkerEditor();
Expand All @@ -120,7 +120,7 @@ public void handleClickEvent(InventoryClickEvent e) {
return;
}

// ── None ─────────────────────────────────────────────────────
// None
if (icon.equals(StaticItems.CATEGORY_GUI_NONE_ICON)) {
kitItem.reset();
if (editing.isEditingShulker()) {
Expand All @@ -137,7 +137,7 @@ public void handleClickEvent(InventoryClickEvent e) {
return;
}

// ── Fixed categories ─────────────────────────────────────────
// Fixed categories
if (icon.equals(StaticItems.CATEGORY_GUI_ARMOR_ICON)) {
GUIManager.getInstance().searchGUI(GUIType.PlayerCustom_Armor).open(player);
return;
Expand All @@ -159,7 +159,7 @@ public void handleClickEvent(InventoryClickEvent e) {
return;
}

// ── Dynamic categories ───────────────────────────────────────
// Dynamic categories
for (DynamicCategory cat : PlayerKitManager.getInstance().getDynamicCategories()) {
if (icon.equals(cat.getIcon())) {
cat.getGui().open(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public boolean removeTopLayer() {
return true;
}

// ── Serialisation helpers ────────────────────────────────────────

// Serialisation helpers
/** Serialise to a single string for YAML storage: "name|BASE_COLOR|COLOR:PATTERN,COLOR:PATTERN,..." */
public String serialise() {
var bannerPatternRegistry = RegistryAccess.registryAccess().getRegistry(RegistryKey.BANNER_PATTERN);
Expand Down Expand Up @@ -112,8 +111,7 @@ private static PatternType parsePatternType(String raw) {
private static String escapePipe(String s) { return s.replace("|", "\\|"); }
private static String unescapePipe(String s) { return s.replace("\\|", "|"); }

// ── PatternLayer record ──────────────────────────────────────────

// PatternLayer record
public record PatternLayer(DyeColor color, PatternType pattern) {
@Override
public boolean equals(Object obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public enum NameFormatUtil {

private static final PlainTextComponentSerializer PLAIN_TEXT_SERIALIZER = PlainTextComponentSerializer.plainText();

// ── Color helpers ────────────────────────────────────────────────────────

// Color helpers
private static TextColor findFirstExplicitColor(Component component) {
if (component == null) return null;
if (component.color() != null) return component.color();
Expand Down Expand Up @@ -51,8 +50,7 @@ public static TextColor extractTrailingColor(Component component) {
return findLastExplicitColor(component);
}

// ── Template / placeholder helpers ──────────────────────────────────────

// Template / placeholder helpers
public static Component parseConfiguredComponent(String raw) {
if (raw == null || raw.isEmpty()) return Component.empty();
return ZonePractice.getMiniMessage().deserialize(StringUtil.legacyToMiniMessage(raw));
Expand Down Expand Up @@ -102,8 +100,7 @@ public static String normalizePlayerNameTemplate(String rawTemplate) {
return rawTemplate + "%player%";
}

// ── Internal rendering ───────────────────────────────────────────────────

// Internal rendering
private static Component renderTemplate(String rawTemplate, Profile profile, String playerName) {
return renderTemplate(rawTemplate, profile, playerName, null);
}
Expand Down Expand Up @@ -146,8 +143,7 @@ private static Component renderTemplate(String rawTemplate, Profile profile, Str
return ZonePractice.getMiniMessage().deserialize(normalized);
}

// ── Public resolution API ────────────────────────────────────────────────

// Public resolution API
public static Component resolvePrefix(Profile profile) {
return resolvePrefix(profile, null);
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION: 58
VERSION: 59

# Mysql database setup.
MYSQL-DATABASE:
Expand Down Expand Up @@ -265,6 +265,7 @@ MATCH-SETTINGS:
LOW-HEALTH-DECIMAL-RATIO: true # If true, health below 2 hearts is shown as a decimal ratio (current/max).
LOW-HEALTH-THRESHOLD: 4.0
SCALE: 20 # The scale setting defines the health display range between 10 and 100 with a default value of 20.
SYMBOL: "♥" # The symbol displayed after the health value in the below-name display.
BUILD-LIMIT-DEFAULT: 4 # Counts from the first players positions Y level. You can set a unique number for this for every arena, then it will consider where you are standing.
AFTER-COUNTDOWN: 3 # After the match is over this countdown start, and when it's over, the players teleport back to the lobby.
ROLLBACK:
Expand Down