示例#1
1
  /** Sends the current cooldown in action bar. */
  private void sendCooldownBar() {
    if (getPlayer() == null) return;

    StringBuilder stringBuilder = new StringBuilder();

    double currentCooldown = Core.getCustomPlayer(getPlayer()).canUse(type);
    double maxCooldown = type.getCountdown();

    int res = (int) (currentCooldown / maxCooldown * 10);
    ChatColor color;
    for (int i = 0; i < 10; i++) {
      color = ChatColor.RED;
      if (i < 10 - res) color = ChatColor.GREEN;
      stringBuilder.append(color + "â–�");
    }

    DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.US);
    otherSymbols.setDecimalSeparator('.');
    otherSymbols.setGroupingSeparator('.');
    otherSymbols.setPatternSeparator('.');
    final DecimalFormat decimalFormat = new DecimalFormat("0.0", otherSymbols);
    String timeLeft = decimalFormat.format(currentCooldown) + "s";

    PlayerUtils.sendInActionBar(
        getPlayer(), getName() + " §f" + stringBuilder.toString() + " §f" + timeLeft);
  }
示例#2
1
  private static final void mysqlFind(
      final Plugin plugin,
      final String playerName,
      final Location location,
      final int radius,
      final WorldManager manager,
      final ArrayList<Player> players) {

    BBPlayerInfo hunted = BBUsersTable.getInstance().getUserByName(playerName);

    PreparedStatement ps = null;
    ResultSet rs = null;

    HashMap<Integer, Integer> creations = new HashMap<Integer, Integer>();
    HashMap<Integer, Integer> destructions = new HashMap<Integer, Integer>();
    HashMap<Integer, Integer> explosions = new HashMap<Integer, Integer>();
    HashMap<Integer, Integer> burns = new HashMap<Integer, Integer>();

    Connection conn = null;

    try {
      conn = ConnectionManager.getConnection();
      if (conn == null) return;
      // TODO maybe more customizable actions?
      String actionString =
          "action IN('"
              + Action.BLOCK_BROKEN.ordinal()
              + "', '"
              + Action.BLOCK_PLACED.ordinal()
              + "', '"
              + Action.LEAF_DECAY.ordinal()
              + "', '"
              + Action.TNT_EXPLOSION.ordinal()
              + "', '"
              + Action.CREEPER_EXPLOSION.ordinal()
              + "', '"
              + Action.MISC_EXPLOSION.ordinal()
              + "', '"
              + Action.LAVA_FLOW.ordinal()
              + "', '"
              + Action.BLOCK_BURN.ordinal()
              + "')";
      ps =
          conn.prepareStatement(
              "SELECT action, type FROM "
                  + BBDataTable.getInstance().getTableName()
                  + " WHERE "
                  + actionString
                  + " AND rbacked = 0 AND x < ? AND x > ? AND y < ? AND y > ?  AND z < ? AND z > ? AND player = ? AND world = ? order by date desc");

      ps.setInt(1, location.getBlockX() + radius);
      ps.setInt(2, location.getBlockX() - radius);
      ps.setInt(3, location.getBlockY() + radius);
      ps.setInt(4, location.getBlockY() - radius);
      ps.setInt(5, location.getBlockZ() + radius);
      ps.setInt(6, location.getBlockZ() - radius);
      ps.setInt(7, hunted.getID());
      ps.setInt(8, manager.getWorld(location.getWorld().getName()));
      rs = ps.executeQuery();
      conn.commit();

      int size = 0;
      while (rs.next()) {
        Action action = Action.values()[rs.getInt("action")];
        int type = rs.getInt("type");

        switch (action) {
          case BLOCK_BROKEN:
          case LEAF_DECAY:
            if (destructions.containsKey(type)) {
              destructions.put(type, destructions.get(type) + 1);
              size++;
            } else {
              destructions.put(type, 1);
              size++;
            }
            break;
          case BLOCK_PLACED:
            if (creations.containsKey(type)) {
              creations.put(type, creations.get(type) + 1);
              size++;
            } else {
              creations.put(type, 1);
              size++;
            }
            break;
          case TNT_EXPLOSION:
          case CREEPER_EXPLOSION:
          case MISC_EXPLOSION:
            if (explosions.containsKey(type)) {
              explosions.put(type, explosions.get(type) + 1);
              size++;
            } else {
              explosions.put(type, 1);
              size++;
            }
          case BLOCK_BURN:
            if (burns.containsKey(type)) {
              burns.put(type, burns.get(type) + 1);
              size++;
            } else {
              burns.put(type, 1);
              size++;
            }
            break;
          case LAVA_FLOW:
            if (creations.containsKey(type)) {
              creations.put(type, creations.get(type) + 1);
              size++;
            } else {
              creations.put(type, 1);
              size++;
            }
            break;
        }
      }
      if (size > 0) {
        StringBuilder creationList = new StringBuilder();
        creationList.append(ChatColor.AQUA.toString());
        creationList.append("Placed Blocks: ");
        creationList.append(ChatColor.WHITE.toString());
        for (Entry<Integer, Integer> entry : creations.entrySet()) {
          creationList.append(Material.getMaterial(entry.getKey()));
          creationList.append(" (");
          creationList.append(entry.getValue());
          creationList.append("), ");
        }
        if (creationList.toString().contains(",")) {
          creationList.delete(creationList.lastIndexOf(","), creationList.length());
        }
        StringBuilder brokenList = new StringBuilder();
        brokenList.append(ChatColor.RED.toString());
        brokenList.append("Broken Blocks: ");
        brokenList.append(ChatColor.WHITE.toString());
        for (Entry<Integer, Integer> entry : destructions.entrySet()) {
          brokenList.append(Material.getMaterial(entry.getKey()));
          brokenList.append(" (");
          brokenList.append(entry.getValue());
          brokenList.append("), ");
        }
        if (brokenList.toString().contains(",")) {
          brokenList.delete(brokenList.lastIndexOf(","), brokenList.length());
        }
        StringBuilder explodeList = new StringBuilder();
        explodeList.append(ChatColor.RED.toString());
        explodeList.append("Exploded Blocks: ");
        explodeList.append(ChatColor.WHITE.toString());
        for (Entry<Integer, Integer> entry : explosions.entrySet()) {
          explodeList.append(Material.getMaterial(entry.getKey()));
          explodeList.append(" (");
          explodeList.append(entry.getValue());
          explodeList.append("), ");
        }
        if (explodeList.toString().contains(",")) {
          explodeList.delete(explodeList.lastIndexOf(","), explodeList.length());
        }

        StringBuilder burnList = new StringBuilder();
        burnList.append(ChatColor.RED.toString());
        burnList.append("Burned Blocks: ");
        burnList.append(ChatColor.WHITE.toString());
        for (Entry<Integer, Integer> entry : burns.entrySet()) {
          burnList.append(Material.getMaterial(entry.getKey()));
          burnList.append(" (");
          burnList.append(entry.getValue());
          burnList.append("), ");
        }
        if (burnList.toString().contains(",")) {
          burnList.delete(burnList.lastIndexOf(","), burnList.length());
        }
        for (Player player : players) {
          player.sendMessage(
              BigBrother.premessage + playerName + " has made " + size + " modifications");
          if (creations.entrySet().size() > 0) {
            player.sendMessage(creationList.toString());
          }
          if (destructions.entrySet().size() > 0) {
            player.sendMessage(brokenList.toString());
          }
          if (explosions.entrySet().size() > 0) {
            player.sendMessage(explodeList.toString());
          }
          if (burns.entrySet().size() > 0) {
            player.sendMessage(burnList.toString());
          }
        }
      } else {
        for (Player player : players) {
          player.sendMessage(
              BigBrother.premessage + playerName + " has no modifications in this area.");
        }
      }
    } catch (SQLException ex) {
      BBLogging.severe("Find SQL Exception", ex);
    } finally {
      ConnectionManager.cleanup("Find SQL", conn, ps, rs);
    }
  }
