How do I get a players name for my scoreboard?

Discussion in 'Plugin Development' started by Anaklusmos857, Apr 27, 2021.

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

    Anaklusmos857

    Hi! If anyone could respond to me? I'm trying to make a scoreboard for my plugin and I want to get a players name on it. Can someone please help me? I'm kinda new to this so this will help a lot!

    Heres my code:

    Code:
    import org.bukkit.Bukkit;import org.bukkit.command.CommandExecutor;import org.bukkit.command.CommandSender;import org.bukkit.plugin.java.JavaPlugin;import org.bukkit.scoreboard.Objective;import org.bukkit.scoreboard.Scoreboard;import org.bukkit.scoreboard.ScoreboardManager;import org.bukkit.entity.Player;public final class Main extends JavaPlugin {
    
    @Overridepublic void onEnable() {
    // Plugin startup logicScoreboardManager manager = Bukkit.getScoreboardManager();Scoreboard board = manager.getNewScoreboard();Player playerName = Player.getName();Objective objective = board.registerNewObjective();}
    
    @Overridepublic void onDisable() {
    // Plugin shutdown logic}
    }
     
    Last edited by a moderator: Apr 28, 2021
  2. Offline

    man_in_matrix

    So what I see right now is that the plugin startup logic along with your scoreboard score is in the same commented line denoted with //. Not quite sure if your code is like that or if it's the website's formatting.
     
  3. Offline

    Newdel

    Player class does not have a static getName method. You have to call it on a player object...Obviously. If it's not obvious to you, stop making plugins, start learning java, then come back
     
    Xp10d3 likes this.
  4. Offline

    Anaklusmos857

    prob the websites formatting
     
Thread Status:
Not open for further replies.

Share This Page