satoshinm / WebSandboxMC

Bukkit plugin providing a web-based interface with an interactive WebGL 3D preview or glimpse of your server 🕷⏳📦 ⛺
https://www.spigotmc.org/resources/websandboxmc.39415/
MIT License
19 stars 5 forks source link

Update to SpigotAPI 1.16.4-R0.1-SNAPSHOT #102

Closed satoshinm closed 2 years ago

satoshinm commented 3 years ago

1.16.4-R0.1-SNAPSHOT is currently the latest API version on https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/

satoshinm commented 3 years ago

Fails to build with a missing package:

src/main/java/io/github/satoshinm/WebSandboxMC/bukkit/ClickableLinks.java:[8,23] package org.json.simple does not exist

is json-simple no longer part of spigot-api? Searching the Spigot forums, only found: https://www.spigotmc.org/threads/safetrade.99870/page-10#post-3621339 "It's not however compiling on 1.14.4 due to package org.json.simple does not exist"

This PR is updating from 1.12-R0.1-SNAPSHOT, so json-simple may be removed between 1.12 and 1.14.4...

It was removed here: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/67d908a9830c71267ee740f5bddd728ce9c64cc7#pom.xml Update to Minecraft 1.14-pre5

-        <dependency>
-            <groupId>com.googlecode.json-simple</groupId>
-            <artifactId>json-simple</artifactId>
-            <version>1.1.1</version>
-            <scope>compile</scope>
-        </dependency>
satoshinm commented 3 years ago

Wow... 71 compile errors now, all of the form:

src/main/java/io/github/satoshinm/WebSandboxMC/bridge/BlockBridge.java:[371,33] cannot find symbol
  symbol:   variable WALL_SIGN
  location: class org.bukkit.Material

https://hub.spigotmc.org/javadocs/spigot/org/bukkit/material/package-summary.html says "all usage of MaterialData is deprecated and subject to removal", did they finally remove it?

Actually https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html still exists, but there are more materials, instead of only WALL_SIGN there is now at least: ACACIA_WALL_SIGN, BIRCH_WALL_SIGN, CRIMSON_WALL_SIGN, DARK_OAK_WALL_SIGN, JUNGLE_WALL_SIGN, OAK_WALL_SIGN, SPRUCE_WALL_SIGN, WARPED_WALL_SIGN, all with WallSign MaterialData.

SIGN_POST, similarly not found. There's also a ton of "an enum switch case label must be the unqualified name of an enumeration constant" errors. But, there is a LEGACY_WALL_SIGN (and LEGACY_SIGN_POST) etc., enum value, and LEGACY_BEACON in addition to BEACON (where this 2nd error occurs). This change was made in https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/f8b2086d60942eb2cd7ac25a2a1408cb790c222c#src/main/java/org/bukkit/Material.java Update to Minecraft 1.13-pre7. Will have to see how we can support both...

Found this: https://www.spigotmc.org/threads/block-material-is-legacy.333620/ mentioning an "api-version: 1.13" key in plugin.yml, if not present then we presumably should get the LEGACY_ blocks. More info at https://www.spigotmc.org/threads/making-a-1-13-plugin-and-getting-errors-about-getmaterial-and-getmetadata.336938/#post-3139338 and advice at https://www.spigotmc.org/threads/sign-inputs-and-texts.342227/#post-3186735:

Just for the sake of clarification, no, this is not what legacy materials are for. They are not to be used in source under any circumstance. It is a way for the Spigot server to have legacy plugins (those programmed against the 1.12 API) to work on 1.13 servers. It's inefficient, it's not to be relied on, you should use the 1.13 Materials if you are writing with the 1.13 API.

so in theory we could build against 1.13 to continue to support older servers, but 1.14+ servers will operate in legacy mode for this plugin, then

satoshinm commented 3 years ago

To make progress, we could first update to 1.12.2 and update other dependencies: https://github.com/satoshinm/WebSandboxMC/pull/103 - it might still work on newer servers, in legacy mode

satoshinm commented 3 years ago

Testing with the 1.12.2 API update plugin from #103, it works on a 1.16.4 PaperMC server, with this warning:

[12:31:10 WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
[12:31:13 WARN]: Legacy plugin WebSandboxMC v1.10.4 does not specify an api-version.

at least it works decently well enough for now, but keeping this pull request open for a full native 1.16.4 API update... bearing in mind preserving 1.12.2-and-earlier compatibility is desirable (maybe a separate BlockBridge for ≤1.12.2 and ≥1.13?, or can the same plugin be written in a compatible way?)

satoshinm commented 2 years ago

Superseded by https://github.com/satoshinm/WebSandboxMC/pull/107