use of eu.pb4.graves.grave.GraveInfo in project UniversalGraves by Patbox.
the class GraveListGui method updateIcons.
private void updateIcons() {
var config = ConfigManager.getConfig();
for (int x = 0; x < this.size; x++) {
this.clearSlot(x);
}
for (GraveInfo graveInfo : GraveManager.INSTANCE.getByUuid(this.targetUUID)) {
if (this.getFirstEmptySlot() == -1) {
return;
}
Map<String, Text> placeholders = graveInfo.getPlaceholders();
List<Text> parsed = new ArrayList<>();
for (Text text : graveInfo.isProtected() ? ConfigManager.getConfig().guiProtectedText : ConfigManager.getConfig().guiText) {
MutableText out = (MutableText) PlaceholderAPI.parsePredefinedText(text, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders);
if (out.getStyle().getColor() == null) {
out.setStyle(out.getStyle().withColor(Formatting.WHITE));
}
parsed.add(out);
}
var list = graveInfo.isProtected() ? config.guiProtectedItem : config.guiItem;
this.addSlot(GuiElementBuilder.from(list[Math.abs(graveInfo.hashCode() % list.length)]).setName((MutableText) parsed.remove(0)).setLore(parsed).setCallback((index, type, action) -> {
if (Permissions.check(this.player, "universal_graves.teleport", 3)) {
this.close();
ServerWorld world = this.player.getServer().getWorld(RegistryKey.of(Registry.WORLD_KEY, graveInfo.getWorld()));
if (world != null) {
var pos = graveInfo.getPosition();
this.player.teleport(world, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, this.player.getYaw(), this.player.getPitch());
}
}
}));
}
}
Aggregations