Java Code Examples for org.bukkit.entity.Player#sendBlockChange()
The following examples show how to use
org.bukkit.entity.Player#sendBlockChange() .
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: StructureUtil.java From Civs with GNU General Public License v3.0 | 7 votes |
public static void removeBoundingBox(UUID uuid) { Player player = Bukkit.getPlayer(uuid); if (player == null || !player.isOnline()) { return; } StructureUtil.BoundingBox boundingBox = boundingBoxes.get(uuid); if (boundingBox == null) { return; } Map<Location, Color> locations = boundingBoxes.get(uuid).getLocations(); if (locations == null) { return; } if (!ConfigManager.getInstance().isUseParticleBoundingBoxes()) { for (Location location : locations.keySet()) { if (!Util.isLocationWithinSightOfPlayer(location)) { continue; } player.sendBlockChange(location, Material.AIR.createBlockData()); } } boundingBoxes.remove(uuid); }
Example 2
Source File: StructureUtil.java From Civs with GNU General Public License v3.0 | 6 votes |
private static void setGlass(World world, double x, double y, double z, Map<Location, Color> boundingBox, Material mat, Player player) { if (y < 1 || y >= world.getMaxHeight()) { return; } Location location = new Location(world, x, y, z); Block block = location.getBlock(); if (block.getType() != Material.AIR || block.getRelative(BlockFace.DOWN).getType() == Material.GRASS_PATH || block.getRelative(BlockFace.DOWN).getType() == Material.FARMLAND) { return; } Color color = Color.RED; if (mat == Material.BLUE_STAINED_GLASS) { color = Color.BLUE; } else if (mat == Material.LIME_STAINED_GLASS) { color = Color.GREEN; } BlockData blockData = mat.createBlockData(); boundingBox.put(new Location(world, x, y, z), color); player.sendBlockChange(location, blockData); }
Example 3
Source File: RegionSelectionImpl.java From NovaGuilds with GNU General Public License v3.0 | 6 votes |
/** * Sends a rectangle * * @param player target player */ @SuppressWarnings("deprecation") protected void sendRectangle(Player player) { if(player == null || getCorner(0) == null || getCorner(1) == null) { return; } for(Block block : RegionUtils.getBorderBlocks(getCorner(0), getCorner(1))) { if(borderMaterial == null) { RegionUtils.resetBlock(player, block); continue; } player.sendBlockChange(block.getLocation(), borderMaterial, borderData); blockList.add(block); } }
Example 4
Source File: RegionSelectionImpl.java From NovaGuilds with GNU General Public License v3.0 | 6 votes |
/** * Sends block change to a player * * @param player target player * @param location block location * @param material material * @param data durability byte */ @SuppressWarnings("deprecation") protected void highlightCorner(Player player, Location location, Material material, Byte data) { if(player == null || location == null) { return; } location = location.clone(); Block highest1 = player.getWorld().getHighestBlockAt(location.getBlockX(), location.getBlockZ()); location.setY(highest1.getY() - (highest1.getType() == Material.SNOW ? 0 : 1)); if(material == null) { material = location.getBlock().getType(); data = location.getBlock().getData(); } player.sendBlockChange(location, material, data); getBlocks().add(location.getBlock()); }
Example 5
Source File: Signs.java From TabooLib with MIT License | 5 votes |
/** * 向玩家发送虚拟牌子,并返回编辑内容 * * @param player 玩家 * @param origin 原始内容 * @param catcher 编辑内容 */ public static void fakeSign(Player player, String[] origin, Consumer<String[]> catcher) { Validate.isTrue(Version.isAfter(Version.v1_8), "Unsupported Version: " + Version.getCurrentVersion()); Location location = player.getLocation(); location.setY(0); try { player.sendBlockChange(location, Materials.OAK_WALL_SIGN.parseMaterial(), (byte) 0); player.sendSignChange(location, format(origin)); } catch (Throwable t) { t.printStackTrace(); } NMS.handle().openSignEditor(player, location.getBlock()); signs.add(new Data(player.getName(), catcher, location.getBlockX(), location.getBlockY(), location.getBlockZ())); }
Example 6
Source File: ForceField.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") private void sendForceField(Player player, Location location) { if(VersionUtil.getMinorVersion() >= 13) { player.sendBlockChange(location, getForceFieldMaterial().createBlockData()); return; } player.sendBlockChange(location, getForceFieldMaterial(), (byte) getForceFieldMaterialData()); }
Example 7
Source File: ForceField.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") private void resetBlock(Player player, Location location) { Block block = location.getBlock(); if(VersionUtil.getMinorVersion() >= 13) { player.sendBlockChange(location, block.getBlockData()); return; } player.sendBlockChange(location, block.getType(), block.getData()); }
Example 8
Source File: RegionUtils.java From NovaGuilds with GNU General Public License v3.0 | 5 votes |
/** * Sends a true block to a player * * @param player target player * @param block block */ @SuppressWarnings("deprecation") public static void resetBlock(Player player, Block block) { if(player == null || block == null) { return; } Material material = block.getWorld().getBlockAt(block.getLocation()).getType(); byte data = block.getWorld().getBlockAt(block.getLocation()).getData(); player.sendBlockChange(block.getLocation(), material, data); }
Example 9
Source File: Players.java From helper with MIT License | 4 votes |
@SuppressWarnings("deprecation") public static void sendBlockChange(Player player, Location loc, Material type, int data) { player.sendBlockChange(loc, type, (byte) data); }
Example 10
Source File: ItemManager.java From civcraft with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") public static void sendBlockChange(Player player, Location loc, int type, int data) { player.sendBlockChange(loc, type, (byte)data); }
Example 11
Source File: RegionVisualizer.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") @Override public void run() { boolean finish = !player.isOnline(); if (player.isOnline()) { Player bukkitPlayer = player.getBukkitPlayer(); // Stores the current wool data byte data; if (currentRepetitions % 2 == 0) { data = LIME_WOOL_DATA; } else { data = RED_WOOL_DATA; } finish = currentRepetitions > REPETITIONS; Iterator<BlockVector> iterator = region.iterator(); while (iterator.hasNext()) { BlockVector vec = iterator.next(); int x = vec.getBlockX(); int y = vec.getBlockY(); int z = vec.getBlockZ(); Location location = new Location(world, x, y, z); if (!finish) { bukkitPlayer.sendBlockChange(location, Material.WOOL, data); } else { Block block = world.getBlockAt(location); Material material = block.getType(); data = block.getData(); bukkitPlayer.sendBlockChange(location, material, data); } } } if (finish) { BukkitTask task = tasks.get(player); task.cancel(); tasks.remove(player); } ++currentRepetitions; }