jensjeflensje / minecraft_imagery

Toolkit for taking pictures and videos in Minecraft
https://www.spigotmc.org/resources/imageryapi-take-pictures-in-minecraft.111347/
MIT License
18 stars 3 forks source link

Player photo error #1

Closed GabryOsas closed 1 year ago

GabryOsas commented 1 year ago

Bug

These days I'm trying this library (1.1.2). My server is 1.16.5 and uses java 16. Players who have not paid for minecraft can also enter it. When I take the photo from this error:

java.lang.NoSuchMethodError: 'org.bukkit.profile.PlayerProfile org.bukkit.entity.Player.getPlayerProfile()'
        at dev.jensderuiter.minecraft_imagery.Util.getPlayerSkin(Util.java:140) ~[?:?]
        at dev.jensderuiter.minecraft_imagery.Util.getPlayerSkinFront(Util.java:49) ~[?:?]
        at dev.jensderuiter.minecraft_imagery.image.ImageCapture.render(ImageCapture.java:230) ~[?:?]
        su me.gabryosas.commandi.CustomMapRender$1.run(CustomMapRender.java:51) ~[?:?]
        at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) ~[patched_1.16.5.jar:git-Paper-794]
        at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.16.5.jar:git-Paper-794]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]
        in java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]
        in java.lang.Thread.run(Thread.java:831) [?:?]

Is this a library bug or did I do something wrong? I literally copied and pasted the code offered as an example.

public BufferedImage takePicture(Player player) {
    List<Player> worldPlayers = player.getWorld().getPlayers();
    worldPlayers.remove(player);
    ImageCapture capture = new ImageCapture(
        player.getEyeLocation(),
        worldPlayers
    );
    BufferedImage image = capture.render();
     return image;
}
jensjeflensje commented 1 year ago

If I understand correctly, you’re running a server with online-mode set to false?

I’m thinking it may be a version incompatibility bug (I didn’t test the new version compatibility with players), or it’s related to not having online mode on.

I’ll get back to you when I’ve managed to reproduce and identify the issue. Thanks for the bug report :)

GabryOsas commented 1 year ago

Yes online-mode is set to false. 👋

jensjeflensje commented 1 year ago

Can confirm it's caused by the the version. 1.16.5 spigot doesn't include a way to fetch the player profile this easily. I'm working on my own implementation that fetches from Mojang directly. I'll update you once it's ready

GabryOsas commented 1 year ago

Ok thanks!

jensjeflensje commented 1 year ago

Hi @GabryOsas, I have fixed this issue in the latest release, 1.1.3: https://github.com/jensjeflensje/minecraft_imagery/releases/tag/1.1.3.

I have made sure it works on both 1.16.5 and 1.19.4 (the base plugin version).

Make sure to update your plugin's dependency information with version 1.1.3.

Thanks for the report! Looking forward to your creations with the library 😄

GabryOsas commented 1 year ago

Thanks!

GabryOsas commented 1 year ago

I tried the new library but from a new error:

java.lang.RuntimeException: Mojang API request was not successful
        at dev.jensderuiter.minecraft_imagery.Util.getPlayerProfile(Util.java:178) ~[?:?]
        at dev.jensderuiter.minecraft_imagery.Util.getPlayerSkin(Util.java:149) ~[?:?]
        at dev.jensderuiter.minecraft_imagery.Util.getPlayerSkinFront(Util.java:58) ~[?:?]
        at dev.jensderuiter.minecraft_imagery.image.ImageCapture.render(ImageCapture.java:230) ~[?:?]
        at me.gabryosas.commandi.CustomMapRender$1.run(CustomMapRender.java:60) ~[?:?]
        at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) ~[patched_1.16.5.jar:git-Paper-794]
        at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.16.5.jar:git-Paper-794]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]
        at java.lang.Thread.run(Thread.java:831) [?:?]

Maybe because if the server is also for people who haven't bought minecraft it's wrong?

jensjeflensje commented 1 year ago

Yeah that's caused by the players not having an actual skin, as they're not registered with Mojang. Isn't there a way you can assign a user to an actual Minecraft account (so that it has a UUID the library can use)?

What is your expected result? I mean, if they're not actual Minecraft accounts, how would they have a skin? Or are you expecting them to be a steve/alex?

I think servers without online-mode to true are very rare for this use case. I also don't want to support cracked servers explicitly.

GabryOsas commented 1 year ago

Does the SkinRestorer library not allow this?

jensjeflensje commented 1 year ago

I don't know for sure. You can try it. That may fix your problem.

Rendering a steve/alex when a player's skin can't be fetched may be something to look into. It's always nice as a fallback.

GabryOsas commented 1 year ago

👌