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);
     }
   }
 }
 /**
  * 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;
 }
Example #3
0
 public Location getMalfunction() {
   Location l;
   // get cuurent TARDIS preset location
   HashMap<String, Object> wherecl = new HashMap<String, Object>();
   wherecl.put("tardis_id", id);
   ResultSetCurrentLocation rscl = new ResultSetCurrentLocation(plugin, wherecl);
   if (rscl.resultSet()) {
     Location cl = new Location(rscl.getWorld(), rscl.getX(), rscl.getY(), rscl.getZ());
     int end = 100 - plugin.getConfig().getInt("preferences.malfunction_end");
     int nether = end - plugin.getConfig().getInt("preferences.malfunction_nether");
     int r = rand.nextInt(100);
     TARDISTimeTravel tt = new TARDISTimeTravel(plugin);
     byte x = (byte) rand.nextInt(15);
     byte z = (byte) rand.nextInt(15);
     byte y = (byte) rand.nextInt(15);
     if (r > end) {
       // get random the_end location
       l = tt.randomDestination(p, x, z, y, dir, "THE_END", null, true, cl);
     } else if (r > nether) {
       // get random nether location
       l = tt.randomDestination(p, x, z, y, dir, "NETHER", null, true, cl);
     } else {
       // get random normal location
       l = tt.randomDestination(p, x, z, y, dir, "NORMAL", null, false, cl);
     }
   } else {
     l = null;
   }
   if (l != null) {
     doMalfunction(l);
   }
   return l;
 }
 public boolean eject(Player player) {
   if (!player.hasPermission("tardis.eject")) {
     TARDISMessage.send(player, "NO_PERMS");
     return true;
   }
   // check they are still in the TARDIS world
   if (!plugin.getUtils().inTARDISWorld(player)) {
     TARDISMessage.send(player, "CMD_IN_WORLD");
     return true;
   }
   // must have a TARDIS
   ResultSetTardisID rs = new ResultSetTardisID(plugin);
   if (!rs.fromUUID(player.getUniqueId().toString())) {
     TARDISMessage.send(player, "NOT_A_TIMELORD");
     return false;
   }
   int ownerid = rs.getTardis_id();
   HashMap<String, Object> wheret = new HashMap<String, Object>();
   wheret.put("uuid", player.getUniqueId().toString());
   ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);
   if (!rst.resultSet()) {
     TARDISMessage.send(player, "NOT_IN_TARDIS");
     return false;
   }
   int thisid = rst.getTardis_id();
   // must be timelord of the TARDIS
   if (thisid != ownerid) {
     TARDISMessage.send(player, "CMD_ONLY_TL");
     return false;
   }
   // track the player
   plugin.getTrackerKeeper().getEjecting().put(player.getUniqueId(), thisid);
   return true;
 }
 /**
  * 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;
 }
  public boolean doExterminate(Player player) {

    if (!plugin.getTrackerKeeper().getExterminate().containsKey(player.getUniqueId())) {
      TARDISMessage.send(player, "TARDIS_BREAK_SIGN");
      return false;
    }
    TARDISExterminator del = new TARDISExterminator(plugin);
    return del.exterminate(
        player, plugin.getTrackerKeeper().getExterminate().get(player.getUniqueId()));
  }
Example #7
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());
     }
   }
 }
Example #8
0
 public boolean isMalfunction() {
   boolean mal = false;
   if (plugin.getConfig().getInt("preferences.malfunction") > 0) {
     int chance = 100 - plugin.getConfig().getInt("preferences.malfunction");
     if (rand.nextInt(100) > chance) {
       mal = true;
       if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {
         plugin.trackRescue.remove(Integer.valueOf(id));
       }
     }
   }
   return mal;
 }
 private String estimateArtron(String size, String cham) {
   SCHEMATIC s = SCHEMATIC.valueOf(size);
   String[] data = cham.split(":");
   int x = plugin.getUtils().parseInt(data[1]);
   int y = plugin.getUtils().parseInt(data[2]);
   int z = plugin.getUtils().parseInt(data[3]);
   switch (s) {
     case DELUXE:
       return data[0] + ":" + (x + 5) + ":" + y + ":" + (z - 1);
     default:
       return data[0] + ":" + (x - 2) + ":" + y + ":" + (z + 2);
   }
 }
Example #10
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;
   }
 }
 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;
 }
 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());
   }
 }
Example #13
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);
   }
 }
 @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());
     }
   }
 }
 @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");
 }
 /**
  * Runnable method to materialise the TARDIS Police Box. Tries to mimic the transparency of
  * materialisation by building the Police Box first with GLASS, then ICE, then the normall wall
  * block (BLUE WOOL or the chameleon material).
  *
  * @param plugin instance of the TARDIS plugin
  * @param tmd the TARDISMaterialisationData
  * @param preset the Chameleon preset currently in use by the TARDIS
  * @param lamp the id of the lamp block
  * @param cham_id the chameleon block id for the police box
  * @param cham_data the chameleon block data for the police box
  */
 public TARDISDematerialisationPreset(
     TARDIS plugin,
     TARDISMaterialisationData tmd,
     PRESET preset,
     int lamp,
     int cham_id,
     byte cham_data) {
   this.plugin = plugin;
   this.tmd = tmd;
   this.loops = 18;
   this.preset = preset;
   this.i = 0;
   this.lamp = lamp;
   this.cham_id = cham_id;
   this.cham_data = cham_data;
   column = plugin.getPresets().getColumn(preset, tmd.getDirection());
   stained_column = plugin.getPresets().getStained(preset, tmd.getDirection());
   glass_column = plugin.getPresets().getGlass(preset, tmd.getDirection());
 }
 @SuppressWarnings("deprecation")
 private byte getWoolColour(int id, PRESET p) {
   HashMap<String, Object> where = new HashMap<String, Object>();
   where.put("tardis_id", id);
   where.put("door_type", 0);
   ResultSetDoors rs = new ResultSetDoors(plugin, where, false);
   if (rs.resultSet()) {
     Block b = plugin.getUtils().getLocationFromDB(rs.getDoor_location(), 0.0F, 0.0F).getBlock();
     if (p.equals(PRESET.FLOWER)) {
       return b.getRelative(BlockFace.UP, 3).getData();
     } else {
       for (BlockFace f : plugin.getGeneralKeeper().getFaces()) {
         if (b.getRelative(f).getType().equals(Material.WOOL)) {
           return b.getRelative(f).getData();
         }
       }
     }
   }
   return (byte) 0;
 }
 private Block getControlBlock(int id, int type) {
   Block b = null;
   HashMap<String, Object> where = new HashMap<String, Object>();
   where.put("tardis_id", id);
   where.put("type", type);
   ResultSetControls rs = new ResultSetControls(plugin, where, false);
   if (rs.resultSet()) {
     Location l = plugin.getLocationUtils().getLocationFromBukkitString(rs.getLocation());
     b = l.getBlock();
   }
   return b;
 }
 /**
  * Gets the next unused TIPS slot in a 20 x 20 grid.
  *
  * @return the first vacant slot
  */
 public int getFreeSlot() {
   int limit = plugin.getConfig().getInt("creation.tips_limit");
   List<Integer> usedSlots = makeUsedSlotList();
   int slot = -1;
   for (int i = 0; i < limit; i++) {
     if (!usedSlots.contains(i)) {
       slot = i;
       break;
     }
   }
   return slot;
 }
 @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();
       }
     }
   }
 }
 private void asyncFetch(final ArrayList<String> names) {
   plugin
       .getServer()
       .getScheduler()
       .runTaskAsynchronously(
           plugin,
           new Runnable() {
             @Override
             public void run() {
               syncFetch(names);
             }
           });
 }
 /** 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);
           }
         }
       }
     }
   }
 }
 /**
  * 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);
 }
 private String[] estimateRepeaters(String size, String cham) {
   String[] r = new String[4];
   SCHEMATIC s = SCHEMATIC.valueOf(size);
   String[] data = cham.split(":");
   int x = plugin.getUtils().parseInt(data[1]);
   int y = plugin.getUtils().parseInt(data[2]);
   int z = plugin.getUtils().parseInt(data[3]);
   switch (s) {
     case DELUXE:
       r[0] = data[0] + ":" + (x + 2) + ":" + (y + 1) + ":" + (z - 3); // environment
       r[1] = data[0] + ":" + x + ":" + (y + 1) + ":" + (z - 1); // x
       r[2] = data[0] + ":" + (x + 4) + ":" + (y + 1) + ":" + (z - 1); // z
       r[3] = data[0] + ":" + (x + 2) + ":" + (y + 1) + ":" + (z + 1); // y
       break;
     default:
       r[0] = data[0] + ":" + (x - 1) + ":" + y + ":" + (z - 1);
       r[1] = data[0] + ":" + (x - 3) + ":" + y + ":" + (z + 1);
       r[2] = data[0] + ":" + (x + 1) + ":" + y + ":" + (z + 1);
       r[3] = data[0] + ":" + (x - 1) + ":" + y + ":" + (z + 3);
       break;
   }
   return r;
 }
 /**
  * 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);
 }
 /**
  * Listens for Fireball, Wither and Dragon entity interaction with the TARDIS blocks. If the block
  * is a TARDIS block, then the block change event is cancelled.
  *
  * @param event an entity affecting a block
  */
 @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
 public void bossBlockBreak(EntityChangeBlockEvent event) {
   Block b = event.getBlock();
   String l = b.getLocation().toString();
   EntityType eType;
   try {
     eType = event.getEntityType();
   } catch (Exception e) {
     eType = null;
   }
   if (eType != null && ents.contains(eType)) {
     if (plugin.getGeneralKeeper().getProtectBlockMap().containsKey(l)) {
       event.setCancelled(true);
     }
   }
 }
Example #27
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 TARDISRecipesUpdater(TARDIS plugin) {
   this.plugin = plugin;
   this.recipes_config = plugin.getRecipesConfig();
   this.flavours.put("Licorice", 0);
   this.flavours.put("Raspberry", 1);
   this.flavours.put("Apple", 2);
   this.flavours.put("Cappuccino", 3);
   this.flavours.put("Blueberry", 4);
   this.flavours.put("Grape", 5);
   this.flavours.put("Island Punch", 6);
   this.flavours.put("Vodka", 7);
   this.flavours.put("Earl Grey", 8);
   this.flavours.put("Strawberry", 9);
   this.flavours.put("Lime", 10);
   this.flavours.put("Lemon", 11);
   this.flavours.put("Bubblegum", 12);
   this.flavours.put("Watermelon", 13);
   this.flavours.put("Orange", 14);
   this.flavours.put("Vanilla", 15);
   this.colours.put("White", 0);
   this.colours.put("Orange", 1);
   this.colours.put("Magenta", 2);
   this.colours.put("Light Blue", 3);
   this.colours.put("Yellow", 4);
   this.colours.put("Lime", 5);
   this.colours.put("Pink", 6);
   this.colours.put("Grey", 7);
   this.colours.put("Light Grey", 8);
   this.colours.put("Cyan", 9);
   this.colours.put("Purple", 10);
   this.colours.put("Blue", 11);
   this.colours.put("Brown", 12);
   this.colours.put("Green", 13);
   this.colours.put("Red", 14);
   this.colours.put("Black", 15);
   this.damage.put("shaped.TARDIS ARS Circuit.lore", 20);
   this.damage.put("shaped.TARDIS Chameleon Circuit.lore", 25);
   this.damage.put("shaped.TARDIS Input Circuit.lore", 50);
   this.damage.put("shaped.TARDIS Materialisation Circuit.lore", 50);
   this.damage.put("shaped.TARDIS Memory Circuit.lore", 20);
   this.damage.put("shaped.TARDIS Randomiser Circuit.lore", 50);
   this.damage.put("shaped.TARDIS Scanner Circuit.lore", 20);
   this.damage.put("shaped.TARDIS Temporal Circuit.lore", 20);
 }
 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");
 }