Advertisement
Guest User

Untitled

a guest
May 30th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.79 KB | None | 0 0
  1. package party.events;
  2.  
  3. import java.io.File;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.GameMode;
  7. import org.bukkit.Location;
  8. import org.bukkit.Material;
  9. import org.bukkit.Sound;
  10. import org.bukkit.configuration.file.FileConfiguration;
  11. import org.bukkit.configuration.file.YamlConfiguration;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.event.EventHandler;
  14. import org.bukkit.event.Listener;
  15. import org.bukkit.event.player.PlayerJoinEvent;
  16. import org.bukkit.inventory.ItemStack;
  17.  
  18. import party.main.PartyPvP;
  19.  
  20. public class Join implements Listener {
  21.  
  22. private PartyPvP plugin;
  23. int Start = 6;
  24. int Countdown;
  25.  
  26. public Join(PartyPvP partyPvP) {
  27. this.plugin = partyPvP;
  28. plugin.getServer().getPluginManager().registerEvents(this, this.plugin);
  29. }
  30.  
  31. public boolean isStarted = false;
  32.  
  33. @EventHandler
  34. public void onJoin(PlayerJoinEvent e) {
  35. final Player p = e.getPlayer();
  36.  
  37. e.setJoinMessage(plugin.Prefix + "§5" + p.getName() + "§7 hat den PartyPvP Server betreten.");
  38.  
  39.  
  40. if(plugin.blue.size() == 0) {
  41. plugin.blue.add(p);
  42. p.sendMessage(plugin.Prefix + "Du wurdest in das Team §9Blau §7verschoben!");
  43. p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind.");
  44. p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3);
  45.  
  46.  
  47. } else if(plugin.red.size() == 0) {
  48. plugin.red.add(p);
  49. p.sendMessage(plugin.Prefix + "Du wurdest in das Team §cRot §7verschoben!");
  50. p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind.");
  51. p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3);
  52.  
  53.  
  54. } else if(plugin.green.size() == 0) {
  55. plugin.green.add(p);
  56. p.sendMessage(plugin.Prefix + "Du wurdest in das Team §aGrün §7verschoben!");
  57. p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind.");
  58. p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3);
  59.  
  60.  
  61. } else if(plugin.yellow.size() == 0) {
  62. plugin.yellow.add(p);
  63. p.sendMessage(plugin.Prefix + "Du wurdest in das Team §eGelb §7verschoben!");
  64. p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind.");
  65. p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3);
  66.  
  67.  
  68. }
  69.  
  70.  
  71. startCountdown();
  72.  
  73. }
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. private void Items(Player p) {
  81. p.getInventory().addItem(new ItemStack(Material.WOOD_SWORD));
  82. p.getInventory().addItem(new ItemStack(Material.FISHING_ROD));
  83. p.getInventory().addItem(new ItemStack(Material.BOW));
  84. p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 1));
  85. p.getInventory().addItem(new ItemStack(Material.BREAD, 5));
  86. p.getInventory().addItem(new ItemStack(Material.ARROW, 5));
  87.  
  88. p.getInventory().setHelmet(new ItemStack(Material.LEATHER_HELMET));
  89. p.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
  90. p.getInventory().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
  91. p.getInventory().setBoots(new ItemStack(Material.LEATHER_BOOTS));
  92.  
  93.  
  94.  
  95. }
  96.  
  97. public void startCountdown() {
  98. if(isStarted) {
  99. return;
  100. }
  101. if(Bukkit.getOnlinePlayers().length == 4) {
  102. for(final Player players : Bukkit.getOnlinePlayers()) {
  103. Countdown = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
  104.  
  105. @Override
  106. public void run() {
  107. isStarted = true;
  108. Start--;
  109. if(Start == 5) {
  110. Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §55 §7Sekunden!");
  111.  
  112. } else if(Start == 4) {
  113. Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §54 §7Sekunden!");
  114.  
  115. } else if(Start == 3) {
  116. Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §53 §7Sekunden!");
  117.  
  118. } else if(Start == 2) {
  119. Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §52 §7Sekunden!");
  120.  
  121. } else if(Start == 1) {
  122. Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §51 §7Sekunde!");
  123.  
  124. } else if(Start == 0) {
  125. Bukkit.getScheduler().cancelTask(Countdown);
  126. Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel hat gestartet! §5Viel Glück!");
  127.  
  128.  
  129. for(Player red : plugin.red) {
  130. File file = new File("plugins/PartyPvP/", "Red-Point.yml");
  131. FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  132. String world = cfg.getString("red.World");
  133. double x = cfg.getDouble("red.X");
  134. double y = cfg.getDouble("red.Y");
  135. double z = cfg.getDouble("red.Z");
  136. double yaw = cfg.getDouble("red.Yaw");
  137. double pitch = cfg.getDouble("red.Pitch");
  138.  
  139. Location loc = new Location(Bukkit.getWorld(world), x, y, z);
  140. loc.setPitch((float)pitch);
  141. loc.setYaw((float)yaw);
  142.  
  143. red.teleport(loc);
  144. Items(red);
  145. red.setGameMode(GameMode.ADVENTURE);
  146.  
  147.  
  148. }
  149.  
  150. for(Player blue : plugin.blue) {
  151. File file = new File("plugins/PartyPvP/", "Blue-Point.yml");
  152. FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  153. String world = cfg.getString("blue.World");
  154. double x = cfg.getDouble("blue.X");
  155. double y = cfg.getDouble("blue.Y");
  156. double z = cfg.getDouble("blue.Z");
  157. double yaw = cfg.getDouble("blue.Yaw");
  158. double pitch = cfg.getDouble("blue.Pitch");
  159.  
  160. Location loc = new Location(Bukkit.getWorld(world), x, y, z);
  161. loc.setPitch((float)pitch);
  162. loc.setYaw((float)yaw);
  163.  
  164. blue.teleport(loc);
  165. Items(blue);
  166. blue.setGameMode(GameMode.ADVENTURE);
  167.  
  168.  
  169. }
  170.  
  171. for(Player green : plugin.green) {
  172. File file = new File("plugins/PartyPvP/", "Green-Point.yml");
  173. FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  174. String world = cfg.getString("green.World");
  175. double x = cfg.getDouble("green.X");
  176. double y = cfg.getDouble("green.Y");
  177. double z = cfg.getDouble("green.Z");
  178. double yaw = cfg.getDouble("green.Yaw");
  179. double pitch = cfg.getDouble("green.Pitch");
  180.  
  181. Location loc = new Location(Bukkit.getWorld(world), x, y, z);
  182. loc.setPitch((float)pitch);
  183. loc.setYaw((float)yaw);
  184.  
  185. green.teleport(loc);
  186. Items(green);
  187. green.setGameMode(GameMode.ADVENTURE);
  188.  
  189.  
  190. }
  191.  
  192. for(Player yellow : plugin.yellow) {
  193. File file = new File("plugins/PartyPvP/", "Yellow-Point.yml");
  194. FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  195. String world = cfg.getString("yellow.World");
  196. double x = cfg.getDouble("yellow.X");
  197. double y = cfg.getDouble("yellow.Y");
  198. double z = cfg.getDouble("yellow.Z");
  199. double yaw = cfg.getDouble("yellow.Yaw");
  200. double pitch = cfg.getDouble("yellow.Pitch");
  201.  
  202. Location loc = new Location(Bukkit.getWorld(world), x, y, z);
  203. loc.setPitch((float)pitch);
  204. loc.setYaw((float)yaw);
  205.  
  206. yellow.teleport(loc);
  207. Items(yellow);
  208. yellow.setGameMode(GameMode.ADVENTURE);
  209.  
  210. }
  211.  
  212.  
  213.  
  214. }
  215.  
  216.  
  217.  
  218.  
  219. }
  220.  
  221. }, 20, 20);
  222. }
  223.  
  224.  
  225. }
  226. }
  227.  
  228. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement