Checking reference is not initialized
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
package mc.core;
|
||||
|
||||
import lombok.Data;
|
||||
import mc.core.exception.ResourceUnloadException;
|
||||
import mc.core.exception.ResourceUnloadedException;
|
||||
import mc.core.world.World;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -98,8 +98,11 @@ public class Location implements Serializable{
|
||||
}
|
||||
|
||||
public World getWorld () {
|
||||
if (world == null) {
|
||||
throw new IllegalStateException("World is not initialized");
|
||||
}
|
||||
if (world.get() == null) {
|
||||
throw new ResourceUnloadException("You're trying to get unloaded world");
|
||||
throw new ResourceUnloadedException("You're trying to get unloaded world");
|
||||
}
|
||||
return this.world.get();
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package mc.core.exception;
|
||||
|
||||
public class ResourceUnloadException extends McCoreUncheckedException {
|
||||
|
||||
public ResourceUnloadException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package mc.core.exception;
|
||||
|
||||
public class ResourceUnloadedException extends McCoreUncheckedException {
|
||||
|
||||
public ResourceUnloadedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user