use of org.bukkit.metadata.FixedMetadataValue in project Minigames by AddstarMC.
the class ScoreboardDisplay method load.
@SuppressWarnings("deprecation")
public static ScoreboardDisplay load(Minigame minigame, ConfigurationSection section) {
int width = section.getInt("width");
int height = section.getInt("height");
Location location = MinigameUtils.loadShortLocation(section.getConfigurationSection("location"));
BlockFace facing = BlockFace.valueOf(section.getString("dir"));
// from invalid world
if (location == null) {
return null;
}
ScoreboardDisplay display = new ScoreboardDisplay(minigame, width, height, location, facing);
display.setOrder(ScoreboardOrder.valueOf(section.getString("order")));
// Convert type to new stat
if (section.contains("type")) {
ScoreboardType type = ScoreboardType.valueOf(section.getString("type"));
switch(type) {
case BEST_KILLS:
display.setStat(MinigameStats.Kills, StatValueField.Max);
break;
case BEST_SCORE:
display.setStat(MinigameStats.Score, StatValueField.Max);
break;
case COMPLETIONS:
display.setStat(MinigameStats.Wins, StatValueField.Total);
break;
case FAILURES:
display.setStat(MinigameStats.Losses, StatValueField.Total);
break;
case LEAST_DEATHS:
display.setStat(MinigameStats.Deaths, StatValueField.Min);
break;
case LEAST_REVERTS:
display.setStat(MinigameStats.Reverts, StatValueField.Min);
break;
case LEAST_TIME:
display.setStat(MinigameStats.CompletionTime, StatValueField.Min);
break;
case TOTAL_DEATHS:
display.setStat(MinigameStats.Deaths, StatValueField.Total);
break;
case TOTAL_KILLS:
display.setStat(MinigameStats.Kills, StatValueField.Total);
break;
case TOTAL_REVERTS:
display.setStat(MinigameStats.Reverts, StatValueField.Total);
break;
case TOTAL_SCORE:
display.setStat(MinigameStats.Score, StatValueField.Total);
break;
case TOTAL_TIME:
display.setStat(MinigameStats.CompletionTime, StatValueField.Total);
break;
default:
break;
}
section.set("type", null);
// Load stat
} else {
MinigameStat stat = MinigameStats.getStat(section.getString("stat", "wins"));
StatValueField field = StatValueField.valueOf(section.getString("field", "Total"));
display.setStat(stat, field);
}
Block block = location.getBlock();
block.setMetadata("MGScoreboardSign", new FixedMetadataValue(Minigames.plugin, true));
block.setMetadata("Minigame", new FixedMetadataValue(Minigames.plugin, minigame));
return display;
}
use of org.bukkit.metadata.FixedMetadataValue in project Minigames by AddstarMC.
the class SpawnEntityAction method executeNodeAction.
@Override
public void executeNodeAction(MinigamePlayer player, Node node) {
if (player == null || !player.isInMinigame())
return;
final Entity ent = node.getLocation().getWorld().spawnEntity(node.getLocation(), EntityType.valueOf(type.getFlag()));
final double vx = Double.valueOf(settings.get("velocityx"));
final double vy = Double.valueOf(settings.get("velocityy"));
final double vz = Double.valueOf(settings.get("velocityz"));
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getPlugin(), new Runnable() {
@Override
public void run() {
ent.setVelocity(new Vector(vx, vy, vz));
}
});
if (ent instanceof LivingEntity) {
LivingEntity lent = (LivingEntity) ent;
if (settings.containsKey("displayname")) {
lent.setCustomName(settings.get("displayname"));
lent.setCustomNameVisible(Boolean.getBoolean(settings.get("displaynamevisible")));
}
}
ent.setMetadata("MinigameEntity", new FixedMetadataValue(Minigames.plugin, true));
player.getMinigame().getBlockRecorder().addEntity(ent, player, true);
}
Aggregations