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

PlotSquared uses deprecated class MaterialData #3883

Closed
2 tasks done
InfectedCatBite opened this issue Nov 30, 2022 · 3 comments · Fixed by #3894
Closed
2 tasks done

PlotSquared uses deprecated class MaterialData #3883

InfectedCatBite opened this issue Nov 30, 2022 · 3 comments · Fixed by #3894
Labels
Approved A project maintainer or developer has reproduced this issue Good first issue Simple issue which would be a good first PR for newbies interested in contributing to the project

Comments

@InfectedCatBite
Copy link

InfectedCatBite commented Nov 30, 2022

Server Implementation

Spigot

Server Version

1.19.2

Describe the bug

BlockEventListener line 940 calls BlockState#getData, which returns MaterialData. This ends up loading the Legacy Material Support even though the server is running 1.19.2 and using 1.19.2 blocks.

BlockFace targetFace = ((Directional) event.getBlock().getState().getData()).getFacing();

To Reproduce

  1. Place a dispenser.
  2. Put a water bucket in the dispenser.
  3. Trigger the dispenser with your favorite redstone trigger.
  4. See the Initializing Legacy Material Support message in the console.

Note that the world doesn't even need to be a plot world! Bad PlotSquared, bad!

Expected behaviour

PlotSquared doesn't load the Legacy Material Support on a 1.19.2 server using 1.19.2 blocks.

Screenshots / Videos

No response

Error log (if applicable)

No response

Plot Debugpaste

Just look at your code.

PlotSquared Version

6.10.4

Checklist

Anything else?

Problem also occurs using Paper.

2022-11-30 05:56:21 [ERROR] [STDERR] [org.bukkit.craftbukkit.v1_19_R1.legacy.CraftLegacy] Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
2022-11-30 05:56:21 [WARN] java.lang.Exception
2022-11-30 05:56:21 [WARN] 	at org.bukkit.craftbukkit.v1_19_R1.legacy.CraftLegacy.<clinit>(CraftLegacy.java:260)
2022-11-30 05:56:21 [WARN] 	at org.bukkit.craftbukkit.v1_19_R1.util.CraftMagicNumbers.getMaterial(CraftMagicNumbers.java:118)
2022-11-30 05:56:21 [WARN] 	at org.bukkit.craftbukkit.v1_19_R1.block.CraftBlockState.getData(CraftBlockState.java:154)
2022-11-30 05:56:21 [WARN] 	at PlotSquared.jar//com.plotsquared.bukkit.listener.BlockEventListener.onBlockDispense(BlockEventListener.java:940)
2022-11-30 05:56:21 [WARN] 	at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor71.execute(Unknown Source)
2022-11-30 05:56:21 [WARN] 	at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77)
2022-11-30 05:56:21 [WARN] 	at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
2022-11-30 05:56:21 [WARN] 	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
2022-11-30 05:56:21 [WARN] 	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:670)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.core.dispenser.IDispenseBehavior$9.a(IDispenseBehavior.java:692)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.core.dispenser.DispenseBehaviorItem.dispense(DispenseBehaviorItem.java:32)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.world.level.block.BlockDispenser.a(BlockDispenser.java:98)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.world.level.block.BlockDispenser.a(BlockDispenser.java:124)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.world.level.block.state.BlockBase$BlockData.a(BlockBase.java:1014)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.server.level.WorldServer.d(WorldServer.java:1141)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.world.ticks.TickListServer.a(TickListServer.java:197)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.world.ticks.TickListServer.a(TickListServer.java:94)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.server.level.WorldServer.a(WorldServer.java:673)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1535)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:446)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1397)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:1173)
2022-11-30 05:56:21 [WARN] 	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305)
2022-11-30 05:56:21 [WARN] 	at java.base/java.lang.Thread.run(Thread.java:833)
@InfectedCatBite InfectedCatBite added the Requires Testing This is a new issue which needs to be approved before labeled with "bug" label Nov 30, 2022
@SirYwell SirYwell added Approved A project maintainer or developer has reproduced this issue Good first issue Simple issue which would be a good first PR for newbies interested in contributing to the project and removed Requires Testing This is a new issue which needs to be approved before labeled with "bug" labels Nov 30, 2022
@InfectedCatBite
Copy link
Author

In addition to fixing the Legacy Material use, I suggest you also add the following to onBlockDispense:

        if (!this.plotAreaManager.hasPlotArea(event.getBlock().getWorld().getName())) {
            return;
        }

No need for the method to do additional checks if the dispenser is not in a plot world.

@NotMyFault
Copy link
Member

NotMyFault commented Dec 9, 2022

Hey,

thanks for the investigation. Would you be interested in filing a pull request to get a rid of the deprecated method?

@InfectedCatBite
Copy link
Author

Sorry, that's beyond my comfort zone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved A project maintainer or developer has reproduced this issue Good first issue Simple issue which would be a good first PR for newbies interested in contributing to the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants