Search in sources :

Example 26 with Location

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

the class PaperListener method onPreSpawnerSpawnEvent.

@EventHandler
public void onPreSpawnerSpawnEvent(PreSpawnerSpawnEvent event) {
    if (Settings.Paper_Components.SPAWNER_SPAWN) {
        Location location = BukkitUtil.adapt(event.getSpawnerLocation());
        PlotArea area = location.getPlotArea();
        if (area != null && !area.isMobSpawnerSpawning()) {
            event.setCancelled(true);
            event.setShouldAbortSpawn(true);
        }
    }
}
Also used : PlotArea(com.plotsquared.core.plot.PlotArea) Location(com.plotsquared.core.location.Location) EventHandler(org.bukkit.event.EventHandler)

Example 27 with Location

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

the class PaperListener method onBlockPlace.

@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event) {
    if (!Settings.Paper_Components.TILE_ENTITY_CHECK || !Settings.Enabled_Components.CHUNK_PROCESSOR) {
        return;
    }
    if (!(event.getBlock().getState(false) instanceof TileState)) {
        return;
    }
    final Location location = BukkitUtil.adapt(event.getBlock().getLocation());
    final PlotArea plotArea = location.getPlotArea();
    if (plotArea == null) {
        return;
    }
    final int tileEntityCount = event.getBlock().getChunk().getTileEntities(false).length;
    if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) {
        final PlotPlayer<?> plotPlayer = BukkitUtil.adapt(event.getPlayer());
        plotPlayer.sendMessage(TranslatableCaption.of("errors.tile_entity_cap_reached"), Template.of("amount", String.valueOf(Settings.Chunk_Processor.MAX_TILES)));
        event.setCancelled(true);
        event.setBuild(false);
    }
}
Also used : TileState(org.bukkit.block.TileState) PlotArea(com.plotsquared.core.plot.PlotArea) Location(com.plotsquared.core.location.Location) EventHandler(org.bukkit.event.EventHandler)

Example 28 with Location

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

the class PaperListener method onEntityPathfind.

@EventHandler
public void onEntityPathfind(EntityPathfindEvent event) {
    if (!Settings.Paper_Components.ENTITY_PATHING) {
        return;
    }
    Location toLoc = BukkitUtil.adapt(event.getLoc());
    Location fromLoc = BukkitUtil.adapt(event.getEntity().getLocation());
    PlotArea tarea = toLoc.getPlotArea();
    if (tarea == null) {
        return;
    }
    PlotArea farea = fromLoc.getPlotArea();
    if (farea == null) {
        return;
    }
    if (tarea != farea) {
        event.setCancelled(true);
        return;
    }
    Plot tplot = toLoc.getPlot();
    Plot fplot = fromLoc.getPlot();
    if (tplot == null ^ fplot == null) {
        event.setCancelled(true);
        return;
    }
    if (tplot == null || tplot.getId().hashCode() == fplot.getId().hashCode()) {
        return;
    }
    if (fplot.isMerged() && fplot.getConnectedPlots().contains(fplot)) {
        return;
    }
    event.setCancelled(true);
}
Also used : PlotArea(com.plotsquared.core.plot.PlotArea) Plot(com.plotsquared.core.plot.Plot) Location(com.plotsquared.core.location.Location) EventHandler(org.bukkit.event.EventHandler)

Example 29 with Location

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

the class ContentMap method saveEntitiesOut.

void saveEntitiesOut(Chunk chunk, CuboidRegion region) {
    for (Entity entity : chunk.getEntities()) {
        Location location = BukkitUtil.adapt(entity.getLocation());
        int x = location.getX();
        int z = location.getZ();
        if (BukkitChunkManager.isIn(region, x, z)) {
            continue;
        }
        if (entity.getVehicle() != null) {
            continue;
        }
        EntityWrapper wrap = new ReplicatingEntityWrapper(entity, (short) 2);
        wrap.saveEntity();
        this.entities.add(wrap);
    }
}
Also used : Entity(org.bukkit.entity.Entity) ReplicatingEntityWrapper(com.plotsquared.bukkit.entity.ReplicatingEntityWrapper) ReplicatingEntityWrapper(com.plotsquared.bukkit.entity.ReplicatingEntityWrapper) EntityWrapper(com.plotsquared.bukkit.entity.EntityWrapper) Location(com.plotsquared.core.location.Location)

Example 30 with Location

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

the class ContentMap method saveEntitiesIn.

void saveEntitiesIn(Chunk chunk, CuboidRegion region, boolean delete) {
    for (Entity entity : chunk.getEntities()) {
        Location location = BukkitUtil.adapt(entity.getLocation());
        int x = location.getX();
        int z = location.getZ();
        if (!BukkitChunkManager.isIn(region, x, z)) {
            continue;
        }
        if (entity.getVehicle() != null) {
            continue;
        }
        EntityWrapper wrap = new ReplicatingEntityWrapper(entity, (short) 2);
        wrap.saveEntity();
        this.entities.add(wrap);
        if (delete) {
            if (!(entity instanceof Player)) {
                entity.remove();
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) ReplicatingEntityWrapper(com.plotsquared.bukkit.entity.ReplicatingEntityWrapper) ReplicatingEntityWrapper(com.plotsquared.bukkit.entity.ReplicatingEntityWrapper) EntityWrapper(com.plotsquared.bukkit.entity.EntityWrapper) Location(com.plotsquared.core.location.Location)

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