コード例 #1
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;
 }
コード例 #2
0
 @EventHandler(priority = EventPriority.MONITOR)
 public void onPlayerQuit(PlayerQuitEvent event) {
   String playerNameStr = event.getPlayer().getName();
   // forget the players Police Box chunk
   HashMap<String, Object> wherep = new HashMap<String, Object>();
   wherep.put("owner", playerNameStr);
   ResultSetTardis rs = new ResultSetTardis(plugin, wherep, "", false);
   if (rs.resultSet()) {
     HashMap<String, Object> wherecl = new HashMap<String, Object>();
     wherecl.put("tardis_id", rs.getTardis_id());
     ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl);
     if (rsc.resultSet()) {
       World w = rsc.getWorld();
       if (w != null) {
         Chunk chunk = w.getChunkAt(new Location(w, rsc.getX(), rsc.getY(), rsc.getZ()));
         if (plugin.tardisChunkList.contains(chunk)) {
           plugin.tardisChunkList.remove(chunk);
         }
       }
     }
   }
 }
コード例 #3
0
 @EventHandler(priority = EventPriority.MONITOR)
 public void onJunkBrakeUse(PlayerInteractEvent event) {
   if (plugin.getGeneralKeeper().isJunkTravelling()) {
     return;
   }
   Block block = event.getClickedBlock();
   if (block != null) {
     Material blockType = block.getType();
     final Location controlLoc = block.getLocation();
     String c_loc = controlLoc.toString();
     HashMap<String, Object> where = new HashMap<String, Object>();
     where.put("location", c_loc);
     if (blockType == Material.LEVER) {
       // Checks handbrake location against the database.
       where.put("type", 0);
       ResultSetControls rsh = new ResultSetControls(plugin, where, false);
       if (rsh.resultSet()) {
         int id = rsh.getTardis_id();
         // is it the Junk TARDIS?
         HashMap<String, Object> wherei = new HashMap<String, Object>();
         wherei.put("tardis_id", id);
         ResultSetTardis rs = new ResultSetTardis(plugin, wherei, "", false);
         if (rs.resultSet() && rs.getPreset().equals(PRESET.JUNK)) {
           final Player player = event.getPlayer();
           if (!player.hasPermission("tardis.junk")) {
             TARDISMessage.send(player, "JUNK_NO_PERM");
             return;
           }
           // get the destination
           getDestination(id, player);
           if (plugin.getGeneralKeeper().getJunkDestination() != null) {
             // get the current location
             Location junkloc = null;
             Biome biome = null;
             HashMap<String, Object> wherecl = new HashMap<String, Object>();
             wherecl.put("tardis_id", id);
             ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl);
             if (rsc.resultSet()) {
               junkloc = new Location(rsc.getWorld(), rsc.getX(), rsc.getY(), rsc.getZ());
               biome = rsc.getBiome();
             }
             if (junkloc == null) {
               TARDISMessage.send(player, "JUNK_NOT_FOUND");
               return;
             }
             // destroy junk TARDIS
             final TARDISMaterialisationData pdd = new TARDISMaterialisationData();
             pdd.setPlayer(player);
             pdd.setChameleon(false);
             pdd.setDirection(COMPASS.SOUTH);
             pdd.setLocation(junkloc);
             pdd.setDematerialise(true);
             pdd.setHide(false);
             pdd.setOutside(false);
             pdd.setSubmarine(rsc.isSubmarine());
             pdd.setTardisID(id);
             pdd.setBiome(biome);
             plugin.getPresetDestroyer().destroyPreset(pdd);
             // fly my pretties
             plugin.getGeneralKeeper().setJunkTravelling(true);
           } else {
             TARDISMessage.send(event.getPlayer(), "JUNK_NO_DEST");
             return;
           }
         }
       }
     }
     if (blockType == Material.TRIPWIRE_HOOK) {
       // 4
       where.put("type", 4);
       ResultSetControls rst = new ResultSetControls(plugin, where, false);
       if (rst.resultSet()) {
         int id = rst.getTardis_id();
         // is it the Junk TARDIS?
         HashMap<String, Object> wherei = new HashMap<String, Object>();
         wherei.put("tardis_id", id);
         ResultSetTardis rs = new ResultSetTardis(plugin, wherei, "", false);
         if (rs.resultSet() && rs.getPreset().equals(PRESET.JUNK)) {
           final Player player = event.getPlayer();
           if (!player.hasPermission("tardis.junk")) {
             TARDISMessage.send(player, "JUNK_NO_PERM");
             return;
           }
           setSignWorld(id, player.getUniqueId());
         }
       }
     }
     if (blockType == Material.STONE_BUTTON) {
       // 1
       where.put("type", 1);
       ResultSetControls rsh = new ResultSetControls(plugin, where, false);
       if (rsh.resultSet()) {
         int id = rsh.getTardis_id();
         // is it the Junk TARDIS?
         HashMap<String, Object> wherei = new HashMap<String, Object>();
         wherei.put("tardis_id", id);
         ResultSetTardis rs = new ResultSetTardis(plugin, wherei, "", false);
         if (rs.resultSet() && rs.getPreset().equals(PRESET.JUNK)) {
           final Player player = event.getPlayer();
           if (!player.hasPermission("tardis.junk")) {
             TARDISMessage.send(player, "JUNK_NO_PERM");
             return;
           }
           setSignCoords(id, 2);
         }
       }
     }
     if (blockType == Material.WOOD_BUTTON) {
       // 6
       where.put("type", 6);
       ResultSetControls rsh = new ResultSetControls(plugin, where, false);
       if (rsh.resultSet()) {
         int id = rsh.getTardis_id();
         // is it the Junk TARDIS?
         HashMap<String, Object> wherei = new HashMap<String, Object>();
         wherei.put("tardis_id", id);
         ResultSetTardis rs = new ResultSetTardis(plugin, wherei, "", false);
         if (rs.resultSet() && rs.getPreset().equals(PRESET.JUNK)) {
           final Player player = event.getPlayer();
           if (!player.hasPermission("tardis.junk")) {
             TARDISMessage.send(player, "JUNK_NO_PERM");
             return;
           }
           setSignCoords(id, 3);
         }
       }
     }
   }
 }
コード例 #4
0
 public boolean doAbandon(CommandSender sender, boolean list) {
   if (sender.hasPermission("tardis.abandon")
       && plugin.getConfig().getBoolean("abandon.enabled")) {
     if (list) {
       // list abandoned TARDISes
       if (sender.hasPermission("tardis.admin")) {
         new TARDISAbandonLister(plugin).list(sender);
         return true;
       } else {
         TARDISMessage.send(sender, "NO_PERMS");
       }
     } else {
       // must be a Player
       Player player = null;
       if (sender instanceof Player) {
         player = (Player) sender;
       }
       if (player == null) {
         TARDISMessage.send(sender, "CMD_NO_CONSOLE");
         return true;
       }
       if (!plugin.getConfig().getBoolean("allow.power_down")) {
         TARDISMessage.send(sender, "ABANDON_POWER_DOWN");
         return true;
       }
       // abandon TARDIS
       ResultSetTardisAbandoned rs = new ResultSetTardisAbandoned(plugin);
       if (!rs.fromUUID(player.getUniqueId().toString())) {
         TARDISMessage.send(player, "NO_TARDIS");
         return true;
       } else {
         PRESET preset = rs.getPreset();
         // need to be in tardis
         HashMap<String, Object> where = new HashMap<String, Object>();
         where.put("uuid", player.getUniqueId().toString());
         ResultSetTravellers rst = new ResultSetTravellers(plugin, where, false);
         if (!rst.resultSet()) {
           TARDISMessage.send(player, "NOT_IN_TARDIS");
           return true;
         }
         if (preset.equals(PRESET.JUNK_MODE)) {
           TARDISMessage.send(player, "ABANDONED_NOT_JUNK");
           return true;
         }
         int id = rs.getTardis_id();
         if (rst.getTardis_id() != id) {
           TARDISMessage.send(player, "ABANDONED_OWN");
           return true;
         }
         if (!rs.isTardis_init()) {
           TARDISMessage.send(player, "ENERGY_NO_INIT");
           return true;
         }
         if (!rs.isHandbrake_on()) {
           TARDISMessage.send(player, "HANDBRAKE_ENGAGE");
           return true;
         }
         if (plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) {
           TARDISMessage.send(player, "NOT_IN_VORTEX");
           return true;
         }
         new TARDISAbandonUpdate(plugin, id, player.getUniqueId().toString()).run();
         if (rs.isPowered_on()) {
           // power down TARDIS
           new TARDISPowerButton(
                   plugin,
                   id,
                   player,
                   rs.getPreset(),
                   rs.isPowered_on(),
                   rs.isHidden(),
                   rs.isLights_on(),
                   player.getLocation(),
                   rs.getArtron_level(),
                   rs.getSchematic().hasLanterns())
               .clickButton();
         }
         // close the door
         new TARDISDoorCloser(plugin, player.getUniqueId(), id).closeDoors();
         TARDISMessage.send(player, "ABANDONED_SUCCESS");
         // clear sign
         if (plugin.getConfig().getBoolean("police_box.name_tardis")) {
           HashMap<String, Object> wherec = new HashMap<String, Object>();
           wherec.put("tardis_id", id);
           ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherec);
           if (rsc.resultSet()) {
             Location current = new Location(rsc.getWorld(), rsc.getX(), rsc.getY(), rsc.getZ());
             Sign sign = getSign(current, rsc.getDirection(), preset);
             if (sign != null) {
               switch (preset) {
                 case GRAVESTONE:
                   sign.setLine(3, "");
                   break;
                 case ANGEL:
                 case JAIL:
                   sign.setLine(2, "");
                   break;
                 default:
                   sign.setLine(0, "");
                   break;
               }
               sign.update();
             }
           }
         }
       }
     }
   } else {
     TARDISMessage.send(sender, "NO_PERMS_ABANDON");
   }
   return true;
 }
コード例 #5
0
 @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;
 }