Solved Individual Scoreboards For Each Player

Discussion in 'Plugin Development' started by CytrixMC, Aug 27, 2014.

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

    CytrixMC

    Hi Bukkit Forums. I lately been stumped on scoreboard for each player. By this I mean I would display statistics for each player such as Kills, Deaths, Coins, etc. I already know how to input data into the config file and displaying it into a scoreboard. I have tried doing this many times but it never worked out perfectly. I am now tired of wasting time and I decided to turn to the community!
     
    GrandmaJam likes this.
  2. Offline

    Bram0101

    Try having a hashmap<String, Scoreboard> (the string is the name of the player and the Scoreboard is what you get when you do scoreboardmanager.getNewScoreboard();). Then when you update the Scoreboard for the player, you check if the players name is in the hashmap, if so you get the Scoreboard and remove all the data and set the data, set the players scoreboard to the Scoreboard and save the Scoreboard in the hashmap. If the players name isn't in the hashmap you create a new scoreboard and set the data, set the players scoreboard to the Scoreboard and put it in the hashmap. (you don't need to save the hashmap. And because you don't need to save the hashmap you don't need to use a uuid.)
     
  3. Offline

    CytrixMC

    I'm sorry. I understand what you mean and thank you for helping me. Although I don't know where to start, If you show me an example of it I can understand it more. I understand what you mean I just cant picture how to do this. Thank you so much for helping me out.
     
  4. Offline

    TheHandfish

    Nah, use the UUID, not the name. What's the point of using the name? Getting the player by name is a deprecated method which may very well be removed in a future update of Craftbukkit. Better get used to UUIDs.
     
  5. Offline

    Jimfutsu

    This is fairly easy, all you have to do is get the information from the configuration, and instead of using the onEnable, use the player join event.
     
  6. Offline

    CytrixMC

    I have never used UUID's because I've been doing bukkit for only a few months now. Can I please have example's of this.

    Yeah I know about the config its just that I am terrible at scoreboards.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  7. Offline

    TheHandfish

    UUIDs are the replacement for player usernames. 1.8 brings about name changes, and therefore, we can't continue to use player names since they can change whenever. This is not so much a problem in this example, where the hash map is not saved, but since the Bukkit.getPlayer(String) method is deprecated, and the only other way is to loop through players to check if the name matches, it's worth it to simply use UUIDs instead. You can get the UUID of a player by using <player>.getUniqueId(). Store that in a variable, then make a hash map: HashMap<UUID, Scoreboard>. To convert the UUID to a Player, simply do Bukkit.getPlayer(uuid); rather than Bukkit.getPlayer(playername).
     
  8. Offline

    Jimfutsu

  9. Offline

    CytrixMC

    Thank you ima try this now.
     
  10. Offline

    TheHandfish

  11. Offline

    FerusGrim

    TheHandfish CytrixMC

    Getting a player via name isn't going to be removed in later versions of Bukkit. It's deprecated for no other reason than to raise awareness over the coming changes with UUIDs, and still has many valid use-cases.
     
  12. Offline

    CytrixMC

    I did it. Although I get an error when I set the scoreboard to the player that joins. here is my code

    Code:
    package me.CytrixMC.KlarityCoins;
     
     
    import java.util.HashMap;
    import java.util.UUID;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;
     
     
    public class Coins extends JavaPlugin implements Listener {
     
    Scoreboard board;
     
    HashMap<UUID, Scoreboard> uuidboard = new HashMap<UUID, Scoreboard>();
     
    public void onEnable(){
    this.getCommand("coins").setExecutor(new CoinsCommand(this));
    getServer().getPluginManager().registerEvents(this, this);
    }
     
     
    @SuppressWarnings("deprecation")
    public void showScoreboard(Player player) {
     
    UUID p = player.getUniqueId();
     
    ScoreboardManager manager = Bukkit.getScoreboardManager();
    Scoreboard board = manager.getNewScoreboard();
     
     
    int a = Bukkit.getOnlinePlayers().length;
    String b = getConfig().getString(Bukkit.getPlayer(p).getName(), ".Coins");
     
    Objective objective = board.registerNewObjective("test", "stats");
    objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    objective.setDisplayName(ChatColor.RED + "Klarity " + ChatColor.GOLD + "FFA");
     
    //Online Score
    Score score1 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.GREEN + "Online:"));
    Score score1int = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" + a));
    score1.setScore(4);
    score1int.setScore(3);
     
    //Coins Score
    Score score2 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.GOLD + "Coins"));
    Score score2int = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" + b));
    score2.setScore(2);
    score2int.setScore(1);
     
    }
     
     
     
    @EventHandler
    public void onJoin(PlayerJoinEvent e){
    Player p = e.getPlayer();
    if(p instanceof Player){
    //Scoreboard Set
    e.getPlayer().setScoreboard(board);
     
    //Coins Config Data
    if(!getConfig().contains(p.getName())){
    getConfig().set(p.getName() + ".Coins", 0);
    }
     
    }
    }
     
     
    @EventHandler
    public void onKill(PlayerDeathEvent e){
    if(e.getEntity() instanceof Player){
    Player p = (Player) e.getEntity();
    if(e.getEntity().getKiller() instanceof Player){
    Player k = p.getKiller();
    addCoins(k, 1);
    }
    }
     
    if(e.getEntity() instanceof Player){
    Player p = (Player) e.getEntity();
    if(e.getEntity().getKiller() instanceof Player){
    removeCoins(p, 1);
    }
    }
    }
     
    public void addCoins(Player p, int i){
    getConfig().set(p.getName() + ".Coins", getConfig().getInt(p.getName() + ".Coins", 0) + i);
    saveConfig();
    }
     
    public void removeCoins(Player p, int i){
    if(getConfig().getInt(p.getName() + ".Coins") == 0){
    return;
    } else {
    getConfig().set(p.getName() + ".Coins", getConfig().getInt(p.getName() + ".Coins", 0) - i);
    saveConfig();
    }
    }
     
    public void onDisable(){
     
    }
     
     
    }
    
    If you need the console error tell me
     
  13. Offline

    TheHandfish

    Every time you get an error, you should post it.

    Code:
    if(getConfig().getInt(p.getName() + ".Coins") == 0){
    This will cause problems for sure. p.getName() should be p.getUniqueId().
     
  14. Offline

    _LB

  15. Offline

    CytrixMC

    Here is the error I get.

    Code:
    [12:02:12] [Server thread/INFO]: Starting minecraft server version 1.7.9
    [12:02:12] [Server thread/INFO]: Loading properties
    [12:02:12] [Server thread/INFO]: Default game type: SURVIVAL
    [12:02:12] [Server thread/INFO]: Generating keypair
    [12:02:12] [Server thread/INFO]: Starting Minecraft server on *:25565
    [12:02:13] [Server thread/INFO]: This server is running CraftBukkit version git-Bukkit-1.7.9-R0.1-b3084jnks (MC: 1.7.9) (Implementing API version 1.7.9-R0.1)
    [12:02:13] [Thread-7/INFO]: ----- Bukkit Auto Updater -----
    [12:02:13] [Thread-7/INFO]: It appears that you're running a Beta Build, when you've specified in bukkit.yml that you prefer to run Recommended Builds.
    [12:02:13] [Thread-7/INFO]: If you would like to be kept informed about new Beta Build releases, it is recommended that you change 'preferred-channel' in your bukkit.yml to 'beta'.
    [12:02:13] [Thread-7/INFO]: With that set, you will be told whenever a new version is available for download, so that you can always keep up to date and secure with the latest fixes.
    [12:02:13] [Thread-7/INFO]: If you would like to disable this warning, simply set 'suggest-channels' to false in bukkit.yml.
    [12:02:13] [Thread-7/INFO]: ----- ------------------- -----
    [12:02:14] [Server thread/INFO]: [FreeForAll] Loading FreeForAll v1.0
    [12:02:14] [Server thread/INFO]: [WorldEdit] Loading WorldEdit v5.5.8
    [12:02:14] [Server thread/INFO]: [ProtocolLib] Loading ProtocolLib v3.4.0
    [12:02:14] [Server thread/WARN]: [ProtocolLib] Version (MC: 1.7.9) has not yet been tested! Proceed with caution.
    [12:02:14] [Server thread/INFO]: [Multiverse-Core] Loading Multiverse-Core v2.4-b527
    [12:02:14] [Server thread/INFO]: [iControlU] Loading iControlU v1.7.0
    [12:02:14] [Server thread/INFO]: [LibsDisguises] Loading LibsDisguises v8.2.6
    [12:02:14] [Server thread/INFO]: [GalaxyFFA] Loading GalaxyFFA v1.0
    [12:02:14] [Server thread/INFO]: [BarAPI] Loading BarAPI v3.1
    [12:02:14] [Server thread/INFO]: [VoxelSniper] Loading VoxelSniper v5.170.0-SNAPSHOT-jnks317-gitfcb8fe1
    [12:02:14] [Server thread/INFO]: [WorldGuard] Loading WorldGuard v5.9
    [12:02:14] [Server thread/INFO]: [KlarityCoins] Loading KlarityCoins v1.0
    [12:02:14] [Server thread/INFO]: [Essentials] Loading Essentials v2.13.1
    [12:02:14] [Server thread/INFO]: [EssentialsSpawn] Loading EssentialsSpawn v2.13.1
    [12:02:14] [Server thread/INFO]: [ProtocolLib] Enabling ProtocolLib v3.4.0
    [12:02:14] [Server thread/INFO]: [ProtocolLib] Started structure compiler thread.
    [12:02:14] [Server thread/INFO]: Preparing level "world"
    [12:02:14] [Server thread/INFO]: Preparing start region for level 0 (Seed: 7442025355649778218)
    [12:02:15] [Server thread/INFO]: Preparing spawn area: 41%
    [12:02:15] [Server thread/INFO]: Preparing start region for level 1 (Seed: 7442025355649778218)
    [12:02:16] [Server thread/INFO]: Preparing start region for level 2 (Seed: 7442025355649778218)
    [12:02:17] [Server thread/INFO]: [FreeForAll] Enabling FreeForAll v1.0
    [12:02:17] [Server thread/INFO]: [WorldEdit] Enabling WorldEdit v5.5.8
    [12:02:18] [Server thread/INFO]: WEPIF: Using the Bukkit Permissions API.
    [12:02:18] [Server thread/INFO]: [Multiverse-Core] Enabling Multiverse-Core v2.4-b527
    [12:02:18] [Server thread/INFO]: [Multiverse-Core] - Version 2.4-b527 (API v14) Enabled - By Rigby, fernferret, lithium3141 and main--
    [12:02:18] [Server thread/INFO]: [AllPay] - Version 10.0 - hooked into Essentials Economy for Multiverse-Core v2.4-b527
    [12:02:19] [Server thread/INFO]: [Multiverse-Core] Loading World & Settings - 'world' - Env: NORMAL - Type: NORMAL & seed: 7442025355649778218
    [12:02:19] [Server thread/INFO]: [Multiverse-Core] Loading World & Settings - 'world_nether' - Env: NETHER - Type: NORMAL & seed: 7442025355649778218
    [12:02:19] [Server thread/INFO]: [Multiverse-Core] Loading World & Settings - 'world_the_end' - Env: THE_END - Type: NORMAL & seed: 7442025355649778218
    [12:02:19] [Server thread/INFO]: [Multiverse-Core] Loading World & Settings - 'FreeForAll' - Env: NORMAL - Type: FLAT & seed: 1008628003248201996
    [12:02:19] [Server thread/INFO]: Preparing start region for level 3 (Seed: 1008628003248201996)
    [12:02:20] [Server thread/INFO]: [Multiverse-Core] Loading World & Settings - 'FFAWorld2' - Env: NORMAL - Type: FLAT & seed: -6215306014615410393
    [12:02:20] [Server thread/INFO]: Preparing start region for level 4 (Seed: -6215306014615410393)
    [12:02:21] [Server thread/INFO]: [Multiverse-Core] 5 - World(s) loaded.
    [12:02:21] [Server thread/INFO]: [iControlU] Enabling iControlU v1.7.0
    [12:02:21] [Server thread/INFO]: [LibsDisguises] Enabling LibsDisguises v8.2.6
    [12:02:21] [Server thread/INFO]: [GalaxyFFA] Enabling GalaxyFFA v1.0
    [12:02:21] [Server thread/INFO]: [BarAPI] Enabling BarAPI v3.1
    [12:02:21] [Server thread/INFO]: [BarAPI] Loaded
    [12:02:21] [Server thread/INFO]: [VoxelSniper] Enabling VoxelSniper v5.170.0-SNAPSHOT-jnks317-gitfcb8fe1
    [12:02:21] [Server thread/INFO]: [VoxelSniper] Registered 75 Sniper Brushes with 149 handles.
    [12:02:21] [Server thread/INFO]: [VoxelSniper] Registered Sniper Listener.
    [12:02:21] [Server thread/INFO]: [WorldGuard] Enabling WorldGuard v5.9
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world) TNT ignition is PERMITTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world) Lighters are PERMITTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world) Lava fire is blocked.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world) Fire spread is UNRESTRICTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'world'
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world_nether) TNT ignition is PERMITTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world_nether) Lighters are PERMITTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world_nether) Lava fire is blocked.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world_nether) Fire spread is UNRESTRICTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'world_nether'
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world_the_end) TNT ignition is PERMITTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world_the_end) Lighters are PERMITTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world_the_end) Lava fire is blocked.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (world_the_end) Fire spread is UNRESTRICTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'world_the_end'
    [12:02:21] [Server thread/INFO]: [WorldGuard] (FreeForAll) TNT ignition is PERMITTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (FreeForAll) Lighters are PERMITTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (FreeForAll) Lava fire is blocked.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (FreeForAll) Fire spread is UNRESTRICTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'FreeForAll'
    [12:02:21] [Server thread/INFO]: [WorldGuard] (FFAWorld2) TNT ignition is PERMITTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (FFAWorld2) Lighters are PERMITTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (FFAWorld2) Lava fire is blocked.
    [12:02:21] [Server thread/INFO]: [WorldGuard] (FFAWorld2) Fire spread is UNRESTRICTED.
    [12:02:21] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'FFAWorld2'
    [12:02:21] [Server thread/INFO]: [WorldGuard] 0 regions loaded for 'world'
    [12:02:21] [Server thread/INFO]: [WorldGuard] 0 regions loaded for 'world_nether'
    [12:02:21] [Server thread/INFO]: [WorldGuard] 0 regions loaded for 'world_the_end'
    [12:02:21] [Server thread/INFO]: [WorldGuard] 0 regions loaded for 'FreeForAll'
    [12:02:21] [Server thread/INFO]: [WorldGuard] 0 regions loaded for 'FFAWorld2'
    [12:02:21] [Server thread/INFO]: [KlarityCoins] Enabling KlarityCoins v1.0
    [12:02:21] [Server thread/INFO]: [Essentials] Enabling Essentials v2.13.1
    [12:02:22] [Server thread/INFO]: Essentials: Using config file enhanced permissions.
    [12:02:22] [Server thread/INFO]: Permissions listed in as player-commands will be given to all users.
    [12:02:22] [Server thread/INFO]: [EssentialsSpawn] Enabling EssentialsSpawn v2.13.1
    [12:02:22] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [12:02:22] [Server thread/INFO]: Done (8.101s)! For help, type "help" or "?"
    [12:02:23] [Server thread/INFO]: [0;34;1m[ProtocolLib] The updater did not find an update, and nothing was downloaded.[m
    [12:03:15] [User Authenticator #1/INFO]: UUID of player CytrixMC is 5d43cf77-3dd5-4b93-a923-c4fa45002b6b
    [12:03:15] [Server thread/INFO]: [0;37;22m?[0;35;1mFFA[0;37;22m? [0;33;22m| [0;36;22mCytrixMC[0;37;22m has joined [0;31;22mKlarity [0;36;1mFFA![m
    [12:03:15] [Server thread/INFO]: [21m[0;37;22m?[0;36;1mGalaxyPvP[0;37;22m? [21m[0;32;1mJOIN[0;37;22mCytrixMC[m
    [12:03:15] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to KlarityCoins v1.0
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:294) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.PlayerList.c(PlayerList.java:251) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.PlayerList.a(PlayerList.java:138) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.LoginListener.c(LoginListener.java:76) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.LoginListener.a(LoginListener.java:42) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:160) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    Caused by: java.lang.IllegalArgumentException: Scoreboard cannot be null
    at org.apache.commons.lang.Validate.notNull(Validate.java:203) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer.setScoreboard(CraftPlayer.java:1214) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at me.CytrixMC.KlarityCoins.Coins.onJoin(Coins.java:71) ~[?:?]
    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:292) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    ... 14 more
    [12:03:15] [Server thread/INFO]: CytrixMC[/24.185.37.239:57231] logged in with entity id 584 at ([FFAWorld2] 443.66986465790194, 5.0, 88.16573312402042)
    [12:10:27] [Server thread/INFO]: [EssentialsSpawn] Disabling EssentialsSpawn v2.13.1
    [12:10:27] [Server thread/INFO]: [Essentials] Disabling Essentials v2.13.1
    [12:10:27] [Server thread/INFO]: [KlarityCoins] Disabling KlarityCoins v1.0
    [12:10:27] [Server thread/INFO]: [WorldGuard] Disabling WorldGuard v5.9
    [12:10:27] [Server thread/INFO]: [VoxelSniper] Disabling VoxelSniper v5.170.0-SNAPSHOT-jnks317-gitfcb8fe1
    [12:10:27] [Server thread/INFO]: [BarAPI] Disabling BarAPI v3.1
    [12:10:27] [Server thread/INFO]: [GalaxyFFA] Disabling GalaxyFFA v1.0
    [12:10:27] [Server thread/INFO]: [LibsDisguises] Disabling LibsDisguises v8.2.6
    [12:10:27] [Server thread/INFO]: [iControlU] Disabling iControlU v1.7.0
    [12:10:27] [Server thread/INFO]: [Multiverse-Core] Disabling Multiverse-Core v2.4-b527
    [12:10:27] [Server thread/INFO]: [Multiverse-Core] - Disabled
    [12:10:27] [Server thread/INFO]: [ProtocolLib] Disabling ProtocolLib v3.4.0
    [12:10:28] [Server thread/INFO]: [WorldEdit] Disabling WorldEdit v5.5.8
    [12:10:28] [Server thread/INFO]: [FreeForAll] Disabling FreeForAll v1.0
    [12:10:28] [Server thread/INFO]: [FreeForAll] Loading FreeForAll v1.0
    [12:10:28] [Server thread/INFO]: [WorldEdit] Loading WorldEdit v5.5.8
    [12:10:28] [Server thread/INFO]: [ProtocolLib] Loading ProtocolLib v3.4.0
    [12:10:28] [Server thread/WARN]: [ProtocolLib] Version (MC: 1.7.9) has not yet been tested! Proceed with caution.
    [12:10:28] [Server thread/INFO]: [Multiverse-Core] Loading Multiverse-Core v2.4-b527
    [12:10:28] [Server thread/INFO]: [iControlU] Loading iControlU v1.7.0
    [12:10:28] [Server thread/INFO]: [LibsDisguises] Loading LibsDisguises v8.2.6
    [12:10:28] [Server thread/INFO]: [GalaxyFFA] Loading GalaxyFFA v1.0
    [12:10:28] [Server thread/INFO]: [BarAPI] Loading BarAPI v3.1
    [12:10:28] [Server thread/INFO]: [VoxelSniper] Loading VoxelSniper v5.170.0-SNAPSHOT-jnks317-gitfcb8fe1
    [12:10:28] [Server thread/INFO]: [WorldGuard] Loading WorldGuard v5.9
    [12:10:28] [Server thread/INFO]: [KlarityCoins] Loading KlarityCoins v1.0
    [12:10:28] [Server thread/INFO]: [Essentials] Loading Essentials v2.13.1
    [12:10:28] [Server thread/INFO]: [EssentialsSpawn] Loading EssentialsSpawn v2.13.1
    [12:10:28] [Server thread/INFO]: [ProtocolLib] Enabling ProtocolLib v3.4.0
    [12:10:28] [Server thread/INFO]: [ProtocolLib] Started structure compiler thread.
    [12:10:28] [Server thread/INFO]: [FreeForAll] Enabling FreeForAll v1.0
    [12:10:28] [Server thread/INFO]: [WorldEdit] Enabling WorldEdit v5.5.8
    [12:10:28] [Server thread/INFO]: WEPIF: Using the Bukkit Permissions API.
    [12:10:28] [Server thread/INFO]: [Multiverse-Core] Enabling Multiverse-Core v2.4-b527
    [12:10:28] [Server thread/INFO]: [Multiverse-Core] - Version 2.4-b527 (API v14) Enabled - By Rigby, fernferret, lithium3141 and main--
    [12:10:28] [Server thread/INFO]: [AllPay] - Version 10.0 - hooked into Essentials Economy for Multiverse-Core v2.4-b527
    [12:10:29] [Server thread/INFO]: [Multiverse-Core] Loading World & Settings - 'world' - Env: NORMAL - Type: NORMAL & seed: 7442025355649778218
    [12:10:29] [Server thread/INFO]: [Multiverse-Core] Loading World & Settings - 'world_nether' - Env: NETHER - Type: NORMAL & seed: 7442025355649778218
    [12:10:30] [Server thread/INFO]: [Multiverse-Core] Loading World & Settings - 'world_the_end' - Env: THE_END - Type: NORMAL & seed: 7442025355649778218
    [12:10:30] [Server thread/INFO]: [Multiverse-Core] Loading World & Settings - 'FreeForAll' - Env: NORMAL - Type: FLAT & seed: 1008628003248201996
    [12:10:30] [Server thread/INFO]: [Multiverse-Core] Loading World & Settings - 'FFAWorld2' - Env: NORMAL - Type: FLAT & seed: -6215306014615410393
    [12:10:30] [Server thread/INFO]: [Multiverse-Core] 5 - World(s) loaded.
    [12:10:30] [Server thread/INFO]: [iControlU] Enabling iControlU v1.7.0
    [12:10:30] [Server thread/INFO]: [LibsDisguises] Enabling LibsDisguises v8.2.6
    [12:10:30] [Server thread/INFO]: [GalaxyFFA] Enabling GalaxyFFA v1.0
    [12:10:30] [Server thread/INFO]: [BarAPI] Enabling BarAPI v3.1
    [12:10:30] [Server thread/INFO]: [BarAPI] Loaded
    [12:10:30] [Server thread/INFO]: [VoxelSniper] Enabling VoxelSniper v5.170.0-SNAPSHOT-jnks317-gitfcb8fe1
    [12:10:30] [Server thread/INFO]: [VoxelSniper] Registered 75 Sniper Brushes with 149 handles.
    [12:10:30] [Server thread/INFO]: [VoxelSniper] Registered Sniper Listener.
    [12:10:31] [Server thread/INFO]: [WorldGuard] Enabling WorldGuard v5.9
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world) TNT ignition is PERMITTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world) Lighters are PERMITTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world) Lava fire is blocked.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world) Fire spread is UNRESTRICTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'world'
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world_nether) TNT ignition is PERMITTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world_nether) Lighters are PERMITTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world_nether) Lava fire is blocked.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world_nether) Fire spread is UNRESTRICTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'world_nether'
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world_the_end) TNT ignition is PERMITTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world_the_end) Lighters are PERMITTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world_the_end) Lava fire is blocked.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (world_the_end) Fire spread is UNRESTRICTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'world_the_end'
    [12:10:31] [Server thread/INFO]: [WorldGuard] (FreeForAll) TNT ignition is PERMITTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (FreeForAll) Lighters are PERMITTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (FreeForAll) Lava fire is blocked.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (FreeForAll) Fire spread is UNRESTRICTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'FreeForAll'
    [12:10:31] [Server thread/INFO]: [WorldGuard] (FFAWorld2) TNT ignition is PERMITTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (FFAWorld2) Lighters are PERMITTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (FFAWorld2) Lava fire is blocked.
    [12:10:31] [Server thread/INFO]: [WorldGuard] (FFAWorld2) Fire spread is UNRESTRICTED.
    [12:10:31] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'FFAWorld2'
    [12:10:31] [Server thread/INFO]: [WorldGuard] 0 regions loaded for 'world'
    [12:10:31] [Server thread/INFO]: [WorldGuard] 0 regions loaded for 'world_nether'
    [12:10:31] [Server thread/INFO]: [WorldGuard] 0 regions loaded for 'world_the_end'
    [12:10:31] [Server thread/INFO]: [WorldGuard] 0 regions loaded for 'FreeForAll'
    [12:10:31] [Server thread/INFO]: [WorldGuard] 0 regions loaded for 'FFAWorld2'
    [12:10:31] [Server thread/INFO]: [KlarityCoins] Enabling KlarityCoins v1.0
    [12:10:31] [Server thread/INFO]: [Essentials] Enabling Essentials v2.13.1
    [12:10:31] [Server thread/INFO]: Essentials: Using config file enhanced permissions.
    [12:10:31] [Server thread/INFO]: Permissions listed in as player-commands will be given to all users.
    [12:10:31] [Server thread/INFO]: [EssentialsSpawn] Enabling EssentialsSpawn v2.13.1
    [12:10:31] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [12:10:31] [Server thread/INFO]: CONSOLE: [0;32;1mReload complete.[m
    [12:10:31] [Server thread/WARN]: Can't keep up! Did the system time change, or is the server overloaded? Running 4134ms behind, skipping 82 tick(s)
    [12:10:33] [Server thread/INFO]: CytrixMC lost connection: Disconnected
    [12:10:33] [Server thread/INFO]: [0;37;22m?[0;35;1mFFA[0;37;22m? [0;33;22m| [0;37;22mCytrixMC[0;35;1m has left [21m[0;31;22mKlarity [0;36;1mFFA![m
    [12:10:33] [Server thread/INFO]: [21m[0;37;22m?[0;36;1mGalaxyPvP[0;37;22m? [21m[0;31;1mLEAVE[0;37;22mCytrixMC[m
    [12:10:33] [Server thread/INFO]: CytrixMC left the game.
    [12:10:35] [User Authenticator #2/INFO]: UUID of player CytrixMC is 5d43cf77-3dd5-4b93-a923-c4fa45002b6b
    [12:10:35] [Server thread/INFO]: [0;37;22m?[0;35;1mFFA[0;37;22m? [0;33;22m| [0;36;22mCytrixMC[0;37;22m has joined [0;31;22mKlarity [0;36;1mFFA![m
    [12:10:35] [Server thread/INFO]: [21m[0;37;22m?[0;36;1mGalaxyPvP[0;37;22m? [21m[0;32;1mJOIN[0;37;22mCytrixMC[m
    [12:10:35] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to KlarityCoins v1.0
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:294) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.PlayerList.c(PlayerList.java:251) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.PlayerList.a(PlayerList.java:138) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.LoginListener.c(LoginListener.java:76) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.LoginListener.a(LoginListener.java:42) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:160) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    Caused by: java.lang.IllegalArgumentException: Scoreboard cannot be null
    at org.apache.commons.lang.Validate.notNull(Validate.java:203) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer.setScoreboard(CraftPlayer.java:1214) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    at me.CytrixMC.KlarityCoins.Coins.onJoin(Coins.java:71) ~[?:?]
    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:292) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    ... 14 more
    [12:10:35] [Server thread/INFO]: CytrixMC[/24.185.37.239:57771] logged in with entity id 1027 at ([FFAWorld2] 437.25731367079277, 6.65658248110962, 98.90889745593749)
    
    and here is my code again.

    Code:
    package me.CytrixMC.KlarityCoins;
     
     
    import java.util.HashMap;
    import java.util.UUID;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;
     
     
    public class Coins extends JavaPlugin implements Listener {
     
    Scoreboard board;
     
    HashMap<UUID, Scoreboard> uuidboard = new HashMap<UUID, Scoreboard>();
     
    public void onEnable(){
    this.getCommand("coins").setExecutor(new CoinsCommand(this));
    getServer().getPluginManager().registerEvents(this, this);
    }
     
     
    @SuppressWarnings("deprecation")
    public void showScoreboard(Player player) {
     
    UUID p = player.getUniqueId();
     
    ScoreboardManager manager = Bukkit.getScoreboardManager();
    Scoreboard board = manager.getNewScoreboard();
     
     
    int a = Bukkit.getOnlinePlayers().length;
    String b = getConfig().getString(Bukkit.getPlayer(p).getName(), ".Coins");
     
    Objective objective = board.registerNewObjective("test", "stats");
    objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    objective.setDisplayName(ChatColor.RED + "Klarity " + ChatColor.GOLD + "FFA");
     
    //Online Score
    Score score1 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.GREEN + "Online:"));
    Score score1int = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" + a));
    score1.setScore(4);
    score1int.setScore(3);
     
    //Coins Score
    Score score2 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.GOLD + "Coins"));
    Score score2int = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" + b));
    score2.setScore(2);
    score2int.setScore(1);
     
    }
     
     
     
    @EventHandler
    public void onJoin(PlayerJoinEvent e){
    Player p = e.getPlayer();
    if(p instanceof Player){
    //Scoreboard Set
    e.getPlayer().setScoreboard(board);
     
    //Coins Config Data
    if(!getConfig().contains(p.getName())){
    getConfig().set(p.getUniqueId() + ".Coins", 0);
    }
     
    }
    }
     
     
    @EventHandler
    public void onKill(PlayerDeathEvent e){
    if(e.getEntity() instanceof Player){
    Player p = (Player) e.getEntity();
    if(e.getEntity().getKiller() instanceof Player){
    Player k = p.getKiller();
    addCoins(k, 1);
    }
    }
     
    if(e.getEntity() instanceof Player){
    Player p = (Player) e.getEntity();
    if(e.getEntity().getKiller() instanceof Player){
    removeCoins(p, 1);
    }
    }
    }
     
    public void addCoins(Player p, int i){
    getConfig().set(p.getUniqueId() + ".Coins", getConfig().getInt(p.getUniqueId() + ".Coins", 0) + i);
    saveConfig();
    }
     
    public void removeCoins(Player p, int i){
    if(getConfig().getInt(p.getUniqueId() + ".Coins") == 0){
    return;
    } else {
    getConfig().set(p.getUniqueId() + ".Coins", getConfig().getInt(p.getUniqueId() + ".Coins", 0) - i);
    saveConfig();
    }
    }
     
    public void onDisable(){
     
    }
     
     
    }
    
    TheHandfish

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  16. Offline

    TheHandfish

    I'm helping a bunch of people at once. I can't answer your question instantly.

    Where is line 71 in your onJoin method's class?
     
  17. Offline

    CytrixMC

    That line is when i set the scoreboard to the player.

    Take your time. I don't need instant help :)

    Can you help?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  18. Offline

    Bram0101

    The Scoreboard variable called board is equal to null, you need to initialize it.
     
  19. Offline

    CytrixMC

    In the onEnable?
     
Thread Status:
Not open for further replies.

Share This Page