public boolean actPrimary( ServerInterface server, LocalConfiguration config, LocalPlayer player, LocalSession session, WorldVector clicked) { BlockBag bag = session.getBlockBag(player); LocalWorld world = clicked.getWorld(); EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player); try { editSession.setBlock(clicked, targetBlock); } catch (MaxChangedBlocksException e) { } finally { if (bag != null) { bag.flushChanges(); } session.remember(editSession); } return true; }
public boolean actPrimary( ServerInterface server, LocalConfiguration config, LocalPlayer player, LocalSession session, WorldVector clicked) { EditSession editSession = session.createEditSession(player); try { boolean successful = false; for (int i = 0; i < 10; i++) { if (gen.generate(editSession, clicked.add(0, 1, 0))) { successful = true; break; } } if (!successful) { player.printError("A tree can't go there."); } } catch (MaxChangedBlocksException e) { player.printError("Max. blocks changed reached."); } finally { session.remember(editSession); } return true; }
/** * Remember an edit session. * * @param player * @param editSession */ public void remember(Player player, EditSession editSession) { LocalPlayer wePlayer = wrapPlayer(player); LocalSession session = controller.getSession(wePlayer); session.remember(editSession); editSession.flushQueue(); controller.flushBlockBag(wePlayer, editSession); }
@Override public boolean act( ServerInterface server, LocalConfiguration config, LocalPlayer player, LocalSession session, WorldVector clicked) { LocalWorld world = clicked.getWorld(); EditSession editSession = new EditSession(server, world, session.getBlockChangeLimit()); try { editSession.makePineTree(clicked.add(0, 1, 0)); } catch (MaxChangedBlocksException e) { player.printError("Max blocks change limit reached."); } finally { session.remember(editSession); } return true; }