/**
  * Make a list of the currently used TIPS slots.
  *
  * @return a list of slot numbers
  */
 private List<Integer> makeUsedSlotList() {
   List<Integer> usedSlots = new ArrayList<Integer>();
   Statement statement = null;
   ResultSet rs = null;
   String query = "SELECT tips FROM " + prefix + "tardis";
   try {
     statement = connection.createStatement();
     rs = statement.executeQuery(query);
     if (rs.isBeforeFirst()) {
       while (rs.next()) {
         usedSlots.add(rs.getInt("tips"));
       }
     }
   } catch (SQLException e) {
     plugin.debug("ResultSet error for tardis table! " + e.getMessage());
   } finally {
     try {
       if (rs != null) {
         rs.close();
       }
       if (statement != null) {
         statement.close();
       }
     } catch (SQLException e) {
       plugin.debug("Error closing tardis table! " + e.getMessage());
     }
   }
   return usedSlots;
 }
 /**
  * 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;
 }
Exemple #3
0
 @Override
 public void run() {
   PreparedStatement ps = null;
   String updates;
   String wheres;
   StringBuilder sbu = new StringBuilder();
   StringBuilder sbw = new StringBuilder();
   for (Map.Entry<String, Object> entry : data.entrySet()) {
     sbu.append(entry.getKey()).append(" = ?,");
   }
   for (Map.Entry<String, Object> entry : where.entrySet()) {
     sbw.append(entry.getKey()).append(" = ");
     if (entry.getValue().getClass().equals(String.class)
         || entry.getValue().getClass().equals(UUID.class)) {
       sbw.append("'").append(entry.getValue()).append("' AND ");
     } else {
       sbw.append(entry.getValue()).append(" AND ");
     }
   }
   where.clear();
   updates = sbu.toString().substring(0, sbu.length() - 1);
   wheres = sbw.toString().substring(0, sbw.length() - 5);
   String query = "UPDATE " + table + " SET " + updates + " WHERE " + wheres;
   try {
     service.testConnection(connection);
     ps = connection.prepareStatement(query);
     int s = 1;
     for (Map.Entry<String, Object> entry : data.entrySet()) {
       if (entry.getValue().getClass().equals(String.class)
           || entry.getValue().getClass().equals(UUID.class)) {
         ps.setString(s, entry.getValue().toString());
       }
       if (entry.getValue() instanceof Integer) {
         ps.setInt(s, (Integer) entry.getValue());
       }
       if (entry.getValue() instanceof Long) {
         ps.setLong(s, (Long) entry.getValue());
       }
       s++;
     }
     data.clear();
     ps.executeUpdate();
   } catch (SQLException e) {
     plugin.debug("Update error for " + table + "! " + e.getMessage());
   } finally {
     try {
       if (ps != null) {
         ps.close();
       }
     } catch (SQLException e) {
       plugin.debug("Error closing " + table + "! " + e.getMessage());
     }
   }
 }
 private void syncFetch(ArrayList<String> names) {
   final TARDISUUIDFetcher fetcher = new TARDISUUIDFetcher(names);
   try {
     cache.putAll(fetcher.call());
   } catch (Exception e) {
     plugin.debug("Error fetching UUID: " + e.getMessage());
   }
 }
 @Override
 public void run() {
   Statement statement = null;
   try {
     service.testConnection(connection);
     statement = connection.createStatement();
     String select =
         "SELECT c_id FROM controls WHERE tardis_id = "
             + id
             + " AND type = "
             + type
             + " AND secondary = "
             + s;
     ResultSet rs = statement.executeQuery(select);
     if (rs.isBeforeFirst()) {
       // update
       String update =
           "UPDATE controls SET location = '" + l + "' WHERE c_id = " + rs.getInt("c_id");
       statement.executeUpdate(update);
     } else {
       // insert
       String insert =
           "INSERT INTO controls (tardis_id, type, location, secondary) VALUES ("
               + id
               + ", "
               + type
               + ", '"
               + l
               + "', "
               + s
               + ")";
       statement.executeUpdate(insert);
     }
   } catch (SQLException e) {
     plugin.debug("Insert control error! " + e.getMessage());
   } finally {
     try {
       if (statement != null) {
         statement.close();
       }
     } catch (SQLException e) {
       plugin.debug("Error closing insert control statement! " + e.getMessage());
     }
   }
 }
 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");
 }
 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");
 }
 /** 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);
           }
         }
       }
     }
   }
 }
 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 + ">");
     }
   }
 }
 /** Convert pre-TARDIS v2.3 controls to the new system. */
 public void convertControls() {
   ResultSetTardis rs = new ResultSetTardis(plugin, null, "", true);
   if (rs.resultSet()) {
     int i = 0;
     ArrayList<HashMap<String, String>> data = rs.getData();
     Statement del = null;
     PreparedStatement ps = null;
     try {
       service.testConnection(connection);
       // clear the controls table first - just incase they have reset `conversion_done` in the
       // config
       del = connection.createStatement();
       del.executeUpdate("DELETE FROM controls");
       // insert values from tardis table
       ps =
           connection.prepareStatement(
               "INSERT INTO controls (tardis_id, type, location) VALUES (?,?,?)");
       for (HashMap<String, String> map : data) {
         int id = plugin.getUtils().parseInt(map.get("tardis_id"));
         String tmph;
         if (map.get("handbrake") == null || map.get("handbrake").isEmpty()) {
           tmph = estimateHandbrake(map.get("size"), map.get("chameleon"));
           plugin
               .getConsole()
               .sendMessage(
                   plugin.getPluginName()
                       + ChatColor.RED
                       + "Handbrake location not found, making an educated guess...");
         } else {
           tmph = map.get("handbrake");
         }
         String tmpb;
         if (map.get("button") == null || map.get("button").isEmpty()) {
           tmpb = estimateButton(map.get("size"), map.get("chameleon"));
           plugin
               .getConsole()
               .sendMessage(
                   plugin.getPluginName()
                       + ChatColor.RED
                       + "Button location not found, making an educated guess...");
         } else {
           tmpb = map.get("button");
         }
         String tmpa;
         if (map.get("artron_button") == null || map.get("artron_button").isEmpty()) {
           tmpa = estimateArtron(map.get("size"), map.get("chameleon"));
           plugin
               .getConsole()
               .sendMessage(
                   plugin.getPluginName()
                       + ChatColor.RED
                       + "Artron Button location not found, making an educated guess...");
         } else {
           tmpa = map.get("artron_button");
         }
         String[] tmpr = new String[4];
         if (map.get("repeater0") == null || map.get("repeater0").isEmpty()) {
           tmpr = estimateRepeaters(map.get("size"), map.get("chameleon"));
           plugin
               .getConsole()
               .sendMessage(
                   plugin.getPluginName()
                       + ChatColor.RED
                       + "Repeater locations not found, making an educated guess...");
         } else {
           tmpr[0] = map.get("repeater0");
           tmpr[1] = map.get("repeater1");
           tmpr[2] = map.get("repeater2");
           tmpr[3] = map.get("repeater3");
         }
         String hb = plugin.getUtils().makeLocationStr(tmph);
         String bn = plugin.getUtils().makeLocationStr(tmpb);
         String ab = plugin.getUtils().makeLocationStr(tmpa);
         ps.setInt(1, id);
         ps.setInt(2, 0);
         ps.setString(3, hb);
         ps.addBatch();
         ps.setInt(1, id);
         ps.setInt(2, 1);
         ps.setString(3, bn);
         ps.addBatch();
         ps.setInt(1, id);
         ps.setInt(2, 2);
         ps.setString(3, tmpr[0]);
         ps.addBatch();
         ps.setInt(1, id);
         ps.setInt(2, 3);
         ps.setString(3, tmpr[1]);
         ps.addBatch();
         ps.setInt(1, id);
         ps.setInt(2, 4);
         ps.setString(3, tmpr[2]);
         ps.addBatch();
         ps.setInt(1, id);
         ps.setInt(2, 5);
         ps.setString(3, tmpr[3]);
         ps.addBatch();
         ps.setInt(1, id);
         ps.setInt(2, 6);
         ps.setString(3, ab);
         ps.addBatch();
         connection.setAutoCommit(false);
         ps.executeBatch();
         connection.setAutoCommit(true);
         i++;
       }
     } catch (SQLException e) {
       plugin.debug("Control conversion error: " + e.getMessage());
     } finally {
       if (del != null) {
         try {
           del.close();
         } catch (SQLException e) {
           plugin.debug("Control delete statement close error: " + e.getMessage());
         }
       }
       if (ps != null) {
         try {
           ps.close();
         } catch (SQLException e) {
           plugin.debug("Control prepared statement close error: " + e.getMessage());
         }
       }
     }
     if (i > 0) {
       plugin
           .getConsole()
           .sendMessage(plugin.getPluginName() + "Converted " + i + " control consoles");
       plugin.getConfig().set("conversions.conversion_done", true);
       plugin.saveConfig();
     }
   }
 }
 public void addRecipes() {
   int i = 0;
   // fix lore
   recipes_config.set("shaped.Stattenheim Remote.lore", "Right-click block~to call TARDIS");
   recipes_config.set("shaped.Artron Storage Cell.lore", "Charge Level~0");
   //
   if (!recipes_config.contains("shaped.TARDIS Remote Key")) {
     recipes_config.set("shaped.TARDIS Remote Key.easy_shape", "RCR,-K-,-T-");
     recipes_config.set("shaped.TARDIS Remote Key.easy_ingredients.R", "REDSTONE");
     recipes_config.set("shaped.TARDIS Remote Key.easy_ingredients.C", "REDSTONE_COMPARATOR");
     recipes_config.set("shaped.TARDIS Remote Key.easy_ingredients.K", "GOLD_NUGGET");
     recipes_config.set("shaped.TARDIS Remote Key.easy_ingredients.T", "REDSTONE_TORCH_ON");
     recipes_config.set("shaped.TARDIS Remote Key.hard_shape", "RCR,-K-,-T-");
     recipes_config.set("shaped.TARDIS Remote Key.hard_ingredients.R", "REDSTONE");
     recipes_config.set("shaped.TARDIS Remote Key.hard_ingredients.C", "REDSTONE_COMPARATOR");
     recipes_config.set("shaped.TARDIS Remote Key.hard_ingredients.K", "GOLD_NUGGET");
     recipes_config.set("shaped.TARDIS Remote Key.hard_ingredients.T", "MAP:1964");
     recipes_config.set("shaped.TARDIS Remote Key.result", "GOLD_NUGGET");
     recipes_config.set("shaped.TARDIS Remote Key.amount", 1);
     recipes_config.set("shaped.TARDIS Remote Key.lore", "Deadlock & unlock~Hide & rebuild");
   } else if (recipes_config
       .getString("shaped.TARDIS Remote Key.easy_ingredients.T")
       .equals("REDSTONE_TORCH")) {
     recipes_config.set("shaped.TARDIS Remote Key.easy_ingredients.T", "REDSTONE_TORCH_ON");
   }
   if (!recipes_config.contains("shaped.White Bow Tie")) {
     for (Map.Entry<String, Integer> map : colours.entrySet()) {
       recipes_config.set("shaped." + map.getKey() + " Bow Tie.easy_shape", "---,SWS,---");
       recipes_config.set("shaped." + map.getKey() + " Bow Tie.easy_ingredients.S", "STRING");
       recipes_config.set(
           "shaped." + map.getKey() + " Bow Tie.easy_ingredients.W", "WOOL:" + map.getValue());
       recipes_config.set("shaped." + map.getKey() + " Bow Tie.hard_shape", "STS,L-L,WWW");
       recipes_config.set("shaped." + map.getKey() + " Bow Tie.hard_ingredients.S", "STRING");
       recipes_config.set(
           "shaped." + map.getKey() + " Bow Tie.hard_ingredients.T", "TRIPWIRE_HOOK");
       recipes_config.set("shaped." + map.getKey() + " Bow Tie.hard_ingredients.L", "LEATHER");
       recipes_config.set(
           "shaped." + map.getKey() + " Bow Tie.hard_ingredients.W", "WOOL:" + map.getValue());
       recipes_config.set("shaped." + map.getKey() + " Bow Tie.result", "LEATHER_CHESTPLATE");
       recipes_config.set("shaped." + map.getKey() + " Bow Tie.amount", 1);
       recipes_config.set("shaped." + map.getKey() + " Bow Tie.lore", "Bow ties are cool!");
       i++;
     }
   }
   if (!recipes_config.contains("shaped.3-D Glasses")) {
     recipes_config.set("shaped.3-D Glasses.easy_shape", "---,P-P,CPM");
     recipes_config.set("shaped.3-D Glasses.easy_ingredients.P", "PAPER");
     recipes_config.set("shaped.3-D Glasses.easy_ingredients.C", "STAINED_GLASS_PANE:9");
     recipes_config.set("shaped.3-D Glasses.easy_ingredients.M", "STAINED_GLASS_PANE:2");
     recipes_config.set("shaped.3-D Glasses.hard_shape", "R-T,P-P,CPM");
     recipes_config.set("shaped.3-D Glasses.hard_ingredients.R", "REDSTONE_COMPARATOR");
     recipes_config.set("shaped.3-D Glasses.hard_ingredients.T", "REDSTONE_TORCH_ON");
     recipes_config.set("shaped.3-D Glasses.hard_ingredients.P", "PAPER");
     recipes_config.set("shaped.3-D Glasses.hard_ingredients.C", "STAINED_GLASS_PANE:9");
     recipes_config.set("shaped.3-D Glasses.hard_ingredients.M", "STAINED_GLASS_PANE:2");
     recipes_config.set("shaped.3-D Glasses.result", "LEATHER_HELMET");
     recipes_config.set("shaped.3-D Glasses.amount", 1);
     recipes_config.set("shaped.3-D Glasses.lore", "");
     i++;
   }
   if (!recipes_config.contains("shaped.Fob Watch")) {
     recipes_config.set("shaped.Fob Watch.easy_shape", "-C-,-W-,R-R");
     recipes_config.set("shaped.Fob Watch.easy_ingredients.C", "MAP:1966");
     recipes_config.set("shaped.Fob Watch.easy_ingredients.W", "WATCH");
     recipes_config.set("shaped.Fob Watch.easy_ingredients.R", "REDSTONE");
     recipes_config.set("shaped.Fob Watch.hard_shape", "-C-,IWI,R-R");
     recipes_config.set("shaped.Fob Watch.hard_ingredients.C", "MAP:1966");
     recipes_config.set("shaped.Fob Watch.hard_ingredients.W", "WATCH");
     recipes_config.set("shaped.Fob Watch.hard_ingredients.I", "IRON_INGOT");
     recipes_config.set("shaped.Fob Watch.hard_ingredients.R", "REDSTONE");
     recipes_config.set("shaped.Fob Watch.result", "WATCH");
     recipes_config.set("shaped.Fob Watch.amount", 1);
     recipes_config.set("shaped.Fob Watch.lore", "");
     i++;
   }
   if (!recipes_config.contains("shaped.Jammy Dodger")) {
     recipes_config.set("shaped.Jammy Dodger.easy_shape", "---,WRW,---");
     recipes_config.set("shaped.Jammy Dodger.easy_ingredients.W", "WHEAT");
     recipes_config.set("shaped.Jammy Dodger.easy_ingredients.R", "INK_SACK:1");
     recipes_config.set("shaped.Jammy Dodger.hard_shape", "---,WRW,---");
     recipes_config.set("shaped.Jammy Dodger.hard_ingredients.W", "WHEAT");
     recipes_config.set("shaped.Jammy Dodger.hard_ingredients.R", "INK_SACK:1");
     recipes_config.set("shaped.Jammy Dodger.result", "COOKIE");
     recipes_config.set("shaped.Jammy Dodger.amount", 8);
     recipes_config.set("shaped.Jammy Dodger.lore", "");
     i++;
   }
   if (!recipes_config.contains("shaped.Fish Finger")) {
     recipes_config.set("shaped.Fish Finger.easy_shape", "-B-,-F-,-B-");
     recipes_config.set("shaped.Fish Finger.easy_ingredients.B", "BREAD");
     recipes_config.set("shaped.Fish Finger.easy_ingredients.F", "RAW_FISH");
     recipes_config.set("shaped.Fish Finger.hard_shape", "-B-,-F-,-B-");
     recipes_config.set("shaped.Fish Finger.hard_ingredients.B", "BREAD");
     recipes_config.set("shaped.Fish Finger.hard_ingredients.F", "RAW_FISH");
     recipes_config.set("shaped.Fish Finger.result", "COOKED_FISH");
     recipes_config.set("shaped.Fish Finger.amount", 3);
     recipes_config.set("shaped.Fish Finger.lore", "Best eaten with custard!");
     i++;
   }
   if (!recipes_config.contains("shapeless.Bowl of Custard")) {
     recipes_config.set("shapeless.Bowl of Custard.recipe", "BOWL,MILK_BUCKET,EGG");
     recipes_config.set("shapeless.Bowl of Custard.result", "MUSHROOM_SOUP");
     recipes_config.set("shapeless.Bowl of Custard.amount", 1);
     recipes_config.set("shapeless.Bowl of Custard.lore", "");
     i++;
   }
   if (!recipes_config.contains("shapeless.Vanilla Jelly Baby")) {
     for (Map.Entry<String, Integer> map : flavours.entrySet()) {
       recipes_config.set(
           "shapeless." + map.getKey() + " Jelly Baby.recipe",
           "SUGAR,SLIME_BALL,INK_SACK:" + map.getValue());
       recipes_config.set("shapeless." + map.getKey() + " Jelly Baby.result", "MELON");
       recipes_config.set("shapeless." + map.getKey() + " Jelly Baby.amount", 4);
       recipes_config.set("shapeless." + map.getKey() + " Jelly Baby.lore", "");
       i++;
     }
   }
   if (!recipes_config.contains("shaped.TARDIS Randomiser Circuit")) {
     recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_shape", "-D-,NCE,-W-");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_ingredients.D", "DIRT");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_ingredients.N", "NETHERRACK");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_ingredients.C", "COMPASS");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_ingredients.E", "ENDER_STONE");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.easy_ingredients.W", "WATER_BUCKET");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_shape", "-D-,NCE,-W-");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_ingredients.D", "DIRT");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_ingredients.N", "NETHERRACK");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_ingredients.C", "COMPASS");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_ingredients.E", "ENDER_STONE");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.hard_ingredients.W", "WATER_BUCKET");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.result", "MAP:1980");
     recipes_config.set("shaped.TARDIS Randomiser Circuit.amount", 1);
     recipes_config.set("shaped.TARDIS Randomiser Circuit.lore", "Uses left~50");
     i++;
   }
   if (!recipes_config.contains("shaped.TARDIS Invisibility Circuit")) {
     recipes_config.set("shaped.TARDIS Invisibility Circuit.easy_shape", "-D-,P-E,-W-");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.easy_ingredients.D", "DIAMOND");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.easy_ingredients.P", "MAP:1978");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.easy_ingredients.E", "EMERALD");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.easy_ingredients.W", "POTION:8206");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.hard_shape", "-D-,P-E,-W-");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.hard_ingredients.D", "DIAMOND");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.hard_ingredients.P", "MAP:1978");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.hard_ingredients.E", "EMERALD");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.hard_ingredients.W", "POTION:8270");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.result", "MAP:1981");
     recipes_config.set("shaped.TARDIS Invisibility Circuit.amount", 1);
     recipes_config.set("shaped.TARDIS Invisibility Circuit.lore", "Uses left~5");
     i++;
   }
   if (!recipes_config.contains("shaped.Painter Circuit")) {
     recipes_config.set("shaped.Painter Circuit.easy_shape", "-I-,DGD,-I-");
     recipes_config.set("shaped.Painter Circuit.easy_ingredients.I", "INK_SACK:0");
     recipes_config.set("shaped.Painter Circuit.easy_ingredients.D", "INK_SACK:5");
     recipes_config.set("shaped.Painter Circuit.easy_ingredients.G", "GOLD_NUGGET");
     recipes_config.set("shaped.Painter Circuit.hard_shape", "-I-,DGD,-I-");
     recipes_config.set("shaped.Painter Circuit.hard_ingredients.I", "INK_SACK:0");
     recipes_config.set("shaped.Painter Circuit.hard_ingredients.D", "INK_SACK:5");
     recipes_config.set("shaped.Painter Circuit.hard_ingredients.G", "GOLD_BLOCK");
     recipes_config.set("shaped.Painter Circuit.result", "MAP:1979");
     recipes_config.set("shaped.Painter Circuit.amount", 1);
     recipes_config.set("shaped.Painter Circuit.lore", "");
     i++;
   } else {
     // fix the hard recipe if necessary
     if (recipes_config.get("shaped.Painter Circuit.hard_shape").equals("-B-,-F-,-B-")) {
       recipes_config.set("shaped.Painter Circuit.hard_shape", "-I-,DGD,-I-");
     }
   }
   if (!recipes_config.contains("shapeless.Painter Upgrade")) {
     recipes_config.set("shapeless.Painter Upgrade.recipe", "BLAZE_ROD,MAP:1979");
     recipes_config.set("shapeless.Painter Upgrade.result", "BLAZE_ROD");
     recipes_config.set("shapeless.Painter Upgrade.amount", 1);
     recipes_config.set("shapeless.Painter Upgrade.lore", "");
     i++;
   }
   if (!recipes_config.contains("shaped.Ignite Circuit")) {
     recipes_config.set("shaped.Ignite Circuit.easy_shape", "-N-,NFN,-N-");
     recipes_config.set("shaped.Ignite Circuit.easy_ingredients.N", "NETHERRACK");
     recipes_config.set("shaped.Ignite Circuit.easy_ingredients.F", "FLINT_AND_STEEL");
     recipes_config.set("shaped.Ignite Circuit.hard_shape", "LN-,NFN,-NL");
     recipes_config.set("shaped.Ignite Circuit.hard_ingredients.N", "NETHERRACK");
     recipes_config.set("shaped.Ignite Circuit.hard_ingredients.F", "FLINT_AND_STEEL");
     recipes_config.set("shaped.Ignite Circuit.hard_ingredients.L", "LAVA_BUCKET");
     recipes_config.set("shaped.Ignite Circuit.result", "MAP:1982");
     recipes_config.set("shaped.Ignite Circuit.amount", 1);
     recipes_config.set("shaped.Ignite Circuit.lore", "");
     i++;
   }
   if (!recipes_config.contains("shapeless.Ignite Upgrade")) {
     recipes_config.set("shapeless.Ignite Upgrade.recipe", "BLAZE_ROD,MAP:1982");
     recipes_config.set("shapeless.Ignite Upgrade.result", "BLAZE_ROD");
     recipes_config.set("shapeless.Ignite Upgrade.amount", 1);
     recipes_config.set("shapeless.Ignite Upgrade.lore", "");
     i++;
   }
   if (!recipes_config.contains("shaped.TARDIS Artron Furnace")) {
     recipes_config.set("shaped.TARDIS Artron Furnace.easy_shape", "---,OFO,RRR");
     recipes_config.set("shaped.TARDIS Artron Furnace.easy_ingredients.O", "OBSIDIAN");
     recipes_config.set("shaped.TARDIS Artron Furnace.easy_ingredients.F", "FURNACE");
     recipes_config.set("shaped.TARDIS Artron Furnace.easy_ingredients.R", "REDSTONE");
     recipes_config.set("shaped.TARDIS Artron Furnace.hard_shape", "---,OFO,RRR");
     recipes_config.set("shaped.TARDIS Artron Furnace.hard_ingredients.O", "OBSIDIAN");
     recipes_config.set("shaped.TARDIS Artron Furnace.hard_ingredients.F", "FURNACE");
     recipes_config.set("shaped.TARDIS Artron Furnace.hard_ingredients.R", "REDSTONE");
     recipes_config.set("shaped.TARDIS Artron Furnace.result", "FURNACE");
     recipes_config.set("shaped.TARDIS Artron Furnace.amount", 1);
     recipes_config.set("shaped.TARDIS Artron Furnace.lore", "");
     i++;
   }
   for (Map.Entry<String, Integer> uses : damage.entrySet()) {
     if (recipes_config.getString(uses.getKey()).isEmpty()) {
       recipes_config.set(uses.getKey(), "Uses left~" + uses.getValue());
     }
   }
   try {
     recipes_config.save(new File(plugin.getDataFolder(), "recipes.yml"));
     if (i > 0) {
       plugin
           .getConsole()
           .sendMessage(
               plugin.getPluginName()
                   + "Added "
                   + ChatColor.AQUA
                   + i
                   + ChatColor.RESET
                   + " new items to recipes.yml");
     }
     String key = recipes_config.getString("shaped.TARDIS Key.result");
     if (!key.equals(plugin.getConfig().getString("preferences.key"))) {
       plugin
           .getConsole()
           .sendMessage(
               plugin.getPluginName()
                   + "The TARDIS Key recipe result (recipes.yml) does not match the configured key preference (config.yml)");
     }
     String r_key_5 = recipes_config.getString("shaped.TARDIS Remote Key.easy_ingredients.K");
     if (r_key_5 != null && !key.equals(r_key_5)) {
       plugin
           .getConsole()
           .sendMessage(
               plugin.getPluginName()
                   + "The TARDIS Key ingredient ("
                   + r_key_5
                   + ") in the 'TARDIS Remote Key' recipe does not match the crafting result of the 'TARDIS Key' recipe ("
                   + key
                   + ") - they should be the same!");
     }
   } catch (IOException io) {
     plugin.debug("Could not save recipes.yml, " + io);
   }
 }
 /** Adds new fields to tables in the database. */
 public void updateTables() {
   int i = 0;
   try {
     for (String u : uuidUpdates) {
       String a_query =
           "SELECT sql FROM sqlite_master WHERE tbl_name = '" + u + "' AND sql LIKE '%uuid%'";
       ResultSet rsu = statement.executeQuery(a_query);
       if (!rsu.next()) {
         i++;
         String u_alter = "ALTER TABLE " + u + " ADD uuid TEXT DEFAULT ''";
         statement.executeUpdate(u_alter);
       }
     }
     for (String a : areaupdates) {
       String[] asplit = a.split(" ");
       String acheck = asplit[0] + " " + asplit[1].substring(0, 3);
       String a_query =
           "SELECT sql FROM sqlite_master WHERE tbl_name = 'areas' AND sql LIKE '%"
               + acheck
               + "%'";
       ResultSet rsa = statement.executeQuery(a_query);
       if (!rsa.next()) {
         i++;
         String a_alter = "ALTER TABLE areas ADD " + a;
         statement.executeUpdate(a_alter);
       }
     }
     for (String b : blockupdates) {
       String[] bsplit = b.split(" ");
       String b_query =
           "SELECT sql FROM sqlite_master WHERE tbl_name = 'blocks' AND sql LIKE '%"
               + bsplit[0]
               + "%'";
       ResultSet rsb = statement.executeQuery(b_query);
       if (!rsb.next()) {
         i++;
         String b_alter = "ALTER TABLE blocks ADD " + b;
         statement.executeUpdate(b_alter);
       }
     }
     for (String c : countupdates) {
       String[] csplit = c.split(" ");
       String c_query =
           "SELECT sql FROM sqlite_master WHERE tbl_name = 't_count' AND sql LIKE '%"
               + csplit[0]
               + "%'";
       ResultSet rsc = statement.executeQuery(c_query);
       if (!rsc.next()) {
         i++;
         String c_alter = "ALTER TABLE t_count ADD " + c;
         statement.executeUpdate(c_alter);
       }
     }
     for (String d : destupdates) {
       String[] dsplit = d.split(" ");
       String d_query =
           "SELECT sql FROM sqlite_master WHERE tbl_name = 'destinations' AND sql LIKE '%"
               + dsplit[0]
               + "%'";
       ResultSet rsd = statement.executeQuery(d_query);
       if (!rsd.next()) {
         i++;
         String d_alter = "ALTER TABLE destinations ADD " + d;
         statement.executeUpdate(d_alter);
       }
     }
     for (String o : doorupdates) {
       String[] osplit = o.split(" ");
       String o_query =
           "SELECT sql FROM sqlite_master WHERE tbl_name = 'doors' AND sql LIKE '%"
               + osplit[0]
               + "%'";
       ResultSet rso = statement.executeQuery(o_query);
       if (!rso.next()) {
         i++;
         String o_alter = "ALTER TABLE doors ADD " + o;
         statement.executeUpdate(o_alter);
       }
     }
     for (String g : gravityupdates) {
       String[] gsplit = g.split(" ");
       String g_query =
           "SELECT sql FROM sqlite_master WHERE tbl_name = 'gravity_well' AND sql LIKE '%"
               + gsplit[0]
               + "%'";
       ResultSet rsg = statement.executeQuery(g_query);
       if (!rsg.next()) {
         i++;
         String g_alter = "ALTER TABLE gravity_well ADD " + g;
         statement.executeUpdate(g_alter);
       }
     }
     for (String p : prefsupdates) {
       String[] psplit = p.split(" ");
       String pcheck = psplit[0] + " " + psplit[1].substring(0, 3);
       String p_query =
           "SELECT sql FROM sqlite_master WHERE tbl_name = 'player_prefs' AND sql LIKE '%"
               + pcheck
               + "%'";
       ResultSet rsp = statement.executeQuery(p_query);
       if (!rsp.next()) {
         i++;
         String p_alter = "ALTER TABLE player_prefs ADD " + p;
         statement.executeUpdate(p_alter);
       }
     }
     for (String t : tardisupdates) {
       String[] tsplit = t.split(" ");
       String t_query =
           "SELECT sql FROM sqlite_master WHERE tbl_name = 'tardis' AND sql LIKE '%"
               + tsplit[0]
               + "%'";
       ResultSet rst = statement.executeQuery(t_query);
       if (!rst.next()) {
         i++;
         String t_alter = "ALTER TABLE tardis ADD " + t;
         statement.executeUpdate(t_alter);
       }
     }
     for (String v : inventoryupdates) {
       String[] vsplit = v.split(" ");
       String v_query =
           "SELECT sql FROM sqlite_master WHERE tbl_name = 'inventories' AND sql LIKE '%"
               + vsplit[0]
               + "%'";
       ResultSet rsv = statement.executeQuery(v_query);
       if (!rsv.next()) {
         i++;
         String v_alter = "ALTER TABLE inventories ADD " + v;
         statement.executeUpdate(v_alter);
       }
     }
     // add biome to current location
     String bio_query =
         "SELECT sql FROM sqlite_master WHERE tbl_name = 'current' AND sql LIKE '%biome%'";
     ResultSet rsbio = statement.executeQuery(bio_query);
     if (!rsbio.next()) {
       i++;
       String bio_alter = "ALTER TABLE current ADD biome TEXT DEFAULT ''";
       statement.executeUpdate(bio_alter);
     }
   } catch (SQLException e) {
     plugin.debug("SQLite database add fields error: " + e.getMessage() + e.getErrorCode());
   }
   if (i > 0) {
     plugin
         .getConsole()
         .sendMessage(
             TARDIS.plugin.getPluginName()
                 + "Added "
                 + ChatColor.AQUA
                 + i
                 + ChatColor.RESET
                 + " fields to the SQLite database!");
   }
 }
  /**
   * Reads a WorldEdit schematic file and writes the data to a CSV file. The dimensions of the
   * schematics are also stored for use by the room builder.
   *
   * @param fileStr the schematic file to read
   * @param s the schematic name
   * @param rotate whether to rotate the schematic 90 degrees counter-clockwise
   * @return true or false depending on whether the room is square or not
   */
  public boolean readAndMakeRoomCSV(String fileStr, String s, boolean rotate) {
    HashMap<String, Integer> blockIDs = new HashMap<String, Integer>();
    boolean square = true;
    plugin.debug("Loading schematic: " + fileStr + ".schematic");
    FileInputStream fis = null;
    try {
      File f = new File(fileStr + ".schematic");
      fis = new FileInputStream(f);
      NBTInputStream nbt = new NBTInputStream(fis);
      CompoundTag backuptag = (CompoundTag) nbt.readTag();
      Map<String, Tag> tagCollection = backuptag.getValue();

      short width = (Short) getChildTag(tagCollection, "Width", ShortTag.class).getValue();
      short height = (Short) getChildTag(tagCollection, "Height", ShortTag.class).getValue();
      short length = (Short) getChildTag(tagCollection, "Length", ShortTag.class).getValue();

      // check the room is square - should never fail on plugin enable as schematics are checked
      // when added
      if (width != length) {
        plugin.console.sendMessage(
            plugin.pluginName + "Load failed - schematic had unequal length sides!");
        square = false;
      } else {
        short[] dimensions = new short[3];
        dimensions[0] = height;
        dimensions[1] = width;
        dimensions[2] = length;
        plugin.room_dimensions.put(s, dimensions);

        byte[] blocks =
            (byte[]) getChildTag(tagCollection, "Blocks", ByteArrayTag.class).getValue();
        byte[] data = (byte[]) getChildTag(tagCollection, "Data", ByteArrayTag.class).getValue();

        nbt.close();
        fis.close();
        int i = 0;
        String[] blockdata = new String[width * height * length];
        int adjust = 256;
        for (byte b : blocks) {
          if (!ignoreBlocks.contains(b)) {
            Integer bid = (b < (byte) 0) ? b + adjust : b;
            if (blockConversion.containsKey(bid)) {
              bid = blockConversion.get(bid);
            }
            if (bid == 35 && (data[i] == 1 || data[i] == 8)) {
              String bstr = bid + ":" + data[i];
              if (blockIDs.containsKey(bstr)) {
                Integer count = blockIDs.get(bstr) + 1;
                blockIDs.put(bstr, count);
              } else {
                blockIDs.put(bstr, 1);
              }
            } else {
              if (blockIDs.containsKey(bid.toString())) {
                Integer count = blockIDs.get(bid.toString()) + 1;
                blockIDs.put(bid.toString(), count);
              } else {
                blockIDs.put(bid.toString(), 1);
              }
            }
          }
          blockdata[i] = b + ":" + data[i];
          i++;
        }
        plugin.roomBlockCounts.put(s, blockIDs);
        int j = 0;
        List<String[][]> layers = new ArrayList<String[][]>();
        for (int h = 0; h < height; h++) {
          String[][] strarr = new String[width][length];
          for (int w = 0; w < width; w++) {
            for (int l = 0; l < length; l++) {
              strarr[w][l] = blockdata[j];
              j++;
            }
          }
          if (rotate) {
            strarr = rotateSquareCCW(strarr);
          }
          layers.add(strarr);
        }
        try {
          String csvFile = (rotate) ? fileStr + "_EW.csv" : fileStr + ".csv";
          File file = new File(csvFile);
          BufferedWriter bw = new BufferedWriter(new FileWriter(file, false));
          for (String[][] l : layers) {
            for (String[] lines : l) {
              StringBuilder buf = new StringBuilder();
              for (String bd : lines) {
                buf.append(bd).append(",");
              }
              String commas = buf.toString();
              String strCommas = commas.substring(0, (commas.length() - 1));
              bw.write(strCommas);
              bw.newLine();
            }
          }
          bw.close();

        } catch (IOException io) {
          plugin.console.sendMessage(plugin.pluginName + "Could not save the room csv file!");
        }
      }
    } catch (IOException e) {
      plugin.console.sendMessage(plugin.pluginName + "Schematic read error: " + e);
    } finally {
      if (fis != null) {
        try {
          fis.close();
        } catch (IOException e) {
        }
      }
    }
    return square;
  }
 /**
  * Listens for player clicking blocks. If the player's name is contained in various tracking
  * HashMaps then we know that they are trying to create a TARDIS area.
  *
  * @param event a player clicking a block
  */
 @EventHandler(priority = EventPriority.MONITOR)
 public void onAreaInteract(PlayerInteractEvent event) {
   final Player player = event.getPlayer();
   final String playerNameStr = player.getName();
   Block block = event.getClickedBlock();
   if (block != null) {
     if (plugin.trackPreset.containsKey(playerNameStr)) {
       String[] split = plugin.trackPreset.get(playerNameStr).split(":");
       String name = split[0];
       String bool = split[1];
       Location block_loc = block.getLocation();
       World w = block_loc.getWorld();
       int fx = block_loc.getBlockX();
       int fy = block_loc.getBlockY();
       int fz = block_loc.getBlockZ();
       player.sendMessage(plugin.pluginName + "Scanning 3 x 3 x 4 area...");
       StringBuilder sb_id = new StringBuilder("[");
       StringBuilder sb_data = new StringBuilder("[");
       StringBuilder sb_stain_id = new StringBuilder("[");
       StringBuilder sb_stain_data = new StringBuilder("[");
       StringBuilder sb_glass_id = new StringBuilder("[");
       StringBuilder sb_glass_data = new StringBuilder("[");
       for (int c = 0; c < 10; c++) {
         sb_id.append("[");
         sb_data.append("[");
         sb_stain_id.append("[");
         sb_stain_data.append("[");
         sb_glass_id.append("[");
         sb_glass_data.append("[");
         for (int y = fy; y < (fy + 4); y++) {
           Block b = w.getBlockAt(fx + orderx[c], y, fz + orderz[c]);
           int id = b.getTypeId();
           if (id == 19) {
             id = 0; // convert sponge to air
           }
           byte data = b.getData();
           if (y == (fy + 3)) {
             sb_id.append(id);
             sb_data.append(data);
             if (not_glass.contains(id)) {
               sb_stain_id.append(id);
               sb_stain_data.append(data);
               sb_glass_id.append(id);
               sb_glass_data.append(data);
             } else {
               sb_stain_id.append(95);
               byte colour = plugin.lookup.getStain().get(id);
               if (colour == -1) {
                 // use the same data as the original block
                 colour = data;
               }
               sb_stain_data.append(colour); // get the appropiately coloured stained glass
               sb_glass_id.append(20);
               sb_glass_data.append(0);
             }
           } else {
             sb_id.append(id).append(",");
             sb_data.append(data).append(",");
             if (not_glass.contains(id)) {
               sb_stain_id.append(id).append(",");
               sb_stain_data.append(data).append(",");
               sb_glass_id.append(id).append(",");
               sb_glass_data.append(data).append(",");
             } else {
               sb_stain_id.append(95).append(",");
               byte colour = plugin.lookup.getStain().get(id);
               if (colour == -1) {
                 // use the same data as the original block
                 colour = data;
               }
               sb_stain_data
                   .append(colour)
                   .append(","); // get the appropiately coloured stained glass
               sb_glass_id.append(20).append(",");
               sb_glass_data.append(0).append(",");
             }
           }
         }
         if (c == 9) {
           sb_id.append("]");
           sb_data.append("]");
           sb_stain_id.append("]");
           sb_stain_data.append("]");
           sb_glass_id.append("]");
           sb_glass_data.append("]");
         } else {
           sb_id.append("],");
           sb_data.append("],");
           sb_stain_id.append("],");
           sb_stain_data.append("],");
           sb_glass_id.append("],");
           sb_glass_data.append("],");
         }
       }
       sb_id.append("]");
       sb_data.append("]");
       sb_stain_id.append("]");
       sb_stain_data.append("]");
       sb_glass_id.append("]");
       sb_glass_data.append("]");
       String ids = sb_id.toString();
       String datas = sb_data.toString();
       String stain_ids = sb_stain_id.toString();
       String stain_datas = sb_stain_data.toString();
       String glass_ids = sb_glass_id.toString();
       String glass_datas = sb_glass_data.toString();
       String filename = "custom_preset_" + name + ".txt";
       String file = plugin.getDataFolder() + File.separator + filename;
       try {
         BufferedWriter bw = new BufferedWriter(new FileWriter(file, false));
         bw.write("##start custom blueprint");
         bw.newLine();
         bw.write("#id");
         bw.newLine();
         bw.write(ids);
         bw.newLine();
         bw.write("#data");
         bw.newLine();
         bw.write(datas);
         bw.newLine();
         bw.write("##start custom stain");
         bw.newLine();
         bw.write("#id");
         bw.newLine();
         bw.write(stain_ids);
         bw.newLine();
         bw.write("#data");
         bw.newLine();
         bw.write(stain_datas);
         bw.newLine();
         bw.write("##start custom glass");
         bw.newLine();
         bw.write("#id");
         bw.newLine();
         bw.write(glass_ids);
         bw.newLine();
         bw.write("#data");
         bw.newLine();
         bw.write(glass_datas);
         bw.newLine();
         bw.write("##sign text - first line is player's name");
         bw.newLine();
         bw.write("#second line");
         bw.newLine();
         bw.write(name);
         bw.newLine();
         bw.write("#third line");
         bw.newLine();
         bw.write("PRESET");
         bw.newLine();
         bw.write(
             "#is the preset asymmetrical? for example are some of the corners different to others");
         bw.newLine();
         bw.write(bool);
         bw.close();
       } catch (IOException e) {
         plugin.debug("Could not create and write to " + filename + "! " + e.getMessage());
       }
       plugin.trackPreset.remove(playerNameStr);
       player.sendMessage(
           plugin.pluginName
               + "Scanning complete! "
               + filename
               + " written to the plugins/TARDIS folder.");
     }
   }
 }
 /**
  * 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 destinations" + 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.utils.parseInt(entry.getValue().toString()));
         }
         s++;
       }
       where.clear();
     }
     rs = statement.executeQuery();
     if (rs.isBeforeFirst()) {
       while (rs.next()) {
         if (multiple) {
           HashMap<String, String> row = new HashMap<String, String>();
           ResultSetMetaData rsmd = rs.getMetaData();
           int columns = rsmd.getColumnCount();
           for (int i = 1; i < columns + 1; i++) {
             row.put(rsmd.getColumnName(i).toLowerCase(Locale.ENGLISH), rs.getString(i));
           }
           data.add(row);
         }
         this.dest_id = rs.getInt("dest_id");
         this.tardis_id = rs.getInt("tardis_id");
         this.dest_name = rs.getString("dest_name");
         this.world = rs.getString("world");
         this.x = rs.getInt("x");
         this.y = rs.getInt("y");
         this.z = rs.getInt("z");
         this.direction = rs.getString("direction");
         this.submarine = rs.getBoolean("submarine");
         this.bind = rs.getString("bind");
         this.type = rs.getInt("type");
       }
     } 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 true;
 }