Skip to content

Commit 58814bc

Browse files
author
NEZNAMY
committed
[API] [Layout] Add method for fixed slot ping as string
1 parent 9e7556c commit 58814bc

File tree

2 files changed

+21
-0
lines changed
  • api/src/main/java/me/neznamy/tab/api/tablist/layout
  • shared/src/main/java/me/neznamy/tab/shared/features/layout/pattern

2 files changed

+21
-0
lines changed

api/src/main/java/me/neznamy/tab/api/tablist/layout/Layout.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ public interface Layout {
6565
*/
6666
void addFixedSlot(int slot, @NonNull String text, @NonNull String skin, int ping);
6767

68+
/**
69+
* Adds fixed slot with specified parameters
70+
*
71+
* @param slot
72+
* Slot (1-80)
73+
* @param text
74+
* Text to display
75+
* @param skin
76+
* Skin definition like in config
77+
* @param ping
78+
* Slot's ping, accepts placeholders that evaluate to a number
79+
*/
80+
void addFixedSlot(int slot, @NonNull String text, @NonNull String skin, @NonNull String ping);
81+
6882
/**
6983
* Adds a player group.
7084
*

shared/src/main/java/me/neznamy/tab/shared/features/layout/pattern/LayoutPattern.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ public void addFixedSlot(int slot, @NonNull String text, @NonNull String skin, i
117117
fixedSlots.put(slot, new FixedSlot(manager, slot, this, manager.getUUID(slot), text, skin, null, ping));
118118
}
119119

120+
@Override
121+
public void addFixedSlot(int slot, @NonNull String text, @NonNull String skin, @NonNull String ping) {
122+
ensureActive();
123+
if (slot < 1 || slot > slotCount) throw new IllegalArgumentException("Slot must be between 1 - " + slotCount + " (was " + slot + ")");
124+
fixedSlots.put(slot, new FixedSlot(manager, slot, this, manager.getUUID(slot), text, skin, ping, manager.getConfiguration().getEmptySlotPing()));
125+
}
126+
120127
@Override
121128
public void addGroup(@Nullable String condition, int[] slots) {
122129
ensureActive();

0 commit comments

Comments
 (0)