world edit api load schematic to player

Discussion in 'Plugin Development' started by GeekWithAChick, Apr 30, 2015.

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

    GeekWithAChick

    I'm creating a plugin where players can load a schematic from my plugin folder. Yes I know the command "//schem load" but it doesn't suit my needs.

    This is what I have:

    Code:
    LocalSession session = we.getWorldEdit().getSession(player.getName());
    LocalWorld world = new  LocalWorld();
    CuboidClipboard clipboard = session.getClipboard();
    File schem = new File("plugins/MyPlugin/test.schematic");
    ClipboardCommands command = new ClipboardCommands(we.getWorldEdit());
    int max = 999999;
    EditSession editSession = new EditSession(world, max);
    
    
    clipboard.loadSchematic(schem);
    session.setClipboard(clipboard);
    
    command.load(null, session, (LocalPlayer) player, editSession);
    I just want to create a command to load a schematic from another folder
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    GeekWithAChick

    The issue is that I don't know how to do it. I can't test my code because I get an error that the player can be cast to a local player.
     
  4. Offline

    mythbusterma

    @GeekWithAChick

    Perhaps you should think about fixing errors that already exist before introducing more into the code?
     
  5. Offline

    GeekWithAChick

    @mythbusterma

    Code:
    LocalSession session = we.getWorldEdit().getSession(player.getName());
    CuboidClipboard clipboard = session.getClipboard();
    File schem = new File("plugins/CloudCrafter/schematics/test.schematic");
    ClipboardCommands command = new ClipboardCommands(we.getWorldEdit());
    LocalPlayer lp = we.wrapPlayer((Player) player);
    
    BukkitWorld BWf = new BukkitWorld(player.getWorld());
    EditSession es = new EditSession(BWf, 2000000);
    
    clipboard.loadSchematic(schem);
    session.setClipboard(clipboard);
    
    command.load(null, session, lp, es);
    So this code is error free and sends me this message:

    [​IMG]

    Maybe I'm not using the correct code.
     
  6. Offline

    mythbusterma

    @GeekWithAChick

    Whatever command you're using belongs to WorldEdit, so it's not being handled by your plugin.
     
  7. Offline

    GeekWithAChick

    @mythbusterma

    Are you talking about the ClipboardCommands? Because I got it from their API
     
  8. Offline

    mythbusterma

    @GeekWithAChick

    ....I'm talking about your plugin not handling the command. Where do you think that message came from?
     
  9. Offline

    GeekWithAChick

Thread Status:
Not open for further replies.

Share This Page