diff --git a/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt b/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt index 8dfb93c6..8fdda864 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt @@ -74,8 +74,8 @@ class InternalKit(id: EntityID): CompositeEntity(id) { this.rawInventory = rawInventory this.rawArmor = rawArmor this.inUse = false - } - }.also { it.setDefault() } + }.also { it.setDefault() } + } @JvmStatic fun getKitInUse(userId: Int, gamemode: String) = useDb { @@ -111,6 +111,7 @@ class InternalKit(id: EntityID): CompositeEntity(id) { fun setDefault() = useDb { find { PersonalKitTable.userId eq userID and (PersonalKitTable.gamemode eq gameMode) and (PersonalKitTable.inUse eq true) } + .filter { it.id.value != this@InternalKit.id.value } .forEach { it.inUse = false } inUse = true } diff --git a/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.kt b/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.kt index 73ac3cb8..5730ff53 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/SchematicNode.kt @@ -120,7 +120,7 @@ class SchematicNode(id: EntityID) : IntEntity(id) { @JvmStatic fun schematicAccessibleForUser(user: SteamwarUser, schematicId: Int?) = fromSql( - "WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE NodeId = ?", + "WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE SN.NodeId = ?", listOf( IntegerColumnType() to user.getId(), IntegerColumnType() to user.getId(), diff --git a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/ReflectionWrapper21.java b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/ReflectionWrapper21.java index 118bfba1..ea8b2d7f 100644 --- a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/ReflectionWrapper21.java +++ b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/ReflectionWrapper21.java @@ -19,11 +19,27 @@ package de.steamwar.fightsystem.utils; +import io.papermc.paper.datacomponent.DataComponentType; import io.papermc.paper.datacomponent.DataComponentTypes; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.HashSet; +import java.util.Set; + public class ReflectionWrapper21 implements ReflectionWrapper { + private static final Set FORBIDDEN_TYPES = new HashSet<>(); + + static { + FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_NAME); + FORBIDDEN_TYPES.add(DataComponentTypes.PROFILE); + FORBIDDEN_TYPES.add(DataComponentTypes.UNBREAKABLE); + FORBIDDEN_TYPES.add(DataComponentTypes.BLOCK_DATA); + FORBIDDEN_TYPES.add(DataComponentTypes.BLOCKS_ATTACKS); + FORBIDDEN_TYPES.add(DataComponentTypes.BUNDLE_CONTENTS); + FORBIDDEN_TYPES.add(DataComponentTypes.CUSTOM_MODEL_DATA); + } + @Override public Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction) { return packet; @@ -31,6 +47,7 @@ public class ReflectionWrapper21 implements ReflectionWrapper { @Override public boolean hasItems(ItemStack stack) { - return stack.getDataTypes().stream().anyMatch(dataComponentType -> dataComponentType != DataComponentTypes.ENCHANTMENTS || dataComponentType != DataComponentTypes.DAMAGE); + FORBIDDEN_TYPES.forEach(stack::resetData); + return false; } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java index fa8e1dc3..afc735a2 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java @@ -34,6 +34,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.PlayerInventory; import java.util.HashSet; import java.util.Set; @@ -62,6 +63,7 @@ public class HotbarKitListener implements Listener { public void onInventoryClick(InventoryClickEvent event) { int slot = event.getSlot(); if (slot < 0 || slot >= HotbarKit.HOTBAR_SIZE) return; + if (!(event.getClickedInventory() instanceof PlayerInventory)) return; Player player = (Player) event.getWhoClicked(); click(player, slot, event); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java index 0bba6ae5..f5489be1 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java @@ -117,7 +117,7 @@ public class Kit { if(kit.isList("Armor")) armor = Objects.requireNonNull(kit.getList("Armor")).toArray(new ItemStack[0]); else - armor = null; + armor = new ItemStack[]{ null, null, null, null}; leaderAllowed = kit.getBoolean("LeaderAllowed"); memberAllowed = kit.getBoolean("MemberAllowed"); if(kit.isList("Effects")) @@ -261,7 +261,7 @@ public class Kit { player.getInventory().setContents(inventory); if(armor != null) player.getInventory().setArmorContents(armor); - player.updateInventory(); + player.updateInventory(); //TODO issue in 1.21.6? if(effects != null) player.addPotionEffects(effects); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index f4489caf..f878e12c 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -35,6 +35,7 @@ import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -180,6 +181,7 @@ public class Permanent implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onExplosion(EntityExplodeEvent e) { + if (!(e.getEntity() instanceof TNTPrimed)) return; e.blockList().removeIf(block -> { if(block.getType() == Material.TNT) { return false; diff --git a/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordTicketType.java b/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordTicketType.java index 6d3921dc..11944ff2 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordTicketType.java +++ b/VelocityCore/src/de/steamwar/velocitycore/discord/DiscordTicketType.java @@ -26,19 +26,23 @@ import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; @AllArgsConstructor public enum DiscordTicketType { - REPORT("U+1F46E", "Spieler melden", ButtonStyle.DANGER), - IDEA("U+1F4A1", "Feature vorschlagen", ButtonStyle.SUCCESS), - BUG("U+1F41B", "Bug melden", ButtonStyle.SECONDARY), - QUESTION("U+2753", "Fragen", ButtonStyle.PRIMARY), - APPEAL("U+1F528", "Entbannungsantrag", ButtonStyle.SECONDARY), - SCHEMATIC("U+1F4BE", "Schematic melden", ButtonStyle.DANGER); + REPORT("U+1F46E", "Spieler melden", ButtonStyle.DANGER, null), + IDEA("U+1F4A1", "Feature vorschlagen", ButtonStyle.SUCCESS, null), + BUG("U+1F41B", "Bug melden", ButtonStyle.LINK, "https://git.steamwar.de/SteamWar/SteamWar/issues/new"), + QUESTION("U+2753", "Fragen", ButtonStyle.PRIMARY, null), + APPEAL("U+1F528", "Entbannungsantrag", ButtonStyle.SECONDARY, null), + SCHEMATIC("U+1F4BE", "Schematic melden", ButtonStyle.DANGER, null); private final String emoji; private final String label; private final ButtonStyle style; + private final String url; public Button toButton() { + if(style == ButtonStyle.LINK) { + return Button.link(url, label).withEmoji(Emoji.fromUnicode(emoji)); + } return Button.of(style, name().toLowerCase(), Emoji.fromUnicode(emoji)).withLabel(label); } diff --git a/VelocityCore/src/de/steamwar/velocitycore/discord/channels/StaticMessageChannel.java b/VelocityCore/src/de/steamwar/velocitycore/discord/channels/StaticMessageChannel.java index f959e1f4..915affbe 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/discord/channels/StaticMessageChannel.java +++ b/VelocityCore/src/de/steamwar/velocitycore/discord/channels/StaticMessageChannel.java @@ -27,6 +27,7 @@ import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteract import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; import net.dv8tion.jda.api.utils.messages.MessageEditData; +import java.util.Collections; import java.util.concurrent.TimeoutException; import java.util.function.Consumer; import java.util.function.Supplier; @@ -62,10 +63,17 @@ public class StaticMessageChannel extends DiscordChannel { } private void init() { - if(getChannel().getLatestMessageIdLong() != 0) - message = getChannel().getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null); - - VelocityCore.schedule(this::update); + if (getChannel().getLatestMessageIdLong() != 0) { + message = getChannel().getIterableHistory() + .onErrorMap(throwable -> Collections.emptyList()) + .deadline(System.currentTimeMillis() + 5000) + .complete() + .stream() + .filter(m -> m.getAuthor().isBot()) + .findFirst() + .orElse(null); + } + VelocityCore.schedule(this::update).schedule(); } public void update() {