9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-19 15:09:23 +00:00

catch more errors

This commit is contained in:
XiaoMoMi
2025-09-28 02:57:50 +08:00
parent d9d129cd97
commit 8a4b0e1c23
2 changed files with 45 additions and 8 deletions

View File

@@ -526,15 +526,32 @@ public class BukkitPlatform implements Platform {
Placeholder placeholder;
if (id.startsWith("%rel_")) {
placeholder = plugin.getPlaceholderManager().registerRelationalPlaceholder(id,
// viewer // owner
(p1, p2) -> PlaceholderAPI.setRelationalPlaceholders((Player) p2.player(), (Player) p1.player(), id));
(p1, p2) -> {
try {
return PlaceholderAPI.setRelationalPlaceholders((Player) p2.player(), (Player) p1.player(), id);
} catch (Exception e) {
return id;
}
});
} else if (id.startsWith("%shared_")) {
String sub = "%" + id.substring("%shared_".length());
placeholder =plugin.getPlaceholderManager().registerSharedPlaceholder(id,
() -> PlaceholderAPI.setPlaceholders(null, sub));
() -> {
try {
return PlaceholderAPI.setPlaceholders(null, sub);
} catch (Exception e) {
return sub;
}
});
} else {
placeholder = plugin.getPlaceholderManager().registerPlayerPlaceholder(id,
(p) -> p == null ? PlaceholderAPI.setPlaceholders(null, id) : PlaceholderAPI.setPlaceholders((OfflinePlayer) p.player(), id));
(p) -> {
try {
return p == null ? PlaceholderAPI.setPlaceholders(null, id) : PlaceholderAPI.setPlaceholders((OfflinePlayer) p.player(), id);
} catch (Exception e) {
return id;
}
});
}
return placeholder;
}