public boolean handleCommand(String[] args, CommandSender sender) {
    Player p = null;
    if (sender instanceof Player) p = (Player) sender;
    if (args.length >= 1) {
      if (p == null) {
        sender.sendMessage(playerOnly);
        return true;
      }
      if (args[0].equalsIgnoreCase("add")) {
        if (!Main.cmdhandler.pm.hasPlayerPermission(p, Permission.MPVP_RS_ADD)) {
          sender.sendMessage(this.noPermMsg);
          return true;
        }
        Block tb = p.getTargetBlock((HashSet<Byte>) null, 10);
        if (tb != null && (tb.getType().equals(Material.WALL_SIGN))) {
          String name = "";
          boolean sky = true;
          if (args.length >= 2) {
            name = args[1];
            if (args.length >= 3) {
              try {
                sky = Boolean.parseBoolean(args[2]);
              } catch (Exception ex) {
              }
              ;
            }
          }
          Sign sign = (Sign) tb.getState();
          RadioStation.buildRadioStation(sign, RadioStation.getFacing(sign));
          Main.gameEngine.configuration.addRadioStation(new RadioStationContainer(sign, name, sky));
          Main.gameEngine.configuration.addNewProtectedRegion(
              sign.getLocation().clone().subtract(11d, 11d, 11d),
              sign.getLocation().clone().add(11d, 11d, 11d));
          sender.sendMessage(ChatColor.DARK_GREEN + Main.gameEngine.dict.get("addRs"));
        } else {
          sender.sendMessage(ChatColor.DARK_RED + Main.gameEngine.dict.get("mustPointOnSign"));
        }
        return true;
      }

      if (args[0].equalsIgnoreCase("remove")) {
        if (!Main.cmdhandler.pm.hasPlayerPermission(p, Permission.MPVP_RS_DEL)) {
          sender.sendMessage(this.noPermMsg);
          return true;
        }
        Block tb = p.getTargetBlock((HashSet<Byte>) null, 10);
        if (tb != null && (tb.getType().equals(Material.WALL_SIGN))) {
          Sign sign = (Sign) tb.getState();
          Main.gameEngine.configuration.removeRadioStation(sign);
          sender.sendMessage(ChatColor.DARK_GREEN + Main.gameEngine.dict.get("rmRs"));
        } else {
          sender.sendMessage(ChatColor.DARK_RED + Main.gameEngine.dict.get("mustPointOnSign"));
        }
        return true;
      }
    }
    return false;
  }
Example #2
0
  @Override
  public void Run(Player player, Server server, String[] args) {
    if (player.getTargetBlock(null, 150).getType() == Material.AIR) {
      player.sendMessage(formatMessage("You have to teleport to a block!"));
      return;
    }

    Location jumpLocation = player.getTargetBlock(null, 150).getLocation().add(0, 1, 0);

    player.teleport(jumpLocation);
    player.sendMessage(ChatColor.YELLOW + "Wooooosh!");
  }
Example #3
0
 @Override
 public boolean canRun(Player player, String[] args) {
   Material block = player.getTargetBlock(null, 7).getType();
   if (block == Material.COBBLESTONE
       || block == Material.SAND
       || block == Material.IRON_ORE
       || block == Material.GOLD_ORE) {
     return PluginHook.canBuild(player, player.getTargetBlock(null, 7));
   } else if (getTarget(player) != null) {
     if (getTarget(player) instanceof LivingEntity) {
       return true;
     }
   }
   return false;
 }
  private boolean editSign(CommandSender sender, String[] args) {
    if (!(sender instanceof Player)) return true;

    if (args.length == 0) return false;
    if (!args[0].matches("^[0-9]+$")) return false;

    int lineNo = Integer.parseInt(args[0]) - 1;
    String newLine = "";
    for (int i = 1; i < args.length; i++) {
      newLine += args[i] + " ";
    }
    newLine = newLine.trim();
    System.out.println("-" + newLine + "-");

    Player player = (Player) sender;
    Block b = player.getTargetBlock(null, 5);
    System.out.println(b);
    if (b != null && (b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN)) {
      Sign sign = (Sign) b.getState();
      String[] lines = sign.getLines();
      lines[lineNo] = newLine;
      SignChangeEvent event = new SignChangeEvent(b, player, lines);
      Bukkit.getPluginManager().callEvent(event);
      if (!event.isCancelled()) {
        sign.setLine(lineNo, newLine);
        sign.update();
      }
    }

    return true;
  }
  @SuppressWarnings("deprecation")
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent event) {
    Player p = event.getPlayer();
    Block b = p.getTargetBlock((Set<Material>) null, p.getGameMode() == GameMode.CREATIVE ? 5 : 4);
    PumpkinCheck check =
        new PumpkinCheck(p.getWorld().getBlockAt(b.getLocation()).getType(), b.getLocation());

    if (targetBlocks.containsKey(p) && targetBlocks.get(p).isPumpkin() && !check.isPumpkin()) {
      Block newBlock = p.getWorld().getBlockAt(targetBlocks.get(p).getLocation());
      byte data = newBlock.getData();

      newBlock.setType(Material.PUMPKIN);
      newBlock.setData(data);
    }

    targetBlocks.put(p, check);

    if (targetBlocks.get(p).isPumpkin()) {
      Block newBlock = p.getWorld().getBlockAt(targetBlocks.get(p).getLocation());
      byte data = newBlock.getData();

      newBlock.setType(Material.JACK_O_LANTERN);
      newBlock.setData(data);
    }
  }
 @Override
 public SkillResult use(Hero hero, String[] args) {
   Player player = hero.getPlayer();
   broadcastExecuteText(hero);
   double chance2x = SkillConfigManager.getUseSetting(hero, this, "chance-2x", 0.2, false);
   double chance3x = SkillConfigManager.getUseSetting(hero, this, "chance-3x", 0.1, false);
   Block wTargetBlock = player.getTargetBlock(null, 20).getRelative(BlockFace.UP);
   double rand = Math.random();
   LivingEntity le =
       player.getWorld().spawnCreature(wTargetBlock.getLocation(), CreatureType.SPIDER);
   le.getWorld().playEffect(le.getLocation(), Effect.SMOKE, 3);
   int count = 1;
   if (rand > (1 - chance2x - chance3x)) {
     LivingEntity le1 =
         player.getWorld().spawnCreature(wTargetBlock.getLocation(), CreatureType.SPIDER);
     le1.getWorld().playEffect(le1.getLocation(), Effect.SMOKE, 3);
     count++;
   }
   if (rand > (1 - chance3x)) {
     LivingEntity le1 =
         player.getWorld().spawnCreature(wTargetBlock.getLocation(), CreatureType.SPIDER);
     le1.getWorld().playEffect(le1.getLocation(), Effect.SMOKE, 3);
     count++;
   }
   broadcast(player.getLocation(), "" + count + "x Multiplier!");
   return SkillResult.NORMAL;
 }
Example #7
0
  public IceSpike(Player player) {
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
    if (bPlayer.isOnCooldown("IceSpike")) return;
    try {
      this.player = player;

      double lowestdistance = range + 1;
      Entity closestentity = null;
      for (Entity entity : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), range)) {
        if (GeneralMethods.getDistanceFromLine(
                    player.getLocation().getDirection(), player.getLocation(), entity.getLocation())
                <= 2
            && (entity instanceof LivingEntity)
            && (entity.getEntityId() != player.getEntityId())) {
          double distance = player.getLocation().distance(entity.getLocation());
          if (distance < lowestdistance) {
            closestentity = entity;
            lowestdistance = distance;
          }
        }
      }
      if (closestentity != null) {
        Block temptestingblock =
            closestentity.getLocation().getBlock().getRelative(BlockFace.DOWN, 1);
        // if (temptestingblock.getType() == Material.ICE){
        this.block = temptestingblock;
        // }
      } else {
        this.block = player.getTargetBlock((HashSet<Material>) null, (int) range);
      }
      for (IceSpike2 icespike : IceSpike2.instances.values()) {
        if (icespike.getBlock().equals(block)) {
          return;
        }
      }
      origin = block.getLocation();
      location = origin.clone();

    } catch (IllegalStateException e) {
      return;
    }

    loadAffectedBlocks();

    if (height != 0) {
      if (canInstantiate()) {
        id = ID;
        instances.put(id, this);
        if (ID >= Integer.MAX_VALUE) {
          ID = Integer.MIN_VALUE;
        }
        ID++;
        time = System.currentTimeMillis() - interval;
        bPlayer.addCooldown("IceSpike", cooldown);
      }
    }
  }
Example #8
0
  @Override
  public void run(Player player, String[] args) {
    try {
      Material block = player.getTargetBlock(null, 7).getType();
      if (block == Material.COBBLESTONE) {
        player.getTargetBlock(null, 7).setType(Material.STONE);
        player.getWorld().playSound(player.getLocation(), Sound.FIRE_IGNITE, 1, 1);
        Location loc = player.getTargetBlock(null, 7).getLocation();
        loc.setX(loc.getX() + 0.5);
        loc.setZ(loc.getZ() + 0.5);
        loc.setY(loc.getY() + 0.5);
        ParticleEffects.sendToLocation(ParticleEffects.FLAME, loc, 1, 1, 1, 0, 10);
      } else if (block == Material.SAND) {
        player.getTargetBlock(null, 7).setType(Material.GLASS);
        player.getWorld().playSound(player.getLocation(), Sound.FIRE_IGNITE, 1, 1);
        Location loc = player.getTargetBlock(null, 7).getLocation();
        loc.setX(loc.getX() + 0.5);
        loc.setZ(loc.getZ() + 0.5);
        loc.setY(loc.getY() + 0.5);
        ParticleEffects.sendToLocation(ParticleEffects.FLAME, loc, 1, 1, 1, 0, 10);
      } else if (block == Material.IRON_ORE) {
        Block b = player.getTargetBlock(null, 7);
        b.setType(Material.AIR);
        b.getWorld().dropItem(b.getLocation(), new ItemStack(Material.IRON_INGOT));
        player.getWorld().playSound(player.getLocation(), Sound.FIRE_IGNITE, 1, 1);
        Location loc = player.getTargetBlock(null, 7).getLocation();
        loc.setX(loc.getX() + 0.5);
        loc.setZ(loc.getZ() + 0.5);
        loc.setY(loc.getY() + 0.5);
        ParticleEffects.sendToLocation(ParticleEffects.FLAME, loc, 1, 1, 1, 0, 10);
      } else if (block == Material.GOLD_ORE) {
        Block b = player.getTargetBlock(null, 7);
        b.setType(Material.AIR);
        b.getWorld().dropItem(b.getLocation(), new ItemStack(Material.GOLD_INGOT));
        player.getWorld().playSound(player.getLocation(), Sound.FIRE_IGNITE, 1, 1);
        Location loc = player.getTargetBlock(null, 7).getLocation();
        loc.setX(loc.getX() + 0.5);
        loc.setZ(loc.getZ() + 0.5);
        loc.setY(loc.getY() + 0.5);
        ParticleEffects.sendToLocation(ParticleEffects.FLAME, loc, 1, 1, 1, 0, 30);
      } else {
        LivingEntity en = (LivingEntity) getTarget(player);
        player.getWorld().playSound(player.getLocation(), Sound.FIRE_IGNITE, 1, 1);
        en.setFireTicks(160);
      }
    } catch (Exception e) {

    }
  }
 @SuppressWarnings("deprecation")
 public static void form(Player player) {
   if (!hasAbility(player, LavaSurgeWall.class)) {
     new LavaSurgeWave(player);
     return;
   } else if (isLavabendable(
       player, player.getTargetBlock((HashSet<Byte>) null, SURGE_WAVE_RANGE))) {
     new LavaSurgeWave(player);
     return;
   }
   moveLava(player);
 }
Example #10
0
  @Override
  public void Run(Player player, Server server, String[] args) {
    PlayerSettings settings = plugin.getPlayerSettings(player);

    settings.setFirstPosition(
        player
            .getTargetBlock(null, plugin.getWorldEditSettings().getMaxSelectionRange())
            .getLocation());

    if (settings.getSelection() == null) {
      player.sendMessage(formatMessage("First position is set!"));
    } else {
      player.sendMessage(
          formatMessage(
              "First position is set!(" + settings.getSelection().getBlocks().size() + " blocks)"));
    }
  }
 @Override
 public SkillResult use(Hero paramHero, String[] paramArrayOfString) {
   final Player localPlayer = paramHero.getPlayer();
   Location localLocation1 = localPlayer.getLocation();
   int distance =
       (int)
           (SkillConfigManager.getUseSetting(
                   paramHero, this, SkillSetting.MAX_DISTANCE.node(), 15, false)
               + (SkillConfigManager.getUseSetting(
                       paramHero, this, SkillSetting.MAX_DISTANCE_INCREASE.node(), 0.0, false)
                   * paramHero.getSkillLevel(this)));
   distance = distance > 0 ? distance : 0;
   Location localLocation2 = null;
   try {
     localLocation2 = localPlayer.getTargetBlock(null, distance).getLocation();
   } catch (IllegalArgumentException iae) {
     return SkillResult.INVALID_TARGET_NO_MSG;
   }
   double d1 = localLocation2.getX() - localLocation1.getX();
   double d2 = localLocation2.getZ() - localLocation1.getZ();
   double d3 = Math.sqrt(d1 * d1 + d2 * d2);
   double d4 = 0;
   try {
     d4 = localLocation2.distance(localLocation1) / 8.0D;
   } catch (IllegalArgumentException iae) {
     return SkillResult.INVALID_TARGET_NO_MSG;
   }
   d1 = d1 / d3 * d4;
   d2 = d2 / d3 * d4;
   localPlayer.setVelocity(new Vector(d1, 1.0D, d2));
   this.chargingPlayers.put(localPlayer, localLocation1);
   this.plugin
       .getServer()
       .getScheduler()
       .scheduleSyncDelayedTask(
           this.plugin,
           new Runnable() {
             @Override
             public void run() {
               localPlayer.setFallDistance(8.0F);
             }
           },
           1L);
   broadcastExecuteText(paramHero);
   return SkillResult.NORMAL;
 }
Example #12
0
  /**
   * Returns a LinkedList of PhatLoots that are linked to the target Block
   *
   * @param player The Player targeting a Block
   * @return The LinkedList of PhatLoots
   */
  public static LinkedList<PhatLoot> getPhatLoots(Player player) {
    LinkedList<PhatLoot> phatLoots = new LinkedList<>();
    // Cancel if the sender is not targeting a correct Block
    Block block = player.getTargetBlock(EnumSet.of(Material.AIR), 10);
    String blockName = block.getType().toString();
    if (!PhatLootsUtil.isLinkableType(block)) {
      player.sendMessage("§6" + blockName + "§4 is not a linkable type.");
      return phatLoots;
    }

    phatLoots = PhatLoots.getPhatLoots(block);

    // Inform the sender if the Block is not linked to any PhatLoots
    if (phatLoots.isEmpty()) {
      player.sendMessage("§4Target §6" + blockName + "§4 is not linked to a PhatLoot");
    }
    return phatLoots;
  }
Example #13
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (cmd.getName().equalsIgnoreCase("lock")) {
      if (!(sender instanceof Player)) {
        sender.sendMessage("Players can only do this!");
        return false;
      }
      Player p = (Player) sender;
      @SuppressWarnings("deprecation")
      Block b = p.getTargetBlock(null, 10);
      if (b.getType() == Material.CHEST) {
        if (locked.containsKey(b.getLocation()) == true) {
          p.sendMessage(
              ChatColor.GRAY
                  + "["
                  + ChatColor.GOLD
                  + "ChestLock"
                  + ChatColor.GRAY
                  + "] "
                  + ChatColor.AQUA
                  + "That chest is locked all ready by "
                  + locked.get(b.getLocation()));
        } else {
          locked.put(b.getLocation(), p.getName());
          p.sendMessage(
              ChatColor.GRAY
                  + "["
                  + ChatColor.GOLD
                  + "ChestLock"
                  + ChatColor.GRAY
                  + "] "
                  + ChatColor.AQUA
                  + "That Chest is now locked!");
          System.out.println(b.getLocation());
          System.out.println(locked.keySet());
        }
      }
    }

    return false;
  }
  // Returns true if a door wasn't changed.
  private static boolean fixDoor(Player player) {
    Block block = player.getTargetBlock(null, 10);
    int type = block.getTypeId();
    boolean doCheck = false;

    // Check if the block being looked at is a door block.

    if (Lockette.protectTrapDoors) {
      if (type == Material.TRAP_DOOR.getId()) doCheck = true;
    }

    if (Lockette.protectDoors) {
      if ((type == Material.WOODEN_DOOR.getId())
          || (type == Material.IRON_DOOR_BLOCK.getId())
          || (type == materialFenceGate)) doCheck = true;
    }

    if (!doCheck) return (true);

    Block signBlock = Lockette.findBlockOwner(block);

    if (signBlock == null) return (true);

    Sign sign = (Sign) signBlock.getState();
    int length = player.getName().length();

    if (length > 15) length = 15;

    // Check owner only.
    if (sign.getLine(1)
        .replaceAll("(?i)\u00A7[0-F]", "")
        .equals(player.getName().substring(0, length))) {
      Lockette.toggleSingleDoor(block);
      return (false);
    }

    return (true);
  }
 @SuppressWarnings("deprecation")
 public void throwEarth() {
   if (sourceblock != null) {
     if (sourceblock.getWorld().equals(player.getWorld())) {
       if (EarthMethods.movedearth.containsKey(sourceblock)) {
         if (!revert) {
           EarthMethods.removeRevertIndex(sourceblock);
         }
       }
       Entity target = GeneralMethods.getTargetedEntity(player, range, new ArrayList<Entity>());
       // Methods.verbose(target);
       if (target == null) {
         destination =
             player
                 .getTargetBlock(EarthMethods.getTransparentEarthbending(), (int) range)
                 .getLocation();
         firstdestination = sourceblock.getLocation().clone();
         firstdestination.setY(destination.getY());
       } else {
         destination = ((LivingEntity) target).getEyeLocation();
         firstdestination = sourceblock.getLocation().clone();
         firstdestination.setY(destination.getY());
         destination = GeneralMethods.getPointOnLine(firstdestination, destination, range);
       }
       if (destination.distance(location) <= 1) {
         progressing = false;
         destination = null;
       } else {
         progressing = true;
         EarthMethods.playEarthbendingSound(sourceblock.getLocation());
         // direction = getDirection().normalize();
         if (sourcetype != Material.SAND && sourcetype != Material.GRAVEL) {
           sourceblock.setType(sourcetype);
         }
       }
     }
   }
 }
  private void put(Player player, String[] args) {
    Block block = player.getTargetBlock(null, 50).getRelative(BlockFace.UP);
    if (!AdminPermissions.has(player, Perms.ADMINTP)
        && !AdminPermissions.has(player, Perms.ANYTP)) {
      player.sendMessage("You don't have permission to use that command");
      return;
    } else if (!AdminHandler.isAdminMode(player.getName())
        && !AdminPermissions.has(player, Perms.ANYTP)) {
      player.sendMessage("You must be in admin mode to teleport");
      return;
    } else if (args.length < 1) {
      player.sendMessage("You must specify a player to bring to your location");
      return;
    } else if (block == null) {
      player.sendMessage("Could not determine a block to teleport players to, aborting teleport.");
    } else if (args[0].equalsIgnoreCase("all")) {
      teleportAll(player, block.getLocation());
      player.sendMessage("You have teleported everyone to the target.");
    } else {
      List<String> players = new ArrayList<String>();
      for (Player p : plugin.getServer().getOnlinePlayers()) {
        if (p.getName().toLowerCase().contains(args[0].toLowerCase())) {
          p.teleport(block.getLocation());
          p.sendMessage(player.getName() + " has teleported you.");
          players.add(p.getName());
        }
      }

      if (players.isEmpty()) player.sendMessage("Could not find any players named " + args[0]);
      else {
        String message = "You have brought to your location:";
        for (String pName : players) message += "  " + pName;

        player.sendMessage(message);
      }
      return;
    }
  }
Example #17
0
 @SuppressWarnings("deprecation")
 public void run() {
   int timeleft = (time - runtime);
   runtime++;
   if (timeleft == 8) {
     EffectUtils.playExplodeEffect(loc);
     item.getItemStack().addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 1);
     zplayer.sendMessage("Your upgraded weapon is available.");
     if (player.getTargetBlock(null, 4).getType() == Material.ENDER_CHEST) {
       zplayer.sendActionBar(
           ChatColor.GRAY
               + "Press right-click to accept weapon. ["
               + ChatColor.RED
               + weapon.getUpgradedName()
               + ChatColor.GRAY
               + "]");
     }
     waiting = true;
   } else if (timeleft == 0) {
     zplayer.sendMessage("You failed to accept your upgraded weapon in time.");
     this.cancelTask();
   }
 }
Example #18
0
  @EventHandler
  public void onPlayerShoot(PlayerInteractEvent e) {

    Player p = e.getPlayer();

    if (ArenaManager.isPlayerPlaying(p)) {
      if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
        if ((e.getItem() != null) && (p.getItemInHand() != null)) {
          if (Objects.equals(
              e.getItem().getItemMeta().getDisplayName(), WeaponManager.WEAPON_NAME)) {
            if (NexusGame.isParticleEffectLibInstalled()) {
              Effect line = new ShootEffect(NexusGame.effects.getEffectManager());
              line.color = Color.PURPLE;
              line.setEntity(p);
              line.setTargetLocation(
                  p.getTargetBlock(Sets.<Material>newHashSet(), 100).getLocation());

              NexusGame.effects.playEffect(line);
            }
          }
        }
      }
    }
  }
Example #19
0
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) {
      sender.sendMessage("You can't run this commands since you are not a player!");
      return false;
    }

    Player player = (Player) sender;

    if (cmd.getName().equalsIgnoreCase("ovo")) {
      if (player.hasPermission("ovo.admin")) {
        if (args.length == 1) {
          if (args[0].equalsIgnoreCase("lobby")) {
            ConfigUtil.get().setLobby(player.getLocation());
            player.sendMessage(ChatHandler.get().sendMessage("commands.lobby.success"));
            return true;
          } else if (args[0].equalsIgnoreCase("zombie")) {
            CustomSheep sheep = new CustomSheep(player.getWorld());
            sheep.setCustomName(ChatColor.GREEN + "Join the queue!");
            sheep.setCustomNameVisible(true);
            sheep.setColor(EnumColor.RED);
            Location loc = player.getLocation();
            EntityTypes.spawnEntity(sheep, loc);
            //                        ((CraftWorld) loc.getWorld()).getHandle().addEntity(sheep);
            //                        sheep.setLocation(loc.getX(), loc.getY(), loc.getZ(),
            // loc.getYaw(), loc.getPitch());
            System.out.println(LocationUtil.get().serialize(sheep.getBukkitEntity().getLocation()));
            player.sendMessage(ChatHandler.get().sendMessage("commands.zombie.success"));
            return true;
          }
        } else if (args.length == 2) {
          if (args[0].equalsIgnoreCase("createmap")) {
            String name = args[1];
            Map map = new Map(name, new ItemStack(Material.DIAMOND_SWORD), new ArrayList<Arena>());
            map.save();
            MapHandler.get().getMaps().add(map);
            player.sendMessage(
                ChatHandler.get()
                    .sendMessage("commands.createmap.success")
                    .replaceAll("%map%", name));
          } else // ovo setloc1 Dome1
          if (args[0].equalsIgnoreCase("setloc1")) {
            Arena arena = ArenaHandler.get().getArena(args[1]);
            if (arena != null) {
              Block targetBlock = player.getTargetBlock((Set<Material>) null, 6);
              if (targetBlock != null) {
                arena.setLoc1(targetBlock.getLocation());
                arena.save();
                player.sendMessage(
                    ChatColor.GREEN + "Successfully set corner 1 to the block you're looking at!");
              }
            } else {
              player.sendMessage(
                  ChatHandler.get()
                      .sendMessage("commands.spawnpoints.arena-not-found")
                      .replaceAll("%arena%", args[1]));
              return false;
            }
          } else // ovo setloc1 Dome1
          if (args[0].equalsIgnoreCase("setloc2")) {
            Arena arena = ArenaHandler.get().getArena(args[1]);
            if (arena != null) {
              Block targetBlock = player.getTargetBlock((Set<Material>) null, 6);
              if (targetBlock != null) {
                arena.setLoc2(targetBlock.getLocation());
                arena.save();
                player.sendMessage(
                    ChatColor.GREEN + "Successfully set corner 2 to the block you're looking at!");
              }
            } else {
              player.sendMessage(
                  ChatHandler.get()
                      .sendMessage("commands.spawnpoints.arena-not-found")
                      .replaceAll("%arena%", args[1]));
              return false;
            }
          }
        } else if (args.length == 3) {
          if (args[0].equalsIgnoreCase("spawnpoints")) {
            String name = args[1];
            Arena arena = ArenaHandler.get().getArena(name);
            if (arena != null) {
              if (isInt(args[2])) {
                int index = Integer.parseInt(args[2]);
                if (index == 1 || index == 2) {
                  List<Location> spawnLocs = arena.getSpawnLocs();
                  spawnLocs.add(index - 1, player.getLocation());
                  arena.setSpawnLocs(spawnLocs);
                  arena.save();
                  player.sendMessage(
                      ChatHandler.get()
                          .sendMessage("commands.spawnpoints.success")
                          .replaceAll("%index%", index + "")
                          .replaceAll("%arena%", arena.getId()));
                  return true;
                } else {
                  player.sendMessage(
                      ChatHandler.get().sendMessage("commands.spawnpoints.incorrect-index"));
                  return false;
                }
              } else {
                player.sendMessage(
                    ChatHandler.get()
                        .sendMessage("commands.spawnpoints.not-correct-index")
                        .replaceAll("%arg%", args[2]));
                return false;
              }
            } else {
              player.sendMessage(
                  ChatHandler.get()
                      .sendMessage("commands.spawnpoints.arena-not-found")
                      .replaceAll("%arena%", args[1]));
              return false;
            }
          } else if (args[0].equalsIgnoreCase("createarena")) {
            String name = args[1];
            String mapname = args[2];
            if (MapHandler.get().getByName(mapname) != null) {
              Map map = MapHandler.get().getByName(mapname);
              Arena arena = new Arena(name, new ArrayList<Location>(), null, null, map);
              map.getArenas().add(arena);
              arena.save();
              map.save();
              player.sendMessage(ChatColor.GREEN + "Successfully created arena " + name);
              ArenaHandler.get().getArenas().add(arena);
              return true;
            }
          }
        }
      } else {
        player.sendMessage(ChatHandler.get().sendMessage("commands.no-permission"));
        return false;
      }
    }

    return false;
  }
  @Override
  public boolean execute(ScrollingMenuSign plugin, Player player, String[] args)
      throws SMSException {
    SMSView view = null;
    SMSMenu menu = plugin.getHandler().getMenu(args[0]);

    if (args.length == 2 && args[1].equalsIgnoreCase("-spout")) { // spout view
      if (plugin.isSpoutEnabled()) view = SMSSpoutView.addSpoutViewToMenu(menu);
      else throw new SMSException("Server is not Spout-enabled");
    } else if (args.length == 3 && args[1].equalsIgnoreCase("-sign")) { // sign view
      Location loc = MiscUtil.parseLocation(args[2], player);
      view = SMSSignView.addSignToMenu(menu, loc);
    } else if (args.length == 3 && args[1].equalsIgnoreCase("-redstone")) { // redstone view
      Location loc = MiscUtil.parseLocation(args[2], player);
      view = SMSRedstoneView.addRedstoneViewToMenu(menu, loc);
    } else if (args.length == 2
        && (args[1].equalsIgnoreCase("-sign") || args[1].equalsIgnoreCase("-redstone"))) {
      // create a new view interactively
      notFromConsole(player);
      String type = args[1].substring(1);
      MiscUtil.statusMessage(
          player,
          "Left-click a block to add it as a &9"
              + type
              + "&- view on menu &e"
              + menu.getName()
              + "&-.");
      MiscUtil.statusMessage(player, "Right-click anywhere to cancel.");
      plugin.expecter.expectingResponse(player, new ExpectViewCreation(menu, args[1]));
      return true;
    } else if (args.length == 3 && args[1].equalsIgnoreCase("-map")) { // map view
      try {
        short mapId = Short.parseShort(args[2]);
        view = SMSMapView.addMapToMenu(menu, mapId);
      } catch (NumberFormatException e) {
        throw new SMSException(e.getMessage());
      }
    } else if (args.length > 1) {
      MiscUtil.errorMessage(player, "Unknown view type: " + args[1]);
      return false;
    }

    if (view == null) {
      // see if we can get a view from what the player is looking at or holding
      notFromConsole(player);
      if (player.getItemInHand().getType() == Material.MAP) { // map view
        PermissionsUtils.requirePerms(player, "scrollingmenusign.use.map");
        short mapId = player.getItemInHand().getDurability();
        view = SMSMapView.addMapToMenu(menu, mapId);
      } else {
        try {
          Block b = player.getTargetBlock(null, 3); // sign view ?
          if (b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST) {
            view = SMSSignView.addSignToMenu(menu, b.getLocation());
          }
        } catch (IllegalStateException e) {
          // ignore
        }
      }
    }

    if (view != null) {
      MiscUtil.statusMessage(
          player,
          String.format(
              "Added &9%s&- view &e%s&- to menu &e%s&-.",
              view.getType(), view.getName(), menu.getName()));
    } else {
      throw new SMSException("Found nothing suitable to add as a menu view");
    }

    return true;
  }
Example #21
0
  /**
   * Detonate TNT for Blast Mining
   *
   * @param event The PlayerInteractEvent
   * @param player Player detonating the TNT
   * @param plugin mcMMO plugin instance
   */
  public static void detonate(PlayerInteractEvent event, Player player, mcMMO plugin) {
    PlayerProfile PP = Users.getProfile(player);

    if (PP.getSkillLevel(SkillType.MINING) < 125) return;

    Block block = event.getClickedBlock();

    if (block == null || block.getType() != Material.TNT) {
      final byte SNOW = 78;
      final byte AIR = 0;
      final int BLOCKS_AWAY = 100;

      HashSet<Byte> transparent = new HashSet<Byte>();

      transparent.add(SNOW);
      transparent.add(AIR);

      block = player.getTargetBlock(transparent, BLOCKS_AWAY);

      if (block.getType() != Material.TNT) {
        return;
      }
    } else if (block.getType() == Material.TNT) {
      event.setCancelled(
          true); // This is the only way I know to avoid the original TNT to be triggered (in case
      // the player is close to it)
    }

    if (!Misc.blockBreakSimulate(block, player, true)) {
      return;
    }

    final double MAX_DISTANCE_AWAY = 10.0;
    final int TIME_CONVERSION_FACTOR = 1000;

    AbilityType ability = AbilityType.BLAST_MINING;

    /* Check Cooldown */
    if (!Skills.cooldownOver(
        PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
      player.sendMessage(
          LocaleLoader.getString("Skills.TooTired")
              + ChatColor.YELLOW
              + " ("
              + Skills.calculateTimeLeft(
                  PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())
              + "s)");

      return;
    }

    /* Send message to nearby players */
    for (Player y : player.getWorld().getPlayers()) {
      if (y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
        y.sendMessage(ability.getAbilityPlayer(player));
      }
    }

    player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));

    /* Create the TNT entity */
    TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
    plugin.tntTracker.put(tnt.getEntityId(), player);
    tnt.setFuseTicks(0);

    /* Disable the original one */
    block.setType(Material.AIR);

    PP.setSkillDATS(ability, System.currentTimeMillis()); // Save DATS for Blast Mining
    PP.setAbilityInformed(ability, false);
  }
Example #22
0
  public void Appelflap_Builder(CommandSender sender) {
    Bukkit.getServer().getLogger().info("Appelflap-Builder method initiated");
    Player Sender = Bukkit.getServer().getPlayer(sender.getName());
    Block target_block = Sender.getTargetBlock(null, 25);
    Location target_block_location = target_block.getLocation();
    int x = target_block_location.getBlockX();
    int y = target_block_location.getBlockY();
    int z = target_block_location.getBlockZ();

    final int[][] ala =
        new int[][] {
          new int[] {x, y + 1, z},
          new int[] {x + 1, y + 1, z},
          new int[] {x + 2, y + 1, z},
          new int[] {x, y + 1, z + 1},
          new int[] {x + 1, y + 1, z + 1},
          new int[] {x + 2, y + 1, z + 1},
          new int[] {x, y + 1, z + 2},
          new int[] {x + 1, y + 1, z + 2},
          new int[] {x + 2, y + 1, z + 2},
          new int[] {x, y + 1, z + 4},
          new int[] {x + 1, y + 1, z + 4},
          new int[] {x + 2, y + 1, z + 4},
          new int[] {x, y + 1, z + 5},
          new int[] {x + 1, y + 1, z + 5},
          new int[] {x + 2, y + 1, z + 5},
          new int[] {x, y + 1, z + 6},
          new int[] {x + 1, y + 1, z + 6},
          new int[] {x + 2, y + 1, z + 6},
          new int[] {x + 3, y + 1, z + 2},
          new int[] {x + 4, y + 1, z + 2},
          new int[] {x + 5, y + 1, z + 2},
          new int[] {x + 6, y + 1, z + 2},
          new int[] {x + 7, y + 1, z + 2},
          new int[] {x + 8, y + 1, z + 2},
          new int[] {x + 9, y + 1, z + 2},
          new int[] {x + 10, y + 1, z + 2},
          new int[] {x + 11, y + 1, z + 2},
          new int[] {x + 3, y + 1, z + 3},
          new int[] {x + 4, y + 1, z + 3},
          new int[] {x + 5, y + 1, z + 3},
          new int[] {x + 6, y + 1, z + 3},
          new int[] {x + 7, y + 1, z + 3},
          new int[] {x + 8, y + 1, z + 3},
          new int[] {x + 9, y + 1, z + 3},
          new int[] {x + 10, y + 1, z + 3},
          new int[] {x + 11, y + 1, z + 3},
          new int[] {x + 12, y + 1, z + 3},
          new int[] {x + 13, y + 1, z + 3},
          new int[] {x + 3, y + 1, z + 4},
          new int[] {x + 4, y + 1, z + 4},
          new int[] {x + 5, y + 1, z + 4},
          new int[] {x + 6, y + 1, z + 4},
          new int[] {x + 7, y + 1, z + 4},
          new int[] {x + 8, y + 1, z + 4},
          new int[] {x + 9, y + 1, z + 4},
          new int[] {x + 10, y + 1, z + 4},
          new int[] {x + 11, y + 1, z + 4},
          new int[] {x + 11, y + 1, z + 4},
        };
    Integer timeride =
        Bukkit.getScheduler()
            .scheduleSyncDelayedTask(
                ChatBot.chatbot,
                new Runnable() {
                  @Override
                  public void run() {
                    Bukkit.getServer().getLogger().info("Appelflap-Builder loop gestart");
                    for (int i = 0; i < ala.length; i++) {
                      for (int j = 0; j < ala[i].length; j++) {
                        Bukkit.getServer()
                            .getWorld("world")
                            .getBlockAt(ala[i][0], ala[i][1], ala[i][2])
                            .setTypeIdAndData(35, (byte) 6, true);
                      }
                    }
                  }
                });
  }
  @Override
  public boolean onCommand(CommandSender cs, Command command, String string, String[] args) {
    Player player = (Player) cs;
    World w = Bukkit.getServer().getWorld("World");
    if (string.equalsIgnoreCase("fexplode")) {
      if (player.hasPermission("explosionman.fexplode") || player.isOp()) {
        @SuppressWarnings("unused")
        boolean canexplode = true;
        @SuppressWarnings("deprecation")
        Block lookBlock = player.getTargetBlock(null, 200);
        Location plocation = lookBlock.getLocation();
        if (args.length == 0) {
          if (MainClass.getConfig().getBoolean("fexplodemsg")) {
            String fexplodemsg =
                MainClass.getConfig()
                    .getString("fexplodetext")
                    .replaceAll("(&([a-f0-9]))", "\u00A7$2");
            player.sendMessage(fexplodemsg);
          }
          w.createExplosion(plocation, MainClass.getConfig().getInt("fexplodepower"));
          if (player.hasPermission("explosionman.fexplodelightning")) {
            w.strikeLightningEffect(plocation);
          }
        } else if (args.length == 1) {
          try {
            @SuppressWarnings("unused")
            float explosionPower = Float.parseFloat(args[0]);
          } catch (NumberFormatException e) {
            player.sendMessage(ChatColor.RED + "That is not a number!");
            return false;
          }
          float explosionPower = Float.parseFloat(args[0]);
          if (explosionPower > MainClass.getConfig().getInt("fexplodebigpower")) {
            if (player.hasPermission("explosionman.fexplodebig") || player.isOp()) {
              canexplode = true;
            } else {
              player.sendMessage(
                  ChatColor.RED + "You do not have permission to create such a large explosion!");
              canexplode = false;
              return false;
            }
          }
          if (canexplode = true) {
            if (MainClass.getConfig().getBoolean("fexplodemsg")) {
              String fexplodemsg =
                  MainClass.getConfig()
                      .getString("fexplodetext")
                      .replaceAll("(&([a-f0-9]))", "\u00A7$2");
              player.sendMessage(fexplodemsg);
            }
            w.createExplosion(plocation, explosionPower);
            if (player.hasPermission("explosionman.fexplodelightning")) {
              w.strikeLightningEffect(plocation);
            }
          }
        } else if (args.length > 1) {
          player.sendMessage(
              ChatColor.RED + "The proper use is " + ChatColor.AQUA + "/fexplode [number]");
        }

      } else {
        player.sendMessage(ChatColor.RED + "You cannot make an explosion over there!");
      }
    }
    return false;
  }
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    // If the player typed /tardis then do the following...
    // check there is the right number of arguments
    if (cmd.getName().equalsIgnoreCase("tardis")) {
      Player player = null;
      if (sender instanceof Player) {
        player = (Player) sender;
      }
      if (args.length == 0) {
        sender.sendMessage(TARDISConstants.COMMANDS.split("\n"));
        return true;
      }
      // the command list - first argument MUST appear here!
      if (!firstArgs.contains(args[0].toLowerCase())) {
        sender.sendMessage(
            plugin.pluginName
                + " That command wasn't recognised type "
                + ChatColor.GREEN
                + "/tardis help"
                + ChatColor.RESET
                + " to see the commands");
        return false;
      }
      if (args[0].equalsIgnoreCase("version")) {
        FileConfiguration pluginYml =
            YamlConfiguration.loadConfiguration(
                plugin.pm.getPlugin("TARDIS").getResource("plugin.yml"));
        String version = pluginYml.getString("version");
        String cb = Bukkit.getVersion();
        sender.sendMessage(
            plugin.pluginName
                + " You are running TARDIS version: "
                + ChatColor.AQUA
                + version
                + ChatColor.RESET
                + " with CraftBukkit "
                + cb);
        return true;
      }
      if (player == null) {
        sender.sendMessage(
            plugin.pluginName + ChatColor.RED + " This command can only be run by a player");
        return false;
      } else {
        if (args[0].equalsIgnoreCase("chameleon")) {
          if (!plugin.getConfig().getBoolean("chameleon")) {
            sender.sendMessage(
                plugin.pluginName
                    + " This server does not allow the use of the chameleon circuit!");
            return false;
          }
          if (player.hasPermission("tardis.timetravel")) {
            if (args.length < 2
                || (!args[1].equalsIgnoreCase("on") && !args[1].equalsIgnoreCase("off"))) {
              sender.sendMessage(plugin.pluginName + " Too few command arguments!");
              return false;
            }
            // get the players TARDIS id
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              ResultSet rs = service.getTardis(player.getName(), "*");
              if (rs == null || !rs.next()) {
                sender.sendMessage(plugin.pluginName + " " + TARDISConstants.NO_TARDIS);
                return false;
              }
              int id = rs.getInt("tardis_id");
              String chamStr = rs.getString("chameleon");
              if (chamStr.equals("")) {
                sender.sendMessage(plugin.pluginName + " Could not find the Chameleon Circuit!");
                return false;
              } else {
                int x, y, z;
                String[] chamData = chamStr.split(":");
                World w = plugin.getServer().getWorld(chamData[0]);
                TARDISConstants.COMPASS d =
                    TARDISConstants.COMPASS.valueOf(rs.getString("direction"));
                x = plugin.utils.parseNum(chamData[1]);
                y = plugin.utils.parseNum(chamData[2]);
                z = plugin.utils.parseNum(chamData[3]);
                Block chamBlock = w.getBlockAt(x, y, z);
                Sign cs = (Sign) chamBlock.getState();
                if (args[1].equalsIgnoreCase("on")) {
                  String queryChameleon =
                      "UPDATE tardis SET chamele_on = 1 WHERE tardis_id = " + id;
                  statement.executeUpdate(queryChameleon);
                  sender.sendMessage(plugin.pluginName + " The Chameleon Circuit was turned ON!");
                  cs.setLine(3, ChatColor.GREEN + "ON");
                }
                if (args[1].equalsIgnoreCase("off")) {
                  String queryChameleon =
                      "UPDATE tardis SET chamele_on = 0 WHERE tardis_id = " + id;
                  statement.executeUpdate(queryChameleon);
                  sender.sendMessage(plugin.pluginName + " The Chameleon Circuit was turned OFF.");
                  cs.setLine(3, ChatColor.RED + "OFF");
                }
                cs.update();
              }
              rs.close();
              statement.close();
              return true;
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " Chameleon Circuit Save Error: " + e);
            }
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("occupy")) {
          if (player.hasPermission("tardis.timetravel")) {
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              ResultSet rs = service.getTardis(player.getName(), "tardis_id");
              if (!rs.next()) {
                sender.sendMessage(
                    plugin.pluginName
                        + " You must be the Timelord of the TARDIS to use this command!");
                return false;
              }
              int id = rs.getInt("tardis_id");
              rs.close();
              String queryOccupied =
                  "SELECT * FROM travellers WHERE tardis_id = "
                      + id
                      + " AND player = '"
                      + player.getName()
                      + "'";
              ResultSet rsOccupied = statement.executeQuery(queryOccupied);
              String queryOcc;
              String occupied;
              if (rsOccupied.next()) {
                queryOcc =
                    "DELETE FROM travellers WHERE tardis_id = "
                        + id
                        + " AND player = '"
                        + player.getName()
                        + "'";
                occupied = ChatColor.RED + "UNOCCUPIED";
              } else {
                queryOcc =
                    "INSERT INTO travellers (tardis_id,player) VALUES ("
                        + id
                        + ",'"
                        + player.getName()
                        + "')";
                occupied = ChatColor.GREEN + "OCCUPIED";
              }
              statement.executeUpdate(queryOcc);
              sender.sendMessage(plugin.pluginName + " TARDIS occupation was set to: " + occupied);
              return true;
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " Couldn't get TARDIS: " + e);
            }
          }
        }
        if (args[0].equalsIgnoreCase("comehere")) {
          if (player.hasPermission("tardis.timetravel")) {
            final Location eyeLocation = player.getTargetBlock(transparent, 50).getLocation();
            if (!plugin.getConfig().getBoolean("include_default_world")
                && plugin.getConfig().getBoolean("default_world")
                && eyeLocation
                    .getWorld()
                    .getName()
                    .equals(plugin.getConfig().getString("default_world_name"))) {
              sender.sendMessage(
                  plugin.pluginName
                      + " The server admin will not allow you to bring the TARDIS to this world!");
              return true;
            }
            Statement statement = null;
            ResultSet rs = null;
            try {
              Connection connection = service.getConnection();
              statement = connection.createStatement();
              rs = service.getTardis(player.getName(), "*");
              if (!rs.next()) {
                sender.sendMessage(
                    plugin.pluginName
                        + " You must be the Timelord of the TARDIS to use this command!");
                return false;
              }
              final TARDISConstants.COMPASS d =
                  TARDISConstants.COMPASS.valueOf(rs.getString("direction"));
              TARDISTimetravel tt = new TARDISTimetravel(plugin);
              int[] start_loc = tt.getStartLocation(eyeLocation, d);
              int count =
                  tt.safeLocation(
                      start_loc[0] - 3,
                      eyeLocation.getBlockY() + 1,
                      start_loc[2],
                      start_loc[1],
                      start_loc[3],
                      eyeLocation.getWorld(),
                      d);
              if (count > 0) {
                sender.sendMessage(
                    plugin.pluginName
                        + " That location would grief existing blocks! Try somewhere else!");
                return true;
              }
              if (plugin.worldGuardOnServer
                  && plugin.getConfig().getBoolean("respect_worldguard")) {
                if (plugin.wgchk.cantBuild(player, eyeLocation)) {
                  sender.sendMessage(
                      plugin.pluginName + "That location is protected by WorldGuard!");
                  return false;
                }
              }
              if (player.hasPermission("tardis.exile")) {
                String areaPerm = plugin.ta.getExileArea(player);
                if (plugin.ta.areaCheckInExile(areaPerm, eyeLocation)) {
                  sender.sendMessage(
                      plugin.pluginName
                          + "You exile status does not allow you to bring the TARDIS to this location!");
                  return false;
                }
              }
              if (plugin.ta.areaCheckLocPlayer(player, eyeLocation)) {
                sender.sendMessage(
                    plugin.pluginName
                        + "You do not have permission ["
                        + plugin.trackPerm.get(player.getName())
                        + "] to bring the TARDIS to this location!");
                plugin.trackPerm.remove(player.getName());
                return false;
              }
              Material m = player.getTargetBlock(transparent, 50).getType();
              if (m != Material.SNOW) {
                int yplusone = eyeLocation.getBlockY();
                eyeLocation.setY(yplusone + 1);
              }
              // set save location
              final Player p = player;
              final int id = rs.getInt("tardis_id");
              String badsave = rs.getString("save");
              boolean chamtmp;
              if (!plugin.getConfig().getBoolean("chameleon")) {
                chamtmp = false;
              } else {
                chamtmp = rs.getBoolean("chamele_on");
              }
              final boolean cham = chamtmp;
              String[] saveData = badsave.split(":");
              World w = plugin.getServer().getWorld(saveData[0]);
              int x, y, z;
              x = plugin.utils.parseNum(saveData[1]);
              y = plugin.utils.parseNum(saveData[2]);
              z = plugin.utils.parseNum(saveData[3]);
              final Location oldSave = w.getBlockAt(x, y, z).getLocation();
              String comehere =
                  eyeLocation.getWorld().getName()
                      + ":"
                      + eyeLocation.getBlockX()
                      + ":"
                      + eyeLocation.getBlockY()
                      + ":"
                      + eyeLocation.getBlockZ();
              String querySave =
                  "UPDATE tardis SET save = '"
                      + comehere
                      + "', current = '"
                      + comehere
                      + "' WHERE tardis_id = "
                      + id;
              statement.executeUpdate(querySave);
              // how many travellers are in the TARDIS?
              plugin.utils.updateTravellerCount(id);
              sender.sendMessage(plugin.pluginName + " The TARDIS is coming...");
              long delay = 100L;
              if (plugin.getServer().getPluginManager().getPlugin("Spout") != null
                  && SpoutManager.getPlayer(player).isSpoutCraftEnabled()) {
                SpoutManager.getSoundManager()
                    .playCustomSoundEffect(
                        plugin,
                        SpoutManager.getPlayer(player),
                        "https://dl.dropbox.com/u/53758864/tardis_land.mp3",
                        false,
                        eyeLocation,
                        9,
                        75);
                delay = 400L;
              }
              Bukkit.getServer()
                  .getScheduler()
                  .scheduleSyncDelayedTask(
                      plugin,
                      new Runnable() {
                        @Override
                        public void run() {
                          plugin.destroyer.destroySign(oldSave, d);
                          plugin.destroyer.destroyTorch(oldSave);
                          plugin.destroyer.destroyBlueBox(oldSave, d, id, false);
                          plugin.builder.buildOuterTARDIS(id, eyeLocation, d, cham, p, false);
                        }
                      },
                      delay);

            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + "Couldn't get TARDIS: " + e);
            } finally {
              try {
                if (rs != null) {
                  rs.close();
                }
                if (statement != null) {
                  statement.close();
                }
              } catch (Exception e) {
              }
            }
            return true;
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("home")) {
          if (player.hasPermission("tardis.timetravel")) {
            Location eyeLocation = player.getTargetBlock(transparent, 50).getLocation();
            if (!plugin.getConfig().getBoolean("include_default_world")
                && plugin.getConfig().getBoolean("default_world")
                && eyeLocation
                    .getWorld()
                    .getName()
                    .equals(plugin.getConfig().getString("default_world_name"))) {
              sender.sendMessage(
                  plugin.pluginName
                      + " The server admin will not allow you to set the TARDIS home in this world!");
              return true;
            }
            if (plugin.worldGuardOnServer && plugin.getConfig().getBoolean("respect_worldguard")) {
              if (plugin.wgchk.cantBuild(player, eyeLocation)) {
                sender.sendMessage(plugin.pluginName + "That location is protected by WorldGuard!");
                return false;
              }
            }
            if (plugin.ta.areaCheckLocPlayer(player, eyeLocation)) {
              sender.sendMessage(
                  plugin.pluginName
                      + "You do not have permission ["
                      + plugin.trackPerm.get(player.getName())
                      + "] to set the TARDIS home to this location!");
              plugin.trackPerm.remove(player.getName());
              return false;
            }
            Material m = player.getTargetBlock(transparent, 50).getType();
            if (m != Material.SNOW) {
              int yplusone = eyeLocation.getBlockY();
              eyeLocation.setY(yplusone + 1);
            }
            // set save location
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              ResultSet rs = service.getTardis(player.getName(), "*");
              if (!rs.next()) {
                sender.sendMessage(
                    plugin.pluginName
                        + " You must be the Timelord of the TARDIS to use this command!");
                return false;
              }
              int id = rs.getInt("tardis_id");
              rs.close();
              String sethome =
                  eyeLocation.getWorld().getName()
                      + ":"
                      + eyeLocation.getBlockX()
                      + ":"
                      + eyeLocation.getBlockY()
                      + ":"
                      + eyeLocation.getBlockZ();
              String querySave =
                  "UPDATE tardis SET home = '" + sethome + "' WHERE tardis_id = " + id;
              statement.executeUpdate(querySave);
              statement.close();
              sender.sendMessage(plugin.pluginName + " The new TARDIS home was set!");
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + "Couldn't get TARDIS: " + e);
            }
            return true;
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("update")) {
          if (player.hasPermission("tardis.update")) {
            String[] validBlockNames = {
              "door",
              "button",
              "save-repeater",
              "x-repeater",
              "z-repeater",
              "y-repeater",
              "chameleon",
              "save-sign"
            };
            if (args.length < 2) {
              sender.sendMessage(plugin.pluginName + " Too few command arguments!");
              return false;
            }
            if (!Arrays.asList(validBlockNames).contains(args[1].toLowerCase(Locale.ENGLISH))) {
              player.sendMessage(
                  plugin.pluginName
                      + " That is not a valid TARDIS block name! Try one of : door|button|save-repeater|x-repeater|z-repeater|y-repeater|chameleon|save-sign");
              return false;
            }
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              String queryInTARDIS =
                  "SELECT tardis.owner, travellers.player FROM tardis, travellers WHERE travellers.player = '"
                      + player.getName()
                      + "' AND travellers.tardis_id = tardis.tardis_id AND travellers.player = tardis.owner";
              ResultSet rs = statement.executeQuery(queryInTARDIS);
              if (rs == null || !rs.next()) {
                sender.sendMessage(
                    plugin.pluginName
                        + " Either you are not a Timelord, or you are not inside your TARDIS. You need to be both to run this command!");
                return false;
              }
              rs.close();
              statement.close();
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " Update TARDIS Blocks Error: " + e);
            }
            plugin.trackPlayers.put(player.getName(), args[1].toLowerCase());
            player.sendMessage(
                plugin.pluginName
                    + " Click the TARDIS "
                    + args[1].toLowerCase()
                    + " to update its position.");
            return true;
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("rebuild") || args[0].equalsIgnoreCase("hide")) {
          if (player.hasPermission("tardis.rebuild")) {
            String save = "";
            World w;
            int x, y, z, id = -1;
            TARDISConstants.COMPASS d = TARDISConstants.COMPASS.EAST;
            boolean cham = false;
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              ResultSet rs = service.getTardis(player.getName(), "*");
              if (!rs.next()) {
                sender.sendMessage(plugin.pluginName + " " + TARDISConstants.NO_TARDIS);
                return false;
              }
              save = rs.getString("save");
              id = rs.getInt("tardis_id");
              if (!plugin.getConfig().getBoolean("chameleon")) {
                cham = false;
              } else {
                cham = rs.getBoolean("chamele_on");
              }
              d = TARDISConstants.COMPASS.valueOf(rs.getString("direction"));
              rs.close();
              statement.close();
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " Select TARDIS By Owner Error: " + e);
            }
            String[] save_data = save.split(":");
            w = plugin.getServer().getWorld(save_data[0]);
            x = plugin.utils.parseNum(save_data[1]);
            y = plugin.utils.parseNum(save_data[2]);
            z = plugin.utils.parseNum(save_data[3]);
            Location l = new Location(w, x, y, z);
            if (args[0].equalsIgnoreCase("rebuild")) {
              plugin.builder.buildOuterTARDIS(id, l, d, cham, player, true);
              sender.sendMessage(plugin.pluginName + " The TARDIS Police Box was rebuilt!");
              return true;
            }
            if (args[0].equalsIgnoreCase("hide")) {
              // remove torch
              plugin.destroyer.destroyTorch(l);
              // remove sign
              plugin.destroyer.destroySign(l, d);
              // remove blue box
              plugin.destroyer.destroyBlueBox(l, d, id, true);
              sender.sendMessage(
                  plugin.pluginName
                      + " The TARDIS Police Box was hidden! Use "
                      + ChatColor.GREEN
                      + "/tardis rebuild"
                      + ChatColor.RESET
                      + " to show it again.");
              return true;
            }
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("list")) {
          if (player.hasPermission("tardis.list")) {
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              ResultSet rs = service.getTardis(player.getName(), "owner");
              if (rs == null || !rs.next()) {
                sender.sendMessage(plugin.pluginName + " " + TARDISConstants.NO_TARDIS);
                return false;
              }
              if (args.length < 2
                  || (!args[1].equalsIgnoreCase("saves")
                      && !args[1].equalsIgnoreCase("companions")
                      && !args[1].equalsIgnoreCase("areas"))) {
                sender.sendMessage(
                    plugin.pluginName
                        + " You need to specify which TARDIS list you want to view! [saves|companions|areas]");
                return false;
              }
              TARDISConstants.list(player, args[1]);
              rs.close();
              statement.close();
              return true;
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " List Companions Error: " + e);
            }
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("find")) {
          if (player.hasPermission("tardis.find")) {
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              ResultSet rs = service.getTardis(player.getName(), "save");
              if (rs == null || !rs.next()) {
                sender.sendMessage(plugin.pluginName + " " + TARDISConstants.NO_TARDIS);
                return false;
              }
              String loc = rs.getString("save");
              String[] findData = loc.split(":");
              sender.sendMessage(
                  plugin.pluginName
                      + " TARDIS was left at "
                      + findData[0]
                      + " at x: "
                      + findData[1]
                      + " y: "
                      + findData[2]
                      + " z: "
                      + findData[3]);
              rs.close();
              statement.close();
              return true;
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " Find TARDIS Error: " + e);
            }
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("add")) {
          if (player.hasPermission("tardis.add")) {
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              String queryList =
                  "SELECT tardis_id, companions FROM tardis WHERE owner = '"
                      + player.getName()
                      + "'";
              ResultSet rs = statement.executeQuery(queryList);
              String comps;
              int id;
              if (!rs.next()) {
                sender.sendMessage(plugin.pluginName + " " + TARDISConstants.NO_TARDIS);
                return false;
              } else {
                id = rs.getInt("tardis_id");
                comps = rs.getString("companions");
              }
              if (args.length < 2) {
                sender.sendMessage(plugin.pluginName + " Too few command arguments!");
                return false;
              }
              if (!args[1].matches("[A-Za-z0-9_]{2,16}")) {
                sender.sendMessage(
                    plugin.pluginName + "That doesn't appear to be a valid username");
                return false;
              } else {
                String queryCompanions;
                if (!rs.wasNull() && !comps.equals("")) {
                  // add to the list
                  String newList = comps + ":" + args[1].toLowerCase();
                  queryCompanions =
                      "UPDATE tardis SET companions = '" + newList + "' WHERE tardis_id = " + id;
                } else {
                  // make a list
                  queryCompanions =
                      "UPDATE tardis SET companions = '"
                          + args[1].toLowerCase()
                          + "' WHERE tardis_id = "
                          + id;
                }
                statement.executeUpdate(queryCompanions);
                player.sendMessage(
                    plugin.pluginName
                        + " You added "
                        + ChatColor.GREEN
                        + args[1]
                        + ChatColor.RESET
                        + " as a TARDIS companion.");
                rs.close();
                statement.close();
                return true;
              }
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " Companion Save Error: " + e);
            }
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("remove")) {
          if (player.hasPermission("tardis.add")) {
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              String queryList =
                  "SELECT tardis_id, companions FROM tardis WHERE owner = '"
                      + player.getName()
                      + "'";
              ResultSet rs = statement.executeQuery(queryList);
              String comps;
              int id;
              if (rs == null || !rs.next()) {
                sender.sendMessage(plugin.pluginName + " " + TARDISConstants.NO_TARDIS);
                return false;
              } else {
                id = rs.getInt("tardis_id");
                comps = rs.getString("companions");
                if (rs.wasNull() || comps.equals("")) {
                  sender.sendMessage(
                      plugin.pluginName + " You have not added any TARDIS companions yet!");
                  return true;
                }
                rs.close();
              }
              if (args.length < 2) {
                sender.sendMessage(plugin.pluginName + " Too few command arguments!");
                return false;
              }
              if (!args[1].matches("[A-Za-z0-9_]{2,16}")) {
                sender.sendMessage(
                    plugin.pluginName + "That doesn't appear to be a valid username");
                return false;
              } else {
                String[] split = comps.split(":");
                StringBuilder buf = new StringBuilder();
                String newList = "";
                if (split.length > 1) {
                  // recompile string without the specified player
                  for (String c : split) {
                    if (!c.equals(args[1].toLowerCase())) {
                      // add to new string
                      buf.append(c).append(":");
                    }
                  }
                  // remove trailing colon
                  newList = buf.toString();
                  newList = newList.substring(0, newList.length() - 1);
                } else {
                  newList = "";
                }
                String queryCompanions =
                    "UPDATE tardis SET companions = '" + newList + "' WHERE tardis_id = " + id;
                statement.executeUpdate(queryCompanions);
                player.sendMessage(
                    plugin.pluginName
                        + " You removed "
                        + ChatColor.GREEN
                        + args[1]
                        + ChatColor.RESET
                        + " as a TARDIS companion.");
                statement.close();
                return true;
              }
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " Companion Save Error: " + e);
            }
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("save")) {
          if (player.hasPermission("tardis.save")) {
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              ResultSet rs = service.getTardis(player.getName(), "*");
              if (rs == null || !rs.next()) {
                sender.sendMessage(plugin.pluginName + " " + TARDISConstants.NO_TARDIS);
                return false;
              }
              if (args.length < 2) {
                sender.sendMessage(plugin.pluginName + " Too few command arguments!");
                return false;
              }
              if (!args[1].matches("[A-Za-z0-9_]{2,16}")) {
                sender.sendMessage(
                    plugin.pluginName
                        + "That doesn't appear to be a valid save name (it may be too long or contains spaces).");
                return false;
              } else {
                String cur = rs.getString("current");
                String sav = rs.getString("save");
                int id = rs.getInt("tardis_id");
                String[] curDest;
                // get current destination
                String queryTraveller =
                    "SELECT * FROM travellers WHERE player = '" + player.getName() + "'";
                ResultSet rsTraveller = statement.executeQuery(queryTraveller);
                if (rsTraveller != null && rsTraveller.next()) {
                  // inside TARDIS
                  curDest = cur.split(":");
                } else {
                  // outside TARDIS
                  curDest = sav.split(":");
                }
                PreparedStatement psSave =
                    connection.prepareStatement(
                        "INSERT INTO destinations (tardis_id,dest_name, world, x, y, z) VALUES (?,?,?,?,?,?)");
                psSave.setInt(1, id);
                psSave.setString(2, args[1]);
                psSave.setString(3, curDest[0]);
                psSave.setInt(4, plugin.utils.parseNum(curDest[1]));
                psSave.setInt(5, plugin.utils.parseNum(curDest[2]));
                psSave.setInt(6, plugin.utils.parseNum(curDest[3]));
                psSave.executeUpdate();
                rs.close();
                rsTraveller.close();
                statement.close();
                psSave.close();
                sender.sendMessage(
                    plugin.pluginName + " The location '" + args[1] + "' was saved successfully.");
                return true;
              }
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " Location Save Error: " + e);
            }
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("removesave")) {
          if (player.hasPermission("tardis.save")) {
            if (args.length < 2) {
              sender.sendMessage(plugin.pluginName + " Too few command arguments!");
              return false;
            }
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              ResultSet rs = service.getTardis(player.getName(), "tardis_id");
              if (rs == null || !rs.next()) {
                sender.sendMessage(plugin.pluginName + " " + TARDISConstants.NO_TARDIS);
                return false;
              }
              int id = rs.getInt("tardis_id");
              String queryDest =
                  "SELECT dest_id FROM destinations WHERE dest_name = '"
                      + args[1]
                      + "' AND tardis_id = "
                      + id;
              ResultSet rsDest = statement.executeQuery(queryDest);
              if (rsDest == null || !rsDest.next()) {
                sender.sendMessage(
                    plugin.pluginName + " Could not find a saved destination with that name!");
                return false;
              }
              int destID = rsDest.getInt("dest_id");
              String queryDelete = "DELETE FROM destinations WHERE dest_id = " + destID;
              statement.executeUpdate(queryDelete);
              sender.sendMessage(
                  plugin.pluginName + " The destination " + args[1] + " was deleted!");
              return true;
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " Destination Save Error: " + e);
            }
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("setdest")) {
          if (player.hasPermission("tardis.save")) {
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              ResultSet rs = service.getTardis(player.getName(), "*");
              if (rs == null || !rs.next()) {
                sender.sendMessage(plugin.pluginName + " " + TARDISConstants.NO_TARDIS);
                return false;
              }
              if (args.length < 2) {
                sender.sendMessage(plugin.pluginName + " Too few command arguments!");
                return false;
              }
              if (!args[1].matches("[A-Za-z0-9_]{2,16}")) {
                sender.sendMessage(
                    plugin.pluginName
                        + "The destination name must be between 2 and 16 characters and have no spaces!");
                return false;
              } else {
                int id = rs.getInt("tardis_id");
                // get location player is looking at
                Block b = player.getTargetBlock(transparent, 50);
                Location l = b.getLocation();
                if (!plugin.getConfig().getBoolean("include_default_world")
                    && plugin.getConfig().getBoolean("default_world")
                    && l.getWorld()
                        .getName()
                        .equals(plugin.getConfig().getString("default_world_name"))) {
                  sender.sendMessage(
                      plugin.pluginName
                          + " The server admin will not allow you to set the TARDIS destination to this world!");
                  return true;
                }
                if (plugin.worldGuardOnServer
                    && plugin.getConfig().getBoolean("respect_worldguard")) {
                  if (plugin.wgchk.cantBuild(player, l)) {
                    sender.sendMessage(
                        plugin.pluginName + "That location is protected by WorldGuard!");
                    return false;
                  }
                }
                if (player.hasPermission("tardis.exile")) {
                  String areaPerm = plugin.ta.getExileArea(player);
                  if (plugin.ta.areaCheckInExile(areaPerm, l)) {
                    sender.sendMessage(
                        plugin.pluginName
                            + "You exile status does not allow you to save the TARDIS to this location!");
                    return false;
                  }
                }
                if (plugin.ta.areaCheckLocPlayer(player, l)) {
                  sender.sendMessage(
                      plugin.pluginName
                          + "You do not have permission ["
                          + plugin.trackPerm.get(player.getName())
                          + "] to set the TARDIS destination to this location!");
                  plugin.trackPerm.remove(player.getName());
                  return false;
                }
                String dw = l.getWorld().getName();
                int dx = l.getBlockX();
                int dy = l.getBlockY() + 1;
                int dz = l.getBlockZ();
                PreparedStatement psSetDest =
                    connection.prepareStatement(
                        "INSERT INTO destinations (tardis_id, dest_name, world, x, y, z) VALUES (?,?,?,?,?,?)");
                psSetDest.setInt(1, id);
                psSetDest.setString(2, args[1]);
                psSetDest.setString(3, dw);
                psSetDest.setInt(4, dx);
                psSetDest.setInt(5, dy);
                psSetDest.setInt(6, dz);
                psSetDest.executeUpdate();
                rs.close();
                statement.close();
                psSetDest.close();
                sender.sendMessage(
                    plugin.pluginName
                        + " The destination '"
                        + args[1]
                        + "' was saved successfully.");
                return true;
              }
            } catch (SQLException e) {
              plugin.console.sendMessage(plugin.pluginName + " Destination Save Error: " + e);
            }
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("direction")) {
          if (player.hasPermission("tardis.timetravel")) {
            if (args.length < 2
                || (!args[1].equalsIgnoreCase("north")
                    && !args[1].equalsIgnoreCase("west")
                    && !args[1].equalsIgnoreCase("south")
                    && !args[1].equalsIgnoreCase("east"))) {
              sender.sendMessage(
                  plugin.pluginName
                      + " You need to specify the compass direction e.g. north, west, south or east!");
              return false;
            }
            try {
              Connection connection = service.getConnection();
              Statement statement = connection.createStatement();
              ResultSet rs = service.getTardis(player.getName(), "*");
              if (rs == null || !rs.next()) {
                sender.sendMessage(plugin.pluginName + " " + TARDISConstants.NO_TARDIS);
                return false;
              }
              String save = rs.getString("save");
              String[] save_data = save.split(":");
              int id = rs.getInt("tardis_id");
              boolean cham;
              if (!plugin.getConfig().getBoolean("chameleon")) {
                cham = false;
              } else {
                cham = rs.getBoolean("chamele_on");
              }
              String dir = args[1].toUpperCase();
              TARDISConstants.COMPASS old_d =
                  TARDISConstants.COMPASS.valueOf(rs.getString("direction"));

              String queryDirectionUpdate =
                  "UPDATE tardis SET direction = '" + dir + "' WHERE tardis_id = " + id;
              statement.executeUpdate(queryDirectionUpdate);
              String queryDoorDirectionUpdate =
                  "UPDATE doors SET door_direction = '"
                      + dir
                      + "' WHERE door_type = 0 AND tardis_id = "
                      + id;
              statement.executeUpdate(queryDoorDirectionUpdate);
              World w = plugin.getServer().getWorld(save_data[0]);
              int x = plugin.utils.parseNum(save_data[1]);
              int y = plugin.utils.parseNum(save_data[2]);
              int z = plugin.utils.parseNum(save_data[3]);
              Location l = new Location(w, x, y, z);
              TARDISConstants.COMPASS d = TARDISConstants.COMPASS.valueOf(dir);
              plugin.destroyer.destroySign(l, old_d);
              plugin.builder.buildOuterTARDIS(id, l, d, cham, player, true);
              rs.close();
              statement.close();
              return true;
            } catch (SQLException e) {
              plugin.console.sendMessage(
                  plugin.pluginName + " Quotes Preferences Save Error: " + e);
            }
          } else {
            sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);
            return false;
          }
        }
        if (args[0].equalsIgnoreCase("namekey")) {
          Material m = Material.getMaterial(plugin.getConfig().getString("key"));
          ItemStack is = player.getItemInHand();
          if (!is.getType().equals(m)) {
            sender.sendMessage(plugin.pluginName + "You can only rename the TARDIS key!");
            return false;
          }
          int count = args.length;
          if (count < 2) {
            return false;
          }
          StringBuilder buf = new StringBuilder(args[1]);
          for (int i = 2; i < count; i++) {
            buf.append(" ").append(args[i]);
          }
          String tmp = buf.toString();
          if (is != null) {
            TARDISItemRenamer ir = new TARDISItemRenamer(is);
            ir.setName(tmp, false);
          }
          sender.sendMessage(plugin.pluginName + "TARDIS key renamed to '" + tmp + "'");
          return true;
        }
        if (args[0].equalsIgnoreCase("help")) {
          if (args.length == 1) {
            sender.sendMessage(TARDISConstants.COMMANDS.split("\n"));
            return true;
          }
          if (args.length == 2) {
            switch (TARDISConstants.fromString(args[1])) {
              case CREATE:
                sender.sendMessage(TARDISConstants.COMMAND_CREATE.split("\n"));
                break;
              case DELETE:
                sender.sendMessage(TARDISConstants.COMMAND_DELETE.split("\n"));
                break;
              case TIMETRAVEL:
                sender.sendMessage(TARDISConstants.COMMAND_TIMETRAVEL.split("\n"));
                break;
              case LIST:
                sender.sendMessage(TARDISConstants.COMMAND_LIST.split("\n"));
                break;
              case FIND:
                sender.sendMessage(TARDISConstants.COMMAND_FIND.split("\n"));
                break;
              case SAVE:
                sender.sendMessage(TARDISConstants.COMMAND_SAVE.split("\n"));
                break;
              case REMOVESAVE:
                sender.sendMessage(TARDISConstants.COMMAND_REMOVESAVE.split("\n"));
                break;
              case ADD:
                sender.sendMessage(TARDISConstants.COMMAND_ADD.split("\n"));
                break;
              case TRAVEL:
                sender.sendMessage(TARDISConstants.COMMAND_TRAVEL.split("\n"));
                break;
              case UPDATE:
                sender.sendMessage(TARDISConstants.COMMAND_UPDATE.split("\n"));
                break;
              case REBUILD:
                sender.sendMessage(TARDISConstants.COMMAND_REBUILD.split("\n"));
                break;
              case CHAMELEON:
                sender.sendMessage(TARDISConstants.COMMAND_CHAMELEON.split("\n"));
                break;
              case SFX:
                sender.sendMessage(TARDISConstants.COMMAND_SFX.split("\n"));
                break;
              case PLATFORM:
                sender.sendMessage(TARDISConstants.COMMAND_PLATFORM.split("\n"));
                break;
              case SETDEST:
                sender.sendMessage(TARDISConstants.COMMAND_SETDEST.split("\n"));
                break;
              case HOME:
                sender.sendMessage(TARDISConstants.COMMAND_HOME.split("\n"));
                break;
              case HIDE:
                sender.sendMessage(TARDISConstants.COMMAND_HIDE.split("\n"));
                break;
              case VERSION:
                sender.sendMessage(TARDISConstants.COMMAND_HIDE.split("\n"));
                break;
              case ADMIN:
                sender.sendMessage(TARDISConstants.COMMAND_ADMIN.split("\n"));
                break;
              case AREA:
                sender.sendMessage(TARDISConstants.COMMAND_AREA.split("\n"));
                break;
              default:
                sender.sendMessage(TARDISConstants.COMMANDS.split("\n"));
            }
          }
          return true;
        }
      }
    }
    // If the above has happened the function will break and return true. if this hasn't happened
    // then value of false will be returned.
    return false;
  }
  @EventHandler(priority = EventPriority.HIGH)
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    switch (event.getAction()) {
      case RIGHT_CLICK_AIR:
      case RIGHT_CLICK_BLOCK:
        {
          switch (event.getMaterial()) {
            case WATER_BUCKET:
              {
                if (!TotalFreedomMod.allowWaterPlace) {
                  player
                      .getInventory()
                      .setItem(
                          player.getInventory().getHeldItemSlot(),
                          new ItemStack(Material.COOKIE, 1));
                  player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
                  event.setCancelled(true);
                }
                break;
              }
            case LAVA_BUCKET:
              {
                if (!TotalFreedomMod.allowLavaPlace) {
                  player
                      .getInventory()
                      .setItem(
                          player.getInventory().getHeldItemSlot(),
                          new ItemStack(Material.COOKIE, 1));
                  player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
                  event.setCancelled(true);
                }
                break;
              }
            case EXPLOSIVE_MINECART:
              {
                if (!TotalFreedomMod.allowTntMinecarts) {
                  player.getInventory().clear(player.getInventory().getHeldItemSlot());
                  player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
                  event.setCancelled(true);
                }
                break;
              }
          }
          break;
        }
      case LEFT_CLICK_AIR:
      case LEFT_CLICK_BLOCK:
        {
          switch (event.getMaterial()) {
            case STICK:
              {
                TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
                if (playerdata.mobThrowerEnabled()) {
                  Location player_pos = player.getLocation();
                  Vector direction = player_pos.getDirection().normalize();

                  LivingEntity rezzed_mob =
                      (LivingEntity)
                          player
                              .getWorld()
                              .spawnEntity(
                                  player_pos.add(direction.multiply(2.0)),
                                  playerdata.mobThrowerCreature());
                  rezzed_mob.setVelocity(direction.multiply(playerdata.mobThrowerSpeed()));
                  playerdata.enqueueMob(rezzed_mob);

                  event.setCancelled(true);
                }
                break;
              }
            case SULPHUR:
              {
                TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
                if (playerdata.isMP44Armed()) {
                  if (playerdata.toggleMP44Firing()) {
                    playerdata.startArrowShooter(TotalFreedomMod.plugin);
                  } else {
                    playerdata.stopArrowShooter();
                  }

                  event.setCancelled(true);
                }
                break;
              }
            case BLAZE_ROD:
              {
                if (TotalFreedomMod.allowExplosions) {
                  if (TFM_SuperadminList.isSeniorAdmin(player, true)) {
                    Block target_block;

                    if (event.getAction().equals(Action.LEFT_CLICK_AIR)) {
                      target_block = player.getTargetBlock(null, 120);
                    } else {
                      target_block = event.getClickedBlock();
                    }

                    if (target_block != null) {
                      player.getWorld().createExplosion(target_block.getLocation(), 4F, true);
                      player.getWorld().strikeLightning(target_block.getLocation());
                    } else {
                      player.sendMessage("Can't resolve target block.");
                    }

                    event.setCancelled(true);
                  }
                }
                break;
              }
            case CARROT:
              {
                if (TotalFreedomMod.allowExplosions) {
                  if (TFM_SuperadminList.isSeniorAdmin(player, true)) {
                    Location player_location = player.getLocation().clone();

                    Vector player_pos = player_location.toVector().add(new Vector(0.0, 1.65, 0.0));
                    Vector player_dir = player_location.getDirection().normalize();

                    double distance = 150.0;
                    Block target_block = player.getTargetBlock(null, Math.round((float) distance));
                    if (target_block != null) {
                      distance = player_location.distance(target_block.getLocation());
                    }

                    final List<Block> affected = new ArrayList<Block>();

                    Block last_block = null;
                    for (double offset = 0.0; offset <= distance; offset += (distance / 25.0)) {
                      Block test_block =
                          player_pos
                              .clone()
                              .add(player_dir.clone().multiply(offset))
                              .toLocation(player.getWorld())
                              .getBlock();

                      if (!test_block.equals(last_block)) {
                        if (test_block.isEmpty()) {
                          affected.add(test_block);
                          test_block.setType(Material.TNT);
                        } else {
                          break;
                        }
                      }

                      last_block = test_block;
                    }

                    new BukkitRunnable() {
                      @Override
                      public void run() {
                        for (Block tnt_block : affected) {
                          TNTPrimed tnt_primed =
                              tnt_block.getWorld().spawn(tnt_block.getLocation(), TNTPrimed.class);
                          tnt_primed.setFuseTicks(5);
                          tnt_block.setType(Material.AIR);
                        }
                      }
                    }.runTaskLater(TotalFreedomMod.plugin, 30L);

                    event.setCancelled(true);
                  }
                }
                break;
              }
          }
          break;
        }
    }
  }
  @EventHandler(priority = EventPriority.HIGH)
  public void onPlayerInteract(PlayerInteractEvent event) {
    final Player player = event.getPlayer();
    final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);

    switch (event.getAction()) {
      case RIGHT_CLICK_AIR:
      case RIGHT_CLICK_BLOCK:
        {
          switch (event.getMaterial()) {
            case WATER_BUCKET:
              {
                if (TFM_ConfigEntry.ALLOW_WATER_PLACE.getBoolean()) {
                  break;
                }

                player
                    .getInventory()
                    .setItem(
                        player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
                player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
                event.setCancelled(true);
                break;
              }

            case LAVA_BUCKET:
              {
                if (TFM_ConfigEntry.ALLOW_LAVA_PLACE.getBoolean()) {
                  break;
                }

                player
                    .getInventory()
                    .setItem(
                        player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
                player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
                event.setCancelled(true);
                break;
              }

            case EXPLOSIVE_MINECART:
              {
                if (TFM_ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean()) {
                  break;
                }

                player.getInventory().clear(player.getInventory().getHeldItemSlot());
                player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
                event.setCancelled(true);
                break;
              }
          }
          break;
        }

      case LEFT_CLICK_AIR:
      case LEFT_CLICK_BLOCK:
        {
          switch (event.getMaterial()) {
            case STICK:
              {
                if (!TFM_AdminList.isSuperAdmin(player)) {
                  break;
                }

                event.setCancelled(true);

                final Location location = player.getTargetBlock(null, 5).getLocation();
                final List<RollbackEntry> entries =
                    TFM_RollbackManager.getEntriesAtLocation(location);

                if (entries.isEmpty()) {
                  TFM_Util.playerMsg(player, "No block edits at that location.");
                  break;
                }

                TFM_Util.playerMsg(
                    player,
                    "Block edits at ("
                        + ChatColor.WHITE
                        + "x"
                        + location.getBlockX()
                        + ", y"
                        + location.getBlockY()
                        + ", z"
                        + location.getBlockZ()
                        + ChatColor.BLUE
                        + ")"
                        + ChatColor.WHITE
                        + ":",
                    ChatColor.BLUE);
                for (RollbackEntry entry : entries) {
                  TFM_Util.playerMsg(
                      player,
                      " - "
                          + ChatColor.BLUE
                          + entry.author
                          + " "
                          + entry.getType()
                          + " "
                          + StringUtils.capitalize(entry.getMaterial().toString().toLowerCase())
                          + (entry.data == 0 ? "" : ":" + entry.data));
                }

                break;
              }

            case BONE:
              {
                if (!playerdata.mobThrowerEnabled()) {
                  break;
                }

                Location player_pos = player.getLocation();
                Vector direction = player_pos.getDirection().normalize();

                LivingEntity rezzed_mob =
                    (LivingEntity)
                        player
                            .getWorld()
                            .spawnEntity(
                                player_pos.add(direction.multiply(2.0)),
                                playerdata.mobThrowerCreature());
                rezzed_mob.setVelocity(direction.multiply(playerdata.mobThrowerSpeed()));
                playerdata.enqueueMob(rezzed_mob);

                event.setCancelled(true);
                break;
              }

            case SULPHUR:
              {
                if (!playerdata.isMP44Armed()) {
                  break;
                }

                event.setCancelled(true);

                if (playerdata.toggleMP44Firing()) {
                  playerdata.startArrowShooter(TotalFreedomMod.plugin);
                } else {
                  playerdata.stopArrowShooter();
                }
                break;
              }

            case BLAZE_ROD:
              {
                if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) {
                  break;
                }

                if (!TFM_AdminList.isSeniorAdmin(player, true)) {
                  break;
                }

                event.setCancelled(true);
                Block targetBlock;

                if (event.getAction().equals(Action.LEFT_CLICK_AIR)) {
                  targetBlock = player.getTargetBlock(null, 120);
                } else {
                  targetBlock = event.getClickedBlock();
                }

                if (targetBlock == null) {
                  player.sendMessage("Can't resolve target block.");
                  break;
                }

                player.getWorld().createExplosion(targetBlock.getLocation(), 4F, true);
                player.getWorld().strikeLightning(targetBlock.getLocation());

                break;
              }

            case CARROT:
              {
                if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) {
                  break;
                }

                if (!TFM_AdminList.isSeniorAdmin(player, true)) {
                  break;
                }

                Location location = player.getLocation().clone();

                Vector playerPostion = location.toVector().add(new Vector(0.0, 1.65, 0.0));
                Vector playerDirection = location.getDirection().normalize();

                double distance = 150.0;
                Block targetBlock = player.getTargetBlock(null, Math.round((float) distance));
                if (targetBlock != null) {
                  distance = location.distance(targetBlock.getLocation());
                }

                final List<Block> affected = new ArrayList<Block>();

                Block lastBlock = null;
                for (double offset = 0.0; offset <= distance; offset += (distance / 25.0)) {
                  Block block =
                      playerPostion
                          .clone()
                          .add(playerDirection.clone().multiply(offset))
                          .toLocation(player.getWorld())
                          .getBlock();

                  if (!block.equals(lastBlock)) {
                    if (block.isEmpty()) {
                      affected.add(block);
                      block.setType(Material.TNT);
                    } else {
                      break;
                    }
                  }

                  lastBlock = block;
                }

                new BukkitRunnable() {
                  @Override
                  public void run() {
                    for (Block tntBlock : affected) {
                      TNTPrimed tnt =
                          tntBlock.getWorld().spawn(tntBlock.getLocation(), TNTPrimed.class);
                      tnt.setFuseTicks(5);
                      tntBlock.setType(Material.AIR);
                    }
                  }
                }.runTaskLater(TotalFreedomMod.plugin, 30L);

                event.setCancelled(true);
                break;
              }
          }
          break;
        }
    }
  }
  public SkillResult use(Hero hero, String[] args) {
    Player player = hero.getPlayer();

    int duration =
        SkillConfigManager.getUseSetting(
            hero, this, SkillSetting.DURATION, Integer.valueOf(10000), false);
    duration +=
        SkillConfigManager.getUseSetting(
                hero, this, SkillSetting.DURATION_INCREASE, Integer.valueOf(10), false)
            * hero.getSkillLevel(this);

    duration = duration / 1000;
    duration = duration * 20;

    Block block = player.getTargetBlock(null, 40);
    Location loc = block.getLocation();

    Location loc1 =
        new Location(
            loc.getWorld(),
            loc.getBlockX() + 7,
            loc.getWorld().getMaxHeight() - 100,
            loc.getBlockZ() + 7);
    Location loc2 =
        new Location(
            loc.getWorld(),
            loc.getBlockX() - 7,
            loc.getWorld().getMaxHeight() - 100,
            loc.getBlockZ() - 7);

    final CuboidArea ca = new CuboidArea(loc1, loc2);
    final Hero her = hero;

    HashSet<Arrow> ars = new HashSet<Arrow>();
    arrows.put(hero, ars);

    final int id =
        Bukkit.getScheduler()
            .scheduleSyncRepeatingTask(
                plugin,
                new Runnable() {
                  public void run() {
                    Location loc = ca.getRandomLocation();
                    Arrow arrow = loc.getWorld().spawn(loc, Arrow.class);
                    arrow.setShooter(her.getPlayer());
                    arrow.setVelocity(new Vector(0, -2, 0));
                    arrow.setBounce(false);
                    arrow.setDamage(her.getHeroClass().getProjectileDamage(ProjectileType.ARROW));
                    final Arrow ar = arrow;
                    Bukkit.getScheduler()
                        .scheduleSyncDelayedTask(
                            plugin,
                            new Runnable() {
                              public void run() {
                                ar.remove();
                              }
                            },
                            20L * 6);

                    if (arrows.containsKey(her)) {
                      arrows.get(her).add(arrow);
                    } else {
                      HashSet<Arrow> ars = new HashSet<Arrow>();
                      ars.add(arrow);
                      arrows.put(her, ars);
                    }
                  }
                },
                0L,
                2L);
    Bukkit.getScheduler()
        .scheduleSyncDelayedTask(
            plugin,
            new Runnable() {
              public void run() {
                Bukkit.getScheduler().cancelTask(id);
                broadcast(
                    her.getPlayer().getLocation(),
                    ChatColor.GRAY
                        + "["
                        + ChatColor.DARK_RED
                        + "Skill"
                        + ChatColor.GRAY
                        + "] "
                        + her.getPlayer().getDisplayName()
                        + ChatColor.GRAY
                        + " is no longer calling down arrows from the sky!");
              }
            },
            duration);
    Bukkit.getScheduler()
        .scheduleSyncDelayedTask(
            plugin,
            new Runnable() {
              public void run() {
                arrows.remove(her);
              }
            },
            duration + (20L * 5));
    broadcast(
        player.getLocation(),
        ChatColor.GRAY
            + "["
            + ChatColor.DARK_RED
            + "Skill"
            + ChatColor.GRAY
            + "] "
            + player.getDisplayName()
            + ChatColor.GRAY
            + " used "
            + ChatColor.WHITE
            + "ArrowRain"
            + ChatColor.GRAY
            + "!");
    return SkillResult.NORMAL;
  }
  @SuppressWarnings("deprecation")
  @Override
  public void run(Spawner spawner, CommandSender sender, String subCommand, String[] args) {

    if (!(sender instanceof Player)) {
      PLUGIN.sendMessage(sender, NO_CONSOLE);
      return;
    }

    Player player = (Player) sender;

    SpawnableEntity entity = null;

    String in = getValue(args, 0, "");

    if (in.isEmpty()) {
      Integer selection = CustomSpawners.entitySelection.get(player);
      if (selection == null) {
        PLUGIN.sendMessage(sender, NO_ID);
        return;
      }
      entity = CustomSpawners.getEntity(selection);
    } else {
      entity = CustomSpawners.getEntity(in);
    }

    if (entity == null) {
      PLUGIN.sendMessage(sender, NO_ID);
      return;
    }

    Block target =
        player.getTargetBlock(CustomSpawners.transparent, CONFIG.getInt("players.maxDistance", 5));

    if (target == null) {
      PLUGIN.sendMessage(
          player, ChatColor.RED + "You must look at a block to make a spawner there.");
      return;
    }

    if (target.getType().equals(Material.AIR)) {
      PLUGIN.sendMessage(
          player, ChatColor.RED + "You must look at a block to make a spawner there.");
      return;
    }

    Spawner newSpawner = PLUGIN.createSpawner(entity, target.getLocation());

    if (CONFIG.getBoolean("data.autosave") && CONFIG.getBoolean("data.saveOnCreate")) {
      PLUGIN.getFileManager().autosave(newSpawner);
    }

    // TODO Add this to wiki.
    Group addTo = null;
    if (sender instanceof Player) {
      Player p = (Player) sender;
      if (CustomSpawners.groupSelection.containsKey(p)) {
        addTo = CustomSpawners.getGroup(CustomSpawners.groupSelection.get(sender));
      }
    } else {
      if (CustomSpawners.consoleGroup != -1) {
        addTo = CustomSpawners.getGroup(CustomSpawners.consoleGroup);
      }
    }

    if (addTo != null
        && CONFIG.getBoolean("players.groupAutoAdd", false)
        && addTo.getType().equals(Group.Type.SPAWNER)) {
      addTo.addItem(newSpawner);
      PLUGIN.sendMessage(
          sender,
          ChatColor.GREEN
              + "Successfully created a new "
              + ChatColor.GOLD
              + in
              + ChatColor.GREEN
              + " spawner with ID number "
              + ChatColor.GOLD
              + newSpawner.getId()
              + ChatColor.GREEN
              + "! This spawner was added to group "
              + ChatColor.GOLD
              + PLUGIN.getFriendlyName(addTo)
              + ChatColor.GREEN
              + ".");
    }

    PLUGIN.sendMessage(
        player,
        ChatColor.GREEN
            + "Successfully created a "
            + ChatColor.GOLD
            + PLUGIN.getFriendlyName(entity)
            + ChatColor.GREEN
            + " spawner with ID "
            + ChatColor.GOLD
            + PLUGIN.getFriendlyName(newSpawner)
            + ChatColor.GREEN
            + "!");
  }
Example #29
0
 @Override
 public Block getTargetBlock(HashSet<Byte> transparent, int maxDistance) {
   return caller.getTargetBlock(transparent, maxDistance);
 }
 @SuppressWarnings("deprecation")
 public boolean doRemoteComeHere(Player player, UUID uuid) {
   Location eyeLocation =
       player.getTargetBlock(plugin.getGeneralKeeper().getTransparent(), 50).getLocation();
   if (!plugin.getConfig().getBoolean("travel.include_default_world")
       && plugin.getConfig().getBoolean("creation.default_world")
       && eyeLocation
           .getWorld()
           .getName()
           .equals(plugin.getConfig().getString("creation.default_world_name"))) {
     TARDISMessage.send(player, "NO_WORLD_TRAVEL");
     return true;
   }
   if (!plugin
       .getPluginRespect()
       .getRespect(eyeLocation, new Parameters(player, FLAG.getDefaultFlags()))) {
     return true;
   }
   if (!plugin.getTardisArea().areaCheckInExisting(eyeLocation)) {
     TARDISMessage.send(
         player,
         "AREA_NO_COMEHERE",
         ChatColor.AQUA + "/tardisremote [player] travel area [area name]");
     return true;
   }
   Material m = player.getTargetBlock(plugin.getGeneralKeeper().getTransparent(), 50).getType();
   if (m != Material.SNOW) {
     int yplusone = eyeLocation.getBlockY();
     eyeLocation.setY(yplusone + 1);
   }
   // check the world is not excluded
   String world = eyeLocation.getWorld().getName();
   if (!plugin.getConfig().getBoolean("worlds." + world)) {
     TARDISMessage.send(player, "NO_PB_IN_WORLD");
     return true;
   }
   // check the remote player is a Time Lord
   HashMap<String, Object> where = new HashMap<String, Object>();
   where.put("uuid", uuid.toString());
   ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0);
   if (!rs.resultSet()) {
     TARDISMessage.send(player, "PLAYER_NO_TARDIS");
     return true;
   }
   Tardis tardis = rs.getTardis();
   final int id = tardis.getTardis_id();
   // check they are not in the tardis
   HashMap<String, Object> wherettrav = new HashMap<String, Object>();
   wherettrav.put("uuid", player.getUniqueId().toString());
   wherettrav.put("tardis_id", id);
   ResultSetTravellers rst = new ResultSetTravellers(plugin, wherettrav, false);
   if (rst.resultSet()) {
     TARDISMessage.send(player, "NO_PB_IN_TARDIS");
     return true;
   }
   if (plugin.getTrackerKeeper().getInVortex().contains(id)) {
     TARDISMessage.send(player, "NOT_WHILE_MAT");
     return true;
   }
   boolean chamtmp = false;
   if (plugin.getConfig().getBoolean("travel.chameleon")) {
     chamtmp = tardis.isChamele_on();
   }
   boolean hidden = tardis.isHidden();
   // get current police box location
   HashMap<String, Object> wherecl = new HashMap<String, Object>();
   wherecl.put("tardis_id", id);
   ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl);
   if (!rsc.resultSet()) {
     hidden = true;
   }
   COMPASS d = rsc.getDirection();
   COMPASS player_d = COMPASS.valueOf(TARDISStaticUtils.getPlayersDirection(player, false));
   Biome biome = rsc.getBiome();
   TARDISTimeTravel tt = new TARDISTimeTravel(plugin);
   int count;
   boolean sub = false;
   Block b = eyeLocation.getBlock();
   if (b.getRelative(BlockFace.UP).getType().equals(Material.WATER)
       || b.getRelative(BlockFace.UP).getType().equals(Material.STATIONARY_WATER)) {
     count = (tt.isSafeSubmarine(eyeLocation, player_d)) ? 0 : 1;
     if (count == 0) {
       sub = true;
     }
   } else {
     int[] start_loc = tt.getStartLocation(eyeLocation, player_d);
     // safeLocation(int startx, int starty, int startz, int resetx, int resetz, World w, COMPASS
     // player_d)
     count =
         tt.safeLocation(
             start_loc[0],
             eyeLocation.getBlockY(),
             start_loc[2],
             start_loc[1],
             start_loc[3],
             eyeLocation.getWorld(),
             player_d);
   }
   if (plugin.getPM().isPluginEnabled("Lockette")) {
     Lockette Lockette = (Lockette) plugin.getPM().getPlugin("Lockette");
     if (Lockette.isProtected(eyeLocation.getBlock())) {
       count = 1;
     }
   }
   if (count > 0) {
     TARDISMessage.send(player, "WOULD_GRIEF_BLOCKS");
     return true;
   }
   boolean cham = chamtmp;
   final QueryFactory qf = new QueryFactory(plugin);
   Location oldSave = null;
   HashMap<String, Object> bid = new HashMap<String, Object>();
   bid.put("tardis_id", id);
   HashMap<String, Object> bset = new HashMap<String, Object>();
   if (rsc.getWorld() != null) {
     oldSave = new Location(rsc.getWorld(), rsc.getX(), rsc.getY(), rsc.getZ());
     // set fast return location
     bset.put("world", rsc.getWorld().getName());
     bset.put("x", rsc.getX());
     bset.put("y", rsc.getY());
     bset.put("z", rsc.getZ());
     bset.put("direction", d.toString());
     bset.put("submarine", rsc.isSubmarine());
   } else {
     // set fast return location
     bset.put("world", eyeLocation.getWorld().getName());
     bset.put("x", eyeLocation.getX());
     bset.put("y", eyeLocation.getY());
     bset.put("z", eyeLocation.getZ());
     bset.put("submarine", (sub) ? 1 : 0);
   }
   qf.doUpdate("back", bset, bid);
   HashMap<String, Object> tid = new HashMap<String, Object>();
   tid.put("tardis_id", id);
   HashMap<String, Object> set = new HashMap<String, Object>();
   set.put("world", eyeLocation.getWorld().getName());
   set.put("x", eyeLocation.getBlockX());
   set.put("y", eyeLocation.getBlockY());
   set.put("z", eyeLocation.getBlockZ());
   set.put("direction", player_d.toString());
   set.put("submarine", (sub) ? 1 : 0);
   if (hidden) {
     HashMap<String, Object> sett = new HashMap<String, Object>();
     sett.put("hidden", 0);
     HashMap<String, Object> ttid = new HashMap<String, Object>();
     ttid.put("tardis_id", id);
     qf.doUpdate("tardis", sett, ttid);
     // restore biome
     plugin.getUtils().restoreBiome(oldSave, biome);
   }
   qf.doUpdate("current", set, tid);
   TARDISMessage.send(player, "TARDIS_COMING");
   //        boolean mat = plugin.getConfig().getBoolean("police_box.materialise");
   //        long delay = (mat) ? 1L : 180L;
   long delay = 1L;
   plugin.getTrackerKeeper().getInVortex().add(id);
   final boolean hid = hidden;
   if (!plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) {
     final DestroyData dd = new DestroyData(plugin, player.getUniqueId().toString());
     dd.setChameleon(cham);
     dd.setDirection(d);
     dd.setLocation(oldSave);
     dd.setPlayer(player);
     dd.setHide(false);
     dd.setOutside(true);
     dd.setSubmarine(rsc.isSubmarine());
     dd.setTardisID(id);
     dd.setBiome(biome);
     plugin
         .getServer()
         .getScheduler()
         .scheduleSyncDelayedTask(
             plugin,
             new Runnable() {
               @Override
               public void run() {
                 if (!hid) {
                   plugin.getTrackerKeeper().getDematerialising().add(id);
                   plugin.getPresetDestroyer().destroyPreset(dd);
                 } else {
                   plugin.getPresetDestroyer().removeBlockProtection(id, qf);
                 }
               }
             },
             delay);
   }
   final BuildData bd = new BuildData(plugin, player.getUniqueId().toString());
   bd.setChameleon(cham);
   bd.setDirection(player_d);
   bd.setLocation(eyeLocation);
   bd.setMalfunction(false);
   bd.setOutside(true);
   bd.setPlayer(player);
   bd.setRebuild(false);
   bd.setSubmarine(sub);
   bd.setTardisID(id);
   plugin
       .getServer()
       .getScheduler()
       .scheduleSyncDelayedTask(
           plugin,
           new Runnable() {
             @Override
             public void run() {
               plugin.getPresetBuilder().buildPreset(bd);
             }
           },
           delay * 2);
   plugin.getTrackerKeeper().getHasDestination().remove(id);
   if (plugin.getTrackerKeeper().getRescue().containsKey(id)) {
     plugin.getTrackerKeeper().getRescue().remove(id);
   }
   return true;
 }