001/* 002 * PlotSquared, a land and world management plugin for Minecraft. 003 * Copyright (C) IntellectualSites <https://intellectualsites.com> 004 * Copyright (C) IntellectualSites team and contributors 005 * 006 * This program is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 018 */ 019package com.plotsquared.bukkit.util; 020 021import com.google.inject.Singleton; 022import com.plotsquared.core.util.ChunkManager; 023import com.sk89q.worldedit.math.BlockVector2; 024import com.sk89q.worldedit.regions.CuboidRegion; 025import io.papermc.lib.PaperLib; 026 027import java.util.concurrent.CompletableFuture; 028 029@Singleton 030public class BukkitChunkManager extends ChunkManager { 031 032 public static boolean isIn(CuboidRegion region, int x, int z) { 033 return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX() && z >= region 034 .getMinimumPoint() 035 .getZ() && z <= region 036 .getMaximumPoint().getZ(); 037 } 038 039 @Override 040 public CompletableFuture<?> loadChunk(String world, BlockVector2 chunkLoc, boolean force) { 041 return PaperLib.getChunkAtAsync(BukkitUtil.getWorld(world), chunkLoc.getX(), chunkLoc.getZ(), force); 042 } 043 044}