Search in sources :

Example 1 with ISoliniaPatch

use of com.solinia.solinia.Interfaces.ISoliniaPatch in project solinia3-core by mixxit.

the class Utils method patchNpcClasses.

private static void patchNpcClasses() {
    try {
        for (ISoliniaPatch patch : StateManager.getInstance().getConfigurationManager().getPatches()) {
            // Lookup npc and edit class
            String npcName = patch.getClasses().get(0);
            int rawClassId = Integer.parseInt(patch.getClasses().get(1));
            int convertedClass = convertRawClassToClass(rawClassId);
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getPetNPCByName(npcName);
            if (npc == null)
                continue;
            npc.setClassid(convertedClass);
            System.out.println("Updated NPC: " + npc.getName() + " to class " + convertedClass);
        }
    } catch (CoreStateInitException e) {
    // skip
    }
}
Also used : ISoliniaPatch(com.solinia.solinia.Interfaces.ISoliniaPatch) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC)

Example 2 with ISoliniaPatch

use of com.solinia.solinia.Interfaces.ISoliniaPatch in project solinia3-core by mixxit.

the class JsonPatchRepository method reload.

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

Aggregations

ISoliniaPatch (com.solinia.solinia.Interfaces.ISoliniaPatch)2 Gson (com.google.gson.Gson)1 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)1 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)1 BufferedReader (java.io.BufferedReader)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1