/** * This is a convenience method to allow the QueuedCommand system to call it. You should NEVER call this directly. * * @param teleporter The Person requesting that the teleport should happen. * @param p Player The Person being teleported. * @param l The potentially unsafe location. */ public void teleportPlayer(CommandSender teleporter, Player p, Location l) { // This command is the override, and MUST NOT TELEPORT SAFELY this.getSafeTTeleporter().safelyTeleport(teleporter, p, l, false); }
/** * {@inheritDoc} */ @Override public void removePlayersFromWorld(String name) { World w = this.plugin.getServer().getWorld(name); if (w != null) { World safeWorld = this.plugin.getServer().getWorlds().get(0); List<Player> ps = w.getPlayers(); SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter(); for (Player p : ps) { // We're removing players forcefully from a world, they'd BETTER spawn safely. teleporter.safelyTeleport(null, p, safeWorld.getSpawnLocation(), true); } } }
private Location getSafeLocation() { // At this time, these can never use the velocity. if (this.destination instanceof CannonDestination) { this.core.log(Level.FINE, "Using Stock TP method. This cannon will have 0 velocity"); } SafeTTeleporter teleporter = this.core.getSafeTTeleporter(); Location newLoc = this.destination.getLocation(this.player); if (this.destination.useSafeTeleporter()) { newLoc = teleporter.getSafeLocation(this.player, this.destination); } if (newLoc == null) { return this.player.getLocation(); } return newLoc; }
SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter(); Location newSpawn = world.getSpawnLocation();
public TeleportCommand(MultiverseCore plugin) { super(plugin); Permission menu = new Permission("multiverse.teleport.*", "Allows you to display the teleport menu.", PermissionDefault.OP); this.setName("Teleport"); this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}"); this.setArgRange(1, 2); this.addKey("mvtp"); this.addKey("mv tp"); this.playerTeleporter = this.plugin.getSafeTTeleporter(); this.setPermission(menu); }
private void spawnAccurately(Player player) { MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld().getName()); Location spawnLocation; if (world != null) { spawnLocation = world.getSpawnLocation(); } else { spawnLocation = player.getWorld().getSpawnLocation(); } this.plugin.getSafeTTeleporter().safelyTeleport(player, player, spawnLocation, false); } }
/** * This method is called to adjust the portal location to the actual portal location (and not * right outside of it. * @param event The Event that was fired. */ @EventHandler(priority = EventPriority.LOWEST) public void playerPortalCheck(PlayerPortalEvent event) { if (event.isCancelled() || event.getFrom() == null) { return; } // REMEMBER! getTo MAY be NULL HERE!!! // If the player was actually outside of the portal, adjust the from location if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.NETHER_PORTAL) { Location newloc = this.plugin.getSafeTTeleporter().findPortalBlockNextTo(event.getFrom()); // TODO: Fix this. Currently, we only check for PORTAL blocks. I'll have to figure out what // TODO: we want to do here. if (newloc != null) { event.setFrom(newloc); } } // Wait for the adjust, then return! if (event.getTo() == null) { return; } } /**
@Override public Location validateChange(String property, Location newValue, Location oldValue, MVWorld object) throws ChangeDeniedException { if (newValue == null) throw new ChangeDeniedException(); if (props.getAdjustSpawn()) { BlockSafety bs = plugin.getBlockSafety(); // verify that the location is safe if (!bs.playerCanSpawnHereSafely(newValue)) { // it's not ==> find a better one! plugin.log(Level.WARNING, String.format("Somebody tried to set the spawn location for '%s' to an unsafe value! Adjusting...", getAlias())); plugin.log(Level.WARNING, "Old Location: " + plugin.getLocationManipulation().strCoordsRaw(oldValue)); plugin.log(Level.WARNING, "New (unsafe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue)); SafeTTeleporter teleporter = plugin.getSafeTTeleporter(); newValue = teleporter.getSafeLocation(newValue, SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS); if (newValue == null) { plugin.log(Level.WARNING, "Couldn't fix the location. I have to abort the spawn location-change :/"); throw new ChangeDeniedException(); } plugin.log(Level.WARNING, "New (safe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue)); } } return super.validateChange(property, newValue, oldValue, object); } }
SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter(); this.plugin.log(Level.WARNING, "Spawn location from world.dat file was unsafe. Adjusting..."); this.plugin.log(Level.WARNING, "Original Location: " + plugin.getLocationManipulation().strCoordsRaw(location));