Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommandAPIBukkit.get().getTags() produces NoSuchMethodError in 1.20.4 #524

Closed
XHawk87 opened this issue Feb 26, 2024 · 6 comments
Closed
Labels
bug Something isn't working implemented for next release This has been implemented in the current dev build for the next public release

Comments

@XHawk87
Copy link
Collaborator

XHawk87 commented Feb 26, 2024

CommandAPI version

9.3.0

Minecraft version

1.20

Are you shading the CommandAPI?

Yes

What I did

I set up a basic project to test the CommandAPIBukkit.get().getTags(); method. See: XHawk87/CommandAPITest

What actually happened

CommandAPI fails with NoSuchMethodError when attempting to call the method CommandAPIBukkit.get().getTags();

What should have happened

It should have found the tags without producing an error.

Server logs and CommandAPI config

See: XHawk87/CommandAPITest

> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :shadowJar UP-TO-DATE

> Task :runServer
Located Paper 1.20.4 build 435 in local cache.
Starting Paper...

Starting org.bukkit.craftbukkit.Main
System Info: Java 17 (OpenJDK 64-Bit Server VM 17.0.9+8-b1166.2) Host: Linux 6.5.0-18-generic (amd64)
Loading libraries, please wait...
2024-02-26 00:52:23,509 ServerMain WARN Advanced terminal features are not available in this environment
[00:52:30 INFO]: Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD]
[00:52:31 INFO]: Found new data pack file/bukkit, loading it automatically
[00:52:32 INFO]: No existing world data, creating new world
[00:52:33 INFO]: Loaded 1174 recipes
[00:52:33 INFO]: Loaded 1271 advancements
[00:52:34 INFO]: Starting minecraft server version 1.20.4
[00:52:34 INFO]: Loading properties
[00:52:34 INFO]: This server is running Paper version git-Paper-435 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 681bbff)
[00:52:34 INFO]: Using 4 threads for Netty based IO
[00:52:34 INFO]: Server Ping Player Sample Count: 12
[00:52:35 INFO]: [ChunkTaskScheduler] Chunk system is using 1 I/O threads, 2 worker threads, and gen parallelism of 2 threads
[00:52:35 WARN]: [!] The timings profiler has been enabled but has been scheduled for removal from Paper in the future.
    We recommend installing the spark profiler as a replacement: https://spark.lucko.me/
    For more information please visit: https://github.com/PaperMC/Paper/issues/8948
[00:52:35 INFO]: Default game type: SURVIVAL
[00:52:35 INFO]: Generating keypair
[00:52:35 INFO]: Starting Minecraft server on *:25565
[00:52:35 INFO]: Using epoll channel type
[00:52:35 INFO]: Paper: Using libdeflate (Linux x86_64) compression from Velocity.
[00:52:35 INFO]: Paper: Using OpenSSL 3.0.x (Linux x86_64) cipher from Velocity.
[00:52:35 INFO]: [CommandAPITest] Loading server plugin CommandAPITest v0.0.0
[00:52:35 INFO]: [CommandAPI] Loaded platform NMS_1_20_R3 > NMS_Common > CommandAPIBukkit
[00:52:35 WARN]: [CommandAPI] Could not hook into the NBT API for NBT support. Download it from https://www.spigotmc.org/resources/nbt-api.7939/
[00:52:35 INFO]: [CommandAPI] Hooked into Spigot successfully for Chat/ChatComponents
[00:52:35 INFO]: [CommandAPI] Hooked into Adventure for AdventureChat/AdventureChatComponents
[00:52:35 INFO]: [CommandAPI] Hooked into Paper for paper-specific API implementations
[00:52:35 INFO]: [CommandAPITest] Enabling CommandAPITest v0.0.0
[00:52:36 INFO]: [CommandAPI] Hooked into Paper ServerResourcesReloadedEvent
[00:52:36 ERROR]: Error occurred while enabling CommandAPITest v0.0.0 (Is it up to date?)
java.lang.NoSuchMethodError: 'net.minecraft.server.CustomFunctionData net.minecraft.server.MinecraftServer.aA()'
	at uk.co.hawks_haven.commandapitest.shaded.dev.jorel.commandapi.nms.NMS_Common.getTags(NMS_Common.java:571) ~[CommandAPITest-0.0.0-all.jar:?]
	at uk.co.hawks_haven.commandapitest.CommandAPITest.onEnable(CommandAPITest.java:20) ~[CommandAPITest-0.0.0-all.jar:?]
	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
	at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:188) ~[paper-1.20.4.jar:git-Paper-435]
	at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.4.jar:git-Paper-435]
	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugin(CraftServer.java:639) ~[paper-1.20.4.jar:git-Paper-435]
	at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugins(CraftServer.java:550) ~[paper-1.20.4.jar:git-Paper-435]
	at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:275) ~[paper-1.20.4.jar:git-Paper-435]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1131) ~[paper-1.20.4.jar:git-Paper-435]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[paper-1.20.4.jar:git-Paper-435]
	at java.lang.Thread.run(Thread.java:840) ~[?:?]
[00:52:36 INFO]: [CommandAPITest] Disabling CommandAPITest v0.0.0
[00:52:36 INFO]: Preparing level "world"
[00:52:49 INFO]: Preparing start region for dimension minecraft:overworld
[00:52:49 INFO]: Time elapsed: 234 ms
[00:52:49 INFO]: Preparing start region for dimension minecraft:the_nether
[00:52:49 INFO]: Time elapsed: 144 ms
[00:52:49 INFO]: Preparing start region for dimension minecraft:the_end
[00:52:50 INFO]: Time elapsed: 143 ms
[00:52:50 INFO]: Running delayed init tasks
[00:52:50 INFO]: Done (16.050s)! For help, type "help"
[00:52:50 INFO]: Timings Reset

Other

No response

@XHawk87 XHawk87 added the bug Something isn't working label Feb 26, 2024
@JorelAli
Copy link
Owner

I have a feeling this may be due to "the limited support for the FunctionArgument" from CommandAPI 9.3.0. With CommandAPI 9.3.0, due to such a short Minecraft release cycle between version 1.20.3 and 1.20.4, in order to meet the CommandAPI's release deadline we had to release without full support for functions (and by extension, tags as well).

I am not in a position to test this right now, but I believe CommandAPI 9.4.0's snapshot build fixes this. Information on using the CommandAPI's snapshot builds can be found in the CommandAPI's Discord server here, or simply change the target to the snapshot repository:

repositories {
    maven { url = "https://s01.oss.sonatype.org/content/repositories/snapshots" }
}

dependencies {
    implementation "dev.jorel:commandapi-bukkit-shade:9.4.0-SNAPSHOT"   
}

If of course version 9.4.0-SNAPSHOT doesn't fix this, then this issue warrants further investigation.

@XHawk87
Copy link
Collaborator Author

XHawk87 commented Feb 26, 2024

Well, I tried it with the snapshot, but I still get the same error.

> Task :compileJava UP-TO-DATE
> Task :processResources
> Task :classes
> Task :shadowJar

> Task :runServer
Located Paper 1.20.4 build 435 in local cache.
Starting Paper...

Starting org.bukkit.craftbukkit.Main
System Info: Java 17 (OpenJDK 64-Bit Server VM 17.0.9+8-b1166.2) Host: Linux 6.5.0-18-generic (amd64)
Loading libraries, please wait...
2024-02-26 01:23:49,471 ServerMain WARN Advanced terminal features are not available in this environment
[01:23:57 INFO]: Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD]
[01:24:00 INFO]: Loaded 1174 recipes
[01:24:00 INFO]: Loaded 1271 advancements
[01:24:01 INFO]: Starting minecraft server version 1.20.4
[01:24:01 INFO]: Loading properties
[01:24:01 INFO]: This server is running Paper version git-Paper-435 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 681bbff)
[01:24:01 INFO]: Using 4 threads for Netty based IO
[01:24:01 INFO]: Server Ping Player Sample Count: 12
[01:24:02 WARN]: [!] The timings profiler has been enabled but has been scheduled for removal from Paper in the future.
    We recommend installing the spark profiler as a replacement: https://spark.lucko.me/
    For more information please visit: https://github.com/PaperMC/Paper/issues/8948
[01:24:02 INFO]: [ChunkTaskScheduler] Chunk system is using 1 I/O threads, 2 worker threads, and gen parallelism of 2 threads
[01:24:02 INFO]: Default game type: SURVIVAL
[01:24:02 INFO]: Generating keypair
[01:24:02 INFO]: Starting Minecraft server on *:25565
[01:24:02 INFO]: Using epoll channel type
[01:24:02 INFO]: Paper: Using libdeflate (Linux x86_64) compression from Velocity.
[01:24:02 INFO]: Paper: Using OpenSSL 3.0.x (Linux x86_64) cipher from Velocity.
[01:24:03 INFO]: [CommandAPITest] Loading server plugin CommandAPITest v0.0.1
[01:24:03 INFO]: [CommandAPI] Loaded platform NMS_1_20_R3 > NMS_Common > CommandAPIBukkit
[01:24:03 INFO]: [CommandAPI] Hooked into Spigot successfully for Chat/ChatComponents
[01:24:03 INFO]: [CommandAPI] Hooked into Adventure for AdventureChat/AdventureChatComponents
[01:24:03 INFO]: [CommandAPI] Hooked into Paper for paper-specific API implementations
[01:24:03 INFO]: Server permissions file permissions.yml is empty, ignoring it
[01:24:03 INFO]: [CommandAPITest] Enabling CommandAPITest v0.0.1
[01:24:03 INFO]: [CommandAPI] Hooked into Paper ServerResourcesReloadedEvent
[01:24:03 ERROR]: Error occurred while enabling CommandAPITest v0.0.1 (Is it up to date?)
java.lang.NoSuchMethodError: 'net.minecraft.server.CustomFunctionData net.minecraft.server.MinecraftServer.aA()'
	at uk.co.hawks_haven.commandapitest.shaded.dev.jorel.commandapi.nms.NMS_Common.getTags(NMS_Common.java:570) ~[CommandAPITest-0.0.1-all.jar:?]
	at uk.co.hawks_haven.commandapitest.CommandAPITest.onEnable(CommandAPITest.java:20) ~[CommandAPITest-0.0.1-all.jar:?]
	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
	at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:188) ~[paper-1.20.4.jar:git-Paper-435]
	at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.4.jar:git-Paper-435]
	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugin(CraftServer.java:639) ~[paper-1.20.4.jar:git-Paper-435]
	at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugins(CraftServer.java:550) ~[paper-1.20.4.jar:git-Paper-435]
	at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:275) ~[paper-1.20.4.jar:git-Paper-435]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1131) ~[paper-1.20.4.jar:git-Paper-435]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[paper-1.20.4.jar:git-Paper-435]
	at java.lang.Thread.run(Thread.java:840) ~[?:?]
[01:24:03 INFO]: [CommandAPITest] Disabling CommandAPITest v0.0.1
[01:24:03 INFO]: Preparing level "world"
[01:24:04 INFO]: Preparing start region for dimension minecraft:overworld
[01:24:04 INFO]: Time elapsed: 441 ms
[01:24:04 INFO]: Preparing start region for dimension minecraft:the_nether
[01:24:04 INFO]: Time elapsed: 86 ms
[01:24:04 INFO]: Preparing start region for dimension minecraft:the_end
[01:24:04 INFO]: Time elapsed: 119 ms
[01:24:04 INFO]: Running delayed init tasks
[01:24:04 INFO]: Done (3.890s)! For help, type "help"
[01:24:04 INFO]: Timings Reset

@JorelAli
Copy link
Owner

🤦 I'm being an idiot. Of course it doesn't work - it's a mapping issue from the shared NMS_Common class. This is a trivial fix, we need to migrate this function call to its respective NMS implementations:

@Override
public final Set<NamespacedKey> getTags() {
Set<NamespacedKey> result = new HashSet<>();
for (ResourceLocation resourceLocation : this.<MinecraftServer>getMinecraftServer().getFunctions().getTagNames()) {
result.add(fromResourceLocation(resourceLocation));
}
return result;
}

(As mentioned earlier, I'm not in a position to do this right now, but should be available after ~11 hours if nobody else fixes this themselves)

@JorelAli
Copy link
Owner

With luck, this should now be fixed in the latest 9.4.0-SNAPSHOT build 🤞

@JorelAli JorelAli added the implemented for next release This has been implemented in the current dev build for the next public release label Feb 26, 2024
@XHawk87
Copy link
Collaborator Author

XHawk87 commented Feb 26, 2024

Looks good on the test server. No errors.

@JorelAli
Copy link
Owner

Fixed in version 9.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working implemented for next release This has been implemented in the current dev build for the next public release
Projects
None yet
Development

No branches or pull requests

2 participants