Compare commits
1 Commits
world-syst
...
SettingsCo
| Author | SHA1 | Date | |
|---|---|---|---|
| 08afee6f38 |
@@ -254,12 +254,27 @@ class SteamwarUser(id: EntityID<Int>): IntEntity(id) {
|
||||
punishments[punishment] = Punishment.createPunishment(this@SteamwarUser.id.value, from, punishment, reason, time, perma)
|
||||
}
|
||||
|
||||
fun setLocale(locale: Locale?, manualeLocale: Boolean) {
|
||||
if (locale == null || (this.manualLocale && !manualLocale)) return
|
||||
fun setJoinLocale(locale: Locale?) {
|
||||
if (locale == null || this.manualLocale) return
|
||||
setCurrentLocale(locale)
|
||||
}
|
||||
|
||||
fun setCurrentLocale(locale: Locale?) {
|
||||
if (locale == null) return
|
||||
useDb {
|
||||
this@SteamwarUser.locale = locale
|
||||
this@SteamwarUser.manualLocale = manualeLocale
|
||||
}
|
||||
}
|
||||
|
||||
fun lockLocale() {
|
||||
useDb {
|
||||
this@SteamwarUser.manualLocale = true
|
||||
}
|
||||
}
|
||||
|
||||
fun unlockLocale() {
|
||||
useDb {
|
||||
this@SteamwarUser.manualLocale = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ object TeamTable : IntIdTable("Team", "TeamID") {
|
||||
|
||||
class Team(id: EntityID<Int>) : IntEntity(id) {
|
||||
companion object : IntEntityClass<Team>(TeamTable) {
|
||||
const val PUBLIC: Int = 0
|
||||
|
||||
private val teamCache = mutableMapOf<Int, Team>()
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -17,6 +17,19 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
LOCALE = English
|
||||
|
||||
SETTINGS_TITLE = Settings
|
||||
SETTINGS_LOCALE_ITEM = §fLocale
|
||||
SETTINGS_LOCALE_CURRENT = §fCurrent locale §e{0}§8.
|
||||
SETTINGS_LOCALE_LOCKED = §cLocked§f to the current locale§8.
|
||||
SETTINGS_LOCALE_UNLOCKED = §aChanged§f by Client locale§8.
|
||||
SETTINGS_PREFIX_ITEM = §fChat prefix
|
||||
SETTINGS_PREFIX_SELECTED = §a> {0}
|
||||
SETTINGS_PREFIX_UNSELECTED = §f> {0}
|
||||
SETTINGS_PREFIX_SW = §eS§8W
|
||||
SETTINGS_PREFIX_TEAM = §{0}{1}
|
||||
|
||||
COMMAND_SYSTEM_ERROR = §cError executing the command!
|
||||
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
LOCALE = Deutsch
|
||||
|
||||
COMMAND_SYSTEM_ERROR = §cFehler beim Ausführen des Befehls!
|
||||
|
||||
PREFIX=§eSteam§8War»
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||
import de.steamwar.velocitycore.network.NetworkSender;
|
||||
|
||||
@Linked
|
||||
public class SetLocaleCommand extends SWCommand {
|
||||
|
||||
public SetLocaleCommand() {
|
||||
super("setlocale", "setlanguage");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(PlayerChatter sender) {
|
||||
sender.user().setLocale(sender.getPlayer().getPlayerSettings().getLocale(), true);
|
||||
sender.withPlayer(player -> NetworkSender.send(player, new LocaleInvalidationPacket(sender.user().getId())));
|
||||
sender.system("LOCK_LOCALE_CHANGED");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Message;
|
||||
import de.steamwar.messages.PlayerChatter;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import de.steamwar.velocitycore.inventory.SWInventory;
|
||||
import de.steamwar.velocitycore.inventory.SWItem;
|
||||
|
||||
@Linked
|
||||
public class SettingsCommand extends SWCommand {
|
||||
|
||||
public SettingsCommand() {
|
||||
super("settings");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(PlayerChatter sender) {
|
||||
SWInventory inventory = new SWInventory(sender, 9, new Message("SETTINGS_TITLE"));
|
||||
SteamwarUser user = sender.user();
|
||||
String localeItem = user.getManualLocale() ? "BOOK" : "BOOK_AND_QUILL";
|
||||
SWItem localeSwItem = new SWItem(localeItem, new Message("SETTINGS_LOCALE_ITEM"));
|
||||
localeSwItem.addLore(new Message("SETTINGS_LOCALE_CURRENT", new Message("LOCALE")));
|
||||
if (user.getManualLocale()) {
|
||||
localeSwItem.addLore(new Message("SETTINGS_LOCALE_LOCKED"));
|
||||
} else {
|
||||
localeSwItem.addLore(new Message("SETTINGS_LOCALE_UNLOCKED"));
|
||||
}
|
||||
inventory.addItem(2, localeSwItem, click -> {
|
||||
if (user.getManualLocale()) {
|
||||
user.unlockLocale();
|
||||
} else {
|
||||
user.lockLocale();
|
||||
}
|
||||
genericCommand(sender);
|
||||
});
|
||||
|
||||
Team team = Team.byId(user.getTeam());
|
||||
String chatPrefixItem = !user.hasPerm(UserPerm.TEAM) ? "BARRIER" : "NAME_TAG";
|
||||
SWItem swItem = new SWItem(chatPrefixItem, new Message("SETTINGS_PREFIX_ITEM"));
|
||||
if (user.hasPerm(UserPerm.TEAM)) {
|
||||
swItem.addLore(new Message("SETTINGS_PREFIX_SELECTED", new Message("SETTINGS_PREFIX_SW")));
|
||||
}
|
||||
if (user.getTeam() != Team.PUBLIC) {
|
||||
swItem.addLore(new Message("SETTINGS_PREFIX_UNSELECTED", new Message("SETTINGS_PREFIX_TEAM", team.getTeamColor(), team.getTeamKuerzel())));
|
||||
}
|
||||
inventory.addItem(6, swItem, click -> {
|
||||
});
|
||||
|
||||
inventory.open();
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class TeamCommand extends SWCommand {
|
||||
helpMessages(sender, "TEAM_HELP_HEADER", "TEAM_HELP_LIST", "TEAM_HELP_INFO");
|
||||
|
||||
SteamwarUser user = sender.user();
|
||||
if(user.getTeam() == 0) {
|
||||
if(user.getTeam() == Team.PUBLIC) {
|
||||
helpMessages(sender, "TEAM_HELP_CREATE", "TEAM_HELP_JOIN");
|
||||
}else{
|
||||
helpMessages(sender, "TEAM_HELP_CHAT", "TEAM_HELP_EVENT", "TEAM_HELP_LEAVE");
|
||||
@@ -162,7 +162,7 @@ public class TeamCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
user.setTeam(0);
|
||||
user.setTeam(Team.PUBLIC);
|
||||
|
||||
if(teamSize == 1)
|
||||
team.disband(user);
|
||||
@@ -182,7 +182,7 @@ public class TeamCommand extends SWCommand {
|
||||
if(notDuringEvent(sender))
|
||||
return;
|
||||
|
||||
if(target.getTeam() != 0){
|
||||
if(target.getTeam() != Team.PUBLIC){
|
||||
sender.system("TEAM_INVITE_IN_TEAM");
|
||||
return;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ public class TeamCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
target.setTeam(0);
|
||||
target.setTeam(Team.PUBLIC);
|
||||
|
||||
sender.system("TEAM_REMOVE_REMOVED");
|
||||
Chatter.of(target).system("TEAM_REMOVE_REMOVED_TARGET");
|
||||
@@ -493,7 +493,7 @@ public class TeamCommand extends SWCommand {
|
||||
@Validator(value = "isNotInTeam", local = true)
|
||||
public TypeValidator<Chatter> isNotInTeamValidator() {
|
||||
return (sender, value, messageSender) -> {
|
||||
if (sender.user().getTeam() != 0) {
|
||||
if (sender.user().getTeam() != Team.PUBLIC) {
|
||||
messageSender.send("TEAM_IN_TEAM");
|
||||
return false;
|
||||
}
|
||||
@@ -504,7 +504,7 @@ public class TeamCommand extends SWCommand {
|
||||
@Validator(value = "isInTeam", local = true)
|
||||
public TypeValidator<Chatter> isInTeamValidator() {
|
||||
return (sender, value, messageSender) -> {
|
||||
if (sender.user().getTeam() == 0) {
|
||||
if (sender.user().getTeam() == Team.PUBLIC) {
|
||||
messageSender.send("TEAM_NOT_IN_TEAM");
|
||||
return false;
|
||||
}
|
||||
@@ -516,7 +516,7 @@ public class TeamCommand extends SWCommand {
|
||||
public TypeValidator<Chatter> isLeaderValidator() {
|
||||
return (sender, value, messageSender) -> {
|
||||
SteamwarUser user = sender.user();
|
||||
if (user.getTeam() == 0) {
|
||||
if (user.getTeam() == Team.PUBLIC) {
|
||||
messageSender.send("TEAM_NOT_IN_TEAM");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SettingsChangedListener extends BasicListener {
|
||||
VelocityCore.schedule(() -> {
|
||||
Player player = event.getPlayer();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
user.setLocale(event.getPlayerSettings().getLocale(), false);
|
||||
user.setJoinLocale(event.getPlayerSettings().getLocale());
|
||||
NetworkSender.send(player, new LocaleInvalidationPacket(user.getId()));
|
||||
}).schedule();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user