Guest User

"KillEvents"-Klasse SkyPvP Plugin

a guest
Nov 5th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. package me.cravercraft.skypvp;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.Location;
  8. import org.bukkit.Material;
  9. import org.bukkit.configuration.file.FileConfiguration;
  10. import org.bukkit.configuration.file.YamlConfiguration;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.entity.PlayerDeathEvent;
  15. import org.bukkit.event.player.PlayerDropItemEvent;
  16. import org.bukkit.event.player.PlayerPickupItemEvent;
  17. import org.bukkit.inventory.ItemStack;
  18.  
  19. public class KillEvents implements Listener {
  20.  
  21. private SkyPvP plugin;
  22. int kills = 0;
  23.  
  24. public KillEvents(SkyPvP plugin) {
  25. this.plugin = plugin;
  26. plugin.getServer().getPluginManager().registerEvents(this, plugin);
  27. }
  28. @EventHandler
  29. public void onPlayerDeath(PlayerDeathEvent e) {
  30. String killedm = e.getEntity().getName();
  31. String killerm = e.getEntity().getKiller().getName();
  32.  
  33.  
  34.  
  35.  
  36. Player killer = e.getEntity().getKiller().getPlayer();
  37.  
  38. Player killed = e.getEntity().getPlayer();
  39.  
  40. if(plugin.inJump.contains(killed.getName())) {
  41. if(plugin.inJump.contains(killer.getName())) {
  42.  
  43. killer.sendMessage(plugin.prefix + "§3Du hast §c" + killedm + " §3getötet");
  44. killed.sendMessage(plugin.prefix + "§3Du wurdest von §e" + killerm + " §3getötet");
  45.  
  46. FileConfiguration cfgp = plugin.getConfig();
  47.  
  48. String world = cfgp.getString("World");
  49. double x = cfgp.getDouble("PosX");
  50. double y = cfgp.getDouble("PosY");
  51. double z = cfgp.getDouble("PosZ");
  52. double yaw = cfgp.getDouble("PosYaw");
  53. double pitch = cfgp.getDouble("PosPitch");
  54.  
  55. Location loc = new Location(Bukkit.getWorld(world), x, y, z);
  56. loc.setPitch((float) pitch);
  57. loc.setYaw((float) yaw);
  58.  
  59. killed.teleport(loc);
  60.  
  61. addKill(killer, killerm);
  62.  
  63. Level1(killed);
  64.  
  65. if(plugin.Level1.contains(killer.getName())) {
  66. Level2(killer);
  67. }
  68. }
  69. }
  70. }
  71. //Level1
  72. @SuppressWarnings("deprecation")
  73. public void Level1(Player p) {
  74.  
  75. plugin.Level1.add(p.getName());
  76.  
  77. ItemStack Level1 = new ItemStack(Material.WOOD_AXE);
  78.  
  79. p.getInventory().setItem(0, Level1);
  80. p.updateInventory();
  81. }
  82.  
  83.  
  84. //Level2
  85. @SuppressWarnings("deprecation")
  86. public void Level2(Player p) {
  87.  
  88. plugin.Level2.add(p.getName());
  89.  
  90. p.getInventory().clear();
  91.  
  92. ItemStack Level2 = new ItemStack(Material.WOOD_SWORD);
  93.  
  94. p.getInventory().setItem(0, Level2);
  95. p.updateInventory();
  96. }
  97.  
  98. //Verhinderungen
  99. @EventHandler
  100. public void onItemDrop(PlayerDropItemEvent e) {
  101. Player p = e.getPlayer();
  102. if(plugin.inJump.contains(p.getName())) {
  103. e.setCancelled(true);
  104. }
  105.  
  106. }
  107. @EventHandler
  108. public void onItemPickup(PlayerPickupItemEvent e) {
  109. Player p = e.getPlayer();
  110. if(plugin.inJump.contains(p.getName())) {
  111. e.setCancelled(true);
  112. }
  113. }
  114. public void addKill(Player killer, String name) {
  115. File file = new File("plugins/SkyPvP", "kills.yml");
  116. FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  117.  
  118. int kills = cfg.getInt(name + ".kills");
  119.  
  120. kills=kills+1;
  121.  
  122. cfg.set(name + ".kills", kills);
  123. try {
  124. cfg.save(file);
  125. } catch (IOException e) {
  126. e.printStackTrace();
  127. }
  128. }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment