Merge branch 'main' into exposed

# Conflicts:
#	CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java
#	CommonCore/SQL/src/de/steamwar/sql/Punishment.java
This commit is contained in:
2025-11-05 16:18:30 +01:00
17 changed files with 138 additions and 35 deletions
@@ -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;
@@ -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!
@@ -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!
@@ -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);
}
}
}
@@ -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();
@@ -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<String, String> 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<String, String> 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> serverConnection = checkSession.checker.getPlayer().getCurrentServer();
if (serverConnection.isPresent()) {
sender.getPlayer().createConnectionRequest(serverConnection.get().getServer()).fireAndForget();
return;
}
}
new CheckSession(sender, schem);
}
@@ -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)) {