Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.04 KB | None | 0 0
  1. public static Main instance;
  2.     private ConfigUtil pluginConfig;
  3.     private RecipeManager recipe;
  4.     /*private ShapedRecipe basic;
  5.     private ShapedRecipe advanced;
  6.     private ShapedRecipe expert;
  7.     private ShapedRecipe remote;*/
  8.     public static boolean usePower = false;
  9.     public static ExodusAPIMessageUtil messageUtil;
  10.     public static String PREFIX;
  11.  
  12.     @SuppressWarnings({ "static-access" })
  13.     @Override
  14.     public void onEnable() {
  15.         messageUtil = new ExodusAPIMessageUtil();
  16.         PREFIX = messageUtil.getPrefix;
  17.         instance = this;
  18.        
  19.         // * load Configuration * //
  20.         loadConfig();
  21.  
  22.         // * Load Recipes * //
  23.         recipe.loadRecipes();
  24.        
  25.         // * Load Commands * //
  26.         registerCommands();
  27.        
  28.         // * Load Events * //
  29.         registerEvents();
  30.        
  31.         // * Load Database * //
  32.         loadDataBase();
  33.        
  34.     }
  35.  
  36.     @Override
  37.     public void onDisable() {
  38.         ACC_DatabaseInterface.closeConnection(ACC_DatabaseInterface.getConnection());
  39.     }
  40.    
  41.     private void registerCommands() {
  42.         this.getCommand("createdir").setExecutor(new Command_createdir());
  43.         this.getCommand("search").setExecutor(new Command_search());
  44.     }
  45.    
  46.     private void registerEvents() {
  47.         Bukkit.getPluginManager().registerEvents(new CamStorageListener(), instance);
  48.     }
  49.    
  50.     private void loadConfig() {
  51.         // * Create Config with Method * //
  52.         pluginConfig = new ConfigUtil(instance, "config.yml");
  53.         pluginConfig.saveDefaultConfig();
  54.        
  55.         // * If Statement to Energy consume ** //
  56.         if (pluginConfig.getConfig().contains("CamStorage.energy.consume")
  57.                 && pluginConfig.getConfig().getBoolean("CamStorage.energy.consume")) {
  58.             Plugin stb = Bukkit.getPluginManager().getPlugin("SensibleToolbox");
  59.             if (stb != null) {
  60.                 usePower = true;
  61.             }
  62.         }
  63.        
  64.     }
  65.    
  66.     /*private void loadRecipe() {
  67.        
  68.         basic = new ShapedRecipe(
  69.                 new ACC_DIR(16, 16 * 128 * 4, new ArrayList<ACC_DigitisedItem>(), "CraftingItem").getItem());
  70.         basic.shape("XYX", "YZY", "XYX");
  71.         basic.setIngredient('X', Material.GLASS);
  72.         basic.setIngredient('Y', Material.OBSIDIAN);
  73.         basic.setIngredient('Z', Material.IRON_INGOT);
  74.         Bukkit.addRecipe(basic);
  75.  
  76.         advanced = new ShapedRecipe(
  77.                 new ACC_DIR(32, 32 * 256 * 4, new ArrayList<ACC_DigitisedItem>(), "CraftingItem").getItem());
  78.         advanced.shape("XYX", "YZY", "XYX");
  79.         advanced.setIngredient('X', Material.GLASS);
  80.         advanced.setIngredient('Y', Material.OBSIDIAN);
  81.         advanced.setIngredient('Z', Material.GOLD_INGOT);
  82.         Bukkit.addRecipe(advanced);
  83.  
  84.         expert = new ShapedRecipe(
  85.                 new ACC_DIR(64, 64 * 512 * 4, new ArrayList<ACC_DigitisedItem>(), "CraftingItem").getItem());
  86.         expert.shape("XYX", "YZY", "XYX");
  87.         expert.setIngredient('X', Material.GLASS);
  88.         expert.setIngredient('Y', Material.OBSIDIAN);
  89.         expert.setIngredient('Z', Material.DIAMOND);
  90.         Bukkit.addRecipe(expert);
  91.  
  92.         remote = new ShapedRecipe(new ACC_HTAD().toItemStack());
  93.         remote.shape("DCD", "BAB", "DDD");
  94.         remote.setIngredient('A', Material.BREWING_STAND);
  95.         remote.setIngredient('B', Material.STONE_BUTTON);
  96.         remote.setIngredient('C', Material.REDSTONE);
  97.         remote.setIngredient('D', Material.IRON_INGOT);
  98.         Bukkit.addRecipe(remote);
  99.     }*/
  100.    
  101.     private void loadDataBase() {
  102.         try {
  103.             ACC_DatabaseInterface.prepareDatabase();
  104.         } catch (SQLException ex) {
  105.             Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  106.         }
  107.         new BukkitRunnable() {
  108.             @Override
  109.             public void run() {
  110.                 try {
  111.                     ACC_DatabaseInterface.getConnection().commit();
  112.                 } catch (SQLException ex) {
  113.                     Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  114.                 }
  115.             }
  116.         }.runTaskTimerAsynchronously(this, 0, 200);
  117.     }
  118.    
  119.  
  120.     @Override
  121.     public File getFile() {
  122.         return super.getFile();
  123.     }
  124.     public static Main getInstance() {
  125.         return instance;
  126.     }
  127.     public ConfigUtil getConfigManager() {
  128.         return pluginConfig;
  129.     }
  130.    
  131.  
  132.     public static <T> List<List<T>> chopped(List<T> list, final int L) {
  133.         List<List<T>> parts = new ArrayList<>();
  134.         final int N = list.size();
  135.         for (int i = 0; i < N; i += L) {
  136.             parts.add(new ArrayList<>(list.subList(i, Math.min(N, i + L))));
  137.         }
  138.         return parts;
  139.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement