Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void playerJoin(Player p, Location loc)
- {
- // Store location and health.
- //if (!locations.containsKey(p))
- // locations.put(p,loc);
- //if (!healthMap.containsKey(p))
- // healthMap.put(p,p.getHealth());
- // Flag that the player has joined.
- setPlayerHasJoined( p, loc );
- // Heal player.
- p.setHealth(20);
- // Sit pets.
- //MAUtils.sitPets(p);
- // Prevent unwanted things when coming from entry location.
- preventUnwantedsFromEntry( p );
- // Update chunk.
- //updateChunk(lobbyLoc);
- //lobbyPlayers.add(p);
- //p.teleport(lobbyLoc);
- // Notify listeners.
- //for (MobArenaListener listener : plugin.getAM().listeners)
- // listener.onPlayerJoin(p);
- movePlayerToLobby( p );
- }
- public void playerLeave(Player p)
- {
- // If they are in the Arena or in the Lobby, clear the inventory.
- if (arenaPlayers.contains(p) || lobbyPlayers.contains(p))
- MAUtils.clearInventory( p );
- // Restore old inventory and fork over rewards.
- restoreInvAndGiveRewards( p );
- // Grab the player's entry location, and warp them there.
- //Location entry = locations.get(p);
- //if (entry != null)
- //{
- // updateChunk(entry);
- // p.teleport(entry);
- //}
- movePlayerToEntry( p );
- //locations.remove(p);
- //if (healthMap.containsKey(p)) p.setHealth(healthMap.remove(p));
- // Remove from the arenaMap and all the sets.
- //plugin.getAM().arenaMap.remove(p);
- //removePlayer(p);
- finishWithPlayer( p );
- // End the arena if conditions are met.
- endArena();
- }
- public void playerDeath(Player p)
- {
- // If spectate-on-death: false, pass on to playerLeave.
- //if (!specOnDeath)
- //{
- //playerLeave(p);
- //return;
- //}
- // Clear inventory
- MAUtils.clearInventory( p );
- // Clear class inventory, restore old inventory and fork over rewards.
- restoreInvAndGiveRewards( p );
- // Remove player from sets, warp to spectator area, then add to specPlayers.
- //p.teleport(spectatorLoc);
- //if (healthMap.containsKey(p)) p.setHealth(healthMap.remove(p));
- //removePlayer(p);
- //specPlayers.add(p);
- // If Player will be spectating on death,
- if ( specOnDeath )
- {
- // Restore health, remove from sets.
- resetPlayer( p );
- // Move to spectator area.
- movePlayerToSpec( p );
- }
- // Otherwise, Player goes back to entry location,
- else
- {
- // Move to entry location.
- movePlayerToEntry( p );
- // Remove entry location, remove from ArenaMap, Restore health, and remove from sets.
- finishWithPlayer( p );
- }
- // Update the monster targets.
- if (running && spawnThread != null)
- spawnThread.updateTargets();
- // Announce and notify
- MAUtils.tellAll(this, MAMessages.get(Msg.PLAYER_DIED, p.getName()));
- for (MobArenaListener listener : plugin.getAM().listeners)
- listener.onPlayerDeath(p);
- // End the arena if conditions are met.
- endArena();
- }
- public void playerSpec(Player p, Location loc)
- {
- //if (!locations.containsKey(p))
- // locations.put(p,loc);
- //if (!healthMap.containsKey(p))
- // healthMap.put(p,p.getHealth());
- setPlayerHasJoined( p );
- // Prevent unwanted things when coming from entry location.
- preventUnwantedsFromEntry( p );
- //specPlayers.add(p);
- //p.teleport(spectatorLoc);
- movePlayerToSpec( p );
- }
- public void restoreInvAndGiveRewards(final Player p)
- {
- final List<ItemStack> rewards = rewardMap.get(p);
- final boolean hadRewards = rewardedPlayers.contains(p);
- //if (clear) MAUtils.clearInventory(p);
- Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
- new Runnable()
- {
- public void run()
- {
- if (!emptyInvJoin)
- MAUtils.restoreInventory(p);
- if (hadRewards)
- return;
- MAUtils.giveRewards(p, rewards, plugin);
- if (running)
- rewardedPlayers.add(p);
- }
- });
- }
- // =========== NEW FUNCTIONS =================
- // Called whenever a player enters a MobArena area (spectator or lobby).
- private void setPlayerHasJoined (Player p, Location loc)
- {
- // Store entry location
- if (!locations.containsKey(p))
- locations.put(p,loc);
- // Store entry health
- if (!healthMap.containsKey(p))
- healthMap.put(p,p.getHealth());
- }
- private void movePlayerToLobby (Player p)
- {
- // Update chunk.
- updateChunk(lobbyLoc);
- // Add player to lobby list.
- lobbyPlayers.add(p);
- // Warp player.
- p.teleport(lobbyLoc);
- // Notify listeners for API.
- for (MobArenaListener listener : plugin.getAM().listeners)
- listener.onPlayerJoin(p);
- }
- private void movePlayerToSpec (Player p)
- {
- // Update chunk.
- updateChunk(spectatorLoc);
- // Add player to spec list.
- specPlayers.add(p);
- // Warp player.
- p.teleport(spectatorLoc);
- }
- private void movePlayerToEntry (Player p)
- {
- // Find entry location
- Location entry = locations.get(p);
- if (entry != null)
- {
- // Update the chunk.
- updateChunk(entry);
- // Move the player.
- p.teleport(entry);
- }
- }
- private void finishWithPlayer (Player p)
- {
- // Remove their entry location.
- locations.remove(p);
- // Remove from the arenaMap.
- plugin.getAM().arenaMap.remove(p);
- // Remove from sets and restore health.
- resetPlayer( p )
- }
- private void resetPlayer (Player p)
- {
- // Restore their health.
- if (healthMap.containsKey(p)) p.setHealth(healthMap.remove(p));
- // Remove from sets.
- removePlayer(p);
- }
- private void preventUnwantedsFromEntry (Player p)
- {
- // Sit pets
- MAUtils.sitPets(p);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement