Java Code Examples for org.bukkit.event.player.PlayerRespawnEvent#setRespawnLocation()
The following examples show how to use
org.bukkit.event.player.PlayerRespawnEvent#setRespawnLocation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeathListener.java From Civs with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onPlayerRespawn(PlayerRespawnEvent event) { final Player player = event.getPlayer(); final Civilian civilian = CivilianManager.getInstance().getCivilian(player.getUniqueId()); Location respawnLocation = civilian.getRespawnPoint(); if (respawnLocation == null) { return; } if (ConfigManager.getInstance().getUseStarterBook()) { Bukkit.getScheduler().scheduleSyncDelayedTask(Civs.getInstance(), new Runnable() { @Override public void run() { player.getInventory().addItem(Util.createStarterBook(civilian.getLocale())); } }, 5L); } event.setRespawnLocation(respawnLocation); civilian.setRespawnPoint(null); CivilianManager.getInstance().saveCivilian(civilian); }
Example 2
Source File: GameListeners.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled = true) public void respawnHandler(PlayerRespawnEvent event) { final Player player = event.getPlayer(); final AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if(p != null) { if(Game.isGameRunning()) { if(p.getTeam() != null && !p.getTeam().isTeamDead()) { event.setRespawnLocation(p.getTeam().getRandomSpawn()); p.getKit().onPlayerSpawn(player); return; } } if(Game.LobbyMap != null && Game.LobbyMap.getSpawn() != null) event.setRespawnLocation(Game.LobbyMap.getSpawn()); //Set people to respawn in the lobby } }
Example 3
Source File: PlayerListener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerRespawn(PlayerRespawnEvent pre) { Player p = pre.getPlayer(); Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p); if (game == null) { return; } if (game.getState() == GameState.RUNNING) { game.getCycle().onPlayerRespawn(pre, p); return; } if (game.getState() == GameState.WAITING) { pre.setRespawnLocation(game.getLobby()); } }
Example 4
Source File: RespawnObjective.java From BetonQuest with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onRespawn(PlayerRespawnEvent event) { String playerID = PlayerConverter.getID(event.getPlayer()); if (containsPlayer(playerID) && checkConditions(playerID)) { if (location != null) { try { event.setRespawnLocation(location.getLocation(playerID)); } catch (QuestRuntimeException e) { LogUtils.getLogger().log(Level.WARNING, "Error while handling '" + instruction.getID() + "' objective: \" + e.getMessage()"); LogUtils.logThrowable(e); } } completeObjective(playerID); } }
Example 5
Source File: ArenaListener.java From civcraft with GNU General Public License v2.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerRespawn(PlayerRespawnEvent event) { Resident resident = CivGlobal.getResident(event.getPlayer()); if (!resident.isInsideArena()) { return; } Arena arena = resident.getCurrentArena(); if (arena == null) { return; } Location loc = arena.getRespawnLocation(resident); if (loc != null) { CivMessage.send(resident, CivColor.LightGray+"Respawned in arena."); World world = Bukkit.getWorld(arena.getInstanceName()); loc.setWorld(world); resident.setLastKilledTime(new Date()); event.setRespawnLocation(loc); } }
Example 6
Source File: PlayerEvents.java From askyblock with GNU General Public License v2.0 | 6 votes |
/** * Places player back on their island if the setting is true * @param e - event */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerRespawn(final PlayerRespawnEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } if (!Settings.respawnOnIsland) { return; } if (respawn.contains(e.getPlayer().getUniqueId())) { respawn.remove(e.getPlayer().getUniqueId()); Location respawnLocation = plugin.getGrid().getSafeHomeLocation(e.getPlayer().getUniqueId(), 1); if (respawnLocation != null) { //plugin.getLogger().info("DEBUG: Setting respawn location to " + respawnLocation); e.setRespawnLocation(respawnLocation); // Get island Island island = plugin.getGrid().getIslandAt(respawnLocation); if (island != null) { // Run perms etc. processPerms(e.getPlayer(), island); } } } }
Example 7
Source File: PlayRespawnEvent.java From WildernessTp with MIT License | 5 votes |
@EventHandler public void on(PlayerRespawnEvent e) { if (e.isBedSpawn() || e.getPlayer().getBedLocation() != null) { return; } if (e.getPlayer().hasPermission("wild.wildtp.respawn.except")) { return; } e.setRespawnLocation(loc.getRandomLoc(loc.getWorldInformation(e.getPlayer().getLocation()), e.getPlayer())); }
Example 8
Source File: PlayerListener.java From WorldGuardExtraFlagsPlugin with MIT License | 5 votes |
@EventHandler(ignoreCancelled = true) public void onPlayerRespawnEvent(PlayerRespawnEvent event) { Player player = event.getPlayer(); ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()); Object respawnLocation = WorldGuardUtils.queryValueUnchecked(player, player.getWorld(), regions.getRegions(), Flags.RESPAWN_LOCATION); if (respawnLocation != null) { event.setRespawnLocation(WorldEditUtils.toLocation(respawnLocation)); } }
Example 9
Source File: PlayerEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerRespawn(PlayerRespawnEvent event) { if (Settings.extras_sendToSpawn) { return; } if (plugin.getWorldManager().isSkyWorld(event.getPlayer().getWorld())) { event.setRespawnLocation(plugin.getWorldManager().getWorld().getSpawnLocation()); } }
Example 10
Source File: PlayerListener.java From civcraft with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); Resident resident = CivGlobal.getResident(player); if (resident == null || !resident.hasTown()) { return; } if (War.isWarTime() && !resident.isInsideArena()) { if (resident.getTown().getCiv().getDiplomacyManager().isAtWar()) { //TownHall townhall = resident.getTown().getTownHall(); Capitol capitol = resident.getCiv().getCapitolStructure(); if (capitol != null) { BlockCoord respawn = capitol.getRandomRespawnPoint(); if (respawn != null) { //PlayerReviveTask reviveTask = new PlayerReviveTask(player, townhall.getRespawnTime(), townhall, event.getRespawnLocation()); resident.setLastKilledTime(new Date()); event.setRespawnLocation(respawn.getCenteredLocation()); CivMessage.send(player, CivColor.LightGray+"You've respawned in the War Room since it's WarTime and you're at war."); //TaskMaster.asyncTask("", reviveTask, 0); } } } } }
Example 11
Source File: PlayerRespawn.java From FunnyGuilds with Apache License 2.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onRespawn(final PlayerRespawnEvent event) { PluginConfiguration config = FunnyGuilds.getInstance().getPluginConfiguration(); Player player = event.getPlayer(); User user = User.get(player); if (! user.hasGuild()) { return; } Location home = user.getGuild().getHome(); if (home == null) { return; } event.setRespawnLocation(home); if (config.createEntityType == null) { return; } Bukkit.getScheduler().runTaskAsynchronously(FunnyGuilds.getInstance(), () -> { Region guildRegion = RegionUtils.getAt(home); if (guildRegion == null) { return; } Guild guild = guildRegion.getGuild(); GuildEntityHelper.spawnGuildHeart(guild, player); }); }
Example 12
Source File: RespawnModule.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onMinecraftRespawn(PlayerRespawnEvent event) { CardinalSpawnEvent spawnEvent = new CardinalSpawnEvent(event.getPlayer(), Teams.getTeamByPlayer(event.getPlayer()).orNull()); Bukkit.getServer().getPluginManager().callEvent(spawnEvent); if (!spawnEvent.isCancelled()) { event.setRespawnLocation(spawnEvent.getSpawn().getLocation()); } }
Example 13
Source File: PlayerListener.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onPlayerRespawn(PlayerRespawnEvent event) { if (settings.getProperty(RestrictionSettings.NO_TELEPORT)) { return; } if (!listenerService.shouldCancelEvent(event)) { return; } Location spawn = spawnLoader.getSpawnLocation(event.getPlayer()); if (spawn != null && spawn.getWorld() != null) { event.setRespawnLocation(spawn); } }
Example 14
Source File: SpawnFeature.java From VoxelGamesLibv2 with MIT License | 4 votes |
@SuppressWarnings("JavaDoc") @GameEvent public void onRespawn(@Nonnull PlayerRespawnEvent e) { e.setRespawnLocation(getSpawn(e.getPlayer().getUniqueId())); }
Example 15
Source File: GameCycle.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
public void onPlayerRespawn(PlayerRespawnEvent pre, Player player) { Team team = this.getGame().getPlayerTeam(player); // reset damager this.getGame().setPlayerDamager(player, null); if (this.getGame().isSpectator(player)) { Collection<Team> teams = this.getGame().getTeams().values(); pre.setRespawnLocation( ((Team) teams.toArray()[Utils.randInt(0, teams.size() - 1)]).getSpawnLocation()); return; } if (team.isDead(this.getGame())) { PlayerStorage storage = this.getGame().getPlayerStorage(player); if (BedwarsRel.getInstance().statisticsEnabled()) { PlayerStatistic statistic = BedwarsRel.getInstance().getPlayerStatisticManager().getStatistic(player); statistic.setCurrentLoses(statistic.getCurrentLoses() + 1); } if (BedwarsRel.getInstance().spectationEnabled()) { if (storage != null && storage.getLeft() != null) { pre.setRespawnLocation(team.getSpawnLocation()); } this.getGame().toSpectator(player); } else { if (this.game.getCycle() instanceof BungeeGameCycle) { this.getGame().playerLeave(player, false); return; } if (!BedwarsRel.getInstance().toMainLobby()) { if (storage != null) { if (storage.getLeft() != null) { pre.setRespawnLocation(storage.getLeft()); } } } else { if (this.getGame().getMainLobby() != null) { pre.setRespawnLocation(this.getGame().getMainLobby()); } else { if (storage != null) { if (storage.getLeft() != null) { pre.setRespawnLocation(storage.getLeft()); } } } } this.getGame().playerLeave(player, false); } } else { if (BedwarsRel.getInstance().getRespawnProtectionTime() > 0) { RespawnProtectionRunnable protection = this.getGame().addProtection(player); protection.runProtection(); } pre.setRespawnLocation(team.getSpawnLocation()); } new BukkitRunnable() { @Override public void run() { GameCycle.this.checkGameOver(); } }.runTaskLater(BedwarsRel.getInstance(), 20L); }
Example 16
Source File: DPlayerListener.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onPlayerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); if (isCitizensNPC(player)) { return; } GlobalPlayer dPlayer = dPlayers.get(player); if (dPlayer == null) { return; } if (dPlayer instanceof EditPlayer) { EditWorld editWorld = ((EditPlayer) dPlayer).getEditWorld(); if (editWorld == null) { return; } if (editWorld.getLobbyLocation() == null) { event.setRespawnLocation(editWorld.getWorld().getSpawnLocation()); } else { event.setRespawnLocation(editWorld.getLobbyLocation()); } } else if (dPlayer instanceof GamePlayer) { GamePlayer gamePlayer = (GamePlayer) dPlayer; GameWorld gameWorld = gamePlayer.getGameWorld(); if (gameWorld == null) { return; } PlayerGroup group = dPlayer.getGroup(); Location respawn = gamePlayer.getLastCheckpoint(); if (respawn == null) { respawn = group.getGameWorld().getStartLocation(group); } boolean shouldResetInventory = gamePlayer.getGameWorld().getDungeon().getRules().getState(GameRule.RESET_CLASS_INVENTORY_ON_RESPAWN); // Because some plugins set another respawn point, DXL teleports a few ticks later. event.setRespawnLocation(respawn); new RespawnTask(player, gamePlayer, respawn, shouldResetInventory).runTaskLater(plugin, 10L); // Don't forget Doge! if (gamePlayer.getWolf() != null) { gamePlayer.getWolf().teleport(respawn); } } }