Hacky fix for chunk-unload flag on 1.14 server

This commit is contained in:
isokissa3 2019-08-05 22:26:15 +03:00
parent 1327ab3112
commit dc8cb8459a
2 changed files with 28 additions and 1 deletions

View File

@ -30,7 +30,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -28,6 +28,20 @@ public class WorldGuardSevenCommunicator implements WorldGuardCommunicator
private AbstractSessionManagerWrapper sessionManager;
private AbstractRegionContainerWrapper regionContainer;
public static boolean supportsForceLoad;
static
{
try
{
WorldGuardSevenCommunicator.supportsForceLoad = Chunk.class.getMethod("setForceLoaded", boolean.class) != null;
}
catch(Throwable e)
{
}
}
@Override
public void onLoad(Plugin plugin) throws Exception
{
@ -96,6 +110,11 @@ public class WorldGuardSevenCommunicator implements WorldGuardCommunicator
for(int z = min.getBlockZ() >> 4; z <= max.getBlockZ() >> 4; z++)
{
world.getChunkAt(x, z).load(true);
if (WorldGuardSevenCommunicator.supportsForceLoad)
{
world.getChunkAt(x, z).setForceLoaded(true);
}
}
}
}
@ -109,6 +128,14 @@ public class WorldGuardSevenCommunicator implements WorldGuardCommunicator
{
if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY)
{
if (WorldGuardSevenCommunicator.supportsForceLoad)
{
chunk.setForceLoaded(true);
chunk.load(true);
return true;
}
return false;
}
}