Java 类org.bukkit.event.player.PlayerInitialSpawnEvent 实例源码

项目:ProjectAres    文件:PlayerListener.java   
@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);
}
项目:Cardinal    文件:ConnectionModule.java   
/**
 * 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);
}
项目:Cardinal-Plus    文件:RespawnModule.java   
@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());
    }
}
项目:ProjectAres    文件:SpawnMatchModule.java   
@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());
}
项目:Arcade2    文件:Sessions.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInitialSpawn(PlayerInitialSpawnEvent event) {
    event.setSpawnLocation(this.fetchSpawn());
}
项目:Cardinal    文件:SpawnModule.java   
/**
 * 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());
}