Advertisement
Guest User

Untitled

a guest
Jun 21st, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. package main;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.Random;
  6. import java.util.logging.Logger;
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.Location;
  9. import org.bukkit.World;
  10. import org.bukkit.configuration.file.FileConfiguration;
  11. import org.bukkit.configuration.file.YamlConfiguration;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.plugin.java.JavaPlugin;
  14.  
  15. public class KitPvP extends JavaPlugin{
  16.  
  17. public static Logger mclogger = Logger.getLogger("§8[§7KitPvP-System§8] §a");
  18. public static Logger logger = Logger.getLogger("[KitPvP-System] ");
  19. public static File file = new File("plugins/KitPvP-System", "config.yml");
  20. public static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  21. File file2 = new File("plugins/KitPvP-System", "maps.yml");
  22. FileConfiguration cfg2 = YamlConfiguration.loadConfiguration(file2);
  23.  
  24. @Override
  25. public void onEnable() {
  26. Bukkit.getPluginManager().registerEvents(new Listeners(), this);
  27. logger.info("lade System...");
  28. logger.info("version: " + getDescription().getVersion());
  29. logger.info("author: " + getDescription().getAuthors());
  30. logger.info("Danke fuers benutzen!");
  31. if(!(file.exists())) {
  32. file.getParentFile().mkdirs();
  33. try {
  34. loadConfig();
  35. } catch (IOException e) {
  36. e.printStackTrace();
  37. }
  38. }else{
  39. try {
  40. loadConfig();
  41. } catch (IOException e) {
  42. e.printStackTrace();
  43. }
  44. }
  45. getCommand("kitpvp").setExecutor(new Commands());
  46. getCommand("kploschen").setExecutor(new Commands());
  47. getCommand("kpcreate").setExecutor(new Commands());
  48. getCommand("kpinterval").setExecutor(new Commands());
  49. getCommand("kpteleport").setExecutor(new Commands());
  50. //SYSTEM
  51. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
  52.  
  53. @Override
  54. public void run() {
  55. Random r = new Random();
  56. final int zufall = r.nextInt(20);
  57. if(cfg2.getBoolean("EnableMap" + zufall + ".enabled")) {
  58. double x = cfg2.getDouble("Map" + zufall + ".X");
  59. double y = cfg2.getDouble("Map" + zufall + ".Y");
  60. double z = cfg2.getDouble("Map" + zufall + ".Z");
  61. double yaw = cfg2.getDouble("Map" + zufall + ".Yaw");
  62. double pitch = cfg2.getDouble("Map" + zufall + ".Pitch");
  63. String worldname = cfg2.getString("Map" + zufall + ".world");
  64. World world = Bukkit.getWorld(worldname);
  65. Location loc = new Location(world, x, y, z, (float)yaw, (float)pitch);
  66. for(Player op : Bukkit.getOnlinePlayers()) {
  67. op.teleport(loc);
  68. }
  69. }else{
  70. System.err.println("FATAL: Die Map " + zufall + " gibt es nicht! Teleportiere zu Map 2");
  71. double x = cfg2.getDouble("Map2.X");
  72. double y = cfg2.getDouble("Map2.Y");
  73. double z = cfg2.getDouble("Map2.Z");
  74. double yaw = cfg2.getDouble("Map2.Yaw");
  75. double pitch = cfg2.getDouble("Map2.Pitch");
  76. String worldname = cfg2.getString("Map2.world");
  77. World world = Bukkit.getWorld(worldname);
  78. Location loc = new Location(world, x, y, z, (float)yaw, (float)pitch);
  79. for(Player op : Bukkit.getOnlinePlayers()) {
  80. op.teleport(loc);
  81. }
  82. }
  83. }
  84. }, 0L, cfg.getInt("interval")*20L);
  85. }
  86.  
  87. @Override
  88. public void onDisable() {
  89. logger.info("endlade System...");
  90. logger.info("version: " + getDescription().getVersion());
  91. logger.info("author: " + getDescription().getAuthors());
  92. logger.info("Danke fuers benutzen!");
  93. }
  94.  
  95. public void loadConfig() throws IOException {
  96. FileConfiguration c = cfg;
  97. c.options().copyDefaults(true);
  98. c.options().copyHeader(true);
  99. c.options().header("Hier kannst du die Zeit zum ändern der Map einstellen!");
  100. c.addDefault("interval", 10800*20L);
  101. for(int i = 1; i <= 20; i++) {
  102. c.addDefault("EnableMap" + i + ".enabled", true);
  103. }
  104. c.save(file);
  105. }
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement