diff --git a/BauSystem/BauSystem_Main/src/BauSystem.properties b/BauSystem/BauSystem_Main/src/BauSystem.properties index 432ac00a..b90933b6 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem.properties @@ -818,7 +818,6 @@ REGION_TNT_HELP_MODE=§8/§etnt §8[§7Mode§8] §8- §7Set TNT behaviour to a g REGION_TNT_ON=§aTNT-Damage activated REGION_TNT_OFF=§cTNT-Damage deactivated REGION_TNT_TB=§aTNT-Damage activated outside the building area -REGION_TNT_BUILD=§aTNT-Damage activated outside the testblok area REGION_TNT_BUILD_DESTROY=§cAn explosion would have destroyed blocks in the building area REGION_TNT_TB_DESTROY=§cAn explosion would have destroyed blocks in the testblock area AFK_KICK_MESSAGE=§cNothing happened on this server for 15 minutes. diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java index 074cd3c5..ad6f86a4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java @@ -123,10 +123,6 @@ public class TNTCommand extends SWCommand { return "REGION_TNT_TB"; } - private String getBuildEnableMessage() { - return "REGION_TNT_BUILD"; - } - private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) { if (requestedMode != null && region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) { region.getFlags().set(Flag.TNT, requestedMode); diff --git a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java index 87abc1c2..c7e9ecf8 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java +++ b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java @@ -35,19 +35,11 @@ import java.util.stream.Collectors; public final class GameModeConfig { public static final Function ToString = Function.identity(); - public static final Function ToStaticWarGear = GameModeConfig::constWarGear; - public static final Function ToInternalName = GameModeConfig::internalName; + public static final Function ToStaticWarGear = __ -> "WarGear"; + public static final Function ToInternalName = file -> file != null ? file.getName().replace(".yml", "") : "WarGear"; public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm"); private static final Random random = new Random(); - private static String constWarGear(File f) { - return "WarGear"; - } - - private static String internalName(File f) { - return f.getName().replace(".yml", ""); - } - private static final Map> byFileName; private static final Map> byGameName; private static final Map> bySchematicType; @@ -109,6 +101,14 @@ public final class GameModeConfig { */ public final List CheckQuestions; + /** + * The allowed checkers to check this schematic type denoted by a list of SteamWar ids. + * The people need the {@link UserPerm#CHECK} to be able to check though. + * + * @implSpec {@code []} by default -> denoting every person with {@link UserPerm#CHECK} can check it + */ + public final List Checkers; + /** * Bundle for countdowns during the fight */ @@ -202,6 +202,7 @@ public final class GameModeConfig { } CheckQuestions = loader.getStringList("CheckQuestions"); + Checkers = loader.getIntList("Checkers"); Times = new TimesConfig(loader.with("Times")); // Arena would be here to be in config order but needs Schematic.Size and EnterStages loaded afterwards Schematic = new SchematicConfig<>(loader.with("Schematic")); diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java index 97cf6de3..d6189931 100644 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java +++ b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/autocheck/AutoChecker15.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; +import de.steamwar.core.Core; import de.steamwar.sql.GameModeConfig; import de.steamwar.sql.SchematicType; import org.bukkit.Material; @@ -109,7 +110,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker { if (!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(material)) { result.getForbiddenItems().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); } else if(material == Material.DISPENSER && (itemType == Material.ARROW || itemType == Material.FIRE_CHARGE)) { - counter += item.getByte("Count"); + counter += Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); } if (item.containsKey("tag")) { result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); diff --git a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java index 62fa611e..05036a9a 100644 --- a/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java +++ b/SchematicSystem/SchematicSystem_15/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand15.java @@ -31,6 +31,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; +import de.steamwar.core.Core; import de.steamwar.sql.GameModeConfig; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; import de.steamwar.schematicsystem.autocheck.BlockPos; @@ -38,9 +39,17 @@ import de.steamwar.sql.SchematicType; import org.bukkit.Material; import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; import java.util.stream.Collectors; public class SchematicCommand15 implements SchematicCommand.ISchematicCommand { + private static final Function getCount = item -> Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); + private static final BiFunction setCount = (item, count) -> Core.getVersion() >= 21 ? + item.createBuilder().putInt("count", count).build() : + item.createBuilder().putByte("Count", count.byteValue()).build(); + @Override public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception { for (BlockPos blockPos : result.getBlockScanResult().getRecords()) { @@ -87,7 +96,7 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand { BaseBlock block = clipboard.getFullBlock(vector); CompoundTag tag = block.getNbtData(); CompoundTagBuilder builder = tag.createBuilder(); - List items = tag.getList("Items", CompoundTag.class); + List items = new ArrayList<>(tag.getList("Items", CompoundTag.class)); Collections.reverse(items); // To let the first item be in the Dispenser List list = new ArrayList<>(); int diff = entry.getValue() - type.Schematic.MaxDispenserItems; @@ -101,12 +110,12 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand { continue; } - if(diff > item.getByte("Count")) { - diff -= item.getByte("Count"); + if(diff > getCount.apply(item)) { + diff -= getCount.apply(item); continue; } - item = item.createBuilder().putByte("Count", (byte) (item.getByte("Count") - diff)).build(); + item = setCount.apply(item, getCount.apply(item) - diff); diff = 0; list.add(item); } diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java index 3687a52b..a4e04c43 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java @@ -35,6 +35,7 @@ public class SchematicSystem extends JavaPlugin { public static GameModeConfig getGameModeConfig(SchematicType type){ GameModeConfig gameModeConfig = GameModeConfig.getBySchematicType(type); + if (gameModeConfig == null) return null; if (gameModeConfig.CheckQuestions.isEmpty() && gameModeConfig.Schematic.ManualCheck) return null; return gameModeConfig; } diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java index 2dc5ad04..2d17ba73 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java @@ -62,7 +62,7 @@ public class ModifyPart extends SWCommand { SchematicType.values().parallelStream() .filter(SchematicType::isAssignable) - .filter(type -> finalClipboard == null || SchematicSystem.getGameModeConfig(type) == null || AutoChecker.sizeCheck(finalClipboard, SchematicSystem.getGameModeConfig(type)).fastOk()) + .filter(type -> finalClipboard != null && SchematicSystem.getGameModeConfig(type) != null && AutoChecker.sizeCheck(finalClipboard, SchematicSystem.getGameModeConfig(type)).fastOk()) .forEach(type -> { TextComponent component = new TextComponent(type.name() + " "); component.setColor(ChatColor.GRAY); diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/FlatteningWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/FlatteningWrapper21.java new file mode 100644 index 00000000..25ada9a8 --- /dev/null +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/FlatteningWrapper21.java @@ -0,0 +1,42 @@ +/* + * 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 . + */ + +package de.steamwar.core; + +import com.destroystokyo.paper.profile.PlayerProfile; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +public class FlatteningWrapper21 extends FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper { + + @Override + public ItemStack setSkullOwner(String player) { + ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1); + head.editMeta(SkullMeta.class, skullMeta -> { + OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.startsWith(".") ? player.substring(1) : player); + PlayerProfile playerProfile = offlinePlayer.getPlayerProfile(); + if (!playerProfile.isComplete()) playerProfile.complete(); + skullMeta.setPlayerProfile(playerProfile); + }); + return head; + } +} diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index 01084241..9bc8fea8 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -44,7 +44,7 @@ public class SWCommand extends AbstractSWCommand { private Command command; @Setter - private Message message = null; + protected Message message = null; private List defaultHelpMessages = new ArrayList<>(); protected SWCommand(String command) { diff --git a/VelocityCore/Persistent/src/de/steamwar/persistent/Persistent.java b/VelocityCore/Persistent/src/de/steamwar/persistent/Persistent.java index 71139e8e..d5fac548 100644 --- a/VelocityCore/Persistent/src/de/steamwar/persistent/Persistent.java +++ b/VelocityCore/Persistent/src/de/steamwar/persistent/Persistent.java @@ -122,6 +122,7 @@ public class Persistent { container = proxy.getPluginManager().getPlugin("velocitycore").orElseThrow(); plugin = (ReloadablePlugin) container.getInstance().orElseThrow(); } catch (NoSuchElementException e) { + e.printStackTrace(); logger.log(Level.WARNING, "Could not find loaded VelocityCore, continuing without unloading."); } @@ -129,6 +130,7 @@ public class Persistent { try { newContainer = prepareLoad(); } catch (Exception e) { + e.printStackTrace(); logger.log(Level.SEVERE, "Could not instantiate new VelocityCore, aborting softreload.", e); return Command.SINGLE_SUCCESS; } @@ -136,13 +138,19 @@ public class Persistent { broadcast("§eNetwork update is starting§8."); try { if(container != null && plugin != null) { + System.out.println("Proxy Shutdown Event"); plugin.onProxyShutdown(new ProxyShutdownEvent()); + System.out.println("Unloading of Container"); unload(container, plugin); } + System.out.println("Loading of new Container"); registerPlugin.invoke((VelocityPluginManager) proxy.getPluginManager(), newContainer); + System.out.println("Proxy Initialization Event"); ((ReloadablePlugin) newContainer.getInstance().orElseThrow()).onProxyInitialization(new ProxyInitializeEvent()); + System.out.println("Proxy Initialization Event finished"); } catch (Throwable t) { + t.printStackTrace(); logger.log(Level.SEVERE, "Error during softreload", t); broadcast("§cNetwork update failed§8, §cexpect network restart soon§8."); return Command.SINGLE_SUCCESS; diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties index cdec29b8..42605662 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties @@ -319,6 +319,7 @@ CHECK_LIST_CHECKING_HOVER=§eTo the reviewer CHECK_SCHEMATIC_ALREADY_CHECKING=§cYou are already reviewing a schematic! CHECK_SCHEMATIC_OWN=§cYou cannot review your own schematics. CHECK_SCHEMATIC_OWN_TEAM=§cYou cannot review your team schematics. +CHECK_SCHEMATIC_EVENT=§cYou cannot check the schematic for the event. CHECK_SCHEMATIC_PREVIOUS=§7{0} from {1}§8: §e{2} CHECK_INVALID_RANK=§cUnknown schematic rank. CHECK_ABORT=§aThe test operation was canceled! diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties index ba79c219..a79cfdf7 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties @@ -301,6 +301,7 @@ CHECK_LIST_CHECKING_HOVER=§eZum Prüfer CHECK_SCHEMATIC_ALREADY_CHECKING=§cDu prüfst schon eine Schematic! CHECK_SCHEMATIC_OWN=§cDu kannst nicht deine eigenen Schematics prüfen. CHECK_SCHEMATIC_OWN_TEAM=§cDu kannst nicht Schematics deines Teams prüfen. +CHECK_SCHEMATIC_EVENT=§cDu kannst die schematic für das Event nicht prüfen. CHECK_SCHEMATIC_PREVIOUS=§7{0} von {1}§8: §e{2} CHECK_INVALID_RANK=§cUnbekannter Schematicrang. CHECK_ABORT=§aDer Prüfvorgang wurde abgebrochen! diff --git a/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java b/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java index 87e2bf92..48a40870 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ArenaMode.java @@ -61,6 +61,8 @@ public class ArenaMode { } if (gameModeConfig.Schematic.loaded && gameModeConfig.Schematic.Type != SchematicType.Normal) { bySchemType.put(gameModeConfig.Schematic.Type, gameModeConfig); + SchematicType checkType = gameModeConfig.Schematic.Type.checkType(); + if (checkType != null) bySchemType.put(checkType, gameModeConfig); } } } diff --git a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java index 17e559ac..c8150a1b 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java +++ b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java @@ -45,6 +45,7 @@ import de.steamwar.velocitycore.commands.ServerSwitchCommand; import de.steamwar.velocitycore.commands.TeamCommand; import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.velocitycore.discord.DiscordConfig; +import de.steamwar.velocitycore.listeners.BasicListener; import de.steamwar.velocitycore.listeners.PollSystem; import lombok.Getter; import lombok.NonNull; @@ -171,6 +172,16 @@ public class VelocityCore implements ReloadablePlugin { ((PacketHandler) any).register(); } } + + @Override + protected void unlinkObject(Object any) { + if (any instanceof PacketHandler) { + ((PacketHandler) any).unregister(); + } + if (any instanceof BasicListener) { + VelocityCore.getProxy().getEventManager().unregisterListener(instance, any); + } + } }; try { linker.link(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java index 4a7b8d38..fe78a018 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java @@ -20,8 +20,8 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.ServerConnection; import de.steamwar.command.SWCommand; -import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; @@ -100,17 +100,31 @@ public class CheckCommand extends SWCommand { sender.system("CHECK_LIST_HEADER", schematicList.size()); for (SchematicNode schematic : schematicList) { + GameModeConfig gameModeConfig = ArenaMode.getBySchemType(schematic.getSchemtype()); + if (gameModeConfig == null) gameModeConfig = GameModeConfig.getDefaults(); CheckSession current = currentSchems.get(schematic.getId()); + ClickEvent clickEvent = null; + Message hoverMessage = null; + if (gameModeConfig.Checkers.isEmpty() || gameModeConfig.Checkers.contains(sender.user().getId())) { + if (current == null) { + clickEvent = ClickEvent.runCommand("/check schematic " + schematic.getId()); + hoverMessage = new Message("CHECK_LIST_TO_CHECK_HOVER"); + } else { + clickEvent = ClickEvent.runCommand("/join " + current.checker.user().getUserName()); + hoverMessage = new Message("CHECK_LIST_CHECKING_HOVER"); + } + } + if (current == null) { sender.prefixless("CHECK_LIST_TO_CHECK", - new Message("CHECK_LIST_TO_CHECK_HOVER"), - ClickEvent.runCommand("/check schematic " + schematic.getId()), + hoverMessage, + clickEvent, getWaitTime(schematic), schematic.getSchemtype().getKuerzel(), SteamwarUser.byId(schematic.getOwner()).getUserName(), schematic.getName()); } else { sender.prefixless("CHECK_LIST_CHECKING", - new Message("CHECK_LIST_CHECKING_HOVER"), - ClickEvent.runCommand("/join " + current.checker.user().getUserName()), + hoverMessage, + clickEvent, getWaitTime(schematic), schematic.getSchemtype().getKuerzel(), SteamwarUser.byId(schematic.getOwner()).getUserName(), schematic.getName(), current.checker.user().getUserName()); } @@ -125,6 +139,11 @@ public class CheckCommand extends SWCommand { } SchematicNode schem = SchematicNode.getSchematicNode(Integer.parseInt(schemID)); + GameModeConfig gameModeConfig = ArenaMode.getBySchemType(schem.getSchemtype()); + if (!gameModeConfig.Checkers.isEmpty() && !gameModeConfig.Checkers.contains(sender.user().getId())) { + sender.system("CHECK_SCHEMATIC_EVENT"); + return; + } if(!schem.getSchemtype().check()){ VelocityCore.getLogger().log(Level.SEVERE, () -> sender.user().getUserName() + " tried to check an uncheckable schematic!"); return; @@ -139,6 +158,15 @@ public class CheckCommand extends SWCommand { sender.system("CHECK_SCHEMATIC_OWN_TEAM"); return; } + + CheckSession checkSession = currentSchems.get(schem.getId()); + if (checkSession != null) { + Optional serverConnection = checkSession.checker.getPlayer().getCurrentServer(); + if (serverConnection.isPresent()) { + sender.getPlayer().createConnectionRequest(serverConnection.get().getServer()).fireAndForget(); + return; + } + } new CheckSession(sender, schem); } diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/PunishmentCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/PunishmentCommand.java index 667b4b15..8305b104 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/PunishmentCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/PunishmentCommand.java @@ -21,8 +21,6 @@ package de.steamwar.velocitycore.commands; import com.google.gson.JsonParser; import com.velocitypowered.api.proxy.Player; -import de.steamwar.velocitycore.VelocityCore; -import de.steamwar.velocitycore.listeners.IPSanitizer; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; @@ -32,6 +30,8 @@ import de.steamwar.sql.BannedUserIPs; import de.steamwar.sql.Punishment; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; +import de.steamwar.velocitycore.VelocityCore; +import de.steamwar.velocitycore.listeners.IPSanitizer; import java.io.IOException; import java.net.URL; @@ -97,7 +97,9 @@ public class PunishmentCommand { bannedUser.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma); } } - BannedUserIPs.banIP(user.getId(), ip); + if (!player.getUsername().startsWith(".")) { + BannedUserIPs.banIP(user.getId(), ip); + } } } @@ -179,7 +181,7 @@ public class PunishmentCommand { private final Punishment.PunishmentType punishmentType; private PunishCommand(String command, Punishment.PunishmentType punishmentType) { - super(command, UserPerm.TEAM); + super(command, punishmentType.getUserPerm()); this.command = command; this.punishmentType = punishmentType; } @@ -194,7 +196,7 @@ public class PunishmentCommand { @Register public void genericCommand(Chatter sender, @Mapper("toPunish") String toPunish, String date, @ErrorMessage(allowEAs = false, value = "PUNISHMENT_USAGE_REASON") String... message) { SteamwarUser punisher = sender.user(); - if (punishmentType.isNeedsAdmin() && !punisher.hasPerm(UserPerm.MODERATION)) + if (!punisher.hasPerm(punishmentType.getUserPerm())) return; SteamwarUser target = unsafeUser(sender, toPunish); @@ -244,14 +246,15 @@ public class PunishmentCommand { private final Punishment.PunishmentType punishmentType; private UnpunishCommand(String command, Punishment.PunishmentType punishmentType) { - super(command, UserPerm.TEAM); + super(command, punishmentType.getUserPerm()); this.command = command; this.punishmentType = punishmentType; } @Register public void genericCommand(Chatter sender, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) { - if (punishmentType.isNeedsAdmin() && !sender.user().hasPerm(UserPerm.MODERATION)) + SteamwarUser punisher = sender.user(); + if (!punisher.hasPerm(punishmentType.getUserPerm())) return; if (!target.isPunished(punishmentType)) { diff --git a/WebsiteBackend/src/de/steamwar/sql/SQLWrapperImpl.kt b/WebsiteBackend/src/de/steamwar/sql/SQLWrapperImpl.kt index 0e843c25..7a850cfb 100644 --- a/WebsiteBackend/src/de/steamwar/sql/SQLWrapperImpl.kt +++ b/WebsiteBackend/src/de/steamwar/sql/SQLWrapperImpl.kt @@ -26,7 +26,7 @@ class SQLWrapperImpl: SQLWrapper { return File("/configs/GameModes") } - override fun loadGameModeConfig(file: File): GameModeConfig { + override fun loadGameModeConfig(file: File?): GameModeConfig { return GameModeConfig(file, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear, true) }