You will have to call the BlockState.update() methods to apply the BlockState back to the actual Block.
bukkit plugin minecraft chests fill and build from class with int in list
Pergunta
I have a List
private List<ChestPoint> chestpoints = new ArrayList<>();
and ChestPoint.java
int x;
int y;
int z;
String findhardness;
String arena;
and want to set chests and fill them with
if(cmd.getName().equalsIgnoreCase("buildfillchests")) {
ItemStack itemsforchest = new ItemStack(Material.CHEST, 1728);
if(args.length == 1){
for(ChestPoint cp : chestpoints){
Location chestloc = null;
if(cp.arena == null ? args[0] == null : cp.arena.equals(args[0])){
chestloc.setX(cp.x);
chestloc.setY(cp.y);
chestloc.setZ(cp.z);
if(chestloc.getBlock().getType() == Material.AIR){
chestloc.getBlock().setType(Material.CHEST);
Inventory chestinv = ((Chest) chestloc.getBlock().getState()).getInventory();
chestinv.addItem(itemsforchest);
}
}
}
} else {
if(args.length == 3 && "by".equals(args[0]) && "all".equals(args[1]) && "chests".equals(args[2])){
for(ChestPoint cp : chestpoints){
Location chestloc = null;
chestloc.setX(cp.x);
chestloc.setY(cp.y);
chestloc.setZ(cp.z);
if(chestloc.getBlock().getType() == Material.AIR){
chestloc.getBlock().setType(Material.CHEST);
Inventory chestinv = ((Chest) chestloc.getBlock().getState()).getInventory();
chestinv.addItem(itemsforchest);
}
}
} else {
sender.sendMessage(ChatColor.RED + "Es funktioniert nur /buildfillchests <arena> oder /buildfillchests by all chests");
}
}
That does not work! I want to build chests on all in the List chestpoints setted chestpoints and fill the chests with chests! But in my log file is no error logged! Can anybody find my mistace?
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow