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; }
@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); } }