From ca589bd07c57b44a1332ce7650c8d995a5e2b25c Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 29 Sep 2025 10:17:49 +0200 Subject: [PATCH 01/11] Add Linkage to CommonCore and implement SpigotLinker used in BauSystem --- .../src/de/steamwar/bausystem/BauSystem.java | 160 ++++-------------- .../features/bau/BauInfoBauGuiItem.java | 1 - .../features/loadtimer/LoadtimerListener.java | 1 - .../features/region/ColorCommand.java | 2 - .../region/RegionScoreboardElement.java | 3 - .../features/script/event/EventListener.java | 2 - .../features/techhider/TechHiderCommand.java | 4 - .../util/items/NightVisionBauGuiItem.java | 1 - .../linkage/specific/ScoreboardItem.java | 37 ---- CommonCore/Linkage/build.gradle.kts | 26 +++ .../de/steamwar/linkage/AbstractLinker.java | 152 +++++++++++++++++ .../src/de/steamwar/linkage/Linked.java | 0 .../de/steamwar/linkage/LinkedInstance.java | 0 .../src/de/steamwar/linkage/MaxVersion.java | 0 .../src/de/steamwar/linkage/MinVersion.java | 0 .../src/de/steamwar/linkage/PluginCheck.java | 0 .../src/de/steamwar/linkage/api/Disable.java | 0 .../src/de/steamwar/linkage/api/Enable.java | 0 CommonCore/build.gradle.kts | 1 + .../src/de/steamwar/linkage/SpigotLinker.java | 82 +++++++++ settings.gradle.kts | 3 +- 21 files changed, 297 insertions(+), 178 deletions(-) delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/linkage/specific/ScoreboardItem.java create mode 100644 CommonCore/Linkage/build.gradle.kts create mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java rename {BauSystem/BauSystem_Main => CommonCore/Linkage}/src/de/steamwar/linkage/Linked.java (100%) rename {BauSystem/BauSystem_Main => CommonCore/Linkage}/src/de/steamwar/linkage/LinkedInstance.java (100%) rename {BauSystem/BauSystem_Main => CommonCore/Linkage}/src/de/steamwar/linkage/MaxVersion.java (100%) rename {BauSystem/BauSystem_Main => CommonCore/Linkage}/src/de/steamwar/linkage/MinVersion.java (100%) rename {BauSystem/BauSystem_Main => CommonCore/Linkage}/src/de/steamwar/linkage/PluginCheck.java (100%) rename {BauSystem/BauSystem_Main => CommonCore/Linkage}/src/de/steamwar/linkage/api/Disable.java (100%) rename {BauSystem/BauSystem_Main => CommonCore/Linkage}/src/de/steamwar/linkage/api/Enable.java (100%) create mode 100644 SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index af84b780..4d473261 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -38,41 +38,29 @@ import de.steamwar.bausystem.utils.TickListener; import de.steamwar.bausystem.utils.TickManager; import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.command.AbstractValidator; -import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.core.CRIUSleepEvent; -import de.steamwar.core.Core; import de.steamwar.core.WorldEditRendererCUIEditor; -import de.steamwar.linkage.LinkedInstance; -import de.steamwar.linkage.MaxVersion; -import de.steamwar.linkage.MinVersion; -import de.steamwar.linkage.PluginCheck; -import de.steamwar.linkage.api.Disable; -import de.steamwar.linkage.api.Enable; +import de.steamwar.linkage.AbstractLinker; +import de.steamwar.linkage.SpigotLinker; import de.steamwar.message.Message; -import de.steamwar.network.packets.PacketHandler; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import java.io.*; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.logging.Level; -import java.util.stream.Collectors; public class BauSystem extends JavaPlugin implements Listener { @@ -83,7 +71,7 @@ public class BauSystem extends JavaPlugin implements Listener { @Getter private static BauSystem instance; - private final Map, Object> instances = new HashMap<>(); + private SpigotLinker linker; @Override public void onEnable() { @@ -96,115 +84,43 @@ public class BauSystem extends JavaPlugin implements Listener { SWUtils.setBausystem(instance); RegionSystem.INSTANCE.load(); - /* - try { - PrototypeLoader.load(); - RegionLoader.load(); - } catch (SecurityException e) { - Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); - Bukkit.shutdown(); - System.exit(1); - return; - } - - new Updater(PrototypeLoader.file, PrototypeLoader::load); - new Updater(RegionLoader.file, RegionLoader::load); - */ SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD)); SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD)); SWCommandUtils.addValidator("supervisor", validator(Permission.SUPERVISOR)); SWCommandUtils.addValidator("owner", validator(Permission.OWNER)); - instances.put(BauServer.class, BauServer.getInstance()); - List> classes = new BufferedReader(new InputStreamReader(BauSystem.class.getResourceAsStream("/META-INF/annotations/de.steamwar.linkage.Linked"))) - .lines() - .map(s -> { - try { - return Class.forName(s, false, BauSystem.class.getClassLoader()); - } catch (ClassNotFoundException | NoClassDefFoundError e) { - if (e.getMessage().equals(s)) { - Bukkit.shutdown(); - throw new SecurityException(e.getMessage(), e); - } - return null; - } - }) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - classes.forEach(clazz -> { - MinVersion minVersion = clazz.getAnnotation(MinVersion.class); - MaxVersion maxVersion = clazz.getAnnotation(MaxVersion.class); - PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class); - if (minVersion != null && Core.getVersion() < minVersion.value()) { - return; - } - if (maxVersion != null && Core.getVersion() > maxVersion.value()) { - return; - } - for (PluginCheck pluginCheck : pluginChecks) { - if (pluginCheck.has() == PluginCheck.Has.THIS && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) != null) { - continue; + linker = new SpigotLinker(BauSystem.getInstance(), BauSystem.MESSAGE) { + @Override + protected void linkObject(Object any) { + super.linkObject(any); + if (any instanceof LuaLib) { + SteamWarLuaPlugin.add((LuaLib) any); } - if (pluginCheck.has() == PluginCheck.Has.NOT && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) == null) { - continue; + if (any instanceof ScoreboardElement) { + BauScoreboard.addElement((ScoreboardElement) any); } - return; - } - - Object any; - try { - any = clazz.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - getLogger().log(Level.SEVERE, e.getMessage(), e); - Bukkit.shutdown(); - throw new SecurityException(e.getMessage()); - } - - instances.put(clazz, any); - if (any instanceof Enable) { - ((Enable) any).enable(); - } - if (any instanceof SWCommand) { - ((SWCommand) any).setMessage(BauSystem.MESSAGE); - } - if (any instanceof Listener) { - Bukkit.getPluginManager().registerEvents((Listener) any, BauSystem.getInstance()); - } - if (any instanceof PacketHandler) { - ((PacketHandler) any).register(); - } - if (any instanceof LuaLib) { - SteamWarLuaPlugin.add((LuaLib) any); - } - if (any instanceof ScoreboardElement) { - BauScoreboard.addElement((ScoreboardElement) any); - } - if (any instanceof BauGuiItem) { - BauGUI.addItem((BauGuiItem) any); - } - if (any instanceof PanzernAlgorithm) { - Panzern.add((PanzernAlgorithm) any); - } - if (any instanceof ConfigConverter) { - Config.addConfigConverter((ConfigConverter) any); - } - if (any instanceof BoundingBoxLoader) { - ((BoundingBoxLoader) any).load(); - } - }); - - instances.forEach((clazz, o) -> { - for (Field field : clazz.getFields()) { - if (field.getAnnotation(LinkedInstance.class) != null) { - try { - field.set(o, instances.get(field.getType())); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } + if (any instanceof BauGuiItem) { + BauGUI.addItem((BauGuiItem) any); + } + if (any instanceof PanzernAlgorithm) { + Panzern.add((PanzernAlgorithm) any); + } + if (any instanceof ConfigConverter) { + Config.addConfigConverter((ConfigConverter) any); + } + if (any instanceof BoundingBoxLoader) { + ((BoundingBoxLoader) any).load(); } } - }); + }; + try { + linker.addLinkableInstance(BauServer.getInstance()); + linker.link(); + } catch (AbstractLinker.LinkException e) { + getLogger().log(Level.SEVERE, "Could not link a class.", e); + Bukkit.shutdown(); + } TickListener.impl.init(); @@ -221,15 +137,7 @@ public class BauSystem extends JavaPlugin implements Listener { @Override public void onDisable() { - instances.forEach((aClass, o) -> { - if (o instanceof Listener) { - HandlerList.unregisterAll((Listener) o); - } - if (o instanceof Disable) { - ((Disable) o).disable(); - } - }); - + linker.unlink(); WorldData.write(); RegionSystem.INSTANCE.save(); Config.getInstance().saveAll(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java index 8a3cffb4..6553f44a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java @@ -26,7 +26,6 @@ import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.FlagOptional; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.core.Core; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerListener.java index c528b9ad..d9cf2118 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerListener.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.region.Region; import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.linkage.Linked; import org.bukkit.Material; -import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java index 6c086ded..4b03cf8a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java @@ -25,8 +25,6 @@ import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java index b810bb1e..9164040f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java @@ -23,12 +23,9 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -import java.io.File; import java.util.List; -import java.util.Optional; @Linked public class RegionScoreboardElement implements ScoreboardElement { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java index 54ddac4e..33946536 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java @@ -25,8 +25,6 @@ import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin; import de.steamwar.bausystem.features.script.lua.libs.StorageLib; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java index 5f205e79..91a3d3a0 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java @@ -34,16 +34,12 @@ import de.steamwar.linkage.LinkedInstance; import de.steamwar.techhider.TechHider; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.command.CommandSender; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import java.io.File; import java.util.*; import java.util.stream.Collectors; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java index 03ebb495..fb73dd8b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java @@ -28,7 +28,6 @@ import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionEffectType; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/linkage/specific/ScoreboardItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/linkage/specific/ScoreboardItem.java deleted file mode 100644 index 6a5dad27..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/linkage/specific/ScoreboardItem.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 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.bausystem.linkage.specific; - -import de.steamwar.bausystem.region.Region; -import org.bukkit.entity.Player; - -public interface ScoreboardItem { - - /** - * Returns one Scoreboard line. If {@code null} result will be ignored. - * If return value contains {@code '?'} it will be replaced to the color - * code of the current {@link Region}. - * - * @param player the player to create the scoreboard line for - * @param region the region the player is in - * @return the String to send, can be {@code null} - */ - String getString(Player player, Region region); -} diff --git a/CommonCore/Linkage/build.gradle.kts b/CommonCore/Linkage/build.gradle.kts new file mode 100644 index 00000000..dd139c6b --- /dev/null +++ b/CommonCore/Linkage/build.gradle.kts @@ -0,0 +1,26 @@ +/* + * 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 . + */ + +plugins { + steamwar.java +} + +dependencies { + compileOnly(libs.classindex) +} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java new file mode 100644 index 00000000..ab401aa2 --- /dev/null +++ b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java @@ -0,0 +1,152 @@ +/* + * 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.linkage; + +import de.steamwar.linkage.api.Disable; +import de.steamwar.linkage.api.Enable; +import lombok.NonNull; +import lombok.experimental.StandardException; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +public abstract class AbstractLinker { + + protected final T plugin; + private Map, Object> instances = new HashMap<>(); + + protected AbstractLinker(@NonNull T plugin) { + this.plugin = plugin; + instances.put(plugin.getClass(), plugin); + } + + @StandardException + public static class LinkException extends Exception { + } + + public final void link() throws LinkException { + List> classes; + try { + classes = new BufferedReader(new InputStreamReader(plugin.getClass().getResourceAsStream("/META-INF/annotations/de.steamwar.linkage.Linked"))) + .lines() + .map(s -> { + try { + return Class.forName(s, false, plugin.getClass().getClassLoader()); + } catch (ClassNotFoundException | NoClassDefFoundError e) { + throw new SecurityException(e.getMessage(), e); + } + }) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + } catch (SecurityException e) { + Throwable cause = e.getCause(); + throw new LinkException(cause.getMessage(), cause); + } + + try { + classes.forEach(clazz -> { + MinVersion minVersion = clazz.getAnnotation(MinVersion.class); + MaxVersion maxVersion = clazz.getAnnotation(MaxVersion.class); + if (!versionCheck(clazz, minVersion, maxVersion)) return; + PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class); + for (PluginCheck pluginCheck : pluginChecks) { + if (!pluginCheck(clazz, pluginCheck)) return; + } + + Object any; + try { + any = clazz.newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + throw new SecurityException(e.getMessage()); + } + instances.put(clazz, any); + + if (any instanceof Enable) { + ((Enable) any).enable(); + } + linkObject(any); + }); + } catch (SecurityException e) { + Throwable cause = e.getCause(); + throw new LinkException(cause.getMessage(), cause); + } + + try { + instances.forEach((clazz, o) -> { + for (Field field : clazz.getFields()) { + if (field.getAnnotation(LinkedInstance.class) != null) { + System.out.println("Setting " + field.getName() + " to " + instances.get(field.getType())); + try { + field.set(o, instances.get(field.getType())); + } catch (IllegalAccessException e) { + throw new SecurityException(e); + } + } + } + }); + } catch (SecurityException e) { + Throwable cause = e.getCause(); + throw new LinkException(cause.getMessage(), cause); + } + } + + public final void unlink() { + instances.forEach((aClass, any) -> { + unlinkObject(any); + if (any instanceof Disable) { + ((Disable) any).disable(); + } + }); + } + + public final void addLinkableInstance(@NonNull Object instance) { + instances.put(instance.getClass(), instance); + } + + /** + * @return {@code true} if the clazz passes the checks {@code false} otherwise + */ + protected boolean versionCheck(@NonNull Class clazz, MinVersion minVersion, MaxVersion maxVersion) { + return true; + } + + /** + * @return {@code true} if the clazz passes the checks {@code false} otherwise + */ + protected boolean pluginCheck(@NonNull Class clazz, PluginCheck pluginCheck) { + return true; + } + + /** + * There is no need in calling {@link Enable#enable()} by this method. + */ + protected abstract void linkObject(Object any); + + /** + * There is no need in calling {@link Disable#disable()} ()} by this method. + */ + protected abstract void unlinkObject(Object any); +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/linkage/Linked.java b/CommonCore/Linkage/src/de/steamwar/linkage/Linked.java similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/linkage/Linked.java rename to CommonCore/Linkage/src/de/steamwar/linkage/Linked.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/linkage/LinkedInstance.java b/CommonCore/Linkage/src/de/steamwar/linkage/LinkedInstance.java similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/linkage/LinkedInstance.java rename to CommonCore/Linkage/src/de/steamwar/linkage/LinkedInstance.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/linkage/MaxVersion.java b/CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/linkage/MaxVersion.java rename to CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/linkage/MinVersion.java b/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/linkage/MinVersion.java rename to CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/linkage/PluginCheck.java b/CommonCore/Linkage/src/de/steamwar/linkage/PluginCheck.java similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/linkage/PluginCheck.java rename to CommonCore/Linkage/src/de/steamwar/linkage/PluginCheck.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Disable.java b/CommonCore/Linkage/src/de/steamwar/linkage/api/Disable.java similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Disable.java rename to CommonCore/Linkage/src/de/steamwar/linkage/api/Disable.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Enable.java b/CommonCore/Linkage/src/de/steamwar/linkage/api/Enable.java similarity index 100% rename from BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Enable.java rename to CommonCore/Linkage/src/de/steamwar/linkage/api/Enable.java diff --git a/CommonCore/build.gradle.kts b/CommonCore/build.gradle.kts index 8e2df2bc..7105676f 100644 --- a/CommonCore/build.gradle.kts +++ b/CommonCore/build.gradle.kts @@ -25,4 +25,5 @@ dependencies { api(project(":CommonCore:SQL")) api(project(":CommonCore:Network")) api(project(":CommonCore:Data")) + api(project(":CommonCore:Linkage")) } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java new file mode 100644 index 00000000..35abb954 --- /dev/null +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java @@ -0,0 +1,82 @@ +/* + * 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.linkage; + +import de.steamwar.command.SWCommand; +import de.steamwar.core.Core; +import de.steamwar.message.Message; +import de.steamwar.network.packets.PacketHandler; +import lombok.NonNull; +import org.bukkit.Bukkit; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; + +public class SpigotLinker extends AbstractLinker { + + private final Message message; + + public SpigotLinker(@NonNull JavaPlugin plugin, Message message) { + super(plugin); + this.message = message; + } + + @Override + protected boolean versionCheck(@NonNull Class clazz, MinVersion minVersion, MaxVersion maxVersion) { + if (minVersion != null && Core.getVersion() < minVersion.value()) { + return false; + } + if (maxVersion != null && Core.getVersion() > maxVersion.value()) { + return false; + } + return true; + } + + @Override + protected boolean pluginCheck(@NonNull Class clazz, PluginCheck pluginCheck) { + if (pluginCheck.has() == PluginCheck.Has.THIS && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) != null) { + return true; + } + if (pluginCheck.has() == PluginCheck.Has.NOT && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) == null) { + return true; + } + return false; + } + + @Override + protected void linkObject(Object any) { + if (any instanceof SWCommand) { + ((SWCommand) any).setMessage(message); + } + if (any instanceof Listener) { + Bukkit.getPluginManager().registerEvents((Listener) any, plugin); + } + if (any instanceof PacketHandler) { + ((PacketHandler) any).register(); + } + } + + @Override + protected void unlinkObject(Object any) { + if (any instanceof Listener) { + HandlerList.unregisterAll((Listener) any); + } + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 3bb2a9d8..7be8fc09 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -187,7 +187,8 @@ include( "CommonCore", "CommonCore:Data", "CommonCore:SQL", - "CommonCore:Network" + "CommonCore:Network", + "CommonCore:Linkage" ) include( From d850894a003d00e8c4eaa8fefc994951edb3ad5c Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 29 Sep 2025 15:26:26 +0200 Subject: [PATCH 02/11] Update VelocityCore to use Linkage --- .../de/steamwar/linkage/AbstractLinker.java | 15 ++- .../src/de/steamwar/linkage/EventMode.java | 31 +++++ .../de/steamwar/velocitycore/Broadcaster.java | 6 +- .../steamwar/velocitycore/EventStarter.java | 2 + .../steamwar/velocitycore/VelocityCore.java | 110 ++++-------------- .../velocitycore/commands/AlertCommand.java | 2 + .../velocitycore/commands/ArenaCommand.java | 2 + .../velocitycore/commands/BauCommand.java | 8 +- .../velocitycore/commands/BugCommand.java | 7 +- .../commands/BuilderCloudCommand.java | 2 + .../commands/ChallengeCommand.java | 4 + .../velocitycore/commands/CheckCommand.java | 2 + .../velocitycore/commands/DevCommand.java | 2 + .../velocitycore/commands/EventCommand.java | 2 + .../commands/EventRescheduleCommand.java | 2 + .../commands/EventreloadCommand.java | 2 + .../velocitycore/commands/FightCommand.java | 4 + .../velocitycore/commands/GDPRQuery.java | 2 + .../velocitycore/commands/HelpCommand.java | 2 + .../commands/HistoricCommand.java | 4 + .../velocitycore/commands/IgnoreCommand.java | 2 + .../velocitycore/commands/JoinmeCommand.java | 2 + .../velocitycore/commands/KickCommand.java | 2 + .../velocitycore/commands/ListCommand.java | 2 + .../velocitycore/commands/LocalCommand.java | 2 + .../velocitycore/commands/ModCommand.java | 2 + .../velocitycore/commands/MsgCommand.java | 7 +- .../velocitycore/commands/PingCommand.java | 2 + .../commands/PlaytimeCommand.java | 2 + .../velocitycore/commands/PollCommand.java | 2 + .../commands/PollresultCommand.java | 2 + .../velocitycore/commands/RCommand.java | 2 + .../velocitycore/commands/RankCommand.java | 2 + .../velocitycore/commands/ReplayCommand.java | 4 + .../velocitycore/commands/RulesCommand.java | 2 + .../velocitycore/commands/SendCommand.java | 2 + .../commands/ServerTeamchatCommand.java | 2 + .../commands/SetLocaleCommand.java | 2 + .../velocitycore/commands/StatCommand.java | 2 + .../commands/StreamingCommand.java | 4 + .../velocitycore/commands/TeamCommand.java | 2 + .../commands/TeamchatCommand.java | 2 + .../velocitycore/commands/TpCommand.java | 2 + .../commands/UnIgnoreCommand.java | 2 + .../velocitycore/commands/VerifyCommand.java | 2 + .../commands/WebpasswordCommand.java | 4 + .../velocitycore/commands/WhoisCommand.java | 3 +- .../velocitycore/listeners/BanListener.java | 2 + .../velocitycore/listeners/ChatListener.java | 2 + .../velocitycore/listeners/CheckListener.java | 2 + .../listeners/ConnectionListener.java | 2 + .../velocitycore/listeners/CookieEvents.java | 4 + .../listeners/EventModeListener.java | 18 ++- .../velocitycore/listeners/IPSanitizer.java | 2 + .../velocitycore/listeners/PluginMessage.java | 2 + .../listeners/SessionManager.java | 2 + .../listeners/SettingsChangedListener.java | 2 + .../listeners/TexturePackSystem.java | 2 + .../listeners/VersionAnnouncer.java | 2 + .../steamwar/velocitycore/mods/Badlion.java | 2 + .../de/steamwar/velocitycore/mods/FML2.java | 2 + .../velocitycore/mods/FabricModSender.java | 2 + .../steamwar/velocitycore/mods/Hostname.java | 2 + .../steamwar/velocitycore/mods/ReplayMod.java | 2 + .../velocitycore/mods/Schematica.java | 2 + .../network/handlers/AnvilAnswerHandler.java | 2 + .../network/handlers/EloPlayerHandler.java | 3 + .../network/handlers/EloSchemHandler.java | 2 + .../handlers/ExecuteCommandHandler.java | 2 + .../network/handlers/FightInfoHandler.java | 2 + .../network/handlers/ImALobbyHandler.java | 2 + .../handlers/InventoryCallbackHandler.java | 2 + .../network/handlers/PlayerSkinHandler.java | 2 + .../network/handlers/PrepareSchemHandler.java | 2 + .../velocitycore/tablist/TablistManager.java | 5 +- 75 files changed, 246 insertions(+), 109 deletions(-) create mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/EventMode.java diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java index ab401aa2..2c013f76 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java @@ -71,6 +71,8 @@ public abstract class AbstractLinker { MinVersion minVersion = clazz.getAnnotation(MinVersion.class); MaxVersion maxVersion = clazz.getAnnotation(MaxVersion.class); if (!versionCheck(clazz, minVersion, maxVersion)) return; + EventMode eventMode = clazz.getAnnotation(EventMode.class); + if (!eventModeCheck(clazz, eventMode)) return; PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class); for (PluginCheck pluginCheck : pluginChecks) { if (!pluginCheck(clazz, pluginCheck)) return; @@ -140,13 +142,22 @@ public abstract class AbstractLinker { return true; } + /** + * @return {@code true} if the clazz passes the checks {@code false} otherwise + */ + protected boolean eventModeCheck(@NonNull Class clazz, EventMode eventMode) { + return true; + } + /** * There is no need in calling {@link Enable#enable()} by this method. */ - protected abstract void linkObject(Object any); + protected void linkObject(Object any) { + } /** * There is no need in calling {@link Disable#disable()} ()} by this method. */ - protected abstract void unlinkObject(Object any); + protected void unlinkObject(Object any) { + } } diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/EventMode.java b/CommonCore/Linkage/src/de/steamwar/linkage/EventMode.java new file mode 100644 index 00000000..513982aa --- /dev/null +++ b/CommonCore/Linkage/src/de/steamwar/linkage/EventMode.java @@ -0,0 +1,31 @@ +/* + * 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.linkage; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface EventMode { + boolean value(); +} diff --git a/VelocityCore/src/de/steamwar/velocitycore/Broadcaster.java b/VelocityCore/src/de/steamwar/velocitycore/Broadcaster.java index f5df6d10..f5a05b7f 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/Broadcaster.java +++ b/VelocityCore/src/de/steamwar/velocitycore/Broadcaster.java @@ -19,17 +19,21 @@ package de.steamwar.velocitycore; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import java.util.List; import java.util.concurrent.TimeUnit; +@Linked +@EventMode(false) class Broadcaster { private final List broadcasts = VelocityCore.get().getConfig().getBroadcasts(); private int lastBroadCast = 0; - Broadcaster() { + public Broadcaster() { if(!broadcasts.isEmpty()) VelocityCore.schedule(this::broadcast).repeat(10, TimeUnit.MINUTES).schedule(); } diff --git a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java index 2a5f85f7..6401ec30 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java +++ b/VelocityCore/src/de/steamwar/velocitycore/EventStarter.java @@ -19,6 +19,7 @@ package de.steamwar.velocitycore; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.persistent.Subserver; @@ -36,6 +37,7 @@ import java.util.concurrent.TimeUnit; import static de.steamwar.persistent.Storage.eventServer; +@Linked public class EventStarter { @Getter diff --git a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java index d5ae82e9..58a9033c 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java +++ b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java @@ -29,22 +29,24 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.scheduler.Scheduler; import de.steamwar.command.*; +import de.steamwar.linkage.AbstractLinker; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.LinkedInstance; import de.steamwar.messages.Chatter; -import de.steamwar.network.packets.PacketHandler; import de.steamwar.persistent.ReloadablePlugin; import de.steamwar.sql.Punishment; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; import de.steamwar.sql.UserElo; import de.steamwar.sql.internal.Statement; -import de.steamwar.velocitycore.commands.*; +import de.steamwar.velocitycore.commands.PunishmentCommand; +import de.steamwar.velocitycore.commands.ServerSwitchCommand; +import de.steamwar.velocitycore.commands.TeamCommand; import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.velocitycore.discord.DiscordConfig; -import de.steamwar.velocitycore.listeners.*; -import de.steamwar.velocitycore.mods.*; -import de.steamwar.velocitycore.network.handlers.*; -import de.steamwar.velocitycore.tablist.TablistManager; +import de.steamwar.velocitycore.listeners.PollSystem; import lombok.Getter; +import lombok.NonNull; import java.nio.file.Path; import java.sql.Driver; @@ -94,9 +96,9 @@ public class VelocityCore implements ReloadablePlugin { @Getter private Config config; private ErrorLogger errorLogger; - private TablistManager tablistManager; @Getter + @LinkedInstance private TeamCommand teamCommand; @Inject @@ -104,9 +106,10 @@ public class VelocityCore implements ReloadablePlugin { this.proxyServer = proxyServer; this.logger = logger; this.dataDirectory = dataDirectory; - } + private AbstractLinker linker; + @Subscribe @Override public void onProxyInitialization(ProxyInitializeEvent event) { @@ -139,64 +142,11 @@ public class VelocityCore implements ReloadablePlugin { initStaticServers(); PollSystem.init(); - new Hostname(); - new PluginMessage(); - new Schematica(); - new Badlion(); - new FabricModSender(); - new ReplayMod(); - new FML2(); - - new ConnectionListener(); - new ChatListener(); - new BanListener(); - new CheckListener(); - new IPSanitizer(); - new VersionAnnouncer(); - new TexturePackSystem(); - local = new Node.LocalNode(); if(MAIN_SERVER) { //new Node.RemoteNode("lx"); } - new TeamchatCommand(); - new MsgCommand(); - new RCommand(); - new PingCommand(); - new AlertCommand(); - new KickCommand(); - new JoinmeCommand(); - new TpCommand(); - HelpCommand helpCommand = new HelpCommand(); - teamCommand = new TeamCommand(); - new ServerTeamchatCommand(); - new DevCommand(); - new SendCommand(); - new EventCommand(); - new EventreloadCommand(); - new EventRescheduleCommand(); - new PollCommand(); - new BugCommand(); - new WhoisCommand(); - new RulesCommand(); - new IgnoreCommand(); - new UnIgnoreCommand(); - new PollresultCommand(); - new ListCommand(); - new StatCommand(); - new VerifyCommand(); - new GDPRQuery(); - new PlaytimeCommand(); - new ArenaCommand(); - new RankCommand(); - new LocalCommand(); - new SetLocaleCommand(); - new BuilderCloudCommand(); - new CheckCommand(); - - new ModCommand(); - // Punishment Commands: new PunishmentCommand("ban", Punishment.PunishmentType.Ban); new PunishmentCommand("mute", Punishment.PunishmentType.Mute); @@ -208,32 +158,19 @@ public class VelocityCore implements ReloadablePlugin { new PunishmentCommand("noteamserver", Punishment.PunishmentType.NoTeamServer); new PunishmentCommand("note", Punishment.PunishmentType.Note); - if(!config.isEventmode()){ - new BauCommand(helpCommand); - new WebpasswordCommand(); - new FightCommand(); - new ChallengeCommand(); - new HistoricCommand(); - new ReplayCommand(); - - new Broadcaster(); - new CookieEvents(); - new StreamingCommand(); - }else{ - new EventModeListener(); + linker = new AbstractLinker<>(this) { + @Override + protected boolean eventModeCheck(@NonNull Class clazz, EventMode eventMode) { + return eventMode == null || eventMode.value() == config.isEventmode(); + } + }; + try { + linker.link(); + } catch (AbstractLinker.LinkException e) { + VelocityCore.getProxy().shutdown(); + return; } - for(PacketHandler handler : new PacketHandler[] { - new EloPlayerHandler(), new EloSchemHandler(), new ExecuteCommandHandler(), new FightInfoHandler(), - new ImALobbyHandler(), new InventoryCallbackHandler(), new PrepareSchemHandler(), new PlayerSkinHandler(), new AnvilAnswerHandler() - }) - handler.register(); - - new EventStarter(); - new SessionManager(); - tablistManager = new TablistManager(); - new SettingsChangedListener(); - schedule(() -> { SteamwarUser.clear(); UserElo.clear(); @@ -269,8 +206,7 @@ public class VelocityCore implements ReloadablePlugin { logger.log(Level.SEVERE, "Could not shutdown discord bot", e); } - if(tablistManager != null) - tablistManager.disable(); + linker.unlink(); errorLogger.unregister(); Statement.closeAll(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/AlertCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/AlertCommand.java index b95bbd69..b1fed2f1 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/AlertCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/AlertCommand.java @@ -19,11 +19,13 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.command.SWCommand; import de.steamwar.messages.Chatter; import de.steamwar.sql.UserPerm; +@Linked public class AlertCommand extends SWCommand { public AlertCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/ArenaCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/ArenaCommand.java index cee6cb04..c7d19a39 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/ArenaCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/ArenaCommand.java @@ -23,6 +23,7 @@ import com.velocitypowered.api.proxy.server.RegisteredServer; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.PlayerChatter; import de.steamwar.persistent.Subserver; @@ -31,6 +32,7 @@ import de.steamwar.velocitycore.VelocityCore; import java.util.Collection; import java.util.List; +@Linked public class ArenaCommand extends SWCommand { public ArenaCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java index 9b24434d..139524a0 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java @@ -19,6 +19,9 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import de.steamwar.velocitycore.*; import de.steamwar.velocitycore.inventory.SWInventory; import de.steamwar.velocitycore.inventory.SWItem; @@ -40,9 +43,12 @@ import de.steamwar.sql.SteamwarUser; import java.util.Collection; import java.util.function.Consumer; +@Linked +@EventMode(false) public class BauCommand extends SWCommand { - private final HelpCommand command; + @LinkedInstance + private HelpCommand command; public BauCommand(HelpCommand command) { super("bau", "b", "build", "gs"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/BugCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/BugCommand.java index 088acb09..3a89640c 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/BugCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/BugCommand.java @@ -19,12 +19,13 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; +import de.steamwar.messages.Chatter; import de.steamwar.persistent.Subserver; import de.steamwar.sql.SWException; -import de.steamwar.command.SWCommand; -import de.steamwar.messages.Chatter; -import de.steamwar.velocitycore.SubserverSystem; +@Linked public class BugCommand extends SWCommand { public BugCommand() { super("bug"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java index 51c0f1bf..766268f5 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java @@ -19,6 +19,7 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.ArenaMode; import de.steamwar.velocitycore.ServerStarter; import de.steamwar.velocitycore.ServerVersion; @@ -37,6 +38,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +@Linked public class BuilderCloudCommand extends SWCommand { public BuilderCloudCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/ChallengeCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/ChallengeCommand.java index 78ced8d1..9e5fc81c 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/ChallengeCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/ChallengeCommand.java @@ -22,6 +22,8 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.messages.PlayerChatter; @@ -35,6 +37,8 @@ import java.util.LinkedList; import static de.steamwar.persistent.Storage.challenges; +@Linked +@EventMode(false) public class ChallengeCommand extends SWCommand { public ChallengeCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java index 8d618600..864187f4 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java @@ -21,6 +21,7 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.messages.PlayerChatter; @@ -44,6 +45,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.BooleanSupplier; import java.util.logging.Level; +@Linked public class CheckCommand extends SWCommand { private static final Map fightTypes = new HashMap<>(); private static final Map> checkQuestions = new HashMap<>(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/DevCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/DevCommand.java index 39703e36..077c663f 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/DevCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/DevCommand.java @@ -27,6 +27,7 @@ import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.messages.PlayerChatter; @@ -43,6 +44,7 @@ import java.net.InetSocketAddress; import java.util.HashMap; import java.util.Map; +@Linked public class DevCommand extends SWCommand { private final File devServerDir = new File("/configs/DevServer"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java index b57d6aad..27d85a86 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java @@ -23,6 +23,7 @@ import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.PlayerChatter; import de.steamwar.persistent.Subserver; @@ -37,6 +38,7 @@ import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; +@Linked public class EventCommand extends SWCommand { public EventCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/EventRescheduleCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/EventRescheduleCommand.java index 9660eba4..857a5060 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/EventRescheduleCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/EventRescheduleCommand.java @@ -21,6 +21,7 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.sql.Event; import de.steamwar.sql.EventFight; @@ -32,6 +33,7 @@ import java.util.Date; import java.util.List; import java.util.ListIterator; +@Linked public class EventRescheduleCommand extends SWCommand { public EventRescheduleCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/EventreloadCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/EventreloadCommand.java index 45aa61b8..64e350b9 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/EventreloadCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/EventreloadCommand.java @@ -20,10 +20,12 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.sql.EventFight; import de.steamwar.sql.UserPerm; +@Linked public class EventreloadCommand extends SWCommand { public EventreloadCommand() { super("eventreload", UserPerm.MODERATION); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java index ee82988c..39d9beea 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/FightCommand.java @@ -21,6 +21,8 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.messages.PlayerChatter; @@ -36,6 +38,8 @@ import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; +@Linked +@EventMode(false) public class FightCommand extends SWCommand { public FightCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/GDPRQuery.java b/VelocityCore/src/de/steamwar/velocitycore/commands/GDPRQuery.java index e54a7ffa..32c9b1ec 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/GDPRQuery.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/GDPRQuery.java @@ -19,6 +19,7 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.command.SWCommand; import de.steamwar.messages.Chatter; @@ -31,6 +32,7 @@ import java.io.*; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +@Linked public class GDPRQuery extends SWCommand { public GDPRQuery() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/HelpCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/HelpCommand.java index 33e595d0..bdcfa73f 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/HelpCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/HelpCommand.java @@ -20,12 +20,14 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import net.kyori.adventure.text.event.ClickEvent; import java.util.function.Function; +@Linked public class HelpCommand extends SWCommand { public HelpCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/HistoricCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/HistoricCommand.java index 395eff33..dee2cb40 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/HistoricCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/HistoricCommand.java @@ -20,6 +20,8 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.messages.PlayerChatter; @@ -27,6 +29,8 @@ import de.steamwar.velocitycore.ArenaMode; import de.steamwar.velocitycore.ServerStarter; import net.kyori.adventure.text.event.ClickEvent; +@Linked +@EventMode(false) public class HistoricCommand extends SWCommand { public HistoricCommand() { super("historic"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/IgnoreCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/IgnoreCommand.java index 684ab5a6..c6165cd0 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/IgnoreCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/IgnoreCommand.java @@ -20,10 +20,12 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.sql.IgnoreSystem; import de.steamwar.sql.SteamwarUser; +@Linked public class IgnoreCommand extends SWCommand { public IgnoreCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/JoinmeCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/JoinmeCommand.java index 4bab8d11..508b18f1 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/JoinmeCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/JoinmeCommand.java @@ -20,12 +20,14 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.messages.PlayerChatter; import de.steamwar.sql.UserPerm; import net.kyori.adventure.text.event.ClickEvent; +@Linked public class JoinmeCommand extends SWCommand { public JoinmeCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/KickCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/KickCommand.java index 4bbd8bef..b0d93bb0 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/KickCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/KickCommand.java @@ -21,9 +21,11 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.sql.UserPerm; +@Linked public class KickCommand extends SWCommand { public KickCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/ListCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/ListCommand.java index dab59005..f57df245 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/ListCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/ListCommand.java @@ -22,6 +22,7 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ServerConnection; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.persistent.Subserver; import de.steamwar.velocitycore.VelocityCore; @@ -32,6 +33,7 @@ import java.util.SortedMap; import java.util.TreeMap; import java.util.stream.Collectors; +@Linked public class ListCommand extends SWCommand { public ListCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/LocalCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/LocalCommand.java index d53afdb7..4ede8e76 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/LocalCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/LocalCommand.java @@ -19,10 +19,12 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.listeners.ChatListener; import de.steamwar.command.SWCommand; import de.steamwar.messages.PlayerChatter; +@Linked public class LocalCommand extends SWCommand { public LocalCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/ModCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/ModCommand.java index c37a3e7c..220bac58 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/ModCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/ModCommand.java @@ -19,6 +19,7 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.inventory.SWInventory; import de.steamwar.velocitycore.inventory.SWItem; import de.steamwar.velocitycore.inventory.SWListInv; @@ -35,6 +36,7 @@ import java.util.Map; import java.util.UUID; import java.util.function.Consumer; +@Linked public class ModCommand extends SWCommand { public ModCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/MsgCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/MsgCommand.java index 5300909d..6491a27a 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/MsgCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/MsgCommand.java @@ -20,17 +20,18 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; -import com.velocitypowered.proxy.Velocity; -import de.steamwar.velocitycore.VelocityCore; -import de.steamwar.velocitycore.listeners.ChatListener; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.ChatterGroup; import de.steamwar.messages.PlayerChatter; import de.steamwar.sql.IgnoreSystem; +import de.steamwar.velocitycore.VelocityCore; +import de.steamwar.velocitycore.listeners.ChatListener; import static de.steamwar.persistent.Storage.lastChats; +@Linked public class MsgCommand extends SWCommand { public MsgCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/PingCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/PingCommand.java index 583f263a..e3c8c8e2 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/PingCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/PingCommand.java @@ -20,8 +20,10 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.PlayerChatter; +@Linked public class PingCommand extends SWCommand { public PingCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/PlaytimeCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/PlaytimeCommand.java index bf04c28a..8b13d44a 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/PlaytimeCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/PlaytimeCommand.java @@ -20,11 +20,13 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.sql.SteamwarUser; import java.text.NumberFormat; +@Linked public class PlaytimeCommand extends SWCommand { public PlaytimeCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/PollCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/PollCommand.java index 72646164..7cd654b9 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/PollCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/PollCommand.java @@ -19,12 +19,14 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.listeners.PollSystem; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; import de.steamwar.messages.Chatter; import de.steamwar.sql.PollAnswer; +@Linked public class PollCommand extends SWCommand { public PollCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/PollresultCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/PollresultCommand.java index 611fd7ed..c47d1e53 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/PollresultCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/PollresultCommand.java @@ -19,6 +19,7 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.listeners.PollSystem; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; @@ -28,6 +29,7 @@ import de.steamwar.sql.UserPerm; import java.util.Map; +@Linked public class PollresultCommand extends SWCommand { public PollresultCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/RCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/RCommand.java index 8ed4a38b..5430b313 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/RCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/RCommand.java @@ -20,10 +20,12 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.PlayerChatter; import static de.steamwar.persistent.Storage.lastChats; +@Linked public class RCommand extends SWCommand { public RCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java index 4d68f07b..45123e18 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java @@ -20,6 +20,7 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.sql.SteamwarUser; @@ -28,6 +29,7 @@ import de.steamwar.velocitycore.ArenaMode; import java.util.Optional; +@Linked public class RankCommand extends SWCommand { public RankCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/ReplayCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/ReplayCommand.java index fe8d9af1..6d825e2a 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/ReplayCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/ReplayCommand.java @@ -19,6 +19,8 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.ArenaMode; import de.steamwar.messages.Message; import de.steamwar.velocitycore.ServerStarter; @@ -32,6 +34,8 @@ import de.steamwar.sql.*; import java.util.ArrayList; import java.util.List; +@Linked +@EventMode(false) public class ReplayCommand extends SWCommand { public ReplayCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/RulesCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/RulesCommand.java index e379d6b1..8128eaff 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/RulesCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/RulesCommand.java @@ -20,12 +20,14 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import net.kyori.adventure.text.event.ClickEvent; import java.util.Arrays; +@Linked public class RulesCommand extends SWCommand { public RulesCommand() { super("rules", "regeln"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/SendCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/SendCommand.java index f1590957..78d27b4d 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/SendCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/SendCommand.java @@ -26,6 +26,7 @@ import com.velocitypowered.api.proxy.server.ServerInfo; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.persistent.Subserver; @@ -38,6 +39,7 @@ import java.util.Collection; import java.util.List; import java.util.stream.Collectors; +@Linked public class SendCommand extends SWCommand { // /send [] diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/ServerTeamchatCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/ServerTeamchatCommand.java index 927644ab..6dc9ea92 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/ServerTeamchatCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/ServerTeamchatCommand.java @@ -19,11 +19,13 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.listeners.ChatListener; import de.steamwar.command.SWCommand; import de.steamwar.messages.Chatter; import de.steamwar.sql.UserPerm; +@Linked public class ServerTeamchatCommand extends SWCommand { public ServerTeamchatCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/SetLocaleCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/SetLocaleCommand.java index a2e66b6b..61abeca1 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/SetLocaleCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/SetLocaleCommand.java @@ -20,10 +20,12 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.PlayerChatter; import de.steamwar.network.packets.server.LocaleInvalidationPacket; import de.steamwar.velocitycore.network.NetworkSender; +@Linked public class SetLocaleCommand extends SWCommand { public SetLocaleCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/StatCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/StatCommand.java index d9694d6c..af545358 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/StatCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/StatCommand.java @@ -19,6 +19,7 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.Node; import de.steamwar.command.SWCommand; import de.steamwar.messages.Chatter; @@ -29,6 +30,7 @@ import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; +@Linked public class StatCommand extends SWCommand { public StatCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/StreamingCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/StreamingCommand.java index edab1c5b..04ddd6e2 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/StreamingCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/StreamingCommand.java @@ -20,11 +20,15 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.persistent.Storage; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; +@Linked +@EventMode(false) public class StreamingCommand extends SWCommand { public static boolean isNotStreaming(Chatter sender) { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java index f0a7be00..d95ed3b5 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java @@ -29,6 +29,7 @@ import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.messages.PlayerChatter; @@ -52,6 +53,7 @@ import java.util.stream.Stream; import static de.steamwar.persistent.Storage.teamInvitations; +@Linked public class TeamCommand extends SWCommand { public TeamCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamchatCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamchatCommand.java index 8381ba94..ee74d5d6 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamchatCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamchatCommand.java @@ -19,12 +19,14 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.listeners.ChatListener; import de.steamwar.command.SWCommand; import de.steamwar.messages.Chatter; import de.steamwar.messages.ChatterGroup; import de.steamwar.sql.SteamwarUser; +@Linked public class TeamchatCommand extends SWCommand { public TeamchatCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TpCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TpCommand.java index 2292c258..9a270dde 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TpCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TpCommand.java @@ -22,6 +22,7 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ServerConnection; import com.velocitypowered.api.proxy.server.RegisteredServer; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.*; import de.steamwar.velocitycore.util.BauLock; import de.steamwar.command.PreviousArguments; @@ -39,6 +40,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +@Linked public class TpCommand extends SWCommand { public TpCommand(){ diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/UnIgnoreCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/UnIgnoreCommand.java index 7f1a5de0..30952834 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/UnIgnoreCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/UnIgnoreCommand.java @@ -20,10 +20,12 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.sql.IgnoreSystem; import de.steamwar.sql.SteamwarUser; +@Linked public class UnIgnoreCommand extends SWCommand { public UnIgnoreCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/VerifyCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/VerifyCommand.java index 96324de2..cf8ba5bd 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/VerifyCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/VerifyCommand.java @@ -19,6 +19,7 @@ package de.steamwar.velocitycore.commands; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.discord.util.AuthManager; import de.steamwar.command.SWCommand; @@ -28,6 +29,7 @@ import net.dv8tion.jda.api.entities.User; import java.util.Base64; import java.util.logging.Level; +@Linked public class VerifyCommand extends SWCommand { public VerifyCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/WebpasswordCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/WebpasswordCommand.java index d19dedd0..8b9632b8 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/WebpasswordCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/WebpasswordCommand.java @@ -20,9 +20,13 @@ package de.steamwar.velocitycore.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.sql.SteamwarUser; +@Linked +@EventMode(false) public class WebpasswordCommand extends SWCommand { public WebpasswordCommand() { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java index 7576f75f..a76c8ac7 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java @@ -23,6 +23,7 @@ import com.velocitypowered.api.proxy.Player; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.persistent.Storage; @@ -41,7 +42,7 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; - +@Linked public class WhoisCommand extends SWCommand { public WhoisCommand() { super("whois"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/BanListener.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/BanListener.java index 1d205cc8..0ac6423c 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/BanListener.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/BanListener.java @@ -22,6 +22,7 @@ package de.steamwar.velocitycore.listeners; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.connection.LoginEvent; import com.velocitypowered.api.proxy.Player; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.sql.BannedUserIPs; @@ -36,6 +37,7 @@ import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; +@Linked public class BanListener extends BasicListener { @Subscribe diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/ChatListener.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/ChatListener.java index dfdf5c7f..673733b9 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/ChatListener.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/ChatListener.java @@ -29,6 +29,7 @@ import com.velocitypowered.api.proxy.ConsoleCommandSource; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ServerConnection; import com.velocitypowered.api.proxy.server.ServerInfo; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.ChatterGroup; import de.steamwar.messages.Message; @@ -50,6 +51,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; +@Linked public class ChatListener extends BasicListener { private static final Logger cmdLogger = Logger.getLogger("Command logger"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/CheckListener.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/CheckListener.java index 4c8ef131..0c3000c1 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/CheckListener.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/CheckListener.java @@ -24,6 +24,7 @@ import com.velocitypowered.api.event.connection.DisconnectEvent; import com.velocitypowered.api.event.connection.PostLoginEvent; import com.velocitypowered.api.event.player.ServerConnectedEvent; import com.velocitypowered.api.proxy.Player; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.persistent.Bauserver; import de.steamwar.persistent.Subserver; @@ -34,6 +35,7 @@ import de.steamwar.velocitycore.commands.CheckCommand; import java.util.ArrayList; import java.util.List; +@Linked public class CheckListener extends BasicListener { @Subscribe diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/ConnectionListener.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/ConnectionListener.java index 765d09c7..1cfd8a49 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/ConnectionListener.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/ConnectionListener.java @@ -27,6 +27,7 @@ import com.velocitypowered.api.event.player.KickedFromServerEvent; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.permission.Tristate; import com.velocitypowered.api.proxy.Player; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.persistent.Subserver; @@ -45,6 +46,7 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; +@Linked public class ConnectionListener extends BasicListener { private static final Set newPlayers = new HashSet<>(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/CookieEvents.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/CookieEvents.java index 660ebc87..f34fe1c5 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/CookieEvents.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/CookieEvents.java @@ -22,11 +22,15 @@ package de.steamwar.velocitycore.listeners; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.player.CookieReceiveEvent; import com.velocitypowered.api.proxy.Player; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; import de.steamwar.sql.EventFight; import de.steamwar.sql.SteamwarUser; import de.steamwar.velocitycore.EventStarter; import de.steamwar.velocitycore.VelocityCore; +@Linked +@EventMode(false) public class CookieEvents extends BasicListener { @Subscribe diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/EventModeListener.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/EventModeListener.java index 7777408e..ecc977ed 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/EventModeListener.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/EventModeListener.java @@ -19,27 +19,25 @@ package de.steamwar.velocitycore.listeners; -import java.net.InetSocketAddress; -import java.nio.charset.Charset; -import java.util.List; - import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.connection.PostLoginEvent; import com.velocitypowered.api.event.player.ServerConnectedEvent; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.Player; - +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.persistent.Subserver; -import de.steamwar.sql.Event; -import de.steamwar.sql.EventFight; -import de.steamwar.sql.Referee; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.TeamTeilnahme; +import de.steamwar.sql.*; import de.steamwar.velocitycore.EventStarter; import de.steamwar.velocitycore.VelocityCore; import net.kyori.adventure.key.Key; +import java.net.InetSocketAddress; +import java.util.List; + +@Linked +@EventMode(true) public class EventModeListener extends BasicListener { public static final Key EVENT_TO_SPECTATE_KEY = Key.key("sw", "event_to_spectate"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/IPSanitizer.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/IPSanitizer.java index bc8c42ba..ca99fbed 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/IPSanitizer.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/IPSanitizer.java @@ -26,6 +26,7 @@ import com.velocitypowered.api.proxy.Player; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import com.velocitypowered.proxy.connection.client.LoginInboundConnection; +import de.steamwar.linkage.Linked; import de.steamwar.persistent.Reflection; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.mods.Hostname; @@ -38,6 +39,7 @@ import java.util.Map; import java.util.UUID; import java.util.logging.Level; +@Linked public class IPSanitizer extends BasicListener { private static final Map trueAddress = new HashMap<>(); // Will likely slightly leak over time diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java index b35279fb..8b37cf8b 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/PluginMessage.java @@ -31,6 +31,7 @@ import com.velocitypowered.api.proxy.messages.ChannelMessageSource; import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.proxy.protocol.ProtocolUtils; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.network.packets.NetworkPacket; import de.steamwar.sql.SteamwarUser; @@ -50,6 +51,7 @@ import java.util.*; import java.util.function.Consumer; import java.util.logging.Level; +@Linked public class PluginMessage extends BasicListener { public static void send(Player player, String legacyChannel, String channel, byte[] data) { diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/SessionManager.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/SessionManager.java index 248fd606..30895cea 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/SessionManager.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/SessionManager.java @@ -22,6 +22,7 @@ package de.steamwar.velocitycore.listeners; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.connection.DisconnectEvent; import com.velocitypowered.api.event.connection.PostLoginEvent; +import de.steamwar.linkage.Linked; import de.steamwar.sql.AuditLog; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.sql.Session; @@ -32,6 +33,7 @@ import java.time.Instant; import static de.steamwar.persistent.Storage.sessions; +@Linked public class SessionManager extends BasicListener { @Subscribe diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/SettingsChangedListener.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/SettingsChangedListener.java index 59693af5..3cd7ae77 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/SettingsChangedListener.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/SettingsChangedListener.java @@ -22,11 +22,13 @@ package de.steamwar.velocitycore.listeners; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.player.PlayerSettingsChangedEvent; import com.velocitypowered.api.proxy.Player; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.network.NetworkSender; import de.steamwar.sql.SteamwarUser; import de.steamwar.network.packets.server.LocaleInvalidationPacket; +@Linked public class SettingsChangedListener extends BasicListener { @Subscribe diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/TexturePackSystem.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/TexturePackSystem.java index 8d07e0c7..65a1a621 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/TexturePackSystem.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/TexturePackSystem.java @@ -22,6 +22,7 @@ package de.steamwar.velocitycore.listeners; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.player.ServerPostConnectEvent; import com.velocitypowered.api.proxy.player.ResourcePackInfo; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.VelocityCore; import net.kyori.adventure.text.Component; @@ -33,6 +34,7 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; // https://jd.papermc.io/velocity/3.4.0/com/velocitypowered/api/proxy/player/ResourcePackInfo.Builder.html#setHash(byte%5B%5D) +@Linked public class TexturePackSystem extends BasicListener { private static final File PACKS_DIR = new File("/var/www/packs"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/VersionAnnouncer.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/VersionAnnouncer.java index 5204d258..7393358c 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/VersionAnnouncer.java +++ b/VelocityCore/src/de/steamwar/velocitycore/listeners/VersionAnnouncer.java @@ -26,6 +26,7 @@ import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.server.ServerInfo; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.velocity.platform.VelocityViaConfig; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.network.packets.server.ClientVersionPacket; import de.steamwar.persistent.Subserver; @@ -35,6 +36,7 @@ import de.steamwar.velocitycore.network.NetworkSender; import java.time.Duration; import java.time.temporal.ChronoUnit; +@Linked public class VersionAnnouncer extends BasicListener { @Subscribe diff --git a/VelocityCore/src/de/steamwar/velocitycore/mods/Badlion.java b/VelocityCore/src/de/steamwar/velocitycore/mods/Badlion.java index 57cc3986..cb26c30b 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/mods/Badlion.java +++ b/VelocityCore/src/de/steamwar/velocitycore/mods/Badlion.java @@ -22,7 +22,9 @@ package de.steamwar.velocitycore.mods; import com.google.gson.JsonObject; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; +import de.steamwar.linkage.Linked; +@Linked public class Badlion { // https://github.com/BadlionClient/BadlionClientModAPI diff --git a/VelocityCore/src/de/steamwar/velocitycore/mods/FML2.java b/VelocityCore/src/de/steamwar/velocitycore/mods/FML2.java index fa0917dd..f2b4bc8c 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/mods/FML2.java +++ b/VelocityCore/src/de/steamwar/velocitycore/mods/FML2.java @@ -25,6 +25,7 @@ import com.velocitypowered.api.proxy.LoginPhaseConnection; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.proxy.connection.client.LoginInboundConnection; import com.velocitypowered.proxy.protocol.ProtocolUtils; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.listeners.BasicListener; import de.steamwar.velocitycore.listeners.PluginMessage; @@ -37,6 +38,7 @@ import net.kyori.adventure.text.Component; import java.util.*; import java.util.logging.Level; +@Linked public class FML2 extends BasicListener { // FML2: https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29 // FML3: https://github.com/adde0109/Ambassador/tree/non-api/src/main/java/org/adde0109/ambassador/forge diff --git a/VelocityCore/src/de/steamwar/velocitycore/mods/FabricModSender.java b/VelocityCore/src/de/steamwar/velocitycore/mods/FabricModSender.java index 2f492a88..209ad423 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/mods/FabricModSender.java +++ b/VelocityCore/src/de/steamwar/velocitycore/mods/FabricModSender.java @@ -28,6 +28,7 @@ import com.velocitypowered.api.event.connection.PluginMessageEvent; import com.velocitypowered.api.event.player.ServerConnectedEvent; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.proxy.protocol.ProtocolUtils; +import de.steamwar.linkage.Linked; import de.steamwar.persistent.Storage; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.listeners.BasicListener; @@ -40,6 +41,7 @@ import io.netty.buffer.Unpooled; import java.util.*; import java.util.concurrent.TimeUnit; +@Linked public class FabricModSender extends BasicListener { private final Set neededFabricMods = new HashSet<>(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/mods/Hostname.java b/VelocityCore/src/de/steamwar/velocitycore/mods/Hostname.java index 19547194..a7c00d9b 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/mods/Hostname.java +++ b/VelocityCore/src/de/steamwar/velocitycore/mods/Hostname.java @@ -24,6 +24,7 @@ import com.velocitypowered.api.event.connection.ConnectionHandshakeEvent; import com.velocitypowered.proxy.connection.client.InitialInboundConnection; import com.velocitypowered.proxy.connection.client.LoginInboundConnection; import com.velocitypowered.proxy.protocol.packet.HandshakePacket; +import de.steamwar.linkage.Linked; import de.steamwar.persistent.Reflection; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.listeners.BasicListener; @@ -32,6 +33,7 @@ import java.util.HashSet; import java.util.Set; import java.util.logging.Level; +@Linked public class Hostname extends BasicListener { private static final Reflection.Field delegate = new Reflection.Field<>(LoginInboundConnection.class, "delegate"); diff --git a/VelocityCore/src/de/steamwar/velocitycore/mods/ReplayMod.java b/VelocityCore/src/de/steamwar/velocitycore/mods/ReplayMod.java index a09e7295..4e08ac8b 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/mods/ReplayMod.java +++ b/VelocityCore/src/de/steamwar/velocitycore/mods/ReplayMod.java @@ -22,6 +22,7 @@ package de.steamwar.velocitycore.mods; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.player.ServerPostConnectEvent; import com.velocitypowered.api.proxy.Player; +import de.steamwar.linkage.Linked; import de.steamwar.persistent.Bauserver; import de.steamwar.persistent.Builderserver; import de.steamwar.velocitycore.VelocityCore; @@ -32,6 +33,7 @@ import de.steamwar.velocitycore.listeners.PluginMessage; import java.util.Arrays; +@Linked public class ReplayMod extends BasicListener { // https://gist.github.com/Johni0702/2547c463e51f65f312cb // https://github.com/ReplayMod/replay-restrictions/blob/master/bungeecord/src/main/java/de/johni0702/replay/restrictions/BungeeCordPlugin.java diff --git a/VelocityCore/src/de/steamwar/velocitycore/mods/Schematica.java b/VelocityCore/src/de/steamwar/velocitycore/mods/Schematica.java index 9cf2c0c7..caac9a27 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/mods/Schematica.java +++ b/VelocityCore/src/de/steamwar/velocitycore/mods/Schematica.java @@ -22,8 +22,10 @@ package de.steamwar.velocitycore.mods; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.connection.PostLoginEvent; import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.listeners.BasicListener; +@Linked public class Schematica extends BasicListener { // https://github.com/Lunatrius/SchematicaPlugin/blob/master/src/main/java/com/github/lunatrius/schematica/plugin/SchematicaPlugin.java diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/AnvilAnswerHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/AnvilAnswerHandler.java index f0abb739..d772672e 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/AnvilAnswerHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/AnvilAnswerHandler.java @@ -19,10 +19,12 @@ package de.steamwar.velocitycore.network.handlers; +import de.steamwar.linkage.Linked; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.client.AnvilAnswerPacket; import de.steamwar.velocitycore.inventory.SWAnvilInv; +@Linked public class AnvilAnswerHandler extends PacketHandler { @Handler diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java index 3ef4eb8f..8915cb42 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java @@ -20,6 +20,8 @@ package de.steamwar.velocitycore.network.handlers; import com.velocitypowered.api.proxy.Player; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.common.FightEndsPacket; @@ -38,6 +40,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.IntFunction; import java.util.stream.Collectors; +@Linked public class EloPlayerHandler extends PacketHandler { private static final int MEDIAN_ELO_GAIN = 40; diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java index 49da0116..eec033e1 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java @@ -19,6 +19,7 @@ package de.steamwar.velocitycore.network.handlers; +import de.steamwar.linkage.Linked; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.common.FightEndsPacket; import de.steamwar.sql.SchemElo; @@ -26,6 +27,7 @@ import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicType; import de.steamwar.velocitycore.ArenaMode; +@Linked public class EloSchemHandler extends PacketHandler { private static final int K = 20; diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/ExecuteCommandHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/ExecuteCommandHandler.java index e96f9286..0f79d12e 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/ExecuteCommandHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/ExecuteCommandHandler.java @@ -19,11 +19,13 @@ package de.steamwar.velocitycore.network.handlers; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.client.ExecuteCommandPacket; import de.steamwar.sql.SteamwarUser; +@Linked public class ExecuteCommandHandler extends PacketHandler { @Handler diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/FightInfoHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/FightInfoHandler.java index 6565f1db..9d7a2067 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/FightInfoHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/FightInfoHandler.java @@ -21,6 +21,7 @@ package de.steamwar.velocitycore.network.handlers; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.server.RegisteredServer; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.network.NetworkSender; import de.steamwar.velocitycore.network.ServerMetaInfo; import de.steamwar.velocitycore.tablist.TablistManager; @@ -30,6 +31,7 @@ import de.steamwar.network.packets.common.FightInfoPacket; import java.util.HashSet; import java.util.Set; +@Linked public class FightInfoHandler extends PacketHandler { private static final Set lobbys = new HashSet<>(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/ImALobbyHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/ImALobbyHandler.java index 391ee1b7..b4eb48f1 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/ImALobbyHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/ImALobbyHandler.java @@ -19,10 +19,12 @@ package de.steamwar.velocitycore.network.handlers; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.network.ServerMetaInfo; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.client.ImALobbyPacket; +@Linked public class ImALobbyHandler extends PacketHandler { @Handler diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/InventoryCallbackHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/InventoryCallbackHandler.java index 54668d94..e8f9894b 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/InventoryCallbackHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/InventoryCallbackHandler.java @@ -20,6 +20,7 @@ package de.steamwar.velocitycore.network.handlers; import com.velocitypowered.api.proxy.Player; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.inventory.InvCallback; import de.steamwar.velocitycore.inventory.SWInventory; import de.steamwar.velocitycore.network.NetworkSender; @@ -33,6 +34,7 @@ import de.steamwar.sql.SteamwarUser; import java.util.HashMap; import java.util.Map; +@Linked public class InventoryCallbackHandler extends PacketHandler { public static final Map inventoryHashMap = new HashMap<>(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PlayerSkinHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PlayerSkinHandler.java index ff18d309..0293545c 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PlayerSkinHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PlayerSkinHandler.java @@ -27,6 +27,7 @@ import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.connection.PostLoginEvent; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.util.GameProfile; +import de.steamwar.linkage.Linked; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.common.PlayerSkinRequestPacket; import de.steamwar.network.packets.common.PlayerSkinResponsePacket; @@ -46,6 +47,7 @@ import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; +@Linked public class PlayerSkinHandler extends PacketHandler { private final int maxCacheSize = 1000; diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PrepareSchemHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PrepareSchemHandler.java index eec027c5..4a90f5ca 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PrepareSchemHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/PrepareSchemHandler.java @@ -20,6 +20,7 @@ package de.steamwar.velocitycore.network.handlers; import com.velocitypowered.api.proxy.Player; +import de.steamwar.linkage.Linked; import de.steamwar.velocitycore.ArenaMode; import de.steamwar.velocitycore.ServerStarter; import de.steamwar.velocitycore.VelocityCore; @@ -28,6 +29,7 @@ import de.steamwar.network.packets.client.PrepareSchemPacket; import de.steamwar.sql.SchematicType; import de.steamwar.sql.SteamwarUser; +@Linked public class PrepareSchemHandler extends PacketHandler { @Handler diff --git a/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java b/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java index 205cf067..2a8c5367 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java +++ b/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java @@ -26,6 +26,8 @@ import com.velocitypowered.api.event.player.ServerPostConnectEvent; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.server.RegisteredServer; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.api.Disable; import de.steamwar.network.packets.common.FightInfoPacket; import de.steamwar.persistent.Storage; import de.steamwar.persistent.Subserver; @@ -38,7 +40,8 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -public class TablistManager extends BasicListener { +@Linked +public class TablistManager extends BasicListener implements Disable { private static final Map fightInfos = new HashMap<>(); From c39447863203b5c79e7bb78b9bfe7beee4b00b76 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 29 Sep 2025 17:14:00 +0200 Subject: [PATCH 03/11] Fix VelocityCore --- .../de/steamwar/linkage/AbstractLinker.java | 4 ++-- VelocityCore/build.gradle.kts | 3 +++ .../de/steamwar/velocitycore/Broadcaster.java | 2 +- .../steamwar/velocitycore/VelocityCore.java | 3 ++- .../velocitycore/commands/BauCommand.java | 21 +++++++++---------- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java index 2c013f76..18e931ce 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java @@ -82,7 +82,7 @@ public abstract class AbstractLinker { try { any = clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { - throw new SecurityException(e.getMessage()); + throw new SecurityException(e.getMessage(), e); } instances.put(clazz, any); @@ -104,7 +104,7 @@ public abstract class AbstractLinker { try { field.set(o, instances.get(field.getType())); } catch (IllegalAccessException e) { - throw new SecurityException(e); + throw new SecurityException(e.getMessage(), e); } } } diff --git a/VelocityCore/build.gradle.kts b/VelocityCore/build.gradle.kts index f290ed22..fd6358f1 100644 --- a/VelocityCore/build.gradle.kts +++ b/VelocityCore/build.gradle.kts @@ -32,6 +32,9 @@ java { } dependencies { + compileOnly(libs.classindex) + annotationProcessor(libs.classindex) + annotationProcessor(libs.velocityapi) compileOnly(libs.velocity) compileOnly(libs.viaapi) diff --git a/VelocityCore/src/de/steamwar/velocitycore/Broadcaster.java b/VelocityCore/src/de/steamwar/velocitycore/Broadcaster.java index f5a05b7f..56030635 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/Broadcaster.java +++ b/VelocityCore/src/de/steamwar/velocitycore/Broadcaster.java @@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit; @Linked @EventMode(false) -class Broadcaster { +public class Broadcaster { private final List broadcasts = VelocityCore.get().getConfig().getBroadcasts(); private int lastBroadCast = 0; diff --git a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java index 58a9033c..86a11106 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java +++ b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java @@ -167,7 +167,8 @@ public class VelocityCore implements ReloadablePlugin { try { linker.link(); } catch (AbstractLinker.LinkException e) { - VelocityCore.getProxy().shutdown(); + logger.log(Level.SEVERE, e.getMessage(), e); + getProxy().shutdown(); return; } diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java index 139524a0..48192baa 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java @@ -19,19 +19,13 @@ package de.steamwar.velocitycore.commands; -import de.steamwar.linkage.EventMode; -import de.steamwar.linkage.Linked; -import de.steamwar.linkage.LinkedInstance; -import de.steamwar.velocitycore.*; -import de.steamwar.velocitycore.inventory.SWInventory; -import de.steamwar.velocitycore.inventory.SWItem; -import de.steamwar.velocitycore.network.NetworkSender; -import de.steamwar.velocitycore.util.BauLock; -import de.steamwar.velocitycore.util.BauLockState; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.EventMode; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.messages.PlayerChatter; @@ -39,6 +33,12 @@ import de.steamwar.network.packets.server.BaumemberUpdatePacket; import de.steamwar.persistent.Bauserver; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; +import de.steamwar.velocitycore.*; +import de.steamwar.velocitycore.inventory.SWInventory; +import de.steamwar.velocitycore.inventory.SWItem; +import de.steamwar.velocitycore.network.NetworkSender; +import de.steamwar.velocitycore.util.BauLock; +import de.steamwar.velocitycore.util.BauLockState; import java.util.Collection; import java.util.function.Consumer; @@ -50,9 +50,8 @@ public class BauCommand extends SWCommand { @LinkedInstance private HelpCommand command; - public BauCommand(HelpCommand command) { + public BauCommand() { super("bau", "b", "build", "gs"); - this.command = command; } @Register(noTabComplete = true) From 22d1e15ae0414fd7225627b12668a6997cdd4b7e Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 3 Oct 2025 13:16:56 +0200 Subject: [PATCH 04/11] Implement Linkage for FightSystem --- .../src/de/steamwar/linkage/Linked.java | 2 +- .../de/steamwar/linkage/LinkedInstance.java | 2 +- .../src/de/steamwar/linkage/MinVersion.java | 2 +- FightSystem/FightSystem_Core/build.gradle.kts | 2 + .../de/steamwar/fightsystem/FightSystem.java | 119 ++++---------- .../fightsystem/commands/AkCommand.java | 2 + .../fightsystem/commands/GamemodeCommand.java | 2 + .../fightsystem/commands/InfoCommand.java | 2 + .../fightsystem/commands/KitCommand.java | 2 + .../fightsystem/commands/LeaveCommand.java | 2 + .../commands/LockschemCommand.java | 2 + .../fightsystem/commands/ReadyCommand.java | 2 + .../fightsystem/commands/RemoveCommand.java | 2 + .../fightsystem/commands/RequestsCommand.java | 2 + .../fightsystem/commands/SkipCommand.java | 2 + .../fightsystem/commands/StateCommand.java | 2 + .../fightsystem/commands/TBCommand.java | 2 + .../fightsystem/commands/TPSWarpCommand.java | 2 + .../commands/TechhiderbugCommand.java | 2 + .../fightsystem/commands/UnrankCommand.java | 2 + .../fightsystem/commands/WGCommand.java | 2 + .../fightsystem/commands/WinCommand.java | 2 + .../countdown/EventSpectateCountdown.java | 2 + .../countdown/NoPlayersOnlineCountdown.java | 2 + .../countdown/PostSchemCountdown.java | 2 + .../countdown/PreRunningCountdown.java | 2 + .../countdown/PreSchemCountdown.java | 2 + .../countdown/SpectateOverCountdown.java | 2 + .../fightsystem/event/HellsBells.java | 4 +- .../de/steamwar/fightsystem/event/Meteor.java | 3 +- .../steamwar/fightsystem/event/NoGravity.java | 2 + .../fightsystem/event/PersistentDamage.java | 2 + .../fightsystem/event/TNTDistributor.java | 2 + .../fightsystem/fight/FightWorld.java | 2 + .../steamwar/fightsystem/fight/HotbarKit.java | 62 +------- .../fightsystem/fight/HotbarKitListener.java | 81 ++++++++++ .../fightsystem/listener/ArenaBorder.java | 2 + .../fightsystem/listener/ArrowStopper.java | 2 + .../listener/BlockFadeListener.java | 2 + .../listener/BlockPlaceCollision.java | 2 + .../steamwar/fightsystem/listener/Chat.java | 2 + .../steamwar/fightsystem/listener/Check.java | 2 + .../fightsystem/listener/ClickAnalyzer.java | 2 + .../listener/DenyInventoryMovement.java | 2 + .../listener/DenyWorldInteraction.java | 2 + .../fightsystem/listener/EntityDamage.java | 2 + .../fightsystem/listener/EventJoin.java | 2 + .../fightsystem/listener/InFightDamage.java | 2 + .../listener/InFightInventory.java | 2 + .../fightsystem/listener/IngameDeath.java | 2 + .../listener/JoinRequestListener.java | 2 + .../fightsystem/listener/LeaveableArena.java | 2 + .../fightsystem/listener/NormalJoin.java | 2 + .../fightsystem/listener/Permanent.java | 2 + .../listener/PersonalKitCreator.java | 2 + .../fightsystem/listener/PrepareSchem.java | 2 + .../fightsystem/listener/Recording.java | 2 + .../listener/RunningWorldInteraction.java | 2 + .../fightsystem/listener/SetupQuit.java | 2 + .../fightsystem/listener/Shutdown.java | 2 + .../fightsystem/listener/Spectator.java | 3 +- .../fightsystem/listener/TestJoin.java | 2 + .../fightsystem/listener/WaterRemover.java | 3 +- .../fightsystem/record/FileRecorder.java | 2 + .../fightsystem/record/LiveRecorder.java | 2 + .../fightsystem/utils/BungeeFightInfo.java | 3 +- .../fightsystem/utils/EnterHandler.java | 2 + .../fightsystem/utils/FightStatistics.java | 2 + .../steamwar/fightsystem/utils/FightUI.java | 2 + .../EventTeamOffWincondition.java | 2 + .../winconditions/Wincondition.java | 2 +- .../winconditions/WinconditionAllDead.java | 2 + .../winconditions/WinconditionAmongUs.java | 2 + .../WinconditionBasePercent.java | 133 ++++++++++++++++ .../winconditions/WinconditionBlocks.java | 2 +- .../WinconditionCaptainDead.java | 2 + .../WinconditionComparisonTimeout.java | 2 +- .../WinconditionHearthRatioTimeout.java | 31 ++++ .../winconditions/WinconditionPercent.java | 147 +++--------------- .../WinconditionPercentTimeout.java | 30 ++++ .../winconditions/WinconditionPoints.java | 4 +- .../WinconditionPointsAirShip.java | 4 +- .../WinconditionPumkinTechKO.java | 30 ++++ .../winconditions/WinconditionTimeTechKO.java | 2 + .../WinconditionTimedDamageTechKO.java | 2 + .../winconditions/WinconditionTimeout.java | 2 + .../WinconditionWaterTechKO.java | 31 ++++ 87 files changed, 538 insertions(+), 292 deletions(-) create mode 100644 FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java create mode 100644 FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBasePercent.java create mode 100644 FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHearthRatioTimeout.java create mode 100644 FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java create mode 100644 FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumkinTechKO.java create mode 100644 FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/Linked.java b/CommonCore/Linkage/src/de/steamwar/linkage/Linked.java index 3b0aa9e0..f3e7ca0d 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/Linked.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/Linked.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * 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 diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/LinkedInstance.java b/CommonCore/Linkage/src/de/steamwar/linkage/LinkedInstance.java index 04e382d1..8fdbc9be 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/LinkedInstance.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/LinkedInstance.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * 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 diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java b/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java index 82d9ce3d..efabd281 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * 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 diff --git a/FightSystem/FightSystem_Core/build.gradle.kts b/FightSystem/FightSystem_Core/build.gradle.kts index 93dd59c4..140696b5 100644 --- a/FightSystem/FightSystem_Core/build.gradle.kts +++ b/FightSystem/FightSystem_Core/build.gradle.kts @@ -22,6 +22,8 @@ plugins { } dependencies { + compileOnly(libs.classindex) + annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index a95670a0..d3ad2147 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -20,26 +20,24 @@ package de.steamwar.fightsystem; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.core.WorldEditRendererCUIEditor; import de.steamwar.core.Core; -import de.steamwar.fightsystem.commands.*; -import de.steamwar.fightsystem.countdown.*; -import de.steamwar.fightsystem.event.*; +import de.steamwar.core.WorldEditRendererCUIEditor; +import de.steamwar.fightsystem.commands.TechareaCommand; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; -import de.steamwar.fightsystem.fight.FightWorld; -import de.steamwar.fightsystem.fight.HotbarKit; -import de.steamwar.fightsystem.listener.*; -import de.steamwar.fightsystem.listener.Shutdown; -import de.steamwar.fightsystem.record.FileRecorder; +import de.steamwar.fightsystem.listener.ClickAnalyzer; +import de.steamwar.fightsystem.listener.PistonListener; import de.steamwar.fightsystem.record.FileSource; import de.steamwar.fightsystem.record.GlobalRecorder; -import de.steamwar.fightsystem.record.LiveRecorder; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.*; -import de.steamwar.fightsystem.winconditions.*; +import de.steamwar.fightsystem.winconditions.Wincondition; +import de.steamwar.fightsystem.winconditions.WinconditionComparisonTimeout; +import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.linkage.AbstractLinker; +import de.steamwar.linkage.SpigotLinker; import de.steamwar.message.Message; import de.steamwar.sql.NodeData; import de.steamwar.sql.SchematicNode; @@ -58,6 +56,8 @@ public class FightSystem extends JavaPlugin { private TechHiderWrapper techHider; private HullHider hullHider; + private SpigotLinker spigotLinker; + @Override public void onLoad() { plugin = this; @@ -77,100 +77,32 @@ public class FightSystem extends JavaPlugin { message = new Message("de.steamwar.fightsystem.FightSystem", FightSystem.class.getClassLoader()); - new EntityDamage(); - new WaterRemover(); - new Permanent(); + spigotLinker = new SpigotLinker(this, message) { + @Override + protected void linkObject(Object any) { + // No Init needed for FightSystem! + } + }; + try { + spigotLinker.link(); + } catch (AbstractLinker.LinkException e) { + e.printStackTrace(); + Bukkit.shutdown(); + return; + } + new PistonListener(ArenaMode.AntiTestCheckPrepare, e -> e.setCancelled(true)); new PistonListener(ArenaMode.Test, e -> getMessage().broadcastActionbar("PISTON_PUSHED_OUTSIDE")); new PistonListener(ArenaMode.Prepare, e -> { getMessage().broadcast("PISTON_PUSHED_OUTSIDE"); shutdown(); }); - new Chat(); - new ArenaBorder(); - new IngameDeath(); - new InFightDamage(); - new InFightInventory(); - new DenyWorldInteraction(); - new DenyInventoryMovement(); - new EventJoin(); - new Recording(); - new Check(); - new Shutdown(); - new SetupQuit(); - new PrepareSchem(); - new TestJoin(); - new NormalJoin(); - new Spectator(); - new RunningWorldInteraction(); - new PersonalKitCreator(); - new ArrowStopper(); new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener()); - new BlockFadeListener(); - new LeaveableArena(); - new ClickAnalyzer(); - new BlockPlaceCollision(); - new HotbarKit.HotbarKitListener(); - new JoinRequestListener(); new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f)); new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new); - new EnterHandler(); techHider = new TechHiderWrapper(); hullHider = new HullHider(); - new FightWorld(); - new FightUI(); - new FightStatistics(); - new BungeeFightInfo(); - - new WinconditionAllDead(); - new WinconditionCaptainDead(); - new WinconditionBlocks(Winconditions.WATER_TECH_KO, "WaterTechKO", "BAR_WATER", FlatteningWrapper.impl::isWater); - new WinconditionBlocks(Winconditions.PUMPKIN_TECH_KO, "PumpkinTechKO", "BAR_CANNONS", block -> block.getType() == WinconditionBlocks.PUMPKIN_LANTERN); - new WinconditionPercent(Winconditions.PERCENT_SYSTEM, "Percent"); - new WinconditionPoints(); - new WinconditionPointsAirShip(); - new WinconditionTimeout(); - new WinconditionTimeTechKO(); - new WinconditionTimedDamageTechKO(); - new EventTeamOffWincondition(); - new WinconditionComparisonTimeout(Winconditions.HEART_RATIO_TIMEOUT, "HeartTimeout", "WIN_MORE_HEALTH", FightTeam::getHeartRatio); - new WinconditionComparisonTimeout(Winconditions.PERCENT_TIMEOUT, "PercentTimeout", "WIN_LESS_DAMAGE", team -> -Wincondition.getPercentWincondition().getPercent(team)); - - new HellsBells(); - new Meteor(); - new PersistentDamage(); - new TNTDistributor(); - new WinconditionAmongUs(); - new NoGravity(); - - new NoPlayersOnlineCountdown(); - new PreSchemCountdown(); - new PostSchemCountdown(); - new PreRunningCountdown(); - new SpectateOverCountdown(); - new EventSpectateCountdown(); - - new LeaveCommand(); - new KitCommand(); - new RemoveCommand(); - new RequestsCommand(); - new InfoCommand(); - new WGCommand(); - new TBCommand(); - new GamemodeCommand(); - new ReadyCommand(); - new AkCommand(); - new LockschemCommand(); - new StateCommand(); - new SkipCommand(); - new TechhiderbugCommand(); - new TPSWarpCommand(); - new UnrankCommand(); - new WinCommand(); - - new LiveRecorder(); - new FileRecorder(); FileSource.startReplay(); @@ -196,6 +128,7 @@ public class FightSystem extends JavaPlugin { public void onDisable() { GlobalRecorder.getInstance().close(); ClickAnalyzer.close(); + spigotLinker.unlink(); } public static void setSpectateState(FightTeam winFightTeam, String winreason, String subtitle, Object... params) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java index 27e6b797..dcb40b9d 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java @@ -25,6 +25,7 @@ import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Kit; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; import org.bukkit.command.Command; @@ -32,6 +33,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class AkCommand implements CommandExecutor { public AkCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java index 5c566261..2c6b6d3a 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList; import de.steamwar.core.CommandRemover; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.GameMode; import org.bukkit.command.CommandSender; @@ -34,6 +35,7 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Level; +@Linked public class GamemodeCommand extends BukkitCommand { private static final List GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival", diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java index 4cd6c19c..ca515dad 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java @@ -26,6 +26,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; import de.steamwar.fightsystem.utils.FightStatistics; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; @@ -34,6 +35,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class InfoCommand implements CommandExecutor { public InfoCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/KitCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/KitCommand.java index 000711d8..c80004dc 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/KitCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/KitCommand.java @@ -22,11 +22,13 @@ package de.steamwar.fightsystem.commands; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class KitCommand implements CommandExecutor { public KitCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaveCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaveCommand.java index 902f7796..61bbf816 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaveCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaveCommand.java @@ -22,11 +22,13 @@ package de.steamwar.fightsystem.commands; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class LeaveCommand implements CommandExecutor { public LeaveCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java index 9ea0c135..eb097998 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java @@ -25,6 +25,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import de.steamwar.sql.*; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.command.Command; @@ -32,6 +33,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class LockschemCommand implements CommandExecutor { public LockschemCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReadyCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReadyCommand.java index 4761ca57..2da5d3c2 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReadyCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReadyCommand.java @@ -22,11 +22,13 @@ package de.steamwar.fightsystem.commands; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class ReadyCommand implements CommandExecutor { public ReadyCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java index f7c93537..d1083ecf 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java @@ -23,11 +23,13 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class RemoveCommand implements CommandExecutor { public RemoveCommand() { 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 131cc898..f998384a 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/RequestsCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/RequestsCommand.java @@ -27,6 +27,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.JoinRequest; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -34,6 +35,7 @@ import org.bukkit.entity.Player; import java.util.function.BiConsumer; +@Linked public class RequestsCommand implements CommandExecutor { public RequestsCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java index a1bedda9..5311eecc 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java @@ -25,11 +25,13 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.record.PacketProcessor; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class SkipCommand implements CommandExecutor { public SkipCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/StateCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/StateCommand.java index 8299a8c6..1fb3b424 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/StateCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/StateCommand.java @@ -22,11 +22,13 @@ package de.steamwar.fightsystem.commands; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class StateCommand implements CommandExecutor { public StateCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TBCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TBCommand.java index fa18262c..9ed7a9fe 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TBCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TBCommand.java @@ -23,11 +23,13 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class TBCommand implements CommandExecutor { public TBCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java index 27927f72..4384f9ce 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java @@ -24,10 +24,12 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +@Linked public class TPSWarpCommand implements CommandExecutor { public TPSWarpCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java index 3080c13e..ed8ce14c 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java @@ -26,6 +26,7 @@ import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SWException; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -36,6 +37,7 @@ import java.io.StringWriter; import java.util.Arrays; import java.util.logging.Level; +@Linked public class TechhiderbugCommand implements CommandExecutor { public TechhiderbugCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/UnrankCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/UnrankCommand.java index 25bdf35b..7f1be4b1 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/UnrankCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/UnrankCommand.java @@ -23,11 +23,13 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; import de.steamwar.fightsystem.utils.FightStatistics; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class UnrankCommand implements CommandExecutor { public UnrankCommand () { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/WGCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/WGCommand.java index 1ffe7dce..30f0414e 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/WGCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/WGCommand.java @@ -24,11 +24,13 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightWorld; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class WGCommand implements CommandExecutor { public WGCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java index d522a8e2..c236442f 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java @@ -7,12 +7,14 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class WinCommand implements CommandExecutor { public WinCommand() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java index e8772398..0054def5 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java @@ -26,7 +26,9 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; +import de.steamwar.linkage.Linked; +@Linked public class EventSpectateCountdown extends Countdown { public EventSpectateCountdown() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java index 94e54e28..b479be63 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java @@ -24,8 +24,10 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.utils.Message; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; +@Linked public class NoPlayersOnlineCountdown extends Countdown { public NoPlayersOnlineCountdown() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java index cb5f2db2..307eae03 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java @@ -24,7 +24,9 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.utils.Message; +import de.steamwar.linkage.Linked; +@Linked public class PostSchemCountdown extends Countdown { public PostSchemCountdown() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java index 17684a70..8dd7e2b2 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java @@ -25,7 +25,9 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; +import de.steamwar.linkage.Linked; +@Linked public class PreRunningCountdown extends Countdown { public PreRunningCountdown() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java index 4200eb65..0a2e0e6c 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java @@ -25,7 +25,9 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; +import de.steamwar.linkage.Linked; +@Linked public class PreSchemCountdown extends Countdown { public PreSchemCountdown() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java index 9f3cb10d..74b81f93 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java @@ -25,7 +25,9 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; +import de.steamwar.linkage.Linked; +@Linked public class SpectateOverCountdown extends Countdown { public SpectateOverCountdown() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java index 3cfa7a87..8c2cb3f6 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java @@ -29,8 +29,8 @@ import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; -import org.bukkit.entity.EntityType; import org.bukkit.scheduler.BukkitTask; import java.util.Arrays; @@ -39,7 +39,7 @@ import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; - +@Linked public class HellsBells { public static final Random random = new Random(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/Meteor.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/Meteor.java index 3f3115d6..74b4cffe 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/Meteor.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/Meteor.java @@ -29,6 +29,7 @@ import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Fireball; import org.bukkit.entity.LargeFireball; @@ -44,7 +45,7 @@ import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; - +@Linked public class Meteor implements Listener { public static final Random random = new Random(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/NoGravity.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/NoGravity.java index 12246f8e..4e3125ea 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/NoGravity.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/NoGravity.java @@ -22,11 +22,13 @@ package de.steamwar.fightsystem.event; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.linkage.Linked; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntitySpawnEvent; +@Linked public class NoGravity implements Listener { public NoGravity() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/PersistentDamage.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/PersistentDamage.java index 543eff9e..7b50a2c9 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/PersistentDamage.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/PersistentDamage.java @@ -28,10 +28,12 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.utils.WorldeditWrapper; import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicNode; import java.util.logging.Level; +@Linked public class PersistentDamage { public PersistentDamage() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/TNTDistributor.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/TNTDistributor.java index 8982bb3d..c19050ac 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/TNTDistributor.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/TNTDistributor.java @@ -23,9 +23,11 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +@Linked public class TNTDistributor { public TNTDistributor() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java index efcc16a3..0f6268b7 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java @@ -27,6 +27,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper; +import de.steamwar.linkage.Linked; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.World; @@ -39,6 +40,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +@Linked public class FightWorld extends StateDependent { @Getter diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java index 6b3df110..d80dd1ad 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java @@ -19,35 +19,18 @@ package de.steamwar.fightsystem.fight; -import de.steamwar.core.Core; -import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.commands.GUI; -import de.steamwar.fightsystem.listener.PersonalKitCreator; -import de.steamwar.fightsystem.states.FightState; -import de.steamwar.fightsystem.states.StateDependentListener; -import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.utils.ItemBuilder; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryOpenEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; import java.util.Collection; -import java.util.HashSet; import java.util.Objects; -import java.util.Set; import java.util.function.Consumer; public class HotbarKit extends Kit { @@ -58,10 +41,10 @@ public class HotbarKit extends Kit { SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).build(), GUI::joinRequest); } - private static final int HOTBAR_SIZE = 9; + protected static final int HOTBAR_SIZE = 9; private final String[] nameTags; - private final Consumer[] onClicks; + protected final Consumer[] onClicks; protected HotbarKit(String name, ItemStack[] inventory, ItemStack[] armor, Collection effects, String[] nameTags, Consumer[] onClicks) { super(name, inventory, armor, effects); @@ -94,45 +77,4 @@ public class HotbarKit extends Kit { } super.loadToPlayer(player); } - - public static class HotbarKitListener implements Listener { - - private static final Set clicked = new HashSet<>(); - - public HotbarKitListener() { - new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this); - new StateDependentTask(ArenaMode.AntiReplay, FightState.All, clicked::clear, 10, 10); - } - - @EventHandler - public void handlePlayerInteract(PlayerInteractEvent event) { - if(event.getAction() == Action.PHYSICAL || (Core.getVersion() > 8 && event.getHand() != EquipmentSlot.HAND)) - return; - - Player player = event.getPlayer(); - int slot = player.getInventory().getHeldItemSlot(); - click(player, slot, event); - } - - @EventHandler - public void onInventoryClick(InventoryClickEvent event) { - int slot = event.getSlot(); - if (slot < 0 || slot >= HOTBAR_SIZE) return; - - Player player = (Player) event.getWhoClicked(); - click(player, slot, event); - } - - private void click(Player player, int slot, Cancellable event) { - Kit activeKit = activeKits.get(player); - if(!(activeKit instanceof HotbarKit) || PersonalKitCreator.inKitCreator(player) || activeKit.getInventory()[slot] == null) - return; - - event.setCancelled(true); - if(!clicked.add(player)) - return; - - ((HotbarKit)activeKit).onClicks[slot].accept(player); - } - } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java new file mode 100644 index 00000000..a321a697 --- /dev/null +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java @@ -0,0 +1,81 @@ +/* + * 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.fightsystem.fight; + +import de.steamwar.core.Core; +import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.listener.PersonalKitCreator; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.states.StateDependentTask; +import de.steamwar.linkage.Linked; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.EquipmentSlot; + +import java.util.HashSet; +import java.util.Set; + +@Linked +public class HotbarKitListener implements Listener { + + private static final Set clicked = new HashSet<>(); + + public HotbarKitListener() { + new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this); + new StateDependentTask(ArenaMode.AntiReplay, FightState.All, clicked::clear, 10, 10); + } + + @EventHandler + public void handlePlayerInteract(PlayerInteractEvent event) { + if (event.getAction() == Action.PHYSICAL || (Core.getVersion() > 8 && event.getHand() != EquipmentSlot.HAND)) + return; + + Player player = event.getPlayer(); + int slot = player.getInventory().getHeldItemSlot(); + click(player, slot, event); + } + + @EventHandler + public void onInventoryClick(InventoryClickEvent event) { + int slot = event.getSlot(); + if (slot < 0 || slot >= HotbarKit.HOTBAR_SIZE) return; + + Player player = (Player) event.getWhoClicked(); + click(player, slot, event); + } + + private void click(Player player, int slot, Cancellable event) { + Kit activeKit = Kit.activeKits.get(player); + if (!(activeKit instanceof HotbarKit) || PersonalKitCreator.inKitCreator(player) || activeKit.getInventory()[slot] == null) + return; + + event.setCancelled(true); + if (!clicked.add(player)) + return; + + ((HotbarKit) activeKit).onClicks[slot].accept(player); + } +} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java index 4c0daa45..b3f846b6 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java @@ -29,6 +29,7 @@ import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentTask; +import de.steamwar.linkage.Linked; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -37,6 +38,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; +@Linked public class ArenaBorder implements Listener { private final Border spectatorBorder = new Border(Config.PlayerRegion, true, 5, "NO_ARENA_LEAVING", "ArenaBorder.spectatorBorder"); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java index 361b86b6..ff77d4ca 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.utils.WorldOfColorWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -32,6 +33,7 @@ import org.bukkit.entity.Projectile; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; +@Linked public class ArrowStopper { private static final Vector NULL_VECTOR = new Vector(0, 0, 0); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFadeListener.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFadeListener.java index 51b5b949..750bbe44 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFadeListener.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFadeListener.java @@ -3,11 +3,13 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockFadeEvent; +@Linked public class BlockFadeListener implements Listener { public BlockFadeListener() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockPlaceCollision.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockPlaceCollision.java index 7b3bf541..ac3c6fb5 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockPlaceCollision.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockPlaceCollision.java @@ -23,6 +23,7 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.FlatteningWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -30,6 +31,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; +@Linked public class BlockPlaceCollision implements Listener { public BlockPlaceCollision() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java index 827f46c9..5e1a0114 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java @@ -27,6 +27,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -34,6 +35,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import java.util.logging.Level; +@Linked public class Chat implements Listener { public Chat(){ diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java index f6efd8cc..8a413b4b 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; @@ -36,6 +37,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import java.util.logging.Level; +@Linked public class Check implements Listener { public Check() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java index d4bd10dc..4cbe464a 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java @@ -24,10 +24,12 @@ import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.core.Core; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.utils.CraftbukkitWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import java.io.*; +@Linked public class ClickAnalyzer { private static final PrintStream output; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyInventoryMovement.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyInventoryMovement.java index 6c7f71f8..746910e2 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyInventoryMovement.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyInventoryMovement.java @@ -23,12 +23,14 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.BountifulWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.player.PlayerPickupItemEvent; +@Linked public class DenyInventoryMovement implements Listener { public DenyInventoryMovement() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java index f494d0bc..21a5a063 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java @@ -25,6 +25,7 @@ import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -38,6 +39,7 @@ import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerKickEvent; +@Linked public class DenyWorldInteraction implements Listener { public DenyWorldInteraction() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/EntityDamage.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/EntityDamage.java index 18959b68..226375f0 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/EntityDamage.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/EntityDamage.java @@ -23,11 +23,13 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; +@Linked public class EntityDamage implements Listener { public EntityDamage() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java index 6630becb..3d7de932 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java @@ -26,6 +26,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -33,6 +34,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; +@Linked public class EventJoin implements Listener { public EventJoin() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java index 7194fdd6..7846d51e 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java @@ -25,6 +25,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.winconditions.Winconditions; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; @@ -34,6 +35,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import java.util.Objects; +@Linked public class InFightDamage implements Listener { public InFightDamage() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java index ad41d0a0..33b4cf78 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java @@ -23,6 +23,7 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -35,6 +36,7 @@ import java.util.Collections; import java.util.EnumSet; import java.util.Set; +@Linked public class InFightInventory implements Listener { private static final Set allowed = Collections.unmodifiableSet(EnumSet.of(Material.TNT, Material.AIR)); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java index 6ff538f4..14f020f7 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java @@ -26,6 +26,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.FightUI; import de.steamwar.fightsystem.utils.SWSound; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; @@ -36,6 +37,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import java.util.function.Consumer; +@Linked public class IngameDeath implements Listener { public IngameDeath() { 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 45121cf7..bf859d48 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/JoinRequestListener.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/JoinRequestListener.java @@ -29,6 +29,7 @@ import de.steamwar.fightsystem.fight.JoinRequest; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -38,6 +39,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; +@Linked public class JoinRequestListener implements Listener { public JoinRequestListener() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/LeaveableArena.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/LeaveableArena.java index 36a5a189..73daed41 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/LeaveableArena.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/LeaveableArena.java @@ -23,6 +23,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -35,6 +36,7 @@ import org.spigotmc.event.player.PlayerSpawnLocationEvent; import java.util.HashMap; import java.util.Map; +@Linked public class LeaveableArena implements Listener { private final Map spectatorsInArena = new HashMap<>(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java index 371ae75c..33e91888 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java @@ -24,11 +24,13 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; +@Linked public class NormalJoin implements Listener { public NormalJoin() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index 4976463c..c35eed95 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -29,6 +29,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.BountifulWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.GameMode; import org.bukkit.Material; @@ -54,6 +55,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.Team; +@Linked public class Permanent implements Listener { private static final Team spectatorTeam = FightScoreboard.getBukkitTeam("Spectator"); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java index f9a3b2d8..b003d84b 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java @@ -26,6 +26,7 @@ import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.Kit; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import de.steamwar.sql.PersonalKit; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; @@ -46,6 +47,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; +@Linked public class PersonalKitCreator implements Listener { private static final Map openKitCreators = new HashMap<>(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java index f02beeed..76c25640 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java @@ -31,6 +31,7 @@ import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.fightsystem.utils.Region; import de.steamwar.fightsystem.utils.WorldeditWrapper; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicNode; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -42,6 +43,7 @@ import org.bukkit.util.Vector; import java.util.HashSet; import java.util.Set; +@Linked public class PrepareSchem implements Listener { private final Set stationaryMovingPistons = new HashSet<>(); 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 117962eb..86b00816 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -39,6 +39,7 @@ import de.steamwar.fightsystem.utils.BountifulWrapper; import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.fightsystem.utils.SWSound; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -61,6 +62,7 @@ import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Predicate; +@Linked public class Recording implements Listener { private static final int AIR = 0; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/RunningWorldInteraction.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/RunningWorldInteraction.java index 7c00a9f1..e938b505 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/RunningWorldInteraction.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/RunningWorldInteraction.java @@ -25,12 +25,14 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; +@Linked public class RunningWorldInteraction implements Listener { public RunningWorldInteraction() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/SetupQuit.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/SetupQuit.java index 87d4b7e9..99755f8a 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/SetupQuit.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/SetupQuit.java @@ -24,11 +24,13 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; +@Linked public class SetupQuit implements Listener { public SetupQuit(){ diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java index 82057e92..08e60f43 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java @@ -23,11 +23,13 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; +@Linked public class Shutdown implements Listener { public Shutdown(){ diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Spectator.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Spectator.java index 399970ca..3fcb820b 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Spectator.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Spectator.java @@ -22,6 +22,7 @@ package de.steamwar.fightsystem.listener; import java.util.HashSet; import java.util.Set; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.Player; @@ -44,7 +45,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentTask; - +@Linked public class Spectator implements Listener { private final Set pseudoSpectator = new HashSet<>(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java index 13a512a4..554d51cb 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; import org.bukkit.entity.Player; @@ -31,6 +32,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; +@Linked public class TestJoin implements Listener { public TestJoin() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java index 847e647b..7f04d6db 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java @@ -27,10 +27,10 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.FlatteningWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; @@ -39,6 +39,7 @@ import org.bukkit.event.entity.EntitySpawnEvent; import java.util.HashMap; import java.util.Map; +@Linked public class WaterRemover implements Listener { private static final int MIN_Y = Config.BluePasteRegion.getMinY() + Config.WaterDepth; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java index 98933dd8..a80463e5 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java @@ -22,11 +22,13 @@ package de.steamwar.fightsystem.record; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; +import de.steamwar.linkage.Linked; import lombok.Getter; import java.io.*; import java.util.zip.GZIPOutputStream; +@Linked public class FileRecorder extends StateDependent implements Recorder { @Getter diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java index 55fef032..e17aa891 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java @@ -22,12 +22,14 @@ package de.steamwar.fightsystem.record; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import java.io.*; import java.net.Socket; import java.util.logging.Level; +@Linked public class LiveRecorder extends StateDependent implements Recorder { private DataOutputStream outputStream; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BungeeFightInfo.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BungeeFightInfo.java index 783917bb..dde1e3f2 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BungeeFightInfo.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BungeeFightInfo.java @@ -25,14 +25,15 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentTask; +import de.steamwar.linkage.Linked; import de.steamwar.network.NetworkSender; import de.steamwar.network.packets.common.FightInfoPacket; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; -import org.bukkit.entity.Player; import java.util.stream.Collectors; +@Linked public class BungeeFightInfo { public BungeeFightInfo() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/EnterHandler.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/EnterHandler.java index 042efba0..53c9ffb3 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/EnterHandler.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/EnterHandler.java @@ -24,9 +24,11 @@ import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.IStateDependent; +import de.steamwar.linkage.Linked; import java.util.Set; +@Linked public class EnterHandler implements IStateDependent { private static final Set enabled = FightState.Running; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java index 3d6c5cac..92ea3826 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java @@ -31,6 +31,7 @@ import de.steamwar.fightsystem.record.FileSource; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.winconditions.Wincondition; +import de.steamwar.linkage.Linked; import de.steamwar.network.NetworkSender; import de.steamwar.network.packets.common.FightEndsPacket; import de.steamwar.sql.EventFight; @@ -49,6 +50,7 @@ import java.util.stream.Collectors; import static de.steamwar.sql.Fight.create; import static de.steamwar.sql.Fight.markReplayAvailable; +@Linked public class FightStatistics { @Getter diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java index 122b6902..d17e535e 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java @@ -31,6 +31,7 @@ import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.winconditions.Wincondition; +import de.steamwar.linkage.Linked; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -42,6 +43,7 @@ import java.util.Queue; import java.util.logging.Level; import java.util.stream.Collectors; +@Linked public class FightUI { @Getter diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java index 77db2ff4..9f0252d2 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java @@ -24,7 +24,9 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; +import de.steamwar.linkage.Linked; +@Linked public class EventTeamOffWincondition extends Wincondition{ public EventTeamOffWincondition(){ diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java index 3b62affa..627a62cf 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java @@ -36,7 +36,7 @@ import java.util.stream.Collectors; public abstract class Wincondition { @Getter - protected static WinconditionPercent percentWincondition = null; + protected static WinconditionBasePercent percentWincondition = null; protected static StateDependentCountdown timeOverCountdown = null; @Getter protected static final List printableWinconditions = new ArrayList<>(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java index 8f2d73a3..c1dc6469 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java @@ -24,9 +24,11 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +@Linked public class WinconditionAllDead extends Wincondition implements Listener { public WinconditionAllDead(){ diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAmongUs.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAmongUs.java index 80572084..3e35177f 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAmongUs.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAmongUs.java @@ -26,6 +26,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -34,6 +35,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import java.util.*; +@Linked public class WinconditionAmongUs extends Wincondition implements Listener { private Map imposter = new HashMap<>(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBasePercent.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBasePercent.java new file mode 100644 index 00000000..e9cd3858 --- /dev/null +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBasePercent.java @@ -0,0 +1,133 @@ +/* + 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.fightsystem.winconditions; + +import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.fight.FightTeam; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.OneShotStateDependent; +import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.utils.Message; +import org.bukkit.entity.EntityType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityExplodeEvent; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + +public abstract class WinconditionBasePercent extends Wincondition implements PrintableWincondition { + + private final Map teamMap = new HashMap<>(); + + protected Consumer checkWin = team -> { + if (getPercent(team) >= Config.PercentWin) { + win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName()); + } + }; + protected Consumer postEnable = team -> {}; + + public WinconditionBasePercent(Winconditions wincondition, String windescription) { + super(windescription); + + if (Config.ActiveWinconditions.contains(wincondition)) { + printableWinconditions.add(this); + percentWincondition = this; + } + + Fight.teams().forEach(team -> new TeamPercent(team, wincondition)); + } + + public Message getDisplay(FightTeam team) { + return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(10000.0 * (1.0 - getPercent(team) / Config.PercentWin)) / 100.0)); + } + + public double getPercent(FightTeam team) { + return teamMap.get(team).getPercent(); + } + + protected int getTotalBlocks(FightTeam team) { + return teamMap.get(team).totalBlocks; + } + + protected int getCurrentBlocks(FightTeam team) { + return teamMap.get(team).currentBlocks; + } + + private class TeamPercent implements Listener { + private final FightTeam team; + + private int totalBlocks = 0; + private int currentBlocks = 0; + private boolean countAnyBlock = false; + + private TeamPercent(FightTeam team, Winconditions wincondition) { + this.team = team; + + new OneShotStateDependent(wincondition, FightState.Running, this::enable); + new StateDependentListener(wincondition, FightState.Running, this).register(); + teamMap.put(team, this); + } + + @EventHandler + public void onEntityExplode(EntityExplodeEvent event) { + if ( + event.getEntityType() == EntityType.FIREBALL || + !team.getExtendRegion().inRegion(event.getEntity().getLocation()) || + (!Config.PercentEntern && !Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft()) + ) { + return; + } + + event.blockList().forEach(block -> { + if (countAnyBlock || Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) { + currentBlocks--; + } + }); + + checkWin.accept(team); + } + + private void enable() { + totalBlocks = 0; + countAnyBlock = false; + team.getSchemRegion().forEach((x, y, z) -> { + if (Config.PercentBlocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.PercentBlocksWhitelist) + totalBlocks++; + }); + // Edge Case for DirtBlock + if (totalBlocks == 0) { + totalBlocks = team.getSchemRegion().volume(); + countAnyBlock = true; + } + currentBlocks = totalBlocks; + postEnable.accept(team); + } + + private double getPercent() { + if (currentBlocks >= totalBlocks) { + return 0; + } + return (totalBlocks - currentBlocks) * 100 / (double) totalBlocks; + } + } +} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java index 72c0873a..1d13d9bd 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionBlocks.java @@ -35,7 +35,7 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; -public class WinconditionBlocks extends Wincondition implements PrintableWincondition { +public abstract class WinconditionBlocks extends Wincondition implements PrintableWincondition { public static final Material PUMPKIN_LANTERN = SWItem.getMaterial("JACK_O_LANTERN"); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java index de0205ab..ada04ad2 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java @@ -25,9 +25,11 @@ import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.linkage.Linked; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +@Linked public class WinconditionCaptainDead extends Wincondition implements Listener { public WinconditionCaptainDead(){ diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionComparisonTimeout.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionComparisonTimeout.java index d3fa4c3c..6e576efd 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionComparisonTimeout.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionComparisonTimeout.java @@ -27,7 +27,7 @@ import de.steamwar.fightsystem.states.StateDependentCountdown; import java.util.function.ToDoubleFunction; -public class WinconditionComparisonTimeout extends Wincondition { +public abstract class WinconditionComparisonTimeout extends Wincondition { public WinconditionComparisonTimeout(Winconditions wincondition, String windescription, String winMessage, ToDoubleFunction evaluate) { super(windescription); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHearthRatioTimeout.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHearthRatioTimeout.java new file mode 100644 index 00000000..2dcd6c1b --- /dev/null +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHearthRatioTimeout.java @@ -0,0 +1,31 @@ +/* + * 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.fightsystem.winconditions; + +import de.steamwar.fightsystem.fight.FightTeam; +import de.steamwar.linkage.Linked; + +@Linked +public class WinconditionHearthRatioTimeout extends WinconditionComparisonTimeout { + + public WinconditionHearthRatioTimeout() { + super(Winconditions.HEART_RATIO_TIMEOUT, "HeartTimeout", "WIN_MORE_HEALTH", FightTeam::getHeartRatio); + } +} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java index f98bdecc..b14f5bef 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercent.java @@ -1,133 +1,30 @@ /* - 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 . -*/ + * 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.fightsystem.winconditions; -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.fight.Fight; -import de.steamwar.fightsystem.fight.FightTeam; -import de.steamwar.fightsystem.states.FightState; -import de.steamwar.fightsystem.states.OneShotStateDependent; -import de.steamwar.fightsystem.states.StateDependentListener; -import de.steamwar.fightsystem.utils.Message; -import org.bukkit.entity.EntityType; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; +import de.steamwar.linkage.Linked; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Consumer; +@Linked +public class WinconditionPercent extends WinconditionBasePercent { -public class WinconditionPercent extends Wincondition implements PrintableWincondition { - - private final Map teamMap = new HashMap<>(); - - protected Consumer checkWin = team -> { - if (getPercent(team) >= Config.PercentWin) { - win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName()); - } - }; - protected Consumer postEnable = team -> {}; - - public WinconditionPercent(Winconditions wincondition, String windescription) { - super(windescription); - - if (Config.ActiveWinconditions.contains(wincondition)) { - printableWinconditions.add(this); - percentWincondition = this; - } - - Fight.teams().forEach(team -> new TeamPercent(team, wincondition)); - } - - public Message getDisplay(FightTeam team) { - return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(10000.0 * (1.0 - getPercent(team) / Config.PercentWin)) / 100.0)); - } - - public double getPercent(FightTeam team) { - return teamMap.get(team).getPercent(); - } - - protected int getTotalBlocks(FightTeam team) { - return teamMap.get(team).totalBlocks; - } - - protected int getCurrentBlocks(FightTeam team) { - return teamMap.get(team).currentBlocks; - } - - private class TeamPercent implements Listener { - private final FightTeam team; - - private int totalBlocks = 0; - private int currentBlocks = 0; - private boolean countAnyBlock = false; - - private TeamPercent(FightTeam team, Winconditions wincondition) { - this.team = team; - - new OneShotStateDependent(wincondition, FightState.Running, this::enable); - new StateDependentListener(wincondition, FightState.Running, this).register(); - teamMap.put(team, this); - } - - @EventHandler - public void onEntityExplode(EntityExplodeEvent event) { - if ( - event.getEntityType() == EntityType.FIREBALL || - !team.getExtendRegion().inRegion(event.getEntity().getLocation()) || - (!Config.PercentEntern && !Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft()) - ) { - return; - } - - event.blockList().forEach(block -> { - if (countAnyBlock || Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) { - currentBlocks--; - } - }); - - checkWin.accept(team); - } - - private void enable() { - totalBlocks = 0; - countAnyBlock = false; - team.getSchemRegion().forEach((x, y, z) -> { - if (Config.PercentBlocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.PercentBlocksWhitelist) - totalBlocks++; - }); - // Edge Case for DirtBlock - if (totalBlocks == 0) { - totalBlocks = team.getSchemRegion().volume(); - countAnyBlock = true; - } - currentBlocks = totalBlocks; - postEnable.accept(team); - } - - private double getPercent() { - if (currentBlocks >= totalBlocks) { - return 0; - } - return (totalBlocks - currentBlocks) * 100 / (double) totalBlocks; - } + public WinconditionPercent() { + super(Winconditions.PERCENT_SYSTEM, "Percent"); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java new file mode 100644 index 00000000..6271dd92 --- /dev/null +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java @@ -0,0 +1,30 @@ +/* + * 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.fightsystem.winconditions; + +import de.steamwar.linkage.Linked; + +@Linked +public class WinconditionPercentTimeout extends WinconditionComparisonTimeout { + + public WinconditionPercentTimeout() { + super(Winconditions.PERCENT_TIMEOUT, "PercentTimeout", "WIN_LESS_DAMAGE", team -> -Wincondition.getPercentWincondition().getPercent(team)); + } +} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java index 028e893e..7c96a924 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java @@ -27,6 +27,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.Message; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -36,7 +37,8 @@ import org.bukkit.event.player.PlayerQuitEvent; import java.util.HashMap; import java.util.Map; -public class WinconditionPoints extends WinconditionPercent implements Listener { +@Linked +public class WinconditionPoints extends WinconditionBasePercent implements Listener { private final Map teamMap = new HashMap<>(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPointsAirShip.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPointsAirShip.java index 4f166a6d..8ef84838 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPointsAirShip.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPointsAirShip.java @@ -25,6 +25,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.utils.Message; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -35,7 +36,8 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -public class WinconditionPointsAirShip extends WinconditionPercent implements Listener { +@Linked +public class WinconditionPointsAirShip extends WinconditionBasePercent implements Listener { private double[] as = new double[] { 0.5, diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumkinTechKO.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumkinTechKO.java new file mode 100644 index 00000000..3d9a8b61 --- /dev/null +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumkinTechKO.java @@ -0,0 +1,30 @@ +/* + * 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.fightsystem.winconditions; + +import de.steamwar.linkage.Linked; + +@Linked +public class WinconditionPumkinTechKO extends WinconditionBlocks { + + public WinconditionPumkinTechKO() { + super(Winconditions.PUMPKIN_TECH_KO, "PumpkinTechKO", "BAR_CANNONS", block -> block.getType() == WinconditionBlocks.PUMPKIN_LANTERN); + } +} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java index 789b130f..5ca79609 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java @@ -30,6 +30,7 @@ import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; +import de.steamwar.linkage.Linked; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -39,6 +40,7 @@ import org.bukkit.event.entity.EntitySpawnEvent; import java.util.HashMap; import java.util.Map; +@Linked public class WinconditionTimeTechKO extends Wincondition implements Listener { private static final int TECH_KO_HALF_TIME = Config.TechKoTime/2; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimedDamageTechKO.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimedDamageTechKO.java index c561400c..7daa923a 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimedDamageTechKO.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimedDamageTechKO.java @@ -29,6 +29,7 @@ import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.Message; import de.steamwar.fightsystem.utils.SWSound; +import de.steamwar.linkage.Linked; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -37,6 +38,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import java.util.HashMap; import java.util.Map; +@Linked public class WinconditionTimedDamageTechKO extends Wincondition implements PrintableWincondition, Listener { private final Map countdowns = new HashMap<>(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java index 3207fee8..9a56195f 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java @@ -23,7 +23,9 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.countdown.TimeOverCountdown; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.linkage.Linked; +@Linked public class WinconditionTimeout extends Wincondition { public WinconditionTimeout() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java new file mode 100644 index 00000000..523fb06f --- /dev/null +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java @@ -0,0 +1,31 @@ +/* + * 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.fightsystem.winconditions; + +import de.steamwar.fightsystem.utils.FlatteningWrapper; +import de.steamwar.linkage.Linked; + +@Linked +public class WinconditionWaterTechKO extends WinconditionBlocks { + + public WinconditionWaterTechKO() { + super(Winconditions.WATER_TECH_KO, "WaterTechKO", "BAR_WATER", FlatteningWrapper.impl::isWater); + } +} From 33b606060a9e0a7a96d92d25dd840318805dd9ea Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 3 Oct 2025 13:23:33 +0200 Subject: [PATCH 05/11] Implement Linkage for LobbySystem --- LobbySystem/build.gradle.kts | 2 + LobbySystem/src/de/steamwar/lobby/Config.java | 2 +- .../src/de/steamwar/lobby/Fightserver.java | 2 +- .../de/steamwar/lobby/LobbyPacketHandler.java | 2 + .../src/de/steamwar/lobby/LobbySystem.java | 47 +++++++------------ .../de/steamwar/lobby/boatrace/BoatRace.java | 4 +- .../de/steamwar/lobby/command/FlyCommand.java | 2 + .../lobby/command/HologramCommand.java | 2 + .../steamwar/lobby/command/ModifyCommand.java | 4 +- .../steamwar/lobby/command/PortalCommand.java | 2 + .../steamwar/lobby/jumpandrun/JumpAndRun.java | 8 ++-- .../lobby/jumpandrun/JumpAndRunCommand.java | 2 + .../de/steamwar/lobby/listener/AlphaWall.java | 6 ++- .../lobby/listener/BasicListener.java | 31 ------------ .../lobby/listener/DoubleJumpListener.java | 5 +- .../lobby/listener/InventoryInteraction.java | 7 ++- .../lobby/listener/MapsRotateListener.java | 5 +- .../lobby/listener/PlayerSeatListener.java | 7 ++- .../steamwar/lobby/listener/PlayerSpawn.java | 7 ++- .../de/steamwar/lobby/listener/Portals.java | 5 +- .../lobby/listener/TeleporterListener.java | 5 +- .../lobby/listener/WorldInteraction.java | 7 +-- .../src/de/steamwar/lobby/map/CustomMap.java | 8 ++-- .../lobby/particle/ParticleListener.java | 4 +- .../lobby/particle/elements/Delayed.java | 2 +- .../particle/elements/RandomParticle.java | 2 +- .../steamwar/lobby/portal/CommandPortal.java | 2 +- .../lobby/portal/FightserverPortal.java | 2 +- .../steamwar/lobby/portal/TeleportPortal.java | 2 +- .../lobby/special/advent/AdventCommand.java | 2 + .../lobby/special/advent/AdventListener.java | 6 ++- .../lobby/special/advent/AdventsCalendar.java | 8 +--- .../lobby/special/advent/Present.java | 2 +- .../special/advent/PresentClickListener.java | 6 ++- .../lobby/special/easter/EggHunt.java | 2 +- .../de/steamwar/lobby/team/TeamPlayer.java | 8 ++-- .../de/steamwar/lobby/util/Leaderboard.java | 2 +- 37 files changed, 111 insertions(+), 111 deletions(-) delete mode 100644 LobbySystem/src/de/steamwar/lobby/listener/BasicListener.java diff --git a/LobbySystem/build.gradle.kts b/LobbySystem/build.gradle.kts index 8662545c..b36a4e79 100644 --- a/LobbySystem/build.gradle.kts +++ b/LobbySystem/build.gradle.kts @@ -27,6 +27,8 @@ java { } dependencies { + compileOnly(libs.classindex) + annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) diff --git a/LobbySystem/src/de/steamwar/lobby/Config.java b/LobbySystem/src/de/steamwar/lobby/Config.java index fd8eeb1c..596b6051 100644 --- a/LobbySystem/src/de/steamwar/lobby/Config.java +++ b/LobbySystem/src/de/steamwar/lobby/Config.java @@ -67,6 +67,6 @@ public class Config { yml.set("waitingHallSpawn", waitingHallSpawn); yml.set("jumpPoints", JumpAndRun.actualPoints); - LobbySystem.getPlugin().saveConfig(); + LobbySystem.getInstance().saveConfig(); } } diff --git a/LobbySystem/src/de/steamwar/lobby/Fightserver.java b/LobbySystem/src/de/steamwar/lobby/Fightserver.java index c1ee6f9e..a5b19995 100644 --- a/LobbySystem/src/de/steamwar/lobby/Fightserver.java +++ b/LobbySystem/src/de/steamwar/lobby/Fightserver.java @@ -33,7 +33,7 @@ public class Fightserver { private static final Map servers = new HashMap<>(); public static void init() { - Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), Fightserver::removeStopped, 20, 20); + Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), Fightserver::removeStopped, 20, 20); } public static void newFightInfo(FightInfoPacket in) { diff --git a/LobbySystem/src/de/steamwar/lobby/LobbyPacketHandler.java b/LobbySystem/src/de/steamwar/lobby/LobbyPacketHandler.java index eb9d5e7c..66638aae 100644 --- a/LobbySystem/src/de/steamwar/lobby/LobbyPacketHandler.java +++ b/LobbySystem/src/de/steamwar/lobby/LobbyPacketHandler.java @@ -19,6 +19,7 @@ package de.steamwar.lobby; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.jumpandrun.JumpAndRun; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.common.FightInfoPacket; @@ -30,6 +31,7 @@ import org.bukkit.event.player.PlayerTeleportEvent; import java.util.Objects; +@Linked public class LobbyPacketHandler extends PacketHandler { @Handler diff --git a/LobbySystem/src/de/steamwar/lobby/LobbySystem.java b/LobbySystem/src/de/steamwar/lobby/LobbySystem.java index 900d0941..29975e12 100644 --- a/LobbySystem/src/de/steamwar/lobby/LobbySystem.java +++ b/LobbySystem/src/de/steamwar/lobby/LobbySystem.java @@ -21,18 +21,12 @@ package de.steamwar.lobby; import de.steamwar.core.Core; import de.steamwar.entity.REntityServer; -import de.steamwar.lobby.command.FlyCommand; -import de.steamwar.lobby.command.HologramCommand; -import de.steamwar.lobby.command.ModifyCommand; -import de.steamwar.lobby.command.PortalCommand; -import de.steamwar.lobby.jumpandrun.JumpAndRun; -import de.steamwar.lobby.jumpandrun.JumpAndRunCommand; -import de.steamwar.lobby.listener.*; +import de.steamwar.linkage.AbstractLinker; +import de.steamwar.linkage.SpigotLinker; +import de.steamwar.lobby.listener.AlphaWall; import de.steamwar.lobby.map.CustomMap; -import de.steamwar.lobby.particle.ParticleListener; -import de.steamwar.lobby.special.advent.AdventsCalendar; -import de.steamwar.lobby.team.TeamPlayer; import de.steamwar.message.Message; +import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; public class LobbySystem extends JavaPlugin { @@ -43,6 +37,8 @@ public class LobbySystem extends JavaPlugin { private static REntityServer entityServer; private static REntityServer debugEntityServer; + private static SpigotLinker spigotLinker; + @Override public void onLoad() { plugin = this; @@ -56,43 +52,32 @@ public class LobbySystem extends JavaPlugin { Core.setServerName("Lobby"); CustomMap.init(); - Fightserver.init(); - new Portals(); - new PortalCommand(); - new HologramCommand(); - new FlyCommand(); - new ModifyCommand(); - - new JumpAndRun(); - new JumpAndRunCommand(); config = new Config(getConfig()); - new PlayerSpawn(); - new DoubleJumpListener(); - new ParticleListener(); - new InventoryInteraction(); - new WorldInteraction(); - new PlayerSeatListener(); - new MapsRotateListener(); - new TeleporterListener(); - new TeamPlayer(); + spigotLinker = new SpigotLinker(this, message); + try { + spigotLinker.link(); + } catch (AbstractLinker.LinkException e) { + e.printStackTrace(); + Bukkit.shutdown(); + return; + } // EggHunt.init(); - AdventsCalendar.init(); new AlphaWall(l -> l.getX() > 999, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getZ() > 892, AlphaWall.REFLECT_Z); new AlphaWall(l -> l.getZ() < 1794, AlphaWall.REFLECT_Z); - new LobbyPacketHandler().register(); } @Override public void onDisable() { + spigotLinker.unlink(); } - public static LobbySystem getPlugin() { + public static LobbySystem getInstance() { return plugin; } diff --git a/LobbySystem/src/de/steamwar/lobby/boatrace/BoatRace.java b/LobbySystem/src/de/steamwar/lobby/boatrace/BoatRace.java index 18e8db6c..031d8989 100644 --- a/LobbySystem/src/de/steamwar/lobby/boatrace/BoatRace.java +++ b/LobbySystem/src/de/steamwar/lobby/boatrace/BoatRace.java @@ -136,7 +136,7 @@ public class BoatRace implements EventListener, Listener { // boat.setBoatType(Boat.Type.values()[new Random().nextInt(Boat.Type.values().length)]); boat.addPassenger(player); bossBar = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SOLID); - task = Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { + task = Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> { hasBacked = false; if (nextCheckpoint != 0) { double kmh = lastDistance * 20 * 3.6; @@ -144,7 +144,7 @@ public class BoatRace implements EventListener, Listener { bossBar.setTitle(LobbySystem.getMessage().parse("BOAT_RACE_TITLE", player, nextCheckpoint, renderTime(System.currentTimeMillis() - startTime), (int) kmh)); } }, 0, 1); - Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance()); } private boolean inRegion(Player p, Location loc1, Location loc2) { diff --git a/LobbySystem/src/de/steamwar/lobby/command/FlyCommand.java b/LobbySystem/src/de/steamwar/lobby/command/FlyCommand.java index e16c6748..56863be7 100644 --- a/LobbySystem/src/de/steamwar/lobby/command/FlyCommand.java +++ b/LobbySystem/src/de/steamwar/lobby/command/FlyCommand.java @@ -20,11 +20,13 @@ package de.steamwar.lobby.command; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; import org.bukkit.entity.Player; +@Linked public class FlyCommand extends SWCommand { public FlyCommand() { diff --git a/LobbySystem/src/de/steamwar/lobby/command/HologramCommand.java b/LobbySystem/src/de/steamwar/lobby/command/HologramCommand.java index bfcc6b79..9166ffaa 100644 --- a/LobbySystem/src/de/steamwar/lobby/command/HologramCommand.java +++ b/LobbySystem/src/de/steamwar/lobby/command/HologramCommand.java @@ -20,10 +20,12 @@ package de.steamwar.lobby.command; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.display.Hologram; import org.bukkit.entity.Player; +@Linked public class HologramCommand extends SWCommand { public HologramCommand() { diff --git a/LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java b/LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java index d782112d..0233b007 100644 --- a/LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java +++ b/LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java @@ -20,6 +20,7 @@ package de.steamwar.lobby.command; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.listener.PlayerSpawn; import de.steamwar.sql.SteamwarUser; @@ -35,6 +36,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import java.util.HashSet; import java.util.Set; +@Linked public class ModifyCommand extends SWCommand implements Listener { private static final Set modifying = new HashSet<>(); @@ -45,7 +47,7 @@ public class ModifyCommand extends SWCommand implements Listener { public ModifyCommand() { super("modify"); - Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance()); } @Register diff --git a/LobbySystem/src/de/steamwar/lobby/command/PortalCommand.java b/LobbySystem/src/de/steamwar/lobby/command/PortalCommand.java index 637b99e3..7eb1036f 100644 --- a/LobbySystem/src/de/steamwar/lobby/command/PortalCommand.java +++ b/LobbySystem/src/de/steamwar/lobby/command/PortalCommand.java @@ -8,6 +8,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.RegionSelector; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.portal.*; import de.steamwar.sql.SteamwarUser; @@ -22,6 +23,7 @@ import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; +@Linked public class PortalCommand extends SWCommand { public PortalCommand() { diff --git a/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java b/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java index 68097463..4094a5b2 100644 --- a/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java +++ b/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java @@ -1,7 +1,7 @@ package de.steamwar.lobby.jumpandrun; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.listener.BasicListener; import de.steamwar.lobby.listener.PlayerSpawn; import de.steamwar.lobby.util.Leaderboard; import de.steamwar.sql.UserConfig; @@ -12,6 +12,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; @@ -22,7 +23,8 @@ import org.bukkit.util.Vector; import java.text.SimpleDateFormat; import java.util.*; -public class JumpAndRun extends BasicListener { +@Linked +public class JumpAndRun implements Listener { public static final String JUMP_AND_RUN_CONFIG = "jump_and_run"; @@ -40,7 +42,7 @@ public class JumpAndRun extends BasicListener { private static final Leaderboard LEADERBOARD = new Leaderboard(LobbySystem.getEntityServer(false), JUMP_AND_RUN_CONFIG, new Location(Bukkit.getWorlds().get(0), 2338.5, 42.5, 1231.5), 5); { - Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { + Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> { Set toReset = new HashSet<>(); CURRENT_POS.forEach((player, index) -> { if (System.currentTimeMillis() - CLICKED.getOrDefault(player, 0L) > 500) { diff --git a/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java b/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java index 7e15b7a8..4b18ef21 100644 --- a/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java +++ b/LobbySystem/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java @@ -1,6 +1,7 @@ package de.steamwar.lobby.jumpandrun; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import de.steamwar.sql.UserConfig; import org.bukkit.entity.Player; @@ -9,6 +10,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; +@Linked public class JumpAndRunCommand extends SWCommand { public JumpAndRunCommand() { diff --git a/LobbySystem/src/de/steamwar/lobby/listener/AlphaWall.java b/LobbySystem/src/de/steamwar/lobby/listener/AlphaWall.java index 502488b5..75ae1875 100644 --- a/LobbySystem/src/de/steamwar/lobby/listener/AlphaWall.java +++ b/LobbySystem/src/de/steamwar/lobby/listener/AlphaWall.java @@ -19,16 +19,19 @@ package de.steamwar.lobby.listener; +import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.command.ModifyCommand; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; import java.util.function.Function; -public class AlphaWall extends BasicListener { +public class AlphaWall implements Listener { public static float REFLECT_X = 360f; public static float REFLECT_Z = 180f; @@ -39,6 +42,7 @@ public class AlphaWall extends BasicListener { public AlphaWall(Function allowed, float reflect) { this.allowed = allowed; this.reflect = reflect; + Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance()); } @EventHandler diff --git a/LobbySystem/src/de/steamwar/lobby/listener/BasicListener.java b/LobbySystem/src/de/steamwar/lobby/listener/BasicListener.java deleted file mode 100644 index 1979b463..00000000 --- a/LobbySystem/src/de/steamwar/lobby/listener/BasicListener.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 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.lobby.listener; - -import de.steamwar.lobby.LobbySystem; -import org.bukkit.Bukkit; -import org.bukkit.event.Listener; - -public class BasicListener implements Listener { - - public BasicListener () { - Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin()); - } -} diff --git a/LobbySystem/src/de/steamwar/lobby/listener/DoubleJumpListener.java b/LobbySystem/src/de/steamwar/lobby/listener/DoubleJumpListener.java index ae554f64..47438002 100644 --- a/LobbySystem/src/de/steamwar/lobby/listener/DoubleJumpListener.java +++ b/LobbySystem/src/de/steamwar/lobby/listener/DoubleJumpListener.java @@ -19,6 +19,7 @@ package de.steamwar.lobby.listener; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.jumpandrun.JumpAndRun; import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.GameMode; @@ -26,12 +27,14 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.util.Vector; -public class DoubleJumpListener extends BasicListener { +@Linked +public class DoubleJumpListener implements Listener { double multiplyer = 1.4; diff --git a/LobbySystem/src/de/steamwar/lobby/listener/InventoryInteraction.java b/LobbySystem/src/de/steamwar/lobby/listener/InventoryInteraction.java index 14b28d97..c9086aba 100644 --- a/LobbySystem/src/de/steamwar/lobby/listener/InventoryInteraction.java +++ b/LobbySystem/src/de/steamwar/lobby/listener/InventoryInteraction.java @@ -19,6 +19,7 @@ package de.steamwar.lobby.listener; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.command.ModifyCommand; import de.steamwar.lobby.special.advent.AdventsCalendar; @@ -26,6 +27,7 @@ import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerDropItemEvent; @@ -34,7 +36,8 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerSwapHandItemsEvent; import org.bukkit.inventory.ItemStack; -public class InventoryInteraction extends BasicListener { +@Linked +public class InventoryInteraction implements Listener { @EventHandler public void handlePlayerInteract(PlayerInteractEvent event) { @@ -50,7 +53,7 @@ public class InventoryInteraction extends BasicListener { offset = 0; } - Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> { + Bukkit.getScheduler().runTaskLater(LobbySystem.getInstance(), () -> { event.getPlayer().getInventory().setItem(PlayerSpawn.FIREWORK_SLOT + offset, PlayerSpawn.FIREWORK); }, 1L); return; diff --git a/LobbySystem/src/de/steamwar/lobby/listener/MapsRotateListener.java b/LobbySystem/src/de/steamwar/lobby/listener/MapsRotateListener.java index e098da02..31825344 100644 --- a/LobbySystem/src/de/steamwar/lobby/listener/MapsRotateListener.java +++ b/LobbySystem/src/de/steamwar/lobby/listener/MapsRotateListener.java @@ -19,12 +19,15 @@ package de.steamwar.lobby.listener; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.command.ModifyCommand; import org.bukkit.entity.ItemFrame; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEntityEvent; -public class MapsRotateListener extends BasicListener { +@Linked +public class MapsRotateListener implements Listener { @EventHandler public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { diff --git a/LobbySystem/src/de/steamwar/lobby/listener/PlayerSeatListener.java b/LobbySystem/src/de/steamwar/lobby/listener/PlayerSeatListener.java index 45113f57..cd6e7919 100644 --- a/LobbySystem/src/de/steamwar/lobby/listener/PlayerSeatListener.java +++ b/LobbySystem/src/de/steamwar/lobby/listener/PlayerSeatListener.java @@ -19,6 +19,7 @@ package de.steamwar.lobby.listener; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import org.bukkit.*; import org.bukkit.block.data.Bisected; @@ -28,6 +29,7 @@ import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -37,7 +39,8 @@ import org.spigotmc.event.entity.EntityDismountEvent; import java.util.HashSet; import java.util.Set; -public class PlayerSeatListener extends BasicListener{ +@Linked +public class PlayerSeatListener implements Listener { public static final World world = Bukkit.getWorlds().get(0); @@ -51,7 +54,7 @@ public class PlayerSeatListener extends BasicListener{ arrow.setTicksLived(1); } } - }.runTaskTimer(LobbySystem.getPlugin(), 20*60,20*60); + }.runTaskTimer(LobbySystem.getInstance(), 20*60,20*60); } @EventHandler diff --git a/LobbySystem/src/de/steamwar/lobby/listener/PlayerSpawn.java b/LobbySystem/src/de/steamwar/lobby/listener/PlayerSpawn.java index 3ca809c1..a1734233 100644 --- a/LobbySystem/src/de/steamwar/lobby/listener/PlayerSpawn.java +++ b/LobbySystem/src/de/steamwar/lobby/listener/PlayerSpawn.java @@ -19,6 +19,7 @@ package de.steamwar.lobby.listener; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.boatrace.BoatRace; import de.steamwar.lobby.special.advent.AdventsCalendar; @@ -31,13 +32,15 @@ import org.bukkit.Material; import org.bukkit.entity.Player; 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.PlayerQuitEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -public class PlayerSpawn extends BasicListener { +@Linked +public class PlayerSpawn implements Listener { public static final int FIREWORK_SLOT = 2; public static final ItemStack FIREWORK = new ItemBuilder(Material.FIREWORK_ROCKET, 1).setDisplayName("§5Rakete").build(); @@ -62,7 +65,7 @@ public class PlayerSpawn extends BasicListener { LobbySystem.getEntityServer(false).addPlayer(player); BoatRace.boatNpcServer.addPlayer(player); - Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> NetworkSender.send(new ImALobbyPacket(), player), 20); + Bukkit.getScheduler().runTaskLater(LobbySystem.getInstance(), () -> NetworkSender.send(new ImALobbyPacket(), player), 20); } public static void giveItems(Player player) { diff --git a/LobbySystem/src/de/steamwar/lobby/listener/Portals.java b/LobbySystem/src/de/steamwar/lobby/listener/Portals.java index 576d17dc..9a0e07b4 100644 --- a/LobbySystem/src/de/steamwar/lobby/listener/Portals.java +++ b/LobbySystem/src/de/steamwar/lobby/listener/Portals.java @@ -19,10 +19,12 @@ package de.steamwar.lobby.listener; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.portal.Portal; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -32,7 +34,8 @@ import java.util.Deque; import java.util.HashMap; import java.util.Map; -public class Portals extends BasicListener { +@Linked +public class Portals implements Listener { private static final Map> portalStack = new HashMap<>(); diff --git a/LobbySystem/src/de/steamwar/lobby/listener/TeleporterListener.java b/LobbySystem/src/de/steamwar/lobby/listener/TeleporterListener.java index 28909e3c..f6a56116 100644 --- a/LobbySystem/src/de/steamwar/lobby/listener/TeleporterListener.java +++ b/LobbySystem/src/de/steamwar/lobby/listener/TeleporterListener.java @@ -21,13 +21,16 @@ package de.steamwar.lobby.listener; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.*; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerInteractEvent; -public class TeleporterListener extends BasicListener { +@Linked +public class TeleporterListener implements Listener { private static final World world = Bukkit.getWorlds().get(0); diff --git a/LobbySystem/src/de/steamwar/lobby/listener/WorldInteraction.java b/LobbySystem/src/de/steamwar/lobby/listener/WorldInteraction.java index b4c439fc..7a1f5108 100644 --- a/LobbySystem/src/de/steamwar/lobby/listener/WorldInteraction.java +++ b/LobbySystem/src/de/steamwar/lobby/listener/WorldInteraction.java @@ -19,12 +19,14 @@ package de.steamwar.lobby.listener; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.command.ModifyCommand; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPhysicsEvent; @@ -33,13 +35,12 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; -import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.player.PlayerArmorStandManipulateEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.server.MapInitializeEvent; import org.bukkit.util.Vector; -public class WorldInteraction extends BasicListener { +@Linked +public class WorldInteraction implements Listener { @EventHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { diff --git a/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java b/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java index 70053b87..6587ad2a 100644 --- a/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java +++ b/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java @@ -75,12 +75,12 @@ public class CustomMap implements Listener { itemFrameIndex.put(itemFrames[i], i); } - Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { + Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> { long modified = mapFile.lastModified(); if (modified > lastModified) { lastModified = modified; System.out.println("Updating Banner: " + mapFile.getName()); - Bukkit.getScheduler().runTaskAsynchronously(LobbySystem.getPlugin(), () -> { + Bukkit.getScheduler().runTaskAsynchronously(LobbySystem.getInstance(), () -> { try { run(); } catch (IOException e) { @@ -89,7 +89,7 @@ public class CustomMap implements Listener { }); } }, 200L, 200L); - Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance()); } @EventHandler @@ -169,7 +169,7 @@ public class CustomMap implements Listener { if (itemFrame == null) continue; int finalX = x; int finalY = y; - Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> { + Bukkit.getScheduler().runTaskLater(LobbySystem.getInstance(), () -> { ItemStack itemStack = itemFrame.getItem(); MapMeta mapMeta = (MapMeta) itemStack.getItemMeta(); MapView mapView = mapMeta.getMapView(); diff --git a/LobbySystem/src/de/steamwar/lobby/particle/ParticleListener.java b/LobbySystem/src/de/steamwar/lobby/particle/ParticleListener.java index 535ebd0b..932b7ef9 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/ParticleListener.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/ParticleListener.java @@ -19,6 +19,7 @@ package de.steamwar.lobby.particle; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.jumpandrun.JumpAndRun; import de.steamwar.lobby.listener.BasicListener; @@ -38,6 +39,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import java.util.HashMap; import java.util.Map; +@Linked public class ParticleListener extends BasicListener { private static final int PLAYER_MAX_SIZE = 20; @@ -48,7 +50,7 @@ public class ParticleListener extends BasicListener { private static Map movingPlayers = new HashMap<>(); public ParticleListener() { - Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { + Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> { movingPlayers.replaceAll((player, integer) -> integer - 1); movingPlayers.entrySet().removeIf(entry -> entry.getValue() <= 0); deg += 0.1; diff --git a/LobbySystem/src/de/steamwar/lobby/particle/elements/Delayed.java b/LobbySystem/src/de/steamwar/lobby/particle/elements/Delayed.java index 3fb9632e..862fb094 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/elements/Delayed.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/elements/Delayed.java @@ -28,7 +28,7 @@ public class Delayed extends DelegatingParticleElement { public Delayed(ParticleElement particleElement, int interval) { super(particleElement); - Bukkit.getPluginManager().registerEvents(delayedData, LobbySystem.getPlugin()); + Bukkit.getPluginManager().registerEvents(delayedData, LobbySystem.getInstance()); this.interval = interval; if (interval <= 0) { throw new IllegalArgumentException("Interval must be greater than 0"); diff --git a/LobbySystem/src/de/steamwar/lobby/particle/elements/RandomParticle.java b/LobbySystem/src/de/steamwar/lobby/particle/elements/RandomParticle.java index def3cabb..088ac457 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/elements/RandomParticle.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/elements/RandomParticle.java @@ -45,7 +45,7 @@ public class RandomParticle implements ParticleElement { throw new IllegalArgumentException("ParticleEnums must not be empty"); } this.randomData = new RandomData(particleEnums.length); - Bukkit.getPluginManager().registerEvents(randomData, LobbySystem.getPlugin()); + Bukkit.getPluginManager().registerEvents(randomData, LobbySystem.getInstance()); this.particleEnums = particleEnums; } diff --git a/LobbySystem/src/de/steamwar/lobby/portal/CommandPortal.java b/LobbySystem/src/de/steamwar/lobby/portal/CommandPortal.java index 36f7862a..f2a07f74 100644 --- a/LobbySystem/src/de/steamwar/lobby/portal/CommandPortal.java +++ b/LobbySystem/src/de/steamwar/lobby/portal/CommandPortal.java @@ -60,7 +60,7 @@ public class CommandPortal implements PortalHandler { String[] pieces = new String[stackIds.length]; while (maxId > 0) { if(!stack.hasNext()) { - LobbySystem.getPlugin().getLogger().log(Level.WARNING, "Stackportal with missing elements: " + player.getName() + " /" + command); + LobbySystem.getInstance().getLogger().log(Level.WARNING, "Stackportal with missing elements: " + player.getName() + " /" + command); player.sendMessage("§cEigentlich solltest du gerade gar nicht durch dieses Portal durchgehen können..."); return; } diff --git a/LobbySystem/src/de/steamwar/lobby/portal/FightserverPortal.java b/LobbySystem/src/de/steamwar/lobby/portal/FightserverPortal.java index 7d82cfdc..66031ec0 100644 --- a/LobbySystem/src/de/steamwar/lobby/portal/FightserverPortal.java +++ b/LobbySystem/src/de/steamwar/lobby/portal/FightserverPortal.java @@ -234,7 +234,7 @@ public class FightserverPortal implements PortalHandler, Comparable presentList = new ArrayList<>(); - private static File file = new File(LobbySystem.getPlugin().getDataFolder(), "presents.yml"); + private static File file = new File(LobbySystem.getInstance().getDataFolder(), "presents.yml"); private static FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file); - public static void init() { - new AdventCommand(); - new AdventListener(); - new PresentClickListener(); - } - static { for (int i = 1; i <= 31; i++) { if (i > 24 && i < 31) continue; diff --git a/LobbySystem/src/de/steamwar/lobby/special/advent/Present.java b/LobbySystem/src/de/steamwar/lobby/special/advent/Present.java index 86884708..780cfeec 100644 --- a/LobbySystem/src/de/steamwar/lobby/special/advent/Present.java +++ b/LobbySystem/src/de/steamwar/lobby/special/advent/Present.java @@ -115,7 +115,7 @@ public class Present { locations.add(point); } generate(); - Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> { + Bukkit.getScheduler().runTaskLater(LobbySystem.getInstance(), () -> { BlockData blockData = location.getBlock().getBlockData(); players.forEach(pl -> { if (pl == player) return; diff --git a/LobbySystem/src/de/steamwar/lobby/special/advent/PresentClickListener.java b/LobbySystem/src/de/steamwar/lobby/special/advent/PresentClickListener.java index 5e788980..79fa339f 100644 --- a/LobbySystem/src/de/steamwar/lobby/special/advent/PresentClickListener.java +++ b/LobbySystem/src/de/steamwar/lobby/special/advent/PresentClickListener.java @@ -19,18 +19,20 @@ package de.steamwar.lobby.special.advent; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.listener.BasicListener; import de.steamwar.sql.NodeMember; import de.steamwar.sql.SteamwarUser; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import java.time.LocalDate; -public class PresentClickListener extends BasicListener { +@Linked +public class PresentClickListener implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { diff --git a/LobbySystem/src/de/steamwar/lobby/special/easter/EggHunt.java b/LobbySystem/src/de/steamwar/lobby/special/easter/EggHunt.java index 68f58efc..87a4a2d6 100644 --- a/LobbySystem/src/de/steamwar/lobby/special/easter/EggHunt.java +++ b/LobbySystem/src/de/steamwar/lobby/special/easter/EggHunt.java @@ -22,7 +22,7 @@ public class EggHunt { } static { - File file = new File(LobbySystem.getPlugin().getDataFolder(), "eggs.yml"); + File file = new File(LobbySystem.getInstance().getDataFolder(), "eggs.yml"); FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file); fileConfiguration.getList("eggs") .forEach(o -> { diff --git a/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java b/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java index ce14aa04..eb51d1cf 100644 --- a/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java @@ -19,6 +19,7 @@ package de.steamwar.lobby.team; +import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.display.NPC; import de.steamwar.lobby.listener.BasicListener; @@ -44,6 +45,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.stream.Collectors; +@Linked public class TeamPlayer extends BasicListener { private static final List cuboids = new ArrayList<>(); @@ -80,8 +82,8 @@ public class TeamPlayer extends BasicListener { }); AtomicInteger count = new AtomicInteger(); - LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players"); - Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { + LobbySystem.getInstance().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players"); + Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> { Collection active = world.getEntitiesByClass(Villager.class); if (active.size() > entities.size()) { Set duplicates = new HashSet<>(); @@ -109,7 +111,7 @@ public class TeamPlayer extends BasicListener { removed.incrementAndGet(); }); if (added.get() > 0 || removed.get() > 0) { - LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + added.get() + " team players, removed " + removed.get() + " team players"); + LobbySystem.getInstance().getLogger().log(Level.INFO, "Loaded " + added.get() + " team players, removed " + removed.get() + " team players"); } } world.getEntitiesByClasses(Villager.class).forEach(entity -> { diff --git a/LobbySystem/src/de/steamwar/lobby/util/Leaderboard.java b/LobbySystem/src/de/steamwar/lobby/util/Leaderboard.java index f3182a1c..a8b84f07 100644 --- a/LobbySystem/src/de/steamwar/lobby/util/Leaderboard.java +++ b/LobbySystem/src/de/steamwar/lobby/util/Leaderboard.java @@ -39,7 +39,7 @@ public class Leaderboard implements Listener { this.configKey = configKey; this.location = location; this.best = best; - Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance()); update(); } From 91a5da9cd274384586c6d17d179063a7b8df5b32 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 3 Oct 2025 13:30:38 +0200 Subject: [PATCH 06/11] Implement Linkage for MissileWars --- MissileWars/build.gradle.kts | 2 + .../steamwar/misslewars/FightScoreboard.java | 2 + .../de/steamwar/misslewars/MissileWars.java | 51 ++++++------------- .../misslewars/commands/AcceptCommand.java | 2 + .../misslewars/commands/DeclineCommand.java | 2 + .../misslewars/commands/InviteCommand.java | 2 + .../misslewars/commands/SpectateCommand.java | 2 + .../misslewars/countdowns/EndCountdown.java | 2 + .../misslewars/countdowns/ItemCountdown.java | 2 + .../countdowns/WaitingCountdown.java | 2 + .../misslewars/listener/ArenaListener.java | 2 + .../misslewars/listener/BreakListener.java | 2 + .../misslewars/listener/ChatListener.java | 2 + .../listener/ConnectionListener.java | 2 + .../misslewars/listener/DeathListener.java | 2 + .../misslewars/listener/EndListener.java | 2 + .../misslewars/listener/FightListener.java | 2 + .../misslewars/listener/ItemListener.java | 2 + .../misslewars/listener/JoinListener.java | 2 + .../listener/PortalDestructListener.java | 2 + .../misslewars/listener/WaitingListener.java | 2 + .../listener/special/BarrierListener.java | 2 + .../listener/special/SpaceListener.java | 2 + 23 files changed, 60 insertions(+), 35 deletions(-) diff --git a/MissileWars/build.gradle.kts b/MissileWars/build.gradle.kts index f393ea31..36470f84 100644 --- a/MissileWars/build.gradle.kts +++ b/MissileWars/build.gradle.kts @@ -27,6 +27,8 @@ java { } dependencies { + compileOnly(libs.classindex) + annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) diff --git a/MissileWars/src/de/steamwar/misslewars/FightScoreboard.java b/MissileWars/src/de/steamwar/misslewars/FightScoreboard.java index ca217fe2..b8fe1aaa 100644 --- a/MissileWars/src/de/steamwar/misslewars/FightScoreboard.java +++ b/MissileWars/src/de/steamwar/misslewars/FightScoreboard.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars; +import de.steamwar.linkage.Linked; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.ScoreboardCallback; import org.bukkit.Bukkit; @@ -37,6 +38,7 @@ import java.util.Objects; /** * Modified Version of the Fight-System Scoreboard */ +@Linked class FightScoreboard implements Listener { public FightScoreboard() { diff --git a/MissileWars/src/de/steamwar/misslewars/MissileWars.java b/MissileWars/src/de/steamwar/misslewars/MissileWars.java index 2dab0597..c36dfbb3 100644 --- a/MissileWars/src/de/steamwar/misslewars/MissileWars.java +++ b/MissileWars/src/de/steamwar/misslewars/MissileWars.java @@ -19,18 +19,10 @@ package de.steamwar.misslewars; -import de.steamwar.misslewars.commands.AcceptCommand; -import de.steamwar.misslewars.commands.DeclineCommand; -import de.steamwar.misslewars.commands.InviteCommand; -import de.steamwar.misslewars.commands.SpectateCommand; -import de.steamwar.misslewars.countdowns.EndCountdown; -import de.steamwar.misslewars.countdowns.ItemCountdown; -import de.steamwar.misslewars.countdowns.WaitingCountdown; +import de.steamwar.linkage.AbstractLinker; +import de.steamwar.linkage.SpigotLinker; import de.steamwar.misslewars.items.CustomItem; import de.steamwar.misslewars.items.Missile; -import de.steamwar.misslewars.listener.*; -import de.steamwar.misslewars.listener.special.BarrierListener; -import de.steamwar.misslewars.listener.special.SpaceListener; import de.steamwar.misslewars.slowmo.SlowMoRunner; import de.steamwar.network.NetworkSender; import de.steamwar.network.packets.common.FightEndsPacket; @@ -63,37 +55,26 @@ public class MissileWars extends JavaPlugin { public void onEnable() { redTeam = new MWTeam(Config.TeamRedColor, Config.RedSpawn, Config.TeamRedName, Config.RedPortalZ); blueTeam = new MWTeam(Config.TeamBlueColor, Config.BlueSpawn, Config.TeamBlueName, Config.BluePortalZ); - new BreakListener(); - new DeathListener(); - new ItemListener(); - new ArenaListener(); - new ConnectionListener(); - new JoinListener(); - new EndListener(); - new PortalDestructListener(); - new WaitingListener(); - new FightListener(); - new ChatListener(); - new SpectateCommand(); - // Invitation Commands - new InviteCommand(); - new AcceptCommand(); - new DeclineCommand(); + SpigotLinker spigotLinker = new SpigotLinker(this, null) { + @Override + protected void linkObject(Object any) { + // No Init needed for MissileWars! + } + }; + try { + spigotLinker.link(); + } catch (AbstractLinker.LinkException e) { + e.printStackTrace(); + Bukkit.shutdown(); + return; + } - new WaitingCountdown(); - new ItemCountdown(); - new EndCountdown(); - - new FightScoreboard(); - Missile.init(); + Missile.init(); CustomItem.init(); StateDependent.setupState(fightState); - new BarrierListener(); - new SpaceListener(); - Bukkit.getScheduler().runTaskTimer(this, new FightInfoPacketSender(), 20, 20); Bukkit.getWorlds().forEach(world -> { diff --git a/MissileWars/src/de/steamwar/misslewars/commands/AcceptCommand.java b/MissileWars/src/de/steamwar/misslewars/commands/AcceptCommand.java index 60b4b056..f2cb1069 100644 --- a/MissileWars/src/de/steamwar/misslewars/commands/AcceptCommand.java +++ b/MissileWars/src/de/steamwar/misslewars/commands/AcceptCommand.java @@ -22,12 +22,14 @@ package de.steamwar.misslewars.commands; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MissileWars; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class AcceptCommand extends SWCommand { public AcceptCommand() { diff --git a/MissileWars/src/de/steamwar/misslewars/commands/DeclineCommand.java b/MissileWars/src/de/steamwar/misslewars/commands/DeclineCommand.java index f0df4aa9..0e0742a2 100644 --- a/MissileWars/src/de/steamwar/misslewars/commands/DeclineCommand.java +++ b/MissileWars/src/de/steamwar/misslewars/commands/DeclineCommand.java @@ -22,12 +22,14 @@ package de.steamwar.misslewars.commands; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MissileWars; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class DeclineCommand extends SWCommand { public DeclineCommand() { diff --git a/MissileWars/src/de/steamwar/misslewars/commands/InviteCommand.java b/MissileWars/src/de/steamwar/misslewars/commands/InviteCommand.java index b0925723..954a1a34 100644 --- a/MissileWars/src/de/steamwar/misslewars/commands/InviteCommand.java +++ b/MissileWars/src/de/steamwar/misslewars/commands/InviteCommand.java @@ -24,6 +24,7 @@ import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MissileWars; @@ -34,6 +35,7 @@ import org.bukkit.entity.Player; import java.util.Collection; import java.util.stream.Collectors; +@Linked public class InviteCommand extends SWCommand { public InviteCommand() { diff --git a/MissileWars/src/de/steamwar/misslewars/commands/SpectateCommand.java b/MissileWars/src/de/steamwar/misslewars/commands/SpectateCommand.java index f70fb063..19c51172 100644 --- a/MissileWars/src/de/steamwar/misslewars/commands/SpectateCommand.java +++ b/MissileWars/src/de/steamwar/misslewars/commands/SpectateCommand.java @@ -22,6 +22,7 @@ package de.steamwar.misslewars.commands; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MissileWars; @@ -29,6 +30,7 @@ import org.bukkit.GameMode; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +@Linked public class SpectateCommand extends SWCommand { public SpectateCommand() { diff --git a/MissileWars/src/de/steamwar/misslewars/countdowns/EndCountdown.java b/MissileWars/src/de/steamwar/misslewars/countdowns/EndCountdown.java index f2d3183b..5a1dc8d1 100644 --- a/MissileWars/src/de/steamwar/misslewars/countdowns/EndCountdown.java +++ b/MissileWars/src/de/steamwar/misslewars/countdowns/EndCountdown.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.countdowns; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.*; import de.steamwar.misslewars.listener.JoinListener; import org.bukkit.Bukkit; @@ -26,6 +27,7 @@ import org.bukkit.scheduler.BukkitTask; import java.util.EnumSet; +@Linked public class EndCountdown extends StateDependent { private BukkitTask task; diff --git a/MissileWars/src/de/steamwar/misslewars/countdowns/ItemCountdown.java b/MissileWars/src/de/steamwar/misslewars/countdowns/ItemCountdown.java index 5270934d..ef66b733 100644 --- a/MissileWars/src/de/steamwar/misslewars/countdowns/ItemCountdown.java +++ b/MissileWars/src/de/steamwar/misslewars/countdowns/ItemCountdown.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.countdowns; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MissileWars; @@ -30,6 +31,7 @@ import org.bukkit.scheduler.BukkitTask; import java.util.EnumSet; +@Linked public class ItemCountdown extends StateDependent { private BukkitTask task; diff --git a/MissileWars/src/de/steamwar/misslewars/countdowns/WaitingCountdown.java b/MissileWars/src/de/steamwar/misslewars/countdowns/WaitingCountdown.java index 57c85f77..3c4b8ddc 100644 --- a/MissileWars/src/de/steamwar/misslewars/countdowns/WaitingCountdown.java +++ b/MissileWars/src/de/steamwar/misslewars/countdowns/WaitingCountdown.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.countdowns; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MissileWars; @@ -28,6 +29,7 @@ import org.bukkit.scheduler.BukkitTask; import java.util.EnumSet; +@Linked public class WaitingCountdown extends StateDependent { private BukkitTask task; diff --git a/MissileWars/src/de/steamwar/misslewars/listener/ArenaListener.java b/MissileWars/src/de/steamwar/misslewars/listener/ArenaListener.java index 4d7a7ecc..4efff8e4 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/ArenaListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/ArenaListener.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MWTeam; @@ -40,6 +41,7 @@ import java.util.EnumSet; import java.util.Map; import java.util.Objects; +@Linked public class ArenaListener extends BasicListener { public ArenaListener() { diff --git a/MissileWars/src/de/steamwar/misslewars/listener/BreakListener.java b/MissileWars/src/de/steamwar/misslewars/listener/BreakListener.java index bbaf1a65..fae3c8c3 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/BreakListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/BreakListener.java @@ -21,12 +21,14 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.FightState; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; import java.util.EnumSet; +@Linked public class BreakListener extends BasicListener { public BreakListener() { diff --git a/MissileWars/src/de/steamwar/misslewars/listener/ChatListener.java b/MissileWars/src/de/steamwar/misslewars/listener/ChatListener.java index 3e039b7b..f2077032 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/ChatListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/ChatListener.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MissileWars; @@ -29,6 +30,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import java.util.EnumSet; +@Linked public class ChatListener extends BasicListener { public ChatListener() { diff --git a/MissileWars/src/de/steamwar/misslewars/listener/ConnectionListener.java b/MissileWars/src/de/steamwar/misslewars/listener/ConnectionListener.java index dab36fa4..9663dbbe 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/ConnectionListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/ConnectionListener.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MWTeam; @@ -32,6 +33,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import java.util.EnumSet; +@Linked public class ConnectionListener extends BasicListener{ public ConnectionListener(){ diff --git a/MissileWars/src/de/steamwar/misslewars/listener/DeathListener.java b/MissileWars/src/de/steamwar/misslewars/listener/DeathListener.java index 5e77523a..1f3008e9 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/DeathListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/DeathListener.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MissileWars; @@ -38,6 +39,7 @@ import java.util.EnumSet; import java.util.HashSet; import java.util.Set; +@Linked public class DeathListener extends BasicListener { private static final Vector ZERO = new Vector(0, 0, 0); diff --git a/MissileWars/src/de/steamwar/misslewars/listener/EndListener.java b/MissileWars/src/de/steamwar/misslewars/listener/EndListener.java index 14833544..36121665 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/EndListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/EndListener.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.FightState; import org.bukkit.GameMode; import org.bukkit.event.EventHandler; @@ -26,6 +27,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import java.util.EnumSet; +@Linked public class EndListener extends BasicListener { public EndListener(){ diff --git a/MissileWars/src/de/steamwar/misslewars/listener/FightListener.java b/MissileWars/src/de/steamwar/misslewars/listener/FightListener.java index 7ed369f8..6ce9aaca 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/FightListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/FightListener.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MissileWars; import org.bukkit.entity.Player; @@ -27,6 +28,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import java.util.EnumSet; +@Linked public class FightListener extends BasicListener { public FightListener() { diff --git a/MissileWars/src/de/steamwar/misslewars/listener/ItemListener.java b/MissileWars/src/de/steamwar/misslewars/listener/ItemListener.java index 4856dc17..4af2411c 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/ItemListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/ItemListener.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MissileWars; @@ -39,6 +40,7 @@ import java.util.EnumSet; import java.util.HashSet; import java.util.Set; +@Linked public class ItemListener extends BasicListener { private Set RED_ITEMS = new HashSet<>(); diff --git a/MissileWars/src/de/steamwar/misslewars/listener/JoinListener.java b/MissileWars/src/de/steamwar/misslewars/listener/JoinListener.java index 5947da8f..4f56cacb 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/JoinListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/JoinListener.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MissileWars; @@ -30,6 +31,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import java.util.EnumSet; +@Linked public class JoinListener extends BasicListener { public JoinListener(){ diff --git a/MissileWars/src/de/steamwar/misslewars/listener/PortalDestructListener.java b/MissileWars/src/de/steamwar/misslewars/listener/PortalDestructListener.java index c235ff35..056b7259 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/PortalDestructListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/PortalDestructListener.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MissileWars; @@ -31,6 +32,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import java.util.EnumSet; +@Linked public class PortalDestructListener extends BasicListener { public PortalDestructListener(){ diff --git a/MissileWars/src/de/steamwar/misslewars/listener/WaitingListener.java b/MissileWars/src/de/steamwar/misslewars/listener/WaitingListener.java index 1180edc3..1d9688b3 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/WaitingListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/WaitingListener.java @@ -19,6 +19,7 @@ package de.steamwar.misslewars.listener; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.FightState; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; @@ -27,6 +28,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import java.util.EnumSet; +@Linked public class WaitingListener extends BasicListener { public WaitingListener() { super(EnumSet.of(FightState.WAITING)); diff --git a/MissileWars/src/de/steamwar/misslewars/listener/special/BarrierListener.java b/MissileWars/src/de/steamwar/misslewars/listener/special/BarrierListener.java index 5220778c..e4ab3cf4 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/special/BarrierListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/special/BarrierListener.java @@ -21,6 +21,7 @@ package de.steamwar.misslewars.listener.special; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.listener.BasicListener; @@ -31,6 +32,7 @@ import org.bukkit.event.block.BlockPhysicsEvent; import java.util.EnumSet; +@Linked public class BarrierListener extends BasicListener { public BarrierListener() { diff --git a/MissileWars/src/de/steamwar/misslewars/listener/special/SpaceListener.java b/MissileWars/src/de/steamwar/misslewars/listener/special/SpaceListener.java index 654811ab..d6c06104 100644 --- a/MissileWars/src/de/steamwar/misslewars/listener/special/SpaceListener.java +++ b/MissileWars/src/de/steamwar/misslewars/listener/special/SpaceListener.java @@ -21,6 +21,7 @@ package de.steamwar.misslewars.listener.special; +import de.steamwar.linkage.Linked; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MissileWars; @@ -38,6 +39,7 @@ import org.bukkit.util.Vector; import java.util.EnumSet; +@Linked public class SpaceListener extends BasicListener { public SpaceListener() { From c7284dc7abd0c126f0107c70da429409bee8c41e Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 3 Oct 2025 13:33:31 +0200 Subject: [PATCH 07/11] Implement Linkage for SchematicSystem --- .../SchematicSystem_Core/build.gradle.kts | 2 ++ .../schematicsystem/SchematicSystem.java | 17 ++++----- .../commands/DownloadCommand.java | 2 ++ .../schematiccommand/SchematicCommand.java | 2 ++ .../SchematicCommandInitializer.java | 36 ------------------- .../schematiccommand/parts/CheckPart.java | 2 ++ .../schematiccommand/parts/MemberPart.java | 2 ++ .../schematiccommand/parts/ModifyPart.java | 2 ++ .../schematiccommand/parts/SavePart.java | 2 ++ .../schematiccommand/parts/SearchPart.java | 2 ++ .../schematiccommand/parts/ViewPart.java | 6 ++-- .../listener/PlayerEventListener.java | 2 ++ 12 files changed, 30 insertions(+), 47 deletions(-) delete mode 100644 SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandInitializer.java diff --git a/SchematicSystem/SchematicSystem_Core/build.gradle.kts b/SchematicSystem/SchematicSystem_Core/build.gradle.kts index df9415f2..36a0e019 100644 --- a/SchematicSystem/SchematicSystem_Core/build.gradle.kts +++ b/SchematicSystem/SchematicSystem_Core/build.gradle.kts @@ -22,6 +22,8 @@ plugins { } dependencies { + compileOnly(libs.classindex) + annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java index d6b94807..96267f9f 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java @@ -19,11 +19,9 @@ package de.steamwar.schematicsystem; +import de.steamwar.linkage.AbstractLinker; +import de.steamwar.linkage.SpigotLinker; import de.steamwar.message.Message; -import de.steamwar.schematicsystem.commands.DownloadCommand; -import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand; -import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandInitializer; -import de.steamwar.schematicsystem.listener.PlayerEventListener; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -36,10 +34,13 @@ public class SchematicSystem extends JavaPlugin { public void onEnable() { instance = this; - SchematicCommandInitializer.init(); - new DownloadCommand(); - - Bukkit.getPluginManager().registerEvents(new PlayerEventListener(), this); + SpigotLinker spigotLinker = new SpigotLinker(this, MESSAGE); + try { + spigotLinker.link(); + } catch (AbstractLinker.LinkException e) { + e.printStackTrace(); + Bukkit.shutdown(); + } } public static SchematicSystem getInstance() { diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java index 3e2f009d..f4fd1c29 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/DownloadCommand.java @@ -20,6 +20,7 @@ package de.steamwar.schematicsystem.commands; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils; import de.steamwar.sql.*; @@ -27,6 +28,7 @@ import org.bukkit.entity.Player; import java.io.IOException; +@Linked public class DownloadCommand extends SWCommand { public DownloadCommand() { super("download", "/download"); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java index b3ecf374..caccd1a5 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.*; import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.command.*; import de.steamwar.core.VersionDependent; +import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; @@ -34,6 +35,7 @@ import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCom import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*; @SuppressWarnings("unused") +@Linked public class SchematicCommand extends SWCommand { public SchematicCommand() { diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandInitializer.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandInitializer.java deleted file mode 100644 index 7245ead6..00000000 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommandInitializer.java +++ /dev/null @@ -1,36 +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.schematicsystem.commands.schematiccommand; - -import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.schematicsystem.commands.schematiccommand.parts.*; - -public class SchematicCommandInitializer { - - public static void init() { - new SchematicCommand().setMessage(SchematicSystem.MESSAGE); - new CheckPart().setMessage(SchematicSystem.MESSAGE); - new MemberPart().setMessage(SchematicSystem.MESSAGE); - new ModifyPart().setMessage(SchematicSystem.MESSAGE); - new SavePart().setMessage(SchematicSystem.MESSAGE); - new SearchPart().setMessage(SchematicSystem.MESSAGE); - new ViewPart().setMessage(SchematicSystem.MESSAGE); - } -} diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java index 9f23a795..246b990b 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java @@ -28,6 +28,7 @@ import com.sk89q.worldedit.session.ClipboardHolder; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; import de.steamwar.core.Core; +import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.autocheck.AutoChecker; @@ -44,6 +45,7 @@ import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCom import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand.impl; @AbstractSWCommand.PartOf(SchematicCommand.class) +@Linked public class CheckPart extends SWCommand { public CheckPart() { super(null); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/MemberPart.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/MemberPart.java index f7f09ac3..6d42c97a 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/MemberPart.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/MemberPart.java @@ -21,6 +21,7 @@ package de.steamwar.schematicsystem.commands.schematiccommand.parts; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand; import de.steamwar.sql.*; @@ -36,6 +37,7 @@ import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCom import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.mkdirs; @AbstractSWCommand.PartOf(SchematicCommand.class) +@Linked public class MemberPart extends SWCommand { public MemberPart() { super(null); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java index ab699d28..7fae8acd 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ModifyPart.java @@ -22,6 +22,7 @@ package de.steamwar.schematicsystem.commands.schematiccommand.parts; import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.SafeSchematicNode; import de.steamwar.schematicsystem.SchematicSystem; @@ -40,6 +41,7 @@ import java.io.IOException; import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*; @AbstractSWCommand.PartOf(SchematicCommand.class) +@Linked public class ModifyPart extends SWCommand { public ModifyPart() { super(null); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SavePart.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SavePart.java index d373f503..9b6f2cb6 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SavePart.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SavePart.java @@ -23,6 +23,7 @@ import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SchematicSelector; +import de.steamwar.linkage.Linked; import de.steamwar.providers.BauServerInfo; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand; @@ -36,6 +37,7 @@ import java.util.logging.Level; import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*; @AbstractSWCommand.PartOf(SchematicCommand.class) +@Linked public class SavePart extends SWCommand { public SavePart() { diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SearchPart.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SearchPart.java index 00dfd850..e3c698f2 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SearchPart.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/SearchPart.java @@ -20,6 +20,7 @@ package de.steamwar.schematicsystem.commands.schematiccommand.parts; import de.steamwar.command.*; +import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils; import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand; @@ -40,6 +41,7 @@ import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCom import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.getUser; @AbstractSWCommand.PartOf(SchematicCommand.class) +@Linked public class SearchPart extends SWCommand { private static final Map> searchMapper = new HashMap<>(); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ViewPart.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ViewPart.java index a22c1813..da51fdca 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ViewPart.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/ViewPart.java @@ -21,10 +21,11 @@ package de.steamwar.schematicsystem.commands.schematiccommand.parts; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.commands.schematiccommand.GUI; -import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils; import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand; +import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils; import de.steamwar.sql.NodeData; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; @@ -34,13 +35,12 @@ import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; -import java.time.format.DateTimeFormatter; -import java.time.format.FormatStyle; import java.util.List; import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*; @AbstractSWCommand.PartOf(SchematicCommand.class) +@Linked public class ViewPart extends SWCommand { public ViewPart() { super(null); diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/listener/PlayerEventListener.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/listener/PlayerEventListener.java index 3afb8ddd..84913014 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/listener/PlayerEventListener.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/listener/PlayerEventListener.java @@ -19,11 +19,13 @@ package de.steamwar.schematicsystem.listener; +import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; +@Linked public class PlayerEventListener implements Listener { @EventHandler From 383604ec9f8fb0c707913315f5c63bf92dfb76a3 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 3 Oct 2025 13:39:19 +0200 Subject: [PATCH 08/11] Implement Linkage for SpigotCore --- .../CaseInsensitiveCommandsListener.java | 2 + .../src/de/steamwar/core/Core.java | 37 ++++++++----------- .../de/steamwar/core/WorldEditRenderer.java | 4 ++ .../core/authlib/AuthlibInjector.java | 11 ++++-- .../de/steamwar/core/events/AntiNocom.java | 6 +-- .../steamwar/core/events/ChattingEvent.java | 2 + .../core/events/PlayerJoinedEvent.java | 3 +- .../steamwar/core/events/WorldLoadEvent.java | 2 + .../network/handlers/ServerDataHandler.java | 4 ++ .../src/de/steamwar/persistent/Subserver.java | 1 + 10 files changed, 44 insertions(+), 28 deletions(-) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/command/CaseInsensitiveCommandsListener.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/command/CaseInsensitiveCommandsListener.java index 05eafdbb..d12e8418 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/command/CaseInsensitiveCommandsListener.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/command/CaseInsensitiveCommandsListener.java @@ -20,6 +20,7 @@ package de.steamwar.command; import de.steamwar.core.Core; +import de.steamwar.linkage.Linked; import de.steamwar.providers.BauServerInfo; import de.steamwar.sql.AuditLog; import de.steamwar.sql.SteamwarUser; @@ -28,6 +29,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +@Linked public class CaseInsensitiveCommandsListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java index 91c05851..703d67e9 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java @@ -21,15 +21,14 @@ package de.steamwar.core; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.Reflection; -import de.steamwar.command.*; -import de.steamwar.core.authlib.AuthlibInjector; -import de.steamwar.core.events.AntiNocom; -import de.steamwar.core.events.ChattingEvent; -import de.steamwar.core.events.PlayerJoinedEvent; -import de.steamwar.core.events.WorldLoadEvent; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.SWTypeMapperCreator; +import de.steamwar.command.TabCompletionCache; +import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.AbstractLinker; +import de.steamwar.linkage.SpigotLinker; import de.steamwar.message.Message; import de.steamwar.network.NetworkReceiver; -import de.steamwar.network.handlers.ServerDataHandler; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.internal.Statement; @@ -37,7 +36,6 @@ import lombok.Getter; import lombok.Setter; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; import java.io.BufferedReader; @@ -95,9 +93,16 @@ public class Core extends JavaPlugin { } }); - for(Listener listener : new Listener[]{new CaseInsensitiveCommandsListener(), new PlayerJoinedEvent(), new ChattingEvent(), new WorldLoadEvent(), RecipeDiscoverWrapper.impl}) { - getServer().getPluginManager().registerEvents(listener, this); - } + SpigotLinker spigotLinker = new SpigotLinker(this, MESSAGE); + try { + spigotLinker.link(); + } catch (AbstractLinker.LinkException e) { + e.printStackTrace(); + Bukkit.shutdown(); + return; + } + + Bukkit.getServer().getPluginManager().registerEvents(RecipeDiscoverWrapper.impl, this); if(!Statement.productionDatabase()) { getServer().getPluginManager().registerEvents(LocaleChangeWrapper.impl, this); } @@ -105,18 +110,8 @@ public class Core extends JavaPlugin { getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new NetworkReceiver()); getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge"); - if(Core.getVersion() < 19) - AuthlibInjector.inject(); - TinyProtocol.init(); CheckpointUtils.signalHandler(); - new AntiNocom(); - - if(Core.getVersion() >= 19) - new ServerDataHandler(); - - if(Bukkit.getPluginManager().getPlugin("WorldEdit") != null) - new WorldEditRenderer(); Bukkit.getScheduler().runTaskTimer(this, TabCompletionCache::invalidateOldEntries, 20, 20); Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SteamwarUser::clear, 72000, 72000); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java index 79c54986..27f76cda 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java @@ -28,6 +28,8 @@ import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.world.World; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.PluginCheck; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -37,6 +39,8 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.player.*; import org.bukkit.util.Vector; +@Linked +@PluginCheck("WorldEdit") public class WorldEditRenderer implements Listener { private static WorldEditRenderer INSTANCE; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/AuthlibInjector.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/AuthlibInjector.java index b9c4011a..06fd942c 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/AuthlibInjector.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/AuthlibInjector.java @@ -22,11 +22,16 @@ package de.steamwar.core.authlib; import de.steamwar.Reflection; import com.mojang.authlib.GameProfileRepository; import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MaxVersion; +import de.steamwar.linkage.api.Enable; -public class AuthlibInjector { - private AuthlibInjector() {} +@Linked +@MaxVersion(18) +public class AuthlibInjector implements Enable { - public static void inject() { + @Override + public void enable() { Class minecraftServerClass = Reflection.getClass("net.minecraft.server.MinecraftServer"); Reflection.Field gameProfile = Reflection.getField(minecraftServerClass, GameProfileRepository.class, 0); Object minecraftServer = Reflection.getTypedMethod(minecraftServerClass, "getServer", minecraftServerClass).invoke(null); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java index 14f8badc..d3e5ea34 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java @@ -19,9 +19,10 @@ package de.steamwar.core.events; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; +import de.steamwar.Reflection; import de.steamwar.core.Core; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SWException; import de.steamwar.techhider.ProtocolUtils; import de.steamwar.techhider.TechHider; @@ -35,14 +36,13 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; +@Linked public class AntiNocom implements Listener { private final Map flags = new ConcurrentHashMap<>(); public AntiNocom() { - Bukkit.getServer().getPluginManager().registerEvents(this, Core.getInstance()); TinyProtocol.instance.addFilter(blockDig, this::onDig); - if(Core.getVersion() > 8) { registerUseItem(); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/ChattingEvent.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/ChattingEvent.java index 1de582f2..40b7412f 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/ChattingEvent.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/ChattingEvent.java @@ -20,11 +20,13 @@ package de.steamwar.core.events; import de.steamwar.core.Core; +import de.steamwar.linkage.Linked; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; +@Linked public class ChattingEvent implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/PlayerJoinedEvent.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/PlayerJoinedEvent.java index d3fd33a0..fc64cb27 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/PlayerJoinedEvent.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/PlayerJoinedEvent.java @@ -20,6 +20,7 @@ package de.steamwar.core.events; import de.steamwar.core.Core; +import de.steamwar.linkage.Linked; import de.steamwar.providers.BauServerInfo; import de.steamwar.sql.AuditLog; import de.steamwar.sql.SteamwarUser; @@ -32,7 +33,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; - +@Linked public class PlayerJoinedEvent implements Listener{ @EventHandler(priority = EventPriority.LOWEST) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/WorldLoadEvent.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/WorldLoadEvent.java index c28f998e..f7aba879 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/WorldLoadEvent.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/WorldLoadEvent.java @@ -19,10 +19,12 @@ package de.steamwar.core.events; +import de.steamwar.linkage.Linked; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.world.WorldInitEvent; +@Linked public class WorldLoadEvent implements Listener { @EventHandler diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java index 8941432b..a758892d 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java @@ -21,7 +21,11 @@ package de.steamwar.network.handlers; import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; +@Linked +@MinVersion(19) public class ServerDataHandler { public ServerDataHandler() { diff --git a/VelocityCore/Persistent/src/de/steamwar/persistent/Subserver.java b/VelocityCore/Persistent/src/de/steamwar/persistent/Subserver.java index 7351e83a..e63b2806 100644 --- a/VelocityCore/Persistent/src/de/steamwar/persistent/Subserver.java +++ b/VelocityCore/Persistent/src/de/steamwar/persistent/Subserver.java @@ -223,6 +223,7 @@ public class Subserver { start(process.getInputStream(), line -> line.contains("Checkpoint restored")); Thread.sleep(100); } else { + sendProgress(0); start(process.getInputStream(), line -> { if (line.contains("Loading libraries, please wait")) sendProgress(2); From d75c82dca54d604a6ca62517815a2ced738ce6c5 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 3 Oct 2025 13:46:39 +0200 Subject: [PATCH 09/11] Implement Linkage for Teamserver --- SpigotCore/SpigotCore_Main/build.gradle.kts | 2 ++ Teamserver/build.gradle.kts | 2 ++ .../src/de/steamwar/teamserver/Builder.java | 32 ++++++------------- .../command/ArenaconfigCommand.java | 2 ++ .../teamserver/command/FreezeCommand.java | 2 ++ .../teamserver/command/GamemodeCommand.java | 2 ++ .../teamserver/command/MaterialCommand.java | 2 ++ .../teamserver/command/SpeedCommand.java | 2 ++ .../listener/AxiomHandshakeListener.java | 4 +++ .../teamserver/listener/FreezeListener.java | 2 ++ .../teamserver/listener/PlayerChange.java | 2 ++ .../teamserver/listener/SelectAdjacent.java | 4 +++ 12 files changed, 35 insertions(+), 23 deletions(-) diff --git a/SpigotCore/SpigotCore_Main/build.gradle.kts b/SpigotCore/SpigotCore_Main/build.gradle.kts index cc941d8c..bc0ff779 100644 --- a/SpigotCore/SpigotCore_Main/build.gradle.kts +++ b/SpigotCore/SpigotCore_Main/build.gradle.kts @@ -26,6 +26,8 @@ tasks.compileJava { } dependencies { + compileOnly(libs.classindex) + annotationProcessor(libs.classindex) compileOnly(project(":CommonCore", "default")) compileOnly(project(":CommandFramework", "default")) compileOnly(project(":SpigotCore:CRIUDummy", "default")) diff --git a/Teamserver/build.gradle.kts b/Teamserver/build.gradle.kts index 44d3e49d..c0e5c933 100644 --- a/Teamserver/build.gradle.kts +++ b/Teamserver/build.gradle.kts @@ -22,6 +22,8 @@ plugins { } dependencies { + compileOnly(libs.classindex) + annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) compileOnly(libs.spigotapi) diff --git a/Teamserver/src/de/steamwar/teamserver/Builder.java b/Teamserver/src/de/steamwar/teamserver/Builder.java index 94dadf8a..3400ff98 100644 --- a/Teamserver/src/de/steamwar/teamserver/Builder.java +++ b/Teamserver/src/de/steamwar/teamserver/Builder.java @@ -19,14 +19,10 @@ package de.steamwar.teamserver; -import de.steamwar.core.Core; import de.steamwar.core.WorldEditRendererCUIEditor; +import de.steamwar.linkage.AbstractLinker; +import de.steamwar.linkage.SpigotLinker; import de.steamwar.message.Message; -import de.steamwar.teamserver.command.*; -import de.steamwar.teamserver.listener.AxiomHandshakeListener; -import de.steamwar.teamserver.listener.FreezeListener; -import de.steamwar.teamserver.listener.PlayerChange; -import de.steamwar.teamserver.listener.SelectAdjacent; import org.bukkit.Bukkit; import org.bukkit.GameRule; import org.bukkit.plugin.java.JavaPlugin; @@ -45,27 +41,17 @@ public final class Builder extends JavaPlugin { MESSAGE = new Message("de.steamwar.teamserver.Teamserver", getClassLoader()); - new GamemodeCommand(); - new SpeedCommand(); - new FreezeCommand(); - new ArenaconfigCommand(); - - if (Bukkit.getPluginManager().getPlugin("AxiomPaper") != null) { - Bukkit.getPluginManager().registerEvents(new AxiomHandshakeListener(), this); + SpigotLinker spigotLinker = new SpigotLinker(this, MESSAGE); + try { + spigotLinker.link(); + } catch (AbstractLinker.LinkException e) { + e.printStackTrace(); + Bukkit.shutdown(); + return; } - Bukkit.getPluginManager().registerEvents(new PlayerChange(), this); - Bukkit.getPluginManager().registerEvents(new FreezeListener(), this); - - MaterialCommand materialCommand = new MaterialCommand(); - Bukkit.getPluginManager().registerEvents(materialCommand, this); - Bukkit.getWorlds().get(0).setGameRule(GameRule.REDUCED_DEBUG_INFO, false); new WorldEditRendererCUIEditor(); - - if (Core.getVersion() >= 20) { - Bukkit.getPluginManager().registerEvents(new SelectAdjacent(), this); - } } @Override diff --git a/Teamserver/src/de/steamwar/teamserver/command/ArenaconfigCommand.java b/Teamserver/src/de/steamwar/teamserver/command/ArenaconfigCommand.java index 6851610c..23d7fa4e 100644 --- a/Teamserver/src/de/steamwar/teamserver/command/ArenaconfigCommand.java +++ b/Teamserver/src/de/steamwar/teamserver/command/ArenaconfigCommand.java @@ -26,6 +26,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.RegionSelector; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.teamserver.Builder; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; @@ -34,6 +35,7 @@ import org.bukkit.entity.Player; import java.io.File; import java.io.IOException; +@Linked public class ArenaconfigCommand extends SWCommand { public ArenaconfigCommand() { diff --git a/Teamserver/src/de/steamwar/teamserver/command/FreezeCommand.java b/Teamserver/src/de/steamwar/teamserver/command/FreezeCommand.java index 814069c4..91692877 100644 --- a/Teamserver/src/de/steamwar/teamserver/command/FreezeCommand.java +++ b/Teamserver/src/de/steamwar/teamserver/command/FreezeCommand.java @@ -20,12 +20,14 @@ package de.steamwar.teamserver.command; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.teamserver.Builder; import de.steamwar.teamserver.listener.FreezeListener; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +@Linked public class FreezeCommand extends SWCommand { public FreezeCommand() { diff --git a/Teamserver/src/de/steamwar/teamserver/command/GamemodeCommand.java b/Teamserver/src/de/steamwar/teamserver/command/GamemodeCommand.java index ed4fc4ff..93b35455 100644 --- a/Teamserver/src/de/steamwar/teamserver/command/GamemodeCommand.java +++ b/Teamserver/src/de/steamwar/teamserver/command/GamemodeCommand.java @@ -20,9 +20,11 @@ package de.steamwar.teamserver.command; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.GameMode; import org.bukkit.entity.Player; +@Linked public class GamemodeCommand extends SWCommand { public GamemodeCommand() { diff --git a/Teamserver/src/de/steamwar/teamserver/command/MaterialCommand.java b/Teamserver/src/de/steamwar/teamserver/command/MaterialCommand.java index 808a5469..13c26699 100644 --- a/Teamserver/src/de/steamwar/teamserver/command/MaterialCommand.java +++ b/Teamserver/src/de/steamwar/teamserver/command/MaterialCommand.java @@ -25,6 +25,7 @@ import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.linkage.Linked; import de.steamwar.teamserver.Builder; import org.bukkit.Material; import org.bukkit.block.data.BlockData; @@ -41,6 +42,7 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; +@Linked public class MaterialCommand extends SWCommand implements Listener { public MaterialCommand() { diff --git a/Teamserver/src/de/steamwar/teamserver/command/SpeedCommand.java b/Teamserver/src/de/steamwar/teamserver/command/SpeedCommand.java index 412886fd..2b22626f 100644 --- a/Teamserver/src/de/steamwar/teamserver/command/SpeedCommand.java +++ b/Teamserver/src/de/steamwar/teamserver/command/SpeedCommand.java @@ -20,8 +20,10 @@ package de.steamwar.teamserver.command; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; +@Linked public class SpeedCommand extends SWCommand { public SpeedCommand() { diff --git a/Teamserver/src/de/steamwar/teamserver/listener/AxiomHandshakeListener.java b/Teamserver/src/de/steamwar/teamserver/listener/AxiomHandshakeListener.java index b68e6fcf..21fae69f 100644 --- a/Teamserver/src/de/steamwar/teamserver/listener/AxiomHandshakeListener.java +++ b/Teamserver/src/de/steamwar/teamserver/listener/AxiomHandshakeListener.java @@ -20,9 +20,13 @@ package de.steamwar.teamserver.listener; import com.moulberry.axiom.event.AxiomHandshakeEvent; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.PluginCheck; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +@Linked +@PluginCheck("AxiomPaper") public class AxiomHandshakeListener implements Listener { @EventHandler diff --git a/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java b/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java index 7d576d2f..575cb513 100644 --- a/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java +++ b/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java @@ -21,6 +21,7 @@ package de.steamwar.teamserver.listener; import de.steamwar.core.Core; import de.steamwar.core.TrickyTrialsWrapper; +import de.steamwar.linkage.Linked; import de.steamwar.teamserver.Builder; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; @@ -39,6 +40,7 @@ import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.player.PlayerInteractEvent; +@Linked public class FreezeListener implements Listener { public static boolean freeze = true; diff --git a/Teamserver/src/de/steamwar/teamserver/listener/PlayerChange.java b/Teamserver/src/de/steamwar/teamserver/listener/PlayerChange.java index 63016c00..71493f64 100644 --- a/Teamserver/src/de/steamwar/teamserver/listener/PlayerChange.java +++ b/Teamserver/src/de/steamwar/teamserver/listener/PlayerChange.java @@ -19,12 +19,14 @@ package de.steamwar.teamserver.listener; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +@Linked public class PlayerChange implements Listener { @EventHandler diff --git a/Teamserver/src/de/steamwar/teamserver/listener/SelectAdjacent.java b/Teamserver/src/de/steamwar/teamserver/listener/SelectAdjacent.java index 2fbebbf3..6a94f635 100644 --- a/Teamserver/src/de/steamwar/teamserver/listener/SelectAdjacent.java +++ b/Teamserver/src/de/steamwar/teamserver/listener/SelectAdjacent.java @@ -25,6 +25,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.world.World; import de.steamwar.core.WorldEditRenderer; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; import de.steamwar.teamserver.Builder; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -43,6 +45,8 @@ import org.bukkit.util.Vector; import java.util.*; import java.util.function.Predicate; +@Linked +@MinVersion(20) public class SelectAdjacent implements Listener { private Vector[] FACES = { From 9dabcfc9180d660acb0098408802eff2e033013e Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 3 Oct 2025 13:51:38 +0200 Subject: [PATCH 10/11] Implement Linkage for TowerRun --- .../de/steamwar/linkage/AbstractLinker.java | 8 +++-- TowerRun/build.gradle.kts | 2 ++ .../src/de/steamwar/towerrun/TowerRun.java | 36 ++++++++++--------- .../towerrun/commands/StartCommand.java | 7 ++-- .../towerrun/countdowns/EndCountdown.java | 9 +++-- .../towerrun/countdowns/GameCountdown.java | 2 ++ .../towerrun/countdowns/LobbyCountdown.java | 2 ++ .../towerrun/listener/GlobalListener.java | 2 ++ .../towerrun/listener/IngameListener.java | 2 ++ .../towerrun/listener/LobbyListener.java | 2 ++ .../towerrun/listener/NotLobbyListener.java | 2 ++ 11 files changed, 50 insertions(+), 24 deletions(-) diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java index 18e931ce..4d663920 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java @@ -27,6 +27,7 @@ import lombok.experimental.StandardException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -100,9 +101,12 @@ public abstract class AbstractLinker { instances.forEach((clazz, o) -> { for (Field field : clazz.getFields()) { if (field.getAnnotation(LinkedInstance.class) != null) { - System.out.println("Setting " + field.getName() + " to " + instances.get(field.getType())); try { - field.set(o, instances.get(field.getType())); + if (Modifier.isStatic(field.getModifiers())) { + field.set(null, instances.get(field.getType())); + } else { + field.set(o, instances.get(field.getType())); + } } catch (IllegalAccessException e) { throw new SecurityException(e.getMessage(), e); } diff --git a/TowerRun/build.gradle.kts b/TowerRun/build.gradle.kts index 8eacd66e..e3a6cf74 100644 --- a/TowerRun/build.gradle.kts +++ b/TowerRun/build.gradle.kts @@ -29,6 +29,8 @@ java { dependencies { annotationProcessor(libs.spigotannotations) compileOnly(libs.spigotannotations) + compileOnly(libs.classindex) + annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) diff --git a/TowerRun/src/de/steamwar/towerrun/TowerRun.java b/TowerRun/src/de/steamwar/towerrun/TowerRun.java index 4503c5da..440b156c 100644 --- a/TowerRun/src/de/steamwar/towerrun/TowerRun.java +++ b/TowerRun/src/de/steamwar/towerrun/TowerRun.java @@ -19,18 +19,14 @@ package de.steamwar.towerrun; +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.AbstractLinker; +import de.steamwar.linkage.LinkedInstance; +import de.steamwar.linkage.SpigotLinker; import de.steamwar.message.Message; -import de.steamwar.towerrun.commands.StartCommand; import de.steamwar.towerrun.config.WorldConfig; -import de.steamwar.towerrun.countdowns.EndCountdown; import de.steamwar.towerrun.countdowns.GameCountdown; -import de.steamwar.towerrun.countdowns.LobbyCountdown; -import de.steamwar.towerrun.game.TowerRunGame; import de.steamwar.towerrun.generator.TowerGenerator; -import de.steamwar.towerrun.listener.GlobalListener; -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; @@ -58,6 +54,7 @@ public class TowerRun extends JavaPlugin { private static TowerGenerator towerGenerator = null; @Getter + @LinkedInstance private static GameCountdown gameCountdown; @@ -70,14 +67,21 @@ public class TowerRun extends JavaPlugin { towerGenerator = new TowerGenerator(WorldConfig.TOWER_GENERATOR_CONFIG); } - new LobbyListener(); - new IngameListener(); - new GlobalListener(); - new NotLobbyListener(); - final LobbyCountdown lobbyCountdown = new LobbyCountdown(); - new EndCountdown(lobbyCountdown); - new StartCommand(lobbyCountdown); - gameCountdown = new GameCountdown(); + SpigotLinker spigotLinker = new SpigotLinker(this, message) { + @Override + protected void linkObject(Object any) { + if (any instanceof SWCommand) { + ((SWCommand) any).setMessage(message); + } + } + }; + try { + spigotLinker.link(); + } catch (AbstractLinker.LinkException e) { + e.printStackTrace(); + Bukkit.shutdown(); + return; + } Bukkit.getScheduler().runTaskTimer(this, new FightInfoPacketSender(), 20, 20); } diff --git a/TowerRun/src/de/steamwar/towerrun/commands/StartCommand.java b/TowerRun/src/de/steamwar/towerrun/commands/StartCommand.java index 262ffff6..dddb2954 100644 --- a/TowerRun/src/de/steamwar/towerrun/commands/StartCommand.java +++ b/TowerRun/src/de/steamwar/towerrun/commands/StartCommand.java @@ -21,18 +21,19 @@ package de.steamwar.towerrun.commands; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.countdowns.LobbyCountdown; import org.bukkit.entity.Player; +@Linked public class StartCommand extends SWCommand { - private final LobbyCountdown countdown; + private LobbyCountdown countdown; - public StartCommand(LobbyCountdown countdown) { + public StartCommand() { super("start", "skip"); - this.countdown = countdown; } @Register diff --git a/TowerRun/src/de/steamwar/towerrun/countdowns/EndCountdown.java b/TowerRun/src/de/steamwar/towerrun/countdowns/EndCountdown.java index 6d631e02..3eb32c7d 100644 --- a/TowerRun/src/de/steamwar/towerrun/countdowns/EndCountdown.java +++ b/TowerRun/src/de/steamwar/towerrun/countdowns/EndCountdown.java @@ -19,6 +19,8 @@ package de.steamwar.towerrun.countdowns; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.config.Config; import de.steamwar.towerrun.game.TowerRunGame; @@ -29,15 +31,16 @@ import org.bukkit.Sound; import java.util.EnumSet; import java.util.Objects; +@Linked public class EndCountdown extends Countdown { - private final LobbyCountdown lobbyCountdown; + @LinkedInstance + private LobbyCountdown lobbyCountdown; private static final boolean RESETS = Objects.requireNonNull(Bukkit.getWorlds().get(0).getWorldFolder().list((dir, name) -> name.equals("backup"))).length > 0; - public EndCountdown(LobbyCountdown lobbyCountdown) { + public EndCountdown() { super(EnumSet.of(GameStates.END)); - this.lobbyCountdown = lobbyCountdown; } @Override diff --git a/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java b/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java index b1d25110..26b69ed7 100644 --- a/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java +++ b/TowerRun/src/de/steamwar/towerrun/countdowns/GameCountdown.java @@ -19,6 +19,7 @@ package de.steamwar.towerrun.countdowns; +import de.steamwar.linkage.Linked; import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.config.Config; import de.steamwar.towerrun.game.TowerRunGame; @@ -26,6 +27,7 @@ import de.steamwar.towerrun.state.GameStates; import java.util.EnumSet; +@Linked public class GameCountdown extends Countdown { private long startTime = 0; diff --git a/TowerRun/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java b/TowerRun/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java index a655c4c3..4377a141 100644 --- a/TowerRun/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java +++ b/TowerRun/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java @@ -19,6 +19,7 @@ package de.steamwar.towerrun.countdowns; +import de.steamwar.linkage.Linked; import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.config.Config; import de.steamwar.towerrun.game.TowerRunGame; @@ -31,6 +32,7 @@ import org.bukkit.Sound; import java.util.EnumSet; @Getter +@Linked public class LobbyCountdown extends Countdown { @Setter diff --git a/TowerRun/src/de/steamwar/towerrun/listener/GlobalListener.java b/TowerRun/src/de/steamwar/towerrun/listener/GlobalListener.java index c20dd391..343bb97a 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/GlobalListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/GlobalListener.java @@ -19,6 +19,7 @@ package de.steamwar.towerrun.listener; +import de.steamwar.linkage.Linked; import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.game.TowerRunGame; @@ -36,6 +37,7 @@ import org.bukkit.event.player.*; import java.util.EnumSet; +@Linked public class GlobalListener extends GameStateBukkitListener implements Listener { public GlobalListener() { super(EnumSet.allOf(GameStates.class)); diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index bc74e57f..abb5d9db 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -20,6 +20,7 @@ package de.steamwar.towerrun.listener; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.config.Config; import de.steamwar.towerrun.config.WorldConfig; @@ -47,6 +48,7 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; +@Linked public class IngameListener extends GameStateBukkitListener { private int time = 0; diff --git a/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java b/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java index 0a4e4358..2b89a81c 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/LobbyListener.java @@ -19,6 +19,7 @@ package de.steamwar.towerrun.listener; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.config.Config; @@ -40,6 +41,7 @@ import org.bukkit.event.player.PlayerMoveEvent; import java.util.EnumSet; import java.util.HashMap; +@Linked public class LobbyListener extends GameStateBukkitListener { public LobbyListener() { super(EnumSet.of(GameStates.WAITING)); diff --git a/TowerRun/src/de/steamwar/towerrun/listener/NotLobbyListener.java b/TowerRun/src/de/steamwar/towerrun/listener/NotLobbyListener.java index 6bfb1623..752ed521 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/NotLobbyListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/NotLobbyListener.java @@ -19,6 +19,7 @@ package de.steamwar.towerrun.listener; +import de.steamwar.linkage.Linked; import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.state.GameStateBukkitListener; @@ -29,6 +30,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import java.util.EnumSet; +@Linked public class NotLobbyListener extends GameStateBukkitListener { public NotLobbyListener() { super(EnumSet.complementOf(EnumSet.of(GameStates.WAITING))); From b55c3d332efd6220f841d44bb8d833f689447742 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 23 Oct 2025 17:27:10 +0200 Subject: [PATCH 11/11] Fix build problems --- .../de/steamwar/lobby/particle/ParticleListener.java | 4 ++-- .../lobby/special/easter/EggClickListener.java | 9 +++++++-- .../steamwar/lobby/special/easter/EggHuntListener.java | 10 ++++++++-- LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java | 4 ++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/LobbySystem/src/de/steamwar/lobby/particle/ParticleListener.java b/LobbySystem/src/de/steamwar/lobby/particle/ParticleListener.java index 932b7ef9..1879d215 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/ParticleListener.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/ParticleListener.java @@ -22,7 +22,6 @@ package de.steamwar.lobby.particle; import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.jumpandrun.JumpAndRun; -import de.steamwar.lobby.listener.BasicListener; import de.steamwar.lobby.listener.PlayerSpawn; import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.sql.SteamwarUser; @@ -31,6 +30,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; @@ -40,7 +40,7 @@ import java.util.HashMap; import java.util.Map; @Linked -public class ParticleListener extends BasicListener { +public class ParticleListener implements Listener { private static final int PLAYER_MAX_SIZE = 20; private static final int SERVER_TEAM_MAX_SIZE = 40; diff --git a/LobbySystem/src/de/steamwar/lobby/special/easter/EggClickListener.java b/LobbySystem/src/de/steamwar/lobby/special/easter/EggClickListener.java index 5b25c44e..8d324146 100644 --- a/LobbySystem/src/de/steamwar/lobby/special/easter/EggClickListener.java +++ b/LobbySystem/src/de/steamwar/lobby/special/easter/EggClickListener.java @@ -1,18 +1,23 @@ package de.steamwar.lobby.special.easter; import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.listener.BasicListener; import de.steamwar.sql.UserConfig; +import org.bukkit.Bukkit; import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; -public class EggClickListener extends BasicListener { +public class EggClickListener implements Listener { + + public EggClickListener() { + Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance()); + } @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { diff --git a/LobbySystem/src/de/steamwar/lobby/special/easter/EggHuntListener.java b/LobbySystem/src/de/steamwar/lobby/special/easter/EggHuntListener.java index 92c903cf..00cb6ca1 100644 --- a/LobbySystem/src/de/steamwar/lobby/special/easter/EggHuntListener.java +++ b/LobbySystem/src/de/steamwar/lobby/special/easter/EggHuntListener.java @@ -1,15 +1,21 @@ package de.steamwar.lobby.special.easter; -import de.steamwar.lobby.listener.BasicListener; +import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.util.ItemBuilder; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; -public class EggHuntListener extends BasicListener { +public class EggHuntListener implements Listener { + + public EggHuntListener() { + Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance()); + } public static final int EASTER_EGG_SLOT = 8; public static final ItemStack EASTER_HUNT = new ItemBuilder(Material.DRAGON_EGG, 1).setDisplayName("§fEaster Hunt").build(); diff --git a/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java b/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java index eb51d1cf..db55aacb 100644 --- a/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java @@ -22,7 +22,6 @@ package de.steamwar.lobby.team; import de.steamwar.linkage.Linked; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.display.NPC; -import de.steamwar.lobby.listener.BasicListener; import de.steamwar.sql.SteamwarUser; import lombok.AllArgsConstructor; import org.bukkit.Bukkit; @@ -33,6 +32,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityInteractEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; @@ -46,7 +46,7 @@ import java.util.logging.Level; import java.util.stream.Collectors; @Linked -public class TeamPlayer extends BasicListener { +public class TeamPlayer implements Listener { private static final List cuboids = new ArrayList<>();