Merge branch 'main' into add-db-indexes

This commit is contained in:
2026-01-23 23:04:11 +01:00
8 changed files with 50 additions and 16 deletions
@@ -74,8 +74,8 @@ class InternalKit(id: EntityID<CompositeID>): CompositeEntity(id) {
this.rawInventory = rawInventory this.rawInventory = rawInventory
this.rawArmor = rawArmor this.rawArmor = rawArmor
this.inUse = false this.inUse = false
} }.also { it.setDefault() }
}.also { it.setDefault() } }
@JvmStatic @JvmStatic
fun getKitInUse(userId: Int, gamemode: String) = useDb { fun getKitInUse(userId: Int, gamemode: String) = useDb {
@@ -111,6 +111,7 @@ class InternalKit(id: EntityID<CompositeID>): CompositeEntity(id) {
fun setDefault() = useDb { fun setDefault() = useDb {
find { PersonalKitTable.userId eq userID and (PersonalKitTable.gamemode eq gameMode) and (PersonalKitTable.inUse eq true) } 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 } .forEach { it.inUse = false }
inUse = true inUse = true
} }
@@ -120,7 +120,7 @@ class SchematicNode(id: EntityID<Int>) : IntEntity(id) {
@JvmStatic @JvmStatic
fun schematicAccessibleForUser(user: SteamwarUser, schematicId: Int?) = fromSql( 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( listOf(
IntegerColumnType() to user.getId(), IntegerColumnType() to user.getId(),
IntegerColumnType() to user.getId(), IntegerColumnType() to user.getId(),
@@ -19,11 +19,27 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import io.papermc.paper.datacomponent.DataComponentType;
import io.papermc.paper.datacomponent.DataComponentTypes; import io.papermc.paper.datacomponent.DataComponentTypes;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
public class ReflectionWrapper21 implements ReflectionWrapper { public class ReflectionWrapper21 implements ReflectionWrapper {
private static final Set<DataComponentType> 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 @Override
public Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction) { public Object explosionHider(Player player, Object packet, PacketHiderFunction packetHiderFunction) {
return packet; return packet;
@@ -31,6 +47,7 @@ public class ReflectionWrapper21 implements ReflectionWrapper {
@Override @Override
public boolean hasItems(ItemStack stack) { public boolean hasItems(ItemStack stack) {
return stack.getDataTypes().stream().anyMatch(dataComponentType -> dataComponentType != DataComponentTypes.ENCHANTMENTS || dataComponentType != DataComponentTypes.DAMAGE); FORBIDDEN_TYPES.forEach(stack::resetData);
return false;
} }
} }
@@ -34,6 +34,7 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.PlayerInventory;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@@ -62,6 +63,7 @@ public class HotbarKitListener implements Listener {
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
int slot = event.getSlot(); int slot = event.getSlot();
if (slot < 0 || slot >= HotbarKit.HOTBAR_SIZE) return; if (slot < 0 || slot >= HotbarKit.HOTBAR_SIZE) return;
if (!(event.getClickedInventory() instanceof PlayerInventory)) return;
Player player = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
click(player, slot, event); click(player, slot, event);
@@ -117,7 +117,7 @@ public class Kit {
if(kit.isList("Armor")) if(kit.isList("Armor"))
armor = Objects.requireNonNull(kit.getList("Armor")).toArray(new ItemStack[0]); armor = Objects.requireNonNull(kit.getList("Armor")).toArray(new ItemStack[0]);
else else
armor = null; armor = new ItemStack[]{ null, null, null, null};
leaderAllowed = kit.getBoolean("LeaderAllowed"); leaderAllowed = kit.getBoolean("LeaderAllowed");
memberAllowed = kit.getBoolean("MemberAllowed"); memberAllowed = kit.getBoolean("MemberAllowed");
if(kit.isList("Effects")) if(kit.isList("Effects"))
@@ -261,7 +261,7 @@ public class Kit {
player.getInventory().setContents(inventory); player.getInventory().setContents(inventory);
if(armor != null) if(armor != null)
player.getInventory().setArmorContents(armor); player.getInventory().setArmorContents(armor);
player.updateInventory(); player.updateInventory(); //TODO issue in 1.21.6?
if(effects != null) if(effects != null)
player.addPotionEffects(effects); player.addPotionEffects(effects);
} }
@@ -35,6 +35,7 @@ import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@@ -180,6 +181,7 @@ public class Permanent implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onExplosion(EntityExplodeEvent e) { public void onExplosion(EntityExplodeEvent e) {
if (!(e.getEntity() instanceof TNTPrimed)) return;
e.blockList().removeIf(block -> { e.blockList().removeIf(block -> {
if(block.getType() == Material.TNT) { if(block.getType() == Material.TNT) {
return false; return false;
@@ -26,19 +26,23 @@ import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
@AllArgsConstructor @AllArgsConstructor
public enum DiscordTicketType { public enum DiscordTicketType {
REPORT("U+1F46E", "Spieler melden", ButtonStyle.DANGER), REPORT("U+1F46E", "Spieler melden", ButtonStyle.DANGER, null),
IDEA("U+1F4A1", "Feature vorschlagen", ButtonStyle.SUCCESS), IDEA("U+1F4A1", "Feature vorschlagen", ButtonStyle.SUCCESS, null),
BUG("U+1F41B", "Bug melden", ButtonStyle.SECONDARY), BUG("U+1F41B", "Bug melden", ButtonStyle.LINK, "https://git.steamwar.de/SteamWar/SteamWar/issues/new"),
QUESTION("U+2753", "Fragen", ButtonStyle.PRIMARY), QUESTION("U+2753", "Fragen", ButtonStyle.PRIMARY, null),
APPEAL("U+1F528", "Entbannungsantrag", ButtonStyle.SECONDARY), APPEAL("U+1F528", "Entbannungsantrag", ButtonStyle.SECONDARY, null),
SCHEMATIC("U+1F4BE", "Schematic melden", ButtonStyle.DANGER); SCHEMATIC("U+1F4BE", "Schematic melden", ButtonStyle.DANGER, null);
private final String emoji; private final String emoji;
private final String label; private final String label;
private final ButtonStyle style; private final ButtonStyle style;
private final String url;
public Button toButton() { 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); return Button.of(style, name().toLowerCase(), Emoji.fromUnicode(emoji)).withLabel(label);
} }
@@ -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.MessageCreateBuilder;
import net.dv8tion.jda.api.utils.messages.MessageEditData; import net.dv8tion.jda.api.utils.messages.MessageEditData;
import java.util.Collections;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
@@ -62,10 +63,17 @@ public class StaticMessageChannel extends DiscordChannel {
} }
private void init() { private void init() {
if(getChannel().getLatestMessageIdLong() != 0) if (getChannel().getLatestMessageIdLong() != 0) {
message = getChannel().getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null); message = getChannel().getIterableHistory()
.onErrorMap(throwable -> Collections.emptyList())
VelocityCore.schedule(this::update); .deadline(System.currentTimeMillis() + 5000)
.complete()
.stream()
.filter(m -> m.getAuthor().isBot())
.findFirst()
.orElse(null);
}
VelocityCore.schedule(this::update).schedule();
} }
public void update() { public void update() {