diff --git a/CommonCore/Network/src/de/steamwar/network/packets/client/AnvilAnswerPacket.java b/CommonCore/Network/src/de/steamwar/network/packets/client/AnvilAnswerPacket.java
new file mode 100644
index 00000000..b911219f
--- /dev/null
+++ b/CommonCore/Network/src/de/steamwar/network/packets/client/AnvilAnswerPacket.java
@@ -0,0 +1,41 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2025 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.network.packets.client;
+
+import de.steamwar.network.packets.NetworkPacket;
+import lombok.*;
+
+@EqualsAndHashCode(callSuper = true)
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ToString
+@Builder(toBuilder = true)
+public class AnvilAnswerPacket extends NetworkPacket {
+ private int playerId;
+ private Action action;
+ private String text;
+
+ public enum Action {
+ CLOSE,
+ ANSWER,
+ LEFT_CLICK
+ }
+}
diff --git a/CommonCore/Network/src/de/steamwar/network/packets/server/AnvilInventoryPacket.java b/CommonCore/Network/src/de/steamwar/network/packets/server/AnvilInventoryPacket.java
new file mode 100644
index 00000000..b8710e9a
--- /dev/null
+++ b/CommonCore/Network/src/de/steamwar/network/packets/server/AnvilInventoryPacket.java
@@ -0,0 +1,36 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2025 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.network.packets.server;
+
+import de.steamwar.network.packets.NetworkPacket;
+import lombok.*;
+
+@EqualsAndHashCode(callSuper = true)
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ToString
+public class AnvilInventoryPacket extends NetworkPacket {
+ private static final long serialVersionUID = -6004390311854048209L;
+ private int playerId;
+ private String title;
+ private String defaultText;
+ private String material;
+}
diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/network/CoreNetworkHandler.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/network/CoreNetworkHandler.java
index d2b9016d..4c3d7e45 100644
--- a/SpigotCore/SpigotCore_Main/src/de/steamwar/network/CoreNetworkHandler.java
+++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/network/CoreNetworkHandler.java
@@ -59,6 +59,11 @@ public class CoreNetworkHandler extends PacketHandler {
InventoryHandler.handleInventoryPacket(packet);
}
+ @Handler
+ public void handleAnvilPacket(AnvilInventoryPacket packet) {
+ InventoryHandler.handleAnvilInventoryPacket(packet);
+ }
+
@Handler
public void handlePingPacket(PingPacket packet) {
UUID uuid = SteamwarUser.get(packet.getId()).getUUID();
diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/InventoryHandler.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/InventoryHandler.java
index a8a378a0..cbf2b8f5 100644
--- a/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/InventoryHandler.java
+++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/InventoryHandler.java
@@ -20,11 +20,15 @@
package de.steamwar.network.handlers;
import com.google.gson.JsonParser;
+import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.network.NetworkSender;
+import de.steamwar.network.packets.NetworkPacket;
import de.steamwar.network.packets.PacketHandler;
+import de.steamwar.network.packets.client.AnvilAnswerPacket;
import de.steamwar.network.packets.client.InventoryCallbackPacket;
+import de.steamwar.network.packets.server.AnvilInventoryPacket;
import de.steamwar.network.packets.server.InventoryPacket;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
@@ -53,4 +57,20 @@ public class InventoryHandler extends PacketHandler {
});
inventory.open();
}
+
+ @Handler
+ public static void handleAnvilInventoryPacket(AnvilInventoryPacket packet) {
+ Player player = Bukkit.getPlayer(SteamwarUser.get(packet.getPlayerId()).getUUID());
+
+ SWAnvilInv inv = new SWAnvilInv(player, packet.getTitle(), packet.getDefaultText());
+ if (packet.getMaterial() != null && !packet.getMaterial().isEmpty()) {
+ inv.setItem(SWItem.getMaterial(packet.getMaterial()));
+ }
+
+ inv.setCallback(s -> NetworkSender.send(AnvilAnswerPacket.builder().playerId(packet.getPlayerId()).action(AnvilAnswerPacket.Action.ANSWER).text(s).build()));
+ inv.addLeftCallback(() -> NetworkSender.send(AnvilAnswerPacket.builder().playerId(packet.getPlayerId()).action(AnvilAnswerPacket.Action.LEFT_CLICK).build()));
+ inv.addCloseCallback(() -> NetworkSender.send(AnvilAnswerPacket.builder().playerId(packet.getPlayerId()).action(AnvilAnswerPacket.Action.CLOSE).build()));
+
+ inv.open();
+ }
}
diff --git a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java
index aa98a034..b4bc9ccc 100644
--- a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java
+++ b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java
@@ -224,7 +224,7 @@ public class VelocityCore implements ReloadablePlugin {
for(PacketHandler handler : new PacketHandler[] {
new EloPlayerHandler(), new EloSchemHandler(), new ExecuteCommandHandler(), new FightInfoHandler(),
- new ImALobbyHandler(), new InventoryCallbackHandler(), new PrepareSchemHandler(), new PlayerSkinHandler()
+ new ImALobbyHandler(), new InventoryCallbackHandler(), new PrepareSchemHandler(), new PlayerSkinHandler(), new AnvilAnswerHandler()
})
handler.register();
diff --git a/VelocityCore/src/de/steamwar/velocitycore/inventory/SWAnvilInv.java b/VelocityCore/src/de/steamwar/velocitycore/inventory/SWAnvilInv.java
new file mode 100644
index 00000000..70d17045
--- /dev/null
+++ b/VelocityCore/src/de/steamwar/velocitycore/inventory/SWAnvilInv.java
@@ -0,0 +1,69 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2025 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.velocitycore.inventory;
+
+import com.velocitypowered.api.proxy.Player;
+import de.steamwar.network.packets.client.AnvilAnswerPacket;
+import de.steamwar.network.packets.server.AnvilInventoryPacket;
+import de.steamwar.sql.SteamwarUser;
+import de.steamwar.velocitycore.network.NetworkSender;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+
+import java.util.HashMap;
+import java.util.function.Consumer;
+
+@AllArgsConstructor
+@Builder(toBuilder = true)
+public class SWAnvilInv {
+ private static final HashMap openInv = new HashMap<>();
+
+ public static void handleClick(AnvilAnswerPacket packet) {
+ try {
+ switch (packet.getAction()) {
+ case LEFT_CLICK:
+ openInv.get(packet.getPlayerId()).leftClickCallback.run();
+ break;
+ case CLOSE:
+ openInv.remove(packet.getPlayerId()).closeCallback.run();
+ break;
+ case ANSWER:
+ openInv.get(packet.getPlayerId()).callback.accept(packet.getText());
+ break;
+ }
+ } catch (NullPointerException ignored) { }
+ }
+
+ private final Player player;
+ private final String title;
+ private final String defaultText;
+ private final String material;
+
+ private final Consumer callback;
+ private final Runnable closeCallback;
+ private final Runnable leftClickCallback;
+
+ public void open() {
+ SteamwarUser user = SteamwarUser.get(player.getUniqueId());
+
+ openInv.put(user.getId(), this);
+ NetworkSender.send(player, new AnvilInventoryPacket(user.getId(), title, defaultText, material));
+ }
+}
diff --git a/VelocityCore/src/de/steamwar/velocitycore/network/handlers/AnvilAnswerHandler.java b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/AnvilAnswerHandler.java
new file mode 100644
index 00000000..f0abb739
--- /dev/null
+++ b/VelocityCore/src/de/steamwar/velocitycore/network/handlers/AnvilAnswerHandler.java
@@ -0,0 +1,32 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2025 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.velocitycore.network.handlers;
+
+import de.steamwar.network.packets.PacketHandler;
+import de.steamwar.network.packets.client.AnvilAnswerPacket;
+import de.steamwar.velocitycore.inventory.SWAnvilInv;
+
+public class AnvilAnswerHandler extends PacketHandler {
+
+ @Handler
+ public void handle(AnvilAnswerPacket packet) {
+ SWAnvilInv.handleClick(packet);
+ }
+}