public void onBlockBreak(BlockBreakEvent event) { Block blockBreaked = event.getBlock(); World world = blockBreaked.getWorld(); Player player = event.getPlayer(); // Sand/Gravel check when destroying a block if (world.getBlockTypeIdAt(blockBreaked.getX(), blockBreaked.getY() + 1, blockBreaked.getZ()) == 12 || world.getBlockTypeIdAt(blockBreaked.getX(), blockBreaked.getY() + 1, blockBreaked.getZ()) == 13) { if (WorldGuard.getWorldGuardState() == false) { player.sendMessage(ChatColor.DARK_RED + "The required plugin is not enabled."); event.setCancelled(true); return; } for (int i = blockBreaked.getY() - 1; i >= 1; i = i - 1) { int xx = blockBreaked.getX(); int yy = i; int zz = blockBreaked.getZ(); Location location = new Location(world, xx, yy, zz); if (world.getBlockTypeIdAt(xx, yy, zz) != 0) { return; } if (!WorldGuard.IsMemberOnLocation(player, location)) { player.sendMessage(ChatColor.RED + "A block on this one is going to fall into a region."); event.setCancelled(true); return; } } } }
// ================================================================================================ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) { if (plugin.posIsWithinColdBiome( event.getPlayer().getTargetBlock(null, 5).getX(), event.getPlayer().getTargetBlock(null, 5).getZ())) { Block targetedBlock = event .getPlayer() .getTargetBlock( null, 5); // first arg is transparent block, second arg is maxDistance to scan. 5 is // default reach for players. if ((null != targetedBlock) && (targetedBlock.getType() == Material.FIRE)) { // check if player is about to extinguish a registered fire with his hands or a tool (and // not a Block) if (plugin.blockIsRegisteredFire( targetedBlock.getX(), targetedBlock.getY(), targetedBlock.getZ())) { plugin.removeDiedFireFromFireList( targetedBlock.getX(), targetedBlock.getY(), targetedBlock.getZ()); if (Arctica.debug) { event.getPlayer().sendMessage(ChatColor.AQUA + "Feuerstelle aus Liste geloescht!"); } } } } } }
@EventHandler(priority = EventPriority.HIGH) public void onBlockPlace(BlockPlaceEvent event) { Block block = event.getBlock(); // Deny GameWorld Blocks GameWorld gworld = GameWorld.get(block.getWorld()); if (gworld != null) { if (!GamePlaceableBlock.canBuildHere( block, block.getFace(event.getBlockAgainst()), event.getItemInHand().getType(), gworld)) { // Workaround for a bug that would allow 3-Block-high jumping Location loc = event.getPlayer().getLocation(); if (loc.getY() > block.getY() + 1.0 && loc.getY() <= block.getY() + 1.5) { if (loc.getX() >= block.getX() - 0.3 && loc.getX() <= block.getX() + 1.3) { if (loc.getZ() >= block.getZ() - 0.3 && loc.getZ() <= block.getZ() + 1.3) { loc.setX(block.getX() + 0.5); loc.setY(block.getY()); loc.setZ(block.getZ() + 0.5); event.getPlayer().teleport(loc); } } } event.setCancelled(true); } } }
public static void generateFeast() { FeastUtils.clearCyl(FeastLoc.getLocation(), radius, 25, Material.GRASS); FeastLoc.setType(Material.ENCHANTMENT_TABLE); for (int x = -2; x <= 2; x++) { for (int z = -2; z <= 2; z++) { int worldx = (x + FeastLoc.getX()); int worldz = (z + FeastLoc.getZ()); if ((Math.abs(x) == Math.abs(z) && x != 0) || (Math.abs(x) == 2 && z == 0) || (Math.abs(z) == 2 && x == 0)) { generateFeastChest( new Location(FeastLoc.getLocation().getWorld(), worldx, FeastLoc.getY(), worldz)); } } } Bukkit.broadcastMessage( ChatColor.GOLD + "Spawned feast at " + FeastLoc.getX() + ", " + FeastLoc.getY() + ", " + FeastLoc.getZ() + "!"); }
private List<Sign> checkZoneForSigns(Block topper, Block bottomer) { Location looking = new Location(topper.getWorld(), 0, 0, 0); List<Sign> signs = new ArrayList<Sign>(); for (int x = topper.getX(); x <= bottomer.getX(); x++) { looking.setX(x); for (int y = bottomer.getY(); y <= topper.getY(); y++) { looking.setY(y); for (int z = topper.getZ(); z <= bottomer.getZ(); z++) { looking.setZ(z); this.plugin.log( Level.FINEST, "Looking for sign at " + this.plugin.getCore().getLocationManipulation().strCoordsRaw(looking)); Material isASign = topper.getWorld().getBlockAt(looking).getType(); if (isASign == Material.WALL_SIGN || isASign == Material.SIGN_POST) { this.plugin.log( Level.FINER, "WOO Found one! " + this.plugin.getCore().getLocationManipulation().strCoordsRaw(looking)); signs.add((Sign) topper.getWorld().getBlockAt(looking).getState()); } } } } return signs; }
public static boolean protectBlock(Block block, String name) { boolean protect = false; if (lwc != null) { lwc.getPhysicalDatabase() .registerProtection( block.getTypeId(), ProtectionTypes.PRIVATE, block.getWorld().getName(), name, "", block.getX(), block.getY(), block.getZ()); protect = true; TDebug.debug( DebugDetailLevel.EVERYTHING, block.getType().name() + " block protected for " + name + ". (" + block.getX() + ", " + block.getY() + ", " + block.getZ() + ")"); } return protect; }
@Override public void run() { if (path != null) { Node n = path.getNextNode(); Block b = null; float angle = yaw; float look = pitch; if (n != null) { if (last == null || path.checkPath(n, last, true)) { b = n.b; if (last != null) { angle = ((float) Math.toDegrees( Math.atan2(last.b.getX() - b.getX(), last.b.getZ() - b.getZ()))); look = (float) (Math.toDegrees(Math.asin(last.b.getY() - b.getY())) / 2); } setPositionRotation(b.getX() + 0.5, b.getY(), b.getZ() + 0.5, angle, look); timer.schedule(new movePath(), 300); } else { pathFindTo(end, maxIter); } } else if (last != null) { setPositionRotation(end.getX(), end.getY(), end.getZ(), end.getYaw(), end.getPitch()); } last = n; } }
@SuppressWarnings("deprecation") @Override public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) { net.minecraft.server.v1_7_R4.World w = ((CraftWorld) b.getWorld()).getHandle(); net.minecraft.server.v1_7_R4.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4); try { Field f = chunk.getClass().getDeclaredField("sections"); f.setAccessible(true); ChunkSection[] sections = (ChunkSection[]) f.get(chunk); ChunkSection chunksection = sections[b.getY() >> 4]; if (chunksection == null) { chunksection = sections[b.getY() >> 4] = new ChunkSection(b.getY() >> 4 << 4, !chunk.world.worldProvider.f); } net.minecraft.server.v1_7_R4.Block mb = net.minecraft.server.v1_7_R4.Block.getById(blockId); chunksection.setTypeId(b.getX() & 15, b.getY() & 15, b.getZ() & 15, mb); chunksection.setData(b.getX() & 15, b.getY() & 15, b.getZ() & 15, data); if (applyPhysics) { w.update(b.getX(), b.getY(), b.getZ(), mb); } } catch (Exception e) { // Bukkit.getLogger().info("Error"); b.setTypeIdAndData(blockId, data, applyPhysics); } }
public void armSwing(Player player) { if (cannons.containsKey(player.getName().toString())) { LoicTargetBlock blox = new LoicTargetBlock(player); Block block = blox.getTargetBlock(); if (block == null) return; getServer() .broadcastMessage( ChatColor.YELLOW + "ATTENTION : " + ChatColor.BLUE + "Ion Cannon Target Locked."); getServer() .broadcastMessage( ChatColor.RED + "WARNING : " + ChatColor.BLUE + "Ion Cannon Firing..."); int size = ((Integer) cannons.get(player.getName())).intValue(); log.info( "[" + name + "] IonCannon fired by: '" + player.getName().toString() + "' with size: " + size); cannons.remove(player.getName()); int beamType = 46; int borderType = 57; for (int i = 0; i < 128; i++) { circleMidpoint(block.getX(), block.getZ(), size, i, borderType, player); circleMidpoint(block.getX(), block.getZ(), size - 1, i, beamType, player); } circleMidpoint(block.getX(), block.getZ(), size, 0, 7, player); cylinderModpoint(block.getX(), block.getZ(), size + 1, 0, 7, player); player.getWorld().getBlockAt(block.getX(), 127, block.getZ()).setTypeId(51); } }
@Override public Vector[] getBlockHitbox(org.bukkit.block.Block block) { net.minecraft.server.v1_7_R3.World w = ((CraftWorld) block.getWorld()).getHandle(); net.minecraft.server.v1_7_R3.Block b = w.getType(block.getX(), block.getY(), block.getZ()); b.updateShape(w, block.getX(), block.getY(), block.getZ()); return new Vector[] { new Vector(block.getX() + b.x(), block.getY() + b.z(), block.getZ() + b.B()), new Vector(block.getX() + b.y(), block.getY() + b.A(), block.getZ() + b.C()) }; }
/* * Called when a block is destroyed from burning. */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockBurn(BlockBurnEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (cfg.activityHaltToggle) { event.setCancelled(true); return; } if (wcfg.disableFireSpread) { event.setCancelled(true); return; } if (wcfg.fireSpreadDisableToggle) { Block block = event.getBlock(); event.setCancelled(true); checkAndDestroyAround( block.getWorld(), block.getX(), block.getY(), block.getZ(), BlockID.FIRE); return; } if (wcfg.disableFireSpreadBlocks.size() > 0) { Block block = event.getBlock(); if (wcfg.disableFireSpreadBlocks.contains(block.getTypeId())) { event.setCancelled(true); checkAndDestroyAround( block.getWorld(), block.getX(), block.getY(), block.getZ(), BlockID.FIRE); return; } } if (wcfg.isChestProtected(event.getBlock())) { event.setCancelled(true); return; } if (wcfg.useRegions) { Block block = event.getBlock(); int x = block.getX(); int y = block.getY(); int z = block.getZ(); Vector pt = toVector(block); RegionManager mgr = plugin.getGlobalRegionManager().get(block.getWorld()); ApplicableRegionSet set = mgr.getApplicableRegions(pt); if (!set.allows(DefaultFlag.FIRE_SPREAD)) { checkAndDestroyAround(block.getWorld(), x, y, z, BlockID.FIRE); event.setCancelled(true); return; } } }
/** * Constructs a Portal for the portal at the passed in keyblock. * * @param b The keyblock for the portal. It should be of type Material.PORTAL, otherwise this * portal will never get entered by the player. */ public Portal(Block b) { keyBlock = b; this.facingNorth = b.getWorld().getBlockAt(b.getX(), b.getY(), b.getZ() - 1).getType().equals(Material.PORTAL) || b.getWorld() .getBlockAt(b.getX(), b.getY(), b.getZ() + 1) .getType() .equals(Material.PORTAL); counterpart = null; }
public CellUnderAttack(Towny plugin, String nameOfFlagOwner, Block flagBaseBlock) { super(flagBaseBlock.getLocation()); this.plugin = plugin; this.nameOfFlagOwner = nameOfFlagOwner; this.flagBaseBlock = flagBaseBlock; this.flagColorId = 0; this.thread = -1; World world = flagBaseBlock.getWorld(); this.flagBlock = world.getBlockAt(flagBaseBlock.getX(), flagBaseBlock.getY() + 1, flagBaseBlock.getZ()); this.flagLightBlock = world.getBlockAt(flagBaseBlock.getX(), flagBaseBlock.getY() + 2, flagBaseBlock.getZ()); }
public void onPlayerMove(PlayerMoveEvent event) { Block to = event.getTo().getBlock(); Block from = event.getFrom().getBlock(); if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) return; Player p = event.getPlayer(); TeamMember m = plugin.getBattlefieldManager().getPlayer(p); for (Battlefield field : plugin.getBattlefieldManager().getFields()) { BFRegion r = field.getRegion(); int check = r.checkMovement(p, to, from); if (check < 0) { if (m == null) return; if (field.isActive()) { event.setTo(plugin.getLastLocation(p)); Format.sendMessage(p, "Cannot leave battlefield during a match!"); } else { Format.sendMessage( p, "Leaving the battlefield '" + ChatColor.WHITE + field.getName() + ChatColor.GRAY + "'."); field.removePlayer(m); r.setPlayerState(p, false); } return; } else if (check > 0) { if (field.isActive()) { event.setTo(plugin.getLastLocation(p)); Format.sendMessage(p, "Cannot enter battlefield during a match!"); } else { Format.sendMessage( p, "Entering the battlefield '" + ChatColor.WHITE + field.getName() + ChatColor.GRAY + "'."); field.addPlayer(p); r.setPlayerState(p, true); } return; } else { if (p.getLocation().getBlock().getRelative(BlockFace.DOWN).getTypeId() != 0) plugin.setLastLocation(p); if (field.isActive()) field.getGametype().getListener().onPlayerMove(m, from, to); } } }
public void loadBeacon() { beaconFlagBlocks = new ArrayList<Block>(); beaconWireframeBlocks = new ArrayList<Block>(); if (!TownyWarConfig.isDrawingBeacon()) return; int beaconSize = TownyWarConfig.getBeaconSize(); if (Coord.getCellSize() < beaconSize) return; Block minBlock = getBeaconMinBlock(getFlagBaseBlock().getWorld()); if (flagBaseBlock.getY() + 4 > minBlock.getY()) return; int outerEdge = beaconSize - 1; for (int y = 0; y < beaconSize; y++) { for (int z = 0; z < beaconSize; z++) { for (int x = 0; x < beaconSize; x++) { Block block = flagBaseBlock .getWorld() .getBlockAt(minBlock.getX() + x, minBlock.getY() + y, minBlock.getZ() + z); if (block.isEmpty()) { int edgeCount = getEdgeCount(x, y, z, outerEdge); if (edgeCount == 1) { beaconFlagBlocks.add(block); } else if (edgeCount > 1) { beaconWireframeBlocks.add(block); } } } } } }
/** * @param block * @param owner */ public Unbreakable(Block block, String owner) { super(block.getX(), block.getY(), block.getZ(), block.getWorld().getName()); this.owner = owner; this.type = new BlockTypeEntry(block.getTypeId(), block.getData()); this.dirty = true; }
private boolean hasAnyMoved(Block block) { int x = block.getX(); int z = block.getZ(); Integer[] pair = new Integer[] {x, z}; if (blocks.containsKey(pair)) return true; return false; }
/** Block place methods */ public static BlockPlaceEvent callBlockPlaceEvent( World world, EntityPlayerMP who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) { BukkitWorld craftWorld = (BukkitWorld) Bukkit.getServer().getWorld(((WorldServer) world).getWorldInfo().getWorldName()); BukkitServer craftServer = (BukkitServer) Bukkit.getServer(); Player player = (who == null) ? null : (Player) BukkitEntity.getEntity(craftServer, who); Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ); Block placedBlock = replacedBlockState.getBlock(); boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ()); BlockPlaceEvent event = new BlockPlaceEvent( placedBlock, replacedBlockState, blockClicked, player.getItemInHand(), player, canBuild); craftServer.getPluginManager().callEvent(event); return event; }
@Override public void onBlockBreak(BlockBreakEvent inEvent) { Player thePlayer = inEvent.getPlayer(); Block theBlock = inEvent.getBlock(); if ((theBlock.getType() != Material.MOB_SPAWNER) || (inEvent.isCancelled())) return; if (creaturebox.permissions != null) { if (creaturebox.permissions.has(thePlayer, "creaturebox.dropspawner") == false) { return; } } else { if (thePlayer.isOp() == false) { return; } } World theWorld = theBlock.getWorld(); Location theLocation = new Location(theWorld, theBlock.getX(), theBlock.getY(), theBlock.getZ(), 0, 0); CreatureSpawner theSpawner = (CreatureSpawner) theBlock.getState(); int theCreatureIndex = plugin.creatureIndex(theSpawner.getCreatureTypeId()); MaterialData theMaterial = new MaterialData(Material.MOB_SPAWNER, (byte) theCreatureIndex); ItemStack theItem = new ItemStack(Material.MOB_SPAWNER, 1, (short) theCreatureIndex); theWorld.dropItemNaturally(theLocation, theItem); thePlayer.sendMessage( String.format( ChatColor.YELLOW + "creaturebox: %s spawner dropped.", theSpawner.getCreatureTypeId())); }
/* * Called when redstone changes. */ @EventHandler(priority = EventPriority.HIGH) public void onBlockRedstoneChange(BlockRedstoneEvent event) { Block blockTo = event.getBlock(); World world = blockTo.getWorld(); ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(world); if (wcfg.simulateSponge && wcfg.redstoneSponges) { int ox = blockTo.getX(); int oy = blockTo.getY(); int oz = blockTo.getZ(); for (int cx = -1; cx <= 1; cx++) { for (int cy = -1; cy <= 1; cy++) { for (int cz = -1; cz <= 1; cz++) { Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz); if (sponge.getTypeId() == 19 && sponge.isBlockIndirectlyPowered()) { SpongeUtil.clearSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz); } else if (sponge.getTypeId() == 19 && !sponge.isBlockIndirectlyPowered()) { SpongeUtil.addSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz); } } } } return; } }
@Override public void run() { try { PreparedStatement statement = this.databaseHandler .getConnection() .prepareStatement( "SELECT * FROM " + block.getWorld().getName() + "_inventory WHERE blockX=" + block.getX() + " AND blockY=" + block.getY() + " AND blockZ=" + block.getZ() + " ORDER BY timestamp DESC LIMIT 9"); ResultSet results = statement.executeQuery(); if (results != null) { GetInventoryChangesEvent event = new GetInventoryChangesEvent( playerName, block.getWorld(), results, block, showBlockInfo); Bukkit.getPluginManager().callEvent(event); } } catch (SQLException e) { e.printStackTrace(); } }
// grow the specified block, return the new growth magnitude public double growAndPersistBlock( Block block, GrowthConfig growthConfig, boolean naturalGrowEvent) { if (!persistConfig.enabled) return 0.0; int w = WorldID.getPID(block.getWorld().getUID()); Coords coords = new Coords(w, block.getX(), block.getY(), block.getZ()); boolean loadChunk = naturalGrowEvent ? Math.random() < persistConfig.growEventLoadChance : true; if (!loadChunk && !plantManager.chunkLoaded(coords)) return 0.0; // don't load the chunk or do anything Plant plant = plantManager.get(coords); if (plant == null) { plant = new Plant(System.currentTimeMillis()); plant.addGrowth((float) BlockGrower.getGrowthFraction(block)); plantManager.add(coords, plant); } else { double growthAmount = growthConfig.getRate(block) * plant.setUpdateTime(System.currentTimeMillis()); plant.addGrowth((float) growthAmount); } blockGrower.growBlock(block, coords, plant.getGrowth()); if (plant.getGrowth() > 1.0) plantManager.remove(coords); return plant.getGrowth(); }
private void pathStep() { if (pathIterator.hasNext()) { Node n = pathIterator.next(); Block b = null; if (last == null || runningPath.checkPath(n, last, true)) { b = n.b; if (last != null) { this.lookAtPoint(last.b.getLocation(), b.getLocation()); } getHandle().setPosition(b.getX(), b.getY(), b.getZ()); } last = n; } else { getHandle() .setPositionRotation( runningPath.getEnd().getX(), runningPath.getEnd().getY(), runningPath.getEnd().getZ(), runningPath.getEnd().getYaw(), runningPath.getEnd().getPitch()); Bukkit.getServer().getScheduler().cancelTask(taskid); taskid = 0; } location = new Location( getHandle().world.getWorld(), getHandle().locX, getHandle().locY, getHandle().locZ); }
/** * Create a plate with default damage * * @param block The block with the plate * @param player The plates owner/creator */ public Plate(Block block, String player) { this.x = block.getX(); this.y = block.getY(); this.z = block.getZ(); this.world = block.getWorld().getName(); this.player = player; }
private void torchCheck(String player, Block block) { ArrayList<Integer> torchTypes = new ArrayList<Integer>(); torchTypes.add(50); // Torch torchTypes.add(75); // Redstone torch (on) torchTypes.add(76); // Redstone torch (off) int x = block.getX(); int y = block.getY(); int z = block.getZ(); Block torchTop = block.getWorld().getBlockAt(x, y + 1, z); if (torchTypes.contains(torchTop.getTypeId()) && torchTop.getData() == 5) { bystanders.add(new BrokenBlock(player, torchTop, world)); } Block torchNorth = block.getWorld().getBlockAt(x + 1, y, z); if (torchTypes.contains(torchNorth.getTypeId()) && torchNorth.getData() == 1) { bystanders.add(new BrokenBlock(player, torchNorth, world)); } Block torchSouth = block.getWorld().getBlockAt(x - 1, y, z); if (torchTypes.contains(torchSouth.getTypeId()) && torchSouth.getData() == 2) { bystanders.add(new BrokenBlock(player, torchSouth, world)); } Block torchEast = block.getWorld().getBlockAt(x, y, z + 1); if (torchTypes.contains(torchEast.getTypeId()) && torchEast.getData() == 3) { bystanders.add(new BrokenBlock(player, torchEast, world)); } Block torchWest = block.getWorld().getBlockAt(x, y, z - 1); if (torchTypes.contains(torchWest.getTypeId()) && torchWest.getData() == 4) { bystanders.add(new BrokenBlock(player, torchWest, world)); } }
public Node(Block b) { this.b = b; xPos = b.getX(); yPos = b.getY(); zPos = b.getZ(); update(); }
private void checkGnomesLivingOnTop(String player, Block block) { ArrayList<Integer> gnomes = new ArrayList<Integer>(); gnomes.add(6); // Sapling gnomes.add(37); // Yellow Flower gnomes.add(38); // Red Flower gnomes.add(39); // Brown Mushroom gnomes.add(40); // Red Mushroom gnomes.add(55); // Redstone gnomes.add(59); // Crops gnomes.add(64); // Wood Door gnomes.add(66); // Tracks gnomes.add(69); // Lever gnomes.add(70); // Stone pressure plate gnomes.add(71); // Iron Door gnomes.add(72); // Wood pressure ePlate gnomes.add(78); // Snow gnomes.add(81); // Cactus gnomes.add(83); // Reeds int x = block.getX(); int y = block.getY(); int z = block.getZ(); Block mrGnome = block.getWorld().getBlockAt(x, y + 1, z); if (gnomes.contains(mrGnome.getTypeId())) { bystanders.add(new BrokenBlock(player, mrGnome, world)); } }
private void surroundingSignChecks(String player, Block block) { int x = block.getX(); int y = block.getY(); int z = block.getZ(); Block top = block.getWorld().getBlockAt(x, y + 1, z); if (top.getTypeId() == 63) { bystanders.add(new BrokenBlock(player, top, world)); } Block north = block.getWorld().getBlockAt(x + 1, y, z); if (north.getTypeId() == 68 && north.getData() == 5) { bystanders.add(new BrokenBlock(player, north, world)); } Block south = block.getWorld().getBlockAt(x - 1, y, z); if (south.getTypeId() == 68 && south.getData() == 4) { bystanders.add(new BrokenBlock(player, south, world)); } Block east = block.getWorld().getBlockAt(x, y, z + 1); if (east.getTypeId() == 68 && east.getData() == 3) { bystanders.add(new BrokenBlock(player, east, world)); } Block west = block.getWorld().getBlockAt(x, y, z - 1); if (west.getTypeId() == 68 && west.getData() == 2) { bystanders.add(new BrokenBlock(player, west, world)); } }
public void setBlock(Block block, int typeId, byte data, String regionName, long respawnTime) { // Save block to configuration in case we crash before restoring String blockName = "x" + block.getX() + "y" + block.getY() + "z" + block.getZ(); String worldName = block.getWorld().getName(); this.config.set("blocksToRegen." + worldName + "." + blockName + ".X", block.getX()); this.config.set("blocksToRegen." + worldName + "." + blockName + ".Y", block.getY()); this.config.set("blocksToRegen." + worldName + "." + blockName + ".Z", block.getZ()); this.config.set("blocksToRegen." + worldName + "." + blockName + ".TypeID", typeId); this.config.set("blocksToRegen." + worldName + "." + blockName + ".Data", data); this.config.set("blocksToRegen." + worldName + "." + blockName + ".RegionName", regionName); this.config.set("blocksToRegen." + worldName + "." + blockName + ".RespawnTime", respawnTime); this.save(); }
public void save() { conf.setProperty(pre + "x", x); conf.setProperty(pre + "z", z); conf.setProperty(pre + "y", y); conf.setProperty(pre + "sx", startBlock.getX()); conf.setProperty(pre + "sy", startBlock.getY()); conf.setProperty(pre + "sz", startBlock.getZ()); conf.save(); }