Advertisement
NiRoXz

FinalDeathListener - Fabi

Mar 20th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Listeners;
  2.  
  3.  
  4. import java.io.File;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.GameMode;
  8. import org.bukkit.Location;
  9. import org.bukkit.OfflinePlayer;
  10. import org.bukkit.Server;
  11. import org.bukkit.Sound;
  12. import org.bukkit.configuration.file.FileConfiguration;
  13. import org.bukkit.configuration.file.YamlConfiguration;
  14. import org.bukkit.craftbukkit.Main;
  15. import org.bukkit.entity.Player;
  16. import org.bukkit.event.EventHandler;
  17. import org.bukkit.event.Listener;
  18. import org.bukkit.event.entity.PlayerDeathEvent;
  19. import org.bukkit.event.player.PlayerRespawnEvent;
  20.  
  21. import com.connorlinfoot.bountifulapi.BountifulAPI;
  22.  
  23. import main.MainClass;
  24. public class FinalDeathListener
  25.   implements Listener
  26. {
  27.      
  28.   private MainClass plugin;
  29.  
  30.   public FinalDeathListener(MainClass plugin)
  31.   {
  32.      
  33.      
  34.     this.plugin = plugin;
  35.     plugin.getServer().getPluginManager().registerEvents(this, plugin);
  36.   }
  37.  
  38.  
  39.   File mapfile = new File("plugins/NextPlugin/Maps", "maps.yml");
  40.   FileConfiguration cfgmap = YamlConfiguration.loadConfiguration(this.mapfile);
  41.  
  42.  
  43. @EventHandler
  44. public void onDeath (PlayerDeathEvent e) {
  45.     Player p = e.getEntity().getPlayer();
  46.     e.setDeathMessage(null);
  47.    
  48.     if(plugin.HasBlock.contains(p)) {
  49.    
  50.         plugin.respawn(p);
  51.    
  52.     } else if(!plugin.HasBlock.contains(p)) {
  53.  
  54.         p.setGameMode(GameMode.SPECTATOR);
  55.         plugin.respawn(p);
  56.         p.getInventory().clear();
  57.        
  58.       BountifulAPI.sendTitle(p,5,10,5,"Ausgeschieden!","");
  59.       p.playSound(p.getLocation(), Sound.BLOCK_PISTON_CONTRACT, 1, 0);
  60.     }
  61.  
  62.  
  63.        
  64.           if (e.getEntity().getKiller() != null) {
  65.              
  66.                 for (Player all : Bukkit.getOnlinePlayers()) {
  67.                    
  68.                     if(plugin.HasBlock.contains(p)) {
  69.                        
  70.                         all.sendMessage(MainClass.prefix + "§r" + p.getDisplayName() +" §7wurde von §r" + e.getEntity().getKiller().getDisplayName() +  " §7getötet");
  71.                        
  72.                     } else if(!plugin.HasBlock.contains(p)) {
  73.                         all.sendMessage(MainClass.prefix + "§r" + p.getDisplayName() + " §7ist ausgeschieden!");
  74.                        
  75.                         if(plugin.TeamBlau.contains(p)) {
  76.                             plugin.TeamBlau.remove(p);
  77.                             p.sendMessage("jgsfhgsqfs");
  78.                         }
  79.                        
  80.                         if(plugin.TeamRot.contains(p)) {
  81.                             plugin.TeamRot.remove(p);
  82.                         }
  83.  
  84.                     }
  85.                    
  86.                 }
  87.                
  88.             } else {
  89.              
  90.                 for (Player all : Bukkit.getOnlinePlayers()) {
  91.                    
  92.                     if(plugin.HasBlock.contains(p)) {
  93.                        
  94.                         all.sendMessage(MainClass.prefix + "§r" + p.getDisplayName() + " §7ist gestorben");
  95.                        
  96.                     } else if(!plugin.HasBlock.contains(p)) {
  97.                         all.sendMessage(MainClass.prefix + "§r" + p.getDisplayName() + " §7ist ausgeschieden!");
  98.                        
  99.                         if(plugin.TeamBlau.contains(p)) {
  100.                             plugin.TeamBlau.remove(p);
  101.                             p.sendMessage("jgsfhgsqfs");
  102.                         }
  103.                        
  104.                         if(plugin.TeamRot.contains(p)) {
  105.                             plugin.TeamRot.remove(p);
  106.                         }
  107.                     }
  108.                        
  109.  
  110.                 }
  111.                
  112.             }
  113.  
  114.  
  115.     if(plugin.TeamBlau.contains(p) && plugin.HasBlock.contains(p)) {
  116.    
  117.     if(!plugin.HasBlock.contains(p)) {
  118.        
  119.         p.sendMessage(MainClass.prefix + "§cDu bist aus dieser Runde ausgeschieden!");
  120.         p.setGameMode(GameMode.SPECTATOR);
  121.         p.getInventory().clear();
  122.         p.playSound(p.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 2);
  123.        
  124.     }
  125.    
  126.    
  127.    
  128.    
  129.     }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement