Solved Running a Builder using the CitizensAPI

Discussion in 'Plugin Help/Development/Requests' started by eyesniper2, Feb 7, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    eyesniper2

    I tried doing that using this code here:
    Code:
            NPCRegistry registry = CitizensAPI.getNPCRegistry();
            NPC npc = registry.getById(id.getSingle(evt).intValue());
            npc.addTrait(BuilderTrait.class);
            BuilderTrait bt = npc.getTrait(BuilderTrait.class);
            File f = new File("plugins/Builder/schematics/");
            try {
                bt.schematic = MCEditSchematicFormat.load(f, schematic.getSingle(evt).trim().replace("\"", ""));
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            bt.TryBuild(player.getSingle(evt));
    
    I did this referencing the latest Builder build off of the citizens build server with this github repo as reference.

    Just also a small note, in this code the
    Code:
    id.getSingle(evt).intValue()
    just retruns the citizens id number, the
    Code:
    schematic.getSingle(evt).trim().replace("\"", "")
    just gets the file name and the
    Code:
    player.getSingle(evt)
    gets the player that is required to run the TryBuild method.

    Through all this the server will crash with this crash log. So I think its safe to say I'm doing something wrong.
     
  2. Offline

    timtower Moderator Moderator

    Moved to its own thread due to 1.8
     
  3. Offline

    fullwall

  4. Offline

    eyesniper2

    @fullwall Awesome, just adding in this list worked!
    Code:
    bt.oncancel = null;
    bt.oncomplete = null;
    bt.onStart = null;
    bt.ContinueLoc =null;
    bt.IgnoreAir = false;
    bt.IgnoreLiquid = false;
    bt.Excavate = false;
    bt.GroupByLayer = true;
    bt.BuildYLayers = 1;
    bt.BuildPatternXY = net.jrbudda.builder.BuilderTrait.BuildPatternsXZ.spiral;
    
    I guess it was just missing those conditions. Thank you for the help!
     
Thread Status:
Not open for further replies.

Share This Page