SteamWar/BauSystem2.0
Archiviert
12
0

Hotfix ScriptGUI removing script on pressing escape when naming
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-07-30 14:22:36 +02:00
Ursprung a1c45b86af
Commit 82b385e5ff

Datei anzeigen

@ -20,13 +20,16 @@
package de.steamwar.bausystem.features.script; package de.steamwar.bausystem.features.script;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform; import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
import de.steamwar.bausystem.utils.ItemUtils;
import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SWListInv;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.sql.Script; import de.steamwar.sql.Script;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -39,6 +42,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@Linked @Linked
public class ScriptGUI implements Listener { public class ScriptGUI implements Listener {
@ -119,7 +123,18 @@ public class ScriptGUI implements Listener {
open(player); open(player);
} else { } else {
SWAnvilInv inv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ENTER_NAME", player), name == null ? "" : name); SWAnvilInv inv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ENTER_NAME", player), name == null ? "" : name);
inv.setCallback(s -> saveWithName(player, meta, s)); AtomicBoolean saved = new AtomicBoolean(false);
ItemStack itemStack = player.getOpenInventory().getCursor();
inv.setCallback(s -> {
saveWithName(player, meta, s);
saved.set(true);
});
inv.addCloseCallback(() -> {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
if (saved.get()) return;
SWUtils.giveItemToPlayer(player, itemStack);
}, 1);
});
inv.open(); inv.open();
} }
} }