InfoBoard help

Discussion in 'Plugin Development' started by diamondcodes, Sep 8, 2014.

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

    diamondcodes

    Alright well I have made a few plugins but I have never looked into Scoreboards/InfoBoards, So can somebody show me a simple InfoBoard like with just for example the Objective Name "Test" with the amount of players online or something like that? or else point me towards a good tutorial?

    Thanks!
     
  2. Offline

    Creeoer

    Ok tutorial

    Alright, first you want to create a ScoreboardManager varialbe then get the bukkit scoreboardmanager.
    Then, create a Scoreboard variable and get a new scoreboard from your manager
    Objective objective = board.registerNewObjective("test", "dummy");
    Alright, now you've registerd your objective object and can cutozmiteit.
    Set its display name by doing objective.setDisplaynaem("blah); You could set its display slot as well. As for the rest ,you could create a Score variable and I believe you can only display intergers (With custom display names) Read up on that tutorial
     
  3. Offline

    diamondcodes

    Creeoer So I did this (Not sure if right),
    Code:java
    1. package me.Immortal.ib;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerJoinEvent;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9. import org.bukkit.scoreboard.*;
    10.  
    11.  
    12. public class Main extends JavaPlugin implements Listener {
    13.  
    14. ScoreboardManager manager = Bukkit.getScoreboardManager();
    15. Scoreboard board = manager.getNewScoreboard();
    16. Objective objective = board.registerNewObjective("test", "dummy");
    17.  
    18. public void onEnable() {
    19.  
    20. this.getServer().getPluginManager().registerEvents(this, this);
    21.  
    22. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    23. objective.setDisplayName("Test");
    24.  
    25. }
    26. @EventHandler
    27. public void onPlayerJoin(PlayerJoinEvent e){
    28. Player player= e.getPlayer();
    29.  
    30. Score score = objective.getScore(player.getDisplayName());
    31. score.setScore(1);
    32. player.setScoreboard(board);
    33. }
    34. }


    But I get this error when joining,
    Code:
    [21:56:30] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to TestingBoard v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.PlayerList.c(PlayerList.java:225) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.PlayerList.a(PlayerList.java:116) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.LoginListener.c(LoginListener.java:78) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.LoginListener.a(LoginListener.java:42) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:149) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    Caused by: java.lang.NoSuchMethodError: org.bukkit.scoreboard.Objective.getScore(Ljava/lang/String;)Lorg/bukkit/scoreboard/Score;
        at me.Immortal.ib.Main.onPlayerJoin(Main.java:30) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        ... 14 more
    
     
  4. Offline

    RainoBoy97

    diamondcodes
    Compile against the same version as you use on the server.
     
  5. Offline

    diamondcodes

    RainoBoy97 Thanks so much! I am having another problem but I will make another post when I get home from school :D
     
Thread Status:
Not open for further replies.

Share This Page