new version 1.3.3
This commit is contained in:
parent
2d5c5eea48
commit
d9eb747c1b
37 changed files with 1021 additions and 471 deletions
|
|
@ -85,7 +85,9 @@ public class ParkourPlayer extends ParkourUser {
|
|||
* @return player as a {@link ParkourPlayer}, null if not found.
|
||||
*/
|
||||
public static @Nullable ParkourPlayer getPlayer(@NotNull Player player) {
|
||||
return getPlayers().stream()
|
||||
// Optimized: search directly in sessions without creating intermediate list
|
||||
return Divider.sections.keySet().stream()
|
||||
.flatMap(session -> session.getPlayers().stream())
|
||||
.filter(other -> other.getUUID().equals(player.getUniqueId()))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
|
|
@ -166,10 +168,7 @@ public class ParkourPlayer extends ParkourUser {
|
|||
player.getInventory().clear();
|
||||
|
||||
// Load hotbar slots from config
|
||||
if (ParkourOption.PLAY.mayPerform(player)) {
|
||||
int slot = Config.CONFIG.getInt("options.hotbar-slots.play");
|
||||
player.getInventory().setItem(slot, Locales.getItem(locale, "play.item").build());
|
||||
}
|
||||
// Don't show Play button when already in parkour
|
||||
if (ParkourOption.COMMUNITY.mayPerform(player)) {
|
||||
int slot = Config.CONFIG.getInt("options.hotbar-slots.community");
|
||||
player.getInventory().setItem(slot, Locales.getItem(locale, "community.item").build());
|
||||
|
|
@ -192,6 +191,33 @@ public class ParkourPlayer extends ParkourUser {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates hotbar items with current language
|
||||
*/
|
||||
public void updateHotbar() {
|
||||
if (!Config.CONFIG.getBoolean("options.inventory-handling")) return;
|
||||
|
||||
player.getInventory().clear();
|
||||
|
||||
// Don't show Play button when already in parkour
|
||||
if (ParkourOption.COMMUNITY.mayPerform(player)) {
|
||||
int slot = Config.CONFIG.getInt("options.hotbar-slots.community");
|
||||
player.getInventory().setItem(slot, Locales.getItem(locale, "community.item").build());
|
||||
}
|
||||
if (ParkourOption.SETTINGS.mayPerform(player)) {
|
||||
int slot = Config.CONFIG.getInt("options.hotbar-slots.settings");
|
||||
player.getInventory().setItem(slot, Locales.getItem(locale, "settings.item").build());
|
||||
}
|
||||
if (ParkourOption.LOBBY.mayPerform(player)) {
|
||||
int slot = Config.CONFIG.getInt("options.hotbar-slots.lobby");
|
||||
player.getInventory().setItem(slot, Locales.getItem(locale, "lobby.item").build());
|
||||
}
|
||||
if (ParkourOption.QUIT.mayPerform(player)) {
|
||||
int slot = Config.CONFIG.getInt("options.hotbar-slots.quit");
|
||||
player.getInventory().setItem(slot, Locales.getItem(locale, "other.quit").build());
|
||||
}
|
||||
}
|
||||
|
||||
public record OptionContainer(ParkourOption option, BiConsumer<ParkourPlayer, String> consumer) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue