Merge pull request 'Fix TablistManager' (#283) from FixTablist into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #283 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
c74873b75c
@ -103,7 +103,7 @@ public class TablistManager extends BasicListener {
|
|||||||
if(bau.size() > 0)
|
if(bau.size() > 0)
|
||||||
tablist.addSubTablist(bau);
|
tablist.addSubTablist(bau);
|
||||||
|
|
||||||
size = (int) Math.ceil(tablist.size() / 20.0);
|
size = (int) Math.ceil((tablist.size() - 1) / 20.0);
|
||||||
tablists.values().forEach(Tablist::refresh);
|
tablists.values().forEach(Tablist::refresh);
|
||||||
seconds++;
|
seconds++;
|
||||||
}
|
}
|
||||||
@ -197,10 +197,11 @@ public class TablistManager extends BasicListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int slimSize(ProxiedPlayer viewer) {
|
public int slimSize(ProxiedPlayer viewer) {
|
||||||
int size = subTablists.stream().mapToInt(tPart -> viewer == null ? tPart.size() : tPart.slimSize(viewer)).sum();
|
return subTablists.stream().mapToInt(tPart -> viewer == null ? tPart.size() : tPart.slimSize(viewer)).map(size -> {
|
||||||
if(withHeaders)
|
size += withHeaders ? 1 : 0; // Space for header
|
||||||
size += subTablists.size() * 2;
|
size += withHeaders && size > 1 ? 1 : 0; // Space for footer
|
||||||
return size;
|
return size;
|
||||||
|
}).sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -210,8 +211,10 @@ public class TablistManager extends BasicListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void print(Tablist viewer, boolean slim) {
|
public void print(Tablist viewer, boolean slim) {
|
||||||
subTablists.forEach(tPart -> {
|
for (int i = 0; i < subTablists.size(); i++) {
|
||||||
if(withHeaders)
|
TablistPart tPart = subTablists.get(i);
|
||||||
|
boolean withoutFooter = i == subTablists.size() - 1;
|
||||||
|
if (withHeaders) {
|
||||||
if (slim) {
|
if (slim) {
|
||||||
int slimSize = tPart.slimSize(viewer.player);
|
int slimSize = tPart.slimSize(viewer.player);
|
||||||
int size = tPart.size();
|
int size = tPart.size();
|
||||||
@ -219,16 +222,19 @@ public class TablistManager extends BasicListener {
|
|||||||
viewer.setSlot(gray, "§7§l" + tPart.name(), 1000);
|
viewer.setSlot(gray, "§7§l" + tPart.name(), 1000);
|
||||||
} else if (slimSize == 0) {
|
} else if (slimSize == 0) {
|
||||||
viewer.setSlot(gray, "§7§l" + tPart.name() + " §8(§7" + size + "§8)", 1000);
|
viewer.setSlot(gray, "§7§l" + tPart.name() + " §8(§7" + size + "§8)", 1000);
|
||||||
|
withoutFooter = true;
|
||||||
} else {
|
} else {
|
||||||
viewer.setSlot(gray, "§7§l" + tPart.name() + " §8(§7+" + (size - slimSize) + "§8)", 1000);
|
viewer.setSlot(gray, "§7§l" + tPart.name() + " §8(§7+" + (size - slimSize) + "§8)", 1000);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
viewer.setSlot(gray, "§7§l" + tPart.name(), 1000);
|
viewer.setSlot(gray, "§7§l" + tPart.name(), 1000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
tPart.print(viewer, slim);
|
tPart.print(viewer, slim);
|
||||||
if(withHeaders)
|
if (withHeaders && !withoutFooter) {
|
||||||
viewer.setSlot(darkGray, "", 1000);
|
viewer.setSlot(darkGray, "", 1000);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren