Guest User

Untitled

a guest
Dec 6th, 2023
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.70 KB | None | 0 0
  1. @Override
  2.     public void onEnable() {
  3.  
  4.         DataFile classDataFile = new DataFile();
  5.  
  6.         plugin = this;
  7.  
  8.         // DATA FILES
  9.         createFiles();
  10.         DataFile.setupDataFile();
  11.         DataFile.getDataFile().options().copyDefaults(true);
  12.         DataFile.saveDataFile();
  13.         DataFile.getDataFile().createSection("callsigns");
  14.  
  15.         // RESTORE CALLSIGNS IN "data.yml" TO HASHMAP
  16.         for (String key : DataFile.getDataFile().getConfigurationSection("callsigns").getKeys(false)) {
  17.             UUID uuid = UUID.fromString(key);
  18.             ConfigurationSection dataFileSec = DataFile.getDataFile().getConfigurationSection("callsigns." + key);
  19.             String cs = dataFileSec.getString("cs");
  20.  
  21.             classDataFile.getCallsignMap().put(uuid, cs);
  22.         }
  23.  
  24.         // Luck Perms Init
  25.         RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
  26.         if (provider != null) {
  27.             luckPerms = provider.getProvider();
  28.         }
  29.  
  30.         // LISTENER REGISTER
  31.         this.getServer().getPluginManager().registerEvents(new LocalChatListener(luckPerms), this);
  32.  
  33.         // COMMAND REGISTER
  34.         this.getCommand("global").setExecutor(new GlobalCommand(luckPerms));
  35.         this.getCommand("global").setTabCompleter(new TabComplete());
  36.  
  37.         this.getCommand("advert").setExecutor(new AdCommand(luckPerms));
  38.         this.getCommand("advert").setTabCompleter(new TabComplete());
  39.  
  40.         this.getCommand("news").setExecutor(new NewsCommand(luckPerms));
  41.         this.getCommand("news").setTabCompleter(new TabComplete());
  42.  
  43.         this.getCommand("blackmarket").setExecutor(new BlackmarketCommand(luckPerms));
  44.         this.getCommand("blackmarket").setTabCompleter(new TabComplete());
  45.  
  46.         this.getCommand("callsign").setExecutor(new CallsignCommand(luckPerms));
  47.         this.getCommand("callsign").setTabCompleter(new CallsignTabComplete());
  48.  
  49.         // ENABLED
  50.         log.info("CityRP-Chat v1.4 Enabled. Created by aDrew1");
  51.     }
  52.  
  53.     @Override
  54.     public void onDisable() {
  55.  
  56.         // SAVE CALLSIGNS IN HASHMAP TO "data.yml"
  57.         DataFile classDataFile = new DataFile();
  58.  
  59.         for (UUID uuid : classDataFile.getCallsignMap().keySet()) {
  60.             String key = uuid.toString();
  61.             String cs = classDataFile.getCallsignMap().get(uuid);
  62.  
  63.             DataFile.getDataFile().createSection("callsigns." + key);
  64.             ConfigurationSection configSec = DataFile.getDataFile().getConfigurationSection("callsigns." + key);
  65.             configSec.set("cs", cs);
  66.  
  67.             DataFile.saveDataFile();
  68.  
  69.         }
  70.  
  71.         log.info("CityRP-Chat v1.4 Disabled. Created by aDrew1");
  72.     }
Advertisement
Add Comment
Please, Sign In to add comment