From 8bdb2bad14c481e5db3cee39522d2e3a09a00cdf Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 13 Aug 2024 19:37:37 +0200 Subject: [PATCH 01/14] Fix TinyProtocol spurious ConcurrentModificationExceptions --- .../src/com/comphenix/tinyprotocol/TinyProtocol.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java index b01690ec..7019c26d 100644 --- a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java @@ -36,6 +36,7 @@ import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.plugin.Plugin; import java.util.*; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.BiFunction; import java.util.logging.Level; @@ -102,7 +103,7 @@ public class TinyProtocol implements Listener { } public void addFilter(Class packetType, BiFunction filter) { - packetFilters.computeIfAbsent(packetType, c -> Collections.synchronizedList(new ArrayList<>(1))).add(filter); + packetFilters.computeIfAbsent(packetType, c -> new CopyOnWriteArrayList<>()).add(filter); } public void removeFilter(Class packetType, BiFunction filter) { From 7afdfd89b09630b75e73f533fde2bbc1e7c89c66 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 18 Aug 2024 18:02:02 +0200 Subject: [PATCH 02/14] Changes to support AIs, Add DummyAI --- .../fightsystem/FightSystem.properties | 3 + .../fightsystem/FightSystem_de.properties | 3 + .../src/de/steamwar/fightsystem/ai/AI.java | 122 ++++++++++----- .../de/steamwar/fightsystem/ai/AIManager.java | 55 +++++++ .../ai/{LixfelAI.java => DummyAI.java} | 36 ++--- .../fightsystem/ai/LixfelPathplanner.java | 141 ------------------ .../de/steamwar/fightsystem/commands/GUI.java | 32 +++- .../fightsystem/commands/RequestsCommand.java | 8 +- .../fightsystem/fight/FightSchematic.java | 7 +- .../steamwar/fightsystem/fight/FightTeam.java | 9 +- .../fightsystem/fight/JoinRequest.java | 77 +++++++--- .../listener/JoinRequestListener.java | 2 +- .../fightsystem/listener/Recording.java | 11 +- .../steamwar/fightsystem/record/Recorder.java | 2 +- 14 files changed, 268 insertions(+), 240 deletions(-) create mode 100644 FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java rename FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/{LixfelAI.java => DummyAI.java} (63%) delete mode 100644 FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelPathplanner.java diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties index 3c220d64..9f80ab7e 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties @@ -83,6 +83,8 @@ SCHEM_PRIVATE=§ePrivate {0} SCHEM_NO_PRIVATE=§7No private {0} present SCHEM_PRIVATE_FORBIDDEN=§7No private {0} allowed +ADD_AI_TITLE=Add AI + # Countdowns COUNTDOWN_MINUTES=§e{0} §7Minutes {1} @@ -114,6 +116,7 @@ RESPAWN=§eRespawn REMOVE_PLAYERS=§cKick player CHOOSE_SCHEMATIC=§eChoose {0} SCHEMATIC_REQUIRED=§cChoose a schematic first +ADD_AI=§eAdd AI KIT_PREVIEW_EDIT=§7Edit kit KIT_PREVIEW_CHOOSE=§aSelect kit diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties index 06b07d18..6723bcfb 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties @@ -77,6 +77,8 @@ SCHEM_PRIVATE=§ePrivates {0} SCHEM_NO_PRIVATE=§7Kein privates {0} vorhanden SCHEM_PRIVATE_FORBIDDEN=§7Kein privates {0} erlaubt +ADD_AI_TITLE=KI hinzufügen + # Countdowns COUNTDOWN_MINUTES=§e{0} §7Minuten {1} @@ -107,6 +109,7 @@ RESPAWN=§eRespawn REMOVE_PLAYERS=§cSpieler rauswerfen CHOOSE_SCHEMATIC=§e{0} wählen SCHEMATIC_REQUIRED=§cZuerst muss eine Schematic gewählt sein +ADD_AI=§eKI hinzufügen KIT_PREVIEW_EDIT=§7Kit bearbeiten KIT_PREVIEW_CHOOSE=§aKit wählen diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java index 6f5cb005..0b681fc2 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java @@ -19,32 +19,38 @@ package de.steamwar.fightsystem.ai; +import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; +import de.steamwar.fightsystem.fight.JoinRequest; import de.steamwar.fightsystem.listener.Chat; +import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.utils.Region; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Note; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.block.Lectern; import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.FaceAttachable; import org.bukkit.block.data.Openable; import org.bukkit.block.data.Powerable; import org.bukkit.block.data.type.Comparator; import org.bukkit.block.data.type.NoteBlock; import org.bukkit.block.data.type.Repeater; +import org.bukkit.block.data.type.Switch; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.scheduler.BukkitTask; @@ -55,10 +61,16 @@ import java.util.logging.Level; public abstract class AI { + public static final int MOVEMENT_DELAY = 4; + public static final double INTERACTION_RANGE = 5.0; + private static final Map ais = new HashMap<>(); + public static void printPos() { + ais.values().forEach(ai -> ai.chat(ai.entity.isValid() + " " + ai.entity.isDead() + " " + ai.entity.getLocation())); + } static { - new OneShotStateDependent(ArenaMode.All, FightState.Spectate, () -> { + new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Spectate, () -> { ais.values().forEach(AI::stop); ais.clear(); }); @@ -68,7 +80,9 @@ public abstract class AI { return ais.get(uuid); } - private final FightTeam team; + @Getter + protected final FightTeam team; + @Getter private final LivingEntity entity; private final BukkitTask task; private final Queue queue = new ArrayDeque<>(); @@ -83,11 +97,15 @@ public abstract class AI { task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1); ais.put(entity.getUniqueId(), this); team.addMember(entity, user); + + if(FightState.Schem.contains(FightState.getFightState())) + Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> schematic(team.getClipboard())); } public abstract SchematicNode chooseSchematic(); + public abstract void schematic(Clipboard clipboard); - public boolean acceptJoinRequest(Player player, FightTeam team) { + public boolean acceptJoinRequest(JoinRequest.Enquirer enquirer, FightTeam team) { return true; } @@ -101,11 +119,7 @@ public abstract class AI { task.cancel(); } - public LivingEntity getEntity() { - return entity; - } - - protected void setReady() { + public void setReady() { if(FightState.getFightState() != FightState.POST_SCHEM_SETUP) return; @@ -115,12 +129,12 @@ public abstract class AI { team.setReady(true); } - protected void chat(String message) { + public void chat(String message) { FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + "» " + message); Chat.broadcastChat("PARTICIPANT_CHAT", team.getColoredName(), entity.getName(), message); } - protected Vector getPosition() { + public Vector getPosition() { Location location = entity.getLocation(); Region extend = team.getExtendRegion(); if(Fight.getUnrotated() == team) @@ -137,26 +151,28 @@ public abstract class AI { ); } - protected Material getBlock(Vector pos) { + public Material getBlock(Vector pos) { queue.add(new Action(1)); - return translate(pos, true).getBlock().getType(); + return translate(pos).getBlock().getType(); } - protected boolean isPowered(Vector pos) { + public BlockData getBlockData(Vector pos) { queue.add(new Action(1)); - return translate(pos, true).getBlock().isBlockPowered(); + return translate(pos).getBlock().getBlockData(); } - protected void setTNT(Vector pos) { + public void setTNT(Vector pos) { queue.add(new Action(1) { @Override public void run() { if(FightState.getFightState() != FightState.RUNNING) return; - Location location = translate(pos, true); - if(interactionDistanceViolation(location)) + Location location = translate(pos); + if(interactionDistanceViolation(location)) { + chat("InteractionDistanceViolation: setTNT"); return; + } Block block = location.getBlock(); if(block.getType() == Material.AIR) @@ -165,24 +181,26 @@ public abstract class AI { }); } - protected void interact(Vector pos) { + public void interact(Vector pos) { queue.add(new Action(1) { @Override public void run() { - Location location = translate(pos, true); - if(interactionDistanceViolation(location)) + Location location = translate(pos); + if(interactionDistanceViolation(location)) { + chat("InteractionDistanceViolation: interact"); return; + } interact(location.getBlock()); } }); } - protected void interact(Vector pos, int n) { + public void interact(Vector pos, int n) { queue.add(new Action(1) { @Override public void run() { - Location location = translate(pos, true); + Location location = translate(pos); if (interactionDistanceViolation(location)) return; Block block = location.getBlock(); @@ -199,13 +217,18 @@ public abstract class AI { }); } - protected void move(Vector pos) { - queue.add(new Action(2) { + public void move(Vector pos) { + queue.add(new Action(MOVEMENT_DELAY) { @Override public void run() { Location location = entity.getLocation(); - Location target = translate(pos, false); - if(Math.abs(location.getX() - target.getX()) > 1 || Math.abs(location.getY() - target.getY()) > 1.2 || Math.abs(location.getZ() - target.getZ()) > 1) { + if(!entity.isOnGround() && location.getBlock().getType() != Material.LADDER) { + FightSystem.getPlugin().getLogger().log(Level.INFO, "Entity falling"); + return; + } + + Location target = translate(pos); + if(Math.abs(location.getX() - target.getX()) > 1.0 || Math.abs(location.getY() - target.getY()) > 1.5 || Math.abs(location.getZ() - target.getZ()) > 1.0) { FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector()); return; } @@ -213,13 +236,16 @@ public abstract class AI { if(!team.getFightPlayer(entity).canEntern() && !team.getExtendRegion().inRegion(target)) return; - entity.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND); + if(!entity.teleport(target, PlayerTeleportEvent.TeleportCause.PLUGIN)) + FightSystem.getPlugin().getLogger().log(Level.INFO, "Entity not teleported: " + entity.isValid()); + + GlobalRecorder.getInstance().entityMoves(entity); } }); } private boolean interactionDistanceViolation(Location location) { - return location.distance(entity.getEyeLocation()) > 5; + return location.distance(entity.getEyeLocation()) > INTERACTION_RANGE; } private void interact(Block block) { @@ -249,23 +275,51 @@ public abstract class AI { powerable.setPowered(false); block.setBlockData(powerable); + updateButton(block); }, type.name().endsWith("STONE_BUTTON") ? 20 : 30); } powerable.setPowered(!isPowered); } block.setBlockData(data); + if(data instanceof Switch) { + updateButton(block); + } + } + + private void updateButton(Block block) { + Switch sw = (Switch) block.getBlockData(); + FaceAttachable.AttachedFace face = sw.getAttachedFace(); + if (face == FaceAttachable.AttachedFace.FLOOR) { + update(block.getRelative(BlockFace.DOWN)); + } else if (face == FaceAttachable.AttachedFace.CEILING) { + update(block.getRelative(BlockFace.UP)); + } else { + update(block.getRelative(sw.getFacing().getOppositeFace())); + } + } + + private void update(Block block) { + BlockData data = block.getBlockData(); + block.setType(Material.BARRIER); + block.setBlockData(data); } private void run() { - if(queue.isEmpty()) - plan(); + if(queue.isEmpty()) { + try { + plan(); + } catch (Throwable t) { + stop(); + throw t; + } + } if(!queue.isEmpty() && --queue.peek().delay == 0) queue.poll().run(); } - private Location translate(Vector pos, boolean blockPos) { + public Location translate(Vector pos) { Region extend = team.getExtendRegion(); if(Fight.getUnrotated() == team) return new Location( @@ -277,9 +331,9 @@ public abstract class AI { else return new Location( Config.world, - extend.getMaxX() - pos.getX() - (blockPos ? 1 : 0), + extend.getMaxX() - pos.getX(), pos.getY() + team.getSchemRegion().getMinY(), - extend.getMaxZ() - pos.getZ() - (blockPos ? 1 : 0) + extend.getMaxZ() - pos.getZ() ); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java new file mode 100644 index 00000000..5b9abf4b --- /dev/null +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java @@ -0,0 +1,55 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.fightsystem.ai; + +import com.comphenix.tinyprotocol.Reflection; +import de.steamwar.fightsystem.fight.FightTeam; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Material; + +import java.util.Arrays; +import java.util.List; +import java.util.function.BooleanSupplier; +import java.util.stream.Collectors; + +@AllArgsConstructor +public class AIManager { + private static final List AIs = Arrays.asList( + new AIManager(DummyAI.class, Material.STONE, () -> true) + ); + + public static List availableAIs() { + return AIs.stream().filter(manager -> manager.available.getAsBoolean()).collect(Collectors.toList()); + } + + private final Class aiClass; + @Getter + private final Material icon; + private final BooleanSupplier available; + + public String name() { + return aiClass.getSimpleName(); + } + + public void join(FightTeam team) { + Reflection.getConstructor(aiClass, FightTeam.class).invoke(team); + } +} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelAI.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/DummyAI.java similarity index 63% rename from FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelAI.java rename to FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/DummyAI.java index 2a89353c..90fcd3d0 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelAI.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/DummyAI.java @@ -19,42 +19,42 @@ package de.steamwar.fightsystem.ai; +import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.FightTeam; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.utils.FightStatistics; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; -import org.bukkit.util.Vector; import java.util.List; import java.util.Random; -public class LixfelAI extends AI { +public class DummyAI extends AI { - private final Random random = new Random(); - private LixfelPathplanner pathplanner; + private static final Random random = new Random(); - public LixfelAI(FightTeam team, String user) { - super(team, SteamwarUser.get(user)); + public DummyAI(FightTeam team) { + super(team, SteamwarUser.get("public")); + + FightStatistics.unrank(); + getEntity().setInvulnerable(true); } - @Override public SchematicNode chooseSchematic() { List publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB()); - SchematicNode schem = publics.get(new Random().nextInt(publics.size())); - pathplanner = new LixfelPathplanner(schem); - return schem; + return publics.get(random.nextInt(publics.size())); + } + + @Override + public void schematic(Clipboard clipboard) { + //does nothing } @Override protected void plan() { - setReady(); - Vector destination = pathplanner.getWalkable().get(random.nextInt(pathplanner.getWalkable().size())); - List path = pathplanner.plan(getPosition(), destination); - if(!path.isEmpty()) - chat("Path size: " + path.size()); - for(Vector p : path) { - move(p); - } + if(FightState.getFightState() == FightState.POST_SCHEM_SETUP) + setReady(); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelPathplanner.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelPathplanner.java deleted file mode 100644 index b2e593e8..00000000 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelPathplanner.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2023 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.fightsystem.ai; - -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.world.block.BlockType; -import de.steamwar.fightsystem.Config; -import de.steamwar.sql.SchematicData; -import de.steamwar.sql.SchematicNode; -import org.bukkit.util.Vector; - -import java.io.IOException; -import java.util.*; - -public class LixfelPathplanner { - - private static BlockType getBlockType(Clipboard clipboard, BlockVector3 vector) { - return clipboard.getBlock(vector).getBlockType(); - } - - private static boolean nonsolid(Clipboard clipboard, BlockVector3 vector) { - return !getBlockType(clipboard, vector).getMaterial().isSolid(); - } - - private static Vector toBukkit(BlockVector3 vector) { - return new Vector(vector.getX() + 0.5, vector.getY(), vector.getZ() + 0.5); - } - - private final List walkable = new ArrayList<>(); - private final Map neighbours = new HashMap<>(); - - public LixfelPathplanner(SchematicNode schem) { - try { - fillWalkable(new SchematicData(schem).load()); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - - public List getWalkable() { - return walkable; - } - - private void fillWalkable(Clipboard clipboard) { - BlockVector3 min = clipboard.getRegion().getMinimumPoint().subtract(Config.PreperationArea, 0, Config.PreperationArea); //TODO assumes nonextended Schematic with maximal size - Region region = clipboard.getRegion(); - clipboard.getRegion().forEach(vector -> { - BlockVector3 below = vector.subtract(0, 1, 0); - if(!region.contains(below)) - return; - - BlockType belowMaterial = getBlockType(clipboard, below); - BlockVector3 above = vector.add(0, 1, 0); - if(nonsolid(clipboard, vector)) { - if( - (belowMaterial.getMaterial().isSolid() || belowMaterial.getId().equals("minecraft:ladder")) && - (!region.contains(above) || nonsolid(clipboard, above)) - ) - walkable.add(toBukkit(vector.subtract(min))); - } else { - if(!region.contains(above)) - walkable.add(toBukkit(above.subtract(min))); - } - }); - - for(Vector vector : walkable) { - neighbours.put(vector, walkable.stream().filter(neighbour -> neighbouring(neighbour, vector)).filter(neighbour -> neighbour != vector).toArray(Vector[]::new)); - } - } - - public List planToAnywhere(Vector start, Vector destination) { - Vector intermediate = walkable.stream().filter(vector -> neighbouring(vector, destination)).findAny().orElse(null); - - if(intermediate == null) - return Collections.emptyList(); - - List plan = plan(start, intermediate); - plan.add(destination); - - return plan; - } - - public List plan(Vector start, Vector destination) { - if(neighbouring(start, destination)) - return Collections.singletonList(destination); - - Map approach = new HashMap<>(); - Set checking = Collections.singleton(destination); - - while(!checking.isEmpty()) { - Set toCheck = new HashSet<>(); - for(Vector current : checking) { - Vector firstStep = Arrays.stream(neighbours.get(current)) - .filter(vector -> !approach.containsKey(vector)) - .filter(next -> { - approach.put(next, current); - toCheck.add(next); - return neighbouring(next, start); - }) - .findAny().orElse(null); - - if(firstStep != null) { - List path = new ArrayList<>(); - path.add(firstStep); - - while(path.get(path.size()-1) != destination) { - path.add(approach.get(path.get(path.size()-1))); - } - - return path; - } - } - checking = toCheck; - } - - return Collections.emptyList(); - } - - private boolean neighbouring(Vector a, Vector b) { - return Math.abs(a.getX() - b.getX()) <= 1 && Math.abs(a.getY() - b.getY()) <= 1 && Math.abs(a.getZ() - b.getZ()) <= 1; - } -} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java index 0fba5388..4834bb0a 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java @@ -22,6 +22,7 @@ package de.steamwar.fightsystem.commands; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.ai.AIManager; import de.steamwar.fightsystem.fight.*; import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.states.FightState; @@ -38,9 +39,8 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; +import java.util.*; +import java.util.stream.Collectors; public class GUI { private GUI(){} @@ -53,7 +53,7 @@ public class GUI { String name = team.getLeader() != null ? team.getLeader().getEntity().getName() : team.getName(); inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColor() + name), click -> { p.closeInventory(); - new JoinRequest(p, team); + JoinRequest.forPlayer(p, team); }); } @@ -89,11 +89,29 @@ public class GUI { inv.open(); } + public static void addAI(Player p) { + SWListInv inv = new SWListInv<>( + p, msg.parse("ADD_AI_TITLE", p), + AIManager.availableAIs().stream().map(manager -> new SWListInv.SWListEntry<>(new SWItem(manager.getIcon(), manager.name()), manager)).collect(Collectors.toList()), + (click, manager) -> { + FightTeam team = Fight.getPlayerTeam(p); + if(FightState.PreLeaderSetup.contains(FightState.getFightState())) { + manager.join(Fight.getOpposite(team)); + } else { + JoinRequest.forAI(manager, team); + } + p.closeInventory(); + } + ); + inv.setCallback(-999, (ClickType click) -> p.closeInventory()); + inv.open(); + } + public static void chooseJoinRequests(Player p){ - List> players = JoinRequest.openRequests(p, Fight.getPlayerTeam(p)); - SWListInv inv = new SWListInv<>(p, msg.parse("REQUESTS_TITLE", p), players, (ClickType click, Player player) -> { + List> players = JoinRequest.openRequests(p, Fight.getPlayerTeam(p)); + SWListInv inv = new SWListInv<>(p, msg.parse("REQUESTS_TITLE", p), players, (ClickType click, JoinRequest request) -> { p.closeInventory(); - RequestsCommand.onJoinRequest(p, player, click.isLeftClick() ? JoinRequest::accept : JoinRequest::decline); + RequestsCommand.onJoinRequest(p, request, click.isLeftClick() ? JoinRequest::accept : JoinRequest::decline); }); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.open(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/RequestsCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/RequestsCommand.java index 36c2a1e3..131cc898 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/RequestsCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/RequestsCommand.java @@ -59,13 +59,7 @@ public class RequestsCommand implements CommandExecutor { return false; } - public static void onJoinRequest(Player player, Player target, BiConsumer handleJoinRequest) { - JoinRequest request = JoinRequest.get(target); - if(request == null) { - FightSystem.getMessage().send("NO_JOIN_REQUEST", player); - return; - } - + public static void onJoinRequest(Player player, JoinRequest request, BiConsumer handleJoinRequest) { FightTeam team = Fight.getPlayerTeam(player); if(!request.required(team)) { FightSystem.getMessage().send("NO_CONFIRMATION", player); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java index 20c304d7..5e84ccdc 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java @@ -34,6 +34,7 @@ import de.steamwar.fightsystem.utils.WorldeditWrapper; import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicType; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.DyeColor; import org.bukkit.Location; @@ -52,6 +53,7 @@ public class FightSchematic extends StateDependent { private final Region region; private final boolean rotate; + @Getter private Clipboard clipboard = null; private int schematic = 0; @@ -137,6 +139,7 @@ public class FightSchematic extends StateDependent { private void paste(){ FreezeWorld freezer = new FreezeWorld(); + team.teleportToSpawn(); Vector dims = WorldeditWrapper.impl.getDimensions(clipboard); WorldeditWrapper.impl.pasteClipboard( clipboard, @@ -149,11 +152,11 @@ public class FightSchematic extends StateDependent { new AffineTransform().rotateY(rotate ? 180 : 0) ); FightSystem.getHullHider().initialize(team); + team.getPlayers().forEach(fightPlayer -> fightPlayer.ifAI(ai -> ai.schematic(clipboard))); if(ArenaMode.Check.contains(Config.mode) && !team.isBlue()) - replaceSync(Material.TNT, Material.OBSIDIAN); + replaceSync(Material.TNT, Material.RED_WOOL); Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3); - Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40); } @Override diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index 853646fc..334f3f83 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.ai.AIManager; import de.steamwar.fightsystem.commands.GUI; import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.events.TeamLeaveEvent; @@ -70,9 +71,11 @@ public class FightTeam { static { setKitButton(notReadyKit, true); - if(!ArenaMode.RankedEvent.contains(Config.mode)){ + if(ArenaMode.VariableTeams.contains(Config.mode)){ notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests); notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).build(), GUI::chooseRemove); + if(!AIManager.availableAIs().isEmpty()) + notReadyKit.setItem(6, "ADD_AI", new ItemBuilder(Material.REDSTONE).build(), GUI::addAI); } if(Config.test()) @@ -452,6 +455,10 @@ public class FightTeam { return schematic.getId(); } + public Clipboard getClipboard() { + return schematic.getClipboard(); + } + public double getCurrentHearts() { return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum(); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/JoinRequest.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/JoinRequest.java index a7756e4c..e4e349c7 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/JoinRequest.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/JoinRequest.java @@ -20,6 +20,7 @@ package de.steamwar.fightsystem.fight; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.ai.AIManager; import de.steamwar.fightsystem.states.FightState; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; @@ -28,44 +29,66 @@ import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.entity.Player; import java.util.*; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; import java.util.stream.Collectors; public class JoinRequest { - private static final Map activeRequests = new HashMap<>(); + private static final Map playerRequests = new HashMap<>(); + private static final List activeRequests = new ArrayList<>(); + public static JoinRequest get(Player player) { + return playerRequests.get(player); + } - public static List> openRequests(Player p, FightTeam team) { - return activeRequests.values().stream().filter( + public static List> openRequests(Player p, FightTeam team) { + return activeRequests.stream().filter( request -> request.waitOnApproval.contains(team) ).map(request -> { - SWItem item = SWItem.getPlayerSkull(request.player); - item.setLore(Arrays.asList( + AtomicReference item = new AtomicReference<>(); + request.enquirer.ifPlayer(player -> item.set(SWItem.getPlayerSkull(player))); + request.enquirer.ifAI(manager -> item.set(new SWItem(manager.getIcon(), manager.name()))); + item.get().setLore(Arrays.asList( FightSystem.getMessage().parse("REQUESTS_LEFT_CLICK", p), FightSystem.getMessage().parse("REQUESTS_RIGHT_CLICK", p) )); - return new SWListInv.SWListEntry<>(item, request.player); + return new SWListInv.SWListEntry<>(item.get(), request); }).collect(Collectors.toList()); } public static void clearRequests() { + playerRequests.clear(); activeRequests.clear(); } - public static JoinRequest get(Player player) { - return activeRequests.get(player); + public static void forPlayer(Player player, FightTeam team) { + new JoinRequest(new Enquirer() { + @Override public String name() { return player.getName(); } + @Override public void ifPlayer(Consumer function) { function.accept(player); } + @Override public void ifAI(Consumer function) {} + }, team, FightState.ingame() ? Fight.teams() : Collections.singleton(team)); } - private final Player player; + public static void forAI(AIManager manager, FightTeam team) { + new JoinRequest(new Enquirer() { + @Override public String name() { return manager.name(); } + @Override public void ifPlayer(Consumer function) {} + @Override public void ifAI(Consumer function) { function.accept(manager); } + }, team, Collections.singleton(Fight.getOpposite(team))); + } + + private final Enquirer enquirer; private final FightTeam team; private final Set waitOnApproval; - public JoinRequest(Player player, FightTeam team) { - this.player = player; + private JoinRequest(Enquirer enquirer, FightTeam team, Collection waitOnApproval) { + this.enquirer = enquirer; this.team = team; - this.waitOnApproval = new HashSet<>(FightState.ingame() ? Fight.teams() : Collections.singleton(team)); + this.waitOnApproval = new HashSet<>(waitOnApproval); Set alreadyAccepted = new HashSet<>(); - activeRequests.put(player, this); + enquirer.ifPlayer(player -> playerRequests.put(player, this)); + activeRequests.add(this); for(FightTeam t : waitOnApproval) { FightPlayer leader = t.getLeader(); if(leader == null) @@ -74,14 +97,14 @@ public class JoinRequest { if(leader.getEntity() == null) continue; - leader.ifPlayer(leaderPlayer -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), player.getName(), team.getColoredName())); + leader.ifPlayer(leaderPlayer -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), enquirer.name(), team.getColoredName())); leader.ifAI(ai -> { - if(ai.acceptJoinRequest(player, team)) + if(ai.acceptJoinRequest(enquirer, team)) alreadyAccepted.add(t); }); } - FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_CONFIRMATION", player, ChatMessageType.ACTION_BAR); + enquirer.ifPlayer(player -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_CONFIRMATION", player, ChatMessageType.ACTION_BAR)); alreadyAccepted.forEach(this::accept); } @@ -93,18 +116,26 @@ public class JoinRequest { waitOnApproval.remove(acceptor); if(waitOnApproval.isEmpty()) { - team.addMember(player); - activeRequests.remove(player); + enquirer.ifPlayer(team::addMember); + enquirer.ifAI(manager -> manager.join(team)); + close(); } } public void decline(FightTeam declinor) { - FightSystem.getMessage().sendPrefixless("REQUEST_YOUR_DECLINED", player, ChatMessageType.ACTION_BAR); - waitOnApproval.forEach(t -> t.broadcast("REQUEST_DECLINED", player.getName())); - silentDecline(); + enquirer.ifPlayer(player -> FightSystem.getMessage().sendPrefixless("REQUEST_YOUR_DECLINED", player, ChatMessageType.ACTION_BAR)); + waitOnApproval.forEach(t -> t.broadcast("REQUEST_DECLINED", enquirer.name())); + close(); } - public void silentDecline() { - activeRequests.remove(player); + public void close() { + enquirer.ifPlayer(playerRequests::remove); + activeRequests.remove(this); + } + + public interface Enquirer { + String name(); + void ifPlayer(Consumer function); + void ifAI(Consumer function); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/JoinRequestListener.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/JoinRequestListener.java index 1ed3fe8b..45121cf7 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/JoinRequestListener.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/JoinRequestListener.java @@ -69,6 +69,6 @@ public class JoinRequestListener implements Listener { public void onLeave(PlayerQuitEvent event) { JoinRequest request = JoinRequest.get(event.getPlayer()); if(request != null) - request.silentDecline(); + request.close(); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java index f77c1904..889c3c1c 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -43,6 +43,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -70,7 +71,7 @@ public class Recording implements Listener { return stack; } - public static boolean isNotSent(Player p){ + public static boolean isNotSent(LivingEntity p){ FightPlayer fp = Fight.getFightPlayer(p); return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE; } @@ -193,10 +194,10 @@ public class Recording implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent e) { - if(e.getEntityType() != EntityType.PLAYER) + if(!e.getEntityType().isAlive()) return; - Player p = (Player) e.getEntity(); + LivingEntity p = (LivingEntity) e.getEntity(); if(isNotSent(p)) return; @@ -208,10 +209,10 @@ public class Recording implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityCombust(EntityCombustEvent e) { - if(e.getEntityType() != EntityType.PLAYER) + if(!e.getEntityType().isAlive()) return; - Player p = (Player) e.getEntity(); + LivingEntity p = (LivingEntity) e.getEntity(); if(isNotSent(p)) return; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java index d57a29b9..73821e6f 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java @@ -204,7 +204,7 @@ public interface Recorder { write(0x0a, e.getEntityId(), start, offHand); } - default void damageAnimation(Player p) { + default void damageAnimation(LivingEntity p) { write(0x0b, p.getEntityId()); } From e1769a42f4f470de2f991b73df4afe157b16978e Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 29 Aug 2024 13:58:27 +0200 Subject: [PATCH 03/14] DummyAI only Test arenas --- .../src/de/steamwar/fightsystem/ai/AIManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java index 5b9abf4b..2cb13f65 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java @@ -20,6 +20,8 @@ package de.steamwar.fightsystem.ai; import com.comphenix.tinyprotocol.Reflection; +import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.FightTeam; import lombok.AllArgsConstructor; import lombok.Getter; @@ -33,7 +35,7 @@ import java.util.stream.Collectors; @AllArgsConstructor public class AIManager { private static final List AIs = Arrays.asList( - new AIManager(DummyAI.class, Material.STONE, () -> true) + new AIManager(DummyAI.class, Material.STONE, () -> ArenaMode.Test.contains(Config.mode)) ); public static List availableAIs() { From 94502a15670d439fbddaf50bb8161730e37bca4c Mon Sep 17 00:00:00 2001 From: TheBreadBeard Date: Thu, 29 Aug 2024 22:40:05 +0200 Subject: [PATCH 04/14] Add npc chat messages --- LobbySystem/src/de/steamwar/lobby/LobbySystem.properties | 8 ++++++-- .../src/de/steamwar/lobby/LobbySystem_de.properties | 8 ++++++-- LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java | 5 ++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties b/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties index 4530aaaf..b1c5ccb9 100644 --- a/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties +++ b/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties @@ -4,8 +4,12 @@ DATE=........ COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===--- # ServerTeamNPC's -NPC_CHAT_1 = §fHello, I''m {0} and I''m a(n) {1}§f. -NPC_CHAT_2 = §fWelcome on §eSteam§8War§f, have fun. +NPC_CHAT_0 = §fHello, I''m {0} and I''m a(n) {1}§f. +NPC_CHAT_1 = §fWelcome on §eSteam§8War§f, have fun. +NPC_CHAT_2 = §eSteam§8War§f was established in 2019. +NPC_CHAT_3 = &fBecome a part of our team by applying via our Discord server (https://steamwar.de/discord). +NPC_CHAT_4 = &fYou can develop your own buildserver features with our Lua script system or activate public ones via our script lybrary. +NPC_CHAT_5 = &fThere are many secrets to discover in this lobby. # Portal Command PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Lists all portals diff --git a/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties b/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties index 969270ee..8c126add 100644 --- a/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties @@ -4,8 +4,12 @@ DATE=........ COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===--- # ServerTeamNPC's -NPC_CHAT_1 = §fHallo, ich bin {0} und bin ein {1}§f. -NPC_CHAT_2 = §fWillkommen auf §eSteam§8War§f, viel Spaß dir. +NPC_CHAT_0 = §fHallo, ich bin {0} und bin ein {1}§f. +NPC_CHAT_1 = §fWillkommen auf §eSteam§8War§f, viel Spaß dir. +NPC_CHAT_2 = §eSteam§8War§f gibt es seit 2019. +NPC_CHAT_3 = &fBewerbe dich gerne für unser Team über unseren Discord-Server (https://steamwar.de/discord). +NPC_CHAT_4 = &fDu kannst mit unserm Lua Script-System deine eigenen Bau Features programmieren oder öffentliche Skripte über die Script-Lybrary aktivieren. +NPC_CHAT_5 = &fAuf dieser Lobby sind so einige secrets versteckt. # Portal Command PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Listet alle Portale auf diff --git a/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java b/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java index 296b1d6f..2142d6fe 100644 --- a/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java @@ -149,8 +149,11 @@ public class TeamPlayer extends BasicListener { players.remove(event.getPlayer()); return; } + + int randomNum = random.nextInt(6); + String message = "NPC_Chat_" + randomNum; + SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName()); - String message = strings.get(random.nextInt(strings.size())); UserPerm.Prefix prefix = user.prefix(); LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), prefix.getColorCode() + prefix.getChatPrefix()); } From 338f2e6ed17dd85c778fbc47fdc6bebd4a1e36b3 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 3 Nov 2024 11:57:37 +0100 Subject: [PATCH 05/14] Add FightInfoPacketSender for TowerRun --- .../towerrun/FightInfoPacketSender.java | 66 +++++++++++++++++++ .../src/de/steamwar/towerrun/TowerRun.java | 3 + .../de/steamwar/towerrun/config/Config.java | 7 ++ .../towerrun/countdowns/GameCountdown.java | 14 ++++ 4 files changed, 90 insertions(+) create mode 100644 TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java diff --git a/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java b/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java new file mode 100644 index 00000000..2893268f --- /dev/null +++ b/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java @@ -0,0 +1,66 @@ +/* + * + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 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.towerrun; + +import de.steamwar.network.NetworkSender; +import de.steamwar.network.packets.common.FightInfoPacket; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.towerrun.config.Config; +import de.steamwar.towerrun.game.TowerRunGame; +import de.steamwar.towerrun.state.GameState; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class FightInfoPacketSender implements Runnable { + + private final World world = Bukkit.getWorlds().get(0); + + private final String serverName = Bukkit.getServer().getName(); + private final String gameMode = "towerrun"; + private final String worldName = world.getName(); + private final String blueName = "§3Alive"; + private final String redName = "§fEscaped"; + + @Override + public void run() { + if (Config.test()) { + return; + } + + List alivePlayers = TowerRunGame.PLAYERS_ALIVE.stream().map(player -> SteamwarUser.get(player.player().getUniqueId()).getId()).collect(Collectors.toList()); + List escapedPlayers = TowerRunGame.PLAYERS_ESCAPED.stream().map(player -> SteamwarUser.get(player.player().getUniqueId()).getId()).collect(Collectors.toList()); + List spectatorPlayers = new ArrayList<>(); + for (Player player : Bukkit.getOnlinePlayers()) { + int id = SteamwarUser.get(player.getUniqueId()).getId(); + if (!alivePlayers.contains(id) && !escapedPlayers.contains(id)) { + spectatorPlayers.add(id); + } + } + + NetworkSender.send(new FightInfoPacket(serverName, gameMode, worldName, blueName, redName, GameState.getCurrentState().name().toLowerCase(), TowerRun.getGameCountdown().getPlayTimeInSeconds(), 0, 0, 0, 0, alivePlayers, escapedPlayers, spectatorPlayers)); + } +} diff --git a/TowerRun/src/de/steamwar/towerrun/TowerRun.java b/TowerRun/src/de/steamwar/towerrun/TowerRun.java index c0717b2f..23f00488 100644 --- a/TowerRun/src/de/steamwar/towerrun/TowerRun.java +++ b/TowerRun/src/de/steamwar/towerrun/TowerRun.java @@ -32,6 +32,7 @@ import de.steamwar.towerrun.listener.IngameListener; import de.steamwar.towerrun.listener.LobbyListener; import de.steamwar.towerrun.listener.NotLobbyListener; import lombok.Getter; +import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.annotation.dependency.Dependency; import org.bukkit.plugin.java.annotation.plugin.ApiVersion; @@ -79,6 +80,8 @@ public class TowerRun extends JavaPlugin { new StartCommand(lobbyCountdown); gameCountdown = new GameCountdown(); + Bukkit.getScheduler().runTaskTimer(this, new FightInfoPacketSender(), 20, 20); + TowerRunGame.reset(); } } diff --git a/TowerRun/src/de/steamwar/towerrun/config/Config.java b/TowerRun/src/de/steamwar/towerrun/config/Config.java index 7890e785..bce0cb54 100644 --- a/TowerRun/src/de/steamwar/towerrun/config/Config.java +++ b/TowerRun/src/de/steamwar/towerrun/config/Config.java @@ -39,6 +39,8 @@ public class Config { public static final int GAME_TIMER; public static final int GAME_ESCAPE_TIMER; + private static final int EventKampfID; + static { File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml"); if (!configFile.exists()) { @@ -53,6 +55,11 @@ public class Config { GAME_TIMER = config.getInt("gameTimer", 20 * 60); GAME_ESCAPE_TIMER = config.getInt("gameEscapeTimer", 60); DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet())); + + EventKampfID = Integer.parseInt(System.getProperty("fightID", "0")); } + public static boolean test() { + return EventKampfID == -1; + } } diff --git a/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java b/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java index b56c1f3b..29487859 100644 --- a/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java +++ b/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java @@ -28,6 +28,8 @@ import java.util.EnumSet; public class GameCountdown extends Countdown { + private long startTime = 0; + public GameCountdown() { super(EnumSet.of(GameStates.INGAME)); } @@ -59,9 +61,21 @@ public class GameCountdown extends Countdown { TowerRun.getMessage().broadcastActionbar("GAME_TIME", String.format("%02d", timeMinutes), String.format("%02d", timeSeconds)); } + @Override + public void enable() { + super.enable(); + startTime = System.currentTimeMillis(); + } + @Override public void disable() { super.disable(); setTime(defaultTime()); + startTime = 0; + } + + public int getPlayTimeInSeconds() { + if (startTime == 0) return 0; + return (int) ((System.currentTimeMillis() - startTime) / 1000); } } From 6fea09fb9d246b69a569aaf57e060d6b20b50b64 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 3 Nov 2024 20:26:24 +0100 Subject: [PATCH 06/14] Fix nit picks --- .../src/de/steamwar/towerrun/FightInfoPacketSender.java | 2 +- TowerRun/src/de/steamwar/towerrun/config/Config.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java b/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java index 2893268f..92171fae 100644 --- a/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java +++ b/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java @@ -2,7 +2,7 @@ * * This file is a part of the SteamWar software. * - * Copyright (C) 2020 SteamWar.de-Serverteam + * Copyright (C) 2024 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 diff --git a/TowerRun/src/de/steamwar/towerrun/config/Config.java b/TowerRun/src/de/steamwar/towerrun/config/Config.java index bce0cb54..91fb02b4 100644 --- a/TowerRun/src/de/steamwar/towerrun/config/Config.java +++ b/TowerRun/src/de/steamwar/towerrun/config/Config.java @@ -39,7 +39,7 @@ public class Config { public static final int GAME_TIMER; public static final int GAME_ESCAPE_TIMER; - private static final int EventKampfID; + private static final int EVENT_KAMPF_ID; static { File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml"); @@ -56,10 +56,10 @@ public class Config { GAME_ESCAPE_TIMER = config.getInt("gameEscapeTimer", 60); DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet())); - EventKampfID = Integer.parseInt(System.getProperty("fightID", "0")); + EVENT_KAMPF_ID = Integer.parseInt(System.getProperty("fightID", "0")); } public static boolean test() { - return EventKampfID == -1; + return EVENT_KAMPF_ID == -1; } } From 1c7c57e10c8b4af6ba30c9cade584a9750354db4 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 10 Nov 2024 17:30:30 +0100 Subject: [PATCH 07/14] Update JDA to 5.2.0 --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index edd33ceb..2379d8bd 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -107,7 +107,7 @@ dependencyResolutionManagement { library("netty", "io.netty:netty-all:4.1.68.Final") library("junit", "junit:junit:4.13.2") library("hamcrest", "org.hamcrest:hamcrest:2.2") - library("jda", "net.dv8tion:JDA:5.0.2") + library("jda", "net.dv8tion:JDA:5.2.0") library("msgpack", "org.msgpack:msgpack-core:0.9.8") library("classindex", "org.atteo.classindex:classindex:3.13") From fdd6d84b544dde94c95ebee90b0170035da9ccec Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 10 Nov 2024 17:46:43 +0100 Subject: [PATCH 08/14] Fix mod name during kick/ban --- VelocityCore/src/de/steamwar/velocitycore/mods/ModUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/mods/ModUtils.java b/VelocityCore/src/de/steamwar/velocitycore/mods/ModUtils.java index 4342103b..b6e68cb9 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/mods/ModUtils.java +++ b/VelocityCore/src/de/steamwar/velocitycore/mods/ModUtils.java @@ -76,9 +76,9 @@ public class ModUtils { String message; if(mods.size() == 1) { - message = sender.parseToLegacy(max == ModType.RED ? "MOD_RED_SING" : "MOD_YELLOW_SING", locale, modList); + message = sender.parseToLegacy(max == ModType.RED ? "MOD_RED_SING" : "MOD_YELLOW_SING", modList); } else { - message = sender.parseToLegacy(max == ModType.RED ? "MOD_RED_PLUR" : "MOD_YELLOW_PLUR", locale, modList); + message = sender.parseToLegacy(max == ModType.RED ? "MOD_RED_PLUR" : "MOD_YELLOW_PLUR", modList); } if(max == ModType.RED) { From af4a3eb2ed553a6618211a90aa7e38a1f92fd8b8 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 11 Nov 2024 09:29:12 +0100 Subject: [PATCH 09/14] Fix empty discord messages --- .../src/de/steamwar/velocitycore/discord/DiscordBot.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordBot.java b/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordBot.java index 57f6c1ef..10cb773f 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordBot.java +++ b/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordBot.java @@ -48,6 +48,7 @@ import net.dv8tion.jda.api.interactions.commands.build.Commands; import net.dv8tion.jda.api.interactions.commands.build.OptionData; import net.dv8tion.jda.api.interactions.components.ActionRow; import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction; import net.dv8tion.jda.api.utils.MemberCachePolicy; import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; @@ -99,6 +100,7 @@ public class DiscordBot { .createDefault(config.getToken()) .setStatus(OnlineStatus.ONLINE) .setMemberCachePolicy(MemberCachePolicy.ONLINE) + .enableIntents(GatewayIntent.MESSAGE_CONTENT) .build(); instance = this; From 32afd1de8c25842dff6ba3bbc0f0bc5e2757142f Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 11 Nov 2024 15:05:08 +0100 Subject: [PATCH 10/14] Fix PR things --- .../src/de/steamwar/towerrun/FightInfoPacketSender.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java b/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java index 92171fae..da8c913b 100644 --- a/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java +++ b/TowerRun/src/de/steamwar/towerrun/FightInfoPacketSender.java @@ -42,8 +42,8 @@ public class FightInfoPacketSender implements Runnable { private final String serverName = Bukkit.getServer().getName(); private final String gameMode = "towerrun"; private final String worldName = world.getName(); - private final String blueName = "§3Alive"; - private final String redName = "§fEscaped"; + private final String blueName = "§3Escaped"; + private final String redName = "§cAlive"; @Override public void run() { @@ -61,6 +61,6 @@ public class FightInfoPacketSender implements Runnable { } } - NetworkSender.send(new FightInfoPacket(serverName, gameMode, worldName, blueName, redName, GameState.getCurrentState().name().toLowerCase(), TowerRun.getGameCountdown().getPlayTimeInSeconds(), 0, 0, 0, 0, alivePlayers, escapedPlayers, spectatorPlayers)); + NetworkSender.send(new FightInfoPacket(serverName, gameMode, worldName, blueName, redName, GameState.getCurrentState().name().toLowerCase(), TowerRun.getGameCountdown().getPlayTimeInSeconds(), 0, 0, 0, 0, escapedPlayers, alivePlayers, spectatorPlayers)); } } From 43618fc2903a9520cad3ae2ffade1c317c457bc0 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 12 Nov 2024 15:41:48 +0100 Subject: [PATCH 11/14] Fix transitive dependencies for STRG+Click in Source code not jumping to Source code --- BauSystem/BauSystem_15/build.gradle.kts | 4 ++-- BauSystem/BauSystem_18/build.gradle.kts | 4 ++-- BauSystem/BauSystem_19/build.gradle.kts | 4 ++-- BauSystem/BauSystem_20/build.gradle.kts | 4 ++-- BauSystem/BauSystem_Main/build.gradle.kts | 2 +- FightSystem/FightSystem_10/build.gradle.kts | 4 ++-- FightSystem/FightSystem_12/build.gradle.kts | 6 +++--- FightSystem/FightSystem_14/build.gradle.kts | 8 ++++---- FightSystem/FightSystem_15/build.gradle.kts | 4 ++-- FightSystem/FightSystem_18/build.gradle.kts | 4 ++-- FightSystem/FightSystem_19/build.gradle.kts | 4 ++-- FightSystem/FightSystem_20/build.gradle.kts | 4 ++-- FightSystem/FightSystem_8/build.gradle.kts | 4 ++-- FightSystem/FightSystem_9/build.gradle.kts | 6 +++--- FightSystem/FightSystem_Core/build.gradle.kts | 2 +- LobbySystem/build.gradle.kts | 2 +- MissileWars/build.gradle.kts | 2 +- SchematicSystem/SchematicSystem_15/build.gradle.kts | 4 ++-- SchematicSystem/SchematicSystem_8/build.gradle.kts | 4 ++-- SchematicSystem/SchematicSystem_Core/build.gradle.kts | 2 +- SpigotCore/SpigotCore_10/build.gradle.kts | 2 +- SpigotCore/SpigotCore_12/build.gradle.kts | 4 ++-- SpigotCore/SpigotCore_14/build.gradle.kts | 8 ++++---- SpigotCore/SpigotCore_15/build.gradle.kts | 2 +- SpigotCore/SpigotCore_18/build.gradle.kts | 6 +++--- SpigotCore/SpigotCore_19/build.gradle.kts | 6 +++--- SpigotCore/SpigotCore_20/build.gradle.kts | 2 +- SpigotCore/SpigotCore_8/build.gradle.kts | 4 ++-- SpigotCore/SpigotCore_9/build.gradle.kts | 4 ++-- SpigotCore/SpigotCore_Main/build.gradle.kts | 6 +++--- TNTLeague/build.gradle.kts | 4 ++-- Teamserver/build.gradle.kts | 2 +- TowerRun/build.gradle.kts | 2 +- TutorialSystem/build.gradle.kts | 2 +- VelocityCore/build.gradle.kts | 2 +- 35 files changed, 67 insertions(+), 67 deletions(-) diff --git a/BauSystem/BauSystem_15/build.gradle.kts b/BauSystem/BauSystem_15/build.gradle.kts index 46aaa27a..2cbe19e6 100644 --- a/BauSystem/BauSystem_15/build.gradle.kts +++ b/BauSystem/BauSystem_15/build.gradle.kts @@ -27,8 +27,8 @@ java { } dependencies { - compileOnly(project(":BauSystem:BauSystem_Main")) - compileOnly(project(":SpigotCore")) + compileOnly(project(":BauSystem:BauSystem_Main", "default")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.nms15) compileOnly(libs.worldedit15) diff --git a/BauSystem/BauSystem_18/build.gradle.kts b/BauSystem/BauSystem_18/build.gradle.kts index 08a1a218..d3ad4f8e 100644 --- a/BauSystem/BauSystem_18/build.gradle.kts +++ b/BauSystem/BauSystem_18/build.gradle.kts @@ -27,8 +27,8 @@ java { } dependencies { - compileOnly(project(":BauSystem:BauSystem_Main")) - compileOnly(project(":SpigotCore")) + compileOnly(project(":BauSystem:BauSystem_Main", "default")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) compileOnly(libs.nms18) diff --git a/BauSystem/BauSystem_19/build.gradle.kts b/BauSystem/BauSystem_19/build.gradle.kts index f67105e7..b72cbf08 100644 --- a/BauSystem/BauSystem_19/build.gradle.kts +++ b/BauSystem/BauSystem_19/build.gradle.kts @@ -27,8 +27,8 @@ java { } dependencies { - compileOnly(project(":BauSystem:BauSystem_Main")) - compileOnly(project(":SpigotCore")) + compileOnly(project(":BauSystem:BauSystem_Main", "default")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) compileOnly(libs.paperapi) diff --git a/BauSystem/BauSystem_20/build.gradle.kts b/BauSystem/BauSystem_20/build.gradle.kts index 5ec08958..b1756244 100644 --- a/BauSystem/BauSystem_20/build.gradle.kts +++ b/BauSystem/BauSystem_20/build.gradle.kts @@ -27,8 +27,8 @@ java { } dependencies { - compileOnly(project(":BauSystem:BauSystem_Main")) - compileOnly(project(":SpigotCore")) + compileOnly(project(":BauSystem:BauSystem_Main", "default")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) diff --git a/BauSystem/BauSystem_Main/build.gradle.kts b/BauSystem/BauSystem_Main/build.gradle.kts index 5138608b..63d6f026 100644 --- a/BauSystem/BauSystem_Main/build.gradle.kts +++ b/BauSystem/BauSystem_Main/build.gradle.kts @@ -33,7 +33,7 @@ java { dependencies { compileOnly(libs.classindex) annotationProcessor(libs.classindex) - compileOnly(project(":SpigotCore")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) compileOnly(libs.axiom) diff --git a/FightSystem/FightSystem_10/build.gradle.kts b/FightSystem/FightSystem_10/build.gradle.kts index 882668ff..d34e28f4 100644 --- a/FightSystem/FightSystem_10/build.gradle.kts +++ b/FightSystem/FightSystem_10/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) - compileOnly(project(":FightSystem:FightSystem_Core")) + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":FightSystem:FightSystem_Core", "default")) compileOnly(libs.nms10) } diff --git a/FightSystem/FightSystem_12/build.gradle.kts b/FightSystem/FightSystem_12/build.gradle.kts index c172455a..8ec0f834 100644 --- a/FightSystem/FightSystem_12/build.gradle.kts +++ b/FightSystem/FightSystem_12/build.gradle.kts @@ -22,9 +22,9 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) - compileOnly(project(":FightSystem:FightSystem_Core")) - compileOnly(project(":FightSystem:FightSystem_8")) + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":FightSystem:FightSystem_Core", "default")) + compileOnly(project(":FightSystem:FightSystem_8", "default")) compileOnly(libs.nms12) compileOnly(libs.worldedit12) diff --git a/FightSystem/FightSystem_14/build.gradle.kts b/FightSystem/FightSystem_14/build.gradle.kts index 2c8e52d5..4fc15121 100644 --- a/FightSystem/FightSystem_14/build.gradle.kts +++ b/FightSystem/FightSystem_14/build.gradle.kts @@ -22,10 +22,10 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) - compileOnly(project(":FightSystem:FightSystem_Core")) - compileOnly(project(":FightSystem:FightSystem_8")) - compileOnly(project(":FightSystem:FightSystem_9")) + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":FightSystem:FightSystem_Core", "default")) + compileOnly(project(":FightSystem:FightSystem_8", "default")) + compileOnly(project(":FightSystem:FightSystem_9", "default")) compileOnly(libs.nms14) compileOnly(libs.worldedit15) diff --git a/FightSystem/FightSystem_15/build.gradle.kts b/FightSystem/FightSystem_15/build.gradle.kts index c1556233..4b16dc73 100644 --- a/FightSystem/FightSystem_15/build.gradle.kts +++ b/FightSystem/FightSystem_15/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) - compileOnly(project(":FightSystem:FightSystem_Core")) + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":FightSystem:FightSystem_Core", "default")) compileOnly(libs.nms15) compileOnly(libs.worldedit15) diff --git a/FightSystem/FightSystem_18/build.gradle.kts b/FightSystem/FightSystem_18/build.gradle.kts index c6a938e0..fa12144d 100644 --- a/FightSystem/FightSystem_18/build.gradle.kts +++ b/FightSystem/FightSystem_18/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) - compileOnly(project(":FightSystem:FightSystem_Core")) + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":FightSystem:FightSystem_Core", "default")) compileOnly(libs.spigotapi) diff --git a/FightSystem/FightSystem_19/build.gradle.kts b/FightSystem/FightSystem_19/build.gradle.kts index 0dc7a095..6ccb56c9 100644 --- a/FightSystem/FightSystem_19/build.gradle.kts +++ b/FightSystem/FightSystem_19/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":FightSystem:FightSystem_Core")) - compileOnly(project(":FightSystem:FightSystem_18")) + compileOnly(project(":FightSystem:FightSystem_Core", "default")) + compileOnly(project(":FightSystem:FightSystem_18", "default")) compileOnly(libs.spigotapi) diff --git a/FightSystem/FightSystem_20/build.gradle.kts b/FightSystem/FightSystem_20/build.gradle.kts index 99c4a656..13eb77cf 100644 --- a/FightSystem/FightSystem_20/build.gradle.kts +++ b/FightSystem/FightSystem_20/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":FightSystem:FightSystem_Core")) - compileOnly(project(":FightSystem:FightSystem_18")) + compileOnly(project(":FightSystem:FightSystem_Core", "default")) + compileOnly(project(":FightSystem:FightSystem_18", "default")) compileOnly(libs.spigotapi) diff --git a/FightSystem/FightSystem_8/build.gradle.kts b/FightSystem/FightSystem_8/build.gradle.kts index d98e4045..7fb2f827 100644 --- a/FightSystem/FightSystem_8/build.gradle.kts +++ b/FightSystem/FightSystem_8/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) - compileOnly(project(":FightSystem:FightSystem_Core")) + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":FightSystem:FightSystem_Core", "default")) compileOnly(libs.nms8) compileOnly(libs.worldedit12) diff --git a/FightSystem/FightSystem_9/build.gradle.kts b/FightSystem/FightSystem_9/build.gradle.kts index 21c34e22..5edfa1e3 100644 --- a/FightSystem/FightSystem_9/build.gradle.kts +++ b/FightSystem/FightSystem_9/build.gradle.kts @@ -22,9 +22,9 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) - compileOnly(project(":FightSystem:FightSystem_Core")) - compileOnly(project(":FightSystem:FightSystem_8")) + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":FightSystem:FightSystem_Core", "default")) + compileOnly(project(":FightSystem:FightSystem_8", "default")) compileOnly(libs.nms9) } diff --git a/FightSystem/FightSystem_Core/build.gradle.kts b/FightSystem/FightSystem_Core/build.gradle.kts index 8b1d5ece..2f044447 100644 --- a/FightSystem/FightSystem_Core/build.gradle.kts +++ b/FightSystem/FightSystem_Core/build.gradle.kts @@ -22,7 +22,7 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) diff --git a/LobbySystem/build.gradle.kts b/LobbySystem/build.gradle.kts index 3ad7a776..aa511a0c 100644 --- a/LobbySystem/build.gradle.kts +++ b/LobbySystem/build.gradle.kts @@ -27,7 +27,7 @@ java { } dependencies { - compileOnly(project(":SpigotCore")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) diff --git a/MissileWars/build.gradle.kts b/MissileWars/build.gradle.kts index 755e1c46..f393ea31 100644 --- a/MissileWars/build.gradle.kts +++ b/MissileWars/build.gradle.kts @@ -27,7 +27,7 @@ java { } dependencies { - compileOnly(project(":SpigotCore")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) diff --git a/SchematicSystem/SchematicSystem_15/build.gradle.kts b/SchematicSystem/SchematicSystem_15/build.gradle.kts index bfb78f90..df407384 100644 --- a/SchematicSystem/SchematicSystem_15/build.gradle.kts +++ b/SchematicSystem/SchematicSystem_15/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) - compileOnly(project(":SchematicSystem:SchematicSystem_Core")) + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) compileOnly(libs.nms15) compileOnly(libs.worldedit15) diff --git a/SchematicSystem/SchematicSystem_8/build.gradle.kts b/SchematicSystem/SchematicSystem_8/build.gradle.kts index f0e3ade3..5f0f9c62 100644 --- a/SchematicSystem/SchematicSystem_8/build.gradle.kts +++ b/SchematicSystem/SchematicSystem_8/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) - compileOnly(project(":SchematicSystem:SchematicSystem_Core")) + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default")) compileOnly(libs.nms8) compileOnly(libs.worldedit12) diff --git a/SchematicSystem/SchematicSystem_Core/build.gradle.kts b/SchematicSystem/SchematicSystem_Core/build.gradle.kts index 3c08c5d2..df9415f2 100644 --- a/SchematicSystem/SchematicSystem_Core/build.gradle.kts +++ b/SchematicSystem/SchematicSystem_Core/build.gradle.kts @@ -22,7 +22,7 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) compileOnly(libs.worldedit15) diff --git a/SpigotCore/SpigotCore_10/build.gradle.kts b/SpigotCore/SpigotCore_10/build.gradle.kts index 38bce259..9606f5c6 100644 --- a/SpigotCore/SpigotCore_10/build.gradle.kts +++ b/SpigotCore/SpigotCore_10/build.gradle.kts @@ -22,7 +22,7 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore:SpigotCore_Main")) + compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) compileOnly(libs.nms10) } diff --git a/SpigotCore/SpigotCore_12/build.gradle.kts b/SpigotCore/SpigotCore_12/build.gradle.kts index a4c6acd3..da6a46c9 100644 --- a/SpigotCore/SpigotCore_12/build.gradle.kts +++ b/SpigotCore/SpigotCore_12/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":CommonCore")) - compileOnly(project(":SpigotCore:SpigotCore_Main")) + compileOnly(project(":CommonCore", "default")) + compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) compileOnly(libs.nms12) } diff --git a/SpigotCore/SpigotCore_14/build.gradle.kts b/SpigotCore/SpigotCore_14/build.gradle.kts index 8586caeb..5ffc8c1c 100644 --- a/SpigotCore/SpigotCore_14/build.gradle.kts +++ b/SpigotCore/SpigotCore_14/build.gradle.kts @@ -22,10 +22,10 @@ plugins { } dependencies { - compileOnly(project(":CommonCore")) - compileOnly(project(":SpigotCore:SpigotCore_Main")) - compileOnly(project(":SpigotCore:SpigotCore_8")) - compileOnly(project(":SpigotCore:SpigotCore_9")) + compileOnly(project(":CommonCore", "default")) + compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) + compileOnly(project(":SpigotCore:SpigotCore_8", "default")) + compileOnly(project(":SpigotCore:SpigotCore_9", "default")) compileOnly(libs.nms14) compileOnly(libs.worldedit15) diff --git a/SpigotCore/SpigotCore_15/build.gradle.kts b/SpigotCore/SpigotCore_15/build.gradle.kts index b637545e..1e49db83 100644 --- a/SpigotCore/SpigotCore_15/build.gradle.kts +++ b/SpigotCore/SpigotCore_15/build.gradle.kts @@ -22,7 +22,7 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore:SpigotCore_Main")) + compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) compileOnly(libs.nms15) } diff --git a/SpigotCore/SpigotCore_18/build.gradle.kts b/SpigotCore/SpigotCore_18/build.gradle.kts index b27c3aed..a3d4fb44 100644 --- a/SpigotCore/SpigotCore_18/build.gradle.kts +++ b/SpigotCore/SpigotCore_18/build.gradle.kts @@ -26,9 +26,9 @@ tasks.compileJava { } dependencies { - compileOnly(project(":CommonCore")) - compileOnly(project(":SpigotCore:SpigotCore_Main")) - compileOnly(project(":SpigotCore:SpigotCore_14")) + compileOnly(project(":CommonCore", "default")) + compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) + compileOnly(project(":SpigotCore:SpigotCore_14", "default")) compileOnly(libs.spigotapi) compileOnly(libs.nms18) diff --git a/SpigotCore/SpigotCore_19/build.gradle.kts b/SpigotCore/SpigotCore_19/build.gradle.kts index da876e7e..ce9922e4 100644 --- a/SpigotCore/SpigotCore_19/build.gradle.kts +++ b/SpigotCore/SpigotCore_19/build.gradle.kts @@ -22,9 +22,9 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore:SpigotCore_Main")) - compileOnly(project(":SpigotCore:SpigotCore_14")) - compileOnly(project(":SpigotCore:SpigotCore_18")) + compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) + compileOnly(project(":SpigotCore:SpigotCore_14", "default")) + compileOnly(project(":SpigotCore:SpigotCore_18", "default")) compileOnly(libs.worldedit15) compileOnly(libs.nms19) diff --git a/SpigotCore/SpigotCore_20/build.gradle.kts b/SpigotCore/SpigotCore_20/build.gradle.kts index a2a54c32..3e894ccc 100644 --- a/SpigotCore/SpigotCore_20/build.gradle.kts +++ b/SpigotCore/SpigotCore_20/build.gradle.kts @@ -22,7 +22,7 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore:SpigotCore_Main")) + compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) compileOnly(libs.spigotapi) diff --git a/SpigotCore/SpigotCore_8/build.gradle.kts b/SpigotCore/SpigotCore_8/build.gradle.kts index 0ec4a191..f03254dd 100644 --- a/SpigotCore/SpigotCore_8/build.gradle.kts +++ b/SpigotCore/SpigotCore_8/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":CommonCore")) - compileOnly(project(":SpigotCore:SpigotCore_Main")) + compileOnly(project(":CommonCore", "default")) + compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) compileOnly(libs.nms8) compileOnly(libs.worldedit12) diff --git a/SpigotCore/SpigotCore_9/build.gradle.kts b/SpigotCore/SpigotCore_9/build.gradle.kts index 31209477..3463498a 100644 --- a/SpigotCore/SpigotCore_9/build.gradle.kts +++ b/SpigotCore/SpigotCore_9/build.gradle.kts @@ -22,8 +22,8 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore:SpigotCore_Main")) - compileOnly(project(":SpigotCore:SpigotCore_8")) + compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) + compileOnly(project(":SpigotCore:SpigotCore_8", "default")) compileOnly(libs.nms9) diff --git a/SpigotCore/SpigotCore_Main/build.gradle.kts b/SpigotCore/SpigotCore_Main/build.gradle.kts index c70479e5..88825bc9 100644 --- a/SpigotCore/SpigotCore_Main/build.gradle.kts +++ b/SpigotCore/SpigotCore_Main/build.gradle.kts @@ -26,9 +26,9 @@ tasks.compileJava { } dependencies { - compileOnly(project(":CommonCore")) - compileOnly(project(":CommandFramework")) - compileOnly(project(":SpigotCore:CRIUDummy")) + compileOnly(project(":CommonCore", "default")) + compileOnly(project(":CommandFramework", "default")) + compileOnly(project(":SpigotCore:CRIUDummy", "default")) compileOnly(libs.worldedit12) diff --git a/TNTLeague/build.gradle.kts b/TNTLeague/build.gradle.kts index b9689d85..0d7fc472 100644 --- a/TNTLeague/build.gradle.kts +++ b/TNTLeague/build.gradle.kts @@ -4,6 +4,6 @@ plugins { dependencies { compileOnly(libs.paperapi21) - compileOnly(project(":SpigotCore")) - compileOnly(project(":KotlinCore")) + compileOnly(project(":SpigotCore", "default")) + compileOnly(project(":KotlinCore", "default")) } \ No newline at end of file diff --git a/Teamserver/build.gradle.kts b/Teamserver/build.gradle.kts index a2b2a4bb..44d3e49d 100644 --- a/Teamserver/build.gradle.kts +++ b/Teamserver/build.gradle.kts @@ -22,7 +22,7 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) diff --git a/TowerRun/build.gradle.kts b/TowerRun/build.gradle.kts index ad7532f4..8eacd66e 100644 --- a/TowerRun/build.gradle.kts +++ b/TowerRun/build.gradle.kts @@ -30,7 +30,7 @@ dependencies { annotationProcessor(libs.spigotannotations) compileOnly(libs.spigotannotations) - compileOnly(project(":SpigotCore")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.nms19) compileOnly(libs.worldedit15) diff --git a/TutorialSystem/build.gradle.kts b/TutorialSystem/build.gradle.kts index 4b7a557a..0336de23 100644 --- a/TutorialSystem/build.gradle.kts +++ b/TutorialSystem/build.gradle.kts @@ -22,7 +22,7 @@ plugins { } dependencies { - compileOnly(project(":SpigotCore")) + compileOnly(project(":SpigotCore", "default")) compileOnly(libs.nms15) } diff --git a/VelocityCore/build.gradle.kts b/VelocityCore/build.gradle.kts index 2255dc08..e9d6386e 100644 --- a/VelocityCore/build.gradle.kts +++ b/VelocityCore/build.gradle.kts @@ -48,7 +48,7 @@ dependencies { annotationProcessor(libs.velocityapi) compileOnly(libs.velocity) - compileOnly(project(":VelocityCore:Persistent")) + compileOnly(project(":VelocityCore:Persistent", "default")) implementation(project(":CommonCore")) implementation(project(":CommandFramework")) From 0485713e862b31e85ce532f61096e98657ebabaa Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 12 Nov 2024 16:10:46 +0100 Subject: [PATCH 12/14] Update GameStates Fix FightserverPortal.fightStateMapper --- .../src/de/steamwar/lobby/portal/FightserverPortal.java | 2 ++ .../src/de/steamwar/towerrun/countdowns/EndCountdown.java | 2 +- .../de/steamwar/towerrun/countdowns/GameCountdown.java | 2 +- .../de/steamwar/towerrun/countdowns/LobbyCountdown.java | 2 +- TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java | 2 +- .../src/de/steamwar/towerrun/listener/IngameListener.java | 2 +- .../src/de/steamwar/towerrun/listener/LobbyListener.java | 2 +- .../de/steamwar/towerrun/listener/NotLobbyListener.java | 2 +- TowerRun/src/de/steamwar/towerrun/state/GameState.java | 4 ++-- TowerRun/src/de/steamwar/towerrun/state/GameStates.java | 8 ++++---- .../de/steamwar/towerrun/winconditions/WinCondition.java | 2 +- 11 files changed, 16 insertions(+), 14 deletions(-) diff --git a/LobbySystem/src/de/steamwar/lobby/portal/FightserverPortal.java b/LobbySystem/src/de/steamwar/lobby/portal/FightserverPortal.java index 08f03bb3..7d82cfdc 100644 --- a/LobbySystem/src/de/steamwar/lobby/portal/FightserverPortal.java +++ b/LobbySystem/src/de/steamwar/lobby/portal/FightserverPortal.java @@ -222,11 +222,13 @@ public class FightserverPortal implements PortalHandler, Comparable name.equals("backup"))).length > 0; public EndCountdown(LobbyCountdown lobbyCountdown) { - super(EnumSet.of(GameStates.ENDING)); + super(EnumSet.of(GameStates.END)); this.lobbyCountdown = lobbyCountdown; } diff --git a/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java b/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java index 29487859..b1d25110 100644 --- a/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java +++ b/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java @@ -31,7 +31,7 @@ public class GameCountdown extends Countdown { private long startTime = 0; public GameCountdown() { - super(EnumSet.of(GameStates.INGAME)); + super(EnumSet.of(GameStates.RUNNING)); } @Override diff --git a/TowerRun/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java b/TowerRun/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java index 40808f1e..a655c4c3 100644 --- a/TowerRun/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java +++ b/TowerRun/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java @@ -37,7 +37,7 @@ public class LobbyCountdown extends Countdown { private boolean override = false; public LobbyCountdown() { - super(EnumSet.of(GameStates.LOBBY)); + super(EnumSet.of(GameStates.WAITING)); } @Override diff --git a/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java b/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java index 2d71ef1d..c83138d4 100644 --- a/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java +++ b/TowerRun/src/de/steamwar/towerrun/game/TowerRunGame.java @@ -49,7 +49,7 @@ public class TowerRunGame { } public static void prepareTowerOrStart() { - if (GameState.getCurrentState() == GameStates.LOBBY) { + if (GameState.getCurrentState() == GameStates.WAITING) { GameState.nextState(); if (TowerRun.getTowerGenerator() == null) { start(); diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index ea07eb04..9e30cf07 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -52,7 +52,7 @@ public class IngameListener extends GameStateBukkitListener { private BukkitRunnable antiCampRunnable; public IngameListener() { - super(EnumSet.of(GameStates.INGAME)); + super(EnumSet.of(GameStates.RUNNING)); } @Override diff --git a/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java b/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java index eb2cb157..52d600ca 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java @@ -37,7 +37,7 @@ import java.util.EnumSet; public class LobbyListener extends GameStateBukkitListener { public LobbyListener() { - super(EnumSet.of(GameStates.LOBBY)); + super(EnumSet.of(GameStates.WAITING)); } @EventHandler diff --git a/TowerRun/src/de/steamwar/towerrun/listener/NotLobbyListener.java b/TowerRun/src/de/steamwar/towerrun/listener/NotLobbyListener.java index 4d3525e5..6bfb1623 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/NotLobbyListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/NotLobbyListener.java @@ -31,7 +31,7 @@ import java.util.EnumSet; public class NotLobbyListener extends GameStateBukkitListener { public NotLobbyListener() { - super(EnumSet.complementOf(EnumSet.of(GameStates.LOBBY))); + super(EnumSet.complementOf(EnumSet.of(GameStates.WAITING))); } @EventHandler diff --git a/TowerRun/src/de/steamwar/towerrun/state/GameState.java b/TowerRun/src/de/steamwar/towerrun/state/GameState.java index 3c3a55e0..46b7e93a 100644 --- a/TowerRun/src/de/steamwar/towerrun/state/GameState.java +++ b/TowerRun/src/de/steamwar/towerrun/state/GameState.java @@ -28,7 +28,7 @@ import java.util.List; @UtilityClass public class GameState { @Getter - private static GameStates currentState = GameStates.LOBBY; + private static GameStates currentState = GameStates.WAITING; private static final List gameStateListeners = new ArrayList<>(); public static void addGameStateListener(GameStateListener gameStateListener) { @@ -49,7 +49,7 @@ public class GameState { public static void reset() { final GameStates oldState = currentState; - currentState = GameStates.LOBBY; + currentState = GameStates.WAITING; gameStateChanges(oldState, currentState); } diff --git a/TowerRun/src/de/steamwar/towerrun/state/GameStates.java b/TowerRun/src/de/steamwar/towerrun/state/GameStates.java index 347e9814..4fe32829 100644 --- a/TowerRun/src/de/steamwar/towerrun/state/GameStates.java +++ b/TowerRun/src/de/steamwar/towerrun/state/GameStates.java @@ -25,10 +25,10 @@ import lombok.Getter; @AllArgsConstructor @Getter public enum GameStates { - ENDING(null), - INGAME(ENDING), - GENERATING_TOWER(INGAME), - LOBBY(GENERATING_TOWER); + END(null), + RUNNING(END), + GENERATING_TOWER(RUNNING), + WAITING(GENERATING_TOWER); private final GameStates nextState; } diff --git a/TowerRun/src/de/steamwar/towerrun/winconditions/WinCondition.java b/TowerRun/src/de/steamwar/towerrun/winconditions/WinCondition.java index 4a736dd5..21e0e860 100644 --- a/TowerRun/src/de/steamwar/towerrun/winconditions/WinCondition.java +++ b/TowerRun/src/de/steamwar/towerrun/winconditions/WinCondition.java @@ -34,7 +34,7 @@ public abstract class WinCondition extends GameStateBukkitListener { private boolean active = false; protected WinCondition(String name) { - super(EnumSet.of(GameStates.INGAME)); + super(EnumSet.of(GameStates.RUNNING)); this.name = name; } From 8c0a888b3dcf184aff63fe847a45381964e37714 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Wed, 13 Nov 2024 13:32:05 +0100 Subject: [PATCH 13/14] Remove PR issues --- LobbySystem/src/de/steamwar/lobby/LobbySystem.properties | 2 +- .../src/de/steamwar/lobby/LobbySystem_de.properties | 2 +- LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java | 9 +-------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties b/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties index b1c5ccb9..2d1f31c0 100644 --- a/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties +++ b/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties @@ -8,7 +8,7 @@ NPC_CHAT_0 = §fHello, I''m {0} and I''m a(n) {1}§f. NPC_CHAT_1 = §fWelcome on §eSteam§8War§f, have fun. NPC_CHAT_2 = §eSteam§8War§f was established in 2019. NPC_CHAT_3 = &fBecome a part of our team by applying via our Discord server (https://steamwar.de/discord). -NPC_CHAT_4 = &fYou can develop your own buildserver features with our Lua script system or activate public ones via our script lybrary. +NPC_CHAT_4 = &fYou can develop your own buildserver features with our Lua script system. NPC_CHAT_5 = &fThere are many secrets to discover in this lobby. # Portal Command diff --git a/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties b/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties index 8c126add..f1c02955 100644 --- a/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties @@ -8,7 +8,7 @@ NPC_CHAT_0 = §fHallo, ich bin {0} und bin ein {1}§f. NPC_CHAT_1 = §fWillkommen auf §eSteam§8War§f, viel Spaß dir. NPC_CHAT_2 = §eSteam§8War§f gibt es seit 2019. NPC_CHAT_3 = &fBewerbe dich gerne für unser Team über unseren Discord-Server (https://steamwar.de/discord). -NPC_CHAT_4 = &fDu kannst mit unserm Lua Script-System deine eigenen Bau Features programmieren oder öffentliche Skripte über die Script-Lybrary aktivieren. +NPC_CHAT_4 = &fDu kannst mit unserm Lua Script-System deine eigenen Bau Features programmieren. NPC_CHAT_5 = &fAuf dieser Lobby sind so einige secrets versteckt. # Portal Command diff --git a/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java b/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java index 2142d6fe..5f2e55b9 100644 --- a/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java @@ -60,11 +60,6 @@ public class TeamPlayer extends BasicListener { private Set players = new HashSet<>(); private Random random = new Random(); - private List strings = new ArrayList<>(); - { - strings.add("NPC_CHAT_1"); - strings.add("NPC_CHAT_2"); - } public static void spawnTeamPlayer(World world, SteamwarUser steamwarUser) { Location location = new Location(world, 2790.5, 69, 1311.5); @@ -150,9 +145,7 @@ public class TeamPlayer extends BasicListener { return; } - int randomNum = random.nextInt(6); - String message = "NPC_Chat_" + randomNum; - + String message = "NPC_Chat_" + random.nextInt(6); SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName()); UserPerm.Prefix prefix = user.prefix(); LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), prefix.getColorCode() + prefix.getChatPrefix()); From d11597540313c28d4bca14b6df6efa34a28b5b11 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 14 Nov 2024 22:08:06 +0100 Subject: [PATCH 14/14] Add ComponentMessage, for TranslatableComponents in Paper >1.20 --- KotlinCore/build.gradle.kts | 2 + .../src/de/steamwar/kotlin/KotlinCore.kt | 2 + .../kotlin/message/ComponentMessage.kt | 36 ++++++++++++++ .../kotlin/message/LanguageListener.kt | 49 +++++++++++++++++++ settings.gradle.kts | 1 + 5 files changed, 90 insertions(+) create mode 100644 KotlinCore/src/de/steamwar/kotlin/message/ComponentMessage.kt create mode 100644 KotlinCore/src/de/steamwar/kotlin/message/LanguageListener.kt diff --git a/KotlinCore/build.gradle.kts b/KotlinCore/build.gradle.kts index 5d00f0f6..0c610074 100644 --- a/KotlinCore/build.gradle.kts +++ b/KotlinCore/build.gradle.kts @@ -32,4 +32,6 @@ tasks.shadowJar { dependencies { compileOnly(libs.paperapi21) + compileOnly(libs.nms21) + compileOnly(project(":SpigotCore")) } diff --git a/KotlinCore/src/de/steamwar/kotlin/KotlinCore.kt b/KotlinCore/src/de/steamwar/kotlin/KotlinCore.kt index e821ade4..89aa1b34 100644 --- a/KotlinCore/src/de/steamwar/kotlin/KotlinCore.kt +++ b/KotlinCore/src/de/steamwar/kotlin/KotlinCore.kt @@ -19,6 +19,7 @@ package de.steamwar.kotlin +import de.steamwar.kotlin.message.LanguageListener import org.bukkit.plugin.java.JavaPlugin class KotlinCore : JavaPlugin() { @@ -32,6 +33,7 @@ class KotlinCore : JavaPlugin() { } override fun onEnable() { + server.pluginManager.registerEvents(LanguageListener, this) } override fun onDisable() { diff --git a/KotlinCore/src/de/steamwar/kotlin/message/ComponentMessage.kt b/KotlinCore/src/de/steamwar/kotlin/message/ComponentMessage.kt new file mode 100644 index 00000000..85d41b3b --- /dev/null +++ b/KotlinCore/src/de/steamwar/kotlin/message/ComponentMessage.kt @@ -0,0 +1,36 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.kotlin.message + +import net.kyori.adventure.key.Key +import net.kyori.adventure.translation.GlobalTranslator +import net.kyori.adventure.translation.Translator +import java.text.MessageFormat +import java.util.* + +class ComponentMessage(private val resourceBundleName: String, private val classLoader: ClassLoader) : Translator { + init { + GlobalTranslator.translator().addSource(this) + } + + override fun name(): Key = Key.key("steamwar", resourceBundleName) + + override fun translate(key: String, locale: Locale): MessageFormat = MessageFormat(ResourceBundle.getBundle(resourceBundleName, locale, classLoader).getString(key), locale) +} diff --git a/KotlinCore/src/de/steamwar/kotlin/message/LanguageListener.kt b/KotlinCore/src/de/steamwar/kotlin/message/LanguageListener.kt new file mode 100644 index 00000000..0824b416 --- /dev/null +++ b/KotlinCore/src/de/steamwar/kotlin/message/LanguageListener.kt @@ -0,0 +1,49 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.kotlin.message + +import de.steamwar.kotlin.KotlinCore +import de.steamwar.sql.SteamwarUser +import org.bukkit.Bukkit +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer +import org.bukkit.event.EventHandler +import org.bukkit.event.EventPriority +import org.bukkit.event.Listener +import org.bukkit.event.player.PlayerJoinEvent +import org.bukkit.event.player.PlayerLocaleChangeEvent + +object LanguageListener: Listener { + + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) + fun onPlayerJoin(event: PlayerJoinEvent) { + val user = SteamwarUser.get(event.player.uniqueId) + val player = event.player as CraftPlayer + player.handle.`adventure$locale` = user.locale + } + + @EventHandler + fun onPlayerConfig(event: PlayerLocaleChangeEvent) { + Bukkit.getScheduler().runTask(KotlinCore.plugin, Runnable { + val user = SteamwarUser.get(event.player.uniqueId) + val player = event.player as CraftPlayer + player.handle.`adventure$locale` = user.locale + }) + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 2379d8bd..a13a1974 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -130,6 +130,7 @@ dependencyResolutionManagement { library("nms18", "de.steamwar:spigot:1.18") library("nms19", "de.steamwar:spigot:1.19") library("nms20", "de.steamwar:spigot:1.20") + library("nms21", "de.steamwar:spigot:1.21") library("axiom", "de.steamwar:axiompaper:RELEASE") library("worldedit12", "de.steamwar:worldedit:1.12")