Hey,
I was just watching the Java tutorials on how to make a TNT Notifier for Bukkit (the permissions section)
and when i tested it, the plugin ran fine if I was an op - placing TNT as normal but as soon as I deop-ed myself when I tried to place the TNT it just disappeared altogether so i tried again in a different place where it placed stone...
Has anyone else had this (weird) problem?
Here is the code for the TNTNotifierBlockListener.java
package com.technotizer;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
public class TNTNotifierBlockListener extends BlockListener {
private TNTNotifier plugin;
public TNTNotifierBlockListener(TNTNotifier instance) {
this.plugin = instance;
}
public void onBlockPlace(BlockPlaceEvent event) {
if(event.isCancelled()) return;
Block block = event.getBlock();
Player player = event.getPlayer();
if(block.getType() == Material.TNT && player.hasPermission("tntnotifier.allow-tnt") == false) {
block.setType(Material.CAKE);
player.sendMessage(ChatColor.RED + "You are not allowed to use TNT on this server - sorry but have a cake!");
plugin.logMessage(player.getName() + " placed a TNT block at " + block.getX() + "," + block.getY() + "," + block.getZ() + ".");
}
}
public void onBlockBreak(BlockBreakEvent event) {
if(event.isCancelled()) return;
Block block = event.getBlock();
if(block.getType() == Material.TNT) {
event.setCancelled(true);
block.setType(Material.AIR);
block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.CAKE, 1));
}
}
}
and here is the code for the plugin.yml file
name: TNTNotifier
version: 0.1
main: com.technotizer.TNTNotifier
permissions:
tntnotifier.allow-tnt:
description: Allows the use of TNT
default: op
Thanks for any help you can provide