Hello i have the problem that i try to get a block its a dispenser and his location is saved in the config but at the first time i run the command everything work and the second it says there is no dispenser and the location is different
infos to my project:
i will make a auto farmer that farm automatily wheat carrots etc. and i set the location from the dispenser in the config and load it from there and when the dispenser look in west i change the block like + 1 in x or like something
(and sorry for my bad english)
Code from the reload class:
#Config get differnt value in a while loop
1 messages · Page 1 of 1 (latest)
i cant upload files i send it in 2 messages
public static void updatefarmersfromconfig() {
int i = config.getInt("Farmer.farmers");
while(i >= 0) {
Location l2 = config.getLocation("Farmer."+i);
Main.getPlugin().reloadConfig();
if(config.getLocation("Farmer."+i).getBlock().getType().toString().equalsIgnoreCase("dispenser")) {
MaterialData data = config.getLocation("Farmer."+i).getBlock().getState().getData();
InventoryHolder dispenserinv = (InventoryHolder) config.getLocation("Farmer."+i).getBlock().getState();
if((dispenserinv.getInventory().isEmpty())) {
String facing = ((Dispenser) data).getFacing().toString();
if(facing.equalsIgnoreCase("north")) l2.setZ((config.getLocation("Farmer."+i).getZ() - 1));
if(facing.equalsIgnoreCase("west")) l2.setX((config.getLocation("Farmer."+i).getX() - 1));
if(facing.equalsIgnoreCase("south")) l2.setZ((config.getLocation("Farmer."+i).getZ() + 1));
if(facing.equalsIgnoreCase("east")) l2.setX((config.getLocation("Farmer."+i).getX() + 1));
if(l2.getBlock().getState().getBlockData().toString().equalsIgnoreCase("CraftBlockData{minecraft:wheat[age=7]}")) {
l2.getBlock().setType(Material.WHEAT);
ItemStack loot = new ItemStack(Material.WHEAT);
dispenserinv.getInventory().addItem(loot);
}
if(facing.equalsIgnoreCase("north")) l2.setZ((config.getLocation("Farmer."+i).getZ()));
if(facing.equalsIgnoreCase("west")) l2.setX((config.getLocation("Farmer."+i).getX()));
if(facing.equalsIgnoreCase("south")) l2.setZ((config.getLocation("Farmer."+i).getZ()));
if(facing.equalsIgnoreCase("east")) l2.setX((config.getLocation("Farmer."+i).getX()));
}else {
System.out.println("No Space");
}
}else {
System.out.println("No Dispenser || "+l2.getBlock().toString());
}
i--;
}
}
i forgot one thing when i reload the server it works one use