sponge: Fix mod registry.

This commit is contained in:
bloodshot 2020-01-07 16:18:38 -05:00
parent 9014c93633
commit a3bb1758a4
4 changed files with 14 additions and 10 deletions

View File

@ -482,9 +482,6 @@ public void onPreInit(GamePreInitializationEvent event, Logger logger, Path path
TrustTypeRegistryModule.getInstance().registerDefaults();
FlagRegistryModule.getInstance().registerDefaults();
ResultTypeRegistryModule.getInstance().registerDefaults();
EntityTypeRegistryModule.getInstance().registerDefaults();
BlockTypeRegistryModule.getInstance().registerDefaults();
ItemTypeRegistryModule.getInstance().registerDefaults();
CreateModeTypeRegistryModule.getInstance().registerDefaults();
GameModeTypeRegistryModule.getInstance().registerDefaults();
WeatherTypeRegistryModule.getInstance().registerDefaults();
@ -503,6 +500,10 @@ public void onServerAboutToStart(GameAboutToStartServerEvent event) {
return;
}
// These must be registered here to catch all mod registrations
BlockTypeRegistryModule.getInstance().registerDefaults();
EntityTypeRegistryModule.getInstance().registerDefaults();
ItemTypeRegistryModule.getInstance().registerDefaults();
this.loadConfig();
this.registerBaseCommands();
this.executor = Executors.newFixedThreadPool(GriefDefenderPlugin.getGlobalConfig().getConfig().thread.numExecutorThreads);

View File

@ -27,6 +27,8 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableList;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.block.BlockType;
import java.util.Collection;
@ -39,7 +41,6 @@
public final class BlockTypeRegistryModule {
protected final Map<String, GDBlockType> blockTypeMappings = new HashMap<>();
private final org.spongepowered.common.registry.type.BlockTypeRegistryModule SPONGE_REGISTRY = org.spongepowered.common.registry.type.BlockTypeRegistryModule.getInstance();
public static BlockTypeRegistryModule getInstance() {
return Holder.INSTANCE;
@ -57,7 +58,7 @@ public Collection<GDBlockType> getAll() {
}
public void registerDefaults() {
for (BlockType type : SPONGE_REGISTRY.getAll()) {
for (BlockType type : Sponge.getRegistry().getAllOf(BlockType.class)) {
this.blockTypeMappings.put(type.getId(), new GDBlockType(type));
}
}

View File

@ -30,6 +30,8 @@
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.EnumCreatureType;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.entity.EntityType;
import org.spongepowered.api.entity.living.Living;
import org.spongepowered.common.entity.SpongeEntityType;
@ -44,7 +46,6 @@ public final class EntityTypeRegistryModule {
protected final Map<String, GDEntityType> entityTypeMappings = new HashMap<>();
public final BiMap<String, EnumCreatureType> SPAWN_TYPES = HashBiMap.create();
private final org.spongepowered.common.registry.type.entity.EntityTypeRegistryModule SPONGE_REGISTRY = org.spongepowered.common.registry.type.entity.EntityTypeRegistryModule.getInstance();
public static EntityTypeRegistryModule getInstance() {
return Holder.INSTANCE;
@ -74,7 +75,7 @@ public EnumCreatureType getCreatureTypeByName(String name) {
}
public void registerDefaults() {
for (EntityType type : SPONGE_REGISTRY.getAll()) {
for (EntityType type : Sponge.getRegistry().getAllOf(EntityType.class)) {
this.entityTypeMappings.put(type.getId(), new GDEntityType(type));
}
SPAWN_TYPES.put("animal", EnumCreatureType.CREATURE);

View File

@ -27,6 +27,8 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableList;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.item.ItemType;
import java.util.Collection;
@ -38,8 +40,7 @@
public final class ItemTypeRegistryModule {
protected final Map<String, GDItemType> itemTypeMappings = new HashMap<>();
private final org.spongepowered.common.registry.type.ItemTypeRegistryModule SPONGE_REGISTRY = org.spongepowered.common.registry.type.ItemTypeRegistryModule.getInstance();
public static ItemTypeRegistryModule getInstance() {
return Holder.INSTANCE;
}
@ -56,7 +57,7 @@ public Collection<GDItemType> getAll() {
}
public void registerDefaults() {
for (ItemType type : SPONGE_REGISTRY.getAll()) {
for (ItemType type : Sponge.getRegistry().getAllOf(ItemType.class)) {
this.itemTypeMappings.put(type.getId(), new GDItemType(type));
}
}