@EventHandler(priority = EventPriority.MONITOR) public void spawn(final PlayerInitialSpawnEvent event) { Location location = spawnLocation(event.getWorld()); double radius = spawnRadius(event.getWorld()); Random random = new Random(); // Random point in circle double angle = random.nextDouble() * Math.PI * 2; double hyp = random.nextDouble() + random.nextDouble(); hyp = (hyp < 1D ? hyp : 2 - hyp) * radius; location.setX(Math.cos(angle) * hyp + location.getX()); location.setZ(Math.sin(angle) * hyp + location.getZ()); event.setSpawnLocation(location); }
/** * Handles new container data when the player initially joins the server. * * @param event The event. */ @EventHandler(priority = EventPriority.LOWEST) public void onPlayerJoin(PlayerInitialSpawnEvent event) { MatchThread thread = Cardinal.getInstance().getMatchThreads().get(0); PlayerContainerData newData = new PlayerContainerData(thread, null, null); PlayerContainerData oldData = PlayerContainerData.empty(); Containers.handleStateChangeEvent(event.getPlayer(), oldData, newData); }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerInitLogin(PlayerInitialSpawnEvent event) { TeamModule teamModule = TeamUtils.getTeamById("observers"); ModuleCollection<SpawnModule> modules = new ModuleCollection<SpawnModule>(); for (SpawnModule spawnModule : match.getModules().getModules(SpawnModule.class)) { if (spawnModule.getTeam() == teamModule) modules.add(spawnModule); } SpawnModule chosen = modules.getRandom(); CardinalSpawnEvent spawnEvent = new CardinalSpawnEvent(event.getPlayer(), chosen, TeamUtils.getTeamById("observers")); Bukkit.getServer().getPluginManager().callEvent(spawnEvent); if (!spawnEvent.isCancelled()) { event.setSpawnLocation(chosen.getLocation()); PlayerUtils.resetPlayer(event.getPlayer()); } }
@EventHandler(priority = EventPriority.MONITOR) public void onInitialSpawn(final PlayerInitialSpawnEvent event) { // Make all joining players spawn in this match's world event.setSpawnLocation(match.getWorld().getSpawnLocation()); }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerInitialSpawn(PlayerInitialSpawnEvent event) { event.setSpawnLocation(this.fetchSpawn()); }
/** * Spawns the player in the appropriate default spawn location. * * @param event The event. */ @EventHandler(priority = EventPriority.HIGH) public void onPlayerInitialSpawn(PlayerInitialSpawnEvent event) { Match match = Cardinal.getMatch(event.getPlayer()); event.setSpawnLocation(getDefaultSpawn(match).getSpawnPoint()); }