bergerhealer / BKCommonLib

An extensive library used in bergerhealer's plugins
Other
180 stars 44 forks source link

Using of "CommonScoreboard" occurs tracebacks [PRIO: LOW] #67

Open tgroeger opened 5 years ago

tgroeger commented 5 years ago
BkCommonLib version: Build #565 (Mon Jul 01 20:25:32 UTC 2019)
Spigot version: 1.14.3

Problem or bug: Creation of CommonScoreboard running in tracebacks:

[23:13:36] [Server thread/WARN]: java.lang.IllegalArgumentException: Instance of type com.bergerkiller.bukkit.common.protocol.CommonPacket does not contain the field declared in net.minecraft.server.v1_14_R1.PacketPlayOutScoreboardObjective
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.fast.ReflectionAccessor.checkInstance(ReflectionAccessor.java:30)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.fast.ReflectionAccessor.f(ReflectionAccessor.java:52)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.fast.ReflectionAccessor.set(ReflectionAccessor.java:98)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.FastField$FastFieldInitProxy.set(FastField.java:291)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.FastField.set(FastField.java:179)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.SafeField.set(SafeField.java:119)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.bukkit.common.protocol.CommonPacket.write(CommonPacket.java:59)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.bukkit.common.scoreboards.CommonObjective.handle(CommonObjective.java:176)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.bukkit.common.scoreboards.CommonObjective.show(CommonObjective.java:157)
[23:13:36] [Server thread/WARN]:    at de.brave.system.Addons.TabPrefix.TabPrefix$2.run(TabPrefix.java:129)
[23:13:36] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftTask.run(CraftTask.java:81)
[23:13:36] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:394)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1011)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:396)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:959)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:804)
[23:13:36] [Server thread/WARN]:    at java.lang.Thread.run(Thread.java:748)
[23:13:36] [Server thread/WARN]: java.lang.IllegalArgumentException: Instance of type com.bergerkiller.bukkit.common.protocol.CommonPacket does not contain the field declared in net.minecraft.server.v1_14_R1.PacketPlayOutScoreboardObjective
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.fast.ReflectionAccessor.checkInstance(ReflectionAccessor.java:30)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.fast.ReflectionAccessor.f(ReflectionAccessor.java:52)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.fast.ReflectionAccessor.set(ReflectionAccessor.java:98)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.FastField$FastFieldInitProxy.set(FastField.java:291)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.FastField.set(FastField.java:179)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.SafeField.set(SafeField.java:119)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.TranslatorFieldAccessor.setInternal(TranslatorFieldAccessor.java:57)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.TranslatorFieldAccessor.set(TranslatorFieldAccessor.java:67)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.bukkit.common.protocol.CommonPacket.write(CommonPacket.java:59)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.bukkit.common.scoreboards.CommonObjective.handle(CommonObjective.java:177)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.bukkit.common.scoreboards.CommonObjective.show(CommonObjective.java:157)
[23:13:36] [Server thread/WARN]:    at de.brave.system.Addons.TabPrefix.TabPrefix$2.run(TabPrefix.java:129)
[23:13:36] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftTask.run(CraftTask.java:81)
[23:13:36] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:394)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1011)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:396)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:959)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:804)
[23:13:36] [Server thread/WARN]:    at java.lang.Thread.run(Thread.java:748)
[23:13:36] [Server thread/WARN]: java.lang.IllegalArgumentException: Instance of type com.bergerkiller.bukkit.common.protocol.CommonPacket does not contain the field declared in net.minecraft.server.v1_14_R1.PacketPlayOutScoreboardObjective
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.fast.ReflectionAccessor.checkInstance(ReflectionAccessor.java:30)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.fast.ReflectionAccessor.f(ReflectionAccessor.java:52)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.fast.ReflectionAccessor.set(ReflectionAccessor.java:98)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.FastField$FastFieldInitProxy.set(FastField.java:291)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.util.FastField.set(FastField.java:179)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.mountiplex.reflection.SafeField.set(SafeField.java:119)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.bukkit.common.protocol.CommonPacket.write(CommonPacket.java:59)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.bukkit.common.scoreboards.CommonObjective.handle(CommonObjective.java:178)
[23:13:36] [Server thread/WARN]:    at com.bergerkiller.bukkit.common.scoreboards.CommonObjective.show(CommonObjective.java:157)
[23:13:36] [Server thread/WARN]:    at de.brave.system.Addons.TabPrefix.TabPrefix$2.run(TabPrefix.java:129)
[23:13:36] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftTask.run(CraftTask.java:81)
[23:13:36] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:394)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1011)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:396)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:959)
[23:13:36] [Server thread/WARN]:    at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:804)
[23:13:36] [Server thread/WARN]:    at java.lang.Thread.run(Thread.java:748)
[23:13:36] [Server thread/WARN]: [System] Task #641 for System v1.0 generated an exception
java.lang.ClassCastException: com.bergerkiller.bukkit.common.protocol.CommonPacket cannot be cast to net.minecraft.server.v1_14_R1.Packet
    at com.bergerkiller.mountiplex.reflection.util.fast.GeneratedInvoker$mplgen79404470.invoke(Unknown Source) ~[?:?]
    at com.bergerkiller.mountiplex.reflection.util.FastMethod$FastMethodInitProxy.invoke(FastMethod.java:191) ~[?:?]
    at com.bergerkiller.mountiplex.reflection.util.FastMethod.invoke(FastMethod.java:122) ~[?:?]
    at com.bergerkiller.mountiplex.reflection.declarations.Template$Method.invoke(Template.java:1506) ~[?:?]
    at com.bergerkiller.bukkit.common.internal.network.ProtocolLibPacketHandler.sendPacket(ProtocolLibPacketHandler.java:141) ~[?:?]
    at com.bergerkiller.bukkit.common.utils.PacketUtil.sendPacket(PacketUtil.java:75) ~[?:?]
    at com.bergerkiller.bukkit.common.utils.PacketUtil.sendPacket(PacketUtil.java:68) ~[?:?]
    at com.bergerkiller.bukkit.common.scoreboards.CommonObjective.handle(CommonObjective.java:179) ~[?:?]
    at com.bergerkiller.bukkit.common.scoreboards.CommonObjective.show(CommonObjective.java:157) ~[?:?]
    at de.brave.system.Addons.TabPrefix.TabPrefix$2.run(TabPrefix.java:129) ~[?:?]
    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftTask.run(CraftTask.java:81) ~[spigot-1.14.3.jar:git-Spigot-595711b-e8b39d4]
    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:394) [spigot-1.14.3.jar:git-Spigot-595711b-e8b39d4]
    at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1011) [spigot-1.14.3.jar:git-Spigot-595711b-e8b39d4]
    at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:396) [spigot-1.14.3.jar:git-Spigot-595711b-e8b39d4]
    at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:959) [spigot-1.14.3.jar:git-Spigot-595711b-e8b39d4]
    at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:804) [spigot-1.14.3.jar:git-Spigot-595711b-e8b39d4]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]

Expected behaviour: Scoreboard should be shown

Steps to reproduce: Source Code:

CommonScoreboard board = CommonScoreboard.get(e.getPlayer()); //Get the scoreboard form the player
CommonObjective sidebar = board.getObjective(Display.SIDEBAR); //Get the sidebar scoreboard
sidebar.show(); //Shwo the sidebar (use siderbar.hide() to hide)
sidebar.setDisplayName("PvP Info");
sidebar.createScore("kills", "§eKills", 17); //Create a new score called 'kills' and make the value 17

new BukkitRunnable() {

    @Override
    public void run() {
        CommonScore kills = sidebar.getScore("kills");
        kills.setValue(18); //Change the value to 18 kills
        kills.update(); //Don't forget ot update the score after changing it!
    }
}.runTaskLater(getPlugin(), 20);
bergerkiller commented 5 years ago

Oh wow I'll be honest, I didn't even know the scoreboard API was used by anyone still. Does it still serve a purpose on top of what the Bukkit API provides?

None of my plugins use it so I don't really have a test environment for it at all. The component was originally added by another developer that needed it at the time.

Is the BKCommonLib scoreboard API critical enough? If so, I can spend some time going through this another time.

bergerkiller commented 5 years ago

Also I wonder, does this API work for 1.13.2 and earlier?

tgroeger commented 5 years ago

I'm using the scoreboard API for the first time, and i saw this traceback and reported it :D I was just trying to create a personal scoreboard for a player which is already in a public scoreboard team.

If this isn't possible at all you dont need to fix it for me. Otherwise a fix would be very nice :)

bergerkiller commented 5 years ago

Well you could make hidden scoreboards (using packets) I suppose, but not sure if thats very useful. If I remember correctly the client also likes disconnecting when some socreboard update is done that is incorrect...

tgroeger commented 5 years ago

Yes, i am using this library anyway (LightCleaner) so i was just trying to play a little bit with given functionalitites. So if you don't mind and don't want to investigate in this topic this issue can be closed :)

bergerkiller commented 5 years ago

It's fine to leave open, the issue is there and valid. It really is up to me to either remove the part of the API, fix the issues or write a demo plugin to actually routinely test this.

Right now it has no priority though, so it's better if you use the builtin API's. :)