use of au.com.mineauz.minigames.minigame.ScoreboardDisplay in project Minigames by AddstarMC.
the class ScoreboardSign method signCreate.
@Override
public boolean signCreate(SignChangeEvent event) {
Sign sign = (Sign) event.getBlock().getState();
if (sign.getType() != Material.WALL_SIGN) {
event.getPlayer().sendMessage(ChatColor.RED + "Scoreboards must be placed on a wall!");
return false;
}
// Parse minigame
Minigame minigame;
if (plugin.mdata.hasMinigame(event.getLine(2))) {
minigame = plugin.mdata.getMinigame(event.getLine(2));
} else {
event.getPlayer().sendMessage(ChatColor.RED + "No Minigame found by the name " + event.getLine(2));
return false;
}
// Parse size
int width;
int height;
if (event.getLine(3).isEmpty()) {
width = ScoreboardDisplay.defaultWidth;
height = ScoreboardDisplay.defaultHeight;
} else if (event.getLine(3).matches("[0-9]+x[0-9]+")) {
String[] parts = event.getLine(3).split("x");
width = Integer.parseInt(parts[0]);
height = Integer.parseInt(parts[1]);
} else {
event.getPlayer().sendMessage(ChatColor.RED + "Invalid size. Requires nothing or (width)x(height) eg. 3x3");
return false;
}
// So we dont have to deal with even size scoreboards
if (width % 2 == 0) {
event.getPlayer().sendMessage(ChatColor.RED + "Length must not be an even number!");
return false;
}
BlockFace facing = ((Directional) sign.getData()).getFacing();
// Add our display
ScoreboardDisplay display = new ScoreboardDisplay(minigame, width, height, event.getBlock().getLocation(), facing);
display.placeSigns();
minigame.getScoreboardData().addDisplay(display);
// Reformat this sign for the next part
event.setLine(1, ChatColor.GREEN + "Scoreboard");
event.setLine(2, minigame.getName(false));
event.getBlock().setMetadata("Minigame", new FixedMetadataValue(plugin, minigame));
return true;
}
use of au.com.mineauz.minigames.minigame.ScoreboardDisplay in project Minigames by AddstarMC.
the class ScoreboardSign method signUse.
@Override
public boolean signUse(Sign sign, MinigamePlayer player) {
Minigame minigame = plugin.mdata.getMinigame(sign.getLine(2));
if (minigame == null) {
return false;
}
ScoreboardDisplay display = minigame.getScoreboardData().getDisplay(sign.getBlock());
if (display == null) {
return false;
}
display.displayMenu(player);
return false;
}
Aggregations