Hello, kind users of MC-Market! I am here today requesting help on a current situation I am in.
I am trying to make it, so when you throw the "bomb" (defined in the below code), after 3 seconds, it makes an explosion at the location of the bomb, then sends the "Your bomb exploded" message. But the explosion and the message doesn't seem to work!
[/SPOILER]
Main.Java:
Please could somebody help me with this issue, thank you kind friends,
I am trying to make it, so when you throw the "bomb" (defined in the below code), after 3 seconds, it makes an explosion at the location of the bomb, then sends the "Your bomb exploded" message. But the explosion and the message doesn't seem to work!
Code:
package me.hawauh.prisonbombs;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class ActualBombs implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (e.getAction() == Action.RIGHT_CLICK_AIR) {
if (e.getMaterial() == GetBombMethods.getBomb1Item().getType()) {
p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
final Item grenade = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.FIREBALL));
grenade.setVelocity(p.getLocation().getDirection().multiply(1.9D));
p.sendMessage("§bYou have thrown a §7Regular Bomb");
Bukkit.getScheduler().scheduleSyncDelayedTask(new Main(), new Runnable() {
public void run() {
grenade.getWorld().createExplosion(grenade.getLocation().getX(), grenade.getLocation().getY(),
grenade.getLocation().getZ(), 3, false, false);
p.sendMessage("§b§lBang! Your bomb exploded!");
}
}, 20*3);
}
if (e.getMaterial() == GetBombMethods.getBomb2Item().getType()) {
p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
final Item grenade = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.MAGMA_CREAM));
grenade.setVelocity(p.getLocation().getDirection().multiply(1.9D));
p.sendMessage("§bYou have thrown a §7Bunker Buster Bomb");
Bukkit.getScheduler().scheduleSyncDelayedTask(new Main(), new Runnable() {
public void run() {
grenade.getWorld().createExplosion(grenade.getLocation(), 2);
grenade.getWorld().createExplosion(grenade.getLocation().getX(), grenade.getLocation().getY(),
grenade.getLocation().getZ(), 3, false, false);
p.sendMessage("§b§lBang! Your bomb exploded!");
}
}, 20*3);
}
}
}
}
Main.Java:
Code:
package me.hawauh.prisonbombs;
import org.bukkit.plugin.java.JavaPlugin;
import me.hawauh.commands.MainCmd;
import me.hawauh.listener.Events;
public class Main extends JavaPlugin {
public static String version = "0.1";
public void onEnable() {
saveDefaultConfig();
System.out.printf("[PrisonBombs] Enabled version " + version);
getServer().getPluginManager().registerEvents(new Events(), this);
getServer().getPluginManager().registerEvents(new GUI(), this);
getServer().getPluginManager().registerEvents(new ActualBombs(), this);
getCommand("prisonbombs").setExecutor(new MainCmd());
}
public void onDisable() {
saveDefaultConfig();
}
}
Please could somebody help me with this issue, thank you kind friends,

