SHARE
TWEET

Main Class

a guest May 21st, 2020 12 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package classes.classes;
  2.  
  3. import classes.classes.ClassInterfaces.BlackSmith;
  4. import classes.classes.ClassInterfaces.Warrior;
  5. import classes.classes.Commands.Menu;
  6. import classes.classes.Commands.SpawnDragon;
  7. import classes.classes.Events.DragonEvent;
  8. import org.bukkit.Bukkit;
  9. import org.bukkit.ChatColor;
  10. import org.bukkit.Material;
  11. import org.bukkit.configuration.file.FileConfiguration;
  12. import org.bukkit.configuration.file.FileConfigurationOptions;
  13. import org.bukkit.configuration.file.YamlConfiguration;
  14. import org.bukkit.entity.Player;
  15. import org.bukkit.event.EventHandler;
  16. import org.bukkit.event.Listener;
  17. import org.bukkit.event.entity.PlayerDeathEvent;
  18. import org.bukkit.event.inventory.InventoryClickEvent;
  19. import org.bukkit.event.player.AsyncPlayerChatEvent;
  20. import org.bukkit.event.player.PlayerJoinEvent;
  21. import org.bukkit.inventory.ItemStack;
  22. import org.bukkit.inventory.ShapedRecipe;
  23. import org.bukkit.inventory.meta.ItemMeta;
  24. import org.bukkit.plugin.java.JavaPlugin;
  25.  
  26. import java.io.File;
  27. import java.io.IOException;
  28. import java.util.ArrayList;
  29.  
  30. public final class Classes extends JavaPlugin implements Listener {
  31.     public static Classes instance;
  32.     public static void setInstance(Classes instance){
  33.         Classes.instance = instance;
  34.     }
  35.     public static Classes getInstance(){
  36.         return instance;
  37.     }
  38.  
  39.     @Override
  40.     public void onEnable() {
  41.         setInstance(this);
  42.         getServer().getPluginManager().registerEvents(new Menu(), this);
  43.         getServer().getPluginManager().registerEvents(this, this);
  44.         getServer().getPluginManager().registerEvents(new Warrior(), this);
  45.         getServer().getPluginManager().registerEvents(new SpawnDragon(), this);
  46.         getServer().getPluginManager().registerEvents(new DragonEvent(), this);
  47.         getServer().getPluginManager().registerEvents(new BlackSmith(), this);
  48.         getCommand("getartifacts").setExecutor(new Artifacts());
  49.         getCommand("classes").setExecutor(new Menu());
  50.         getCommand("spawndragon").setExecutor(new SpawnDragon());
  51.         File specialcrafting = new File(getDataFolder() + File.separator + "specialcraftingtables.yml");
  52.         if(!specialcrafting.exists()){
  53.             try {
  54.                 specialcrafting.createNewFile();
  55.                 FileConfiguration special = YamlConfiguration.loadConfiguration(specialcrafting);
  56.                 special.set("PlacedCraftings", new ArrayList<String>());
  57.                 special.save(specialcrafting);
  58.             } catch (IOException e) {
  59.                 e.printStackTrace();
  60.             }
  61.  
  62.         }
  63.         // Plugin startup logic
  64.  
  65.     }
  66.  
  67.     @EventHandler
  68.     public void onPlayerJoin(PlayerJoinEvent e) throws IOException {
  69.         File file = new File(getDataFolder() + File.separator + e.getPlayer().getUniqueId() + ".yml");
  70.         if(!file.exists()){
  71.             file.createNewFile();
  72.             FileConfiguration edit = YamlConfiguration.loadConfiguration(file);
  73.             edit.set("HasWarrior", false);
  74.             edit.set("HasMage", false);
  75.             edit.set("HasFisher", false);
  76.             edit.set("HasGuardian", false);
  77.             edit.set("HasSales", false);
  78.             edit.set("HasLumber", false);
  79.             edit.set("HasArcher", false);
  80.             edit.set("HasScientist", false);
  81.             edit.set("CurrentClass", "none");
  82.             edit.save(file);
  83.  
  84.         }
  85.     }
  86.  
  87.     public static File getFile(Player player){
  88.         File file = new File("plugins/Classes/" + File.separator + player.getUniqueId() + ".yml");
  89.         return file;
  90.     }
  91.  
  92.     @EventHandler
  93.     public void onTag(AsyncPlayerChatEvent e){
  94.         if(e.getPlayer() != null){
  95.             Player player = e.getPlayer();
  96.             File file = getFile(player);
  97.             FileConfiguration edit = YamlConfiguration.loadConfiguration(file);
  98.             if(edit.get("CurrentClass") != "none"){
  99.                 if(edit.get("CurrentClass").equals("Warrior")){
  100.                     player.setDisplayName(player.getDisplayName() + ChatColor.translateAlternateColorCodes('&', " &7[&3Warrior&7]&f"));
  101.                 }
  102.             }
  103.         }
  104.     }
  105.  
  106.     @EventHandler
  107.     public void onDeath(PlayerDeathEvent e){
  108.         e.setDeathMessage(null);
  109.     }
  110.  
  111.  
  112.  
  113.  
  114.     @Override
  115.     public void onDisable() {
  116.         // Plugin shutdown logic
  117.     }
  118. }
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