Digital and Interactive Games 2015 - Term 3, Session 10

Aug 15, 2015 13:54


Digital and Interactive Games 2015, Term 3, Session 10
Today: - Framework for a full game
(continue...)
- Scoreboard object

config.yml
playerSpawnPoint
world: world
x: 100
y: 100
z: 100
mobSpawnPoint
world: world
x: 100
y: 100
z: 100
SpectatorPoint
world:
x:
y:
z:

New Plugin
ScoreboardExample
Team team

- - - - - - - - - -

Objective

public void createScoreBoard() {
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();

Objective objective = board.registerNewObjective("Test", "test 2");
objective.setDisplayName(ChatColor.AQUA + "Statistics");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);

Team team = board.registerNewTeam("Team");
team.setPrefix(ChatColor.RED + "[Text]");

Score score = objective.getScore(ChatColor.GOLD + "Online Players");
score.setScore(Bukkit.getOnlinePlayers().size());

Score score2 = objective.getScore(ChatColor.GOLD + "Max Players");
score2.setScore(Bukkit.getMaxPlayers());

Score score3 = objective.getScore(ChatColor.GOLD + "View Distance");
score3.setScore(Bukkit.getViewDistance());
}

PlayerJoinListener

scoreboard Example plugin

PlayerJoinListener (ScoreboardExample p) {
plugin = p;
}

@EventHandler (ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerJoinEvent (PlayerJoinEvent e) {
player p = e.getPlayers();
plugin.team.addPlayers(p);
plugin.updateScoreboard();
p.setScoreboard(plugin.board);
}

objective

Score →

Restore

clear

Objective
Statistics
Score → activePlayers ← score.setScore

yml, minecraft, game programming, minecraft plugins, programming, game design, java

Previous post Next post
Up