Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean send(Location location, Player to) {
- return send(location.getBlockX() >> 4, location.getBlockZ() >> 4, to);
- }
- public static boolean send(int cx, int cz, Player to) {
- try {
- net.minecraft.server.World world = ((CraftWorld) to.getWorld()).getHandle();
- Packet51MapChunk packet = new Packet51MapChunk(cx * 16, 0, cz * 16, 16, 128, 16, world);
- net.minecraft.server.Chunk chunk = world.getChunkAt(cx, cz);
- NetServerHandler handler = ((CraftPlayer) to).getHandle().netServerHandler;
- //Send pre-chunk
- handler.sendPacket(new Packet50PreChunk(cx * 16, cz * 16, true));
- //Send chunk
- handler.sendPacket(packet);
- //Send entities
- for (Object o : chunk.tileEntities.values()) {
- TileEntity entity = (TileEntity) o;
- handler.sendPacket(entity.l());
- }
- return true;
- } catch (Exception ex) {}
- return false;
- }
- public static boolean safeSend(Location location, Player to) {
- return safeSend(location.getBlockX() >> 4, location.getBlockZ() >> 4, to);
- }
- public static boolean safeSend(int cx, int cz, Player to) {
- if (Bukkit.getServer().getPluginManager().isPluginEnabled("NoLaggChunks")) {
- PlayerChunkLoader.clear(to, cx, cz);
- return true;
- } else {
- return send(cx, cz, to);
- }
- }
- public static void safeSendAll(Location location) {
- safeSendAll(location.getBlockX() >> 4, location.getBlockZ() >> 4, location.getWorld());
- }
- public static void safeSendAll(int cx, int cz, World world) {
- if (Bukkit.getServer().getPluginManager().isPluginEnabled("NoLaggChunks")) {
- PlayerChunkLoader.clearAll(world.getChunkAt(cx, cz));
- } else {
- for (Player player : world.getPlayers()) {
- send(cx, cz, player);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement