Skip to content

Instantly share code, notes, and snippets.

@WouterG
Created February 8, 2020 17:13
Show Gist options
  • Save WouterG/17b7879a64ec755545a8a0acca8b58a3 to your computer and use it in GitHub Desktop.
Save WouterG/17b7879a64ec755545a8a0acca8b58a3 to your computer and use it in GitHub Desktop.
import net.menoni.rd.RuntimeDebugger;
import net.menoni.rd.model.Debugger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
public class examplelistener implements Debugger, Debugger.Stoppable, Listener {
public void debug(RuntimeDebugger plugin, CommandSender cs) {
Bukkit.getPluginManager().registerEvents(this, plugin);
cs.sendMessage(ChatColor.YELLOW + "Right-click blocks to start making gold!");
}
@EventHandler
public void makeGold(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
Block b = event.getClickedBlock();
b.setType(Material.GOLD_BLOCK);
}
public void stop() {
// HandlerList.unregisterAll(this);
/* you normally do this to remove the listener, otherwise it keeps going after stop,
but the runtimedebugger does this for us */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment