hi there im trying to develop a bukkit plugin for myself but when i try something like this Code: package me.jacklin213.basic; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; public class BasicBlockListener implements Listener { public static Basic plugin; public BasicBlockListener(Basic instance) { plugin = instance; } @EventHandler public void onBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); Block block = event.getBlockPlaced(); if (block.getType() == Material.TORCH) { player.sendMessage("You have placed a torch!"); if (block.getType() == Material.DIRT) { player.sendMessage("You have placed dirt!"); if (block.getType() == Material.LAVA) { player.sendMessage("BEWARE no grefing with the lava!"); } } } } } it only says something when i place dirt but if i put torch to the top like this Code: package me.jacklin213.basic; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; public class BasicBlockListener implements Listener { public static Basic plugin; public BasicBlockListener(Basic instance) { plugin = instance; } @EventHandler public void onBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); Block block = event.getBlockPlaced(); if (block.getType() == Material.DIRT) { player.sendMessage("You have placed dirt!"); if (block.getType() == Material.TORCH) { player.sendMessage("You have placed a torch!"); if (block.getType() == Material.LAVA) { player.sendMessage("BEWARE no grefing with the lava!"); } } } } } it only sends a message when i place torch. PLZ help me
Code: if (block.getType() == Material.DIRT) { player.sendMessage("You have placed dirt!"); if (block.getType() == Material.TORCH) { player.sendMessage("You have placed a torch!"); if (block.getType() == Material.LAVA) { player.sendMessage("BEWARE no grefing with the lava!"); } } } That's your code, properly indented. This isn't Python.The { brace signifies that the following code is inside the if statement, and } signifies that the code is no longer in the if statement. Code: if (block.getType() == Material.DIRT) { player.sendMessage("You have placed dirt!"); } if (block.getType() == Material.TORCH) { player.sendMessage("You have placed a torch!"); } if (block.getType() == Material.LAVA) { player.sendMessage("BEWARE no grefing with the lava!"); } Is probably what you meant.
@jacklin213 Also, the event won't detect Lava placement because players are using a bukkit to place the lava. That should be handled in a BucketEmptyEvent instead.
kk ty @zhuowei it works ty @r0306 how would i do that? another question is when i active it by doing /b it would say Basic enabled (plugin name) b y does it say b under it ??
The /b displays because the plugin returned false after processing the command, which means "The command didn't work, show the help file". Code: public void onCommand(...stuff if (label.equals("b")){ //do stuff return true; //Successfully executed } return false; //unsuccessfully executed; show the player the help. }
Code: public void onEmpty(PlayerBucketEmptyEvent event) { Player player = event.getPlayer(); if (event.getBucket() = Material.LAVA_BUCKET) { player.sendMessage("BEWARE no grefing with the lava!"); } }
Code: public void onEmpty(PlayerBucketEmptyEvent event) { Player player = event.getPlayer(); if ("event.getBucket"() = Material.LAVA_BUCKET) { player.sendMessage("BEWARE no grefing with the lava!"); } } i put in quote marks
@jacklin213 Oh. I used the wrong operator. Use "==" instead of "=". Code: if (event.getBucket() == Material.LAVA_BUCKET) {