Making custom scoreboard objective on player list

Discussion in 'Plugin Development' started by ToldiIII, Nov 25, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    ToldiIII

    I started creating a custom scoreboard objective that displays the health level, ping or a customized interval on the tab. Instead, I do not want to use a scoreboard team or a simple scoreboard, because it has a problem, for example, if I give the placeholder the level of the player's experience (interval markup), but this throws IllegalArgumentException to the server console. This is inappropriate, so I would like to use the custom scoreboard object.
    I've looked at each page what it should, but it did not help. Here is the code I started:
    Code:
    try {
        Object newPacketObj = Class.forName("net.minecraft.server." + version + ".PacketPlayOutScoreboardObjective").getConstructor().newInstance();
        Class<?> newPacketScore = Class.forName("net.minecraft.server." + version + ".PacketPlayOutScoreboardObjective");
        newPacketScore.getDeclaredField("a").setAccessible(true);
    } catch (Exception e) {
      e.printStackTrace();
    }
    Example images what I want:
    upload_2018-11-25_18-4-49.png

    upload_2018-11-25_18-5-38.png
     
    Last edited: Nov 26, 2018
  2. What's the IllegalArgumentException? Also, I do not see what you are trying to do with your code. It would be much simpler if you just wrote using the Bukkit scoreboard system, made a new objective, that assigned values to those objectives. Please, post the IllegalArgumentException
     
  3. Offline

    ToldiIII

    As I said, the Bukkit objects are not correct because not work the way they should. For example: if I set the health object with Bukkit and update it in the game then I get the result: https://hub.spigotmc.org/jira/browse/SPIGOT-3835

    With the custom packets, I get the opposite of that. That is, it works normally.

    This error:
    Show Spoiler

    [09:08:21 WARN]: [MyPlugin] Task #54906 for MyPlugin v3.7 generated an exception
    java.lang.IllegalArgumentException: Entry cannot be longer than 40 characters!
    at org.bukkit.craftbukkit.v1_13_R2.scoreboard.CraftObjective.getScore(CraftObjective.java:113) ~[patched_1.13.2.jar:git-Paper-461]
    at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftTask.run(CraftTask.java:82) ~[patched_1.13.2.jar:git-Paper-461]
    at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:448) ~[patched_1.13.2.jar:git-Paper-461]
    at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:1008) ~[patched_1.13.2.jar:git-Paper-461]
    at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:439) ~[patched_1.13.2.jar:git-Paper-461]
    at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:943) ~[patched_1.13.2.jar:git-Paper-461]
    at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:841) ~[patched_1.13.2.jar:git-Paper-461]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_192]

    The code is visible in the post above because it is the path of the error.
     
    TheEnderCrafter9 likes this.
Thread Status:
Not open for further replies.

Share This Page