mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-24 00:51:34 +01:00
Prevent Check#notNull from concatenating strings unnecessarily
This commit is contained in:
parent
ea3f558d8a
commit
66ab1bb53d
@ -1312,8 +1312,8 @@ public class Entity implements Viewable, EventHandler, DataContainer, Permission
|
||||
final Chunk lastChunk = instance.getChunkAt(lastX, lastZ);
|
||||
final Chunk newChunk = instance.getChunkAt(x, z);
|
||||
|
||||
Check.notNull(lastChunk, "The entity " + getEntityId() + " was in an unloaded chunk at " + lastX + ";" + lastZ);
|
||||
Check.notNull(newChunk, "The entity " + getEntityId() + " tried to move in an unloaded chunk at " + x + ";" + z);
|
||||
Check.notNull(lastChunk, "The entity {0} was in an unloaded chunk at {1};{2}", getEntityId(), lastX, lastZ);
|
||||
Check.notNull(newChunk, "The entity {0} tried to move in an unloaded chunk at {1};{2}", getEntityId(), x, z);
|
||||
|
||||
if (lastChunk != newChunk) {
|
||||
instance.UNSAFE_switchEntityChunk(this, lastChunk, newChunk);
|
||||
|
@ -4,6 +4,7 @@ import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -22,6 +23,13 @@ public final class Check {
|
||||
}
|
||||
}
|
||||
|
||||
@Contract("null, _, _ -> fail")
|
||||
public static void notNull(@Nullable Object object, @NotNull String reason, Object... arguments) {
|
||||
if (Objects.isNull(object)) {
|
||||
throw new NullPointerException(MessageFormat.format(reason, arguments));
|
||||
}
|
||||
}
|
||||
|
||||
@Contract("true, _ -> fail")
|
||||
public static void argCondition(boolean condition, @NotNull String reason) {
|
||||
if (condition) {
|
||||
|
Loading…
Reference in New Issue
Block a user