mirror of
https://github.com/TotalFreedomMC/TF-WorldGuardExtraFlagsPlugin.git
synced 2025-02-05 11:52:42 +00:00
Hacky fix for chunk-unload flag on 1.14 server
This commit is contained in:
parent
1327ab3112
commit
dc8cb8459a
2 changed files with 28 additions and 1 deletions
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue