SHARE
TWEET

Untitled

a guest Apr 20th, 2019 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.shadowolfyt.zander;
  2.  
  3. import com.shadowolfyt.zander.commands.*;
  4. import com.shadowolfyt.zander.events.*;
  5. import com.shadowolfyt.zander.guis.*;
  6. import net.md_5.bungee.api.ChatColor;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.configuration.file.FileConfiguration;
  9. import org.bukkit.plugin.PluginDescriptionFile;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11.  
  12. import java.sql.DriverManager;
  13. import java.sql.SQLException;
  14.  
  15. public class ZanderMain extends JavaPlugin {
  16.     public static ZanderMain plugin;
  17.     public FileConfiguration configuration;
  18.  
  19.     @Override
  20.     public void onEnable() {
  21.         plugin = this;
  22.         establishConnection();
  23.         loadConfiguration();
  24.  
  25.         PluginDescriptionFile pdf = plugin.getDescription();
  26.         getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "\n\nZander has been enabled.\nRunning Version " + pdf.getVersion() + "\nGitHub Repository: https://github.com/shadowolfyt/zander\nCreated by shadowolfyt\n\n");
  27.  
  28.         // Events Registry
  29.         getServer().getPluginManager().registerEvents(new PlayerOnJoin(this), this);
  30.         getServer().getPluginManager().registerEvents(new PlayerOnQuit(this), this);
  31.         getServer().getPluginManager().registerEvents(new ServerListPing(this), this);
  32.         getServer().getPluginManager().registerEvents(new PlayerDeath(this), this);
  33.         getServer().getPluginManager().registerEvents(new WhitelistListener(this), this);
  34.         getServer().getPluginManager().registerEvents(new WhitelistGUI(null), this);
  35.         getServer().getPluginManager().registerEvents(new WhitelistListGUI(null), this);
  36.         getServer().getPluginManager().registerEvents(new JukeboxGUI(this), this);
  37.         getServer().getPluginManager().registerEvents(new PunishGUI(this), this);
  38.         getServer().getPluginManager().registerEvents(new AnnouncementManager(this), this);
  39.  
  40.         // Command Registry
  41.         this.getCommand("heal").setExecutor((CommandExecutor)new heal());
  42.         this.getCommand("feed").setExecutor((CommandExecutor)new feed());
  43.         this.getCommand("starve").setExecutor((CommandExecutor)new starve());
  44.         this.getCommand("adventure").setExecutor((CommandExecutor)new adventure());
  45.         this.getCommand("creative").setExecutor((CommandExecutor)new creative());
  46.         this.getCommand("survival").setExecutor((CommandExecutor)new survival());
  47.         this.getCommand("spectator").setExecutor((CommandExecutor)new spectator());
  48.         this.getCommand("fly").setExecutor((CommandExecutor)new fly());
  49.         this.getCommand("profile").setExecutor((CommandExecutor)new profile(this));
  50.         this.getCommand("whitelist").setExecutor((CommandExecutor)new whitelist());
  51.         this.getCommand("jukebox").setExecutor((CommandExecutor)new jukebox());
  52.         this.getCommand("punish").setExecutor((CommandExecutor)new punish());
  53.     }
  54.  
  55.     public void establishConnection() {
  56.         try {
  57.             Class.forName("com.mysql.jdbc.Driver");
  58.             DriverManager.getConnection("jdbc:mysql://" + ZanderMain.plugin.getConfig().getString("database.ip") + ":" + ZanderMain.plugin.getConfig().getString("database.port") + "/" + ZanderMain.plugin.getConfig().getString("database.databasename"), ZanderMain.plugin.getConfig().getString("database.username"), ZanderMain.plugin.getConfig().getString("database.password"));
  59.             getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Database connection was successful.");
  60.         } catch (SQLException e) {
  61.             e.printStackTrace();
  62.             getServer().getConsoleSender().sendMessage(ChatColor.RED + "Database connection failed!");
  63.         } catch (ClassNotFoundException e) {
  64.             e.printStackTrace();
  65.             getServer().getConsoleSender().sendMessage(ChatColor.RED + "Database connection failed!");
  66.         }
  67.     }
  68.  
  69.     private void loadConfiguration() {
  70.         plugin.saveDefaultConfig();
  71.         plugin.reloadConfig();
  72.         plugin.saveConfig();
  73.     }
  74.  
  75.     @Override
  76.     public void onDisable() {
  77.         getServer().getConsoleSender().sendMessage(ChatColor.RED + "\n\nZander has been disabled.\n");
  78.         loadConfiguration();
  79.     }
  80. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top