Java Code Examples for com.sk89q.worldedit.bukkit.BukkitAdapter#adapt()
The following examples show how to use
com.sk89q.worldedit.bukkit.BukkitAdapter#adapt() .
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: RadiationCommandHandler.java From CraftserveRadiation with Apache License 2.0 | 6 votes |
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 2
Source File: WorldEditUtils.java From WorldGuardExtraFlagsPlugin with MIT License | 6 votes |
public static org.bukkit.Location toLocation(Object location) { if (WorldEditUtils.legacyToLocationMethod != null) { try { return (org.bukkit.Location)WorldEditUtils.legacyToLocationMethod.invoke(null, location); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException("Unsupported WorldEdit version"); } } else { return BukkitAdapter.adapt((Location)location); } }
Example 3
Source File: HookWorldGuard_V7_0.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
public static boolean allowsMobCombat(Location location) { WorldGuard api = getAPI(); WorldGuardPlatform platform = api.getPlatform(); RegionContainer container = platform.getRegionContainer(); RegionQuery query = container.createQuery(); com.sk89q.worldedit.util.Location weLocation = BukkitAdapter.adapt(location); if(MOB_COMBAT_FLAG instanceof StateFlag) { StateFlag mobCombatFlag = (StateFlag) MOB_COMBAT_FLAG; State state = query.queryState(weLocation, null, mobCombatFlag); return (state != State.DENY); } return true; }
Example 4
Source File: HookWorldGuard_V7_0.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
public static boolean allowsTagging(Location location) { WorldGuard api = getAPI(); WorldGuardPlatform platform = api.getPlatform(); RegionContainer container = platform.getRegionContainer(); RegionQuery query = container.createQuery(); if(NO_TAGGING_FLAG instanceof BooleanFlag) { BooleanFlag noTaggingFlag = (BooleanFlag) NO_TAGGING_FLAG; com.sk89q.worldedit.util.Location weLocation = BukkitAdapter.adapt(location); Boolean value = query.queryValue(weLocation, null, noTaggingFlag); return (value == null || !value); } return true; }
Example 5
Source File: Radiation.java From CraftserveRadiation with Apache License 2.0 | 5 votes |
@Override public boolean test(Player player, RegionContainer regionContainer) { Location location = BukkitAdapter.adapt(player.getLocation()); location = location.setY(Math.max(0, Math.min(255, location.getY()))); ApplicableRegionSet regions = regionContainer.createQuery().getApplicableRegions(location); Boolean value = regions.queryValue(WorldGuardPlugin.inst().wrapPlayer(player), this.flag); return value != null && value; }
Example 6
Source File: SchematicHandler13.java From UhcCore with GNU General Public License v3.0 | 5 votes |
public static ArrayList<Integer> pasteSchematic(Location loc, String path) throws Exception{ Bukkit.getLogger().info("[UhcCore] Pasting "+path); File schematic = new File(path); World world = BukkitAdapter.adapt(loc.getWorld()); ClipboardFormat format = ClipboardFormats.findByFile(schematic); ClipboardReader reader = format.getReader(new FileInputStream(schematic)); Clipboard clipboard = reader.read(); EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1); enableWatchdog(editSession); Operation operation = new ClipboardHolder(clipboard) .createPaste(editSession) .to(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ())) .ignoreAirBlocks(false) .build(); Operations.complete(operation); editSession.flushSession(); ArrayList<Integer> dimensions = new ArrayList<>(); dimensions.add(clipboard.getDimensions().getY()); dimensions.add(clipboard.getDimensions().getX()); dimensions.add(clipboard.getDimensions().getZ()); Bukkit.getLogger().info("[UhcCore] Successfully pasted '"+path+"' at "+loc.getBlockX()+" "+loc.getBlockY()+" "+loc.getBlockZ()); return dimensions; }
Example 7
Source File: HookWorldGuard_V7_0.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
public static boolean allowsPVP(Location location) { WorldGuard api = getAPI(); WorldGuardPlatform platform = api.getPlatform(); RegionContainer container = platform.getRegionContainer(); RegionQuery query = container.createQuery(); com.sk89q.worldedit.util.Location weLocation = BukkitAdapter.adapt(location); StateFlag.State state = query.queryState(weLocation, null, Flags.PVP); return (state != StateFlag.State.DENY); }
Example 8
Source File: WorldEditHandler7_beta_1.java From AreaShop with GNU General Public License v3.0 | 5 votes |
@Override public WorldEditSelection getPlayerSelection(Player player) { try { Region region = pluginInterface.getWorldEdit().getSession(player).getSelection(BukkitAdapter.adapt(player.getWorld())); return new WorldEditSelection( player.getWorld(), BukkitAdapter.adapt(player.getWorld(), region.getMinimumPoint()), BukkitAdapter.adapt(player.getWorld(), region.getMaximumPoint()) ); } catch (IncompleteRegionException e) { return null; } }
Example 9
Source File: FastAsyncWorldEditHandler.java From AreaShop with GNU General Public License v3.0 | 5 votes |
@Override public WorldEditSelection getPlayerSelection(Player player) { try { Region region = pluginInterface.getWorldEdit().getSession(player).getSelection(BukkitAdapter.adapt(player.getWorld())); return new WorldEditSelection( player.getWorld(), BukkitAdapter.adapt(player.getWorld(), region.getMinimumPoint()), BukkitAdapter.adapt(player.getWorld(), region.getMaximumPoint()) ); } catch (IncompleteRegionException e) { return null; } }
Example 10
Source File: WorldEditHandler7_beta_4.java From AreaShop with GNU General Public License v3.0 | 5 votes |
@Override public WorldEditSelection getPlayerSelection(Player player) { try { Region region = pluginInterface.getWorldEdit().getSession(player).getSelection(BukkitAdapter.adapt(player.getWorld())); return new WorldEditSelection( player.getWorld(), BukkitAdapter.adapt(player.getWorld(), region.getMinimumPoint()), BukkitAdapter.adapt(player.getWorld(), region.getMaximumPoint()) ); } catch (IncompleteRegionException e) { return null; } }
Example 11
Source File: Spigot_v1_16_R1.java From worldedit-adapters with GNU Lesser General Public License v3.0 | 5 votes |
@Override public BaseBlock getBlock(Location location) { checkNotNull(location); CraftWorld craftWorld = ((CraftWorld) location.getWorld()); int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); final WorldServer handle = craftWorld.getHandle(); Chunk chunk = handle.getChunkAt(x >> 4, z >> 4); final BlockPosition blockPos = new BlockPosition(x, y, z); final IBlockData blockData = chunk.getType(blockPos); int internalId = Block.getCombinedId(blockData); BlockState state = BlockStateIdAccess.getBlockStateById(internalId); if (state == null) { org.bukkit.block.Block bukkitBlock = location.getBlock(); state = BukkitAdapter.adapt(bukkitBlock.getBlockData()); } // Read the NBT data TileEntity te = chunk.a(blockPos, Chunk.EnumTileEntityState.CHECK); if (te != null) { NBTTagCompound tag = new NBTTagCompound(); readTileEntityIntoTag(te, tag); // Load data return state.toBaseBlock((CompoundTag) toNative(tag)); } return state.toBaseBlock(); }
Example 12
Source File: Spigot_v1_15_R2.java From worldedit-adapters with GNU Lesser General Public License v3.0 | 5 votes |
@Override public BaseBlock getBlock(Location location) { checkNotNull(location); CraftWorld craftWorld = ((CraftWorld) location.getWorld()); int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); final WorldServer handle = craftWorld.getHandle(); Chunk chunk = handle.getChunkAt(x >> 4, z >> 4); final BlockPosition blockPos = new BlockPosition(x, y, z); final IBlockData blockData = chunk.getType(blockPos); int internalId = Block.getCombinedId(blockData); BlockState state = BlockStateIdAccess.getBlockStateById(internalId); if (state == null) { org.bukkit.block.Block bukkitBlock = location.getBlock(); state = BukkitAdapter.adapt(bukkitBlock.getBlockData()); } // Read the NBT data TileEntity te = chunk.a(blockPos, Chunk.EnumTileEntityState.CHECK); if (te != null) { NBTTagCompound tag = new NBTTagCompound(); readTileEntityIntoTag(te, tag); // Load data return state.toBaseBlock((CompoundTag) toNative(tag)); } return state.toBaseBlock(); }
Example 13
Source File: Spigot_v1_14_R4.java From worldedit-adapters with GNU Lesser General Public License v3.0 | 5 votes |
@Override public BaseBlock getBlock(Location location) { checkNotNull(location); CraftWorld craftWorld = ((CraftWorld) location.getWorld()); int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); final WorldServer handle = craftWorld.getHandle(); Chunk chunk = handle.getChunkAt(x >> 4, z >> 4); final BlockPosition blockPos = new BlockPosition(x, y, z); final IBlockData blockData = chunk.getType(blockPos); int internalId = Block.getCombinedId(blockData); BlockState state = BlockStateIdAccess.getBlockStateById(internalId); if (state == null) { org.bukkit.block.Block bukkitBlock = location.getBlock(); state = BukkitAdapter.adapt(bukkitBlock.getBlockData()); } // Read the NBT data TileEntity te = chunk.a(blockPos, Chunk.EnumTileEntityState.CHECK); if (te != null) { NBTTagCompound tag = new NBTTagCompound(); readTileEntityIntoTag(te, tag); // Load data return state.toBaseBlock((CompoundTag) toNative(tag)); } return state.toBaseBlock(); }
Example 14
Source File: Spigot_v1_13_R2_2.java From worldedit-adapters with GNU Lesser General Public License v3.0 | 5 votes |
@Override public BaseBlock getBlock(Location location) { checkNotNull(location); CraftWorld craftWorld = ((CraftWorld) location.getWorld()); int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); final WorldServer handle = craftWorld.getHandle(); Chunk chunk = handle.getChunkAt(x >> 4, z >> 4); final IBlockData blockData = chunk.getBlockData(x, y, z); int internalId = Block.getCombinedId(blockData); BlockState state = BlockStateIdAccess.getBlockStateById(internalId); if (state == null) { org.bukkit.block.Block bukkitBlock = location.getBlock(); state = BukkitAdapter.adapt(bukkitBlock.getBlockData()); } // Read the NBT data TileEntity te = handle.getTileEntity(new BlockPosition(x, y, z)); if (te != null) { NBTTagCompound tag = new NBTTagCompound(); readTileEntityIntoTag(te, tag); // Load data return state.toBaseBlock((CompoundTag) toNative(tag)); } return state.toBaseBlock(); }
Example 15
Source File: WorldGuardIntegration.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
@Override public boolean canCreateShopHere(@NotNull Player player, @NotNull Location location) { LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); com.sk89q.worldedit.util.Location wgLoc = BukkitAdapter.adapt(location); boolean canBypass = WorldGuard.getInstance() .getPlatform() .getSessionManager() .hasBypass(localPlayer, BukkitAdapter.adapt(location.getWorld())); if (canBypass) { Util.debugLog( "Player " + player.getName() + " bypassing the protection checks, because player have bypass permission in WorldGuard"); return true; } RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); RegionQuery query = container.createQuery(); if (query.getApplicableRegions(wgLoc).getRegions().isEmpty()) { return !whiteList; } for (WorldGuardFlags flag : createFlags) { switch (flag) { case BUILD: if (query.queryState(wgLoc, localPlayer, Flags.BUILD) == StateFlag.State.DENY) { return false; } break; case FLAG: if (query.queryState(wgLoc, localPlayer, this.createFlag) == StateFlag.State.DENY) { return false; } break; case CHEST_ACCESS: if (query.queryState(wgLoc, localPlayer, Flags.CHEST_ACCESS) == StateFlag.State.DENY) { return false; } break; case INTERACT: if (query.queryState(wgLoc, localPlayer, Flags.INTERACT) == StateFlag.State.DENY) { return false; } break; } } return true; }
Example 16
Source File: WorldGuardIntegration.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
@Override public boolean canTradeShopHere(@NotNull Player player, @NotNull Location location) { LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); com.sk89q.worldedit.util.Location wgLoc = BukkitAdapter.adapt(location); boolean canBypass = WorldGuard.getInstance() .getPlatform() .getSessionManager() .hasBypass(localPlayer, BukkitAdapter.adapt(location.getWorld())); if (canBypass) { Util.debugLog( "Player " + player.getName() + " bypassing the protection checks, because player have bypass permission in WorldGuard"); return true; } RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); RegionQuery query = container.createQuery(); if (query.getApplicableRegions(wgLoc).getRegions().isEmpty()) { return !whiteList; } for (WorldGuardFlags flag : tradeFlags) { switch (flag) { case BUILD: if (!query.testState(wgLoc, localPlayer, Flags.BUILD)) { return false; } break; case FLAG: if (!query.testState(wgLoc, localPlayer, this.tradeFlag)) { return false; } break; case CHEST_ACCESS: if (!query.testState(wgLoc, localPlayer, Flags.CHEST_ACCESS)) { return false; } break; case INTERACT: if (!query.testState(wgLoc, localPlayer, Flags.INTERACT)) { return false; } break; } } return true; }