Search in sources :

Example 1 with SoliniaNPC

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

the class SoliniaNPCFactory method CreateNPCCopy.

public static ISoliniaNPC CreateNPCCopy(int npcid, String name, boolean operatorCreated) throws CoreStateInitException {
    ISoliniaNPC sourcenpc = StateManager.getInstance().getConfigurationManager().getNPC(npcid);
    SoliniaNPC npc = new SoliniaNPC();
    npc.setId(StateManager.getInstance().getConfigurationManager().getNextNPCId());
    npc.setName(name);
    npc.setBoss(sourcenpc.isBoss());
    npc.setRaidboss(sourcenpc.isRaidboss());
    npc.setRaidheroic(sourcenpc.isRaidheroic());
    npc.setAC(sourcenpc.getAC());
    npc.setAccuracyRating(sourcenpc.getAccuracyRating());
    npc.setAvoidanceRating(sourcenpc.getAvoidanceRating());
    npc.setAnimal(sourcenpc.isAnimal());
    npc.setUndead(sourcenpc.isUndead());
    npc.setClassid(sourcenpc.getClassid());
    npc.setRaceid(sourcenpc.getRaceid());
    npc.setHeroic(sourcenpc.isHeroic());
    npc.setBurning(sourcenpc.isBurning());
    npc.setChestitem(sourcenpc.getChestitem());
    npc.setClassid(sourcenpc.getClassid());
    npc.setCustomhead(sourcenpc.isCustomhead());
    npc.setCustomheaddata(sourcenpc.getCustomheaddata());
    npc.setDisguisetype(sourcenpc.getDisguisetype());
    npc.setFactionid(sourcenpc.getFactionid());
    npc.setFeetitem(sourcenpc.getFeetitem());
    npc.setGuard(sourcenpc.isGuard());
    npc.setHanditem(sourcenpc.getHanditem());
    npc.setHeaditem(sourcenpc.getHeaditem());
    npc.setInvisible(sourcenpc.isInvisible());
    npc.setKillTriggerText(sourcenpc.getKillTriggerText());
    npc.setLegsitem(sourcenpc.getLegsitem());
    npc.setLevel(sourcenpc.getLevel());
    npc.setLoottableid(sourcenpc.getLoottableid());
    npc.setMctype(sourcenpc.getMctype());
    npc.setMerchantid(sourcenpc.getMerchantid());
    npc.setOffhanditem(sourcenpc.getOffhanditem());
    npc.setRaceid(sourcenpc.getRaceid());
    npc.setRandomchatTriggerText(sourcenpc.getRandomchatTriggerText());
    npc.setRandomSpawn(sourcenpc.isRandomSpawn());
    npc.setRoamer(sourcenpc.isRoamer());
    npc.setUpsidedown(sourcenpc.isUpsidedown());
    npc.setUsedisguise(sourcenpc.isUsedisguise());
    npc.setOperatorCreated(operatorCreated);
    return StateManager.getInstance().getConfigurationManager().addNPC(npc);
}
Also used : ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) SoliniaNPC(com.solinia.solinia.Models.SoliniaNPC)

Example 2 with SoliniaNPC

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

the class SoliniaNPCFactory method CreateNPC.

public static ISoliniaNPC CreateNPC(String name, int level, int factionid, boolean operatorCreated) throws CoreStateInitException {
    SoliniaNPC npc = new SoliniaNPC();
    npc.setId(StateManager.getInstance().getConfigurationManager().getNextNPCId());
    npc.setName(name);
    npc.setLevel(level);
    npc.setFactionid(factionid);
    npc.setOperatorCreated(operatorCreated);
    return StateManager.getInstance().getConfigurationManager().addNPC(npc);
}
Also used : ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) SoliniaNPC(com.solinia.solinia.Models.SoliniaNPC)

Example 3 with SoliniaNPC

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

the class JsonNPCRepository method commit.

@Override
public void commit() {
    // TODO Auto-generated method stub
    GsonBuilder gsonbuilder = new GsonBuilder();
    // gsonbuilder.setPrettyPrinting();
    gsonbuilder.registerTypeAdapterFactory(new ISoliniaNPCEventHandlerTypeAdapterFactory(SoliniaNPCEventHandler.class));
    Gson gson = gsonbuilder.create();
    String jsonOutput = gson.toJson(NPCs.values(), new TypeToken<List<SoliniaNPC>>() {
    }.getType());
    try {
        File file = new File(filePath);
        if (!file.exists())
            file.createNewFile();
        FileOutputStream fileOut = new FileOutputStream(file);
        OutputStreamWriter outWriter = new OutputStreamWriter(fileOut);
        outWriter.append(jsonOutput);
        outWriter.close();
        fileOut.close();
        System.out.println("Commited " + NPCs.size() + " NPCs");
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ISoliniaNPCEventHandler(com.solinia.solinia.Interfaces.ISoliniaNPCEventHandler) SoliniaNPCEventHandler(com.solinia.solinia.Models.SoliniaNPCEventHandler) GsonBuilder(com.google.gson.GsonBuilder) TypeToken(com.google.gson.reflect.TypeToken) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) SoliniaNPC(com.solinia.solinia.Models.SoliniaNPC) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) Gson(com.google.gson.Gson) ISoliniaNPCEventHandlerTypeAdapterFactory(com.solinia.solinia.Factories.ISoliniaNPCEventHandlerTypeAdapterFactory) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) File(java.io.File)

Aggregations

ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)3 SoliniaNPC (com.solinia.solinia.Models.SoliniaNPC)3 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 TypeToken (com.google.gson.reflect.TypeToken)1 ISoliniaNPCEventHandlerTypeAdapterFactory (com.solinia.solinia.Factories.ISoliniaNPCEventHandlerTypeAdapterFactory)1 ISoliniaNPCEventHandler (com.solinia.solinia.Interfaces.ISoliniaNPCEventHandler)1 SoliniaNPCEventHandler (com.solinia.solinia.Models.SoliniaNPCEventHandler)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1