com.sk89q.worldedit.world.World Java Examples

The following examples show how to use com.sk89q.worldedit.world.World. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RollbackDatabase.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public RollbackDatabase(final World world) throws SQLException, ClassNotFoundException {
        this.prefix = "";
        this.worldName = Fawe.imp().getWorldName(world);
        this.world = world;
        this.dbLocation = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + "summary.db");
        connection = openConnection();
        CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `" + prefix + "edits` (`player` BLOB(16) NOT NULL,`id` INT NOT NULL,`x1` INT NOT NULL,`y1` INT NOT NULL,`z1` INT NOT NULL,`x2` INT NOT NULL,`y2` INT NOT NULL,`z2` INT NOT NULL,`time` INT NOT NULL, PRIMARY KEY (player, id))";
        INSERT_EDIT = "INSERT OR REPLACE INTO `" + prefix + "edits` (`player`,`id`,`x1`,`y1`,`z1`,`x2`,`y2`,`z2`,`time`) VALUES(?,?,?,?,?,?,?,?,?)";
        PURGE = "DELETE FROM `" + prefix + "edits` WHERE `time`<?";
//        GET_EDITS_POINT = "SELECT `player`,`id` FROM `" + prefix + "edits` WHERE `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?";
        GET_EDITS = "SELECT `player`,`id` FROM `" + prefix + "edits` WHERE `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=? AND `time`>? ORDER BY `time` DESC, `id` DESC";
        GET_EDITS_USER = "SELECT `player`,`id` FROM `" + prefix + "edits` WHERE `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=? AND `time`>? AND `player`=? ORDER BY `time` DESC, `id` DESC";
        GET_EDITS_ASC = "SELECT `player`,`id` FROM `" + prefix + "edits` WHERE `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=? AND `time`>? ORDER BY `time` ASC, `id` ASC";
        GET_EDITS_USER_ASC = "SELECT `player`,`id` FROM `" + prefix + "edits` WHERE `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=? AND `time`>? AND `player`=? ORDER BY `time` ASC, `id` ASC";
        DELETE_EDITS_USER = "DELETE FROM `" + prefix + "edits` WHERE `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=? AND `time`>? AND `player`=?";
        DELETE_EDIT_USER = "DELETE FROM `" + prefix + "edits` WHERE `player`=? AND `id`=?";
        init();
        purge((int) TimeUnit.DAYS.toMillis(Settings.IMP.HISTORY.DELETE_AFTER_DAYS));
    }
 
Example #2
Source File: FawePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public PlayerProxy createProxy() {
    Player player = getPlayer();
    World world = getWorldForEditing();

    PlatformManager platformManager = WorldEdit.getInstance().getPlatformManager();

    Player permActor = platformManager.queryCapability(Capability.PERMISSIONS).matchPlayer(player);
    if (permActor == null) {
        permActor = player;
    }

    Player cuiActor = platformManager.queryCapability(Capability.WORLDEDIT_CUI).matchPlayer(player);
    if (cuiActor == null) {
        cuiActor = player;
    }

    PlayerProxy proxy = new PlayerProxy(player, permActor, cuiActor, world);
    if (world instanceof VirtualWorld) {
        proxy.setOffset(Vector.ZERO.subtract(((VirtualWorld) world).getOrigin()));
    }
    return proxy;
}
 
Example #3
Source File: WorldEditBinding.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets an {@link BaseBlock} from a {@link ArgumentStack}.
 *
 * @param context the context
 * @return a pattern
 * @throws ParameterException on error
 * @throws WorldEditException on error
 */
@BindingMatch(type = BaseBlock.class,
        behavior = BindingBehavior.CONSUMES,
        consumedCount = 1)
public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, WorldEditException {
    Actor actor = context.getContext().getLocals().get(Actor.class);
    ParserContext parserContext = new ParserContext();
    parserContext.setActor(context.getContext().getLocals().get(Actor.class));
    if (actor instanceof Entity) {
        Extent extent = ((Entity) actor).getExtent();
        if (extent instanceof World) {
            parserContext.setWorld((World) extent);
        }
    }
    parserContext.setSession(worldEdit.getSessionManager().get(actor));
    try {
        return worldEdit.getBlockFactory().parseFromInput(context.next(), parserContext);
    } catch (NoMatchException e) {
        throw new ParameterException(e.getMessage(), e);
    }
}
 
Example #4
Source File: WorldGuardSevenCommunicator.java    From WorldGuardExtraFlagsPlugin with MIT License 6 votes vote down vote up
@Override
public boolean doUnloadChunkFlagCheck(org.bukkit.World world, Chunk chunk) 
{
	for (ProtectedRegion region : this.getRegionContainer().get(world).getApplicableRegions(new ProtectedCuboidRegion("UnloadChunkFlagTester", BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16), BlockVector3.at(chunk.getX() * 16 + 15, 256, chunk.getZ() * 16 + 15))))
	{
		if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY)
		{
			if (WorldGuardSevenCommunicator.supportsForceLoad)
			{
				chunk.setForceLoaded(true);
				chunk.load(true);
				
				return true;
			}
			
			return false;
		}
	}
	
	return true;
}
 
Example #5
Source File: LocalSession.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
private void loadHistoryNegativeIndex(UUID uuid, World world) {
    if (!Settings.IMP.HISTORY.USE_DISK) {
        return;
    }
    File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid + File.separator + "index");
    if (file.exists()) {
        try {
            FaweInputStream is = new FaweInputStream(new FileInputStream(file));
            historyNegativeIndex = Math.min(Math.max(0, is.readInt()), history.size());
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        historyNegativeIndex = 0;
    }
}
 
Example #6
Source File: WorldEditApiProvider.java    From GriefPrevention with MIT License 6 votes vote down vote up
public void revertVisuals(Player player, GPPlayerData playerData, UUID claimUniqueId) {
    final LocalSession session = this.getLocalSession(player.getName());
    if (session == null || !session.hasCUISupport()) {
        return;
    }
    final World world = this.getWorld(player.getWorld());
    final RegionSelector region = session.getRegionSelector(world);
    final GPActor actor = this.getOrCreateActor(player);
    region.clear();
    session.dispatchCUISelection(actor);
    if (claimUniqueId != null) {
        actor.dispatchCUIEvent(new MultiSelectionClearEvent(claimUniqueId));
    } else {
        actor.dispatchCUIEvent(new MultiSelectionClearEvent());
    }
}
 
Example #7
Source File: DefaultFloorRegenerator.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void regenerate(Floor floor, EditSession session, RegenerationCause cause) {
	Clipboard clipboard = floor.getClipboard();
	
	Region region = clipboard.getRegion();
	World world = region.getWorld();
	WorldData data = world.getWorldData();
	
	ClipboardHolder holder = new ClipboardHolder(clipboard, data);
	
	Operation pasteOperation = holder.createPaste(session, data)
			.to(region.getMinimumPoint())
			.ignoreAirBlocks(true)
			.build();
	
	try {
		Operations.complete(pasteOperation);
	} catch (WorldEditException e) {
		throw new RuntimeException(e);
	}
}
 
Example #8
Source File: RadiationCommandHandler.java    From CraftserveRadiation with Apache License 2.0 6 votes vote down vote up
private boolean define(Player player, RegionContainer container, String regionId, int radius) {
    Objects.requireNonNull(player, "player");
    Objects.requireNonNull(container, "container");
    Objects.requireNonNull(regionId, "regionId");

    World world = BukkitAdapter.adapt(player.getWorld());
    RegionManager regionManager = container.get(world);
    if (regionManager == null) {
        player.sendMessage(ChatColor.RED + "Sorry, region manager for world " + world.getName() + " is not currently accessible.");
        return false;
    }

    BlockVector3 origin = BukkitAdapter.asBlockVector(player.getLocation());
    this.define(regionManager, this.createCuboid(regionId, origin, radius));
    this.flagGlobal(regionManager, true);
    return true;
}
 
Example #9
Source File: SimpleClipboardFloor.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Deprecated
public void generate(EditSession session) {
	Region region = floorClipboard.getRegion();
	World world = region.getWorld();
	WorldData data = world.getWorldData();
	
	ClipboardHolder holder = new ClipboardHolder(floorClipboard, data);
	
	Operation pasteOperation = holder.createPaste(session, data)
			.to(region.getMinimumPoint())
			.ignoreAirBlocks(true)
			.build();
	
	try {
		Operations.complete(pasteOperation);
	} catch (WorldEditException e) {
		throw new RuntimeException(e);
	}
}
 
Example #10
Source File: FloodFillTool.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
    World world = (World) clicked.getExtent();

    int initialType = world.getBlockType(clicked.toVector());

    if (initialType == BlockID.AIR) {
        return true;
    }

    if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
        return true;
    }

    EditSession editSession = session.createEditSession(player);

    try {
        recurse(server, editSession, world, clicked.toVector().toBlockVector(),
                clicked.toVector(), range, initialType, new HashSet<BlockVector>());
    } catch (WorldEditException e) {
        throw new RuntimeException(e);
    }
    editSession.flushQueue();
    session.remember(editSession);
    return true;
}
 
Example #11
Source File: LocalSession.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param uuid
 * @param world
 * @return If any loading occured
 */
public boolean loadSessionHistoryFromDisk(UUID uuid, World world) {
    if (world == null || uuid == null) {
        return false;
    }
    if (Settings.IMP.HISTORY.USE_DISK) {
        MAX_HISTORY_SIZE = Integer.MAX_VALUE;
    }
    world = WorldWrapper.unwrap(world);
    if (!world.equals(currentWorld)) {
        this.uuid = uuid;
        // Save history
        saveHistoryNegativeIndex(uuid, currentWorld);
        history.clear();
        currentWorld = world;
        // Load history
        if (loadHistoryChangeSets(uuid, currentWorld)) {
            loadHistoryNegativeIndex(uuid, currentWorld);
            return true;
        }
        historyNegativeIndex = 0;
    }
    return false;
}
 
Example #12
Source File: WorldEditBinding.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets an {@link Mask} from a {@link ArgumentStack}.
 *
 * @param context the context
 * @return a pattern
 * @throws ParameterException on error
 * @throws WorldEditException on error
 */
@BindingMatch(type = Mask.class,
        behavior = BindingBehavior.CONSUMES,
        consumedCount = 1)
public Mask getMask(ArgumentStack context) throws ParameterException, WorldEditException {
    Actor actor = context.getContext().getLocals().get(Actor.class);
    ParserContext parserContext = new ParserContext();
    parserContext.setActor(context.getContext().getLocals().get(Actor.class));
    if (actor instanceof Entity) {
        Extent extent = ((Entity) actor).getExtent();
        if (extent instanceof World) {
            parserContext.setWorld((World) extent);
        }
    }
    parserContext.setSession(worldEdit.getSessionManager().get(actor));
    try {
        return worldEdit.getMaskFactory().parseFromInput(context.next(), parserContext);
    } catch (NoMatchException e) {
        throw new ParameterException(e.getMessage(), e);
    }
}
 
Example #13
Source File: AbstractPlayerActor.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) {
    final Vector pos = getBlockIn();
    final int x = pos.getBlockX();
    final int initialY = Math.max(0, pos.getBlockY());
    int y = Math.max(0, pos.getBlockY() + 1);
    final int z = pos.getBlockZ();
    final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
    final World world = getPosition().getWorld();

    while (y <= world.getMaxY() + 2) {
        if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
            break; // Hit something
        } else if (y > maxY + 1) {
            break;
        } else if (y == maxY + 1) {
            floatAt(x, y - 1, z, alwaysGlass);
            return true;
        }

        ++y;
    }

    return false;
}
 
Example #14
Source File: PlotTrimFilter.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public PlotTrimFilter(World world, long fileDuration, long inhabitedTicks, long chunkInactivity) {
    super(fileDuration, inhabitedTicks, chunkInactivity);
    Fawe.debug("Initializing Plot trim...");

    String worldName = Fawe.imp().getWorldName(world);
    PlotArea area = PS.get().getPlotAreaByString(worldName);
    IndependentPlotGenerator gen = area.getGenerator();
    if (!(area instanceof HybridPlotWorld) || !(gen instanceof HybridGen)) {
        throw new UnsupportedOperationException("Trim does not support non hybrid plot worlds");
    }
    this.hg = (HybridGen) gen;
    this.hpw = (HybridPlotWorld) area;
    if (hpw.PLOT_SCHEMATIC || hpw.MAIN_BLOCK.length != 1 || hpw.TOP_BLOCK.length != 1) {
        throw new UnsupportedOperationException("WIP - will implement later");
    }
    this.occupiedRegions = new LongHashSet();
    this.unoccupiedChunks = new LongHashSet();

    this.reference = calculateReference();

    Fawe.debug(" - calculating claims");
    this.calculateClaimedArea();
}
 
Example #15
Source File: DBHandler.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public RollbackDatabase getDatabase(World world) {
    String worldName = Fawe.imp().getWorldName(world);
    RollbackDatabase database = databases.get(worldName);
    if (database != null) {
        return database;
    }
    try {
        database = new RollbackDatabase(world);
        databases.put(worldName, database);
        return database;
    } catch (Throwable e) {
        Fawe.debug("============ NO JDBC DRIVER! ============");
        Fawe.debug("TODO: Bundle driver with FAWE (or disable database)");
        Fawe.debug("=========================================");
        e.printStackTrace();
        Fawe.debug("=========================================");
        return null;
    }
}
 
Example #16
Source File: CFICommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        aliases = {"schem", "schematic", "schems", "schematics", "addschems"},
        usage = "[url] <mask> <file|folder|url> <rarity> <distance> <rotate=true>",
        desc = "Populate schematics",
        help = "Populate a schematic on the terrain\n" +
                " - Change the mask (e.g. angle mask) to only place the schematic in specific locations.\n" +
                " - The rarity is a value between 0 and 100.\n" +
                " - The distance is the spacing between each schematic"
)
@CommandPermissions("worldedit.anvil.cfi")
public void schem(FawePlayer fp, @Optional BufferedImage imageMask, Mask mask, String schematic, int rarity, int distance, boolean rotate) throws ParameterException, IOException, WorldEditException {
    HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();

    World world = fp.getWorld();
    WorldData wd = world.getWorldData();
    MultiClipboardHolder multi = ClipboardFormat.SCHEMATIC.loadAllFromInput(fp.getPlayer(), wd, schematic, true);
    if (multi == null) {
        return;
    }
    if (imageMask == null) {
        gen.addSchems(mask, wd, multi.getHolders(), rarity, distance, rotate);
    } else {
        gen.addSchems(imageMask, mask, wd, multi.getHolders(), rarity, distance, rotate);
    }
    msg("Added schematics!").send(fp);
    populate(fp);
}
 
Example #17
Source File: FaweAPI.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Fix the lighting in a selection<br>
 * - First removes all lighting, then relights
 * - Relights in parallel (if enabled) for best performance<br>
 * - Also resends chunks<br>
 *
 * @param world
 * @param selection (assumes cuboid)
 * @return
 */
public static int fixLighting(World world, Region selection, @Nullable FaweQueue queue, final FaweQueue.RelightMode mode) {
    final Vector bot = selection.getMinimumPoint();
    final Vector top = selection.getMaximumPoint();

    final int minX = bot.getBlockX() >> 4;
    final int minZ = bot.getBlockZ() >> 4;

    final int maxX = top.getBlockX() >> 4;
    final int maxZ = top.getBlockZ() >> 4;

    int count = 0;
    if (queue == null) {
        queue = SetQueue.IMP.getNewQueue(world, true, false);
    }
    // Remove existing lighting first
    if (queue instanceof NMSMappedFaweQueue) {
        final NMSMappedFaweQueue nmsQueue = (NMSMappedFaweQueue) queue;
        NMSRelighter relighter = new NMSRelighter(nmsQueue);
        for (int x = minX; x <= maxX; x++) {
            for (int z = minZ; z <= maxZ; z++) {
                relighter.addChunk(x, z, null, 65535);
                count++;
            }
        }
        if (mode != FaweQueue.RelightMode.NONE) {
            boolean sky = nmsQueue.hasSky();
            if (sky) {
                relighter.fixSkyLighting();
            }
            relighter.fixBlockLighting();
        } else {
            relighter.removeLighting();
        }
        relighter.sendChunks();
    }
    return count;
}
 
Example #18
Source File: LocalSession.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Construct a new edit session.
 *
 * @param player the player
 * @return an edit session
 */
@SuppressWarnings("deprecation")
public EditSession createEditSession(Player player) {
    checkNotNull(player);

    BlockBag blockBag = getBlockBag(player);

    World world = player.getWorld();
    boolean isPlayer = player.isPlayer();
    EditSessionBuilder builder = new EditSessionBuilder(world);
    if (player.isPlayer()) builder.player(FawePlayer.wrap(player));
    builder.blockBag(blockBag);
    builder.fastmode(fastMode);

    EditSession editSession = builder.build();

    Request.request().setEditSession(editSession);
    if (mask != null) {
        editSession.setMask(mask);
    }
    if (sourceMask != null) {
        editSession.setSourceMask(sourceMask);
    }
    if (transform != null) {
        editSession.addTransform(transform);
    }
    return editSession;
}
 
Example #19
Source File: WorldEditApiProvider.java    From GriefPrevention with MIT License 5 votes vote down vote up
public RegionSelector getRegionSelector(Player player) {
    final LocalSession session = getLocalSession(player.getName());
    if (session == null) {
        return null;
    }

    World world = session.getSelectionWorld();
    if (world == null) {
        world = this.getWorld(player.getWorld());
    }
    return session.getRegionSelector(world);
}
 
Example #20
Source File: FawePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
     * Get the World the player is editing in (may not match the world they are in)<br/>
     * - e.g. If they are editing a CFI world.<br/>
     * @return Editing world
     */
    public World getWorldForEditing() {
        VirtualWorld virtual = getSession().getVirtualWorld();
        if (virtual != null) {
            return virtual;
        }
//        CFICommands.CFISettings cfi = getMeta("CFISettings");
//        if (cfi != null && cfi.hasGenerator() && cfi.getGenerator().hasPacketViewer()) {
//            return cfi.getGenerator();
//        }
        return WorldEdit.getInstance().getPlatformManager().getWorldForEditing(getWorld());
    }
 
Example #21
Source File: FawePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Load all the undo EditSession's from disk for a world <br>
 * - Usually already called when necessary
 *
 * @param world
 */
public void loadSessionsFromDisk(final World world) {
    if (world == null) {
        return;
    }
    getSession().loadSessionHistoryFromDisk(getUUID(), world);
}
 
Example #22
Source File: MappedFaweQueue.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public MappedFaweQueue(final World world, IFaweQueueMap map) {
    this.weWorld = world;
    if (world != null) this.world = Fawe.imp().getWorldName(world);
    if (map == null) {
        map = getSettings().PREVENT_CRASHES ? new WeakFaweQueueMap(this) : new DefaultFaweQueueMap(this);
    }
    this.map = map;
}
 
Example #23
Source File: PlayerProxy.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public PlayerProxy(Player basePlayer, Actor permActor, Actor cuiActor, World world) {
    Preconditions.checkNotNull(basePlayer);
    Preconditions.checkNotNull(permActor);
    Preconditions.checkNotNull(cuiActor);
    Preconditions.checkNotNull(world);
    this.basePlayer = basePlayer;
    this.permActor = permActor;
    this.cuiActor = cuiActor;
    this.world = world;
}
 
Example #24
Source File: NukkitPlatform.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<? extends com.sk89q.worldedit.world.World> getWorlds() {
    Collection<Level> levels = mod.getServer().getLevels().values();
    List<com.sk89q.worldedit.world.World> ret = new ArrayList<>(levels.size());
    for (Level level : levels) {
        ret.add(new NukkitWorld(level));
    }
    return ret;
}
 
Example #25
Source File: NavigationCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        aliases = {"jumpto", "j"},
        usage = "[world,x,y,z]",
        desc = "Teleport to a location" +
        		"Flags:\n" + 
        		"  -f forces the specified position to be used",
        flags = "f",
        min = 0,
        max = 1
)
@CommandPermissions("worldedit.navigation.jumpto.command")
public void jumpTo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    WorldVector pos;
    if (args.argsLength() == 1) {
        String arg = args.getString(0);
        String[] split = arg.split(",");
        World world = FaweAPI.getWorld(split[0]);
        if (world != null && split.length == 4 && MathMan.isInteger(split[1]) && MathMan.isInteger(split[2]) && MathMan.isInteger(split[3])) {
            pos = new WorldVector((LocalWorld) world, Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]));
        } else {
            BBC.SELECTOR_INVALID_COORDINATES.send(player, args.getString(0));
            return;
        }
    } else {
        pos = player.getSolidBlockTrace(300);
    }
    if (pos != null) {
        if(args.hasFlag('f')) player.setPosition(pos); else player.findFreePosition(pos);
        BBC.POOF.send(player);
    } else {
        BBC.NO_BLOCK.send(player);
    }
}
 
Example #26
Source File: CuboidRegion.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Construct a new instance of this cuboid using two corners of the cuboid.
 *
 * @param world the world
 * @param pos1  the first position
 * @param pos2  the second position
 */
public CuboidRegion(World world, Vector pos1, Vector pos2) {
    super(world);
    checkNotNull(pos1);
    checkNotNull(pos2);
    this.pos1 = pos1;
    this.pos2 = pos2;
    if (pos1 instanceof WorldVector) {
        setWorld(((WorldVector) pos1).getWorld());
    } else if (pos2 instanceof WorldVector) {
        setWorld(((WorldVector) pos2).getWorld());
    }
    recalculate();
}
 
Example #27
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getWorldName(World world) {
    if (world instanceof WorldWrapper) {
        return getWorldName(((WorldWrapper) world).getParent());
    }
    else if (world instanceof EditSession) {
        return getWorldName(((EditSession) world).getWorld());
    }
    return getWorldName(((ForgeWorld) world).getWorld());

}
 
Example #28
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public String getWorldName(net.minecraft.world.World w) {
    Integer[] ids = DimensionManager.getIDs();
    WorldServer[] worlds = DimensionManager.getWorlds();
    for (int i = 0; i < ids.length; i++) {
        if (worlds[i] == w) {
            return w.getWorldInfo().getWorldName() + ";" + ids[i];
        }
    }
    return w.getWorldInfo().getWorldName() + ";" + w.provider.dimensionId;
}
 
Example #29
Source File: CylinderRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new selector.
 *
 * @param world the world
 * @param center the center
 * @param radius the radius
 * @param minY the minimum Y
 * @param maxY the maximum Y
 */
public CylinderRegionSelector(@Nullable World world, Vector2D center, Vector2D radius, int minY, int maxY) {
    this(world);

    region.setCenter(center);
    region.setRadius(radius);

    region.setMinimumY(Math.min(minY, maxY));
    region.setMaximumY(Math.max(minY, maxY));
}
 
Example #30
Source File: NMSMappedFaweQueue.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public NMSMappedFaweQueue(World world, IFaweQueueMap map) {
    super(world, map);
    this.maxY = world.getMaxY();
}