Guest User

Untitled

a guest
Apr 18th, 2020
197
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedReader;
  2. import java.io.File;
  3. import java.io.InputStream;
  4. import java.io.InputStreamReader;
  5. import java.io.Reader;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8. import java.util.logging.Level;
  9.  
  10. import org.apache.logging.log4j.core.config.Configuration;
  11. import org.bukkit.Bukkit;
  12. import org.bukkit.ChatColor;
  13. import org.bukkit.Material;
  14. import org.bukkit.configuration.file.FileConfiguration;
  15. import org.bukkit.configuration.file.YamlConfiguration;
  16. import org.bukkit.event.Listener;
  17. import org.bukkit.inventory.ItemStack;
  18. import org.bukkit.plugin.Plugin;
  19. import org.bukkit.plugin.java.JavaPlugin;
  20.  
  21. import jdk.nashorn.internal.runtime.regexp.joni.Config;
  22. import me.cat700.mythics.api.MShapedRecipe;
  23. import me.cat700.mythics.api.MShapelessRecipe;
  24. import me.cat700.mythics.api.RecipeHelpShapeless;
  25.  
  26. @SuppressWarnings("unused")
  27. public class mythics extends JavaPlugin implements Listener {
  28.     private static mythics Plugin;
  29.    
  30.     private static FileConfiguration config = new YamlConfiguration();
  31.    
  32.    
  33.     @Override
  34.     public void onEnable() {       
  35.         Plugin = this;
  36.         configstart();
  37.        
  38.         MShapedRecipe SROP = new MShapedRecipe("test", new ItemStack(Material.ACACIA_BUTTON));
  39.         SROP.Shape(" !! ", "    ", "    ", "    ");
  40.         SROP.SetIngredient('!', new ItemStack(Material.TRIPWIRE_HOOK));
  41.         SROP.addrecipe();
  42.         SROP.newRecipe("test", new ItemStack(Material.ACACIA_BUTTON));
  43.         SROP.Shape("    ", " !! ", "    ", "    ");
  44.         SROP.SetIngredient('!', new ItemStack(Material.TRIPWIRE_HOOK, 50));
  45.         SROP.addrecipe();
  46.  
  47.         MShapelessRecipe SLROP = new MShapelessRecipe("test", new ItemStack(Material.ACACIA_BUTTON));
  48.         SLROP.AddIngredient(new ItemStack(Material.TRIPWIRE_HOOK, 50));
  49.         SLROP.newRecipe("test2", new ItemStack(Material.ACACIA_BUTTON));
  50.         SLROP.AddIngredient(new ItemStack(Material.TRIPWIRE_HOOK));
  51.  
  52.         getServer().getPluginManager().registerEvents(new teleportBow(), (Plugin)this);
  53.         getServer().getPluginManager().registerEvents(new mythicCrafter(), (Plugin)this);
  54.         getServer().getPluginManager().registerEvents(new RecipeHelpShapeless(), (Plugin)this);
  55.         //getServer().getPluginManager().registerEvents(new RecipeHelp(), (Plugin)this);
  56.         getServer().getPluginManager().registerEvents(new MBoots(), (Plugin) this);
  57.         mythicCrafter.Recipe();
  58.     }
  59.  
  60.     public static mythics getplugin() {
  61.         return Plugin;
  62.     }
  63.     public static FileConfiguration getconfig() {
  64.         return config;
  65.     }
  66.     private void configstart() {
  67.         List<String> missing = new ArrayList<String>();
  68.         FileConfiguration defconfig = new YamlConfiguration();
  69.         Reader defaultStream = null;
  70.         File configFile = new File(this.getDataFolder(), "config.yml");
  71.        
  72.         try {
  73.             defaultStream = new InputStreamReader(this.getResource("config.yml"), "UTF8");
  74.             if (defaultStream != null) {
  75.                 config.load(configFile);
  76.                 defconfig = YamlConfiguration.loadConfiguration(defaultStream);
  77.                 for (String path : defconfig.getKeys(true)) {
  78.                     if (!defconfig.isConfigurationSection(path)) {
  79.                         if (!config.contains(path)) {
  80.                             missing.add(path);
  81.                         }
  82.                     }
  83.                 }
  84.             }
  85.         } catch (Exception ex) {}
  86.        
  87.         for (String path : missing) {
  88.             Object value = defconfig.get(path);
  89.             config.set(path, value);
  90.             config.addDefault(path, value);
  91.         }
  92.        
  93.         try {
  94.             config.save(configFile);
  95.         } catch (Exception ex) {}
  96.     }
  97. }
RAW Paste Data