daily pastebin goal
87%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.craftyn.mailbox;
  2.  
  3. import java.util.logging.Logger;
  4.  
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.Material;
  7. import org.bukkit.block.Sign;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.block.BlockBreakEvent;
  10. import org.bukkit.event.block.BlockListener;
  11. import org.bukkit.event.block.SignChangeEvent;
  12.  
  13. public class MailboxBlockListener extends BlockListener {
  14.     private Mailbox _plugin;
  15.     private final Logger log = Logger.getLogger("Minecraft");
  16.  
  17.     public MailboxBlockListener(Mailbox plugin) {
  18.         _plugin = plugin;
  19.     }
  20.    
  21.    
  22. public void onSignChange(SignChangeEvent event){
  23.     log.info("Debug - SignChangeEvent called.");
  24.     Player p = event.getPlayer();
  25.     if(event.getLine(0).equalsIgnoreCase("[mailbox]")){
  26.         event.setLine(0, "§2[Mailbox]");
  27.         event.setLine(1, "§6" + p.getName());
  28.         p.sendMessage(ChatColor.BLUE + "Mailbox successfully created!");
  29.        
  30.     }
  31. }
  32.  
  33.  
  34. public void onBlockBreak(BlockBreakEvent event) {
  35.     log.info("Debug - BlockBreakEvent called.");
  36.     Player p = event.getPlayer();
  37.     Material material = event.getBlock().getType();
  38.     if (material.equals(Material.SIGN) || material.equals(Material.WALL_SIGN)) {
  39.         Sign sign = (Sign)event.getBlock().getState();
  40.         if (ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase("[Mailbox]")) {
  41.             p.sendMessage(ChatColor.RED + "Mailbox deleted!");
  42.         }
  43.     }
  44. }
  45.  
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top