mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +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
|
* Handler used for loaded blocks with unknown namespace
|
||||||
* in order to do not lose the information while saving, and for runtime debugging purpose.
|
* 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<>();
|
private static final Map<String, BlockHandler> DUMMY_CACHE = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@ApiStatus.Internal
|
|
||||||
public static @NotNull BlockHandler get(@NotNull String namespace) {
|
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(String name) {
|
||||||
|
super(name);
|
||||||
private Dummy(NamespaceID namespaceID) {
|
|
||||||
this.namespaceID = namespaceID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull NamespaceID getNamespaceId() {
|
|
||||||
return namespaceID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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