This method hooks into the BlockBreakEvent event and sends a message to the player who broke the block.
plugin.registerEvent("BlockBreakEvent", function(e) e:getPlayer():sendMessage("You broke a block")end)
This next example allows the player to execute the command /inspect in order to be placed into a table. Once placed in this table, the player will not be able to break blocks and instead will receive information on the block that was broken. The same command can be run again to disable this feature.
-- Importsmaterial =import("$.Material")color =newInstance("#.wrappers.ChatColorWrapper", {plugin.getPlugin()})-- An inspect command with an event to tell what a block isinspecters = {}-- Add the commandlocal inspectCommand = plugin.addCommand({name="inspect"}, function(cmd)local sender = cmd.getSender()-- Make sure it's a player sending the commandifnot cmd.isPlayerSender() then sender:sendMessage(color.DARK_RED:toString() .."Only players can run this command!")returnend-- Go through every inspector and check if any equals this players uuidfor k,v inpairs(inspecters) doif v == sender:getUniqueId() then-- Remove them from inspectors and tell themtable.remove(inspecters, k) sender:sendMessage(color.YELLOW .."You are no longer an inspector")returnendend-- Else, add them and tell themtable.insert(inspecters, sender:getUniqueId()) sender:sendMessage(color.YELLOW .."You are now an inspector")end)-- Add the eventplugin.registerEvent("BlockBreakEvent", function(e)-- Go through every inspector and check if any equals this players uuidfor _,v inpairs(inspecters) doif v == e:getPlayer():getUniqueId() then-- Tell them the block e:getPlayer():sendMessage(color.AQUA .."That is " .. color.GOLD .. e:getBlock():getType():name()) e:setCancelled(true)breakendendend)