我有一个列表
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 应用回实际的 block 。
关于java - bukkit 插件《我的世界》箱子用列表中的 int 填充并从类构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22382341/