From d6202f959652870a1c205c317ce462fe65d8fe74 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 26 Nov 2024 16:30:24 +0100 Subject: [PATCH] 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(); + } }