Search in sources :

Example 21 with Location

use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.

the class HybridPlotManager method createRoadEast.

@Override
public boolean createRoadEast(@NonNull final Plot plot, @Nullable QueueCoordinator queue) {
    boolean enqueue = false;
    if (queue == null) {
        queue = hybridPlotWorld.getQueue();
        enqueue = true;
    }
    super.createRoadEast(plot, queue);
    PlotId id = plot.getId();
    PlotId id2 = PlotId.of(id.getX() + 1, id.getY());
    Location bot = getPlotBottomLocAbs(id2);
    Location top = getPlotTopLocAbs(id);
    Location pos1 = Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1, hybridPlotWorld.getMinGenHeight(), bot.getZ() - 1);
    Location pos2 = Location.at(hybridPlotWorld.getWorldName(), bot.getX(), hybridPlotWorld.getMaxGenHeight(), top.getZ() + 1);
    this.resetBiome(hybridPlotWorld, pos1, pos2);
    if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
        return true;
    }
    createSchemAbs(queue, pos1, pos2, true);
    return !enqueue || queue.enqueue();
}
Also used : PlotId(com.plotsquared.core.plot.PlotId) Location(com.plotsquared.core.location.Location)

Example 22 with Location

use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.

the class ChunkListener method shouldSave.

public boolean shouldSave(String world, int chunkX, int chunkZ) {
    int x = chunkX << 4;
    int z = chunkZ << 4;
    int x2 = x + 15;
    int z2 = z + 15;
    Location loc = Location.at(world, x, 1, z);
    PlotArea plotArea = plotAreaManager.getPlotArea(loc);
    if (plotArea != null) {
        Plot plot = plotArea.getPlot(loc);
        if (plot != null && plot.hasOwner()) {
            return true;
        }
    }
    loc = Location.at(world, x2, 1, z2);
    plotArea = plotAreaManager.getPlotArea(loc);
    if (plotArea != null) {
        Plot plot = plotArea.getPlot(loc);
        if (plot != null && plot.hasOwner()) {
            return true;
        }
    }
    loc = Location.at(world, x2, 1, z);
    plotArea = plotAreaManager.getPlotArea(loc);
    if (plotArea != null) {
        Plot plot = plotArea.getPlot(loc);
        if (plot != null && plot.hasOwner()) {
            return true;
        }
    }
    loc = Location.at(world, x, 1, z2);
    plotArea = plotAreaManager.getPlotArea(loc);
    if (plotArea != null) {
        Plot plot = plotArea.getPlot(loc);
        if (plot != null && plot.hasOwner()) {
            return true;
        }
    }
    loc = Location.at(world, x + 7, 1, z + 7);
    plotArea = plotAreaManager.getPlotArea(loc);
    if (plotArea == null) {
        return false;
    }
    Plot plot = plotArea.getPlot(loc);
    return plot != null && plot.hasOwner();
}
Also used : SinglePlotArea(com.plotsquared.core.plot.world.SinglePlotArea) PlotArea(com.plotsquared.core.plot.PlotArea) Plot(com.plotsquared.core.plot.Plot) Location(com.plotsquared.core.location.Location)

Example 23 with Location

use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.

the class EntitySpawnListener method onTeleport.

@EventHandler
public void onTeleport(EntityTeleportEvent event) {
    Entity entity = event.getEntity();
    Entity fromLocation = event.getEntity();
    Block toLocation = event.getTo().getBlock();
    final Location fromLocLocation = BukkitUtil.adapt(fromLocation.getLocation());
    final PlotArea fromArea = fromLocLocation.getPlotArea();
    Location toLocLocation = BukkitUtil.adapt(toLocation.getLocation());
    PlotArea toArea = toLocLocation.getPlotArea();
    if (toArea == null) {
        if (fromLocation.getType() == EntityType.SHULKER && fromArea != null) {
            event.setCancelled(true);
        }
        return;
    }
    Plot toPlot = toArea.getOwnedPlot(toLocLocation);
    if (fromLocation.getType() == EntityType.SHULKER && fromArea != null) {
        final Plot fromPlot = fromArea.getOwnedPlot(fromLocLocation);
        if (fromPlot != null || toPlot != null) {
            if ((fromPlot == null || !fromPlot.equals(toPlot)) && (toPlot == null || !toPlot.equals(fromPlot))) {
                event.setCancelled(true);
                return;
            }
        }
    }
    if (entity instanceof Vehicle || entity instanceof ArmorStand) {
        testNether(event.getEntity());
    }
}
Also used : Vehicle(org.bukkit.entity.Vehicle) Entity(org.bukkit.entity.Entity) PlotArea(com.plotsquared.core.plot.PlotArea) ArmorStand(org.bukkit.entity.ArmorStand) Plot(com.plotsquared.core.plot.Plot) Block(org.bukkit.block.Block) Location(com.plotsquared.core.location.Location) EventHandler(org.bukkit.event.EventHandler)

