Skip to content

Commit fd96855

Browse files
authored
Merge pull request #19
Changed the reset of chat input prompts
2 parents 78a13ca + 5d95881 commit fd96855

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

core/src/main/java/me/wolfyscript/utilities/api/inventory/gui/GuiHandler.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@
2929
import net.kyori.adventure.text.format.NamedTextColor;
3030
import org.bukkit.Bukkit;
3131
import org.bukkit.entity.Player;
32-
import org.bukkit.event.EventHandler;
3332
import org.bukkit.event.Listener;
3433
import org.bukkit.event.inventory.InventoryCloseEvent;
35-
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
3634
import org.bukkit.scheduler.BukkitTask;
3735
import org.jetbrains.annotations.NotNull;
3836
import org.jetbrains.annotations.Nullable;
@@ -333,6 +331,8 @@ public void openWindow(GuiWindow<C> window) {
333331
final GuiCluster<C> cluster = window.getCluster();
334332
Player player1 = getPlayer();
335333
if (player1.hasPermission(window.getPermission())) {
334+
// Cancels the chat input when a new window is opened to prevent
335+
cancelChatInput();
336336
var currentWindow = getWindow(cluster);
337337
if (currentWindow == null || !currentWindow.getNamespacedKey().equals(window.getNamespacedKey())) {
338338
getHistory(cluster).add(0, window);
@@ -527,11 +527,4 @@ public void onClose(GUIInventory<C> guiInventory, InventoryCloseEvent event) {
527527
}
528528
}
529529
}
530-
531-
@EventHandler
532-
private void onCommand(PlayerCommandPreprocessEvent event) {
533-
if (!event.getMessage().startsWith("/wua") && !event.getMessage().startsWith("/wui") && event.getPlayer().getUniqueId().equals(uuid) && isChatEventActive()) {
534-
cancelChatInput();
535-
}
536-
}
537530
}

core/src/main/java/me/wolfyscript/utilities/api/inventory/gui/InventoryAPI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ private boolean executeButton(Button<C> button, GuiHandler<C> guiHandler, Player
293293
* It cancels the event and passes the message into the /wui command.
294294
* <strong>It is recommended to use the /wui command instead of typing directly into the chat.</strong>
295295
*/
296+
@Deprecated(forRemoval = true)
296297
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
297298
public void onPreChat(AsyncPlayerChatEvent event) {
298299
if (hasGuiHandler(event.getPlayer())) {

0 commit comments

Comments
 (0)