SPIGOT-7011, SPIGOT-7065: Overhaul of structures
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
@@ -30,6 +30,7 @@ public abstract class AbstractTestingBase {
|
||||
public static final List<Material> INVALIDATED_MATERIALS;
|
||||
|
||||
public static final DataPackResources DATA_PACK;
|
||||
public static final IRegistryCustom.Dimension REGISTRY_CUSTOM;
|
||||
|
||||
static {
|
||||
SharedConstants.tryDetectVersion();
|
||||
@@ -37,11 +38,11 @@ public abstract class AbstractTestingBase {
|
||||
// Set up resource manager
|
||||
ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA, Collections.singletonList(new ResourcePackVanilla(ResourcePackSourceVanilla.BUILT_IN_METADATA, "minecraft")));
|
||||
// add tags and loot tables for unit tests
|
||||
IRegistryCustom.Dimension registry = IRegistryCustom.builtinCopy().freeze();
|
||||
REGISTRY_CUSTOM = IRegistryCustom.builtinCopy().freeze();
|
||||
// Register vanilla pack
|
||||
DATA_PACK = DataPackResources.loadResources(resourceManager, registry, CommandDispatcher.ServerType.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
|
||||
DATA_PACK = DataPackResources.loadResources(resourceManager, REGISTRY_CUSTOM, CommandDispatcher.ServerType.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
|
||||
// Bind tags
|
||||
DATA_PACK.updateRegistryTags(registry);
|
||||
DATA_PACK.updateRegistryTags(REGISTRY_CUSTOM);
|
||||
|
||||
DummyServer.setup();
|
||||
DummyEnchantments.setup();
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.CraftLootTable;
|
||||
import org.bukkit.craftbukkit.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemFactory;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
@@ -97,6 +98,14 @@ public final class DummyServer implements InvocationHandler {
|
||||
}
|
||||
}
|
||||
);
|
||||
methods.put(Server.class.getMethod("getRegistry", Class.class),
|
||||
new MethodHandler() {
|
||||
@Override
|
||||
public Object handle(DummyServer server, Object[] args) {
|
||||
return CraftRegistry.createRegistry((Class) args[0], AbstractTestingBase.REGISTRY_CUSTOM);
|
||||
}
|
||||
}
|
||||
);
|
||||
Bukkit.setServer(Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(new DummyServer()));
|
||||
} catch (Throwable t) {
|
||||
throw new Error(t);
|
||||
|
||||
Reference in New Issue
Block a user