Example 24 with Location

use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.

the class EntitySpawnListener method creatureSpawnEvent.

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void creatureSpawnEvent(EntitySpawnEvent event) {
    Entity entity = event.getEntity();
    Location location = BukkitUtil.adapt(entity.getLocation());
    PlotArea area = location.getPlotArea();
    if (!location.isPlotArea()) {
        return;
    }
    Plot plot = location.getOwnedPlotAbs();
    if (plot == null) {
        EntityType type = entity.getType();
        if (!area.isMobSpawning()) {
            switch(type) {
                case DROPPED_ITEM:
                    if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
                        event.setCancelled(true);
                        return;
                    }
                case PLAYER:
                    return;
            }
            if (type.isAlive()) {
                event.setCancelled(true);
            }
        }
        if (!area.isMiscSpawnUnowned() && !type.isAlive()) {
            event.setCancelled(true);
        }
        return;
    }
    if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
        event.setCancelled(true);
    }
    switch(entity.getType()) {
        case ENDER_CRYSTAL:
            if (BukkitEntityUtil.checkEntity(entity, plot)) {
                event.setCancelled(true);
            }
        case SHULKER:
            if (!entity.hasMetadata("shulkerPlot")) {
                entity.setMetadata("shulkerPlot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot.getId()));
            }
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) Entity(org.bukkit.entity.Entity) PlotArea(com.plotsquared.core.plot.PlotArea) Plot(com.plotsquared.core.plot.Plot) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) Location(com.plotsquared.core.location.Location) Plugin(org.bukkit.plugin.Plugin) EventHandler(org.bukkit.event.EventHandler)

Example 25 with Location

use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.

the class PaperListener method onPlayerNaturallySpawnCreaturesEvent.

@EventHandler
public void onPlayerNaturallySpawnCreaturesEvent(PlayerNaturallySpawnCreaturesEvent event) {
    if (Settings.Paper_Components.CANCEL_CHUNK_SPAWN) {
        Location location = BukkitUtil.adapt(event.getPlayer().getLocation());
        PlotArea area = location.getPlotArea();
        if (area != null && !area.isMobSpawning()) {
            event.setCancelled(true);
        }
    }
}
Also used : PlotArea(com.plotsquared.core.plot.PlotArea) Location(com.plotsquared.core.location.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Location (com.plotsquared.core.location.Location)82 Plot (com.plotsquared.core.plot.Plot)41 PlotArea (com.plotsquared.core.plot.PlotArea)26 EventHandler (org.bukkit.event.EventHandler)15 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)14 PlotPlayer (com.plotsquared.core.player.PlotPlayer)12 UUID (java.util.UUID)12 HashSet (java.util.HashSet)10 TranslatableCaption (com.plotsquared.core.configuration.caption.TranslatableCaption)9 NonNull (org.checkerframework.checker.nullness.qual.NonNull)9 QueueCoordinator (com.plotsquared.core.queue.QueueCoordinator)8 Caption (com.plotsquared.core.configuration.caption.Caption)7 BlockLoc (com.plotsquared.core.location.BlockLoc)7 Template (net.kyori.adventure.text.minimessage.Template)7 Entity (org.bukkit.entity.Entity)7 Settings (com.plotsquared.core.configuration.Settings)6 ClassicPlotWorld (com.plotsquared.core.generator.ClassicPlotWorld)6 PlotFlag (com.plotsquared.core.plot.flag.PlotFlag)6 SinglePlotArea (com.plotsquared.core.plot.world.SinglePlotArea)6 PlotSquared (com.plotsquared.core.PlotSquared)5