Remove some strain on the Database

This commit is contained in:
2025-11-05 17:09:53 +01:00
parent 73b3d21749
commit 0f0c8b763e
6 changed files with 95 additions and 35 deletions
@@ -33,14 +33,13 @@ import de.steamwar.messages.PlayerChatter;
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
import de.steamwar.persistent.Bauserver;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.velocitycore.*;
import de.steamwar.velocitycore.inventory.SWInventory;
import de.steamwar.velocitycore.inventory.SWItem;
import de.steamwar.velocitycore.network.NetworkSender;
import de.steamwar.velocitycore.util.BauLock;
import de.steamwar.velocitycore.util.BauLockState;
import de.steamwar.data.BauLockState;
import java.util.Collection;
import java.util.function.Consumer;
@@ -19,11 +19,15 @@
package de.steamwar.velocitycore.util;
import de.steamwar.data.BauLockState;
import de.steamwar.messages.Chatter;
import de.steamwar.network.packets.server.BaulockUpdatePacket;
import de.steamwar.persistent.Bauserver;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserConfig;
import de.steamwar.sql.UserPerm;
import de.steamwar.velocitycore.network.NetworkSender;
import lombok.experimental.UtilityClass;
@UtilityClass
@@ -33,6 +37,10 @@ public class BauLock {
public static void setLocked(Chatter owner, BauLockState state) {
UserConfig.updatePlayerConfig(owner.user().getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name());
owner.system("BAU_LOCKED_" + state.name());
Bauserver bauserver = Bauserver.get(owner.user().getUUID());
if(bauserver != null)
bauserver.getRegisteredServer().getPlayersConnected().stream().findAny().ifPresent(player -> NetworkSender.send(player, new BaulockUpdatePacket()));
}
public static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
@@ -1,30 +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.util;
public enum BauLockState {
NOBODY, // Locks the build server for all users
SUPERVISOR, // Locks the build server for supervisors
SERVERTEAM, // opens the build server only for every added user which is a server team member
TEAM_AND_SERVERTEAM, //opens the build server only for every added user which is in the same team as the buildOwner and every server team member
TEAM, //opens the build server only for every added user which is in the same team as the buildOwner
OPEN //unlocks the build server for all users
}