Question

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?

Était-ce utile?

La solution

You will have to call the BlockState.update() methods to apply the BlockState back to the actual Block.

http://jd.bukkit.org/beta/doxygen/d9/d1c/interfaceorg_1_1bukkit_1_1block_1_1BlockState.html#a0734c83720823a6eb2247aaf4b60ec0e

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top