Search in sources :

Example 6 with SoliniaCraft

use of com.solinia.solinia.Models.SoliniaCraft in project solinia3-core by mixxit.

the class JsonCraftRepository method reload.

@Override
public void reload() {
    List<SoliniaCraft> file = new ArrayList<SoliniaCraft>();
    try {
        Gson gson = new Gson();
        BufferedReader br = new BufferedReader(new FileReader(filePath));
        file = gson.fromJson(br, new TypeToken<List<SoliniaCraft>>() {
        }.getType());
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    Crafts.clear();
    for (SoliniaCraft i : file) {
        Crafts.put(i.getId(), i);
    }
    System.out.println("Reloaded " + Crafts.size() + " Crafts");
}
Also used : ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) SoliniaCraft(com.solinia.solinia.Models.SoliniaCraft) Gson(com.google.gson.Gson) FileReader(java.io.FileReader) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

SoliniaCraft (com.solinia.solinia.Models.SoliniaCraft)6 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)3 Player (org.bukkit.entity.Player)3 Gson (com.google.gson.Gson)2 SoliniaCraftCreationException (com.solinia.solinia.Exceptions.SoliniaCraftCreationException)2 FileNotFoundException (java.io.FileNotFoundException)2 CommandSender (org.bukkit.command.CommandSender)2 GsonBuilder (com.google.gson.GsonBuilder)1 TypeToken (com.google.gson.reflect.TypeToken)1 InvalidCraftSettingException (com.solinia.solinia.Exceptions.InvalidCraftSettingException)1 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)1 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)1 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)1 SoliniaPlayerSkill (com.solinia.solinia.Models.SoliniaPlayerSkill)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1