Exemple #1
0
 public void saveSettings() {
   try {
     Gson gson = new GsonBuilder().setPrettyPrinting().create();
     String data = gson.toJson(this);
     OutputStream os =
         new FileOutputStream(new File(plugin.getDataFolder() + File.separator + menuFile));
     os.write(data.getBytes());
     os.close();
   } catch (Exception e) {
     plugin.getServer().getLogger().warning("Error while saving settings!");
     e.printStackTrace();
   }
 }
Exemple #2
0
 public void refreshSubServersGUI(boolean clear) {
   if (subServersInventory == null)
     subServersInventory = plugin.getServer().createInventory(null, InventoryType.CHEST);
   if (clear) subServersInventory.clear();
   for (MenuItem srv : subServers) {
     ItemStack is = getItemStackByMenuItem(srv);
     subServersInventory.setItem(srv.getSlot(), is);
   }
 }
Exemple #3
0
 public static Settings loadSettings(ServerMenu _plugin) {
   plugin = _plugin;
   Settings settings;
   Gson gson = new Gson();
   try (FileReader reader =
       new FileReader(new File(plugin.getDataFolder() + File.separator + menuFile))) {
     settings = gson.fromJson(reader, Settings.class);
     reader.close();
     return settings;
   } catch (Exception e) {
     settings = new Settings();
     settings.resetSettingsToDefault();
     settings.saveSettings();
     return settings;
   }
 }