示例#3
1
  private static final void mysqlFind(
      final Plugin plugin,
      final Location location,
      final int radius,
      final WorldManager manager,
      final ArrayList<Player> players) {
    PreparedStatement ps = null;
    ResultSet rs = null;
    Connection conn = null;
    HashMap<BBPlayerInfo, Integer> modifications = new HashMap<BBPlayerInfo, Integer>();
    try {
      conn = ConnectionManager.getConnection();
      if (conn == null) return;
      // TODO maybe more customizable actions?
      String actionString =
          "action IN('"
              + Action.BLOCK_BROKEN.ordinal()
              + "', '"
              + Action.BLOCK_PLACED.ordinal()
              + "', '"
              + Action.LEAF_DECAY.ordinal()
              + "', '"
              + Action.TNT_EXPLOSION.ordinal()
              + "', '"
              + Action.CREEPER_EXPLOSION.ordinal()
              + "', '"
              + Action.MISC_EXPLOSION.ordinal()
              + "', '"
              + Action.LAVA_FLOW.ordinal()
              + "', '"
              + Action.BLOCK_BURN.ordinal()
              + "')";

      /*
       * org.h2.jdbc.JdbcSQLException: Column "ID" must be in the GROUP BY
       * list; SQL statement:
       */
      if (BBSettings.usingDBMS(DBMS.H2) || BBSettings.usingDBMS(DBMS.POSTGRES)) {
        ps =
            conn.prepareStatement(
                "SELECT player, count(player) AS modifications FROM "
                    + BBDataTable.getInstance().getTableName()
                    + " WHERE "
                    + actionString
                    + " AND rbacked = '0' AND x < ? AND x > ? AND y < ? AND y > ? AND z < ? AND z > ? AND world = ? GROUP BY id,player ORDER BY id DESC");
      } else {
        ps =
            conn.prepareStatement(
                "SELECT player, count(player) AS modifications FROM "
                    + BBDataTable.getInstance().getTableName()
                    + " WHERE "
                    + actionString
                    + " AND rbacked = '0' AND x < ? AND x > ? AND y < ? AND y > ? AND z < ? AND z > ? AND world = ? GROUP BY player ORDER BY id DESC");
      }
      ps.setInt(1, location.getBlockX() + radius);
      ps.setInt(2, location.getBlockX() - radius);
      ps.setInt(3, location.getBlockY() + radius);
      ps.setInt(4, location.getBlockY() - radius);
      ps.setInt(5, location.getBlockZ() + radius);
      ps.setInt(6, location.getBlockZ() - radius);
      ps.setInt(7, manager.getWorld(location.getWorld().getName()));
      rs = ps.executeQuery();
      conn.commit();

      int size = 0;
      while (rs.next()) {
        BBPlayerInfo player = BBUsersTable.getInstance().getUserByID(rs.getInt("player"));
        int mods = rs.getInt("modifications");
        modifications.put(player, mods);
        size++;
      }
      if (size > 0) {
        StringBuilder playerList = new StringBuilder();
        for (Entry<BBPlayerInfo, Integer> entry : modifications.entrySet()) {
          if (entry.getKey() != null) {
            playerList.append(entry.getKey().getName());
            playerList.append(" (");
            playerList.append(entry.getValue());
            playerList.append("), ");
          }
        }
        if (playerList.indexOf(",") != -1) {
          playerList.delete(playerList.lastIndexOf(","), playerList.length());
        }
        // TODO Put into sync'd runnable
        for (Player player : players) {
          player.sendMessage(
              BigBrother.premessage + playerList.length() + " player(s) have modified this area:");
          player.sendMessage(playerList.toString());
        }
      } else {
        for (Player player : players) {
          player.sendMessage(BigBrother.premessage + "No modifications in this area.");
        }
      }
    } catch (SQLException ex) {
      BBLogging.severe("Find SQL Exception", ex);
    } finally {
      ConnectionManager.cleanup("Find SQL", conn, ps, rs);
    }
  }
示例#4
1
  // TODO use IN(1,2,3)
  private void mysqlFind(boolean sqlite) {
    PreparedStatement ps = null;
    ResultSet rs = null;
    Connection conn = null;
    HashMap<String, Integer> modifications = new HashMap<String, Integer>();
    try {
      conn = ConnectionManager.getConnection();

      // TODO maybe more customizable actions?
      String actionString =
          "action IN('"
              + Action.BLOCK_BROKEN.ordinal()
              + "', '"
              + Action.BLOCK_PLACED.ordinal()
              + "', '"
              + Action.LEAF_DECAY.ordinal()
              + "', '"
              + Action.TNT_EXPLOSION.ordinal()
              + "', '"
              + Action.CREEPER_EXPLOSION.ordinal()
              + "', '"
              + Action.MISC_EXPLOSION.ordinal()
              + "', '"
              + Action.BLOCK_BURN.ordinal()
              + "')";
      ps =
          conn.prepareStatement(
              "SELECT player, count(player) AS modifications FROM "
                  + BBDataBlock.BBDATA_NAME
                  + " WHERE "
                  + actionString
                  + " AND rbacked = '0' AND x < ? AND x > ? AND y < ? AND y > ? AND z < ? AND z > ? AND world = ? GROUP BY player ORDER BY id DESC");

      ps.setInt(1, location.getBlockX() + radius);
      ps.setInt(2, location.getBlockX() - radius);
      ps.setInt(3, location.getBlockY() + radius);
      ps.setInt(4, location.getBlockY() - radius);
      ps.setInt(5, location.getBlockZ() + radius);
      ps.setInt(6, location.getBlockZ() - radius);
      ps.setInt(7, worlds.indexOf(location.getWorld()));
      rs = ps.executeQuery();
      conn.commit();

      int size = 0;
      while (rs.next()) {
        String player = rs.getString("player");
        int mods = rs.getInt("modifications");
        modifications.put(player, mods);
        size++;
      }
      if (size > 0) {
        StringBuilder playerList = new StringBuilder();
        for (Entry<String, Integer> entry : modifications.entrySet()) {
          playerList.append(entry.getKey());
          playerList.append(" (");
          playerList.append(entry.getValue());
          playerList.append("), ");
        }
        playerList.delete(playerList.lastIndexOf(","), playerList.length());
        for (Player player : players) {
          player.sendMessage(BigBrother.premessage + size + " player(s) have modified this area:");
          player.sendMessage(playerList.toString());
        }
      } else {
        for (Player player : players) {
          player.sendMessage(BigBrother.premessage + "No modifications in this area.");
        }
      }
    } catch (SQLException ex) {
      BigBrother.log.log(Level.SEVERE, "[BBROTHER]: Find SQL Exception", ex);
    } finally {
      try {
        if (rs != null) rs.close();
        if (ps != null) ps.close();
        if (conn != null) conn.close();
      } catch (SQLException ex) {
        BigBrother.log.log(Level.SEVERE, "[BBROTHER]: Find SQL Exception (on close)");
      }
    }
  }
示例#5
0
  public void runCommand(String... obj) {
    StringBuilder command = new StringBuilder();
    for (String s : obj) {
      command.append(s);
    }

    String cmd = command.toString();

    outLog.info("Command run by remote user: '******'");

    Server.dispatchCommand(getServer().getConsoleSender(), cmd);
  }
  @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;
  }
示例#7
0
  private void mysqlFind(boolean sqlite, String playerName) {
    PreparedStatement ps = null;
    ResultSet rs = null;

    HashMap<Integer, Integer> creations = new HashMap<Integer, Integer>();
    HashMap<Integer, Integer> destructions = new HashMap<Integer, Integer>();
    HashMap<Integer, Integer> explosions = new HashMap<Integer, Integer>();
    HashMap<Integer, Integer> burns = new HashMap<Integer, Integer>();

    Connection conn = null;

    try {
      conn = ConnectionManager.getConnection();

      // TODO maybe more customizable actions?
      String actionString =
          "action IN('"
              + Action.BLOCK_BROKEN.ordinal()
              + "', '"
              + Action.BLOCK_PLACED.ordinal()
              + "', '"
              + Action.LEAF_DECAY.ordinal()
              + "', '"
              + Action.TNT_EXPLOSION.ordinal()
              + "', '"
              + Action.CREEPER_EXPLOSION.ordinal()
              + "', '"
              + Action.MISC_EXPLOSION.ordinal()
              + "', '"
              + Action.BLOCK_BURN.ordinal()
              + "')";
      ps =
          conn.prepareStatement(
              "SELECT action, type FROM "
                  + BBDataBlock.BBDATA_NAME
                  + " WHERE "
                  + actionString
                  + " AND rbacked = 0 AND x < ? AND x > ? AND y < ? AND y > ?  AND z < ? AND z > ? AND player = ? AND world = ? order by date desc");

      ps.setInt(1, location.getBlockX() + radius);
      ps.setInt(2, location.getBlockX() - radius);
      ps.setInt(3, location.getBlockY() + radius);
      ps.setInt(4, location.getBlockY() - radius);
      ps.setInt(5, location.getBlockZ() + radius);
      ps.setInt(6, location.getBlockZ() - radius);
      ps.setString(7, playerName);
      ps.setInt(8, worlds.indexOf(location.getWorld()));
      rs = ps.executeQuery();
      conn.commit();

      int size = 0;
      while (rs.next()) {
        Action action = Action.values()[rs.getInt("action")];
        int type = rs.getInt("type");

        switch (action) {
          case BLOCK_BROKEN:
          case LEAF_DECAY:
            if (destructions.containsKey(type)) {
              destructions.put(type, destructions.get(type) + 1);
              size++;
            } else {
              destructions.put(type, 1);
              size++;
            }
            break;
          case BLOCK_PLACED:
            if (creations.containsKey(type)) {
              creations.put(type, creations.get(type) + 1);
              size++;
            } else {
              creations.put(type, 1);
              size++;
            }
            break;
          case TNT_EXPLOSION:
          case CREEPER_EXPLOSION:
          case MISC_EXPLOSION:
            if (explosions.containsKey(type)) {
              explosions.put(type, explosions.get(type) + 1);
              size++;
            } else {
              explosions.put(type, 1);
              size++;
            }
          case BLOCK_BURN:
            if (burns.containsKey(type)) {
              burns.put(type, burns.get(type) + 1);
              size++;
            } else {
              burns.put(type, 1);
              size++;
            }
            break;
        }
      }
      if (size > 0) {
        StringBuilder creationList = new StringBuilder();
        // creationList.append(Color.AQUA);
        creationList.append("Placed Blocks: ");
        // creationList.append(Color.WHITE);
        for (Entry<Integer, Integer> entry : creations.entrySet()) {
          creationList.append(Material.getMaterial(entry.getKey()));
          creationList.append(" (");
          creationList.append(entry.getValue());
          creationList.append("), ");
        }
        if (creationList.toString().contains(","))
          creationList.delete(creationList.lastIndexOf(","), creationList.length());
        StringBuilder brokenList = new StringBuilder();
        // brokenList.append(Color.RED);
        brokenList.append("Broken Blocks: ");
        // brokenList.append(Color.WHITE);
        for (Entry<Integer, Integer> entry : destructions.entrySet()) {
          brokenList.append(Material.getMaterial(entry.getKey()));
          brokenList.append(" (");
          brokenList.append(entry.getValue());
          brokenList.append("), ");
        }
        if (brokenList.toString().contains(","))
          brokenList.delete(brokenList.lastIndexOf(","), brokenList.length());
        StringBuilder explodeList = new StringBuilder();
        // brokenList.append(Color.RED);
        explodeList.append("Exploded Blocks: ");
        // brokenList.append(Color.WHITE);
        for (Entry<Integer, Integer> entry : explosions.entrySet()) {
          explodeList.append(Material.getMaterial(entry.getKey()));
          explodeList.append(" (");
          explodeList.append(entry.getValue());
          explodeList.append("), ");
        }
        if (explodeList.toString().contains(","))
          explodeList.delete(explodeList.lastIndexOf(","), explodeList.length());

        StringBuilder burnList = new StringBuilder();
        // brokenList.append(Color.RED);
        burnList.append("Burned Blocks: ");
        // brokenList.append(Color.WHITE);
        for (Entry<Integer, Integer> entry : burns.entrySet()) {
          burnList.append(Material.getMaterial(entry.getKey()));
          burnList.append(" (");
          burnList.append(entry.getValue());
          burnList.append("), ");
        }
        if (burnList.toString().contains(","))
          burnList.delete(burnList.lastIndexOf(","), burnList.length());
        for (Player player : players) {
          player.sendMessage(
              BigBrother.premessage + playerName + " has made " + size + " modifications");
          if (creations.entrySet().size() > 0) player.sendMessage(creationList.toString());
          if (destructions.entrySet().size() > 0) player.sendMessage(brokenList.toString());
          if (explosions.entrySet().size() > 0) player.sendMessage(explodeList.toString());
          if (burns.entrySet().size() > 0) player.sendMessage(burnList.toString());
        }
      } else {
        for (Player player : players) {
          player.sendMessage(
              BigBrother.premessage + playerName + " has no modifications in this area.");
        }
      }
    } catch (SQLException ex) {
      BigBrother.log.log(Level.SEVERE, "[BBROTHER]: Find SQL Exception", ex);
    } finally {
      try {
        if (rs != null) rs.close();
        if (ps != null) ps.close();
        if (conn != null) conn.close();
      } catch (SQLException ex) {
        BigBrother.log.log(Level.SEVERE, "[BBROTHER]: Find SQL Exception (on close)");
      }
    }
  }