wesjd / anvilgui Goto Github PK
View Code? Open in Web Editor NEWCapture user input in Minecraft through an anvil GUI in under 20 lines of code
License: MIT License
Capture user input in Minecraft through an anvil GUI in under 20 lines of code
License: MIT License
Possibly related to #53
If a server is stopped from the console while an AnvilGUI is open, the viewing player will have a named Paper placed in their inventory on next startup, without fail.
Using AnvilGUI master-7dbcfc2cdb (latest at time of writing) on a Spigot 1.13.2 server.
new AnvilGUI.Builder()
.onClose(player -> {
})
.onComplete((player, text) -> {
Bukkit.getScheduler().cancelTask(taskId);
try {
board.getObjective(ChatColor.YELLOW + "Quests").unregister();
} catch (Exception e) {
// Fail silently
}
new BukkitRunnable() {
@Override
public void run() {
c.acceptConversationInput(text);
}
}.runTaskLater(plugin, 20);
return AnvilGUI.Response.close();
})
.preventClose()
.text(Lang.get("questEditorName"))
.plugin(plugin)
.open((Player)c);
Currently, it is possible to register only click action on the ouput slot, but there are still 2 slots that could be useful in some situations.
F.e. I have a panel GUI that opens AnvilGUI, but the only way how to get back is by changing a name or clicking outside GUI.
It would be useful to have the ability to define one more button, like a 2nd input slot, that could return to a previous GUI.
Adding the ability to define actions per each slot click would allow more variation.
Hey, I tried to add AnvilGUI to my project using maven. It says that version master-SNAPSHOT isn't available, only master-799c34ce7d-1.
Also when I try to compile the plugin with the AnvilGUI, it also compiles it with all Bukkit classes, so the compiled file size is like 31MB.
Can you add support for 1.7.10?
I want make the text to empty. but using .text("") is not working.
If I use .text(""), it just print Material name ex(Name tag, Paper, Glass, ...)
how can i do?
new AnvilGUI.Builder()
.onComplete((player, text) -> {
if(Login.getPasswordEquals(p, text)) {
player.sendMessage(ChatColor.RED + "Login!");
return AnvilGUI.Response.close();
} else {
p.kickPlayer(ChatColor.RED + "[YLogin] no.");
return AnvilGUI.Response.close();
}
})
.preventClose()
.item(new ItemStack(Material.PAPER))
.text("")
.title(ChatColor.RED + "Login")
.plugin(Main.getPlugin(Main.class))
.open(p);
The error is
Failure to find com.github.WesJD.AnvilGUI:anvilgui:pom:99a504a3bb in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
why my maven always looks up AnvilGUI from https://repo.maven.apache.org/maven2? My Pom is
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ldmc</groupId>
<artifactId>CoronaPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.example.yourMain</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<jackson.version>2.10.0</jackson.version>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<layout>default</layout>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.30.1</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-jdbc-client</artifactId>
<version>3.8.5</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-rx-java2</artifactId>
<version>3.8.5</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.9</version>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>5.0.0-RC4</version>
</dependency>
<dependency>
<groupId>com.github.WesJD.AnvilGUI</groupId>
<artifactId>anvilgui</artifactId>
<version>99a504a3bb</version>
</dependency>
</dependencies>
</project>
Could you help me solve this problem? Thank you very much.
The GUI pops up but the insert text is blank and you can't type in it because the piece of paper is missing in the left box of the GUI. This was happening before my latest pull request, which is located here.
This problem was reported by a user running paper 1.14.3
[16:33:19 ERROR]: Could not pass event InventoryClickEvent to TradePlus v3.56
java.lang.RuntimeException: java.lang.NoSuchFieldException: modifiers
at com.trophonix.tradeplus.shaded.anvilgui.version.Wrapper1_14_R1.setActiveContainerId(Wrapper1_14_R1.java:79) ~[?:?]
at com.trophonix.tradeplus.shaded.anvilgui.AnvilGUI.openInventory(AnvilGUI.java:154) ~[?:?]
at com.trophonix.tradeplus.shaded.anvilgui.AnvilGUI.(AnvilGUI.java:128) ~[?:?]
at com.trophonix.tradeplus.shaded.anvilgui.AnvilGUI.(AnvilGUI.java:28) ~[?:?]
at com.trophonix.tradeplus.shaded.anvilgui.AnvilGUI$Builder.open(AnvilGUI.java:319) ~[?:?]
at com.trophonix.tradeplus.extras.Extra.onClick(Extra.java:112) ~[?:?]
at com.trophonix.tradeplus.trade.Trade.onClick(Trade.java:309) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor993.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.14.3.jar:git-Paper-131]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.14.3.jar:git-Paper-131]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.14.3.jar:git-Paper-131]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:545) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.PlayerConnection.a(PlayerConnection.java:2341) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.PacketPlayInWindowClick.a(SourceFile:33) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.PacketPlayInWindowClick.a(SourceFile:10) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:18) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.TickTask.run(SourceFile:18) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:127) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:105) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.MinecraftServer.aW(MinecraftServer.java:1002) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.MinecraftServer.executeNext(MinecraftServer.java:995) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:115) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.MinecraftServer.sleepForTick(MinecraftServer.java:979) ~[patched_1.14.3.jar:git-Paper-131]
at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:912) ~[patched_1.14.3.jar:git-Paper-131]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: java.lang.NoSuchFieldException: modifiers
at java.lang.Class.getField(Class.java:1703) ~[?:1.8.0_212]
at com.trophonix.tradeplus.shaded.anvilgui.version.Wrapper1_14_R1.setActiveContainerId(Wrapper1_14_R1.java:73) ~[?:?]
... 25 more`
You can see my code here
https://github.com/Trophonix/TradePlus/blob/master/src/main/java/com/trophonix/tradeplus/extras/Extra.java#L90
Dear WesJD,
Is it possible to run some code when the player 'cancels' the renaming them selves?
I can't figure it out because the InventoryCloseEvent is always fired, no mater if the AnvilGUI did 'player.closeInventory()' or the if the player cancels it him/her self...
Thank you,
Siem
Nevermind
When I try to create an AnvilGUI.Builder I'm thrown a ClassNotFoundException. This may be my own error, although I'm not sure what I might've done wrong.
Error:
[00:16:47 INFO]: Anarchist issued server command: /anvil
[00:16:47 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'anvil' in plugin AnvilAnywhere v${project.version}
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:146) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:666) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1189) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1001) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [patched.jar:git-PaperSpigot-"4c7641d"]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_161]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_161]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:774) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616) [patched.jar:git-PaperSpigot-"4c7641d"]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: java.lang.NoClassDefFoundError: net/wesjd/anvilgui/AnvilGUI$Builder
at github.benlewis9000.anvilanywhere.Commands.AnvilCommand.onCommand(AnvilCommand.java:21) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched.jar:git-PaperSpigot-"4c7641d"]
... 15 more
Caused by: java.lang.ClassNotFoundException: net.wesjd.anvilgui.AnvilGUI$Builder
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_161]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:102) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:87) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_161]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_161]
at github.benlewis9000.anvilanywhere.Commands.AnvilCommand.onCommand(AnvilCommand.java:21) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched.jar:git-PaperSpigot-"4c7641d"]
... 15 more
My implementation:
public class AnvilCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String string, String[] args) {
if (cmd.getLabel().equalsIgnoreCase("anvil")&& sender instanceof Player){
Player player = (Player) ((Player) sender).getPlayer();
if (player.hasPermission("anvilanywhere.use") || player.isOp()){
new AnvilGUI.Builder().plugin(AnvilAnywhere.plugin).open(player);
}
else player.sendMessage("§d6» §cYou must be rank §8]§cImmortal§8]§c or higher to use this! Support the server by purchasing ranks at §bshop.incidia.net§c!");
return true;
}
return false;
}
}
I'm working on a mainly GUI based plugin and it uses AnvilGUI to get input from the user, but because I want to open an inventory after the player finished inputting I get
java.lang.IllegalArgumentException: You can't close an inventory that isn't open!
You could change your closeInventory method in AnvilGUI to something like:
'public void closeInventory() {
if (isInventoryOpen) {
Validate.isTrue(this.open, "You can't close an inventory that isn't open!");
this.open = false;
WRAPPER.handleInventoryCloseEvent(this.holder);
WRAPPER.setActiveContainerDefault(this.holder);
WRAPPER.sendPacketCloseWindow(this.holder, this.containerId);
HandlerList.unregisterAll(this.listener);
}
}'
Just change 'isInventoryOpen' to a boolean that can tell if the Anvil is open or not. I'm not familiar with your code so I don't know how you would do it exactly.
Hey,
when i create an anvil using this code: https://hastebin.com/oqoqujijis.coffeescript
it only creates a "blank' anvil (without an item), therefore nothing can be rename.
No errors are thrown.
I've been using this API for years now, but the newest update goes beyond the size of 300kb when compiled.
Could you please create a minimized version of it, without using Classgraph? I don't think that Classgraph is really needed here for such a small minecraft library.
Thanks!
How can i change the title in the gui?
1.13's been released but this lib doesn't support it yet
new AnvilGUI(main, playerClicker, "Enter amount...", (player, reply) -> {
if (isNumeric(reply)) {
long value = (long) Math.round(Integer.parseInt(reply));
playerClicker.performCommand("bank withdraw " + value + "");
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7Enter a valid number."));
}
return "";
});
When confirming the rename, it adds the renamed paper to the player's inventory.
https://nexus.wesjd.net/repository/thirdparty/
seems to be offline.
when im in the anvil gui then i click to output item with right mouse click, it comes to different page without anything
https://i.snag.gy/dbUT8p.jpg
not just right click, also drop(q)
Is there any news about a 1.10 version?
Hey,
after creating the latest version of spigot.jar with build tools (version 1.15-R0.1-SNAPSHOT").
I got this error:
[14:41:07] [Server thread/ERROR]: Could not pass event InventoryClickEvent to Life v1.0 org.bukkit.event.EventException: null at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[spigot.jar:git-Spigot-047b6f8-61d4b09] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot.jar:git-Spigot-047b6f8-61d4b09] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:529) ~[spigot.jar:git-Spigot-047b6f8-61d4b09] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:514) ~[spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:2147) ~[?:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.PacketPlayInWindowClick.a(SourceFile:32) ~[spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.PacketPlayInWindowClick.a(SourceFile:10) ~[spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) ~[spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) [spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(SourceFile:144) [spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(SourceFile:118) [spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.MinecraftServer.aZ(MinecraftServer.java:917) [spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:910) [spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeAll(SourceFile:103) [spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:893) [spigot.jar:git-Spigot-047b6f8-61d4b09] at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:827) [spigot.jar:git-Spigot-047b6f8-61d4b09] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222] Caused by: java.lang.ExceptionInInitializerError at net.wesjd.anvilgui.AnvilGUI$Builder.open(AnvilGUI.java:319) ~[?:?] at de.robinp2000.life.listeners.InventoryClickListener.onClick(InventoryClickListener.java:280) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot.jar:git-Spigot-047b6f8-61d4b09] ... 17 more Caused by: java.lang.RuntimeException: Your server version isn't supported in AnvilGUI! at net.wesjd.anvilgui.version.VersionMatcher.lambda$match$1(VersionMatcher.java:47) ~[?:?] at java.util.Optional.orElseThrow(Optional.java:290) ~[?:1.8.0_222] at net.wesjd.anvilgui.version.VersionMatcher.match(VersionMatcher.java:47) ~[?:?] at net.wesjd.anvilgui.AnvilGUI.<clinit>(AnvilGUI.java:33) ~[?:?] at net.wesjd.anvilgui.AnvilGUI$Builder.open(AnvilGUI.java:319) ~[?:?] at de.robinp2000.life.listeners.InventoryClickListener.onClick(InventoryClickListener.java:280) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot.jar:git-Spigot-047b6f8-61d4b09] ... 17 more
Tested in version 1.14. It takes the XP cost listed on the GUI when you click.
I get this error when loading my plugin:
[18:07:53] [Server thread/ERROR]: [MaschinenMC-Lobby] Plugin MaschinenMC-Lobby v1.0 has failed to register events for class net.maschinenmc.lobby.listeners.NavigatorListener because net/wesjd/anvilgui/AnvilGUI$Response does not exist.
When the anvil inventory opens, the items in my inventory always go to random slots. When you try to update the inventory, the items go back to their original place however.
Here's my inventory before opening the anvil GUI:
And after I open the anvil GUI it becomes this weird mess:
I am using Java 11 on 1.13.2 with the latest version of Anvil GUI. This was not an issue in earlier versions.
This is still happening for me in earlier versions, at least 1.9 and 1.10. Has the jar been updated since the commit? It seems like it maybe hasn't - navigating to the file in browser shows it was updated 3 days ago.
Edit: I cloned the repo to get the updated code and it's fixed, but there's a problem where if I return a message, it removes the input paper and the same issue occurs so I have to close the inventory instead of using the error system.
Originally posted by @Trophonix in #32 (comment)
Description
I've noticed a bug where inventory items are permanently lost if the anvil GUI is not used correctly. If any inventory item is shift-cliked while using the GUI, the item is inserted into the second slot and can no longer be returned to the player. Example video. The example shown in the video is when using the waypoints plugin, which uses this library. I submitted the same issue to that plugin, but was redirected here.
Impact
This is not an issue with normal use, however it can be very unfortunate if valuable items are lost if someone accidentally shift-clicks one of their items.
Steps to reproduce
Using waypoints (or another plugin depending on this library I suppose): Open GUI, add new waypoint or folder to open anvil GUI, then shift-click an item within the inventory to insert it into the second anvil slot. It is also possible to insert an item into the second anvil slot by repeatedly left-clicking it with a selected item. The inserted item can then no longer be returned and will be permanently lost after exiting the gui.
System
Java 1.8
Minecraft version 1.15.2
Paper latest version (for now anyway): Paper-121 (API version 1.15.2-R0.1-SNAPSHOT)
Waypoints plugin version: 2.6.1
Error logs
No logs or errors displayed in console.
I'm not a plugin developer, so unfortunately I can't provide any technical details regarding the code using the GUI.
Hey,
When a player shift+clicks on the result item they get it...
Is there any way to stop that?
Thanks!
EDIT: Not sure, but I think it only happens on 'return null;'.
It would be really useful if I had a way to catch when the inventory was closed. I'm trying to use this for a GUI-based plugin and I need to open back up my GUI when the anvil is closed regardless of whether they gave input. Tried a quick solution by making my own class that extends AnvilGUI with its own listener but that don't work haha.
For now I will just make the class I'm using it in a Listener and make my own onClose method but it'd be a nice feature!
Implementation ideas:
After that it'd just be as simple as running the consumer in your inventoryClose method
I am not sure if it is possible, but it would be awesome if text size in this anvil could be set larger then default 35.
I am using this plugin for User GUI inputs, and in some situations, I need more than these 35 chars.
See title:
Some way to disallow ESC-ing out of the AnvilGUI?
<dependency>
<groupId>com.github.WesJD.AnvilGUI</groupId>
<artifactId>AnvilGUI</artifactId>
<version>478e0c196e</version>
</dependency>
new AnvilGUI.Builder()
.onClose(player -> {
player.sendMessage("You closed the inventory.");
})
.onComplete((player, text) -> {
if(text.equalsIgnoreCase("you")) {
player.sendMessage("You have magical powers!");
return AnvilGUI.Response.close();
} else {
return AnvilGUI.Response.text("Incorrect.");
}
})
.preventClose()
.text("What is the meaning of life?")
.plugin((Plugin) plugin)
.open(p);
this is the dependency I using according to jitpack
and still, I get the error of Response class doesn't exists
[23:06:43] [Server thread/WARN]: [ArtMap] Task #152 for ArtMap v3.3.1 generated an exception
java.lang.NoSuchMethodError: net.minecraft.server.v1_14_R1.ContainerProperty.a(I)V
at net.wesjd.anvilgui.version.Wrapper1_14_R1$AnvilContainer.e(Wrapper1_14_R1.java:132) ~[?:?]
at net.minecraft.server.v1_14_R1.ContainerAnvil.a(ContainerAnvil.java:123) ~[spigot-1.14.4.jar:git-Spigot-9de398a-8b09d98]
at net.minecraft.server.v1_14_R1.ContainerAnvil$1.update(ContainerAnvil.java:42) ~[spigot-1.14.4.jar:git-Spigot-9de398a-8b09d98]
at net.minecraft.server.v1_14_R1.InventorySubcontainer.setItem(InventorySubcontainer.java:158) ~[spigot-1.14.4.jar:git-Spigot-9de398a-8b09d98]
at org.bukkit.craftbukkit.v1_14_R1.inventory.CraftResultInventory.setItem(CraftResultInventory.java:37) ~[spigot-1.14.4.jar:git-Spigot-9de398a-8b09d98]
at net.wesjd.anvilgui.AnvilGUI.openInventory(AnvilGUI.java:149) ~[?:?]
at net.wesjd.anvilgui.AnvilGUI.(AnvilGUI.java:128) ~[?:?]
at net.wesjd.anvilgui.AnvilGUI.(AnvilGUI.java:94) ~[?:?]
at me.Fupery.ArtMap.Painting.ArtistHandler.lambda$handlePacket$2(ArtistHandler.java:55) ~[?:?]
at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftTask.run(CraftTask.java:81) ~[spigot-1.14.4.jar:git-Spigot-9de398a-8b09d98]
at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:394) [spigot-1.14.4.jar:git-Spigot-9de398a-8b09d98]
at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1023) [spigot-1.14.4.jar:git-Spigot-9de398a-8b09d98]
at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:396) [spigot-1.14.4.jar:git-Spigot-9de398a-8b09d98]
at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:971) [spigot-1.14.4.jar:git-Spigot-9de398a-8b09d98]
at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:816) [spigot-1.14.4.jar:git-Spigot-9de398a-8b09d98]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
SOLVED
Hey, just having a problem with the onClose part of the builder of AnvilGUI
I'm using this:
new AnvilGUI.Builder() .onClose(player -> { new BukkitRunnable() { public void run() { List<Inventory> invs = Helpop.inv.get(player.getUniqueId()); player.openInventory(invs.get(0)); } }.runTaskLater(Core.plugin, 1); }) .onComplete((player, text) -> { if(Assets.isNumeric(text)) { int id = Integer.valueOf(text); if(!Assets.senderName.containsKey(id)) { return AnvilGUI.Response.text("Invalid ticket"); } new BukkitRunnable() { public void run() { new HelpopAdminManager(id); player.openInventory(HelpopAdminManager.map.get(id)); } }.runTaskLater(Core.plugin, 1); return AnvilGUI.Response.close(); } else { return AnvilGUI.Response.text("Numerical ids only"); } }) .text("id") .plugin(Core.plugin) .open(p);
however, when I put in my value (that is valid) and click next, it just acts like I closed the GUI.
I reverted a few versions back and fixes it but causes a separate problem haha. (I use 478e0c1 now)
Nice resource, I use it on all my GUI plugins.
Any other questions just dm me on discord: Joshb_#0001
[15:54:11] [Server thread/ERROR]: [plugin] Plugin plugin v0.05 has failed to register events for class com.plugin.a.b because net/wesjd/anvilgui/AnvilGUI$Response does not exist.
AnvilGUI s = new AnvilGUI.Builder()
.onClose(player -> {
player.sendMessage("You closed the inventory.");
})
.onComplete((player, text) -> {
if(text.equalsIgnoreCase("you")) {
player.sendMessage("You have magical powers!");
return AnvilGUI.Response.close();
} else {
return AnvilGUI.Response.text("Incorrect.");
}
})
.preventClose()
.text("minecraft:anvil")
.plugin(plugin)
.open(p);```
i have no idea how to fix it
please help
minimal error is like
Can not set final int field net.minecraft.server.v1_14_R1.Container.windowId to java.lang.Integer
the full error;
[16:27:15] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to AnvilLogin v1.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:529) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:514) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at net.minecraft.server.v1_14_R1.PlayerList.a(PlayerList.java:173) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at net.minecraft.server.v1_14_R1.LoginListener.c(LoginListener.java:154) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at net.minecraft.server.v1_14_R1.LoginListener.tick(LoginListener.java:53) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at net.minecraft.server.v1_14_R1.NetworkManager.a(NetworkManager.java:220) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at net.minecraft.server.v1_14_R1.ServerConnection.c(ServerConnection.java:129) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1091) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:393) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:970) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:815) [spigot-1.14.4.jar:git-Spigot-065a373-763e560]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.RuntimeException: java.lang.IllegalAccessException: Can not set final int field net.minecraft.server.v1_14_R1.Container.windowId to java.lang.Integer
at net.wesjd.anvilgui.version.Wrapper1_14_R1.setActiveContainerId(Wrapper1_14_R1.java:79) ~[?:?]
at net.wesjd.anvilgui.AnvilGUI.openInventory(AnvilGUI.java:154) ~[?:?]
at net.wesjd.anvilgui.AnvilGUI.<init>(AnvilGUI.java:128) ~[?:?]
at net.wesjd.anvilgui.AnvilGUI.<init>(AnvilGUI.java:28) ~[?:?]
at net.wesjd.anvilgui.AnvilGUI$Builder.open(AnvilGUI.java:319) ~[?:?]
at io.github.portlek.anvillogin.AnvilLogin.openRegister(AnvilLogin.java:62) ~[?:?]
at io.github.portlek.anvillogin.AnvilLogin.join(AnvilLogin.java:39) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot-1.14.4.jar:git-Spigot-065a373-763e560]
... 13 more
Caused by: java.lang.IllegalAccessException: Can not set final int field net.minecraft.server.v1_14_R1.Container.windowId to java.lang.Integer
at jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:76) ~[?:?]
at jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:80) ~[?:?]
at jdk.internal.reflect.UnsafeQualifiedIntegerFieldAccessorImpl.set(UnsafeQualifiedIntegerFieldAccessorImpl.java:79) ~[?:?]
at java.lang.reflect.Field.set(Field.java:780) ~[?:?]
at net.wesjd.anvilgui.version.Wrapper1_14_R1.setActiveContainerId(Wrapper1_14_R1.java:77) ~[?:?]
at net.wesjd.anvilgui.AnvilGUI.openInventory(AnvilGUI.java:154) ~[?:?]
at net.wesjd.anvilgui.AnvilGUI.<init>(AnvilGUI.java:128) ~[?:?]
at net.wesjd.anvilgui.AnvilGUI.<init>(AnvilGUI.java:28) ~[?:?]
at net.wesjd.anvilgui.AnvilGUI$Builder.open(AnvilGUI.java:319) ~[?:?]
at io.github.portlek.anvillogin.AnvilLogin.openRegister(AnvilLogin.java:62) ~[?:?]
at io.github.portlek.anvillogin.AnvilLogin.join(AnvilLogin.java:39) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot-1.14.4.jar:git-Spigot-065a373-763e560]
... 13 more
How can i use it wighout maven?
When using your resource to open a gui after you type out a reply. My inventories get messed up. my listener is ignored when I either close the inventory via ESC key, or when your AnvilGUI response.text is used.
Example:
either escaping the inventory via esc key, or a anvilgui.response.text return statement
https://i.imgur.com/zKgOI4w.png
My listener then gets ignored:
https://i.imgur.com/SCxSq8l.png
When my GUI is supposed to look like this
https://i.imgur.com/JtuM7Vc.png
I've had problems in the past as well trying to open guis with your resource in the earlier versions as well. Getting these errors:
https://i.imgur.com/LTA1ZMa.png
Thanks!
This resource is great.
When I try and enter a colour code it works for the first paper displayed in the Anvil GUI. However, the second paper does not display the colour code correctly.
Code:
new AnvilGUI.Builder()
.onComplete((p, text) -> {
if(text.equalsIgnoreCase(plugin.getConfig().getString("Code"))) {
p.sendMessage(colour(plugin.getConfig().getString("CorrectCode")));
return AnvilGUI.Response.close();
} else {
return AnvilGUI.Response.text(colour(plugin.getConfig().getString("IncorrectCode")));
}
})
.preventClose()
.text(colour(plugin.getConfig().getString("AnvilText")))
.plugin(plugin)
.open(player);
}
private String colour(String i) {
return ChatColor.translateAlternateColorCodes('&', i);
}
With the code below the item is given to the player as it should be with name and lore. But the item within the anvilGUI once opened is not the same item as the one given. I am using 99a504a.
myPlayer.getInventory().addItem(item);
new AnvilGUI.Builder()
.onComplete((player, text) ->
{
String cmdStr = anvilCommand.getCommand().replace("%args%", text);
player.performCommand(cmdStr);
return AnvilGUI.Response.close();
})
.item(item)
.plugin(plugin)
.open(myPlayer);
When the Player klicks the 3rd item then onComplete gets called.
so when the player klicks the first item then onCancel should get called becouse I have no idea how the player should cancel what he is doing. And I really need this function and please don´t close this so fast and help me pls
When your xp level is >= 1 and when you click the result in the right side, the item gets picked up and disappears, therefor you cannot see the return strings
Hey there!
I am running into an issue whilst trying to compile my own plugin. I have a rather small understanding of maven, as I am still starting out and therefore I was unable to solve this problem:
Failed to execute goal on project sounds: Could not resolve dependencies for project me.theblockbender.nature:sounds:jar:0.1-SNAPSHOT: Failed to collect dependencies at net.wesjd:anvilgui:jar:1.2-SNAPSHOT: Failed to read artifact descriptor for net.wesjd:anvilgui:jar:1.2-SNAPSHOT: Could not find artifact net.wesjd:anvilgui-parent:pom:1.2-SNAPSHOT in spigot-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/) -> [Help 1]
I have all the spigot dependencies installed on my local repository. I made sure of that. You can find my POM file here: https://github.com/JustDJplease/NatureSounds/blob/master/pom.xml. Any suggestions as to what I am doing wrong?
Is there a way when yes how do I do it and how I initialize it in my main ??
This error occurs if a player closes the inventory before the code (before the GUI returns close) has fully run
org.bukkit.event.EventException: null at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:529) ~[spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:514) ~[spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:2147) ~[spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.PacketPlayInWindowClick.a(SourceFile:32) ~[spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.PacketPlayInWindowClick.a(SourceFile:10) ~[spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) ~[spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) [spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(SourceFile:144) [spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(SourceFile:118) [spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.MinecraftServer.aZ(MinecraftServer.java:917) [spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:910) [spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.awaitTasks(SourceFile:127) [spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:894) [spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:827) [spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151] Caused by: java.lang.IllegalArgumentException: You can't close an inventory that isn't open! at org.apache.commons.lang.Validate.isTrue(Validate.java:136) ~[spigot-1.15.jar:git-Spigot-f39a89e-73698cf] at net.wesjd.anvilgui.AnvilGUI.closeInventory(AnvilGUI.java:165) ~[?:?] at net.wesjd.anvilgui.AnvilGUI$ListenUp.onInventoryClick(AnvilGUI.java:208) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot-1.15.jar:git-Spigot-f39a89e-73698cf] ... 17 more
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.