Advertisement
Guest User

KlickOnKopfListener

a guest
Jun 26th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.38 KB | None | 0 0
  1. public static File logs = new File("plugins/Smash", "stats.yml");
  2. public static YamlConfiguration cfg = YamlConfiguration.loadConfiguration(logs);
  3.  
  4. public static void save(Player p){
  5. try {
  6. cfg.save(logs);
  7. p.sendMessage("Kopf gesetzt!");
  8. } catch (IOException e) {
  9.  
  10. }
  11. }
  12.  
  13. public static void createStats(){
  14. if(!logs.exists()){
  15. try {
  16. logs.createNewFile();
  17. } catch (IOException e) {
  18. // TODO Auto-generated catch block
  19. e.printStackTrace();
  20. }
  21. }
  22. }
  23.  
  24. @EventHandler
  25. public void onDeath(PlayerDeathEvent e){
  26. e.setDeathMessage(null);
  27.  
  28. final Player p = e.getEntity();
  29.  
  30. final Player k = p.getKiller();
  31.  
  32.  
  33. e.setDeathMessage(null);
  34.  
  35. if(p.getKiller() == null) {
  36. p.sendMessage(Data.prefix + "Du bist gestorben!");
  37. MySQL.addTode(p.getUniqueId().toString(), 1, p.getName());
  38. p.spigot().respawn();
  39. } else {
  40. double leben = k.getHealth();
  41. double herzen = leben / 2;
  42. p.sendMessage(Data.prefix + "Du wurdest von §e" + p.getKiller().getName() + " §7mit §e" + herzen +"❤ §7getötet!");
  43. k.sendMessage(Data.prefix + "Du hast §e" + p.getName() + " §7getötet!");
  44. k.setHealth(20D);
  45.  
  46. MySQL.addCoins(k.getUniqueId().toString(), 1, k);
  47. p.sendMessage("+1 Coin");
  48. MySQL.addKIlls(k.getUniqueId().toString(), 1, k.getName());
  49.  
  50. MySQL.addTode(p.getUniqueId().toString(), 1, p.getName());
  51.  
  52. p.getInventory().clear();
  53. p.spigot().respawn();
  54. }
  55. }
  56.  
  57. @EventHandler
  58. public void onInteract(PlayerInteractEvent e){
  59. Player p = e.getPlayer();
  60.  
  61. if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
  62. if(e.getClickedBlock().getType() == Material.SKULL){
  63. Block skull = e.getClickedBlock();
  64. Skull s = (Skull) skull.getState();
  65.  
  66.  
  67. if(CMD_KOPF.kopfsetup.contains(p)){
  68. cfg.set("Kopf-1" + ".X", skull.getX());
  69. cfg.set("Kopf-1" + ".Y", skull.getY());
  70. cfg.set("Kopf-1" + ".Z", skull.getZ());
  71. cfg.set("Kopf-1" + ".World", skull.getWorld().getName());
  72. cfg.set("Kopf-1" + ".Richtung", s.getRotation().toString());
  73. save(p);
  74. CMD_KOPF.kopfsetup.remove(p);
  75. }else if(CMD_KOPF.kopfsetup2.contains(p)){
  76. cfg.set("Kopf-2" + ".X", skull.getX());
  77. cfg.set("Kopf-2" + ".Y", skull.getY());
  78. cfg.set("Kopf-2" + ".Z", skull.getZ());
  79. cfg.set("Kopf-2" + ".World", skull.getWorld().getName());
  80. cfg.set("Kopf-2" + ".Richtung", s.getRotation().toString());
  81. save(p);
  82. CMD_KOPF.kopfsetup2.remove(p);
  83. }else if(CMD_KOPF.kopfsetup3.contains(p)){
  84. cfg.set("Kopf-3" + ".X", skull.getX());
  85. cfg.set("Kopf-3" + ".Y", skull.getY());
  86. cfg.set("Kopf-3" + ".Z", skull.getZ());
  87. cfg.set("Kopf-3" + ".World", skull.getWorld().getName());
  88. cfg.set("Kopf-3" + ".Richtung", s.getRotation().toString());
  89. save(p);
  90. CMD_KOPF.kopfsetup3.remove(p);
  91. }else if(CMD_KOPF.kopfsetup4.contains(p)){
  92. cfg.set("Kopf-4" + ".X", skull.getX());
  93. cfg.set("Kopf-4" + ".Y", skull.getY());
  94. cfg.set("Kopf-4" + ".Z", skull.getZ());
  95. cfg.set("Kopf-4" + ".World", skull.getWorld().getName());
  96. cfg.set("Kopf-4" + ".Richtung", s.getRotation().toString());
  97. save(p);
  98. CMD_KOPF.kopfsetup4.remove(p);
  99. }else if(CMD_KOPF.kopfsetup5.contains(p)){
  100. cfg.set("Kopf-5" + ".X", skull.getX());
  101. cfg.set("Kopf-5" + ".Y", skull.getY());
  102. cfg.set("Kopf-5" + ".Z", skull.getZ());
  103. cfg.set("Kopf-5" + ".World", skull.getWorld().getName());
  104. cfg.set("Kopf-5" + ".Richtung", s.getRotation().toString());
  105. save(p);
  106. CMD_KOPF.kopfsetup5.remove(p);
  107. }else if(CMD_KOPF.kopfsetup6.contains(p)){
  108. cfg.set("Kopf-6" + ".X", skull.getX());
  109. cfg.set("Kopf-6" + ".Y", skull.getY());
  110. cfg.set("Kopf-6" + ".Z", skull.getZ());
  111. cfg.set("Kopf-6" + ".World", skull.getWorld().getName());
  112. cfg.set("Kopf-6" + ".Richtung", s.getRotation().toString());
  113. save(p);
  114. CMD_KOPF.kopfsetup6.remove(p);
  115. }else if(CMD_KOPF.kopfsetup7.contains(p)){
  116. cfg.set("Kopf-7" + ".X", skull.getX());
  117. cfg.set("Kopf-7" + ".Y", skull.getY());
  118. cfg.set("Kopf-7" + ".Z", skull.getZ());
  119. cfg.set("Kopf-7" + ".World", skull.getWorld().getName());
  120. cfg.set("Kopf-7" + ".Richtung", s.getRotation().toString());
  121. save(p);
  122. CMD_KOPF.kopfsetup7.remove(p);
  123. }else if(CMD_KOPF.kopfsetup8.contains(p)){
  124. cfg.set("Kopf-8" + ".X", skull.getX());
  125. cfg.set("Kopf-8" + ".Y", skull.getY());
  126. cfg.set("Kopf-8" + ".Z", skull.getZ());
  127. cfg.set("Kopf-8" + ".World", skull.getWorld().getName());
  128. cfg.set("Kopf-8" + ".Richtung", s.getRotation().toString());
  129. save(p);
  130. CMD_KOPF.kopfsetup8.remove(p);
  131. }else if(CMD_KOPF.kopfsetup9.contains(p)){
  132. cfg.set("Kopf-9" + ".X", skull.getX());
  133. cfg.set("Kopf-9" + ".Y", skull.getY());
  134. cfg.set("Kopf-9" + ".Z", skull.getZ());
  135. cfg.set("Kopf-9" + ".World", skull.getWorld().getName());
  136. cfg.set("Kopf-9" + ".Richtung", s.getRotation().toString());
  137. save(p);
  138. CMD_KOPF.kopfsetup9.remove(p);
  139. }else if(CMD_KOPF.kopfsetup10.contains(p)){
  140. cfg.set("Kopf-10" + ".X", skull.getX());
  141. cfg.set("Kopf-10" + ".Y", skull.getY());
  142. cfg.set("Kopf-10" + ".Z", skull.getZ());
  143. cfg.set("Kopf-10" + ".World", skull.getWorld().getName());
  144. cfg.set("Kopf-10" + ".Richtung", s.getRotation().toString());
  145. save(p);
  146. CMD_KOPF.kopfsetup10.remove(p);
  147. }
  148. }
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement