Fix crashing after server shutdown in serverPlayerDisconnectEvent
This commit is contained in:
@@ -145,13 +145,13 @@ public class ServerApi
|
||||
|
||||
public void serverPlayerJoinEvent(IServerPlayerWrapper player)
|
||||
{
|
||||
if (DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
if (DhApiWorldProxy.INSTANCE.worldLoaded() && DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IDhServerWorld serverWorld = SharedApi.getIDhServerWorld();
|
||||
LOGGER.info("Player [${player.getName()}] joined.");
|
||||
LOGGER.info("Player ["+player.getName()+"] joined.");
|
||||
if (serverWorld != null)
|
||||
{
|
||||
serverWorld.addPlayer(player);
|
||||
@@ -159,13 +159,13 @@ public class ServerApi
|
||||
}
|
||||
public void serverPlayerDisconnectEvent(IServerPlayerWrapper player)
|
||||
{
|
||||
if (DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
if (DhApiWorldProxy.INSTANCE.worldLoaded() && DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IDhServerWorld serverWorld = SharedApi.getIDhServerWorld();
|
||||
LOGGER.info("Player [${player.getName()}] disconnected.");
|
||||
LOGGER.info("Player ["+player.getName()+"] disconnected.");
|
||||
if (serverWorld != null)
|
||||
{
|
||||
serverWorld.removePlayer(player);
|
||||
@@ -173,13 +173,13 @@ public class ServerApi
|
||||
}
|
||||
public void serverPlayerLevelChangeEvent(IServerPlayerWrapper player, IServerLevelWrapper originLevel, IServerLevelWrapper destinationLevel)
|
||||
{
|
||||
if (DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
if (DhApiWorldProxy.INSTANCE.worldLoaded() && DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IDhServerWorld serverWorld = SharedApi.getIDhServerWorld();
|
||||
LOGGER.info("Player [${player.getName()}] changed level: [${originLevel.getKeyedLevelDimensionName()}] -> [${destinationLevel.getKeyedLevelDimensionName()}].");
|
||||
LOGGER.info("Player ["+player.getName()+"] changed level: ["+originLevel.getKeyedLevelDimensionName()+"] -> ["+destinationLevel.getKeyedLevelDimensionName()+"].");
|
||||
if (serverWorld != null)
|
||||
{
|
||||
serverWorld.changePlayerLevel(player, originLevel, destinationLevel);
|
||||
@@ -188,7 +188,7 @@ public class ServerApi
|
||||
|
||||
public void pluginMessageReceived(IServerPlayerWrapper player, @NotNull AbstractNetworkMessage message)
|
||||
{
|
||||
if (DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
if (DhApiWorldProxy.INSTANCE.worldLoaded() && DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -190,7 +190,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
||||
try
|
||||
{
|
||||
// loop until the generator is shutdown
|
||||
while (!Thread.interrupted() && !DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
while (!Thread.interrupted() && DhApiWorldProxy.INSTANCE.worldLoaded() && !DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
{
|
||||
this.generator.preGeneratorTaskStart();
|
||||
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ public abstract class AbstractFullDataNetworkRequestQueue implements IDebugRende
|
||||
|
||||
public synchronized boolean tick(DhBlockPos2D targetPos)
|
||||
{
|
||||
if (DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
if (DhApiWorldProxy.INSTANCE.worldLoaded() && DhApiWorldProxy.INSTANCE.getReadOnly())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ public class DhApiWorldProxy implements IDhApiWorldProxy
|
||||
public boolean worldLoaded() { return SharedApi.getAbstractDhWorld() != null; }
|
||||
|
||||
@Override
|
||||
public void setReadOnly(boolean readOnly) { this.setReadOnly(readOnly, true); }
|
||||
public void setReadOnly(boolean readOnly) throws IllegalStateException { this.setReadOnly(readOnly, true); }
|
||||
/**
|
||||
* Not part of the public API.
|
||||
* Normal API users shouldn't be able to change the upcoming world state
|
||||
* this is only here so DH can revert the readonly value after the world is unloaded
|
||||
*/
|
||||
public void setReadOnly(boolean readOnly, boolean throwIfWorldUnloaded)
|
||||
public void setReadOnly(boolean readOnly, boolean throwIfWorldUnloaded) throws IllegalStateException
|
||||
{
|
||||
if (throwIfWorldUnloaded && SharedApi.getAbstractDhWorld() == null)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ public class DhApiWorldProxy implements IDhApiWorldProxy
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getReadOnly()
|
||||
public boolean getReadOnly() throws IllegalStateException
|
||||
{
|
||||
if (SharedApi.getAbstractDhWorld() == null)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ public class DhApiWorldProxy implements IDhApiWorldProxy
|
||||
//================//
|
||||
|
||||
@Override
|
||||
public IDhApiLevelWrapper getSinglePlayerLevel()
|
||||
public IDhApiLevelWrapper getSinglePlayerLevel() throws IllegalStateException
|
||||
{
|
||||
if (SharedApi.getAbstractDhWorld() == null)
|
||||
{
|
||||
@@ -138,7 +138,7 @@ public class DhApiWorldProxy implements IDhApiWorldProxy
|
||||
|
||||
|
||||
@Override
|
||||
public Iterable<IDhApiLevelWrapper> getAllLoadedLevelWrappers()
|
||||
public Iterable<IDhApiLevelWrapper> getAllLoadedLevelWrappers() throws IllegalStateException
|
||||
{
|
||||
AbstractDhWorld world = SharedApi.getAbstractDhWorld();
|
||||
if (world == null)
|
||||
@@ -155,7 +155,7 @@ public class DhApiWorldProxy implements IDhApiWorldProxy
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IDhApiLevelWrapper> getAllLoadedLevelsForDimensionType(IDhApiDimensionTypeWrapper dimensionTypeWrapper)
|
||||
public Iterable<IDhApiLevelWrapper> getAllLoadedLevelsForDimensionType(IDhApiDimensionTypeWrapper dimensionTypeWrapper) throws IllegalStateException
|
||||
{
|
||||
AbstractDhWorld world = SharedApi.getAbstractDhWorld();
|
||||
if (world == null)
|
||||
@@ -176,7 +176,7 @@ public class DhApiWorldProxy implements IDhApiWorldProxy
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IDhApiLevelWrapper> getAllLoadedLevelsWithDimensionNameLike(String dimensionName)
|
||||
public Iterable<IDhApiLevelWrapper> getAllLoadedLevelsWithDimensionNameLike(String dimensionName) throws IllegalStateException
|
||||
{
|
||||
AbstractDhWorld world = SharedApi.getAbstractDhWorld();
|
||||
if (world == null)
|
||||
|
||||
Reference in New Issue
Block a user