fix(elytra,chat): make elytra sub-modes report their mode and wire the chat-scope toggle
- ElytraGenerator no longer hardcodes Modes.elytra(): the mode is passed through the constructor (canonical (session, pointType, mode) plus two convenience overloads); CloseGenerator/MinSpeed/Obstacle/SpeedDemon/ TimeTrial now declare their own mode, so getMode() is reachable - Session.ChatType gets next(); ParkourUser gets setChatType(); SettingsMenu gains a chat-scope cycle button (slot 15) so LOBBY_ONLY/PLAYERS_ONLY are no longer dead branches - ChatTypeTest covers the cycle order and wrap-around - TODO.md: PROGRESS-8 records both fixes checkstyle 0 error / 135 warning, PMD 0, tests 96/0 fail (1 skipped)
This commit is contained in:
parent
02e2947f47
commit
8ff02cff18
11 changed files with 122 additions and 17 deletions
|
|
@ -8,14 +8,19 @@ import dev.loki.loparkour.player.core.ParkourPlayer;
|
|||
import dev.loki.loparkour.player.core.ParkourUser;
|
||||
import dev.loki.loparkour.menu.gui.inventory.InventoryGui;
|
||||
import dev.loki.loparkour.player.service.UserRegistry;
|
||||
import dev.loki.loparkour.session.core.Session;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SettingsMenu extends LPMenu {
|
||||
|
||||
private static final int ROWS = 3;
|
||||
private static final int SLOT_PARKOUR_SETTINGS = 11;
|
||||
private static final int SLOT_LANG = 13;
|
||||
private static final int SLOT_CHAT = 15;
|
||||
private static final int SLOT_CLOSE = 22;
|
||||
|
||||
@Override
|
||||
|
|
@ -44,7 +49,24 @@ public class SettingsMenu extends LPMenu {
|
|||
});
|
||||
}
|
||||
|
||||
final ParkourUser user = ParkourUser.getUser(player);
|
||||
if (ParkourOption.CHAT.mayPerform(player) && user != null) {
|
||||
gui = gui.setItem(SLOT_CHAT, chatItem(user), e -> {
|
||||
user.setChatType(user.chatType().next());
|
||||
open(player);
|
||||
});
|
||||
}
|
||||
|
||||
gui.setItem(SLOT_CLOSE, closeButton(player), e -> player.closeInventory())
|
||||
.open(player);
|
||||
}
|
||||
|
||||
/** Scope button — the locale lists its values in {@link Session.ChatType#next()} order. */
|
||||
private ItemStack chatItem(@NotNull ParkourUser user) {
|
||||
final String locale = user.locale();
|
||||
final List<String> values = Locales.getStringList(locale, "settings.chat.values");
|
||||
final Session.ChatType chatType = user.chatType();
|
||||
final String label = chatType.ordinal() < values.size() ? values.get(chatType.ordinal()) : chatType.name();
|
||||
return localeItem(locale, "settings.chat", label);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue