private void getDestination(int id, Player p) {
   // get the destination sign
   Sign s = getDestinationSign(id);
   if (s != null) {
     String line1 = s.getLine(1);
     String line2 = s.getLine(2);
     String line3 = s.getLine(3);
     if (line1.isEmpty() || line2.isEmpty() || line3.isEmpty()) {
       TARDISMessage.send(p, "JUNK_LINES");
       return;
     }
     World w = plugin.getServer().getWorld(line1);
     int x = TARDISNumberParsers.parseInt(line2);
     int z = TARDISNumberParsers.parseInt(line3);
     // load the chunk
     Chunk chunk = w.getChunkAt(x, z);
     while (!chunk.isLoaded()) {
       w.loadChunk(chunk);
     }
     int y = w.getHighestBlockYAt(x, z);
     Location d = new Location(w, x, y, z);
     // TODO check destination
     if (plugin.getPluginRespect().getRespect(d, new Parameters(p, FLAG.getNoMessageFlags()))) {
       while (!chunk.isLoaded()) {
         chunk.load();
       }
       d.setY(getActualHighestY(d));
       plugin.getGeneralKeeper().setJunkDestination(d);
     }
   }
 }
Example #2
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;
   }
 }
 /**
  * Retrieves an SQL ResultSet from the destinations table. This method builds an SQL query string
  * from the parameters supplied and then executes the query. Use the getters to retrieve the
  * results.
  *
  * @return true or false depending on whether any data matches the query
  */
 public boolean resultSet() {
   PreparedStatement statement = null;
   ResultSet rs = null;
   String wheres = "";
   if (where != null) {
     StringBuilder sbw = new StringBuilder();
     for (Map.Entry<String, Object> entry : where.entrySet()) {
       sbw.append(entry.getKey()).append(" = ? AND ");
     }
     wheres = " WHERE " + sbw.toString().substring(0, sbw.length() - 5);
   }
   String query = "SELECT * FROM next" + wheres;
   try {
     service.testConnection(connection);
     statement = connection.prepareStatement(query);
     if (where != null) {
       int s = 1;
       for (Map.Entry<String, Object> entry : where.entrySet()) {
         if (entry.getValue().getClass().equals(String.class)) {
           statement.setString(s, entry.getValue().toString());
         } else {
           statement.setInt(s, plugin.getUtils().parseInt(entry.getValue().toString()));
         }
         s++;
       }
       where.clear();
     }
     rs = statement.executeQuery();
     if (rs.isBeforeFirst()) {
       while (rs.next()) {
         this.next_id = rs.getInt("next_id");
         this.tardis_id = rs.getInt("tardis_id");
         this.world = plugin.getServer().getWorld(rs.getString("world"));
         this.x = rs.getInt("x");
         this.y = rs.getInt("y");
         this.z = rs.getInt("z");
         this.direction = COMPASS.valueOf(rs.getString("direction"));
         this.submarine = rs.getBoolean("submarine");
       }
     } else {
       return false;
     }
   } catch (SQLException e) {
     plugin.debug("ResultSet error for destinations table! " + e.getMessage());
     return false;
   } finally {
     try {
       if (rs != null) {
         rs.close();
       }
       if (statement != null) {
         statement.close();
       }
     } catch (SQLException e) {
       plugin.debug("Error closing destinations table! " + e.getMessage());
     }
   }
   return this.world != null;
 }
Example #4
0
 public void doMalfunction(Location l) {
   HashMap<String, Object> where = new HashMap<String, Object>();
   where.put("tardis_id", id);
   ResultSetLamps rsl = new ResultSetLamps(plugin, where, true);
   List<Block> lamps = new ArrayList<Block>();
   if (rsl.resultSet()) {
     // flicker lights
     ArrayList<HashMap<String, String>> data = rsl.getData();
     for (HashMap<String, String> map : data) {
       Location loc = plugin.utils.getLocationFromDB(map.get("location"), 0.0F, 0.0F);
       lamps.add(loc.getBlock());
     }
     if (plugin.pm.isPluginEnabled("Citizens")
         && plugin.getConfig().getBoolean("allow.emergency_npc")) {
       // get player prefs
       HashMap<String, Object> wherep = new HashMap<String, Object>();
       wherep.put("player", p.getName());
       ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, wherep);
       if (rsp.resultSet() && rsp.isEpsOn()) {
         // schedule the NPC to appear
         String message =
             "This is Emergency Programme One. Now listen, this is important. If this message is activated, then it can only mean one thing: we must be in danger, and I mean fatal. You're about to die any second with no chance of escape.";
         HashMap<String, Object> wherev = new HashMap<String, Object>();
         wherev.put("tardis_id", id);
         ResultSetTravellers rst = new ResultSetTravellers(plugin, wherev, true);
         List<String> players;
         if (rst.resultSet()) {
           players = rst.getData();
         } else {
           players = new ArrayList<String>();
           players.add(p.getName());
         }
         TARDISEPSRunnable EPS_runnable =
             new TARDISEPSRunnable(plugin, message, p, players, id, eps, creeper);
         plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, EPS_runnable, 220L);
       }
     }
     final long start = System.currentTimeMillis() + 10000;
     TARDISLampsRunnable runnable = new TARDISLampsRunnable(plugin, lamps, start);
     runnable.setHandbrake(handbrake_loc);
     int taskID =
         plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, runnable, 10L, 10L);
     runnable.setTask(taskID);
   }
 }
 public boolean build(Player p, int tips, int id) {
   if (!plugin.getConfig().getBoolean("allow.zero_room")) {
     TARDISMessage.send(p, "ZERO_DISABLED");
     return true;
   }
   TARDISInteriorPostioning tintpos = new TARDISInteriorPostioning(plugin);
   int slot = tips;
   if (tips == -1) {
     slot = tintpos.getFreeSlot();
     // uodate TARDIS table with new slot number
     QueryFactory qf = new QueryFactory(plugin);
     HashMap<String, Object> set = new HashMap<String, Object>();
     set.put("tips", slot);
     HashMap<String, Object> where = new HashMap<String, Object>();
     where.put("tardis_id", id);
     qf.doUpdate("tardis", set, where);
   }
   TARDISTIPSData pos = tintpos.getTIPSData(slot);
   int x = pos.getCentreX();
   int y = 64;
   int z = pos.getCentreZ();
   World w = plugin.getServer().getWorld("TARDIS_Zero_room");
   if (w == null) {
     TARDISMessage.send(p, "ZERO_NOT_FOUND");
     return true;
   }
   Location l = new Location(w, x, y, z);
   TARDISRoomBuilder builder = new TARDISRoomBuilder(plugin, "ZERO", l, COMPASS.SOUTH, p);
   if (builder.build()) {
     UUID uuid = p.getUniqueId();
     // ok, room growing was successful, so take their energy!
     int amount = plugin.getRoomsConfig().getInt("rooms.ZERO.cost");
     QueryFactory qf = new QueryFactory(plugin);
     HashMap<String, Object> set = new HashMap<String, Object>();
     set.put("uuid", p.getUniqueId().toString());
     qf.alterEnergyLevel("tardis", -amount, set, p);
     // remove blocks from condenser table if rooms_require_blocks is true
     if (plugin.getConfig().getBoolean("growth.rooms_require_blocks")) {
       TARDISCondenserData c_data = plugin.getGeneralKeeper().getRoomCondenserData().get(uuid);
       for (Map.Entry<String, Integer> entry : c_data.getBlockIDCount().entrySet()) {
         HashMap<String, Object> wherec = new HashMap<String, Object>();
         wherec.put("tardis_id", c_data.getTardis_id());
         wherec.put("block_data", entry.getKey());
         qf.alterCondenserBlockCount(entry.getValue(), wherec);
       }
       plugin.getGeneralKeeper().getRoomCondenserData().remove(uuid);
     }
     // are we doing an achievement?
     if (plugin.getAchievementConfig().getBoolean("rooms.enabled")) {
       TARDISAchievementFactory taf =
           new TARDISAchievementFactory(
               plugin, p, "rooms", plugin.getBuildKeeper().getSeeds().size());
       taf.doAchievement("ZERO");
     }
   }
   return true;
 }
 public void addPerms(String player) {
   BufferedReader bufRdr = null;
   try {
     bufRdr = new BufferedReader(new FileReader(permissionsFile));
     String line;
     // read each line of text file
     while ((line = bufRdr.readLine()) != null) {
       if (line.charAt(0) == '#') {
         group = line.substring(1).trim();
         permgroups.put(group, new ArrayList<String>());
       } else {
         List<String> perms = permgroups.get(group);
         perms.add(line.trim());
       }
     }
   } catch (IOException io) {
     plugin.debug("Could not read perms file. " + io.getMessage());
   } finally {
     if (bufRdr != null) {
       try {
         bufRdr.close();
       } catch (IOException e) {
         plugin.debug("Error closing perms reader! " + e.getMessage());
       }
     }
   }
   plugin.getServer().dispatchCommand(plugin.console, "world TARDIS_WORLD_" + player);
   int i = 0;
   for (Map.Entry<String, List<String>> entry : permgroups.entrySet()) {
     String grpstr = entry.getKey();
     List<String> perms = entry.getValue();
     plugin.getServer().dispatchCommand(plugin.console, "group " + grpstr);
     for (String p : perms) {
       plugin.getServer().dispatchCommand(plugin.console, "group addperm " + p);
     }
     if (i == 0) {
       plugin.getServer().dispatchCommand(plugin.console, "user " + player);
       plugin.getServer().dispatchCommand(plugin.console, "user setgroup " + grpstr);
     }
     i++;
   }
   plugin.getServer().dispatchCommand(plugin.console, "permissions save");
   plugin.getServer().dispatchCommand(plugin.console, "permissions reload");
 }
 @Override
 public void run() {
   TARDISRegulatorInventory reg = new TARDISRegulatorInventory();
   ItemStack[] items = reg.getRegulator();
   Inventory inv = plugin.getServer().createInventory(player, 54, "Helmic Regulator");
   inv.setContents(items);
   player.openInventory(inv);
   // play inflight sound
   TARDISSounds.playTARDISSound(player.getLocation(), player, "interior_flight");
 }
 private void asyncFetch(final ArrayList<String> names) {
   plugin
       .getServer()
       .getScheduler()
       .runTaskAsynchronously(
           plugin,
           new Runnable() {
             @Override
             public void run() {
               syncFetch(names);
             }
           });
 }
 /**
  * Closes the inventory.
  *
  * @param p the player using the GUI
  */
 private void close(final Player p) {
   plugin
       .getServer()
       .getScheduler()
       .scheduleSyncDelayedTask(
           plugin,
           new Runnable() {
             @Override
             public void run() {
               p.closeInventory();
             }
           },
           1L);
 }
 /**
  * A repeating task that checks if the charged creeper in the TARDIS Artron Energy Capacitor is
  * still there.
  */
 public void startCreeperCheck() {
   plugin
       .getServer()
       .getScheduler()
       .scheduleSyncRepeatingTask(
           plugin,
           new Runnable() {
             @Override
             public void run() {
               checkCreepers();
             }
           },
           600L,
           12000L);
 }
 public void addPerms(String player) {
   BufferedReader bufRdr = null;
   try {
     bufRdr = new BufferedReader(new FileReader(permissionsFile));
     String line;
     // read each line of text file
     while ((line = bufRdr.readLine()) != null) {
       if (line.charAt(0) == '#') {
         group = line.substring(1).trim();
         permgroups.put(group, new ArrayList<String>());
       } else {
         List<String> perms = permgroups.get(group);
         perms.add(line.trim());
       }
     }
   } catch (IOException io) {
     plugin.debug("Could not read perms file. " + io.getMessage());
   } finally {
     if (bufRdr != null) {
       try {
         bufRdr.close();
       } catch (IOException e) {
         plugin.debug("Error closing perms reader! " + e.getMessage());
       }
     }
   }
   // get the default world
   String w = plugin.getServer().getWorlds().get(0).getName();
   // pex world <world> inherit <parentWorld> - make the TARDIS world inherit the main worlds
   // permissions
   plugin
       .getServer()
       .dispatchCommand(
           plugin.getConsole(), "pex world " + "TARDIS_WORLD_" + player + " inherit " + w);
   plugin.getServer().dispatchCommand(plugin.getConsole(), "pex reload");
 }
 @EventHandler(ignoreCancelled = true)
 public void onAdminMenuClick(InventoryClickEvent event) {
   Inventory inv = event.getInventory();
   String name = inv.getTitle();
   if (name.equals("§4Admin Menu")) {
     event.setCancelled(true);
     int slot = event.getRawSlot();
     if (slot < 54) {
       String option = getDisplay(inv, slot);
       if (slot == 53 && option.equals("Player Preferences")) {
         final Player p = (Player) event.getWhoClicked();
         // close this gui and load the Player Prefs Menu
         plugin
             .getServer()
             .getScheduler()
             .scheduleSyncDelayedTask(
                 plugin,
                 new Runnable() {
                   @Override
                   public void run() {
                     Inventory ppm =
                         plugin.getServer().createInventory(p, 18, "§4Player Prefs Menu");
                     ppm.setContents(
                         new TARDISPrefsMenuInventory(plugin, p.getUniqueId()).getMenu());
                     p.openInventory(ppm);
                   }
                 },
                 1L);
         return;
       }
       if (!option.isEmpty()) {
         boolean bool = plugin.getConfig().getBoolean(option);
         plugin.getConfig().set(option, !bool);
         String lore = (bool) ? "false" : "true";
         setLore(inv, slot, lore);
         plugin.saveConfig();
       }
     }
   }
 }
 /** Checks the creeper is there and spawns in a new one if not. */
 private void checkCreepers() {
   ResultSetTardis rs = new ResultSetTardis(plugin, null, "", true);
   if (rs.resultSet()) {
     ArrayList<HashMap<String, String>> data = rs.getData();
     for (HashMap<String, String> map : data) {
       // only if there is a saved creeper location
       if (!map.get("creeper").isEmpty()) {
         // only if the TARDIS has been initialised
         if (map.get("tardis_init").equals("1")) {
           String[] creeperData = map.get("creeper").split(":");
           World w = plugin.getServer().getWorld(creeperData[0]);
           if (w != null) {
             float cx = 0, cy = 0, cz = 0;
             try {
               cx = plugin.utils.parseFloat(creeperData[1]);
               cy = plugin.utils.parseFloat(creeperData[2]) + 1;
               cz = plugin.utils.parseFloat(creeperData[3]);
             } catch (NumberFormatException nfe) {
               plugin.debug("Couldn't convert to a float! " + nfe.getMessage());
             }
             Location l = new Location(w, cx, cy, cz);
             plugin.myspawn = true;
             Entity e = w.spawnEntity(l, EntityType.CREEPER);
             // if there is a creeper there already get rid of it!
             for (Entity k : e.getNearbyEntities(1d, 1d, 1d)) {
               if (k.getType().equals(EntityType.CREEPER)) {
                 e.remove();
                 break;
               }
             }
             Creeper c = (Creeper) e;
             c.setPowered(true);
           }
         }
       }
     }
   }
 }
Example #14
0
 private void cleanWorlds(World w, String owner) {
   // remove world guard region protection
   if (plugin.worldGuardOnServer && plugin.getConfig().getBoolean("use_worldguard")) {
     plugin.wgchk.removeRegion(w, owner);
   }
   // unload and remove the world if it's a TARDIS_WORLD_ world
   if (w.getName().contains("TARDIS_WORLD_")) {
     String name = w.getName();
     List<Player> players = w.getPlayers();
     Location spawn = plugin.getServer().getWorlds().get(0).getSpawnLocation();
     for (Player p : players) {
       p.sendMessage(
           plugin.pluginName + "World scheduled for deletion, teleporting you to spawn!");
       p.teleport(spawn);
     }
     if (plugin.pm.isPluginEnabled("Multiverse-Core")) {
       plugin.getServer().dispatchCommand(plugin.console, "mv remove " + name);
     }
     if (plugin.pm.isPluginEnabled("MultiWorld")) {
       plugin.getServer().dispatchCommand(plugin.console, "mw unload " + name);
       plugin.getServer().dispatchCommand(plugin.console, "mw delete " + name);
     }
     if (plugin.pm.isPluginEnabled("My Worlds")) {
       plugin.getServer().dispatchCommand(plugin.console, "myworlds unload " + name);
     }
     if (plugin.pm.isPluginEnabled("WorldBorder")) {
       // wb <world> clear
       plugin.getServer().dispatchCommand(plugin.console, "wb " + name + " clear");
     }
     plugin.getServer().unloadWorld(w, true);
     File world_folder =
         new File(plugin.getServer().getWorldContainer() + File.separator + name + File.separator);
     if (!deleteFolder(world_folder)) {
       plugin.debug("Could not delete world <" + name + ">");
     }
   }
 }
 public void clickButton() {
   HashMap<String, Object> wherep = new HashMap<String, Object>();
   wherep.put("tardis_id", id);
   HashMap<String, Object> setp = new HashMap<String, Object>();
   if (powered) {
     if (isTravelling(id)) {
       TARDISMessage.send(player, "POWER_NO");
       return;
     }
     TARDISSounds.playTARDISSound(loc, player, "power_down");
     // power down
     setp.put("powered_on", 0);
     TARDISMessage.send(player, "POWER_OFF");
     long delay = 0;
     // if hidden, rebuild
     if (hidden) {
       plugin
           .getServer()
           .dispatchCommand(plugin.getConsole(), "tardisremote " + player.getName() + " rebuild");
       TARDISMessage.send(player, "POWER_FAIL");
       delay = 20L;
     }
     // police box lamp, delay it incase the TARDIS needs rebuilding
     if (preset.equals(PRESET.NEW) || preset.equals(PRESET.OLD)) {
       plugin
           .getServer()
           .getScheduler()
           .scheduleSyncDelayedTask(
               plugin,
               new Runnable() {
                 @Override
                 public void run() {
                   new TARDISPoliceBoxLampToggler(plugin).toggleLamp(id, false);
                 }
               },
               delay);
     }
     // if lights are on, turn them off
     if (lights) {
       new TARDISLampToggler(plugin).flickSwitch(id, player.getUniqueId(), true, lanterns);
     }
     // if beacon is on turn it off
     new TARDISBeaconToggler(plugin).flickSwitch(player.getUniqueId(), false);
   } else {
     // don't power up if there is no power
     if (level <= plugin.getArtronConfig().getInt("standby")) {
       TARDISMessage.send(player, "POWER_LOW");
       return;
     }
     TARDISSounds.playTARDISSound(loc, player, "power_up");
     // power up
     setp.put("powered_on", 1);
     TARDISMessage.send(player, "POWER_ON");
     // if lights are off, turn them on
     if (lights) {
       new TARDISLampToggler(plugin).flickSwitch(id, player.getUniqueId(), false, lanterns);
     }
     // determine beacon prefs
     HashMap<String, Object> wherek = new HashMap<String, Object>();
     wherek.put("uuid", player.getUniqueId().toString());
     ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, wherek);
     boolean beacon_on = true;
     if (rsp.resultSet()) {
       beacon_on = rsp.isBeaconOn();
     }
     // if beacon is off turn it on
     if (beacon_on) {
       new TARDISBeaconToggler(plugin).flickSwitch(player.getUniqueId(), true);
     }
     // police box lamp
     if (preset.equals(PRESET.NEW) || preset.equals(PRESET.OLD)) {
       new TARDISPoliceBoxLampToggler(plugin).toggleLamp(id, true);
     }
   }
   new QueryFactory(plugin).doUpdate("tardis", setp, wherep);
 }
Example #16
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;
   }
 }
 @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;
 }
 @Override
 public void run() {
   int[][] ids;
   byte[][] datas;
   // get relative locations
   int x = tmd.getLocation().getBlockX(),
       plusx = tmd.getLocation().getBlockX() + 1,
       minusx = tmd.getLocation().getBlockX() - 1;
   int y;
   if (preset.equals(PRESET.SUBMERGED)) {
     y = tmd.getLocation().getBlockY() - 1;
   } else {
     y = tmd.getLocation().getBlockY();
   }
   int z = tmd.getLocation().getBlockZ(),
       plusz = tmd.getLocation().getBlockZ() + 1,
       minusz = tmd.getLocation().getBlockZ() - 1;
   World world = tmd.getLocation().getWorld();
   if (i < loops) {
     i++;
     // expand placed blocks to a police box
     switch (i % 3) {
       case 2: // stained
         ids = stained_column.getId();
         datas = stained_column.getData();
         break;
       case 1: // glass
         ids = glass_column.getId();
         datas = glass_column.getData();
         break;
       default: // preset
         ids = column.getId();
         datas = column.getData();
         break;
     }
     // first run - play sound
     if (i == 1) {
       switch (preset) {
         case GRAVESTONE:
           // remove flower
           int flowerx;
           int flowery = (tmd.getLocation().getBlockY() + 1);
           int flowerz;
           switch (tmd.getDirection()) {
             case NORTH:
               flowerx = tmd.getLocation().getBlockX();
               flowerz = tmd.getLocation().getBlockZ() + 1;
               break;
             case WEST:
               flowerx = tmd.getLocation().getBlockX() + 1;
               flowerz = tmd.getLocation().getBlockZ();
               break;
             case SOUTH:
               flowerx = tmd.getLocation().getBlockX();
               flowerz = tmd.getLocation().getBlockZ() - 1;
               break;
             default:
               flowerx = tmd.getLocation().getBlockX() - 1;
               flowerz = tmd.getLocation().getBlockZ();
               break;
           }
           plugin.getUtils().setBlock(world, flowerx, flowery, flowerz, 0, (byte) 0);
           break;
         case CAKE:
           plugin.getPresetDestroyer().destroyLamp(tmd.getLocation(), preset);
           break;
         default:
           break;
       }
       // only play the sound if the player is outside the TARDIS
       if (tmd.isOutside()) {
         HashMap<String, Object> wherep = new HashMap<String, Object>();
         wherep.put("uuid", tmd.getPlayer().getUniqueId().toString());
         ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, wherep);
         boolean minecart = false;
         if (rsp.resultSet()) {
           minecart = rsp.isMinecartOn();
         }
         if (!minecart) {
           plugin.getUtils().playTARDISSoundNearby(tmd.getLocation(), "tardis_takeoff");
         } else {
           world.playSound(tmd.getLocation(), Sound.MINECART_INSIDE, 1.0F, 0.0F);
         }
       }
       the_colour = getWoolColour(tmd.getTardisID(), preset);
     } else {
       // just change the walls
       int xx, zz;
       for (int n = 0; n < 9; n++) {
         int[] colids = ids[n];
         byte[] coldatas = datas[n];
         switch (n) {
           case 0:
             xx = minusx;
             zz = minusz;
             break;
           case 1:
             xx = x;
             zz = minusz;
             break;
           case 2:
             xx = plusx;
             zz = minusz;
             break;
           case 3:
             xx = plusx;
             zz = z;
             break;
           case 4:
             xx = plusx;
             zz = plusz;
             break;
           case 5:
             xx = x;
             zz = plusz;
             break;
           case 6:
             xx = minusx;
             zz = plusz;
             break;
           case 7:
             xx = minusx;
             zz = z;
             break;
           default:
             xx = x;
             zz = z;
             break;
         }
         for (int yy = 0; yy < 4; yy++) {
           boolean change = true;
           if (yy == 0 && n == 9) {
             Block rail = world.getBlockAt(xx, y, zz);
             if (rail.getType().equals(Material.RAILS)
                 || rail.getType().equals(Material.POWERED_RAIL)) {
               change = false;
             }
           }
           switch (colids[yy]) {
             case 2:
             case 3:
               int subi = (preset.equals(PRESET.SUBMERGED)) ? cham_id : colids[yy];
               byte subd = (preset.equals(PRESET.SUBMERGED)) ? cham_data : coldatas[yy];
               plugin.getUtils().setBlock(world, xx, (y + yy), zz, subi, subd);
               break;
             case 35: // wool
               int chai =
                   (preset.equals(PRESET.NEW) || preset.equals(PRESET.OLD)) ? cham_id : colids[yy];
               byte chad =
                   (preset.equals(PRESET.NEW) || preset.equals(PRESET.OLD))
                       ? cham_data
                       : coldatas[yy];
               if (preset.equals(PRESET.PARTY)
                   || (preset.equals(PRESET.FLOWER) && coldatas[yy] == 0)) {
                 chad = the_colour;
               }
               plugin.getUtils().setBlock(world, xx, (y + yy), zz, chai, chad);
               break;
             case 38:
               break;
             case 50: // lamps, glowstone and torches
             case 89:
             case 124:
               int light =
                   (preset.equals(PRESET.NEW) || preset.equals(PRESET.OLD)) ? lamp : colids[yy];
               plugin.getUtils().setBlock(world, xx, (y + yy), zz, light, coldatas[yy]);
               break;
             case 64:
             case 68: // except the sign and doors
             case 71:
               break;
             case 95:
               if (coldatas[yy] == -1) {
                 if (preset.equals(PRESET.PARTY)
                     || (preset.equals(PRESET.FLOWER) && coldatas[yy] == 0)) {
                   chad = the_colour;
                 } else {
                   // if it was a wool / stained glass / stained clay block get the data from that
                   int[] finalids = column.getId()[n];
                   byte[] finaldatas = column.getData()[n];
                   if (finalids[yy] == 35
                       || finalids[yy] == 95
                       || finalids[yy] == 159
                       || finalids[yy] == 160
                       || finalids[yy] == 171) {
                     if (preset.equals(PRESET.NEW) || preset.equals(PRESET.OLD)) {
                       chad = cham_data;
                     } else {
                       chad = finaldatas[yy];
                     }
                   } else {
                     chad =
                         plugin.getBuildKeeper().getStainedGlassLookup().getStain().get(cham_id);
                   }
                 }
                 plugin.getUtils().setBlock(world, xx, (y + yy), zz, 95, chad);
               } else {
                 plugin.getUtils().setBlock(world, xx, (y + yy), zz, colids[yy], coldatas[yy]);
               }
               break;
             default: // everything else
               if (change) {
                 plugin.getUtils().setBlock(world, xx, (y + yy), zz, colids[yy], coldatas[yy]);
               }
               break;
           }
         }
       }
     }
   } else {
     plugin.getServer().getScheduler().cancelTask(task);
     task = 0;
     new TARDISDeinstaPreset(plugin).instaDestroyPreset(tmd, false, preset);
   }
 }
Example #19
0
 /** Builds the TARDIS Police Box. */
 public void buildPoliceBox() {
   int plusx, minusx, x, plusz, minusz, z;
   byte sd = 0, grey = 8;
   byte mds = data,
       mdw = data,
       mdn = data,
       mde = data,
       bds = data,
       bdw = data,
       bdn = data,
       bde = data;
   final World world;
   // expand placed blocks to a police box
   double lowX = location.getX();
   double lowY = location.getY();
   double lowZ = location.getZ();
   location.setX(lowX + 0.5);
   location.setY(lowY + 2);
   location.setZ(lowZ + 0.5);
   // get relative locations
   x = location.getBlockX();
   plusx = (location.getBlockX() + 1);
   minusx = (location.getBlockX() - 1);
   final int y = location.getBlockY();
   final int plusy = (location.getBlockY() + 1),
       minusy = (location.getBlockY() - 1),
       down2y = (location.getBlockY() - 2),
       down3y = (location.getBlockY() - 3);
   z = (location.getBlockZ());
   plusz = (location.getBlockZ() + 1);
   minusz = (location.getBlockZ() - 1);
   world = location.getWorld();
   int south = mat, west = mat, north = mat, east = mat, signx = 0, signz = 0;
   String doorloc = "";
   // platform
   plugin.buildPB.addPlatform(location, false, d, p, tid);
   QueryFactory qf = new QueryFactory(plugin);
   HashMap<String, Object> ps = new HashMap<String, Object>();
   ps.put("tardis_id", tid);
   String loc = "";
   // get direction player is facing from yaw place block under door if block is in list of blocks
   // an iron door cannot go on
   switch (d) {
     case SOUTH:
       // if (yaw >= 315 || yaw < 45)
       plugin.utils.setBlockCheck(
           world, x, down3y, minusz, 35, grey, tid); // door is here if player facing south
       loc = world.getBlockAt(x, down3y, minusz).getLocation().toString();
       ps.put("location", loc);
       doorloc = world.getName() + ":" + x + ":" + down2y + ":" + minusz;
       sd = 2;
       signx = x;
       signz = (minusz - 1);
       south = 71;
       mds = 8;
       bds = 1;
       break;
     case EAST:
       // if (yaw >= 225 && yaw < 315)
       plugin.utils.setBlockCheck(
           world, minusx, down3y, z, 35, grey, tid); // door is here if player facing east
       loc = world.getBlockAt(minusx, down3y, z).getLocation().toString();
       ps.put("location", loc);
       doorloc = world.getName() + ":" + minusx + ":" + down2y + ":" + z;
       sd = 4;
       signx = (minusx - 1);
       signz = z;
       east = 71;
       mde = 8;
       bde = 0;
       break;
     case NORTH:
       // if (yaw >= 135 && yaw < 225)
       plugin.utils.setBlockCheck(
           world, x, down3y, plusz, 35, grey, tid); // door is here if player facing north
       loc = world.getBlockAt(x, down3y, plusz).getLocation().toString();
       ps.put("location", loc);
       doorloc = world.getName() + ":" + x + ":" + down2y + ":" + plusz;
       sd = 3;
       signx = x;
       signz = (plusz + 1);
       north = 71;
       mdn = 8;
       bdn = 3;
       break;
     case WEST:
       // if (yaw >= 45 && yaw < 135)
       plugin.utils.setBlockCheck(
           world, plusx, down3y, z, 35, grey, tid); // door is here if player facing west
       loc = world.getBlockAt(plusx, down3y, z).getLocation().toString();
       ps.put("location", loc);
       doorloc = world.getName() + ":" + plusx + ":" + down2y + ":" + z;
       sd = 5;
       signx = (plusx + 1);
       signz = z;
       west = 71;
       mdw = 8;
       bdw = 2;
       break;
   }
   ps.put("police_box", 1);
   qf.doInsert("blocks", ps);
   if (!loc.isEmpty()) {
     plugin.protectBlockMap.put(loc, tid);
   }
   // should insert the door when tardis is first made, and then update location there after!
   HashMap<String, Object> whered = new HashMap<String, Object>();
   whered.put("door_type", 0);
   whered.put("tardis_id", tid);
   ResultSetDoors rsd = new ResultSetDoors(plugin, whered, false);
   HashMap<String, Object> setd = new HashMap<String, Object>();
   setd.put("door_location", doorloc);
   if (rsd.resultSet()) {
     HashMap<String, Object> whereid = new HashMap<String, Object>();
     whereid.put("door_id", rsd.getDoor_id());
     qf.doUpdate("doors", setd, whereid);
   } else {
     setd.put("tardis_id", tid);
     setd.put("door_type", 0);
     setd.put("door_direction", d.toString());
     qf.doInsert("doors", setd);
   }
   // bottom layer corners
   plugin.utils.setBlockAndRemember(world, plusx, down2y, plusz, mat, data, tid);
   plugin.utils.setBlockAndRemember(world, minusx, down2y, plusz, mat, data, tid);
   plugin.utils.setBlockAndRemember(world, minusx, down2y, minusz, mat, data, tid);
   plugin.utils.setBlockAndRemember(world, plusx, down2y, minusz, mat, data, tid);
   // middle layer corners
   plugin.utils.setBlockAndRemember(world, plusx, minusy, plusz, mat, data, tid);
   plugin.utils.setBlockAndRemember(world, minusx, minusy, plusz, mat, data, tid);
   plugin.utils.setBlockAndRemember(world, minusx, minusy, minusz, mat, data, tid);
   plugin.utils.setBlockAndRemember(world, plusx, minusy, minusz, mat, data, tid);
   // top layer
   switch (mat) {
     case 18:
       plugin.utils.setBlockAndRemember(world, x, y, z, 17, data, tid);
       break;
     case 46:
       plugin.utils.setBlockAndRemember(world, x, y, z, 35, (byte) 14, tid);
       break;
     case 79:
       plugin.utils.setBlockAndRemember(world, x, y, z, 35, (byte) 3, tid);
       break;
     case 89:
       plugin.utils.setBlockAndRemember(world, x, y, z, 35, (byte) 4, tid);
       break;
     default:
       plugin.utils.setBlockAndRemember(world, x, y, z, mat, data, tid);
       break;
   }
   plugin.utils.setBlockAndRemember(world, plusx, y, z, mat, data, tid); // east
   plugin.utils.setBlockAndRemember(world, plusx, y, plusz, mat, data, tid);
   plugin.utils.setBlockAndRemember(world, x, y, plusz, mat, data, tid); // south
   plugin.utils.setBlockAndRemember(world, minusx, y, plusz, mat, data, tid);
   plugin.utils.setBlockAndRemember(world, minusx, y, z, mat, data, tid); // west
   plugin.utils.setBlockAndRemember(world, minusx, y, minusz, mat, data, tid);
   plugin.utils.setBlockAndRemember(world, x, y, minusz, mat, data, tid); // north
   plugin.utils.setBlockAndRemember(world, plusx, y, minusz, mat, data, tid);
   if (!plain) {
     // set sign
     plugin.utils.setBlock(world, signx, y, signz, 68, sd);
     Block sign = world.getBlockAt(signx, y, signz);
     if (sign.getType().equals(Material.WALL_SIGN)) {
       Sign s = (Sign) sign.getState();
       if (plugin.getConfig().getBoolean("name_tardis")) {
         HashMap<String, Object> wheret = new HashMap<String, Object>();
         wheret.put("tardis_id", tid);
         ResultSetTardis rst = new ResultSetTardis(plugin, wheret, "", false);
         if (rst.resultSet()) {
           String owner = rst.getOwner();
           if (owner.length() > 14) {
             s.setLine(0, owner.substring(0, 12) + "'s");
           } else {
             s.setLine(0, owner + "'s");
           }
         }
       }
       s.setLine(1, ChatColor.WHITE + "POLICE");
       s.setLine(2, ChatColor.WHITE + "BOX");
       s.update();
     }
     // put torch on top
     if (mat == 79) {
       plugin.utils.setBlockAndRemember(world, x, plusy, z, 76, (byte) 5, tid);
     } else {
       plugin.utils.setBlockAndRemember(world, x, plusy, z, lamp, (byte) 5, tid);
     }
   }
   // bottom layer with door bottom
   plugin.utils.setBlockAndRemember(world, plusx, down2y, z, west, bdw, tid);
   plugin.utils.setBlockAndRemember(world, x, down2y, plusz, north, bdn, tid);
   plugin.utils.setBlockAndRemember(world, minusx, down2y, z, east, bde, tid);
   plugin.utils.setBlockAndRemember(world, x, down2y, minusz, south, bds, tid);
   // middle layer with door top
   plugin.utils.setBlockAndRemember(world, plusx, minusy, z, west, mdw, tid);
   plugin.utils.setBlockAndRemember(world, x, minusy, plusz, north, mdn, tid);
   plugin.utils.setBlockAndRemember(world, minusx, minusy, z, east, mde, tid);
   plugin.utils.setBlockAndRemember(world, x, minusy, minusz, south, mds, tid);
   // message travellers in tardis
   HashMap<String, Object> where = new HashMap<String, Object>();
   where.put("tardis_id", tid);
   ResultSetTravellers rst = new ResultSetTravellers(plugin, where, true);
   if (rst.resultSet()) {
     final List<String> travellers = rst.getData();
     plugin
         .getServer()
         .getScheduler()
         .scheduleSyncDelayedTask(
             plugin,
             new Runnable() {
               @Override
               public void run() {
                 for (String s : travellers) {
                   Player p = plugin.getServer().getPlayer(s);
                   if (p != null) {
                     String message =
                         (mal)
                             ? "There was a malfunction and the emergency handbrake was engaged! Scan location before exit!"
                             : "LEFT-click the handbrake to exit!";
                     p.sendMessage(plugin.pluginName + message);
                   }
                 }
               }
             },
             30L);
   }
   plugin.tardisMaterialising.remove(Integer.valueOf(tid));
 }
Example #20
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);
   }
 }