From bb8b46c4372dad137d018a1790ae4e1fc40cc5df Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 29 Nov 2023 17:49:24 +0100 Subject: [PATCH 1/3] Add restriction for checking own team schematics --- .../steamwar/bungeecore/commands/CheckCommand.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index b2aee64..b47adec 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -22,10 +22,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.bot.util.DiscordSchemAlert; import de.steamwar.bungeecore.listeners.ConnectionListener; -import de.steamwar.sql.CheckedSchematic; -import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SchematicType; -import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.*; import de.steamwar.command.SWCommand; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ProxyServer; @@ -87,8 +84,11 @@ public class CheckCommand extends SWCommand { Message.sendPrefixless("CHECK_LIST_HEADER", player, schematicList.size()); + SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); + int playerTeam = steamwarUser.hasPerm(UserPerm.MODERATION) ? -1 : steamwarUser.getTeam(); for (SchematicNode schematic : schematicList) { CheckSession current = currentSchems.get(schematic.getId()); + boolean sameTeam = SteamwarUser.get(schematic.getOwner()).getTeam() == playerTeam; long waitedMillis = Timestamp.from(Instant.now()).getTime() - schematic.getLastUpdate().getTime(); String color = waitedMillis > 14400000 ? (waitedMillis > 86400000 ? "§c" : "§e") : "§a"; long hours = waitedMillis / 3600000; @@ -97,7 +97,7 @@ public class CheckCommand extends SWCommand { if (current == null) { Message.sendPrefixless("CHECK_LIST_TO_CHECK", player, Message.parse("CHECK_LIST_TO_CHECK_HOVER", player), - new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getId()), + sameTeam ? null : new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getId()), waitTime, schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName()); } else { @@ -126,6 +126,9 @@ public class CheckCommand extends SWCommand { return; } + int playerTeam = SteamwarUser.get(player.getUniqueId()).getTeam(); + boolean sameTeam = SteamwarUser.get(schem.getOwner()).getTeam() == playerTeam; + if (sameTeam) return; new CheckSession(player, schem); } From 6f31058d61edd5d24d98b88bff7467eacaee6c81 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 29 Nov 2023 18:15:20 +0100 Subject: [PATCH 2/3] Remove CalendarCommand and CalendarListener from Bungee --- src/de/steamwar/bungeecore/commands/CheckCommand.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index b47adec..c803bbe 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -85,10 +85,11 @@ public class CheckCommand extends SWCommand { Message.sendPrefixless("CHECK_LIST_HEADER", player, schematicList.size()); SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); - int playerTeam = steamwarUser.hasPerm(UserPerm.MODERATION) ? -1 : steamwarUser.getTeam(); + int playerTeam = steamwarUser.hasPerm(UserPerm.MODERATION) ? 0 : steamwarUser.getTeam(); for (SchematicNode schematic : schematicList) { + SteamwarUser schematicOwner = SteamwarUser.get(schematic.getOwner()); CheckSession current = currentSchems.get(schematic.getId()); - boolean sameTeam = SteamwarUser.get(schematic.getOwner()).getTeam() == playerTeam; + boolean sameTeam = schematicOwner.getTeam() != 0 && schematicOwner.getTeam() == playerTeam; long waitedMillis = Timestamp.from(Instant.now()).getTime() - schematic.getLastUpdate().getTime(); String color = waitedMillis > 14400000 ? (waitedMillis > 86400000 ? "§c" : "§e") : "§a"; long hours = waitedMillis / 3600000; @@ -99,13 +100,13 @@ public class CheckCommand extends SWCommand { Message.parse("CHECK_LIST_TO_CHECK_HOVER", player), sameTeam ? null : new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getId()), waitTime, - schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName()); + schematic.getSchemtype().getKuerzel(), schematicOwner.getUserName(), schematic.getName()); } else { Message.sendPrefixless("CHECK_LIST_CHECKING", player, Message.parse("CHECK_LIST_CHECKING_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + current.checker.getName()), waitTime, - schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName(), current.checker.getName()); + schematic.getSchemtype().getKuerzel(), schematicOwner.getUserName(), schematic.getName(), current.checker.getName()); } } } From a571832d672e7a199758611a91230b35de951caa Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 29 Nov 2023 18:30:04 +0100 Subject: [PATCH 3/3] Update Peer Review stuff and add message --- .../bungeecore/commands/CheckCommand.java | 21 +++++++++---------- .../steamwar/messages/BungeeCore.properties | 1 + .../messages/BungeeCore_de.properties | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index c803bbe..eedde0f 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -84,12 +84,8 @@ public class CheckCommand extends SWCommand { Message.sendPrefixless("CHECK_LIST_HEADER", player, schematicList.size()); - SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); - int playerTeam = steamwarUser.hasPerm(UserPerm.MODERATION) ? 0 : steamwarUser.getTeam(); for (SchematicNode schematic : schematicList) { - SteamwarUser schematicOwner = SteamwarUser.get(schematic.getOwner()); CheckSession current = currentSchems.get(schematic.getId()); - boolean sameTeam = schematicOwner.getTeam() != 0 && schematicOwner.getTeam() == playerTeam; long waitedMillis = Timestamp.from(Instant.now()).getTime() - schematic.getLastUpdate().getTime(); String color = waitedMillis > 14400000 ? (waitedMillis > 86400000 ? "§c" : "§e") : "§a"; long hours = waitedMillis / 3600000; @@ -98,15 +94,15 @@ public class CheckCommand extends SWCommand { if (current == null) { Message.sendPrefixless("CHECK_LIST_TO_CHECK", player, Message.parse("CHECK_LIST_TO_CHECK_HOVER", player), - sameTeam ? null : new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getId()), + new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getId()), waitTime, - schematic.getSchemtype().getKuerzel(), schematicOwner.getUserName(), schematic.getName()); + schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName()); } else { Message.sendPrefixless("CHECK_LIST_CHECKING", player, Message.parse("CHECK_LIST_CHECKING_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + current.checker.getName()), waitTime, - schematic.getSchemtype().getKuerzel(), schematicOwner.getUserName(), schematic.getName(), current.checker.getName()); + schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName(), current.checker.getName()); } } } @@ -118,18 +114,21 @@ public class CheckCommand extends SWCommand { return; } + SteamwarUser checkingUser = SteamwarUser.get(player.getUniqueId()); SchematicNode schem = SchematicNode.getSchematicNode(Integer.parseInt(schemID)); if(!schem.getSchemtype().check()){ ProxyServer.getInstance().getLogger().log(Level.SEVERE, player.getName() + " tried to check an uncheckable schematic!"); return; - }else if(schem.getOwner() == SteamwarUser.get(player.getUniqueId()).getId()) { + }else if(schem.getOwner() == checkingUser.getId()) { Message.send("CHECK_SCHEMATIC_OWN", player); return; } - int playerTeam = SteamwarUser.get(player.getUniqueId()).getTeam(); - boolean sameTeam = SteamwarUser.get(schem.getOwner()).getTeam() == playerTeam; - if (sameTeam) return; + int playerTeam = checkingUser.hasPerm(UserPerm.MODERATION) ? 0 : checkingUser.getTeam(); + if (playerTeam != 0 && SteamwarUser.get(schem.getOwner()).getTeam() == playerTeam) { + Message.send("CHECK_SCHEMATIC_OWN_TEAM", player); + return; + } new CheckSession(player, schem); } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index c038809..0575535 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -293,6 +293,7 @@ CHECK_LIST_CHECKING={0} §8{1} §7{2} §e{3} §7is being reviewed by §e{4} 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_PREVIOUS=§7{0} from {1}§8: §e{2} CHECK_INVALID_RANK=§cUnknown schematic rank. CHECK_ABORT=§aThe test operation was canceled! diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index e396bdb..7e5566a 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -276,6 +276,7 @@ CHECK_LIST_CHECKING={0} §8{1} §7{2} §e{3} §7wird geprüft von §e{4} 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_PREVIOUS=§7{0} von {1}§8: §e{2} CHECK_INVALID_RANK=§cUnbekannter Schematicrang. CHECK_ABORT=§aDer Prüfvorgang wurde abgebrochen!