Skip to content
Permalink
Browse files

Avoid block state snapshots, avoid double-checking spawns.

  • Loading branch information...
wizjany committed Jun 20, 2019
1 parent 7e65ec4 commit 7b87710eb8049b4ea12eca391ff7d6f8b46b203d
@@ -32,6 +32,7 @@
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import io.papermc.lib.PaperLib;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@@ -629,7 +630,10 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
}

EntityType entityType = event.getEntityType();
checkCreatureSpawn(event, wcfg.useRegions && cfg.useRegionsCreatureSpawnEvent, wcfg, entityType, event.getSpawnReason(), event.getLocation());
// natural spawns on paper servers have already been checked by the pre-spawn event, no need to check again
if (!PaperLib.isPaper() || event.getSpawnReason() != SpawnReason.NATURAL || event.getEntityType() == EntityType.SLIME) {
checkCreatureSpawn(event, wcfg.useRegions && cfg.useRegionsCreatureSpawnEvent, wcfg, entityType, event.getSpawnReason(), event.getLocation());
}
}

static boolean checkCreatureSpawn(Cancellable event, boolean checkRegions, WorldConfiguration wcfg,
@@ -19,6 +19,7 @@

package com.sk89q.worldguard.bukkit.util;

import io.papermc.lib.PaperLib;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
@@ -45,7 +46,7 @@ private Blocks() {
* @return a list of connected blocks, not including the given block
*/
public static List<Block> getConnected(Block block) {
BlockState state = block.getState();
BlockState state = PaperLib.getBlockState(block, false).getState();
BlockData data = state.getBlockData();

if (data instanceof Bed) {

0 comments on commit 7b87710

Please sign in to comment.
You can’t perform that action at this time.