Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rektwarfare.dtp.events;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.GameMode;
- import org.bukkit.Material;
- import org.bukkit.Sound;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.PlayerDeathEvent;
- import org.bukkit.inventory.ItemStack;
- import com.rektwarfare.dtp.DTP;
- import com.rektwarfare.dtp.game.EndGame;
- import com.rektwarfare.dtp.listeners.MainMenu;
- import com.rektwarfare.dtp.timer.GameEndTimer;
- import com.rektwarfare.dtp.utils.TabUtils;
- import net.milkbowl.vault.economy.EconomyResponse;
- public class DeathEvents implements Listener {
- public DTP plugin;
- public GameEndTimer endGameTimer;
- public DeathEvents(DTP plugin) {
- this.plugin = plugin;
- }
- public MainMenu kitClass = new MainMenu(plugin);
- public EndGame endGame = new EndGame(plugin);
- @SuppressWarnings("static-access")
- @EventHandler
- public void onDeathEvents(PlayerDeathEvent e) {
- Player player = e.getEntity();
- Player killer = e.getEntity().getKiller();
- e.getDrops().clear();
- e.setDroppedExp(0);
- e.setDeathMessage(null);
- plugin.updatescoreonQuit(player);
- player.spigot().respawn();
- if (player.getGameMode() == GameMode.ADVENTURE || player.getGameMode() == GameMode.SURVIVAL) {
- player.setGameMode(GameMode.SPECTATOR);
- }
- player.sendMessage(ChatColor.RED + "You're now a spectator for the remainder of the game.");
- if (player.getName().equals(plugin.presidentPlayer)) {
- for (Player p : Bukkit.getOnlinePlayers()) {
- p.playSound(p.getLocation(), Sound.ENDERMAN_SCREAM, 1, 1);
- }
- Bukkit.broadcastMessage(ChatColor.RED + killer.getName() + ChatColor.YELLOW + " has assassinated the "
- + ChatColor.BLUE + "President!");
- endGame.gameOver(0);
- Bukkit.broadcastMessage(ChatColor.RED + "" + ChatColor.BOLD + "Attackers win!" + ChatColor.YELLOW + " The President has been killed.");
- EconomyResponse r = plugin.econ.depositPlayer(killer, 5);
- if (r.transactionSuccess()) {
- killer.sendMessage(plugin.prefix + "+5 Coins for killing the President!");
- }
- }
- EconomyResponse r = plugin.econ.depositPlayer(killer, 1);
- if (r.transactionSuccess()) {
- killer.sendMessage(plugin.prefix + "+1 Coins for killing " + player.getName() + "!");
- }
- plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
- @SuppressWarnings("deprecation")
- public void run() {
- player.spigot().respawn();
- player.teleport(plugin.maplobby);
- player.getInventory().clear();
- player.updateInventory();
- for (Player p : Bukkit.getOnlinePlayers()) {
- if (!p.equals(player)) {
- p.hidePlayer(player);
- }
- }
- kitClass.kitselected.remove(player.getUniqueId());
- TabUtils.sendFullTitle(player, 10, 10, 10, ChatColor.BLUE + "" + ChatColor.BOLD + "YOU DIED",
- ChatColor.YELLOW + "You are now a spectator");
- player.sendMessage(ChatColor.YELLOW + "You are now a " + ChatColor.BLUE + "Spectator");
- if (player.getPlayer().getGameMode() == GameMode.SURVIVAL
- || (player.getPlayer().getGameMode() == GameMode.ADVENTURE)) {
- player.getPlayer().setGameMode(GameMode.SPECTATOR);
- }
- player.getPlayer().setGameMode(GameMode.SPECTATOR);
- player.getInventory().setHelmet(new ItemStack(Material.AIR));
- player.getInventory().setChestplate(new ItemStack(Material.AIR));
- player.getInventory().setLeggings(new ItemStack(Material.AIR));
- player.getInventory().setBoots(new ItemStack(Material.AIR));
- player.setHealth(20);
- player.getInventory().clear();
- player.updateInventory();
- }
- }, 2L);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement