From 771c77247a0cc99688a809c2042d330546313562 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 1 Dec 2025 15:52:15 +0100 Subject: [PATCH] Add Punishment.PunishmentType.NoEvent --- .../SQL/src/de/steamwar/sql/Punishment.kt | 8 ++++++++ .../steamwar/messages/BungeeCore.properties | 8 ++++++++ .../messages/BungeeCore_de.properties | 8 ++++++++ .../steamwar/velocitycore/VelocityCore.java | 1 + .../commands/PunishmentCommand.java | 10 ++++++---- .../velocitycore/commands/TeamCommand.java | 12 ++++++++++++ .../discord/channels/EventChannel.java | 19 +------------------ 7 files changed, 44 insertions(+), 22 deletions(-) diff --git a/CommonCore/SQL/src/de/steamwar/sql/Punishment.kt b/CommonCore/SQL/src/de/steamwar/sql/Punishment.kt index d2ad06ba..663355f1 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Punishment.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Punishment.kt @@ -179,6 +179,14 @@ class Punishment(id: EntityID) : IntEntity(id) { "UNNOTEAMSERVER", UserPerm.MODERATION ), + NoEvent( + "NOEVENT_TEAM", + "NOEVENT_PERMA", + "NOEVENT_UNTIL", + "NOEVENT_ERROR", + "UNNOEVENT", + UserPerm.MODERATION + ), Note("NOTE_TEAM", null, null, null, null, UserPerm.PUNISHMENTS, true); fun isMulti() = multi diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties index 9f9c2e03..87c785b1 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties @@ -208,6 +208,14 @@ NOTEAMSERVER_UNTIL=§7You are excluded from §e§lteam servers§7 §euntil {0}§ UNNOTEAMSERVER_ERROR=§cThe player is not excluded from team servers. UNNOTEAMSERVER=§e{0} §7may now set §e§lteam servers§7 again§8. +NOEVENT_TEAM=§e{0} §7was excluded from §e{1} {2} §7from §e§levents§8: §f{3} +NOEVENT_PERMA=§7You are §epermanently§7 excluded from §e§levents§8: §e{0} +NOEVENT_UNTIL=§7You are excluded from §e§levents§7 §euntil {0}§8: §e{1} +NOEVENT_ERROR=§cThe player is not excluded from events. +UNNOEVENT=§e{0} §7may now participate in §e§levents§7 again§8. +NOEVENT_PLAYER_PUNISHED=§7A player in your Team is excluded from §e§levents§8.§7 Your team cannot participate§8. +NOEVENT_INVITED_PUNISHED=§cThe player you invited cannot attend §e§levents§8.§7 If they join your future Event participation will be restricted§8. + NOTE_TEAM=§e{0} §7received a §e§lnote§7 from §e{1} {2}: §f{3} #BugCommand diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties index e6a06d11..2dddb85b 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties @@ -190,6 +190,14 @@ NOTEAMSERVER_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lTeamserver§7 setzen a UNNOTEAMSERVER_ERROR=§cDer Spieler ist nicht vom Teamserver setzten ausgeschlossen. UNNOTEAMSERVER=§e{0} §7darf nun wieder §e§lTeamserver§7 setzen§8. +NOEVENT_TEAM=§e{0} §7wurde von §e{1} {2} §7aus §e§lEvents§8 ausgeschlossen: §f{3} +NOEVENT_PERMA=§7Du bist §epermanent§7 von §e§lEvents§8 ausgeschlossen: §e{0} +NOEVENT_UNTIL=§7Du bist §ebis zum {0}§7 von §e§lEvents§7 ausgeschlossen§8: §e{1} +NOEVENT_ERROR=§cDer Spieler ist nicht von Events ausgeschlossen. +UNNOEVENT=§e{0} §7kann nun wieder an §e§lEvents§7 teilnehmen§8. +NOEVENT_PLAYER_PUNISHED=§7Ein Spieler deines Teams ist von §e§lEvents§7 ausgeschlossen§8.§7 Dein Team kann nicht teilnehmen§8. +NOEVENT_INVITED_PUNISHED=§cDer von dir eingeladene Spieler kann nicht an §e§lEvents§7 teilnehmen§8.§7 Wenn er beitritt, wird deine zukünftige Teilnahme an Events eingeschränkt§8. + NOTE_TEAM=§e{0} §7erhielt von §e{1} {2} §7die §e§lNotiz§7§8: §f{3} #BugCommand diff --git a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java index 74efe014..36d8b683 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java +++ b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java @@ -151,6 +151,7 @@ public class VelocityCore implements ReloadablePlugin { new PunishmentCommand("nodev", Punishment.PunishmentType.NoDevServer); new PunishmentCommand("nofight", Punishment.PunishmentType.NoFightServer); new PunishmentCommand("noteamserver", Punishment.PunishmentType.NoTeamServer); + new PunishmentCommand("noevent", Punishment.PunishmentType.NoEvent); new PunishmentCommand("note", Punishment.PunishmentType.Note); linker = new AbstractLinker<>(this) { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/PunishmentCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/PunishmentCommand.java index ec5015a3..f926dde8 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/PunishmentCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/PunishmentCommand.java @@ -26,10 +26,7 @@ import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; -import de.steamwar.sql.BannedUserIPs; -import de.steamwar.sql.Punishment; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserPerm; +import de.steamwar.sql.*; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.listeners.IPSanitizer; @@ -213,6 +210,11 @@ public class PunishmentCommand { if(punishmentType == Punishment.PunishmentType.Ban) ban(target, banTime, msg, punisher, isPerma); Chatter.serverteam().system(punishmentType.getTeamMessage(), target, sender, new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg); + if (punishmentType == Punishment.PunishmentType.NoEvent) { + int teamId = target.getTeam(); + if (teamId == 0) return; + TeamTeilnahme.deleteFuture(teamId); + } } @Register diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java index b17a4fcc..a861894d 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java @@ -141,6 +141,9 @@ public class TeamCommand extends SWCommand { user.setTeam(t); teamInvitations.remove(user.getId()); sender.system("TEAM_JOIN_JOINED", Team.byId(t).getTeamName()); + if (user.isPunished(Punishment.PunishmentType.NoEvent)) { + TeamTeilnahme.deleteFuture(t); + } } @Register("stepback") @@ -201,6 +204,9 @@ public class TeamCommand extends SWCommand { invitations.add(team.getTeamId()); sender.system("TEAM_INVITE_INVITED", target.getUserName()); + if (target.isPunished(Punishment.PunishmentType.NoEvent)) { + sender.system("NOEVENT_INVITED_PUNISHED"); + } Chatter.of(target).system("TEAM_INVITE_INVITED_TARGET", team.getTeamColor(), team.getTeamName()); } @@ -422,6 +428,12 @@ public class TeamCommand extends SWCommand { TeamTeilnahme.notTeilnehmen(team.getTeamId(), event.getEventID()); sender.system("TEAM_EVENT_LEFT"); }else{ + if (team.getMembers().stream().anyMatch(integer -> { + return SteamwarUser.get(integer).isPunished(Punishment.PunishmentType.NoEvent); + })) { + sender.system("NOEVENT_PLAYER_PUNISHED"); + return; + } TeamTeilnahme.teilnehmen(team.getTeamId(), event.getEventID()); sender.system("TEAM_EVENT_JOINED", event.getEventName()); sender.prefixless("TEAM_EVENT_HOW_TO_LEAVE"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/discord/channels/EventChannel.java b/VelocityCore/src/de/steamwar/velocitycore/discord/channels/EventChannel.java index 1d19dab0..860a28b1 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/discord/channels/EventChannel.java +++ b/VelocityCore/src/de/steamwar/velocitycore/discord/channels/EventChannel.java @@ -25,9 +25,6 @@ import de.steamwar.sql.Team; import de.steamwar.sql.TeamTeilnahme; import lombok.experimental.UtilityClass; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.entities.emoji.Emoji; -import net.dv8tion.jda.api.interactions.components.ActionRow; -import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu; import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; import java.awt.*; @@ -54,12 +51,6 @@ public class EventChannel { .setTitle("Zukünftige Events") .setAuthor("SteamWar", "https://www.steamwar.de"); - - StringSelectMenu.Builder menuBuilder = StringSelectMenu.create("eventName") - .setPlaceholder("Wähle ein Event aus!") - .setMinValues(1) - .setMaxValues(1); - Timestamp now = Timestamp.from(Instant.now()); List events = Event.getComing(); events.forEach(event -> { @@ -73,18 +64,10 @@ public class EventChannel { st.append("\nAngemeldete Teams: ").append(teilname); } embedBuilder.addField(event.getEventName(), st.toString(), false); - if(event.getDeadline().after(Timestamp.from(Instant.now()))) { - menuBuilder.addOption(event.getEventName(), event.getEventID() + "", "An " + event.getEventName() + " teilnehmen", Emoji.fromUnicode("U+1F4DD")); - } }); - MessageCreateBuilder messageBuilder = new MessageCreateBuilder() + return new MessageCreateBuilder() .setEmbeds(embedBuilder.build()); - - if(events.stream().anyMatch(event -> event.getDeadline().after(Timestamp.from(Instant.now())))) { - messageBuilder.setComponents(ActionRow.of(menuBuilder.build())); - } - return messageBuilder; } private MessageCreateBuilder updateCurrent() {