Spigot plugin help needed | Minecraft Server | Spigot 1.8?

ki
- in Worlds
5

I was just trying to make an animation where blocks appear and disappear. But somehow it doesn't work, maybe you have tips or the solution? No errors are shown in the console.

new BukkitRunnable () {
int timer;
@Override
public void run () {
timer--;
switch (timer) {

case 20:
Bukkit.broadcastMessage ( "start");
Bukkit.getWorld ("Lobby"). GetBlockAt (1149, 95, -512) .setType (Material.WOOL);
break;

case 19:
Bukkit.getWorld ("Lobby"). GetBlockAt (1149, 94, -513) .setType (Material.WOOD);
break;

case 18:
Bukkit.getWorld ("Lobby"). GetBlockAt (1148, 93, -513) .setType (Material.DIAMOND_BLOCK);
break;

case 17:
Bukkit.getWorld ("Lobby"). GetBlockAt (1148, 92, -511) .setType (Material.GOLD_BLOCK);
break;

case 16:
Bukkit.getWorld ("Lobby"). GetBlockAt (1149, 91, -512) .setType (Material.IRON_BLOCK);
break;

case 15:
Bukkit.getWorld ("Lobby"). GetBlockAt (1149, 90, -512) .setType (Material.REDSTONE_BLOCK);
break;

case 14:
Bukkit.getWorld ("Lobby"). GetBlockAt (1149, 95, -512) .setType (Material.AIR);
break;

case 13:
Bukkit.getWorld ("Lobby"). GetBlockAt (1149, 94, -513) .setType (Material.AIR);
break;

case 12:
Bukkit.getWorld ("Lobby"). GetBlockAt (1148, 93, -513) .setType (Material.AIR);
break;

case 11:
Bukkit.getWorld ("Lobby"). GetBlockAt (1148, 92, -511) .setType (Material.AIR);
break;

case 10:
Bukkit.getWorld ("Lobby"). GetBlockAt (1149, 91, -512) .setType (Material.AIR);
break;

case 9:
Bukkit.getWorld ("Lobby"). GetBlockAt (1149, 90, -512) .setType (Material.AIR);
timer ++;
}
}

} .runTaskTimer (Main.getPlugin (Main.class), 0, 20);

Ap

I haven't done anything with Java for a long time, but can it be that your variable has not been assigned a value? As a result, the "cases" would never occur.

ki

First of all thanks for your answer. Usually it has timer--; always worked because it is then set to the "starting point".

Ap

In itself timer-- works; also. The point CelebornMagic wants to point out is that you only wrote int timer; this means that the variable timer has no value, which in Java, as far as I know, is then counted as 0 for integers.

You just have to change it to int timer = 20; (or whatever number you want).

Ap

Exactly, that's what I mean.

ki

Thanks to all @ JanMarcel01 and @CelebornMagic now it works.