예제 #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
 @EventHandler(priority = EventPriority.LOWEST)
 public void onBlockDamage(BlockDamageEvent e) {
   if (e.getBlock().getType().equals(Material.SKULL)) {
     Player player = e.getPlayer();
     Skull skull = (Skull) e.getBlock().getState();
     String name = this.hasOwner(skull) ? skull.getOwner() : this.def;
     if (e.getItemInHand().getTypeId() == this.sw.getConfiguration().getTool()) {
       this.sw.getActionWorker().executeCuboid(e);
     } else if (this.sw
         .getConfiguration()
         .getActionMap()
         .containsKey(e.getItemInHand().getTypeId())) {
       this.sw.getActionWorker().executeAction(e, name);
     } else if (skull.getSkullType() == SkullType.PLAYER)
       this.sw.getActionWorker().executeQuery(player, name);
   }
 }
예제 #3
0
 private boolean hasOwner(Skull skull) {
   return skull.hasOwner() && !skull.getOwner().equals("");
 }