Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.16 KB | None | 0 0
  1. package me.patrickfreed.iCotestConfig;
  2.  
  3. import com.iConomy.iConomy;
  4. import com.nijiko.permissions.PermissionHandler;
  5. import com.nijikokun.bukkit.Permissions.Permissions;
  6. import java.io.File;
  7. import java.io.IOException;
  8. import java.util.HashMap;
  9.  
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.Server;
  12. import org.bukkit.event.Event.Priority;
  13. import org.bukkit.event.Event;
  14. import org.bukkit.plugin.java.JavaPlugin;
  15. import org.bukkit.plugin.PluginManager;
  16. import org.bukkit.plugin.Plugin;
  17. import org.bukkit.util.config.Configuration;
  18.  
  19. public class iConomyPunga extends JavaPlugin {
  20.  
  21.     private static PluginListener PluginListener = null;
  22.     private static iConomy iConomy = null;
  23.     private static Server Server = null;
  24.     public static HashMap<String, String> pconfig = new HashMap<String, String>();
  25.     public static PermissionHandler Permissions;
  26.     public Configuration config;
  27.     ConfigClass conf;
  28.    
  29.     private final iConomyPungaEntityListener entityListener = new iConomyPungaEntityListener(this);
  30.  
  31.    
  32.     public void onEnable() {
  33.      File yml = new File(getDataFolder()+"/config.yml");
  34.       this.config = getConfiguration();
  35.     if (!yml.exists()) {
  36.         new File(getDataFolder().toString()).mkdir();
  37.     try {
  38.     yml.createNewFile();
  39.     }
  40.    
  41.     catch (IOException ex) {
  42.     System.out.println("cannot create file "+yml.getPath());
  43.     }
  44.        }  
  45.    
  46.     conf.setMode(this);
  47.     conf.setMsgs(this);
  48.     conf.setPs(this);
  49.     conf.setAs(this);
  50.     conf.setStatics(this);
  51.     config.save();
  52.    
  53.      getConfiguration();
  54.      Server = getServer();
  55.      PluginManager pm = getServer().getPluginManager();
  56.         PluginListener = new PluginListener();
  57.         pm.registerEvent(Event.Type.PLUGIN_ENABLE, PluginListener, Priority.Monitor, this);
  58.         if (!(new File(getDataFolder(), "config.yml")).exists()) {
  59.          defaultConfig();
  60.         }  
  61.         loadConfig();
  62.         pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Event.Priority.Normal, this);
  63.         pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Event.Priority.Normal, this);
  64.         setupPermissions();
  65.     }
  66.    
  67.     public void onDisable() {
  68.      System.out.println("");
  69.     }
  70.    
  71.     private void loadConfig() {
  72.     }
  73.  
  74.     private void defaultConfig() {
  75.     }
  76.    
  77.     private void setupPermissions() {
  78.      Plugin permissions = this.getServer().getPluginManager().getPlugin("Permissions");
  79.  
  80.         if (Permissions == null) {
  81.          if (permissions != null) {
  82.              Permissions = ((Permissions)permissions).getHandler();
  83.             } else {
  84.              System.out.println("Permission system not detected, defaulting to OP");
  85.             }
  86.         }
  87.     }
  88.  
  89.     public static boolean hasPermissions(Player p, String s) {
  90.         if (Permissions != null) {
  91.             return Permissions.has(p, s);
  92.         } else {
  93.             return p.isOp();
  94.         }
  95.     }
  96.    
  97.     public static Server getBukkitServer() {
  98.         return Server;
  99.     }
  100.  
  101.     public static iConomy getiConomy() {
  102.         return iConomy;
  103.     }
  104.    
  105.     public static boolean setiConomy(iConomy plugin) {
  106.         if (iConomy == null) {
  107.             iConomy = plugin;
  108.         } else {
  109.             return false;
  110.         }
  111.         return true;
  112.     }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement