예제 #1
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent e) {
   Player p = e.getPlayer();
   Block b = e.getBlock();
   if (p.getGameMode() == GameMode.CREATIVE) {
     if (b.getType() == Material.SKULL) {
       Skull skull = (Skull) e.getBlock().getState();
       String name = this.hasOwner(skull) ? skull.getOwner() : this.def;
       if (!this.hasTool(p)) {
         if (p.isSneaking()) {
           if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
             if (p.hasPermission(perm) || p.isOp()) {
               p.sendMessage(this.des.replace("#", name));
               // Disable skull?
             } else {
               e.setCancelled(true);
               p.sendMessage(this.noperm);
             }
           }
         } else if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
           this.sw.getActionWorker().executeQuery(p, name);
           if (p.hasPermission(perm)) {
             e.setCancelled(true);
             p.sendMessage(RED + "To destroy skull you must sneak and break");
           } else {
             e.setCancelled(true);
             p.sendMessage(this.noperm);
           }
         }
       } else if (p.isSneaking()) {
         e.setCancelled(true);
         this.sw.getActionWorker().executeQuery(p.getPlayer(), name);
       } else {
         e.setCancelled(true);
         ItemStack s = p.getItemInHand();
         this.onBlockDamage(new BlockDamageEvent(p, b, s, false));
         if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
           p.sendMessage(RED + "Block selected is already a part of a skull wall");
           p.sendMessage(RED + "Overlapping walls will not perform as expected!");
         }
       }
     }
   } else if (this.sw.getConfiguration().isProtecting()
       && e.getBlock().getType() == Material.SKULL
       && !p.hasPermission(perm))
     e.setCancelled(SkullWalls.getWallHandler().hasPermission(b, p, this.noperm));
 }
예제 #2
0
 public ActionListener(SkullWalls sw) {
   this.sw = sw;
   this.def = sw.getConfiguration().getName();
 }