org.bukkit.event.player.PlayerRespawnEvent Java Examples
The following examples show how to use
org.bukkit.event.player.PlayerRespawnEvent.
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: NameTagX.java From TAB with Apache License 2.0 | 7 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void a(PlayerRespawnEvent e) { ITabPlayer p = Shared.getPlayer(e.getPlayer().getUniqueId()); if (p == null) return; if (!p.disabledNametag) Shared.featureCpu.runMeasuredTask("processing PlayerRespawnEvent", CPUFeature.NAMETAGX_EVENT_RESPAWN, new Runnable() { public void run() { for (ArmorStand as : p.getArmorStands()) { as.updateLocation(e.getRespawnLocation()); List<ITabPlayer> nearbyPlayers = as.getNearbyPlayers(); synchronized (nearbyPlayers){ for (ITabPlayer nearby : nearbyPlayers) { nearby.sendPacket(as.getTeleportPacket(nearby)); } } } } }); }
Example #2
Source File: PlayerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@Test public void shouldHandlePlayerRespawnNoChanges() { // given Player player = mock(Player.class); Location originalLocation = mock(Location.class); PlayerRespawnEvent event = spy(new PlayerRespawnEvent(player, originalLocation, false)); given(settings.getProperty(RestrictionSettings.NO_TELEPORT)).willReturn(false); given(listenerService.shouldCancelEvent(event)).willReturn(true); given(spawnLoader.getSpawnLocation(player)).willReturn(null); // when listener.onPlayerRespawn(event); // then verify(spawnLoader).getSpawnLocation(player); verify(event, never()).setRespawnLocation(any()); }
Example #3
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 #4
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 #5
Source File: ExprLevel.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override @Nullable public Class<?>[] acceptChange(final ChangeMode mode) { if (mode == ChangeMode.REMOVE_ALL) return null; if (ScriptLoader.isCurrentEvent(PlayerRespawnEvent.class) && !ScriptLoader.hasDelayBefore.isTrue()) { Skript.error("Cannot change a player's level in a respawn event. Add a delay of 1 tick or change the 'new level' in a death event."); return null; } if (ScriptLoader.isCurrentEvent(PlayerDeathEvent.class) && getTime() == 0 && getExpr().isDefault() && !ScriptLoader.hasDelayBefore.isTrue()) { Skript.warning("Changing the player's level in a death event will change the player's level before he dies. " + "Use either 'past level of player' or 'new level of player' to clearly state whether to change the level before or after he dies."); } if (getTime() == -1 && !ScriptLoader.isCurrentEvent(PlayerDeathEvent.class)) return null; return new Class[] {Number.class}; }
Example #6
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 #7
Source File: QuestItemHandler.java From BetonQuest with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onRespawn(final PlayerRespawnEvent event) { if (Config.getString("config.remove_items_after_respawn").equals("false")) return; // some plugins block item dropping after death and add those // items after respawning, so the player doesn't loose his // inventory after death; this aims to force removing quest // items, as they have been added to the backpack already if (event.getPlayer().getGameMode() == GameMode.CREATIVE) return; final Inventory inv = event.getPlayer().getInventory(); for (int i = 0; i < inv.getSize(); i++) { if (Utils.isQuestItem(inv.getItem(i))) { inv.setItem(i, null); } } }
Example #8
Source File: PlayerDeathListener.java From EnchantmentsEnhance with GNU General Public License v3.0 | 6 votes |
/** * Returns enhanced item to the player when respawn. * * @param e */ @EventHandler(priority = EventPriority.MONITOR) public void onPlayerRespawn(PlayerRespawnEvent e) { Player p = e.getPlayer(); File playerFile = new File(m.getDataFolder() + "/death/" + p.getName() + ".yml"); FileConfiguration pFile = YamlConfiguration.loadConfiguration( playerFile); if (playerFile.exists()) { ItemStack[] content = ((List<?>) pFile.get("Items")) .toArray(new ItemStack[0]); p.getInventory().addItem(content); if (playerFile.delete()) { // Delete a file. } } }
Example #9
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 #10
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 #11
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 #12
Source File: Soulbound.java From MineTinker with GNU General Public License v3.0 | 6 votes |
/** * Effect if a player respawns */ @EventHandler public void effect(PlayerRespawnEvent event) { Player player = event.getPlayer(); if (!player.hasPermission("minetinker.modifiers.soulbound.use")) { return; } if (!storedItemStacks.containsKey(player.getUniqueId())) { return; } ArrayList<ItemStack> stored = storedItemStacks.get(player.getUniqueId()); for (ItemStack is : stored) { if (player.getInventory().addItem(is).size() != 0) { //adds items to (full) inventory player.getWorld().dropItem(player.getLocation(), is); } // no else as it gets added in if ChatWriter.logModifier(player, event, this, is); } storedItemStacks.remove(player.getUniqueId()); }
Example #13
Source File: PlayerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@Test public void shouldIgnorePlayerRespawnUnloadedWorld() { // given Player player = mock(Player.class); Location originalLocation = mock(Location.class); Location newLocation = mock(Location.class); given(newLocation.getWorld()).willReturn(null); PlayerRespawnEvent event = spy(new PlayerRespawnEvent(player, originalLocation, false)); given(settings.getProperty(RestrictionSettings.NO_TELEPORT)).willReturn(false); given(listenerService.shouldCancelEvent(event)).willReturn(true); given(spawnLoader.getSpawnLocation(player)).willReturn(newLocation); // when listener.onPlayerRespawn(event); // then verify(spawnLoader).getSpawnLocation(player); verify(event, never()).setRespawnLocation(any()); }
Example #14
Source File: PlayerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@Test public void shouldHandlePlayerRespawn() { // given Player player = mock(Player.class); Location originalLocation = mock(Location.class); Location newLocation = mock(Location.class); World world = mock(World.class); given(newLocation.getWorld()).willReturn(world); PlayerRespawnEvent event = spy(new PlayerRespawnEvent(player, originalLocation, false)); given(settings.getProperty(RestrictionSettings.NO_TELEPORT)).willReturn(false); given(listenerService.shouldCancelEvent(event)).willReturn(true); given(spawnLoader.getSpawnLocation(player)).willReturn(newLocation); // when listener.onPlayerRespawn(event); // then verify(spawnLoader).getSpawnLocation(player); verify(event).setRespawnLocation(newLocation); }
Example #15
Source File: PlayerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@Test public void shouldIgnorePlayerRespawn() { // given Player player = mock(Player.class); Location respawnLocation = mock(Location.class); PlayerRespawnEvent event = spy(new PlayerRespawnEvent(player, respawnLocation, false)); given(settings.getProperty(RestrictionSettings.NO_TELEPORT)).willReturn(false); given(listenerService.shouldCancelEvent(event)).willReturn(false); // when listener.onPlayerRespawn(event); // then verifyNoInteractions(spawnLoader); verify(event, never()).setRespawnLocation(any()); }
Example #16
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 #17
Source File: PlayerEventHandler.java From GriefDefender with MIT License | 5 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUID())) { return; } final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); playerData.lastPvpTimestamp = null; }
Example #18
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 #19
Source File: Bar.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerTeleport(final PlayerRespawnEvent event) { if(event.getPlayer() != null && event.getRespawnLocation() != null) { // final AnniPlayer p = AnniPlayer.getPlayer(event.getPlayer().getUniqueId()); // if(p != null) // { // if(permanentBar) // BarAPI.sendPermDragon(event.getPlayer()); // else handleTeleport(event.getPlayer(), event.getRespawnLocation().clone()); // } } }
Example #20
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 #21
Source File: PlayerListener.java From AnimatedFrames with MIT License | 5 votes |
@EventHandler public void on(final PlayerRespawnEvent event) { Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { @Override public void run() { for (AnimatedFrame frame : plugin.frameManager.getFramesInWorld(event.getPlayer().getWorld().getName())) { frame.addViewer(event.getPlayer()); } } }, 20); }
Example #22
Source File: PetOwnerListener.java From SonarPet with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerRespawn(PlayerRespawnEvent event) { final Player p = event.getPlayer(); new BukkitRunnable() { @Override public void run() { EchoPet.getManager().loadPets(p, true, false, true); } }.runTaskLater(EchoPet.getPlugin(), 20L); }
Example #23
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 #24
Source File: PlayerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@Test public void shouldIgnorePlayerRespawnWithNoTeleport() { // given Player player = mock(Player.class); Location respawnLocation = mock(Location.class); PlayerRespawnEvent event = spy(new PlayerRespawnEvent(player, respawnLocation, false)); given(settings.getProperty(RestrictionSettings.NO_TELEPORT)).willReturn(true); // when listener.onPlayerRespawn(event); // then verifyNoInteractions(listenerService); verify(event, never()).setRespawnLocation(any()); }
Example #25
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 #26
Source File: FlagQueueLobby.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerRespawn(PlayerRespawnEvent event) { final SpleefPlayer player = getHeavySpleef().getSpleefPlayer(event.getPlayer()); if (!died.containsKey(player)) { return; } final Location teleportTo = died.remove(player); Bukkit.getScheduler().runTaskLater(getHeavySpleef().getPlugin(), new Runnable() { @Override public void run() { if (!player.isOnline()) { return; } PlayerStateHolder state = player.removePlayerState(FlagQueueLobby.this); if (state != null) { state.apply(player.getBukkitPlayer(), teleportTo == null); } else { //Ugh, something went wrong player.sendMessage(getI18N().getString(Messages.Player.ERROR_ON_INVENTORY_LOAD)); } if (teleportTo != null) { player.teleport(teleportTo); } } }, 5L); }
Example #27
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 #28
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 #29
Source File: TestSoulboundListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@ParameterizedTest @ValueSource(booleans = { true, false }) public void testItemRecover(boolean soulbound) { PlayerMock player = server.addPlayer(); ItemStack item = new CustomItem(Material.DIAMOND_SWORD, "&4Cool Sword"); SlimefunUtils.setSoulbound(item, soulbound); player.getInventory().setItem(6, item); player.setHealth(0); player.respawn(); server.getPluginManager().assertEventFired(PlayerRespawnEvent.class, event -> { return player.getInventory().getItem(6).isSimilar(item) == soulbound; }); }
Example #30
Source File: PlayerEvents.java From askyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVistorSpawn(final PlayerRespawnEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } // This will override any global settings if (Settings.allowVisitorKeepInvOnDeath) { InventorySave.getInstance().loadPlayerInventory(e.getPlayer()); InventorySave.getInstance().clearSavedInventory(e.getPlayer()); } }