Example #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;
   }
 }
Example #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;
   }
 }
Example #3
0
 public void flickSwitch(UUID uuid, boolean on) {
   HashMap<String, Object> whereb = new HashMap<String, Object>();
   whereb.put("uuid", uuid.toString());
   ResultSetTardis rs = new ResultSetTardis(plugin, whereb, "", false);
   if (rs.resultSet()) {
     SCHEMATIC schm = rs.getSchematic();
     if (no_beacon.contains(schm)) {
       // doesn't have a beacon!
       return;
     }
     // toggle beacon
     String beacon = rs.getBeacon();
     String[] beaconData;
     int plusy = 0;
     if (beacon.isEmpty()) {
       // get the location from the TARDIS size and the creeper location
       switch (schm) {
         case REDSTONE:
           plusy = 14;
           break;
         case ELEVENTH:
           plusy = 22;
           break;
         case DELUXE:
           plusy = 23;
           break;
         case BIGGER:
         case ARS:
           plusy = 12;
           break;
         default: // BUDGET, STEAMPUNK, WAR, CUSTOM?
           plusy = 11;
           break;
       }
       String creeper = rs.getCreeper();
       beaconData = creeper.split(":");
     } else {
       beaconData = beacon.split(":");
     }
     World w = plugin.getServer().getWorld(beaconData[0]);
     boolean stuffed = (beaconData[1].contains(".5"));
     int bx, bz;
     // get rid of decimal places due to incorrectly copied values from creeper field...
     if (stuffed) {
       bx = (int) plugin.getUtils().parseFloat(beaconData[1]) * 1;
       bz = (int) plugin.getUtils().parseFloat(beaconData[3]) * 1;
     } else {
       bx = plugin.getUtils().parseInt(beaconData[1]);
       bz = plugin.getUtils().parseInt(beaconData[3]);
     }
     int by = (int) plugin.getUtils().parseFloat(beaconData[2]) * 1 + plusy;
     if (beacon.isEmpty() || stuffed) {
       // update the tardis table so we don't have to do this again
       String beacon_loc = beaconData[0] + ":" + bx + ":" + by + ":" + bz;
       HashMap<String, Object> set = new HashMap<String, Object>();
       set.put("beacon", beacon_loc);
       HashMap<String, Object> where = new HashMap<String, Object>();
       where.put("tardis_id", rs.getTardis_id());
       new QueryFactory(plugin).doUpdate("tardis", set, where);
     }
     Location bl = new Location(w, bx, by, bz);
     Block b = bl.getBlock();
     while (!b.getChunk().isLoaded()) {
       b.getChunk().load();
     }
     b.setType((on) ? Material.GLASS : Material.BEDROCK);
   }
 }