Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.wayche.TNTBlock;
- 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 TNTBlockBlockListener extends BlockListener {
- private TNTBlock plugin;
- public TNTBlockBlockListener(TNTBlock 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("tntblock.allow-tnt") == false){
- String msg = player.getName() + " hat hier einen TNT Block gesetzt: " + block.getX() + "," + block.getY() + "," + block.getZ() + ".";
- block.setTypeId(plugin.config.getInt("place"));
- player.sendMessage(ChatColor.BLUE + player.getName() + " " + ChatColor.DARK_RED + "du darfst kein TNT benutzen!");
- System.out.println("\033[31m\033[44m" + player.getName() + " hat hier einen TNT Block gesetzt: " + block.getX() + "," + block.getY() + "," + block.getZ() + "." + "\033[0m\n");
- System.out.println(ChatColor.GREEN + "Blubb");
- for (Player onlinePlayer : plugin.getServer().getOnlinePlayers()){
- if (onlinePlayer.hasPermission("tntblock.notify")){
- onlinePlayer.sendMessage(ChatColor.DARK_RED + msg); }
- }
- }
- }
- 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(plugin.config.getInt("drop"), 1));
- }
- }
- }
Add Comment
Please, Sign In to add comment