Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2018
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. @EventHandler
  2. public void onMobSpawn(CreatureSpawnEvent e) {
  3. String mobworld = e.getEntity().getWorld().getName();
  4. List<String> world1 = main.getConfig().getStringList("Enabled-Worlds");
  5. for (String world2 : world1) {
  6. if (e.getSpawnReason().equals(SpawnReason.NATURAL)) {
  7. if (mobworld.equalsIgnoreCase(world2)) {
  8. e.setCancelled(true);
  9. } else {}
  10. }
  11. }
  12. }
  13. public Location loc;
  14.  
  15. @EventHandler
  16. public void onPlayerKillMod(EntityDeathEvent e) {
  17. e.getDrops().clear();
  18. e.setDroppedExp(0);
  19. }
  20.  
  21. @SuppressWarnings("deprecation")
  22. @EventHandler
  23. public void onPlayerDeath(PlayerDeathEvent e){
  24. Player p = e.getEntity().getPlayer();
  25. if (config.getString("Players." + p.getName() + ".Arena") == null) {
  26. } else {
  27. try {
  28. config.load(file);
  29. } catch (IOException | InvalidConfigurationException e2) {
  30. e2.printStackTrace();
  31. }
  32. e.setDeathMessage("");
  33. p.sendMessage("§6You left the arena §c" + config.getString("Players." + p.getName() + ".Arena"));
  34. p.sendMessage("§cGame Ended! Results:");
  35. p.sendMessage("§7§m+-----------------+");
  36. p.sendMessage("§6 Points:");
  37. p.sendMessage(" §a+ " + config.getInt("Players." + p.getName() + ".Last-Game-Points"));
  38. p.sendMessage(" ");
  39. p.sendMessage("§6 Total Points:");
  40. p.sendMessage(" §a " + config.getInt("Players." + p.getName() + ".Total-Points"));
  41. p.sendMessage("§7§m+-----------------+");
  42. p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1020, 1000));
  43. p.removePotionEffect(PotionEffectType.CONFUSION);
  44. p.playEffect(p.getLocation(), Effect.ENDER_SIGNAL, 1);
  45. World world = Bukkit.getWorld(config.getString("Lobby.World"));
  46. double x = config.getDouble("Lobby.X");
  47. x = x + 0.5;
  48. double y = config.getDouble("Lobby.Y");
  49. double z = config.getDouble("Lobby.Z");
  50. z = z + 0.5;
  51. int yaw = config.getInt("Lobby.Yaw");
  52. int pitch = config.getInt("Lobby.Pitch");
  53. for (Entity entity : p.getWorld().getLivingEntities()) {
  54. if (entity.getName().equalsIgnoreCase("§cArena: §6" + config.getString("Players." + p.getName() + ".Arena"))) {
  55. double x1 = entity.getLocation().getBlockX();
  56. double y1 = entity.getLocation().getBlockY();
  57. y1 = y1 + 100;
  58. double z1 = entity.getLocation().getBlockZ();
  59. entity.teleport(new Location(entity.getWorld(), x1, y1, z1));
  60. }
  61. }
  62. try {
  63. config.load(file);
  64. } catch (IOException | InvalidConfigurationException e1) {
  65. e1.printStackTrace();
  66. }
  67. p.teleport(new Location(world, x, y, z, yaw , pitch));
  68. p.getInventory().clear();
  69. p.getInventory().setHelmet(null);
  70. p.getInventory().setChestplate(null);
  71. p.getInventory().setLeggings(null);
  72. p.getInventory().setBoots(null);
  73. int total = config.getInt("Players." + p.getName() + ".Total-Points");
  74. int toAdd = config.getInt("Players." + p.getName() + ".Last-Game-Points");
  75. config.set("Players." + p.getName() + ".Total-Points", total + toAdd);
  76. config.set("Players." + p.getName() + ".Last-Game-Points", 0);
  77. p.getWorld().playSound(p.getLocation(), Sound.PORTAL_TRAVEL, 1, 1);
  78. config.set("Players." + p.getName() + ".Arena", null);
  79. try {
  80. config.save(file);
  81. } catch (IOException e2) {
  82. e2.printStackTrace();
  83. }
  84. try {
  85. config.load(file);
  86. } catch (IOException | InvalidConfigurationException e1) {
  87. e1.printStackTrace();
  88. }
  89. }
  90. }
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement