Advertisement
Guest User

main.class

a guest
Jun 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. package me.bricedev.wrcp;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.Effect;
  8. import org.bukkit.Location;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.inventory.ItemStack;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13. import org.bukkit.scheduler.BukkitRunnable;
  14.  
  15. public class Main
  16. extends JavaPlugin implements Listener {
  17. static Main pl;
  18. static GenerateChest gc = new GenerateChest();
  19. Database data = Database.instance;
  20. LoadChances lc = LoadChances.instance;
  21. Timer timer = Timer.instance;
  22. FindAvaliableLocation fal = new FindAvaliableLocation();
  23. ArrayList<String> commands = new ArrayList();
  24. public void onEnable() {
  25. saveDefaultConfig();
  26. if (!getConfig().isInt("LargestDinctance_Y")) {
  27. getConfig().set("LargestDinctance_Y", Integer.valueOf(300));
  28. getConfig().set("SmallestDinctance_Y", Integer.valueOf(60));
  29. saveConfig();
  30. saveDefaultConfig();
  31. }
  32. if (!getConfig().isList("CommandsToExecuteOnLoot")) {
  33. ArrayList<String> commands = new ArrayList<String>();
  34. commands.add("eco give {player} 100");
  35. getConfig().set("CommandsToExecuteOnLoot", commands);
  36. saveConfig();
  37. saveDefaultConfig();
  38. }
  39. this.data.setup(this);
  40. this.data.data.options().copyDefaults(true);
  41. pl = this;
  42. gc.GenerateChest(getConfig().getInt("SpawnChestPerTime"));
  43. if (!this.data.data.isConfigurationSection("Chests")) {
  44. this.data.data.createSection("Chests");
  45. this.data.saveData();
  46. }
  47. if (!this.data.data.isConfigurationSection("ItemDatabase")) {
  48. this.data.data.createSection("ItemDatabase");
  49. this.data.saveData();
  50. }
  51. if (!this.data.data.isConfigurationSection("LocationDatabase")) {
  52. this.data.data.createSection("LocationDatabase");
  53. this.data.saveData();
  54. }
  55. getCommand("wcp").setExecutor(new CommandManager());
  56. getServer().getPluginManager().registerEvents(new LootEvent(), this);
  57. getServer().getPluginManager().registerEvents(new ItemAdderGui(), this);
  58. if (getConfig().getBoolean("Particles")) {
  59. Particles();
  60. }
  61. this.lc.loaditems();
  62. if (getConfig().getBoolean("KillChest")) {
  63. this.timer.decrease();
  64. }
  65. this.timer.loadchests();
  66. this.fal.init();
  67. if (getConfig().getList("CommandsToExecuteOnLoot") != null) {
  68. this.commands = (ArrayList)getConfig().getList("CommandsToExecuteOnLoot");
  69. }
  70. }
  71.  
  72. public void onDisable() { this.timer.saveChests(); }
  73.  
  74. HashMap<Location, Integer> chests = new HashMap();
  75.  
  76. ArrayList<Player> abletobreak = new ArrayList();
  77. ArrayList<Player> additem = new ArrayList();
  78. static HashMap<Integer, ItemStack> items = new HashMap();
  79. HashMap<Integer, ItemStack> itemstoadd = new HashMap();
  80. HashMap<Integer, Integer> chances = new HashMap();
  81. HashMap<Player, Integer> currentpage = new HashMap();
  82. HashMap<Player, Integer> idediting = new HashMap();
  83. HashMap<Player, Integer> lastpageno = new HashMap();
  84.  
  85. public void Particles() {
  86. new BukkitRunnable() {
  87. public void run() {
  88. try {
  89. for (Map.Entry<Location, Integer> e : Main.this.chests.entrySet()) {
  90. Location loc = (Location) e.getKey();
  91. loc.getWorld().playEffect(loc, Effect.MOBSPAWNER_FLAMES, 1);
  92. }
  93.  
  94. } catch (Exception exception) {
  95. }
  96. }
  97. }.runTaskTimer(Main.pl, 20, 20L);
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement