У меня есть список
private List<ChestPoint> chestpoints = new ArrayList<>();
и ChestPoint.java
int x;
int y;
int z;
String findhardness;
String arena;
и хотите установить сундуки и наполнить их
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");
}
}
Это не работает! Я хочу построить сундуки на всех в контрольных точках списка, установил контрольные точки и наполнит сундуки сундуками! Но в моем файле журнала ошибка не регистрируется! Может ли кто-нибудь найти мою ошибку?
Вам нужно будет вызвать методы BlockState.update(), чтобы применить BlockState к фактическому блоку.