mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 21:17:53 +01:00
BlockHandlerBase
This commit is contained in:
parent
e3600525fa
commit
98fc704139
@ -295,23 +295,16 @@ public interface BlockHandler {
|
||||
* Handler used for loaded blocks with unknown namespace
|
||||
* in order to do not lose the information while saving, and for runtime debugging purpose.
|
||||
*/
|
||||
class Dummy implements BlockHandler {
|
||||
@ApiStatus.Internal
|
||||
final class Dummy extends BlockHandlerBase {
|
||||
private static final Map<String, BlockHandler> DUMMY_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static @NotNull BlockHandler get(@NotNull String namespace) {
|
||||
return DUMMY_CACHE.computeIfAbsent(namespace, s -> new Dummy(NamespaceID.from(namespace)));
|
||||
return DUMMY_CACHE.computeIfAbsent(namespace, Dummy::new);
|
||||
}
|
||||
|
||||
private final NamespaceID namespaceID;
|
||||
|
||||
private Dummy(NamespaceID namespaceID) {
|
||||
this.namespaceID = namespaceID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull NamespaceID getNamespaceId() {
|
||||
return namespaceID;
|
||||
private Dummy(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package net.minestom.server.instance.block;
|
||||
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BlockHandlerBase implements BlockHandler {
|
||||
|
||||
private final NamespaceID namespace;
|
||||
|
||||
public BlockHandlerBase(String name) {
|
||||
namespace = NamespaceID.from(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull NamespaceID getNamespaceId() {
|
||||
return namespace;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user