Beispiel #1
0
 public boolean exterminate(int id) {
   HashMap<String, Object> where = new HashMap<String, Object>();
   where.put("tardis_id", id);
   ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false);
   try {
     if (rs.resultSet()) {
       String saveLoc = rs.getCurrent();
       Location bb_loc = plugin.utils.getLocationFromDB(saveLoc, 0F, 0F);
       String chunkLoc = rs.getChunk();
       String owner = rs.getOwner();
       TARDISConstants.SCHEMATIC schm = rs.getSchematic();
       TARDISConstants.COMPASS d = rs.getDirection();
       if (!rs.isHidden()) {
         // clear the torch
         //                    plugin.destroyPB.destroyPlatform(rs.getPlatform(), id);
         plugin.destroyPB.destroyPoliceBox(bb_loc, d, id, false, false, false, null);
       }
       String[] chunkworld = chunkLoc.split(":");
       World cw = plugin.getServer().getWorld(chunkworld[0]);
       int restore = getRestore(cw);
       if (!cw.getName().contains("TARDIS_WORLD_")) {
         plugin.destroyI.destroyInner(schm, id, cw, restore, owner);
       }
       cleanDatabase(id);
       cleanWorlds(cw, owner);
       return true;
     }
   } catch (Exception e) {
     plugin.console.sendMessage(plugin.pluginName + "TARDIS prune by id error: " + e);
   } finally {
     return false;
   }
 }
Beispiel #2
0
 /**
  * Deletes a TARDIS.
  *
  * @param player running the command.
  * @param block the block that represents the Police Box sign
  * @return true or false depending on whether the TARIS could be deleted
  */
 public boolean exterminate(Player player, Block block) {
   int signx = 0, signz = 0;
   String playerNameStr = player.getName();
   Location sign_loc = block.getLocation();
   HashMap<String, Object> where = new HashMap<String, Object>();
   if (player.hasPermission("tardis.delete")) {
     Block blockbehind = null;
     byte data = block.getData();
     if (data == 4) {
       blockbehind = block.getRelative(BlockFace.EAST, 2);
     }
     if (data == 5) {
       blockbehind = block.getRelative(BlockFace.WEST, 2);
     }
     if (data == 3) {
       blockbehind = block.getRelative(BlockFace.NORTH, 2);
     }
     if (data == 2) {
       blockbehind = block.getRelative(BlockFace.SOUTH, 2);
     }
     if (blockbehind != null) {
       Block blockDown = blockbehind.getRelative(BlockFace.DOWN, 2);
       Location bd_loc = blockDown.getLocation();
       String bd_str =
           bd_loc.getWorld().getName()
               + ":"
               + bd_loc.getBlockX()
               + ":"
               + bd_loc.getBlockY()
               + ":"
               + bd_loc.getBlockZ();
       where.put("current", bd_str);
     } else {
       player.sendMessage(
           plugin.pluginName + ChatColor.RED + "Could not get TARDIS save location!");
       return false;
     }
   } else {
     where.put("owner", playerNameStr);
   }
   ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false);
   if (rs.resultSet()) {
     int id = rs.getTardis_id();
     String saveLoc = rs.getCurrent();
     String chunkLoc = rs.getChunk();
     String owner = rs.getOwner();
     TARDISConstants.SCHEMATIC schm = rs.getSchematic();
     TARDISConstants.COMPASS d = rs.getDirection();
     // need to check that a player is not currently in the TARDIS
     if (player.hasPermission("tardis.delete")) {
       HashMap<String, Object> travid = new HashMap<String, Object>();
       travid.put("tardis_id", id);
       ResultSetTravellers rst = new ResultSetTravellers(plugin, travid, false);
       if (rst.resultSet()) {
         player.sendMessage(
             plugin.pluginName
                 + ChatColor.RED
                 + "You cannot delete this TARDIS as it is occupied!");
         return false;
       }
     }
     // check the sign location
     Location bb_loc = plugin.utils.getLocationFromDB(saveLoc, 0F, 0F);
     // get TARDIS direction
     switch (d) {
       case EAST:
         signx = -2;
         signz = 0;
         break;
       case SOUTH:
         signx = 0;
         signz = -2;
         break;
       case WEST:
         signx = 2;
         signz = 0;
         break;
       case NORTH:
         signx = 0;
         signz = 2;
         break;
     }
     int signy = -2;
     // if the sign was on the TARDIS destroy the TARDIS!
     if (sign_loc.getBlockX() == bb_loc.getBlockX() + signx
         && sign_loc.getBlockY() + signy == bb_loc.getBlockY()
         && sign_loc.getBlockZ() == bb_loc.getBlockZ() + signz) {
       if (!rs.isHidden()) {
         // remove Police Box
         plugin.destroyPB.destroyPoliceBox(bb_loc, d, id, false, false, false, null);
       }
       String[] chunkworld = chunkLoc.split(":");
       World cw = plugin.getServer().getWorld(chunkworld[0]);
       int restore = getRestore(cw);
       if (!cw.getName().contains("TARDIS_WORLD_")) {
         plugin.destroyI.destroyInner(schm, id, cw, restore, playerNameStr);
       }
       cleanDatabase(id);
       cleanWorlds(cw, owner);
       player.sendMessage(
           plugin.pluginName + "The TARDIS was removed from the world and database successfully.");
       return true;
     } else {
       // cancel the event because it's not the player's TARDIS
       player.sendMessage(TARDISConstants.NOT_OWNER);
       return false;
     }
   } else {
     player.sendMessage("Don't grief the TARDIS!");
     return false;
   }
 }