Java Code Examples for org.bukkit.event.player.PlayerRespawnEvent#getPlayer()
The following examples show how to use
org.bukkit.event.player.PlayerRespawnEvent#getPlayer() .
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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 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: TabView.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
protected void onRespawn(PlayerRespawnEvent event) { if (this.viewer == event.getPlayer()) this.respawnFakeEntities(); }
Example 14
Source File: BossBarView.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
public void onPlayerRespawn(PlayerRespawnEvent event) { // Entities are destroyed when a player respawns, so we resend it. if (viewer == event.getPlayer()) handleSpawn(); }
Example 15
Source File: ListenerCombatChecks.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true) public void onRespawn(PlayerRespawnEvent e) { Player player = e.getPlayer(); checkSelfDeathUntag(player); }
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); } } }