From 128d2d3378c4abf61aa4903b8ccd7a3cda607bc7 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sun, 24 Nov 2024 22:26:43 +0100 Subject: [PATCH 01/49] Should fix traces not being deleted --- .../bausystem/features/tracer/TraceManager.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java index 1f0c5140..213d5e8e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java @@ -142,17 +142,18 @@ public class TraceManager implements Listener { * * @param trace the trace to be removed */ - public boolean remove(Trace trace) { + public void remove(Trace trace) { Map traces = tracesByRegion.getOrDefault(trace.getRegion(), Collections.emptyMap()); Integer traceId = traces.entrySet().stream() .filter(entry -> entry.getValue() == trace) .map(Map.Entry::getKey) .findFirst() .orElse(null); - if (traceId == null) return false; + if (traceId == null) throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)"); traces.remove(traceId); trace.hide(); - return true; + trace.getMetadataSaveFile().delete(); + trace.getRecordsSaveFile().delete(); } /** @@ -171,8 +172,8 @@ public class TraceManager implements Listener { tracesByRegion.getOrDefault(region, new HashMap<>()) .forEach((i, trace) -> { if (trace.getRegion() != region) return; - trace.getMetadataSaveFile().deleteOnExit(); - trace.getRecordsSaveFile().deleteOnExit(); + trace.getMetadataSaveFile().delete(); + trace.getRecordsSaveFile().delete(); }); tracesByRegion.getOrDefault(region, new HashMap<>()).clear(); } From 16a5de7a8459a4da69894dce85e81bc72575b4ea Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 24 Nov 2024 23:14:10 +0100 Subject: [PATCH 02/49] Fix Permissions --- WebsiteBackend/src/de/steamwar/routes/Data.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebsiteBackend/src/de/steamwar/routes/Data.kt b/WebsiteBackend/src/de/steamwar/routes/Data.kt index 64039974..103fb044 100644 --- a/WebsiteBackend/src/de/steamwar/routes/Data.kt +++ b/WebsiteBackend/src/de/steamwar/routes/Data.kt @@ -73,7 +73,7 @@ fun Route.configureDataRoutes() { route("/admin") { install(SWPermissionCheck) { mustAuth = true - permission = UserPerm.PREFIX_MODERATOR + permission = UserPerm.MODERATION } get("/users") { call.respond(SteamwarUser.getAll().map { ResponseUser(it) }) From 0ca3ede280d82bb0fd270552ba583fb22618bb2c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 24 Nov 2024 23:26:18 +0100 Subject: [PATCH 03/49] Replace WorldEditSUI --- .../de/steamwar/core/WorldEditWrapper14.java | 17 ++- .../de/steamwar/core/WorldEditWrapper8.java | 29 ++++- .../src/de/steamwar/core/Core.java | 3 + .../de/steamwar/core/WorldEditRenderer.java | 116 ++++++++++++++++++ .../de/steamwar/core/WorldEditWrapper.java | 20 +-- 5 files changed, 171 insertions(+), 14 deletions(-) create mode 100644 SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java index 1b48b638..38ae351a 100644 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java @@ -52,7 +52,7 @@ import java.util.stream.Collectors; import static com.google.common.base.Preconditions.checkNotNull; -public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper { +public class WorldEditWrapper14 implements WorldEditWrapper { private static final ClipboardFormat SCHEMATIC = ClipboardFormats.findByAlias("schematic"); private static final ClipboardFormat SCHEM = ClipboardFormats.findByAlias("schem"); @@ -131,6 +131,21 @@ public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper { } } + @Override + public org.bukkit.util.Vector getOrigin(Clipboard clipboard) { + return new org.bukkit.util.Vector(clipboard.getOrigin().getX(), clipboard.getOrigin().getY(), clipboard.getOrigin().getZ()); + } + + @Override + public org.bukkit.util.Vector getMinimum(Region region) { + return new org.bukkit.util.Vector(region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); + } + + @Override + public org.bukkit.util.Vector getMaximum(Region region) { + return new org.bukkit.util.Vector(region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ()); + } + private static class MCEditSchematicReader extends NBTSchematicReader { private final NBTInputStream inputStream; diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java index 32f3faf7..e021ceed 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java @@ -23,7 +23,6 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Maps; import com.sk89q.jnbt.*; import com.sk89q.worldedit.*; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.extension.input.ParserContext; @@ -34,17 +33,24 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.SchematicReader; import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.registry.WorldData; import de.steamwar.sql.NoClipboardException; import org.bukkit.entity.Player; -import java.io.*; -import java.util.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.stream.Collectors; -public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper { +public class WorldEditWrapper8 implements WorldEditWrapper { @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { @@ -105,6 +111,21 @@ public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper { return new SchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData()); } + @Override + public org.bukkit.util.Vector getOrigin(Clipboard clipboard) { + return new org.bukkit.util.Vector(clipboard.getOrigin().getX(), clipboard.getOrigin().getY(), clipboard.getOrigin().getZ()); + } + + @Override + public org.bukkit.util.Vector getMinimum(Region region) { + return new org.bukkit.util.Vector(region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); + } + + @Override + public org.bukkit.util.Vector getMaximum(Region region) { + return new org.bukkit.util.Vector(region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ()); + } + private static class SpongeSchematicReader implements ClipboardReader { private final NBTInputStream inputStream; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java index 7e0b3719..9c1e51ef 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java @@ -106,6 +106,9 @@ public class Core extends JavaPlugin{ if(Core.getVersion() >= 19) new ServerDataHandler(); + if(Core.getVersion() > 8 && Bukkit.getPluginManager().getPlugin("WorldEdit") != null) + new WorldEditRenderer(); + Bukkit.getScheduler().runTaskTimer(this, TabCompletionCache::invalidateOldEntries, 20, 20); Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SteamwarUser::clear, 72000, 72000); Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SchematicNode::clear, 20L * 30, 20L * 30); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java new file mode 100644 index 00000000..3b5e7aff --- /dev/null +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java @@ -0,0 +1,116 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import com.sk89q.worldedit.EmptyClipboardException; +import com.sk89q.worldedit.IncompleteRegionException; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.regions.RegionSelector; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public class WorldEditRenderer { + + private static final int VIEW_DISTANCE = 64; + private static final int SQ_VIEW_DISTANCE = VIEW_DISTANCE * VIEW_DISTANCE; + + private static final double STEP_SIZE = 0.5; + + private final WorldEditPlugin we; + + public WorldEditRenderer() { + we = WorldEditWrapper.getWorldEditPlugin(); + + Bukkit.getScheduler().runTaskTimer(Core.getInstance(), this::render, 20, 20); + } + + private void render() { + for(Player player : Bukkit.getOnlinePlayers()) { + //noinspection deprecation + if(player.getItemInHand().getType() != Material.WOODEN_AXE) + continue; + + LocalSession session = we.getSession(player); + try { + Clipboard clipboard = session.getClipboard().getClipboard(); + Region region = clipboard.getRegion(); + Vector offset = player.getLocation().toVector().subtract(WorldEditWrapper.impl.getOrigin(clipboard)); + drawCuboid( + WorldEditWrapper.impl.getMinimum(region).add(offset), + WorldEditWrapper.impl.getMaximum(region).add(offset), + Particle.VILLAGER_HAPPY, player + ); + } catch (EmptyClipboardException e) { + //ignore + } + + RegionSelector regionSelector = session.getRegionSelector(session.getSelectionWorld()); + try { + Region region = regionSelector.getRegion(); + drawCuboid(WorldEditWrapper.impl.getMinimum(region), WorldEditWrapper.impl.getMaximum(region), Particle.DRAGON_BREATH, player); + } catch (IncompleteRegionException e) { + //ignore + } + } + } + + private void drawCuboid(Vector min, Vector max, Particle particle, Player owner) { + for(double x = min.getBlockX(); x <= max.getBlockX(); x += STEP_SIZE) { + draw(x, min.getBlockY(), min.getBlockZ(), particle, owner); + draw(x, min.getBlockY(), max.getBlockZ(), particle, owner); + draw(x, max.getBlockY(), min.getBlockZ(), particle, owner); + draw(x, max.getBlockY(), max.getBlockZ(), particle, owner); + } + + for(double y = min.getBlockY() + STEP_SIZE; y <= max.getBlockY() - STEP_SIZE; y += STEP_SIZE) { + draw(min.getBlockX(), y, min.getBlockZ(), particle, owner); + draw(min.getBlockX(), y, max.getBlockZ(), particle, owner); + draw(max.getBlockX(), y, min.getBlockZ(), particle, owner); + draw(max.getBlockX(), y, max.getBlockZ(), particle, owner); + } + + for(double z = min.getBlockZ() + STEP_SIZE; z <= max.getBlockZ() - STEP_SIZE; z += STEP_SIZE) { + draw(min.getBlockX(), min.getBlockY(), z, particle, owner); + draw(min.getBlockX(), max.getBlockY(), z, particle, owner); + draw(max.getBlockX(), min.getBlockY(), z, particle, owner); + draw(max.getBlockX(), max.getBlockY(), z, particle, owner); + } + } + + private void draw(double x, double y, double z, Particle particle, Player owner) { + for(Player player : Bukkit.getOnlinePlayers()) { + Location location = player.getLocation(); + double dx = x - location.getX(); + double dy = y - location.getY(); + double dz = z - location.getZ(); + if(dx*dx + dy*dy + dz*dz > SQ_VIEW_DISTANCE) + continue; + + player.spawnParticle(player == owner ? particle : Particle.TOWN_AURA, x, y, z, 1); + } + } +} diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java index 14f85e16..c034723c 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java @@ -21,24 +21,26 @@ package de.steamwar.core; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.regions.Region; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import java.io.IOException; import java.io.InputStream; -public class WorldEditWrapper { - private WorldEditWrapper() {} +public interface WorldEditWrapper { + WorldEditWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); - public static final IWorldEditWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); + InputStream getPlayerClipboard(Player player, boolean schemFormat); + void setPlayerClipboard(Player player, InputStream is, boolean schemFormat); + Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException; - public interface IWorldEditWrapper { - InputStream getPlayerClipboard(Player player, boolean schemFormat); - void setPlayerClipboard(Player player, InputStream is, boolean schemFormat); - Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException; - } + Vector getOrigin(Clipboard clipboard); + Vector getMinimum(Region region); + Vector getMaximum(Region region); - public static WorldEditPlugin getWorldEditPlugin() { + static WorldEditPlugin getWorldEditPlugin() { return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); } } From df37fa15647efea4407bae4540e47829f0b74e3e Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 25 Nov 2024 17:02:06 +0100 Subject: [PATCH 04/49] Hotfix SendCommand sending on random servers --- .../src/de/steamwar/velocitycore/commands/SendCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/SendCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/SendCommand.java index 660a4ec3..de9a73f3 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/SendCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/SendCommand.java @@ -70,7 +70,7 @@ public class SendCommand extends SWCommand { public RegisteredServer map(Chatter sender, PreviousArguments previousArguments, String s) { SteamwarUser user = sender.user(); for (RegisteredServer registeredServer : VelocityCore.getProxy().getAllServers()) { - if (check(user, registeredServer)) { + if (registeredServer.getServerInfo().getName().equalsIgnoreCase(s) && check(user, registeredServer)) { return registeredServer; } } From d6202f959652870a1c205c317ce462fe65d8fe74 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 26 Nov 2024 16:30:24 +0100 Subject: [PATCH 05/49] First 1.21.3 drafts --- .../features/script/event/EventListener.java | 2 +- .../src/de/steamwar/inventory/SWItem21.java | 38 ++++++++++++++++ .../src/de/steamwar/inventory/SWItem8.java | 45 +++++++++++++++++++ SpigotCore/SpigotCore_Main/build.gradle.kts | 7 ++- .../src/de/steamwar/inventory/SWItem.java | 26 +++++++---- 5 files changed, 107 insertions(+), 11 deletions(-) create mode 100644 SpigotCore/SpigotCore_21/src/de/steamwar/inventory/SWItem21.java create mode 100644 SpigotCore/SpigotCore_8/src/de/steamwar/inventory/SWItem8.java 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 c32b0231..22c5257c 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 @@ -146,7 +146,7 @@ public class EventListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onEntitySpawn(EntitySpawnEvent event) { - if (event.getEntityType() != EntityType.PRIMED_TNT) { + if (event.getEntityType().name().equals("tnt")) { return; } Region tntRegion = Region.getRegion(event.getLocation()); diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/inventory/SWItem21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/inventory/SWItem21.java new file mode 100644 index 00000000..ed9432b0 --- /dev/null +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/inventory/SWItem21.java @@ -0,0 +1,38 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.inventory; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemFlag; + +import java.util.Collection; +import java.util.EnumSet; + +public class SWItem21 implements SWItem.ISWItem { + @Override + public Collection getHideFlags() { + return EnumSet.allOf(ItemFlag.class); + } + + @Override + public Enchantment getDurabilityEnchantment() { + return Enchantment.UNBREAKING; + } +} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/inventory/SWItem8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/inventory/SWItem8.java new file mode 100644 index 00000000..d30bf696 --- /dev/null +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/inventory/SWItem8.java @@ -0,0 +1,45 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.inventory; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemFlag; + +import java.util.Collection; +import java.util.EnumSet; + +public class SWItem8 implements SWItem.ISWItem { + @Override + public Collection getHideFlags() { + return EnumSet.of( + ItemFlag.HIDE_ATTRIBUTES, + ItemFlag.HIDE_DESTROYS, + ItemFlag.HIDE_UNBREAKABLE, + ItemFlag.HIDE_ENCHANTS, + ItemFlag.HIDE_PLACED_ON, + ItemFlag.HIDE_POTION_EFFECTS + ); + } + + @Override + public Enchantment getDurabilityEnchantment() { + return Enchantment.DURABILITY; + } +} diff --git a/SpigotCore/SpigotCore_Main/build.gradle.kts b/SpigotCore/SpigotCore_Main/build.gradle.kts index 88825bc9..8329f671 100644 --- a/SpigotCore/SpigotCore_Main/build.gradle.kts +++ b/SpigotCore/SpigotCore_Main/build.gradle.kts @@ -32,7 +32,12 @@ dependencies { compileOnly(libs.worldedit12) - compileOnly(libs.spigotapi) + compileOnly(libs.paperapi21) { + attributes { + // Very Hacky, but it works + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) + } + } compileOnly(libs.netty) compileOnly(libs.authlib) compileOnly(libs.viaapi) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java index d9f9c23a..61938cb6 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java @@ -21,7 +21,9 @@ package de.steamwar.inventory; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import de.steamwar.core.Core; import de.steamwar.core.FlatteningWrapper; +import de.steamwar.core.VersionDependent; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.enchantments.Enchantment; @@ -30,10 +32,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; +import java.util.Collection; import java.util.List; public class SWItem { + private static final ISWItem impl = VersionDependent.getVersionImpl(Core.getInstance()); + private ItemStack itemStack; private ItemMeta itemMeta; private InvCallback callback; @@ -107,7 +112,7 @@ public class SWItem { itemMeta.setDisplayName(name); if (lore != null && !lore.isEmpty()) itemMeta.setLore(lore); - if (enchanted) itemMeta.addEnchant(Enchantment.DURABILITY , 10, true); + if (enchanted) itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true); itemStack.setItemMeta(itemMeta); } callback = c; @@ -144,12 +149,9 @@ public class SWItem { private void hideAttributes() { if (itemMeta == null) return; - itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); - itemMeta.addItemFlags(ItemFlag.HIDE_DESTROYS); - itemMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); - itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - itemMeta.addItemFlags(ItemFlag.HIDE_PLACED_ON); - itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + for (ItemFlag flag : impl.getHideFlags()) { + itemMeta.addItemFlags(flag); + } } public ItemStack getItemStack() { @@ -192,10 +194,16 @@ public class SWItem { public void setEnchanted(boolean enchanted) { if (enchanted){ - itemMeta.addEnchant(Enchantment.DURABILITY , 10, true); + itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true); } else { - itemMeta.removeEnchant(Enchantment.DURABILITY); + itemMeta.removeEnchant(impl.getDurabilityEnchantment()); } itemStack.setItemMeta(itemMeta); } + + public interface ISWItem { + Collection getHideFlags(); + + Enchantment getDurabilityEnchantment(); + } } From d5c06688f0e366b7af67e2077dd9600d08df5dd9 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 26 Nov 2024 16:34:24 +0100 Subject: [PATCH 06/49] Backend Fixes... --- WebsiteBackend/src/de/steamwar/plugins/Auth.kt | 5 +++-- WebsiteBackend/src/de/steamwar/plugins/Plugins.kt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/WebsiteBackend/src/de/steamwar/plugins/Auth.kt b/WebsiteBackend/src/de/steamwar/plugins/Auth.kt index 6d90339a..cc5c0822 100644 --- a/WebsiteBackend/src/de/steamwar/plugins/Auth.kt +++ b/WebsiteBackend/src/de/steamwar/plugins/Auth.kt @@ -29,6 +29,7 @@ import io.ktor.server.application.hooks.* import io.ktor.server.auth.* import io.ktor.server.request.* import io.ktor.server.response.* +import io.ktor.util.* data class SWAuthPrincipal(val token: Token, val user: SteamwarUser) : Principal @@ -104,7 +105,7 @@ Message: ${cause.message} } onCallRespond { call -> - if (call.response.status()?.isSuccess() == true) { + if ((call.response.status() ?: HttpStatusCode.OK).isSuccess()) { return@onCallRespond } @@ -120,7 +121,7 @@ Message: ${cause.message} Headers: ${call.request.headers.entries().joinToString("\n ") { "${it.key}: ${it.value}" }} Body: - ${call.request.receiveChannel()} + ${call.request.receiveChannel().toByteArray().decodeToString()} """.trimIndent() SWException.log(msg, stack) diff --git a/WebsiteBackend/src/de/steamwar/plugins/Plugins.kt b/WebsiteBackend/src/de/steamwar/plugins/Plugins.kt index b8780f64..fc8dde36 100644 --- a/WebsiteBackend/src/de/steamwar/plugins/Plugins.kt +++ b/WebsiteBackend/src/de/steamwar/plugins/Plugins.kt @@ -50,7 +50,7 @@ fun Application.configurePlugins() { it.request.headers["X-Forwarded-For"] ?: it.request.local.remoteHost } requestWeight { applicationCall, _ -> - if(applicationCall.request.headers["X-Forwarded-For"] != null) { + if(!applicationCall.request.headers.contains("X-Forwarded-For")) { 0 } else { 1 From 9911a52da96e668650bbadebf5373b702dc8a503 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 26 Nov 2024 21:59:52 +0100 Subject: [PATCH 07/49] Bugfixes, tested. --- .../de/steamwar/core/WorldEditRenderer.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java index 3b5e7aff..9c1f69b4 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java @@ -26,6 +26,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; +import com.sk89q.worldedit.world.World; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -40,6 +41,8 @@ public class WorldEditRenderer { private static final double STEP_SIZE = 0.5; + private static final Vector ONES = new Vector(1, 1, 1); + private final WorldEditPlugin we; public WorldEditRenderer() { @@ -68,17 +71,22 @@ public class WorldEditRenderer { //ignore } - RegionSelector regionSelector = session.getRegionSelector(session.getSelectionWorld()); - try { - Region region = regionSelector.getRegion(); - drawCuboid(WorldEditWrapper.impl.getMinimum(region), WorldEditWrapper.impl.getMaximum(region), Particle.DRAGON_BREATH, player); - } catch (IncompleteRegionException e) { - //ignore + World world = session.getSelectionWorld(); + if(world != null) { + RegionSelector regionSelector = session.getRegionSelector(world); + try { + Region region = regionSelector.getRegion(); + drawCuboid(WorldEditWrapper.impl.getMinimum(region), WorldEditWrapper.impl.getMaximum(region), Particle.DRAGON_BREATH, player); + } catch (IncompleteRegionException e) { + //ignore + } } } } private void drawCuboid(Vector min, Vector max, Particle particle, Player owner) { + max.add(ONES); + for(double x = min.getBlockX(); x <= max.getBlockX(); x += STEP_SIZE) { draw(x, min.getBlockY(), min.getBlockZ(), particle, owner); draw(x, min.getBlockY(), max.getBlockZ(), particle, owner); @@ -110,7 +118,7 @@ public class WorldEditRenderer { if(dx*dx + dy*dy + dz*dz > SQ_VIEW_DISTANCE) continue; - player.spawnParticle(player == owner ? particle : Particle.TOWN_AURA, x, y, z, 1); + player.spawnParticle(player == owner ? particle : Particle.TOWN_AURA, x, y, z, 1, 0.0, 0.0, 0.0, 0.0); } } } From 510aec048b423d7e846850f837acbbd0ee641aa1 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 27 Nov 2024 00:26:06 +0100 Subject: [PATCH 08/49] send help ._. --- BauSystem/BauSystem_21/build.gradle.kts | 17 ++ .../bausystem/utils/NMSWrapper21.java | 151 ++++++++++++++++++ .../features/loadtimer/LoadtimerListener.java | 5 +- .../features/region/FreezeListener.java | 3 +- .../features/script/event/EventListener.java | 3 +- BauSystem/build.gradle.kts | 1 + .../fightsystem/event/HellsBells.java | 9 +- .../fightsystem/listener/Recording.java | 5 +- .../fightsystem/listener/WaterRemover.java | 3 +- .../fightsystem/record/PacketProcessor.java | 3 +- .../winconditions/WinconditionTimeTechKO.java | 5 +- .../de/steamwar/core/FlatteningWrapper14.java | 18 ++- SpigotCore/SpigotCore_21/build.gradle.kts | 6 + .../TrickyTrialsWrapper21.java} | 15 +- .../de/steamwar/core/FlatteningWrapper8.java | 2 +- .../TrickyTrialsWrapper8.java} | 22 +-- .../de/steamwar/core/TrickyTrialsWrapper.java | 31 ++++ .../src/de/steamwar/inventory/SWItem.java | 18 +-- .../teamserver/listener/FreezeListener.java | 3 +- settings.gradle.kts | 2 + 20 files changed, 266 insertions(+), 56 deletions(-) create mode 100644 BauSystem/BauSystem_21/build.gradle.kts create mode 100644 BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java rename SpigotCore/SpigotCore_21/src/de/steamwar/{inventory/SWItem21.java => core/TrickyTrialsWrapper21.java} (74%) rename SpigotCore/SpigotCore_8/src/de/steamwar/{inventory/SWItem8.java => core/TrickyTrialsWrapper8.java} (62%) create mode 100644 SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java diff --git a/BauSystem/BauSystem_21/build.gradle.kts b/BauSystem/BauSystem_21/build.gradle.kts new file mode 100644 index 00000000..0c9e97d4 --- /dev/null +++ b/BauSystem/BauSystem_21/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + steamwar.java +} + +java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +dependencies { + compileOnly(project(":BauSystem:BauSystem_Main", "default")) + compileOnly(project(":SpigotCore", "default")) + + compileOnly(libs.paperapi21) + + compileOnly(libs.nms21) +} \ No newline at end of file diff --git a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java new file mode 100644 index 00000000..94751f74 --- /dev/null +++ b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java @@ -0,0 +1,151 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.utils; + +import com.comphenix.tinyprotocol.Reflection; +import de.steamwar.bausystem.features.util.NoClipCommand; +import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.particles.ParticleParam; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.protocol.game.PacketPlayInSetCreativeSlot; +import net.minecraft.network.protocol.game.PacketPlayOutExplosion; +import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange; +import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.level.EnumGamemode; +import net.minecraft.world.level.Explosion; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.List; + +public class NMSWrapper21 implements NMSWrapper { + + @Override + public void setInternalGameMode(Player player, GameMode gameMode) { + ((CraftPlayer) player).getHandle().e.a(EnumGamemode.a(gameMode.getValue())); + } + + @Override + public void setSlotToItemStack(Player player, Object o) { + PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o; + int index = packetPlayInSetCreativeSlot.b(); + if (index >= 36 && index <= 44) { + index -= 36; + } else if (index > 44) { + index -= 5; + } else if (index <= 8) { + index = index - 8 + 36; + } + player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.e())); + if (index < 9) player.getInventory().setHeldItemSlot(index); + player.updateInventory(); + } + + private static final Reflection.FieldAccessor gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12); + + @Override + public void setGameStateChangeReason(Object packet) { + gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d); + } + + @Override + public void setPlayerBuildAbilities(Player player) { + ((CraftPlayer) player).getHandle().fZ().d = true; + ((CraftPlayer) player).getHandle().fZ().e = true; + } + + @Override + public Material pathMaterial() { + return Material.DIRT_PATH; + } + + private static final int threshold = 2048; + + @Override + public boolean checkItemStack(ItemStack item) { + net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + NBTTagCompound tag = nmsItem.a(DataComponents.b, CustomData.a).c(); + if (tag.e("BlockEntityTag")) { + NBTTagCompound blockTag = tag.p("BlockEntityTag"); + if (blockTag.e("Items")) { + return drillDown(blockTag.c("Items", 10), 0, 0) > threshold; + } + } + + return false; + } + + private int drillDown(NBTTagList items, int layer, int start) { + if (layer > 2) return start + threshold; + int invalid = start; + for (NBTBase nbtBase : items) { + if (!(nbtBase instanceof NBTTagCompound slot)) + continue; + if (slot.e("tag")) { + invalid += slot.f("Count"); + NBTTagCompound iTag = slot.p("tag"); + if (iTag.e("BlockEntityTag")) { + NBTTagCompound blockTag = iTag.p("BlockEntityTag"); + if (blockTag.e("Items")) { + invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid); + } + } + } + if (invalid > threshold) + break; + } + return invalid; + } + + private final Class explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion"); + private final Reflection.FieldAccessor a = Reflection.getField(explosionPacket, double.class, 0); + private final Reflection.FieldAccessor b = Reflection.getField(explosionPacket, double.class, 1); + private final Reflection.FieldAccessor c = Reflection.getField(explosionPacket, double.class, 2); + private final Reflection.FieldAccessor d = Reflection.getField(explosionPacket, float.class, 0); + private final Reflection.FieldAccessor e = Reflection.getField(explosionPacket, List.class, 0); + private final Reflection.FieldAccessor f = Reflection.getField(explosionPacket, Explosion.Effect.class, 0); + private final Reflection.FieldAccessor g = Reflection.getField(explosionPacket, ParticleParam.class, 0); + private final Reflection.FieldAccessor h = Reflection.getField(explosionPacket, ParticleParam.class, 1); + private final Reflection.FieldAccessor i = Reflection.getField(explosionPacket, Holder.class, 0); + + @Override + public Object resetExplosionKnockback(Object packet) { + PacketPlayOutExplosion packetPlayOutExplosion = (PacketPlayOutExplosion) packet; + return new PacketPlayOutExplosion( + a.get(packetPlayOutExplosion), + b.get(packetPlayOutExplosion), + c.get(packetPlayOutExplosion), + d.get(packetPlayOutExplosion), + e.get(packetPlayOutExplosion), + null, + f.get(packetPlayOutExplosion), + g.get(packetPlayOutExplosion), + h.get(packetPlayOutExplosion), + i.get(packetPlayOutExplosion) + ); + } +} 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 ddbaed9a..c528b9ad 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 @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.loadtimer; 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; @@ -57,7 +58,7 @@ public class LoadtimerListener implements Listener { @EventHandler public void onEntitySpawn(EntitySpawnEvent event) { - if (!getTimers().isEmpty() && event.getEntityType() == EntityType.PRIMED_TNT) { + if (!getTimers().isEmpty() && event.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) { Region r = Region.getRegion(event.getLocation()); if (hasTimer(r)) { getTimer(r).onTntSpawn(); @@ -67,7 +68,7 @@ public class LoadtimerListener implements Listener { @EventHandler public void onEntityExplode(EntityExplodeEvent event) { - if (!getTimers().isEmpty() && event.getEntityType() == EntityType.PRIMED_TNT) { + if (!getTimers().isEmpty() && event.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) { Region r = Region.getRegion(event.getLocation()); if (hasTimer(r)) { getTimer(r).onTntExplode(event); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java index df73575c..a284cfa8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java @@ -6,6 +6,7 @@ import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.core.Core; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -31,7 +32,7 @@ public class FreezeListener implements Listener, ScoreboardElement { return; } e.setCancelled(true); - if (e.getEntityType() == EntityType.PRIMED_TNT) { + if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) { Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { e.getLocation().getBlock().setType(Material.TNT, false); }, 1L); 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 22c5257c..3886c672 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 @@ -28,6 +28,7 @@ import de.steamwar.bausystem.features.tpslimit.TPSUtils; 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; import org.bukkit.Material; @@ -161,7 +162,7 @@ public class EventListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onEntityExplode(EntityExplodeEvent event) { - if (event.getEntityType() != EntityType.PRIMED_TNT) { + if (event.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) { return; } Region tntRegion = Region.getRegion(event.getLocation()); diff --git a/BauSystem/build.gradle.kts b/BauSystem/build.gradle.kts index 55df7b50..7a02ffa7 100644 --- a/BauSystem/build.gradle.kts +++ b/BauSystem/build.gradle.kts @@ -32,4 +32,5 @@ dependencies { implementation(project(":BauSystem:BauSystem_18")) implementation(project(":BauSystem:BauSystem_19")) implementation(project(":BauSystem:BauSystem_20")) + implementation(project(":BauSystem:BauSystem_21")) } 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 7fe7e4b2..3cfa7a87 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.event; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.countdown.Countdown; @@ -97,13 +98,13 @@ public class HellsBells { currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> { for (int w = 0; w < width; w++) { if (direction.isNorthOrWest()) { - Config.world.spawnEntity(redStart.addAndToLocation(Config.world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), EntityType.PRIMED_TNT); + Config.world.spawnEntity(redStart.addAndToLocation(Config.world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), TrickyTrialsWrapper.impl.getTntEntityType()); - Config.world.spawnEntity(blueStart.addAndToLocation(Config.world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT); + Config.world.spawnEntity(blueStart.addAndToLocation(Config.world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), TrickyTrialsWrapper.impl.getTntEntityType()); } else { - Config.world.spawnEntity(redStart.addAndToLocation(Config.world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT); + Config.world.spawnEntity(redStart.addAndToLocation(Config.world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), TrickyTrialsWrapper.impl.getTntEntityType()); - Config.world.spawnEntity(blueStart.addAndToLocation(Config.world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), EntityType.PRIMED_TNT); + Config.world.spawnEntity(blueStart.addAndToLocation(Config.world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), TrickyTrialsWrapper.impl.getTntEntityType()); } } if (length.addAndGet(-2) <= 0) { 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 889c3c1c..b4040b74 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.listener; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.events.TeamDeathEvent; @@ -221,7 +222,7 @@ public class Recording implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onTNTSpawn(EntitySpawnEvent e){ - if(e.getEntityType() != EntityType.PRIMED_TNT) + if(e.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) return; GlobalRecorder.getInstance().tntSpawn(e.getEntity()); @@ -229,7 +230,7 @@ public class Recording implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onExplosion(EntityExplodeEvent e){ - if(e.getEntityType() != EntityType.PRIMED_TNT) + if(e.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) return; Location loc = e.getLocation(); 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 c89fcab0..847e647b 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.listener; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.Fight; @@ -56,7 +57,7 @@ public class WaterRemover implements Listener { @EventHandler public void handleEntitySpawn(EntitySpawnEvent event) { - if(event.getEntityType() != EntityType.PRIMED_TNT) + if(event.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) return; Location location = event.getLocation(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java index 6296e374..ee0c1af1 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.record; import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.core.Core; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.entity.REntity; import de.steamwar.entity.REntityServer; import de.steamwar.entity.RPlayer; @@ -298,7 +299,7 @@ public class PacketProcessor implements Listener { private void tntSpawn() throws IOException { int entityId = source.readInt(); - execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.PRIMED_TNT, Config.SpecSpawn))); + execSync(() -> addREntity(entityId, new REntity(entityServer, TrickyTrialsWrapper.impl.getTntEntityType(), Config.SpecSpawn))); } private void entityVelocity() throws IOException { 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 1659edbc..f1177afa 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.winconditions; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; @@ -70,7 +71,7 @@ public class WinconditionTimeTechKO extends Wincondition implements Listener { @EventHandler public void onSpawn(EntitySpawnEvent e) { - if(e.getEntityType() != EntityType.PRIMED_TNT) + if(e.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) return; Location location = e.getLocation(); @@ -84,7 +85,7 @@ public class WinconditionTimeTechKO extends Wincondition implements Listener { @EventHandler public void onExplode(EntityExplodeEvent e) { - if(e.getEntityType() != EntityType.PRIMED_TNT) + if(e.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) return; FightTeam spawn = spawnLocations.remove(e.getEntity().getEntityId()); diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java index f5626d03..1aec490e 100644 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java @@ -232,9 +232,21 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper scoreboardName.set(packet, ChatWrapper.impl.stringToChatComponent(title)); } - private static final Class scoreActionEnum = Reflection.getClass("{nms.server}.ScoreboardServer$Action"); - private static final Reflection.FieldAccessor scoreAction = Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0); - private static final Object scoreActionChange = scoreActionEnum.getEnumConstants()[0]; + private static final Class scoreActionEnum; + private static final Reflection.FieldAccessor scoreAction; + private static final Object scoreActionChange; + + static { + if (Core.getVersion() < 21) { + scoreActionEnum = Reflection.getClass("{nms.server}.ScoreboardServer$Action"); + scoreAction = Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0); + scoreActionChange = scoreActionEnum.getEnumConstants()[0]; + } else { + scoreActionEnum = null; + scoreAction = null; + scoreActionChange = null; + } + } @Override public void setScoreAction(Object packet) { diff --git a/SpigotCore/SpigotCore_21/build.gradle.kts b/SpigotCore/SpigotCore_21/build.gradle.kts index b702534b..33938708 100644 --- a/SpigotCore/SpigotCore_21/build.gradle.kts +++ b/SpigotCore/SpigotCore_21/build.gradle.kts @@ -30,4 +30,10 @@ dependencies { attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) } } + compileOnly(libs.nms21) { + attributes { + // Very Hacky, but it works + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) + } + } } diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/inventory/SWItem21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java similarity index 74% rename from SpigotCore/SpigotCore_21/src/de/steamwar/inventory/SWItem21.java rename to SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java index ed9432b0..c1d1e4c6 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/inventory/SWItem21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java @@ -17,22 +17,19 @@ * along with this program. If not, see . */ -package de.steamwar.inventory; +package de.steamwar.core; import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemFlag; +import org.bukkit.entity.EntityType; -import java.util.Collection; -import java.util.EnumSet; - -public class SWItem21 implements SWItem.ISWItem { +public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper { @Override - public Collection getHideFlags() { - return EnumSet.allOf(ItemFlag.class); + public EntityType getTntEntityType() { + return EntityType.TNT; } @Override - public Enchantment getDurabilityEnchantment() { + public Enchantment getUnbreakingEnchantment() { return Enchantment.UNBREAKING; } } diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/FlatteningWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/FlatteningWrapper8.java index 535c5261..7d485286 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/FlatteningWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/FlatteningWrapper8.java @@ -96,7 +96,7 @@ public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper private static final Reflection.FieldAccessor spawnLivingType = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1); private static final Map types = new HashMap<>(); static { - types.put(EntityType.PRIMED_TNT, 50); + types.put(TrickyTrialsWrapper.impl.getTntEntityType(), 50); types.put(EntityType.ARMOR_STAND, 30); types.put(EntityType.ARROW, 60); types.put(EntityType.FIREBALL, 63); diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/inventory/SWItem8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java similarity index 62% rename from SpigotCore/SpigotCore_8/src/de/steamwar/inventory/SWItem8.java rename to SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java index d30bf696..6d7392dc 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/inventory/SWItem8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java @@ -17,29 +17,19 @@ * along with this program. If not, see . */ -package de.steamwar.inventory; +package de.steamwar.core; import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemFlag; +import org.bukkit.entity.EntityType; -import java.util.Collection; -import java.util.EnumSet; - -public class SWItem8 implements SWItem.ISWItem { +public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper { @Override - public Collection getHideFlags() { - return EnumSet.of( - ItemFlag.HIDE_ATTRIBUTES, - ItemFlag.HIDE_DESTROYS, - ItemFlag.HIDE_UNBREAKABLE, - ItemFlag.HIDE_ENCHANTS, - ItemFlag.HIDE_PLACED_ON, - ItemFlag.HIDE_POTION_EFFECTS - ); + public EntityType getTntEntityType() { + return EntityType.PRIMED_TNT; } @Override - public Enchantment getDurabilityEnchantment() { + public Enchantment getUnbreakingEnchantment() { return Enchantment.DURABILITY; } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java new file mode 100644 index 00000000..d678244c --- /dev/null +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java @@ -0,0 +1,31 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; + +public interface TrickyTrialsWrapper { + TrickyTrialsWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); + + EntityType getTntEntityType(); + + Enchantment getUnbreakingEnchantment(); +} diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java index 61938cb6..bc401476 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java @@ -23,6 +23,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import de.steamwar.core.Core; import de.steamwar.core.FlatteningWrapper; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.core.VersionDependent; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -33,12 +34,11 @@ import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; import java.util.Collection; +import java.util.EnumSet; import java.util.List; public class SWItem { - private static final ISWItem impl = VersionDependent.getVersionImpl(Core.getInstance()); - private ItemStack itemStack; private ItemMeta itemMeta; private InvCallback callback; @@ -112,7 +112,7 @@ public class SWItem { itemMeta.setDisplayName(name); if (lore != null && !lore.isEmpty()) itemMeta.setLore(lore); - if (enchanted) itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true); + if (enchanted) itemMeta.addEnchant(TrickyTrialsWrapper.impl.getUnbreakingEnchantment(), 10, true); itemStack.setItemMeta(itemMeta); } callback = c; @@ -149,7 +149,7 @@ public class SWItem { private void hideAttributes() { if (itemMeta == null) return; - for (ItemFlag flag : impl.getHideFlags()) { + for (ItemFlag flag : EnumSet.allOf(ItemFlag.class)) { itemMeta.addItemFlags(flag); } } @@ -194,16 +194,10 @@ public class SWItem { public void setEnchanted(boolean enchanted) { if (enchanted){ - itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true); + itemMeta.addEnchant(TrickyTrialsWrapper.impl.getUnbreakingEnchantment() , 10, true); } else { - itemMeta.removeEnchant(impl.getDurabilityEnchantment()); + itemMeta.removeEnchant(TrickyTrialsWrapper.impl.getUnbreakingEnchantment()); } itemStack.setItemMeta(itemMeta); } - - public interface ISWItem { - Collection getHideFlags(); - - Enchantment getDurabilityEnchantment(); - } } diff --git a/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java b/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java index 5bcb4fed..7d576d2f 100644 --- a/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java +++ b/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java @@ -20,6 +20,7 @@ package de.steamwar.teamserver.listener; import de.steamwar.core.Core; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.teamserver.Builder; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; @@ -55,7 +56,7 @@ public class FreezeListener implements Listener { public void onEntitySpawn(EntitySpawnEvent e) { if (!freeze) return; e.setCancelled(true); - if (e.getEntityType() == EntityType.PRIMED_TNT) { + if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) { Bukkit.getScheduler().runTaskLater(Builder.getInstance(), () -> { e.getLocation().getBlock().setType(Material.TNT, false); }, 1L); diff --git a/settings.gradle.kts b/settings.gradle.kts index d12d432f..7c1d761a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -130,6 +130,7 @@ dependencyResolutionManagement { library("nms18", "de.steamwar:spigot:1.18") library("nms19", "de.steamwar:spigot:1.19") library("nms20", "de.steamwar:spigot:1.20") + library("nms21", "de.steamwar:spigot:1.21") library("axiom", "de.steamwar:axiompaper:RELEASE") library("worldedit12", "de.steamwar:worldedit:1.12") @@ -173,6 +174,7 @@ include( "BauSystem:BauSystem_18", "BauSystem:BauSystem_19", "BauSystem:BauSystem_20", + "BauSystem:BauSystem_21", "BauSystem:BauSystem_Main" ) From 8b007721fb953a9444d1bc74806e9f1353214296 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 27 Nov 2024 12:38:50 +0100 Subject: [PATCH 09/49] Fix NPC Chat messages --- LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java b/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java index 5f2e55b9..2829ec2f 100644 --- a/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/LobbySystem/src/de/steamwar/lobby/team/TeamPlayer.java @@ -145,7 +145,7 @@ public class TeamPlayer extends BasicListener { return; } - String message = "NPC_Chat_" + random.nextInt(6); + String message = "NPC_CHAT_" + random.nextInt(6); SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName()); UserPerm.Prefix prefix = user.prefix(); LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), prefix.getColorCode() + prefix.getChatPrefix()); From 313d63e99dd502a4b948d5ffbd4f6b3eba1c762a Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 27 Nov 2024 19:06:30 +0100 Subject: [PATCH 10/49] Bausystem geht:tm: --- BauSystem/BauSystem_Main/build.gradle.kts | 8 +++- .../features/gui/editor/BauGuiEditor.java | 3 +- .../features/script/event/EventListener.java | 2 +- .../simulator/gui/base/SimulatorBaseGui.java | 3 +- .../team/boundary/BoundaryViewer.java | 3 +- .../util/items/NightVisionBauGuiItem.java | 1 - .../SQL/src/de/steamwar/sql/NodeData.java | 2 +- .../de/steamwar/core/FlatteningWrapper14.java | 18 ++------ .../steamwar/core/TrickyTrialsWrapper14.java | 30 +++++++++++++ .../de/steamwar/core/WorldEditWrapper14.java | 4 +- .../de/steamwar/core/WorldEditWrapper18.java | 7 +-- .../src/de/steamwar/core/ChatWrapper21.java | 44 +++++++++++++++++++ .../steamwar/core/CraftbukkitWrapper21.java | 41 +++++++++++++++++ .../steamwar/core/TrickyTrialsWrapper21.java | 18 ++++++++ .../steamwar/core/TrickyTrialsWrapper8.java | 12 +++++ .../de/steamwar/core/WorldEditWrapper8.java | 3 +- SpigotCore/SpigotCore_Main/build.gradle.kts | 7 +-- .../de/steamwar/core/TrickyTrialsWrapper.java | 11 +++++ .../de/steamwar/inventory/SWInventory.java | 5 ++- settings.gradle.kts | 2 +- 20 files changed, 184 insertions(+), 40 deletions(-) create mode 100644 SpigotCore/SpigotCore_14/src/de/steamwar/core/TrickyTrialsWrapper14.java create mode 100644 SpigotCore/SpigotCore_21/src/de/steamwar/core/ChatWrapper21.java create mode 100644 SpigotCore/SpigotCore_21/src/de/steamwar/core/CraftbukkitWrapper21.java diff --git a/BauSystem/BauSystem_Main/build.gradle.kts b/BauSystem/BauSystem_Main/build.gradle.kts index 63d6f026..9ae53822 100644 --- a/BauSystem/BauSystem_Main/build.gradle.kts +++ b/BauSystem/BauSystem_Main/build.gradle.kts @@ -35,12 +35,16 @@ dependencies { annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) - compileOnly(libs.spigotapi) + compileOnly(libs.paperapi21) { + attributes { + // Very Hacky, but it works + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) + } + } compileOnly(libs.axiom) compileOnly(libs.authlib) compileOnly(libs.viaapi) - compileOnly(libs.nms20) compileOnly(libs.fawe18) implementation(libs.luaj) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditor.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditor.java index 733e7213..e40b01f3 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditor.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditor.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.gui.editor; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.gui.BauGUI; import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.linkage.Linked; @@ -72,7 +73,7 @@ public class BauGuiEditor implements Listener { inv.setItem(mapping.getSize() + 5, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH", p), Arrays.asList(BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH_LORE", p)), false, clickType -> { }).getItemStack()); - inv.setItem(mapping.getSize() + 6, new SWItem(Material.SCUTE, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack()); + inv.setItem(mapping.getSize() + 6, new SWItem(TrickyTrialsWrapper.impl.getTurtleScute(), BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack()); inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).getItemStack()); p.openInventory(inv); 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 3886c672..3eb099aa 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 @@ -147,7 +147,7 @@ public class EventListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onEntitySpawn(EntitySpawnEvent event) { - if (event.getEntityType().name().equals("tnt")) { + if (event.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) { return; } Region tntRegion = Region.getRegion(event.getLocation()); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java index 41f95a88..9e81340b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.simulator.gui.base; import de.steamwar.bausystem.features.simulator.SimulatorWatcher; import de.steamwar.bausystem.features.simulator.data.Simulator; import de.steamwar.core.Core; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Bukkit; @@ -46,7 +47,7 @@ public abstract class SimulatorBaseGui { public final void open() { String newTitle = title(); - String originalTitle = player.getOpenInventory().getTitle(); + String originalTitle = TrickyTrialsWrapper.impl.getInventoryTitle(player.getOpenInventory()); if (inv != null && (Core.getVersion() > 19 || newTitle.equals(originalTitle))) { // TODO: Flickering is better but not gone! diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java index 744ae0df..e2e1ec37 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Particle; @@ -56,7 +57,7 @@ public class BoundaryViewer implements Listener { } private void showRegion(Region region, Player player) { - drawCuboid(player, Particle.VILLAGER_HAPPY, region.getMinPoint(), region.getMaxPoint()); + drawCuboid(player, TrickyTrialsWrapper.impl.getVillagerHappyParticle(), region.getMinPoint(), region.getMaxPoint()); if (region.hasType(RegionType.TESTBLOCK)) { drawCuboid(player, Particle.END_ROD, region.getMinPointTestblockExtension(), region.getMaxPointTestblockExtension()); } 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 d9cab51e..03ebb495 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 @@ -47,7 +47,6 @@ public class NightVisionBauGuiItem extends BauGuiItem { PotionMeta meta = (PotionMeta) itemStack.getItemMeta(); meta.setColor(PotionEffectType.NIGHT_VISION.getColor()); meta.setDisplayName(BauSystem.MESSAGE.parse("NIGHT_VISION_ITEM_ON", player)); - meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); meta.setCustomModelData(1); itemStack.setItemMeta(meta); return itemStack; diff --git a/CommonCore/SQL/src/de/steamwar/sql/NodeData.java b/CommonCore/SQL/src/de/steamwar/sql/NodeData.java index 52743811..33bb0020 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/NodeData.java +++ b/CommonCore/SQL/src/de/steamwar/sql/NodeData.java @@ -71,7 +71,7 @@ public class NodeData { if(rs.wasNull() || schemData.available() == 0) { throw new SecurityException("SchemData is null"); } - return new GZIPInputStream(schemData); + return schemData; } catch (IOException e) { throw new SecurityException("SchemData is wrong", e); } diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java index 1aec490e..b7a9bf7f 100644 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java @@ -232,21 +232,9 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper scoreboardName.set(packet, ChatWrapper.impl.stringToChatComponent(title)); } - private static final Class scoreActionEnum; - private static final Reflection.FieldAccessor scoreAction; - private static final Object scoreActionChange; - - static { - if (Core.getVersion() < 21) { - scoreActionEnum = Reflection.getClass("{nms.server}.ScoreboardServer$Action"); - scoreAction = Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0); - scoreActionChange = scoreActionEnum.getEnumConstants()[0]; - } else { - scoreActionEnum = null; - scoreAction = null; - scoreActionChange = null; - } - } + private static final Class scoreActionEnum = Core.getVersion() < 21 ? Reflection.getClass("{nms.server}.ScoreboardServer$Action") : null; + private static final Reflection.FieldAccessor scoreAction = Core.getVersion() < 21 ? Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0) : null; + private static final Object scoreActionChange = Core.getVersion() < 21 ? scoreActionEnum.getEnumConstants()[0] : null; @Override public void setScoreAction(Object packet) { diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/TrickyTrialsWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/TrickyTrialsWrapper14.java new file mode 100644 index 00000000..aa30ea37 --- /dev/null +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/TrickyTrialsWrapper14.java @@ -0,0 +1,30 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import org.bukkit.Material; + +public class TrickyTrialsWrapper14 extends TrickyTrialsWrapper8 { + + @Override + public Material getTurtleScute() { + return Material.SCUTE; + } +} diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java index 1b48b638..d7138cca 100644 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java @@ -54,8 +54,8 @@ import static com.google.common.base.Preconditions.checkNotNull; public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper { - private static final ClipboardFormat SCHEMATIC = ClipboardFormats.findByAlias("schematic"); - private static final ClipboardFormat SCHEM = ClipboardFormats.findByAlias("schem"); + private static final ClipboardFormat SCHEMATIC = BuiltInClipboardFormat.MCEDIT_SCHEMATIC; + private static final ClipboardFormat SCHEM = BuiltInClipboardFormat.SPONGE_SCHEMATIC; @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { diff --git a/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java b/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java index 4942b2a1..54c7240b 100644 --- a/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java +++ b/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java @@ -19,10 +19,8 @@ package de.steamwar.core; -import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader; -import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader; +import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import de.steamwar.sql.NoClipboardException; import java.io.IOException; @@ -34,9 +32,8 @@ public class WorldEditWrapper18 extends WorldEditWrapper14 { @SuppressWarnings("removal") public Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException { //Use FAWE reader due to FAWE capability of reading corrupt FAWE schems - NBTInputStream nbtStream = new NBTInputStream(is); try { - return (schemFormat ? new SpongeSchematicReader(nbtStream) : new MCEditSchematicReader(nbtStream)).read(); + return (schemFormat ? BuiltInClipboardFormat.FAST.getReader(is) : BuiltInClipboardFormat.MCEDIT_SCHEMATIC.getReader(is)).read(); } catch (NullPointerException e) { throw new NoClipboardException(); } diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/ChatWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/ChatWrapper21.java new file mode 100644 index 00000000..760ba393 --- /dev/null +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/ChatWrapper21.java @@ -0,0 +1,44 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import net.minecraft.network.chat.IChatMutableComponent; +import net.minecraft.network.chat.contents.LiteralContents; +import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; +import net.minecraft.network.syncher.DataWatcher; + +import java.util.ArrayList; + +public class ChatWrapper21 implements ChatWrapper { + @Override + public Object stringToChatComponent(String text) { + return IChatMutableComponent.a(LiteralContents.a(text)); + } + + @Override + public Object getDataWatcherPacket(int entityId, Object... dataWatcherKeyValues) { + ArrayList> nativeWatchers = new ArrayList<>(1); + for(int i = 0; i < dataWatcherKeyValues.length; i+=2) { + nativeWatchers.add(((DataWatcher.Item) BountifulWrapper.impl.getDataWatcherItem(dataWatcherKeyValues[i], dataWatcherKeyValues[i+1])).e()); + } + + return new PacketPlayOutEntityMetadata(entityId, nativeWatchers); + } +} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/CraftbukkitWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/CraftbukkitWrapper21.java new file mode 100644 index 00000000..2309a2a6 --- /dev/null +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/CraftbukkitWrapper21.java @@ -0,0 +1,41 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import com.comphenix.tinyprotocol.Reflection; +import com.comphenix.tinyprotocol.TinyProtocol; +import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; +import net.minecraft.world.level.World; +import net.minecraft.world.level.chunk.Chunk; +import net.minecraft.world.level.chunk.status.ChunkStatus; +import net.minecraft.world.level.lighting.LevelLightEngine; +import org.bukkit.entity.Player; + +public class CraftbukkitWrapper21 implements CraftbukkitWrapper.ICraftbukkitWrapper { + + private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle", ChunkStatus.class); + private static final Reflection.MethodInvoker getLightEngine = Reflection.getTypedMethod(World.class, null, LevelLightEngine.class); + + @Override + public void sendChunk(Player p, int chunkX, int chunkZ) { + Chunk chunk = (Chunk) getHandle.invoke(p.getWorld().getChunkAt(chunkX, chunkZ), ChunkStatus.n); + TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, (LevelLightEngine) getLightEngine.invoke(chunk.r), null, null, true)); + } +} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java index c1d1e4c6..00717405 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java @@ -19,8 +19,11 @@ package de.steamwar.core; +import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; +import org.bukkit.inventory.InventoryView; public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper { @Override @@ -32,4 +35,19 @@ public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper { public Enchantment getUnbreakingEnchantment() { return Enchantment.UNBREAKING; } + + @Override + public Material getTurtleScute() { + return Material.TURTLE_SCUTE; + } + + @Override + public Particle getVillagerHappyParticle() { + return Particle.HAPPY_VILLAGER; + } + + @Override + public String getInventoryTitle(InventoryView view) { + return view.getTitle(); + } } diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java index 6d7392dc..35b80c58 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java @@ -19,8 +19,10 @@ package de.steamwar.core; +import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; +import org.bukkit.inventory.InventoryView; public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper { @Override @@ -32,4 +34,14 @@ public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper { public Enchantment getUnbreakingEnchantment() { return Enchantment.DURABILITY; } + + @Override + public Material getTurtleScute() { + return Material.STONE; + } + + @Override + public String getInventoryTitle(InventoryView view) { + return view.getTitle(); + } } diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java index 32f3faf7..ad9b40f9 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java @@ -43,6 +43,7 @@ import java.io.*; import java.util.*; import java.util.logging.Level; import java.util.stream.Collectors; +import java.util.zip.GZIPInputStream; public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper { @@ -88,7 +89,7 @@ public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper { WorldData world = new BukkitWorld(player.getWorld()).getWorldData(); Clipboard clipboard; try { - clipboard = getClipboard(is, schemFormat); + clipboard = getClipboard(new GZIPInputStream(is), schemFormat); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/SpigotCore/SpigotCore_Main/build.gradle.kts b/SpigotCore/SpigotCore_Main/build.gradle.kts index 8329f671..88825bc9 100644 --- a/SpigotCore/SpigotCore_Main/build.gradle.kts +++ b/SpigotCore/SpigotCore_Main/build.gradle.kts @@ -32,12 +32,7 @@ dependencies { compileOnly(libs.worldedit12) - compileOnly(libs.paperapi21) { - attributes { - // Very Hacky, but it works - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) - } - } + compileOnly(libs.spigotapi) compileOnly(libs.netty) compileOnly(libs.authlib) compileOnly(libs.viaapi) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java index d678244c..7c2cfc4d 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java @@ -19,8 +19,11 @@ package de.steamwar.core; +import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; +import org.bukkit.inventory.InventoryView; public interface TrickyTrialsWrapper { TrickyTrialsWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); @@ -28,4 +31,12 @@ public interface TrickyTrialsWrapper { EntityType getTntEntityType(); Enchantment getUnbreakingEnchantment(); + + Material getTurtleScute(); + + default Particle getVillagerHappyParticle() { + return Particle.VILLAGER_HAPPY; + } + + String getInventoryTitle(InventoryView view); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java index 94a8cf3a..11fe1ec6 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java @@ -20,6 +20,7 @@ package de.steamwar.inventory; import de.steamwar.core.Core; +import de.steamwar.core.TrickyTrialsWrapper; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -138,7 +139,7 @@ public class SWInventory implements Listener { public void open() { InventoryView view = player.openInventory(inventory); - title = view.getTitle(); + title = TrickyTrialsWrapper.impl.getInventoryTitle(view); Core.getInstance().getLogger().info("[SWINV] Opened " + title + " for " + player.getName()); if(!open) { Bukkit.getPluginManager().registerEvents(this, Core.getInstance()); @@ -153,7 +154,7 @@ public class SWInventory implements Listener { if (callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null) { e.setCancelled(true); - Core.getInstance().getLogger().info("[SWINV] " + e.getWhoClicked().getName() + " " + e.getClick().name() + " clicked " + e.getRawSlot() + " on " + (e.getCurrentItem() != null ? e.getCurrentItem().getItemMeta().getDisplayName() : "[EMPTY]") + " in " + e.getView().getTitle()); + Core.getInstance().getLogger().info("[SWINV] " + e.getWhoClicked().getName() + " " + e.getClick().name() + " clicked " + e.getRawSlot() + " on " + (e.getCurrentItem() != null ? e.getCurrentItem().getItemMeta().getDisplayName() : "[EMPTY]") + " in " + TrickyTrialsWrapper.impl.getInventoryTitle(e.getView())); callbacks.get(e.getRawSlot()).accept(e); } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 7c1d761a..a531b252 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -119,7 +119,7 @@ dependencyResolutionManagement { library("datafixer", "com.mojang:datafixerupper:4.0.26") library("brigadier", "com.mojang:brigadier:1.0.18") library("viaapi", "com.viaversion:viaversion-api:4.3.1") - library("anvilgui", "net.wesjd:anvilgui:1.7.0-SNAPSHOT") + library("anvilgui", "net.wesjd:anvilgui:1.10.3-SNAPSHOT") library("nms8", "de.steamwar:spigot:1.8") library("nms9", "de.steamwar:spigot:1.9") From edd3524b41894ac32897a4f00bade3fe5e54e021 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 27 Nov 2024 22:51:49 +0100 Subject: [PATCH 11/49] Fix Build --- .../de/steamwar/bausystem/utils/NMSWrapper21.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java index 94751f74..5ff195c2 100644 --- a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java +++ b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java @@ -30,13 +30,16 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.network.protocol.game.PacketPlayInSetCreativeSlot; import net.minecraft.network.protocol.game.PacketPlayOutExplosion; import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.server.level.PlayerInteractManager; +import net.minecraft.world.entity.player.PlayerAbilities; import net.minecraft.world.item.component.CustomData; import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.level.Explosion; import org.bukkit.GameMode; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -44,9 +47,11 @@ import java.util.List; public class NMSWrapper21 implements NMSWrapper { + private static final Reflection.FieldAccessor playerInteractManager = Reflection.getField(EntityPlayer.class, null, PlayerInteractManager.class); + @Override public void setInternalGameMode(Player player, GameMode gameMode) { - ((CraftPlayer) player).getHandle().e.a(EnumGamemode.a(gameMode.getValue())); + playerInteractManager.get(((CraftPlayer) player).getHandle()).a(EnumGamemode.a(gameMode.getValue())); } @Override @@ -74,7 +79,8 @@ public class NMSWrapper21 implements NMSWrapper { @Override public void setPlayerBuildAbilities(Player player) { - ((CraftPlayer) player).getHandle().fZ().d = true; + PlayerAbilities abilities = ((CraftPlayer) player).getHandle().; + ((CraftPlayer) player).getHandle().().d = true; ((CraftPlayer) player).getHandle().fZ().e = true; } From e71a704d25055cdc9de7903d4c320739a6a46a31 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 28 Nov 2024 16:57:49 +0100 Subject: [PATCH 12/49] Fix 1.9-1.12 WorldEditRenderer --- .../src/de/steamwar/core/WorldEditRenderer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java index 9c1f69b4..7850754e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java @@ -43,6 +43,8 @@ public class WorldEditRenderer { private static final Vector ONES = new Vector(1, 1, 1); + private static final Material WAND = Material.valueOf(Core.getVersion() > 12 ? "WOODEN_AXE" : "WOOD_AXE"); + private final WorldEditPlugin we; public WorldEditRenderer() { @@ -54,7 +56,7 @@ public class WorldEditRenderer { private void render() { for(Player player : Bukkit.getOnlinePlayers()) { //noinspection deprecation - if(player.getItemInHand().getType() != Material.WOODEN_AXE) + if(player.getItemInHand().getType() != WAND) continue; LocalSession session = we.getSession(player); From 891f4b0e9cf9ecf370d62f19fe33a136ed054afd Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 28 Nov 2024 17:03:34 +0100 Subject: [PATCH 13/49] Fix Schematic submission in 1.12 --- .../autocheck/AutoCheckerResult.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java index 6a708bdf..a7d13f17 100644 --- a/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java +++ b/SchematicSystem/SchematicSystem_Core/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java @@ -19,6 +19,7 @@ package de.steamwar.schematicsystem.autocheck; +import de.steamwar.core.Core; import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.SchematicSystem; import lombok.Builder; @@ -143,13 +144,15 @@ public class AutoCheckerResult { blockScanResult.getDefunctNbt().forEach(blockVector3 -> { SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DEFUNCT_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()); }); - blockScanResult.getDesignBlocks().forEach((material, poss) -> { - if(material.getBlastResistance() > type.getMaxBlastResistance()) { - poss.forEach(pos -> { - SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); - }); - } - }); + if(Core.getVersion() > 12) { + blockScanResult.getDesignBlocks().forEach((material, poss) -> { + if(material.getBlastResistance() > type.getMaxBlastResistance()) { + poss.forEach(pos -> { + SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); + }); + } + }); + } entities.forEach(blockPos -> { SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_ENTITY", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockPos), blockPos.getX(), blockPos.getY(), blockPos.getZ()); }); From e088e9794b1adad4385f0bfa28183879d179d2a8 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 28 Nov 2024 23:28:44 +0100 Subject: [PATCH 14/49] Update WorldEditWrapper21 --- .../bausystem/utils/NMSWrapper21.java | 36 +++---- .../SQL/src/de/steamwar/sql/NodeData.java | 2 +- .../de/steamwar/core/WorldEditWrapper14.java | 38 +------- .../de/steamwar/core/WorldEditWrapper18.java | 6 +- SpigotCore/SpigotCore_21/build.gradle.kts | 4 + .../de/steamwar/core/WorldEditWrapper21.java | 97 +++++++++++++++++++ .../de/steamwar/core/WorldEditWrapper8.java | 35 +------ .../de/steamwar/core/WorldEditWrapper.java | 45 ++++++++- settings.gradle.kts | 1 + 9 files changed, 171 insertions(+), 93 deletions(-) create mode 100644 SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java diff --git a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java index 5ff195c2..b80cb69c 100644 --- a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java +++ b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java @@ -32,10 +32,12 @@ import net.minecraft.network.protocol.game.PacketPlayOutExplosion; import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange; import net.minecraft.server.level.EntityPlayer; import net.minecraft.server.level.PlayerInteractManager; +import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.entity.player.PlayerAbilities; import net.minecraft.world.item.component.CustomData; import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.level.Explosion; +import net.minecraft.world.phys.Vec3D; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; @@ -44,6 +46,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import java.util.List; +import java.util.Optional; public class NMSWrapper21 implements NMSWrapper { @@ -77,11 +80,13 @@ public class NMSWrapper21 implements NMSWrapper { gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d); } + private static final Reflection.FieldAccessor playerAbilities = Reflection.getField(EntityHuman.class, null, PlayerAbilities.class); + @Override public void setPlayerBuildAbilities(Player player) { - PlayerAbilities abilities = ((CraftPlayer) player).getHandle().; - ((CraftPlayer) player).getHandle().().d = true; - ((CraftPlayer) player).getHandle().fZ().e = true; + PlayerAbilities abilities = playerAbilities.get(((CraftPlayer) player).getHandle()); + abilities.d = true; + abilities.e = true; } @Override @@ -128,30 +133,11 @@ public class NMSWrapper21 implements NMSWrapper { } private final Class explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion"); - private final Reflection.FieldAccessor a = Reflection.getField(explosionPacket, double.class, 0); - private final Reflection.FieldAccessor b = Reflection.getField(explosionPacket, double.class, 1); - private final Reflection.FieldAccessor c = Reflection.getField(explosionPacket, double.class, 2); - private final Reflection.FieldAccessor d = Reflection.getField(explosionPacket, float.class, 0); - private final Reflection.FieldAccessor e = Reflection.getField(explosionPacket, List.class, 0); - private final Reflection.FieldAccessor f = Reflection.getField(explosionPacket, Explosion.Effect.class, 0); - private final Reflection.FieldAccessor g = Reflection.getField(explosionPacket, ParticleParam.class, 0); - private final Reflection.FieldAccessor h = Reflection.getField(explosionPacket, ParticleParam.class, 1); - private final Reflection.FieldAccessor i = Reflection.getField(explosionPacket, Holder.class, 0); + private final Reflection.FieldAccessor explosionKnockback = Reflection.getField(explosionPacket, Optional.class, 0); @Override public Object resetExplosionKnockback(Object packet) { - PacketPlayOutExplosion packetPlayOutExplosion = (PacketPlayOutExplosion) packet; - return new PacketPlayOutExplosion( - a.get(packetPlayOutExplosion), - b.get(packetPlayOutExplosion), - c.get(packetPlayOutExplosion), - d.get(packetPlayOutExplosion), - e.get(packetPlayOutExplosion), - null, - f.get(packetPlayOutExplosion), - g.get(packetPlayOutExplosion), - h.get(packetPlayOutExplosion), - i.get(packetPlayOutExplosion) - ); + explosionKnockback.set(packet, Optional.empty()); + return packet; } } diff --git a/CommonCore/SQL/src/de/steamwar/sql/NodeData.java b/CommonCore/SQL/src/de/steamwar/sql/NodeData.java index 33bb0020..52743811 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/NodeData.java +++ b/CommonCore/SQL/src/de/steamwar/sql/NodeData.java @@ -71,7 +71,7 @@ public class NodeData { if(rs.wasNull() || schemData.available() == 0) { throw new SecurityException("SchemData is null"); } - return schemData; + return new GZIPInputStream(schemData); } catch (IOException e) { throw new SecurityException("SchemData is wrong", e); } diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java index d7138cca..9e9e434a 100644 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java @@ -59,29 +59,8 @@ public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper { @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { - ClipboardHolder clipboardHolder; - try { - clipboardHolder = WorldEditWrapper.getWorldEditPlugin().getSession(player).getClipboard(); - } catch (EmptyClipboardException e) { - throw new NoClipboardException(); - } - - Clipboard clipboard = clipboardHolder.getClipboard(); - if(clipboard == null) - throw new NoClipboardException(); - - PipedOutputStream outputStream = new PipedOutputStream(); - PipedInputStream inputStream; - try { - inputStream = new PipedInputStream(outputStream, 4096); - }catch(NullPointerException e){ - throw new RuntimeException(e.getMessage(), new IOException(e)); - } catch (IOException e) { - throw new SecurityException("Could not init piped input stream", e); - } - - new Thread(() -> { - try{ + return WorldEditWrapper.getPlayerClipboard(player, schemFormat, (outputStream, clipboard, clipboardHolder) -> { + try { if(schemFormat){ ClipboardWriter writer = SCHEM.getWriter(outputStream); writer.write(clipboard); @@ -89,17 +68,10 @@ public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper { }else{ SCHEMATIC.getWriter(outputStream).write(clipboard); } - }catch(NullPointerException | IOException e) { - Core.getInstance().getLogger().log(Level.SEVERE, "Could not write schematic", e); + } catch (Exception e) { + throw new RuntimeException(e.getMessage(), e); } - try { - outputStream.close(); - } catch (IOException e) { - Core.getInstance().getLogger().log(Level.SEVERE, "Could not close schem writer", e); - } - }, "SchemWriter").start(); - - return inputStream; + }); } @Override diff --git a/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java b/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java index 54c7240b..903113c4 100644 --- a/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java +++ b/SpigotCore/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java @@ -19,8 +19,9 @@ package de.steamwar.core; +import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.*; import de.steamwar.sql.NoClipboardException; import java.io.IOException; @@ -31,9 +32,10 @@ public class WorldEditWrapper18 extends WorldEditWrapper14 { @Override @SuppressWarnings("removal") public Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException { + NBTInputStream nbtStream = new NBTInputStream(is); //Use FAWE reader due to FAWE capability of reading corrupt FAWE schems try { - return (schemFormat ? BuiltInClipboardFormat.FAST.getReader(is) : BuiltInClipboardFormat.MCEDIT_SCHEMATIC.getReader(is)).read(); + return (schemFormat ? new SpongeSchematicReader(nbtStream) : new MCEditSchematicReader(nbtStream)).read(); } catch (NullPointerException e) { throw new NoClipboardException(); } diff --git a/SpigotCore/SpigotCore_21/build.gradle.kts b/SpigotCore/SpigotCore_21/build.gradle.kts index 33938708..b4eded6e 100644 --- a/SpigotCore/SpigotCore_21/build.gradle.kts +++ b/SpigotCore/SpigotCore_21/build.gradle.kts @@ -23,6 +23,10 @@ plugins { dependencies { compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) + compileOnly(project(":SpigotCore:SpigotCore_18", "default")) + compileOnly(project(":SpigotCore:SpigotCore_14", "default")) + + compileOnly(libs.fawe21) compileOnly(libs.paperapi21) { attributes { diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java new file mode 100644 index 00000000..c7215c8e --- /dev/null +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java @@ -0,0 +1,97 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV2; +import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV3; +import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriterV3; +import com.sk89q.jnbt.NBTInputStream; +import com.sk89q.jnbt.NBTOutputStream; +import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader; +import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader; +import com.sk89q.worldedit.session.ClipboardHolder; +import org.bukkit.entity.Player; +import org.enginehub.linbus.stream.LinBinaryIO; +import org.enginehub.linbus.stream.LinStream; +import org.enginehub.linbus.tree.LinCompoundTag; +import org.enginehub.linbus.tree.LinRootEntry; +import org.enginehub.linbus.tree.LinTagType; + +import java.io.*; + +public class WorldEditWrapper21 implements WorldEditWrapper.IWorldEditWrapper { + + @Override + public InputStream getPlayerClipboard(Player player, boolean schemFormat) { + return WorldEditWrapper.getPlayerClipboard(player, schemFormat, (outputStream, clipboard, clipboardHolder) -> { + try { + new FastSchematicWriterV3(new NBTOutputStream(outputStream)).write(clipboard); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + } + + @Override + public void setPlayerClipboard(Player player, InputStream is, boolean schemFormat) { + Clipboard clipboard = null; + try { + clipboard = getClipboard(is, schemFormat); + } catch (IOException e) { + throw new RuntimeException(e.getMessage(), e); + } + + if (clipboard == null) + throw new SecurityException("Clipboard is null"); + + Actor actor = WorldEditWrapper.getWorldEditPlugin().wrapCommandSender(player); + WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard)); + } + + @Override + public Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException { + if (!schemFormat) { + return new MCEditSchematicReader(new NBTInputStream(is)).read(); + } else { + BufferedInputStream bis = new BufferedInputStream(is); + + bis.mark(Integer.MAX_VALUE); + + LinStream linStream = LinBinaryIO.read(new DataInputStream(bis)); + + LinCompoundTag entry = LinRootEntry.readFrom(linStream).value(); + + bis.reset(); + + switch (entry.getTag("Version", LinTagType.intTag()).valueAsInt()) { + case 1: + return new SpongeSchematicV1Reader(entry.linStream()).read(); + case 2: + return new FastSchematicReaderV2(new NBTInputStream(bis)).read(); + case 3: + return new FastSchematicReaderV3(bis).read(); + default: + throw new IOException("Unknown schematic version"); + } + } + } +} diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java index ad9b40f9..3913c262 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java @@ -49,39 +49,14 @@ public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper { @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { - ClipboardHolder clipboardHolder; - try { - clipboardHolder = WorldEditWrapper.getWorldEditPlugin().getSession(player).getClipboard(); - } catch (EmptyClipboardException e) { - throw new NoClipboardException(); - } - - Clipboard clipboard = clipboardHolder.getClipboard(); - if(clipboard == null) - throw new NoClipboardException(); - - PipedOutputStream outputStream = new PipedOutputStream(); - PipedInputStream inputStream; - try { - inputStream = new PipedInputStream(outputStream, 4096); - } catch (IOException e) { - throw new SecurityException("Could not init piped input stream", e); - } - - new Thread(() -> { + return WorldEditWrapper.getPlayerClipboard(player, schemFormat, (outputStream, clipboard, clipboardHolder) -> + { try { ClipboardFormat.SCHEMATIC.getWriter(outputStream).write(clipboard, clipboardHolder.getWorldData()); } catch (IOException e) { - Core.getInstance().getLogger().log(Level.SEVERE, "Could not write schematic", e); + throw new RuntimeException(e); } - try { - outputStream.close(); - } catch (IOException e) { - Core.getInstance().getLogger().log(Level.SEVERE, "Could not close schem writer", e); - } - }, "SchemWriter").start(); - - return inputStream; + }); } @Override @@ -89,7 +64,7 @@ public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper { WorldData world = new BukkitWorld(player.getWorld()).getWorldData(); Clipboard clipboard; try { - clipboard = getClipboard(new GZIPInputStream(is), schemFormat); + clipboard = getClipboard(is, schemFormat); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java index 14f85e16..90396119 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java @@ -19,13 +19,18 @@ package de.steamwar.core; +import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.session.ClipboardHolder; +import de.steamwar.sql.NoClipboardException; +import org.apache.logging.log4j.util.TriConsumer; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; +import java.util.logging.Level; public class WorldEditWrapper { private WorldEditWrapper() {} @@ -41,4 +46,40 @@ public class WorldEditWrapper { public static WorldEditPlugin getWorldEditPlugin() { return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); } + + public static InputStream getPlayerClipboard(Player player, boolean schemFormat, TriConsumer consumer) { + ClipboardHolder clipboardHolder; + try { + clipboardHolder = WorldEditWrapper.getWorldEditPlugin().getSession(player).getClipboard(); + } catch (EmptyClipboardException e) { + throw new NoClipboardException(); + } + + Clipboard clipboard = clipboardHolder.getClipboard(); + if(clipboard == null) + throw new NoClipboardException(); + + PipedOutputStream outputStream = new PipedOutputStream(); + PipedInputStream inputStream; + try { + inputStream = new PipedInputStream(outputStream, 4096); + } catch (IOException e) { + throw new SecurityException("Could not init piped input stream", e); + } + + new Thread(() -> { + try { + consumer.accept(outputStream, clipboard, clipboardHolder); + } catch (Exception e) { + Core.getInstance().getLogger().log(Level.SEVERE, "Could not write schematic", e); + } + try { + outputStream.close(); + } catch (IOException e) { + Core.getInstance().getLogger().log(Level.SEVERE, "Could not close schem writer", e); + } + }, "SchemWriter").start(); + + return inputStream; + } } diff --git a/settings.gradle.kts b/settings.gradle.kts index a531b252..29574740 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -136,6 +136,7 @@ dependencyResolutionManagement { library("worldedit12", "de.steamwar:worldedit:1.12") library("worldedit15", "de.steamwar:worldedit:1.15") library("fawe18", "de.steamwar:fastasyncworldedit:1.18") + library("fawe21", "de.steamwar:fastasyncworldedit:1.21") library("velocity", "de.steamwar:velocity:RELEASE") library("velocityapi", "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT") From 46c2de43a4b8290b411de5751c826200184d9535 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 29 Nov 2024 13:02:35 +0100 Subject: [PATCH 15/49] Fix clipboard WorldEditRenderer with transform --- .../de/steamwar/core/WorldEditWrapper14.java | 18 ++++++++++++++---- .../de/steamwar/core/WorldEditWrapper8.java | 8 ++++++++ .../de/steamwar/core/WorldEditRenderer.java | 14 +++++++------- .../src/de/steamwar/core/WorldEditWrapper.java | 2 ++ 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java index 38ae351a..eae1c53e 100644 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java @@ -35,6 +35,8 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.*; import com.sk89q.worldedit.extent.clipboard.io.legacycompat.*; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; +import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; @@ -44,6 +46,7 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; import de.steamwar.sql.NoClipboardException; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import java.io.*; import java.util.*; @@ -137,13 +140,20 @@ public class WorldEditWrapper14 implements WorldEditWrapper { } @Override - public org.bukkit.util.Vector getMinimum(Region region) { - return new org.bukkit.util.Vector(region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); + public Vector getMinimum(Region region) { + return new Vector(region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); } @Override - public org.bukkit.util.Vector getMaximum(Region region) { - return new org.bukkit.util.Vector(region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ()); + public Vector getMaximum(Region region) { + return new Vector(region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ()); + } + + @Override + public Vector applyTransform(Vector vector, Transform transform) { + Vector3 v = Vector3.at(vector.getX(), vector.getY(), vector.getZ()); + v = transform.apply(v); + return new org.bukkit.util.Vector(v.getX(), v.getY(), v.getZ()); } private static class MCEditSchematicReader extends NBTSchematicReader { diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java index e021ceed..69ebb544 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java @@ -32,6 +32,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.SchematicReader; +import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; @@ -126,6 +127,13 @@ public class WorldEditWrapper8 implements WorldEditWrapper { return new org.bukkit.util.Vector(region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ()); } + @Override + public org.bukkit.util.Vector applyTransform(org.bukkit.util.Vector vector, Transform transform) { + Vector v = new Vector(vector.getX(), vector.getY(), vector.getZ()); + v = transform.apply(v); + return new org.bukkit.util.Vector(v.getX(), v.getY(), v.getZ()); + } + private static class SpongeSchematicReader implements ClipboardReader { private final NBTInputStream inputStream; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java index 7850754e..cd9a0d4e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extent.clipboard.Clipboard; +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; @@ -43,7 +44,7 @@ public class WorldEditRenderer { private static final Vector ONES = new Vector(1, 1, 1); - private static final Material WAND = Material.valueOf(Core.getVersion() > 12 ? "WOODEN_AXE" : "WOOD_AXE"); + private static final Material WAND = FlatteningWrapper.impl.getMaterial("WOOD_AXE"); private final WorldEditPlugin we; @@ -62,13 +63,12 @@ public class WorldEditRenderer { LocalSession session = we.getSession(player); try { Clipboard clipboard = session.getClipboard().getClipboard(); + Vector pos = player.getLocation().toVector(); Region region = clipboard.getRegion(); - Vector offset = player.getLocation().toVector().subtract(WorldEditWrapper.impl.getOrigin(clipboard)); - drawCuboid( - WorldEditWrapper.impl.getMinimum(region).add(offset), - WorldEditWrapper.impl.getMaximum(region).add(offset), - Particle.VILLAGER_HAPPY, player - ); + Transform transform = session.getClipboard().getTransform(); + Vector a = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMinimum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos); + Vector b = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMaximum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos); + drawCuboid(Vector.getMinimum(a, b), Vector.getMaximum(a, b), Particle.VILLAGER_HAPPY, player); } catch (EmptyClipboardException e) { //ignore } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java index c034723c..1d9ef6cd 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java @@ -21,6 +21,7 @@ package de.steamwar.core; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.Region; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -39,6 +40,7 @@ public interface WorldEditWrapper { Vector getOrigin(Clipboard clipboard); Vector getMinimum(Region region); Vector getMaximum(Region region); + Vector applyTransform(Vector vector, Transform transform); static WorldEditPlugin getWorldEditPlugin() { return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); From f51de58921ecce5576cd82fdd42f5bd291bf4277 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 29 Nov 2024 13:17:52 +0100 Subject: [PATCH 16/49] Fix checking deleted schematic limbo --- .../velocitycore/commands/CheckCommand.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java index af6328b2..7fb5118a 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java @@ -272,12 +272,13 @@ public class CheckCommand extends SWCommand { } private boolean concludeCheckSession(String reason, SchematicType type) { - if(SchematicNode.getSchematicNode(schematic.getId()) == null) // Schematic was deleted - return false; + boolean exists = SchematicNode.getSchematicNode(schematic.getId()) != null; - CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason); - if(type != null) - schematic.setSchemtype(type); + if(exists) { + CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason); + if(type != null) + schematic.setSchemtype(type); + } remove(); VelocityCore.schedule(() -> { @@ -285,7 +286,7 @@ public class CheckCommand extends SWCommand { if(subserver != null) subserver.stop(); }).schedule(); - return true; + return exists; } private void remove() { From 28f96e313aeb7a5f10de269e551f263e242260fa Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 29 Nov 2024 14:09:32 +0100 Subject: [PATCH 17/49] Fix bau addmember hover message --- VelocityCore/src/de/steamwar/velocitycore/SubserverSystem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/SubserverSystem.java b/VelocityCore/src/de/steamwar/velocitycore/SubserverSystem.java index bd2c7f73..68bee31d 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/SubserverSystem.java +++ b/VelocityCore/src/de/steamwar/velocitycore/SubserverSystem.java @@ -47,7 +47,7 @@ public class SubserverSystem { Chatter o = Chatter.of(owner); o.system("SERVER_ADD_MEMBER", p); - o.prefixless("SERVER_ADD_MESSAGE", new Message("SERVER_ADD_MESSAGE_HOVER"), ClickEvent.runCommand("/bau addmember " + p.user().getUserName())); + o.prefixless("SERVER_ADD_MESSAGE", new Message("SERVER_ADD_MESSAGE_HOVER", p.user().getUserName()), ClickEvent.runCommand("/bau addmember " + p.user().getUserName())); } public static void sendPlayer(Subserver subserver, Player player) { From 8e2cca854e18798fb0318bd19c5e0bbdf50da505 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 29 Nov 2024 14:59:53 +0100 Subject: [PATCH 18/49] Fix JsonParser.readString unavailable in 1.15- --- .../src/de/steamwar/inventory/SchematicSelector.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java index 73c45259..648247bb 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SchematicSelector.java @@ -21,7 +21,8 @@ package de.steamwar.inventory; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import com.google.gson.internal.Streams; +import com.google.gson.stream.JsonReader; import de.steamwar.core.Core; import de.steamwar.sql.*; import lombok.*; @@ -29,6 +30,7 @@ import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; +import java.io.StringReader; import java.text.MessageFormat; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; @@ -381,7 +383,7 @@ public class SchematicSelector { String cfg = UserConfig.getConfig(user.getId(), "selector:filters"); if (cfg != null) { - JsonArray array = JsonParser.parseString(cfg).getAsJsonArray(); + JsonArray array = Streams.parse(new JsonReader(new StringReader(cfg))).getAsJsonArray(); for (int i = 0; i < array.size(); i++) { JsonObject object = array.get(i).getAsJsonObject(); filterCache.get(player)[i] = new SelectorFilter(object); From 4ee8456fd4631ca310a7165e5503487b596440cf Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 29 Nov 2024 15:23:17 +0100 Subject: [PATCH 19/49] Fix ConcurrentModificationException through death in loop --- .../src/de/steamwar/towerrun/listener/IngameListener.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java index 9e30cf07..befc7d47 100644 --- a/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java +++ b/TowerRun/src/de/steamwar/towerrun/listener/IngameListener.java @@ -29,6 +29,7 @@ import de.steamwar.towerrun.state.GameStates; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; @@ -83,14 +84,16 @@ public class IngameListener extends GameStateBukkitListener { .min(Comparator.comparing(Function.identity())) .orElse(0.0); + List toDamage = new ArrayList<>(); TowerRunGame.PLAYERS_ALIVE.forEach(towerRunPlayer -> { if (towerRunPlayer.player().getLocation().getY() - minY > 20) { towerRunPlayer.player().sendTitle("ยงa", TowerRun.getMessage().parse("CATCH_UP_WARNING", towerRunPlayer.player()), 5, 30, 5); } if (towerRunPlayer.player().getLocation().getY() - minY > 30) { - towerRunPlayer.player().damage(1.0); + toDamage.add(towerRunPlayer.player()); } }); + toDamage.forEach(p -> p.damage(1.0)); } }; antiCampRunnable.runTaskTimer(TowerRun.getInstance(), 100, 100); From 996e4932d7f7f270c4017fa4d8a3c9d7554d5a02 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 30 Nov 2024 09:35:29 +0100 Subject: [PATCH 20/49] Text 1.20 Tablist fix --- .../src/de/steamwar/velocitycore/tablist/Tablist.java | 6 ++++-- .../de/steamwar/velocitycore/tablist/TablistManager.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/tablist/Tablist.java b/VelocityCore/src/de/steamwar/velocitycore/tablist/Tablist.java index 315717a6..1d8a0738 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/tablist/Tablist.java +++ b/VelocityCore/src/de/steamwar/velocitycore/tablist/Tablist.java @@ -142,8 +142,10 @@ public class Tablist extends ChannelInboundHandlerAdapter { } public void onServerPostSwitch() { - if(player.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_20)) { - current.clear(); + if(player.getProtocolVersion().noLessThan(ProtocolVersion.MINECRAFT_1_20)) { + if(player.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_20)) + current.clear(); + sendPacket(player, createTeamPacket); } } diff --git a/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java b/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java index 29cebb38..c008d76c 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java +++ b/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java @@ -65,7 +65,7 @@ public class TablistManager extends BasicListener { tablists.computeIfAbsent(event.getPlayer(), Tablist::new).onServerSwitch(); } - if(event.getPlayer().getProtocolVersion().noGreaterThan(ProtocolVersion.MINECRAFT_1_20)) + if(event.getPlayer().getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_20)) Tablist.sendPacket(event.getPlayer(), Tablist.createTeamPacket); } From 2032a0b6427a1233ab9271c0dbf4322ab6d0c604 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 30 Nov 2024 10:31:49 +0100 Subject: [PATCH 21/49] Fix links in chat not clickable --- VelocityCore/src/de/steamwar/messages/Chatter.java | 7 ++++--- .../src/de/steamwar/velocitycore/mods/ModUtils.java | 9 ++++----- .../velocitycore/network/handlers/EloPlayerHandler.java | 6 +++--- .../de/steamwar/velocitycore/tablist/TablistPart.java | 7 +++---- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/VelocityCore/src/de/steamwar/messages/Chatter.java b/VelocityCore/src/de/steamwar/messages/Chatter.java index c6571303..224b502f 100644 --- a/VelocityCore/src/de/steamwar/messages/Chatter.java +++ b/VelocityCore/src/de/steamwar/messages/Chatter.java @@ -26,9 +26,9 @@ import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ServerConnection; import de.steamwar.persistent.Servertype; import de.steamwar.persistent.Subserver; -import de.steamwar.velocitycore.VelocityCore; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; +import de.steamwar.velocitycore.VelocityCore; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; @@ -47,6 +47,7 @@ import java.util.function.Supplier; import java.util.stream.Stream; public interface Chatter { + LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder().extractUrls().build(); static Stream allPlayers() { return VelocityCore.getProxy().getAllPlayers().stream(); @@ -138,7 +139,7 @@ public interface Chatter { } default String parseToLegacy(Message message) { - return LegacyComponentSerializer.legacySection().serialize(parse(message)); + return SERIALIZER.serialize(parse(message)); } default Component parse(String format, Object... params) { @@ -178,7 +179,7 @@ public interface Chatter { params[i] = func.apply(this); } } - return LegacyComponentSerializer.legacySection().deserialize(format.format(params)); + return SERIALIZER.deserialize(format.format(params)); } static PlayerChatter of(Player player) { diff --git a/VelocityCore/src/de/steamwar/velocitycore/mods/ModUtils.java b/VelocityCore/src/de/steamwar/velocitycore/mods/ModUtils.java index c1cf7bad..c23434ec 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/mods/ModUtils.java +++ b/VelocityCore/src/de/steamwar/velocitycore/mods/ModUtils.java @@ -20,18 +20,17 @@ package de.steamwar.velocitycore.mods; import com.velocitypowered.api.proxy.Player; -import de.steamwar.sql.Punishment; -import de.steamwar.velocitycore.VelocityCore; -import de.steamwar.velocitycore.commands.PunishmentCommand; import de.steamwar.messages.Chatter; import de.steamwar.sql.Mod; import de.steamwar.sql.Mod.ModType; +import de.steamwar.sql.Punishment; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; +import de.steamwar.velocitycore.VelocityCore; +import de.steamwar.velocitycore.commands.PunishmentCommand; import lombok.Getter; import lombok.experimental.UtilityClass; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import java.sql.Timestamp; import java.time.Instant; @@ -88,7 +87,7 @@ public class ModUtils { VelocityCore.getLogger().log(Level.SEVERE, "%s %s wurde automatisch wegen der Mods %s gebannt.".formatted(user.getUserName(), user.getId(), modList)); } - disconnect.accept(LegacyComponentSerializer.legacySection().deserialize(message)); + disconnect.accept(Chatter.SERIALIZER.deserialize(message)); return false; } } diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java index 417a0e5e..3ef4eb8f 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java +++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java @@ -20,6 +20,7 @@ package de.steamwar.velocitycore.network.handlers; import com.velocitypowered.api.proxy.Player; +import de.steamwar.messages.Chatter; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.common.FightEndsPacket; import de.steamwar.sql.SchematicType; @@ -29,7 +30,6 @@ import de.steamwar.velocitycore.ArenaMode; import de.steamwar.velocitycore.VelocityCore; import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.title.Title; import java.time.Duration; @@ -186,10 +186,10 @@ public class EloPlayerHandler extends PacketHandler { double eloStep = eloGain / 40.0; for (int i = 0; i < 40; i++) { - Component eloGainComponent = LegacyComponentSerializer.legacySection().deserialize(color + (int) (eloStep * (i + 1))); + Component eloGainComponent = Chatter.SERIALIZER.deserialize(color + (int) (eloStep * (i + 1))); int finalI = i; VelocityCore.schedule(() -> player.showTitle(Title.title( - LegacyComponentSerializer.legacySection().deserialize(getRankup.apply(finalI)), + Chatter.SERIALIZER.deserialize(getRankup.apply(finalI)), eloGainComponent, Title.Times.times(Duration.ofMillis(finalI == 0 ? 250 : 0), Duration.ofSeconds(2), Duration.ofMillis(finalI == 39 ? 250 : 0)) ))).delay(i * 50L, TimeUnit.MILLISECONDS).schedule(); diff --git a/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistPart.java b/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistPart.java index 308c9820..f00f663e 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistPart.java +++ b/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistPart.java @@ -26,7 +26,6 @@ import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; import lombok.Getter; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import java.util.List; import java.util.UUID; @@ -43,7 +42,7 @@ public interface TablistPart { public Item(UUID uuid, String displayName, List properties) { this.uuid = uuid; - this.displayName = LegacyComponentSerializer.legacySection().deserialize(displayName); + this.displayName = Chatter.SERIALIZER.deserialize(displayName); this.properties = properties; } @@ -55,9 +54,9 @@ public interface TablistPart { this.uuid = player.getUniqueId(); UserPerm.Prefix prefix = SteamwarUser.get(player.getUniqueId()).prefix(); if (prefix == UserPerm.emptyPrefix && sameTeam) { - this.displayName = LegacyComponentSerializer.legacySection().deserialize("ยงf" + player.getUsername()); + this.displayName = Chatter.SERIALIZER.deserialize("ยงf" + player.getUsername()); } else { - this.displayName = LegacyComponentSerializer.legacySection().deserialize(prefix.getColorCode() + player.getUsername()); + this.displayName = Chatter.SERIALIZER.deserialize(prefix.getColorCode() + player.getUsername()); } this.properties = player.getGameProfileProperties(); } From fd791ea98d1fd27f407cfd63d553030dbd284d34 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 1 Dec 2024 00:13:08 +0100 Subject: [PATCH 22/49] Update AdventCommand --- .../src/de/steamwar/lobby/special/advent/AdventCommand.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LobbySystem/src/de/steamwar/lobby/special/advent/AdventCommand.java b/LobbySystem/src/de/steamwar/lobby/special/advent/AdventCommand.java index efbac117..28b06419 100644 --- a/LobbySystem/src/de/steamwar/lobby/special/advent/AdventCommand.java +++ b/LobbySystem/src/de/steamwar/lobby/special/advent/AdventCommand.java @@ -25,6 +25,7 @@ import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.lobby.LobbySystem; import de.steamwar.sql.NodeMember; +import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -72,6 +73,7 @@ public class AdventCommand extends SWCommand { item = SWItem.getPlayerSkull(random.nextBoolean() ? "MHF_Present1" : "MHF_Present2"); } else { item = new SWItem(Material.CHEST, ""); + item.setLore(List.of("ยงe>>>ยง7 " + SchematicNode.getSchematicNode(present.getSchematicId()).getName())); } item.setName(LobbySystem.getMessage().parse("ADVENT_CALENDAR_DAY", player, present.getDay())); itemList.add(new SWListInv.SWListEntry<>(item, present)); From 7927a195d63642d2288533c0bc1d25cefd7dd7fb Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 11:39:23 +0100 Subject: [PATCH 23/49] Fix REntity for 1.15.2-1.21.3 <1.15.2: Untested --- .../utils/PlayerMovementWrapper15.java | 11 ++--- .../utils/PlayerMovementWrapper18.java | 11 ++--- .../utils/PlayerMovementWrapper19.java | 11 ++--- .../utils/PlayerMovementWrapper20.java | 11 ++--- .../bausystem/utils/NMSWrapper21.java | 18 ++++---- .../utils/PlayerMovementWrapper.java | 13 ++---- SpigotCore/SpigotCore_21/build.gradle.kts | 1 + .../de/steamwar/core/BountifulWrapper21.java | 42 +++++++++++++++++++ .../de/steamwar/core/WorldEditWrapper21.java | 28 ++++++++++++- .../de/steamwar/core/BountifulWrapper8.java | 13 +++++- .../de/steamwar/core/BountifulWrapper9.java | 15 ++++++- .../de/steamwar/core/BountifulWrapper.java | 2 +- .../src/de/steamwar/core/ErrorHandler.java | 2 +- .../de/steamwar/core/WorldEditRenderer.java | 2 +- .../src/de/steamwar/entity/REntity.java | 20 +++------ 15 files changed, 127 insertions(+), 73 deletions(-) create mode 100644 SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java index b0ed19b3..12f80cdb 100644 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java +++ b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java @@ -46,14 +46,9 @@ public class PlayerMovementWrapper15 implements PlayerMovementWrapper { PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); Object packet = Reflection.newInstance(teleportPacket); teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0)); - if (Float.isNaN(packetPlayInFlying.a(Float.NaN))) { - teleportYaw.set(packet, rotToByte(player.getLocation().getYaw())); - teleportPitch.set(packet, rotToByte(player.getLocation().getPitch())); - } else { - teleportYaw.set(packet, rotToByte(packetPlayInFlying.a(0.0F))); - teleportPitch.set(packet, rotToByte(packetPlayInFlying.b(0.0F))); - } + teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0), + Float.isNaN(packetPlayInFlying.a(Float.NaN)) ? player.getLocation().getYaw() : packetPlayInFlying.a(0.0F), + Float.isNaN(packetPlayInFlying.b(Float.NaN)) ? player.getLocation().getPitch() : packetPlayInFlying.b(0.0F)); return packet; } } diff --git a/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java b/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java index 8762e418..d1e186d2 100644 --- a/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java +++ b/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java @@ -44,14 +44,9 @@ public class PlayerMovementWrapper18 implements PlayerMovementWrapper { PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); Object packet = Reflection.newInstance(teleportPacket); teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c); - if (packetPlayInFlying.h) { - teleportYaw.set(packet, rotToByte(player.getLocation().getYaw())); - teleportPitch.set(packet, rotToByte(player.getLocation().getPitch())); - } else { - teleportYaw.set(packet, rotToByte(packetPlayInFlying.d)); - teleportPitch.set(packet, rotToByte(packetPlayInFlying.e)); - } + teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, + packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d, + packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e); return packet; } } diff --git a/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java b/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java index 9262bfea..9815023c 100644 --- a/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java +++ b/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java @@ -48,14 +48,9 @@ public class PlayerMovementWrapper19 implements PlayerMovementWrapper { PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); Object packet = Reflection.newInstance(teleportPacket); teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c); - if (packetPlayInFlying.h) { - teleportYaw.set(packet, rotToByte(player.getLocation().getYaw())); - teleportPitch.set(packet, rotToByte(player.getLocation().getPitch())); - } else { - teleportYaw.set(packet, rotToByte(packetPlayInFlying.d)); - teleportPitch.set(packet, rotToByte(packetPlayInFlying.e)); - } + teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, + packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d, + packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e); return packet; } } diff --git a/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java b/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java index 958e4bb8..75701471 100644 --- a/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java +++ b/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java @@ -49,14 +49,9 @@ public class PlayerMovementWrapper20 implements PlayerMovementWrapper { PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); Object packet = Reflection.newInstance(teleportPacket); teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c); - if (packetPlayInFlying.h) { - teleportYaw.set(packet, rotToByte(player.getLocation().getYaw())); - teleportPitch.set(packet, rotToByte(player.getLocation().getPitch())); - } else { - teleportYaw.set(packet, rotToByte(packetPlayInFlying.d)); - teleportPitch.set(packet, rotToByte(packetPlayInFlying.e)); - } + teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, + packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d, + packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e); return packet; } } diff --git a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java index b80cb69c..1c3ce035 100644 --- a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java +++ b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java @@ -21,9 +21,7 @@ package de.steamwar.bausystem.utils; import com.comphenix.tinyprotocol.Reflection; import de.steamwar.bausystem.features.util.NoClipCommand; -import net.minecraft.core.Holder; import net.minecraft.core.component.DataComponents; -import net.minecraft.core.particles.ParticleParam; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -36,8 +34,6 @@ import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.entity.player.PlayerAbilities; import net.minecraft.world.item.component.CustomData; import net.minecraft.world.level.EnumGamemode; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.phys.Vec3D; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; @@ -45,7 +41,6 @@ import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.util.List; import java.util.Optional; public class NMSWrapper21 implements NMSWrapper { @@ -132,12 +127,15 @@ public class NMSWrapper21 implements NMSWrapper { return invalid; } - private final Class explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion"); - private final Reflection.FieldAccessor explosionKnockback = Reflection.getField(explosionPacket, Optional.class, 0); - @Override public Object resetExplosionKnockback(Object packet) { - explosionKnockback.set(packet, Optional.empty()); - return packet; + PacketPlayOutExplosion explosion = (PacketPlayOutExplosion) packet; + + return new PacketPlayOutExplosion( + explosion.b(), + Optional.empty(), + explosion.f(), + explosion.g() + ); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java index b0748762..15aea7f0 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java @@ -24,21 +24,16 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.core.BountifulWrapper; import de.steamwar.core.Core; import de.steamwar.core.VersionDependent; +import de.steamwar.entity.REntity; import org.bukkit.entity.Player; public interface PlayerMovementWrapper { - Class teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport"); - Reflection.FieldAccessor teleportEntity = Reflection.getField(teleportPacket, Integer.TYPE, 0); - BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0); - Reflection.FieldAccessor teleportYaw = Reflection.getField(teleportPacket, Byte.TYPE, 0); - Reflection.FieldAccessor teleportPitch = Reflection.getField(teleportPacket, Byte.TYPE, 1); + Class teleportPacket = REntity.teleportPacket; + Reflection.FieldAccessor teleportEntity = REntity.teleportEntity; + BountifulWrapper.PositionSetter teleportPosition = REntity.teleportPosition; PlayerMovementWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); void setPosition(Player player, Object object); Object convertToOut(Player player, Object object); - - default byte rotToByte(float rot) { - return (byte)((int)(rot * 256.0F / 360.0F)); - } } diff --git a/SpigotCore/SpigotCore_21/build.gradle.kts b/SpigotCore/SpigotCore_21/build.gradle.kts index b4eded6e..b9a7805e 100644 --- a/SpigotCore/SpigotCore_21/build.gradle.kts +++ b/SpigotCore/SpigotCore_21/build.gradle.kts @@ -25,6 +25,7 @@ dependencies { compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) compileOnly(project(":SpigotCore:SpigotCore_18", "default")) compileOnly(project(":SpigotCore:SpigotCore_14", "default")) + compileOnly(project(":SpigotCore:SpigotCore_9", "default")) compileOnly(libs.fawe21) diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java new file mode 100644 index 00000000..d144c9b6 --- /dev/null +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java @@ -0,0 +1,42 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import com.comphenix.tinyprotocol.Reflection; +import net.minecraft.world.entity.PositionMoveRotation; +import net.minecraft.world.phys.Vec3D; + +public class BountifulWrapper21 extends BountifulWrapper9 { + + @Override + public BountifulWrapper.PositionSetter getPositionSetter(Class packetClass, int fieldOffset) { + try { + Reflection.FieldAccessor field = Reflection.getField(packetClass, PositionMoveRotation.class, 0); + + return (packet, x, y, z, pitch, yaw) -> { + PositionMoveRotation pos = field.get(packet); + + field.set(packet, new PositionMoveRotation(new Vec3D(x, y, z), pos.b(), pitch, yaw)); + }; + } catch (IllegalArgumentException e) { + return super.getPositionSetter(packetClass, fieldOffset); + } + } +} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java index c7215c8e..087dc439 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java @@ -28,8 +28,12 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader; import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader; +import com.sk89q.worldedit.math.Vector3; +import com.sk89q.worldedit.math.transform.Transform; +import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import org.enginehub.linbus.stream.LinBinaryIO; import org.enginehub.linbus.stream.LinStream; import org.enginehub.linbus.tree.LinCompoundTag; @@ -38,7 +42,7 @@ import org.enginehub.linbus.tree.LinTagType; import java.io.*; -public class WorldEditWrapper21 implements WorldEditWrapper.IWorldEditWrapper { +public class WorldEditWrapper21 implements WorldEditWrapper { @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { @@ -94,4 +98,26 @@ public class WorldEditWrapper21 implements WorldEditWrapper.IWorldEditWrapper { } } } + + @Override + public org.bukkit.util.Vector getOrigin(Clipboard clipboard) { + return new org.bukkit.util.Vector(clipboard.getOrigin().x(), clipboard.getOrigin().y(), clipboard.getOrigin().z()); + } + + @Override + public Vector getMinimum(Region region) { + return new Vector(region.getMinimumPoint().x(), region.getMinimumPoint().y(), region.getMinimumPoint().z()); + } + + @Override + public Vector getMaximum(Region region) { + return new Vector(region.getMaximumPoint().x(), region.getMaximumPoint().y(), region.getMaximumPoint().z()); + } + + @Override + public Vector applyTransform(Vector vector, Transform transform) { + Vector3 v = Vector3.at(vector.getX(), vector.getY(), vector.getZ()); + v = transform.apply(v); + return new org.bukkit.util.Vector(v.x(), v.y(), v.z()); + } } diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java index d901401c..54ea45b3 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java @@ -25,6 +25,7 @@ import net.md_5.bungee.api.chat.BaseComponent; import net.minecraft.server.v1_8_R3.ChatComponentText; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.PacketPlayOutChat; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -70,11 +71,15 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { Reflection.FieldAccessor posX = Reflection.getField(packetClass, int.class, fieldOffset); Reflection.FieldAccessor posY = Reflection.getField(packetClass, int.class, fieldOffset +1); Reflection.FieldAccessor posZ = Reflection.getField(packetClass, int.class, fieldOffset +2); + Reflection.FieldAccessor lookPitch = Reflection.getField(packetClass, byte.class, 0); + Reflection.FieldAccessor lookYaw = Reflection.getField(packetClass, byte.class, 1); - return (packet, x, y, z) -> { + return (packet, x, y, z, pitch, yaw) -> { posX.set(packet, MathHelper.floor(x * 32)); posY.set(packet, MathHelper.floor(y * 32)); posZ.set(packet, MathHelper.floor(z * 32)); + lookPitch.set(packet, (byte)(pitch * 256 / 360)); + lookYaw.set(packet, (byte)(yaw * 256 / 360)); }; } @@ -83,11 +88,15 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { Reflection.FieldAccessor moveX = Reflection.getField(packetClass, "b", byte.class); Reflection.FieldAccessor moveY = Reflection.getField(packetClass, "c", byte.class); Reflection.FieldAccessor moveZ = Reflection.getField(packetClass, "d", byte.class); + Reflection.FieldAccessor lookYaw = Reflection.getField(packetClass, "e", byte.class); + Reflection.FieldAccessor lookPitch = Reflection.getField(packetClass, "f", byte.class); - return (packet, x, y, z) -> { + return (packet, x, y, z, pitch, yaw) -> { moveX.set(packet, (byte)(x*32)); moveY.set(packet, (byte)(y*32)); moveZ.set(packet, (byte)(z*32)); + lookYaw.set(packet, (byte)(yaw*256/360)); + lookPitch.set(packet, (byte)(pitch*256/360)); }; } diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java index 2832f2f4..b4ae9845 100644 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java +++ b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java @@ -23,6 +23,7 @@ import com.comphenix.tinyprotocol.Reflection; import com.viaversion.viaversion.api.Via; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; +import net.minecraft.server.v1_9_R2.PacketPlayOutEntity; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -64,11 +65,17 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { Reflection.FieldAccessor posX = Reflection.getField(packetClass, double.class, fieldOffset); Reflection.FieldAccessor posY = Reflection.getField(packetClass, double.class, fieldOffset+1); Reflection.FieldAccessor posZ = Reflection.getField(packetClass, double.class, fieldOffset+2); + boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport"); + Class pitchYawType = isByteClass ? byte.class : int.class; + Reflection.FieldAccessor lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1); + Reflection.FieldAccessor lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2); - return (packet, x, y, z) -> { + return (packet, x, y, z, pitch, yaw) -> { posX.set(packet, x); posY.set(packet, y); posZ.set(packet, z); + lookPitch.set(packet, (int)(pitch*256/360)); + lookYaw.set(packet, (int)(yaw*256/360)); }; } @@ -78,11 +85,15 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { Reflection.FieldAccessor moveX = Reflection.getField(packetClass, "b", type); Reflection.FieldAccessor moveY = Reflection.getField(packetClass, "c", type); Reflection.FieldAccessor moveZ = Reflection.getField(packetClass, "d", type); + Reflection.FieldAccessor movePitch = Reflection.getField(packetClass, "e", byte.class); + Reflection.FieldAccessor moveYaw = Reflection.getField(packetClass, "f", byte.class); - return (packet, x, y, z) -> { + return (packet, x, y, z, pitch, yaw) -> { moveX.set(packet, (short)(x*4096)); moveY.set(packet, (short)(y*4096)); moveZ.set(packet, (short)(z*4096)); + movePitch.set(packet, (byte)(pitch*256/360)); + moveYaw.set(packet, (byte)(yaw*256/360)); }; } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java index 2e532908..f1c86afe 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java @@ -44,7 +44,7 @@ public class BountifulWrapper { } public interface PositionSetter { - void set(Object packet, double x, double y, double z); + void set(Object packet, double x, double y, double z, float pitch, float yaw); } public interface UUIDSetter { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java index c9585847..62a7f2b7 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java @@ -77,7 +77,7 @@ public class ErrorHandler extends Handler { return; try { - SWException.log(message, stacktrace); + //SWException.log(message, stacktrace); } catch (SecurityException e) { Core.getInstance().getLogger().log(Level.INFO, "Could not log error in database", e); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java index cd9a0d4e..437a8515 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java @@ -68,7 +68,7 @@ public class WorldEditRenderer { Transform transform = session.getClipboard().getTransform(); Vector a = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMinimum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos); Vector b = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMaximum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos); - drawCuboid(Vector.getMinimum(a, b), Vector.getMaximum(a, b), Particle.VILLAGER_HAPPY, player); + drawCuboid(Vector.getMinimum(a, b), Vector.getMaximum(a, b), TrickyTrialsWrapper.impl.getVillagerHappyParticle(), player); } catch (EmptyClipboardException e) { //ignore } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java index 5f97b0df..6948dc68 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java @@ -393,25 +393,19 @@ public class REntity { return ChatWrapper.impl.getDataWatcherPacket(entityId, dataWatcherKeyValues); } - private static final Class teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport"); - private static final Reflection.FieldAccessor teleportEntity = Reflection.getField(teleportPacket, int.class, 0); - private static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0); - private static final Reflection.FieldAccessor teleportYaw = Reflection.getField(teleportPacket, byte.class, 0); - private static final Reflection.FieldAccessor teleportPitch = Reflection.getField(teleportPacket, byte.class, 1); + public static final Class teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport"); + public static final Reflection.FieldAccessor teleportEntity = Reflection.getField(teleportPacket, int.class, 0); + public static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0); private Object getTeleportPacket(){ Object packet = Reflection.newInstance(teleportPacket); teleportEntity.set(packet, entityId); - teleportPosition.set(packet, x, y, z); - teleportYaw.set(packet, yaw); - teleportPitch.set(packet, pitch); + teleportPosition.set(packet, x, y, z, pitch, yaw); return packet; } private static final Class entityPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity"); private static final Reflection.FieldAccessor moveEntityId = Reflection.getField(entityPacket, int.class, 0); private static final BountifulWrapper.PositionSetter movePosition = BountifulWrapper.impl.getRelMoveSetter(entityPacket); - private static final Reflection.FieldAccessor lookYaw = Reflection.getField(entityPacket, "e", byte.class); - private static final Reflection.FieldAccessor lookPitch = Reflection.getField(entityPacket, "f", byte.class); private static final Class lookPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutEntityLook"); private static final Class movePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutRelEntityMove"); private static final Class moveLookPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutRelEntityMoveLook"); @@ -430,9 +424,7 @@ public class REntity { Object packet = Reflection.newInstance(clazz); moveEntityId.set(packet, entityId); - movePosition.set(packet, diffX, diffY, diffZ); - lookYaw.set(packet, yaw); - lookPitch.set(packet, pitch); + movePosition.set(packet, diffX, diffY, diffZ, pitch, yaw); return packet; } @@ -476,7 +468,7 @@ public class REntity { return entity -> { Object packet = Reflection.newInstance(spawnPacket); entityId.set(packet, entity.entityId); - position.set(packet, entity.x, entity.y, entity.z); + position.set(packet, entity.x, entity.y, entity.z, entity.pitch, entity.yaw); return packet; }; } From f1154f3ea545c9e2370e143f4f4c659680e79073 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 1 Dec 2024 13:17:57 +0100 Subject: [PATCH 24/49] Fix messages of LobbySystem NPC Chat --- LobbySystem/src/de/steamwar/lobby/LobbySystem.properties | 8 ++++---- .../src/de/steamwar/lobby/LobbySystem_de.properties | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties b/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties index 2d1f31c0..2d3aa782 100644 --- a/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties +++ b/LobbySystem/src/de/steamwar/lobby/LobbySystem.properties @@ -1,4 +1,4 @@ -PREFIX = ยงeLobbyยง8Systemยง8ยป +PREFIX = ยงeLobbyยง8Systemยง8ยปยง7 TIME = HH:mm:ss DATE=........ COMMAND_HELP_HEAD=ยง7---=== (ยงe{0}ยง7) ===--- @@ -7,9 +7,9 @@ COMMAND_HELP_HEAD=ยง7---=== (ยงe{0}ยง7) ===--- NPC_CHAT_0 = ยงfHello, I''m {0} and I''m a(n) {1}ยงf. NPC_CHAT_1 = ยงfWelcome on ยงeSteamยง8Warยงf, have fun. NPC_CHAT_2 = ยงeSteamยง8Warยงf was established in 2019. -NPC_CHAT_3 = &fBecome a part of our team by applying via our Discord server (https://steamwar.de/discord). -NPC_CHAT_4 = &fYou can develop your own buildserver features with our Lua script system. -NPC_CHAT_5 = &fThere are many secrets to discover in this lobby. +NPC_CHAT_3 = ยงfBecome a part of our team by applying via our Discord server (https://steamwar.de/discord). +NPC_CHAT_4 = ยงfYou can develop your own buildserver features with our Lua script system. +NPC_CHAT_5 = ยงfThere are many secrets to discover in this lobby. # Portal Command PORTAL_COMMAND_LIST_HELP = ยง8/ยง7portal ยงelist ยง8- ยง7Lists all portals diff --git a/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties b/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties index f1c02955..73808174 100644 --- a/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/LobbySystem/src/de/steamwar/lobby/LobbySystem_de.properties @@ -7,9 +7,9 @@ COMMAND_HELP_HEAD=ยง7---=== (ยงe{0}ยง7) ===--- NPC_CHAT_0 = ยงfHallo, ich bin {0} und bin ein {1}ยงf. NPC_CHAT_1 = ยงfWillkommen auf ยงeSteamยง8Warยงf, viel SpaรŸ dir. NPC_CHAT_2 = ยงeSteamยง8Warยงf gibt es seit 2019. -NPC_CHAT_3 = &fBewerbe dich gerne fรผr unser Team รผber unseren Discord-Server (https://steamwar.de/discord). -NPC_CHAT_4 = &fDu kannst mit unserm Lua Script-System deine eigenen Bau Features programmieren. -NPC_CHAT_5 = &fAuf dieser Lobby sind so einige secrets versteckt. +NPC_CHAT_3 = ยงfBewerbe dich gerne fรผr unser Team รผber unseren Discord-Server (https://steamwar.de/discord). +NPC_CHAT_4 = ยงfDu kannst mit unserm Lua Script-System deine eigenen Bau Features programmieren. +NPC_CHAT_5 = ยงfAuf dieser Lobby sind so einige secrets versteckt. # Portal Command PORTAL_COMMAND_LIST_HELP = ยง8/ยง7portal ยงelist ยง8- ยง7Listet alle Portale auf From 37072b1f494a1d5aeeddf54a9ce6ae76a5e832b0 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 17:06:35 +0100 Subject: [PATCH 25/49] Fixes... --- .../de/steamwar/core/FlatteningWrapper14.java | 2 +- .../src/de/steamwar/core/WorldEditWrapper14.java | 16 ++++++---------- .../src/de/steamwar/core/WorldEditWrapper8.java | 13 +------------ .../src/de/steamwar/core/ErrorHandler.java | 2 +- .../src/de/steamwar/core/WorldEditWrapper.java | 10 ++++++---- 5 files changed, 15 insertions(+), 28 deletions(-) diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java index b7a9bf7f..9d807498 100644 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java @@ -294,7 +294,7 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1); SkullMeta headmeta = (SkullMeta) head.getItemMeta(); assert headmeta != null; - headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(player.startsWith(".") ? player.substring(1) : player)); + headmeta.setOwningPlayer(Bukkit.getOfflinePlayer((player.startsWith(".") ? player.substring(1) : player).replaceAll("ยง.", ""))); headmeta.setDisplayName(player); head.setItemMeta(headmeta); return head; diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java index ae0130ab..cd116bac 100644 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java @@ -63,16 +63,12 @@ public class WorldEditWrapper14 implements WorldEditWrapper { @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { return WorldEditWrapper.getPlayerClipboard(player, schemFormat, (outputStream, clipboard, clipboardHolder) -> { - try { - if(schemFormat){ - ClipboardWriter writer = SCHEM.getWriter(outputStream); - writer.write(clipboard); - writer.close(); - }else{ - SCHEMATIC.getWriter(outputStream).write(clipboard); - } - } catch (Exception e) { - throw new RuntimeException(e.getMessage(), e); + if(schemFormat){ + ClipboardWriter writer = SCHEM.getWriter(outputStream); + writer.write(clipboard); + writer.close(); + }else{ + SCHEMATIC.getWriter(outputStream).write(clipboard); } }); } diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java index e62e7e3f..f3fc2800 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/WorldEditWrapper8.java @@ -37,33 +37,22 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.registry.WorldData; -import de.steamwar.sql.NoClipboardException; import org.bukkit.entity.Player; import java.io.IOException; import java.io.InputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.logging.Level; import java.util.stream.Collectors; -import java.util.zip.GZIPInputStream; public class WorldEditWrapper8 implements WorldEditWrapper { @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { return WorldEditWrapper.getPlayerClipboard(player, schemFormat, (outputStream, clipboard, clipboardHolder) -> - { - try { - ClipboardFormat.SCHEMATIC.getWriter(outputStream).write(clipboard, clipboardHolder.getWorldData()); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); + ClipboardFormat.SCHEMATIC.getWriter(outputStream).write(clipboard, clipboardHolder.getWorldData())); } @Override diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java index 62a7f2b7..c9585847 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java @@ -77,7 +77,7 @@ public class ErrorHandler extends Handler { return; try { - //SWException.log(message, stacktrace); + SWException.log(message, stacktrace); } catch (SecurityException e) { Core.getInstance().getLogger().log(Level.INFO, "Could not log error in database", e); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java index 0d94049c..87906944 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java @@ -22,10 +22,8 @@ package de.steamwar.core; import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.session.ClipboardHolder; import de.steamwar.sql.NoClipboardException; -import org.apache.logging.log4j.util.TriConsumer; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.Region; import org.bukkit.Bukkit; @@ -51,7 +49,7 @@ public interface WorldEditWrapper { return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); } - public static InputStream getPlayerClipboard(Player player, boolean schemFormat, TriConsumer consumer) { + public static InputStream getPlayerClipboard(Player player, boolean schemFormat, SchematicWriter consumer) { ClipboardHolder clipboardHolder; try { clipboardHolder = WorldEditWrapper.getWorldEditPlugin().getSession(player).getClipboard(); @@ -73,7 +71,7 @@ public interface WorldEditWrapper { new Thread(() -> { try { - consumer.accept(outputStream, clipboard, clipboardHolder); + consumer.write(outputStream, clipboard, clipboardHolder); } catch (Exception e) { Core.getInstance().getLogger().log(Level.SEVERE, "Could not write schematic", e); } @@ -86,4 +84,8 @@ public interface WorldEditWrapper { return inputStream; } + + public static interface SchematicWriter { + void write(OutputStream outputStream, Clipboard clipboard, ClipboardHolder holder) throws IOException; + } } From 47cca70d95c1f5cd6a0ef72fb7c3ee17364b709d Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 17:12:48 +0100 Subject: [PATCH 26/49] Fix Particle --- .../team/boundary/BoundaryViewer.java | 3 +- .../core/TrickyParticleWrapper21.java | 29 +++++++++++++++++++ .../steamwar/core/TrickyTrialsWrapper21.java | 5 ---- .../steamwar/core/TrickyParticleWrapper9.java | 29 +++++++++++++++++++ .../steamwar/core/TrickyParticleWrapper.java | 28 ++++++++++++++++++ .../de/steamwar/core/TrickyTrialsWrapper.java | 5 ---- .../de/steamwar/core/WorldEditRenderer.java | 2 +- 7 files changed, 89 insertions(+), 12 deletions(-) create mode 100644 SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyParticleWrapper21.java create mode 100644 SpigotCore/SpigotCore_9/src/de/steamwar/core/TrickyParticleWrapper9.java create mode 100644 SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyParticleWrapper.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java index e2e1ec37..51bef65c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.core.TrickyParticleWrapper; import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; @@ -57,7 +58,7 @@ public class BoundaryViewer implements Listener { } private void showRegion(Region region, Player player) { - drawCuboid(player, TrickyTrialsWrapper.impl.getVillagerHappyParticle(), region.getMinPoint(), region.getMaxPoint()); + drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getMinPoint(), region.getMaxPoint()); if (region.hasType(RegionType.TESTBLOCK)) { drawCuboid(player, Particle.END_ROD, region.getMinPointTestblockExtension(), region.getMaxPointTestblockExtension()); } diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyParticleWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyParticleWrapper21.java new file mode 100644 index 00000000..5575a45b --- /dev/null +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyParticleWrapper21.java @@ -0,0 +1,29 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import org.bukkit.Particle; + +public class TrickyParticleWrapper21 implements TrickyParticleWrapper { + @Override + public Particle getVillagerHappy() { + return Particle.HAPPY_VILLAGER; + } +} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java index 00717405..1b10c742 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java @@ -41,11 +41,6 @@ public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper { return Material.TURTLE_SCUTE; } - @Override - public Particle getVillagerHappyParticle() { - return Particle.HAPPY_VILLAGER; - } - @Override public String getInventoryTitle(InventoryView view) { return view.getTitle(); diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/TrickyParticleWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/TrickyParticleWrapper9.java new file mode 100644 index 00000000..5c2c879b --- /dev/null +++ b/SpigotCore/SpigotCore_9/src/de/steamwar/core/TrickyParticleWrapper9.java @@ -0,0 +1,29 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import org.bukkit.Particle; + +public class TrickyParticleWrapper9 implements TrickyParticleWrapper { + @Override + public Particle getVillagerHappy() { + return Particle.VILLAGER_HAPPY; + } +} diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyParticleWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyParticleWrapper.java new file mode 100644 index 00000000..ae781100 --- /dev/null +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyParticleWrapper.java @@ -0,0 +1,28 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.core; + +import org.bukkit.Particle; + +public interface TrickyParticleWrapper { + public TrickyParticleWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); + + Particle getVillagerHappy(); +} diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java index 7c2cfc4d..da8fc7cd 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java @@ -20,7 +20,6 @@ package de.steamwar.core; import org.bukkit.Material; -import org.bukkit.Particle; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.inventory.InventoryView; @@ -34,9 +33,5 @@ public interface TrickyTrialsWrapper { Material getTurtleScute(); - default Particle getVillagerHappyParticle() { - return Particle.VILLAGER_HAPPY; - } - String getInventoryTitle(InventoryView view); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java index 437a8515..377efe13 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java @@ -68,7 +68,7 @@ public class WorldEditRenderer { Transform transform = session.getClipboard().getTransform(); Vector a = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMinimum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos); Vector b = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMaximum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos); - drawCuboid(Vector.getMinimum(a, b), Vector.getMaximum(a, b), TrickyTrialsWrapper.impl.getVillagerHappyParticle(), player); + drawCuboid(Vector.getMinimum(a, b), Vector.getMaximum(a, b), TrickyParticleWrapper.impl.getVillagerHappy(), player); } catch (EmptyClipboardException e) { //ignore } From f01cb668740afae24caaed5556884e468b19f520 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 17:20:24 +0100 Subject: [PATCH 27/49] Add CraftbukkitWrapper21 for FightSystem --- FightSystem/FightSystem_21/build.gradle.kts | 43 +++++++++++++++++++ .../utils/CraftbukkitWrapper21.java | 30 +++++++++++++ FightSystem/build.gradle.kts | 1 + settings.gradle.kts | 1 + 4 files changed, 75 insertions(+) create mode 100644 FightSystem/FightSystem_21/build.gradle.kts create mode 100644 FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper21.java diff --git a/FightSystem/FightSystem_21/build.gradle.kts b/FightSystem/FightSystem_21/build.gradle.kts new file mode 100644 index 00000000..a05590d1 --- /dev/null +++ b/FightSystem/FightSystem_21/build.gradle.kts @@ -0,0 +1,43 @@ +/* + * 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(project(":FightSystem:FightSystem_Core", "default")) + compileOnly(project(":FightSystem:FightSystem_18", "default")) + + compileOnly(libs.paperapi21) { + attributes { + // Very Hacky, but it works + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) + } + } + + compileOnly(libs.nms21) { + attributes { + // Very Hacky, but it works + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) + } + } + + compileOnly(libs.fastutil) +} diff --git a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper21.java b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper21.java new file mode 100644 index 00000000..9e52bb36 --- /dev/null +++ b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper21.java @@ -0,0 +1,30 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.fightsystem.utils; + +import org.bukkit.entity.Entity; + +public class CraftbukkitWrapper21 extends CraftbukkitWrapper18 { + + @Override + public float headRotation(Entity e) { + return getEntity(e).bS(); + } +} diff --git a/FightSystem/build.gradle.kts b/FightSystem/build.gradle.kts index 3f367461..0cd412bc 100644 --- a/FightSystem/build.gradle.kts +++ b/FightSystem/build.gradle.kts @@ -37,4 +37,5 @@ dependencies { implementation(project(":FightSystem:FightSystem_18")) implementation(project(":FightSystem:FightSystem_19")) implementation(project(":FightSystem:FightSystem_20")) + implementation(project(":FightSystem:FightSystem_21")) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 29574740..69d5c67b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -198,6 +198,7 @@ include( "FightSystem:FightSystem_18", "FightSystem:FightSystem_19", "FightSystem:FightSystem_20", + "FightSystem:FightSystem_21", "FightSystem:FightSystem_Core", "FightSystem:FightSystem_Standalone" ) From b041a50abb7469fd31759fac517a970a92416c18 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 18:56:21 +0100 Subject: [PATCH 28/49] Remove Unused Replace --- .../SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java index 9d807498..b7a9bf7f 100644 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java @@ -294,7 +294,7 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1); SkullMeta headmeta = (SkullMeta) head.getItemMeta(); assert headmeta != null; - headmeta.setOwningPlayer(Bukkit.getOfflinePlayer((player.startsWith(".") ? player.substring(1) : player).replaceAll("ยง.", ""))); + headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(player.startsWith(".") ? player.substring(1) : player)); headmeta.setDisplayName(player); head.setItemMeta(headmeta); return head; From 4dcfeb77b2e03b1333739f7b3c9dadfad788d19f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 1 Dec 2024 19:19:27 +0100 Subject: [PATCH 29/49] Unlock 21 BuilderCloud (and Bau) --- .../src/de/steamwar/velocitycore/ServerVersion.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java b/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java index 5da93505..31b8e39e 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java @@ -31,11 +31,16 @@ public enum ServerVersion { SPIGOT_12("spigot-1.12.2.jar", 12), SPIGOT_15("spigot-1.15.2.jar", 15), PAPER_19("paper-1.19.3.jar", 19), - PAPER_20("paper-1.20.1.jar", 20); + PAPER_20("paper-1.20.1.jar", 20), + PAPER_21("paper-1.21.jar", 21); private static final Map chatMap = new HashMap<>(); static { + chatMap.put("21", ServerVersion.PAPER_21); + chatMap.put("1.21", ServerVersion.PAPER_21); + chatMap.put("1.21.3", ServerVersion.PAPER_21); + chatMap.put("20", ServerVersion.PAPER_20); chatMap.put("1.20", ServerVersion.PAPER_20); chatMap.put("1.20.1", ServerVersion.PAPER_20); From 116005c0c9f2ffc24197a13911482f42f2429937 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 1 Dec 2024 19:22:48 +0100 Subject: [PATCH 30/49] Fix Tablist gone after softreload --- .../src/de/steamwar/velocitycore/tablist/TablistManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java b/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java index c008d76c..06c0d725 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java +++ b/VelocityCore/src/de/steamwar/velocitycore/tablist/TablistManager.java @@ -55,7 +55,7 @@ public class TablistManager extends BasicListener { public TablistManager() { VelocityCore.schedule(this::updateTablist).repeat(1, TimeUnit.SECONDS).schedule(); synchronized (tablists) { - VelocityCore.getProxy().getAllPlayers().forEach(player -> tablists.put(player, new Tablist(player))); + VelocityCore.getProxy().getAllPlayers().forEach(player -> tablists.computeIfAbsent(player, Tablist::new).onServerSwitch()); } } From a4d5850555d5e91a9ef44c9761c92a4fa142a30b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 19:40:07 +0100 Subject: [PATCH 31/49] Hotfix: SimulatorBaseGui InventoryView --- .../features/simulator/gui/base/SimulatorBaseGui.java | 2 +- .../src/de/steamwar/core/TrickyTrialsWrapper21.java | 5 +++++ .../src/de/steamwar/core/TrickyTrialsWrapper8.java | 5 +++++ .../src/de/steamwar/core/TrickyTrialsWrapper.java | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java index 9e81340b..7aee66a0 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java @@ -70,7 +70,7 @@ public abstract class SimulatorBaseGui { return; } - player.getOpenInventory().close(); + TrickyTrialsWrapper.impl.closeInventoryView(player.getOpenInventory()); inventory = new SWInventory(player, () -> { inv = Bukkit.createInventory(null, size, title()); diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java index 1b10c742..840c4cad 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java @@ -45,4 +45,9 @@ public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper { public String getInventoryTitle(InventoryView view) { return view.getTitle(); } + + @Override + public void closeInventoryView(InventoryView view) { + view.close(); + } } diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java index 35b80c58..0b67fdff 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java @@ -44,4 +44,9 @@ public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper { public String getInventoryTitle(InventoryView view) { return view.getTitle(); } + + @Override + public void closeInventoryView(InventoryView view) { + view.close(); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java index da8fc7cd..02d8febf 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java @@ -34,4 +34,6 @@ public interface TrickyTrialsWrapper { Material getTurtleScute(); String getInventoryTitle(InventoryView view); + + void closeInventoryView(InventoryView view); } From 851904beac27b76aa70ced134b58d90233e45746 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 1 Dec 2024 19:57:59 +0100 Subject: [PATCH 32/49] Fix 1.20 Baus --- BauSystem/BauSystem_Main/build.gradle.kts | 7 +------ .../features/simulator/gui/base/SimulatorBaseGui.java | 2 +- .../src/de/steamwar/core/TrickyTrialsWrapper21.java | 6 ------ .../src/de/steamwar/core/TrickyTrialsWrapper.java | 2 -- 4 files changed, 2 insertions(+), 15 deletions(-) diff --git a/BauSystem/BauSystem_Main/build.gradle.kts b/BauSystem/BauSystem_Main/build.gradle.kts index 9ae53822..8f46699d 100644 --- a/BauSystem/BauSystem_Main/build.gradle.kts +++ b/BauSystem/BauSystem_Main/build.gradle.kts @@ -35,12 +35,7 @@ dependencies { annotationProcessor(libs.classindex) compileOnly(project(":SpigotCore", "default")) - compileOnly(libs.paperapi21) { - attributes { - // Very Hacky, but it works - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) - } - } + compileOnly(libs.spigotapi) compileOnly(libs.axiom) compileOnly(libs.authlib) compileOnly(libs.viaapi) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java index 7aee66a0..82c8dabb 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java @@ -70,7 +70,7 @@ public abstract class SimulatorBaseGui { return; } - TrickyTrialsWrapper.impl.closeInventoryView(player.getOpenInventory()); + player.closeInventory(); inventory = new SWInventory(player, () -> { inv = Bukkit.createInventory(null, size, title()); diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java index 840c4cad..32932a25 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java @@ -20,7 +20,6 @@ package de.steamwar.core; import org.bukkit.Material; -import org.bukkit.Particle; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.inventory.InventoryView; @@ -45,9 +44,4 @@ public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper { public String getInventoryTitle(InventoryView view) { return view.getTitle(); } - - @Override - public void closeInventoryView(InventoryView view) { - view.close(); - } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java index 02d8febf..da8fc7cd 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java @@ -34,6 +34,4 @@ public interface TrickyTrialsWrapper { Material getTurtleScute(); String getInventoryTitle(InventoryView view); - - void closeInventoryView(InventoryView view); } From bf21d7ee90200ac8069e4bc9814ea56d887fee45 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 1 Dec 2024 19:58:27 +0100 Subject: [PATCH 33/49] Fix 1.20 Baus --- .../src/de/steamwar/core/TrickyTrialsWrapper8.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java index 0b67fdff..35b80c58 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java @@ -44,9 +44,4 @@ public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper { public String getInventoryTitle(InventoryView view) { return view.getTitle(); } - - @Override - public void closeInventoryView(InventoryView view) { - view.close(); - } } From a009c841b149c0dfdfd6b03da63a43d8a0f08eac Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 20:13:12 +0100 Subject: [PATCH 34/49] Fix: getOpenInventory --- .../features/simulator/gui/base/SimulatorBaseGui.java | 4 ++-- .../src/de/steamwar/core/TrickyTrialsWrapper21.java | 6 ++++++ .../src/de/steamwar/core/TrickyTrialsWrapper8.java | 6 ++++++ .../src/de/steamwar/core/TrickyTrialsWrapper.java | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java index 82c8dabb..65bee3de 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java @@ -55,7 +55,7 @@ public abstract class SimulatorBaseGui { inv.setItem(i, null); } setup(); - if (player.getOpenInventory().getTopInventory() != inv) { + if (TrickyTrialsWrapper.impl.getTopInventory(player.getOpenInventory()) != inv) { inventory.open(); SimulatorWatcher.watch(player, simulator, this::open); } @@ -63,7 +63,7 @@ public abstract class SimulatorBaseGui { player.getOpenInventory().setTitle(title()); } populate(); - if (player.getOpenInventory().getTopInventory() == inv) { + if (TrickyTrialsWrapper.impl.getTopInventory(player.getOpenInventory()) == inv) { inventory.open(); SimulatorWatcher.watch(player, simulator, this::open); } diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java index 32932a25..096fc5c4 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java @@ -22,6 +22,7 @@ package de.steamwar.core; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper { @@ -44,4 +45,9 @@ public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper { public String getInventoryTitle(InventoryView view) { return view.getTitle(); } + + @Override + public Inventory getTopInventory(InventoryView view) { + return view.getTopInventory(); + } } diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java index 35b80c58..6e3ed151 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java @@ -22,6 +22,7 @@ package de.steamwar.core; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper { @@ -44,4 +45,9 @@ public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper { public String getInventoryTitle(InventoryView view) { return view.getTitle(); } + + @Override + public Inventory getTopInventory(InventoryView view) { + return view.getTopInventory(); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java index da8fc7cd..5ce7ec2e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java @@ -22,6 +22,7 @@ package de.steamwar.core; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; public interface TrickyTrialsWrapper { @@ -34,4 +35,6 @@ public interface TrickyTrialsWrapper { Material getTurtleScute(); String getInventoryTitle(InventoryView view); + + Inventory getTopInventory(InventoryView view); } From e16410fd65b7b4b032d6f381936967199069d008 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 21:54:59 +0100 Subject: [PATCH 35/49] Hotfix: Fix BountifulWrapper9 (hopefully) --- .../features/simulator/gui/base/SimulatorBaseGui.java | 2 +- .../src/de/steamwar/core/BountifulWrapper9.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java index 65bee3de..4e70c08c 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java @@ -47,7 +47,7 @@ public abstract class SimulatorBaseGui { public final void open() { String newTitle = title(); - String originalTitle = TrickyTrialsWrapper.impl.getInventoryTitle(player.getOpenInventory()); + String originalTitle = player.getOpenInventory().getTitle(); if (inv != null && (Core.getVersion() > 19 || newTitle.equals(originalTitle))) { // TODO: Flickering is better but not gone! diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java index b4ae9845..55905ce5 100644 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java +++ b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java @@ -74,8 +74,10 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { posX.set(packet, x); posY.set(packet, y); posZ.set(packet, z); - lookPitch.set(packet, (int)(pitch*256/360)); - lookYaw.set(packet, (int)(yaw*256/360)); + int pitchInt = (int) (pitch*256/360); + lookPitch.set(packet, isByteClass ? (byte) pitchInt : pitchInt); + int yawInt = (int) (yaw*256/360); + lookYaw.set(packet, isByteClass ? (byte) yawInt : yawInt); }; } From 66d417a2107310d67620edc338800822cd6bcc08 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 22:01:59 +0100 Subject: [PATCH 36/49] Remove Now Unused Wrappers --- .../features/simulator/gui/base/SimulatorBaseGui.java | 4 ++-- .../src/de/steamwar/core/TrickyTrialsWrapper21.java | 10 ---------- .../src/de/steamwar/core/TrickyTrialsWrapper8.java | 10 ---------- .../src/de/steamwar/core/TrickyTrialsWrapper.java | 4 ---- .../src/de/steamwar/inventory/SWInventory.java | 4 ++-- 5 files changed, 4 insertions(+), 28 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java index 4e70c08c..e3ddd797 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java @@ -55,7 +55,7 @@ public abstract class SimulatorBaseGui { inv.setItem(i, null); } setup(); - if (TrickyTrialsWrapper.impl.getTopInventory(player.getOpenInventory()) != inv) { + if (player.getOpenInventory().getTopInventory() != inv) { inventory.open(); SimulatorWatcher.watch(player, simulator, this::open); } @@ -63,7 +63,7 @@ public abstract class SimulatorBaseGui { player.getOpenInventory().setTitle(title()); } populate(); - if (TrickyTrialsWrapper.impl.getTopInventory(player.getOpenInventory()) == inv) { + if (player.getOpenInventory().getTopInventory() == inv) { inventory.open(); SimulatorWatcher.watch(player, simulator, this::open); } diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java index 096fc5c4..fe3bc55f 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/TrickyTrialsWrapper21.java @@ -40,14 +40,4 @@ public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper { public Material getTurtleScute() { return Material.TURTLE_SCUTE; } - - @Override - public String getInventoryTitle(InventoryView view) { - return view.getTitle(); - } - - @Override - public Inventory getTopInventory(InventoryView view) { - return view.getTopInventory(); - } } diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java index 6e3ed151..5bb66d2d 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/TrickyTrialsWrapper8.java @@ -40,14 +40,4 @@ public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper { public Material getTurtleScute() { return Material.STONE; } - - @Override - public String getInventoryTitle(InventoryView view) { - return view.getTitle(); - } - - @Override - public Inventory getTopInventory(InventoryView view) { - return view.getTopInventory(); - } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java index 5ce7ec2e..9a3d51dd 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TrickyTrialsWrapper.java @@ -33,8 +33,4 @@ public interface TrickyTrialsWrapper { Enchantment getUnbreakingEnchantment(); Material getTurtleScute(); - - String getInventoryTitle(InventoryView view); - - Inventory getTopInventory(InventoryView view); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java index 11fe1ec6..001fae9f 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java @@ -139,7 +139,7 @@ public class SWInventory implements Listener { public void open() { InventoryView view = player.openInventory(inventory); - title = TrickyTrialsWrapper.impl.getInventoryTitle(view); + title = view.getTitle(); Core.getInstance().getLogger().info("[SWINV] Opened " + title + " for " + player.getName()); if(!open) { Bukkit.getPluginManager().registerEvents(this, Core.getInstance()); @@ -154,7 +154,7 @@ public class SWInventory implements Listener { if (callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null) { e.setCancelled(true); - Core.getInstance().getLogger().info("[SWINV] " + e.getWhoClicked().getName() + " " + e.getClick().name() + " clicked " + e.getRawSlot() + " on " + (e.getCurrentItem() != null ? e.getCurrentItem().getItemMeta().getDisplayName() : "[EMPTY]") + " in " + TrickyTrialsWrapper.impl.getInventoryTitle(e.getView())); + Core.getInstance().getLogger().info("[SWINV] " + e.getWhoClicked().getName() + " " + e.getClick().name() + " clicked " + e.getRawSlot() + " on " + (e.getCurrentItem() != null ? e.getCurrentItem().getItemMeta().getDisplayName() : "[EMPTY]") + " in " + e.getView().getTitle()); callbacks.get(e.getRawSlot()).accept(e); } } From 7140fbb1a0c55431a605d87083a338f8db791f62 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 22:31:47 +0100 Subject: [PATCH 37/49] Hotfix: Replays --- .../SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java index 55905ce5..5d663033 100644 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java +++ b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java @@ -65,7 +65,7 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { Reflection.FieldAccessor posX = Reflection.getField(packetClass, double.class, fieldOffset); Reflection.FieldAccessor posY = Reflection.getField(packetClass, double.class, fieldOffset+1); Reflection.FieldAccessor posZ = Reflection.getField(packetClass, double.class, fieldOffset+2); - boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport"); + boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport") || packetClass.getSimpleName().contains("PacketPlayOutNamedEntitySpawn"); Class pitchYawType = isByteClass ? byte.class : int.class; Reflection.FieldAccessor lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1); Reflection.FieldAccessor lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2); From dfe7c389f6ba4fada70438bdb3304e5e0d123c06 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 22:36:12 +0100 Subject: [PATCH 38/49] Hotfix: Replays (Again!) --- .../src/de/steamwar/core/BountifulWrapper9.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java index 5d663033..55e31925 100644 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java +++ b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java @@ -74,10 +74,10 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { posX.set(packet, x); posY.set(packet, y); posZ.set(packet, z); - int pitchInt = (int) (pitch*256/360); - lookPitch.set(packet, isByteClass ? (byte) pitchInt : pitchInt); - int yawInt = (int) (yaw*256/360); - lookYaw.set(packet, isByteClass ? (byte) yawInt : yawInt); + byte pitchInt = (byte) (pitch*256/360); + lookPitch.set(packet, isByteClass ? pitchInt : (int) pitchInt); + byte yawInt = (byte) (yaw*256/360); + lookYaw.set(packet, isByteClass ? yawInt : (int) yawInt); }; } From 2ea8c939613699184ff92c4c00d5c51466ecb1ea Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 22:41:36 +0100 Subject: [PATCH 39/49] Hotfix: Replays (Again Again!) --- .../src/de/steamwar/core/BountifulWrapper9.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java index 55e31925..252f8675 100644 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java +++ b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java @@ -74,10 +74,12 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { posX.set(packet, x); posY.set(packet, y); posZ.set(packet, z); - byte pitchInt = (byte) (pitch*256/360); - lookPitch.set(packet, isByteClass ? pitchInt : (int) pitchInt); - byte yawInt = (byte) (yaw*256/360); - lookYaw.set(packet, isByteClass ? yawInt : (int) yawInt); + byte pitchByte = (byte) (pitch*256/360); + int pitchInt = (int) (pitch*256/360); + lookPitch.set(packet, isByteClass ? pitchByte : pitchInt); + byte yawByte = (byte) (yaw*256/360); + int yawInt = (int) (yaw*256/360); + lookYaw.set(packet, isByteClass ? yawByte : yawInt); }; } From 2788670bbb74abed15c3a020d5aca27bf577243e Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 22:46:44 +0100 Subject: [PATCH 40/49] Hotfix: Replays (Again Again Again!) --- .../src/de/steamwar/core/BountifulWrapper9.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java index 252f8675..fa126698 100644 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java +++ b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java @@ -74,12 +74,13 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { posX.set(packet, x); posY.set(packet, y); posZ.set(packet, z); - byte pitchByte = (byte) (pitch*256/360); - int pitchInt = (int) (pitch*256/360); - lookPitch.set(packet, isByteClass ? pitchByte : pitchInt); - byte yawByte = (byte) (yaw*256/360); - int yawInt = (int) (yaw*256/360); - lookYaw.set(packet, isByteClass ? yawByte : yawInt); + if (isByteClass) { + lookPitch.set(packet, (byte) (pitch*256/360)); + lookYaw.set(packet, (byte) (yaw*256/360)); + } else { + lookPitch.set(packet, (int) (pitch*256/360)); + lookYaw.set(packet, (int) (yaw*256/360)); + } }; } From e61466e3903609be4f0eac32dcafecf30da62768 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 23:32:04 +0100 Subject: [PATCH 41/49] Hotfix: Fix 1.21 Schematic Writer --- .../src/de/steamwar/core/WorldEditWrapper21.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java index 087dc439..a3dbe8ce 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java @@ -21,11 +21,10 @@ package de.steamwar.core; import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV2; import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV3; -import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriterV3; import com.sk89q.jnbt.NBTInputStream; -import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader; import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader; import com.sk89q.worldedit.math.Vector3; @@ -46,13 +45,7 @@ public class WorldEditWrapper21 implements WorldEditWrapper { @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { - return WorldEditWrapper.getPlayerClipboard(player, schemFormat, (outputStream, clipboard, clipboardHolder) -> { - try { - new FastSchematicWriterV3(new NBTOutputStream(outputStream)).write(clipboard); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); + return WorldEditWrapper.getPlayerClipboard(player, schemFormat, (outputStream, clipboard, clipboardHolder) -> BuiltInClipboardFormat.FAST_V3.getWriter(outputStream).write(clipboard)); } @Override From 015391040261fac8223851756fcaf8988809a030 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 23:39:00 +0100 Subject: [PATCH 42/49] Hotfix: Fix 1.21 Schematic Writer (again) --- .../src/de/steamwar/core/WorldEditWrapper21.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java index a3dbe8ce..b2ec6b38 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java @@ -25,6 +25,7 @@ import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader; import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader; import com.sk89q.worldedit.math.Vector3; @@ -45,7 +46,11 @@ public class WorldEditWrapper21 implements WorldEditWrapper { @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { - return WorldEditWrapper.getPlayerClipboard(player, schemFormat, (outputStream, clipboard, clipboardHolder) -> BuiltInClipboardFormat.FAST_V3.getWriter(outputStream).write(clipboard)); + return WorldEditWrapper.getPlayerClipboard(player, schemFormat, (outputStream, clipboard, clipboardHolder) -> { + ClipboardWriter writer = BuiltInClipboardFormat.FAST_V3.getWriter(outputStream); + writer.write(clipboard); + writer.close(); + }); } @Override From 990a59ae72414ce0cac26a51985e41908a5146c8 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 1 Dec 2024 23:44:08 +0100 Subject: [PATCH 43/49] Hotfix: Fix 1.21 Schematic Writer (again?) --- .../src/de/steamwar/core/WorldEditWrapper21.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java index b2ec6b38..4ae22cac 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java @@ -82,6 +82,10 @@ public class WorldEditWrapper21 implements WorldEditWrapper { LinCompoundTag entry = LinRootEntry.readFrom(linStream).value(); + if (entry.value().size() == 1) { + entry = entry.getTag("Schematic", LinTagType.compoundTag()); + } + bis.reset(); switch (entry.getTag("Version", LinTagType.intTag()).valueAsInt()) { From f97cc2ca612bdcc78a68469a280d7ce15c88f881 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 2 Dec 2024 17:24:17 +0100 Subject: [PATCH 44/49] Hotfix CustomMap --- LobbySystem/src/de/steamwar/lobby/map/CustomMap.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java b/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java index 002ba041..f3d944ae 100644 --- a/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java +++ b/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java @@ -97,8 +97,7 @@ public class CustomMap implements Listener { for (Entity entity : event.getChunk().getEntities()) { if (!(entity instanceof ItemFrame)) continue; ItemFrame itemFrame = (ItemFrame) entity; - ItemStack itemStack = itemFrame.getItem(); - if (itemStack.getType() != Material.FILLED_MAP) continue; + itemFrame.setItem(new ItemStack(Material.FILLED_MAP, 1)); Vector vector = itemFrame.getLocation().getBlock().getLocation().toVector(); if (itemFrameIndex.containsKey(vector)) { if (itemFrames[itemFrameIndex.get(vector)] != null) continue; From d93d7c95eb8cfe54c42e21dc47bc4cb4d690be48 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 2 Dec 2024 18:21:45 +0100 Subject: [PATCH 45/49] Remove ModifyCommand --- .../steamwar/lobby/command/ModifyCommand.java | 88 ------------------- 1 file changed, 88 deletions(-) delete mode 100644 LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java diff --git a/LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java b/LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java deleted file mode 100644 index d782112d..00000000 --- a/LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java +++ /dev/null @@ -1,88 +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.command; - -import de.steamwar.command.SWCommand; -import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.listener.PlayerSpawn; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserPerm; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.HashSet; -import java.util.Set; - -public class ModifyCommand extends SWCommand implements Listener { - - private static final Set modifying = new HashSet<>(); - - public static boolean modifying(HumanEntity player) { - return modifying.contains(player); - } - - public ModifyCommand() { - super("modify"); - Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin()); - } - - @Register - public void modify(Player player) { - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - if(!user.hasPerm(UserPerm.ADMINISTRATION)) { - return; - } - - if(modifying(player)) { - modifying.remove(player); - LobbySystem.getEntityServer(true).removePlayer(player); - player.setGameMode(GameMode.ADVENTURE); - player.setOp(false); - PlayerSpawn.giveItems(player); - }else { - modifying.add(player); - LobbySystem.getEntityServer(true).addPlayer(player); - player.setGameMode(GameMode.CREATIVE); - player.setOp(true); - } - } - - @EventHandler - public void onLeave(PlayerQuitEvent event) { - Player player = event.getPlayer(); - - modifying.remove(player); - player.setOp(false); - } - - @Register("waitinghallspawn") - public void setWaitingHallSpawn(Player player) { - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - if(!user.hasPerm(UserPerm.ADMINISTRATION)) - return; - - LobbySystem.config().setWaitingHallSpawn(player.getLocation()); - } -} From bd95e95bc38fa63ca4e0c4dd83b0cc02dfa8de39 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 2 Dec 2024 18:25:47 +0100 Subject: [PATCH 46/49] Revert "Remove ModifyCommand" This reverts commit d93d7c95eb8cfe54c42e21dc47bc4cb4d690be48. --- .../steamwar/lobby/command/ModifyCommand.java | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java diff --git a/LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java b/LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java new file mode 100644 index 00000000..d782112d --- /dev/null +++ b/LobbySystem/src/de/steamwar/lobby/command/ModifyCommand.java @@ -0,0 +1,88 @@ +/* + * 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.command; + +import de.steamwar.command.SWCommand; +import de.steamwar.lobby.LobbySystem; +import de.steamwar.lobby.listener.PlayerSpawn; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashSet; +import java.util.Set; + +public class ModifyCommand extends SWCommand implements Listener { + + private static final Set modifying = new HashSet<>(); + + public static boolean modifying(HumanEntity player) { + return modifying.contains(player); + } + + public ModifyCommand() { + super("modify"); + Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin()); + } + + @Register + public void modify(Player player) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + if(!user.hasPerm(UserPerm.ADMINISTRATION)) { + return; + } + + if(modifying(player)) { + modifying.remove(player); + LobbySystem.getEntityServer(true).removePlayer(player); + player.setGameMode(GameMode.ADVENTURE); + player.setOp(false); + PlayerSpawn.giveItems(player); + }else { + modifying.add(player); + LobbySystem.getEntityServer(true).addPlayer(player); + player.setGameMode(GameMode.CREATIVE); + player.setOp(true); + } + } + + @EventHandler + public void onLeave(PlayerQuitEvent event) { + Player player = event.getPlayer(); + + modifying.remove(player); + player.setOp(false); + } + + @Register("waitinghallspawn") + public void setWaitingHallSpawn(Player player) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + if(!user.hasPerm(UserPerm.ADMINISTRATION)) + return; + + LobbySystem.config().setWaitingHallSpawn(player.getLocation()); + } +} From 79a993c8ec1aacb7824c6f08b7bad247b445817b Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 2 Dec 2024 18:30:08 +0100 Subject: [PATCH 47/49] Hotfix CustomMap --- LobbySystem/src/de/steamwar/lobby/map/CustomMap.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java b/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java index f3d944ae..a664a977 100644 --- a/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java +++ b/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java @@ -97,12 +97,13 @@ public class CustomMap implements Listener { for (Entity entity : event.getChunk().getEntities()) { if (!(entity instanceof ItemFrame)) continue; ItemFrame itemFrame = (ItemFrame) entity; - itemFrame.setItem(new ItemStack(Material.FILLED_MAP, 1)); Vector vector = itemFrame.getLocation().getBlock().getLocation().toVector(); if (itemFrameIndex.containsKey(vector)) { if (itemFrames[itemFrameIndex.get(vector)] != null) continue; itemFrames[itemFrameIndex.get(vector)] = itemFrame; lastModified = 0; + ItemStack itemStack = new ItemStack(Material.FILLED_MAP, 1); + itemFrame.setItem(itemStack); MapView mapView = ((MapMeta) itemFrame.getItem().getItemMeta()).getMapView(); new ArrayList<>(mapView.getRenderers()).forEach(mapView::removeRenderer); mapView.addRenderer(new MapRenderer() { From a040448b5e6ca598401a981ed9095e9ec89f796c Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 2 Dec 2024 18:36:38 +0100 Subject: [PATCH 48/49] Hotfix CustomMap --- LobbySystem/src/de/steamwar/lobby/map/CustomMap.java | 1 + 1 file changed, 1 insertion(+) diff --git a/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java b/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java index a664a977..abe79f53 100644 --- a/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java +++ b/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java @@ -103,6 +103,7 @@ public class CustomMap implements Listener { itemFrames[itemFrameIndex.get(vector)] = itemFrame; lastModified = 0; ItemStack itemStack = new ItemStack(Material.FILLED_MAP, 1); + ((MapMeta) itemStack.getItemMeta()).setMapView(Bukkit.createMap(itemFrame.getWorld())); itemFrame.setItem(itemStack); MapView mapView = ((MapMeta) itemFrame.getItem().getItemMeta()).getMapView(); new ArrayList<>(mapView.getRenderers()).forEach(mapView::removeRenderer); From 57d4727f3568bc643e6630bd93b46c07a19acc21 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 2 Dec 2024 18:39:14 +0100 Subject: [PATCH 49/49] Hotfix CustomMap (die letzte) --- LobbySystem/src/de/steamwar/lobby/map/CustomMap.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java b/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java index abe79f53..70053b87 100644 --- a/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java +++ b/LobbySystem/src/de/steamwar/lobby/map/CustomMap.java @@ -102,9 +102,13 @@ public class CustomMap implements Listener { if (itemFrames[itemFrameIndex.get(vector)] != null) continue; itemFrames[itemFrameIndex.get(vector)] = itemFrame; lastModified = 0; + ItemStack itemStack = new ItemStack(Material.FILLED_MAP, 1); - ((MapMeta) itemStack.getItemMeta()).setMapView(Bukkit.createMap(itemFrame.getWorld())); + MapMeta mapMeta = (MapMeta) itemStack.getItemMeta(); + mapMeta.setMapView(Bukkit.createMap(itemFrame.getWorld())); + itemStack.setItemMeta(mapMeta); itemFrame.setItem(itemStack); + MapView mapView = ((MapMeta) itemFrame.getItem().getItemMeta()).getMapView(); new ArrayList<>(mapView.getRenderers()).forEach(mapView::removeRenderer); mapView.addRenderer(new MapRenderer() {