非静态方法参考错误

时间:2015-06-22 23:26:01

标签: java jdbc

好的,我的邮件课即可致电

public class Main extends JavaPlugin {
    @Override
    public void onEnable () {
    getLogger().info("Loading configs...");
        Hud.startHud();
    }
    @Override
    public void onDisable () {

    }
}

它给了我 非静态方法不能从静态上下文引用

public class Hud extends JavaPlugin {
    public void startHud () {
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard board = manager.getNewScoreboard();
        Team team = board.registerNewTeam("teamname");
        Objective objective = board.registerNewObjective("test", "dummy");
        Score score = objective.getScore(ChatColor.GREEN + "Kills:"); //Get a fake offline player
        score.setScore(1);
    }
}

1 个答案:

答案 0 :(得分:0)

使startHud()成为静态方法。否则称之为new Hud().startHud();