From e1ac12e1a668fe0b16f61225a5d63c18314fb40c Mon Sep 17 00:00:00 2001 From: kashike Date: Mon, 28 Nov 2016 16:34:57 -0800 Subject: [PATCH] Fix some OCD issues ref #23 --- SpongeAPI | 2 +- .../org/spongepowered/common/command/SpongeCommand.java | 2 +- .../common/config/category/CollisionModCategory.java | 2 +- .../common/config/category/DebugCategory.java | 2 +- .../config/category/EntityActivationRangeCategory.java | 2 +- .../common/config/category/EntityCollisionCategory.java | 2 +- .../mixin/entitycollisions/MixinEntity_Collisions.java | 2 +- .../common/registry/SpongeGameRegistry.java | 9 ++++++++- 8 files changed, 15 insertions(+), 8 deletions(-) diff --git a/SpongeAPI b/SpongeAPI index 87ef7bef51f..871fcd1b9cd 160000 --- a/SpongeAPI +++ b/SpongeAPI @@ -1 +1 @@ -Subproject commit 87ef7bef51f4c8dc6cc9713523841de9772d9d8e +Subproject commit 871fcd1b9cddc82fefce9fdecc1ac690ae6762dd diff --git a/src/main/java/org/spongepowered/common/command/SpongeCommand.java b/src/main/java/org/spongepowered/common/command/SpongeCommand.java index 02377383912..f1437a1124a 100644 --- a/src/main/java/org/spongepowered/common/command/SpongeCommand.java +++ b/src/main/java/org/spongepowered/common/command/SpongeCommand.java @@ -392,7 +392,7 @@ private static CommandSpec getBlockInfoCommand() { final RayTraceResult rayTraceResult = EntityUtil.rayTraceFromEntity(entityPlayerMP, 5, 1.0F); if (rayTraceResult.typeOfHit != RayTraceResult.Type.BLOCK) { src.sendMessage(Text.of(TextColors.RED, TextStyles.ITALIC, - "Failed to find an entity! Please execute the command when looking at an entity!")); + "Failed to find a block! Please execute the command when looking at a block!")); return CommandResult.empty(); } final WorldServer worldServer = (WorldServer) entityPlayerMP.world; diff --git a/src/main/java/org/spongepowered/common/config/category/CollisionModCategory.java b/src/main/java/org/spongepowered/common/config/category/CollisionModCategory.java index d517999dd19..ad6fc9fc85b 100644 --- a/src/main/java/org/spongepowered/common/config/category/CollisionModCategory.java +++ b/src/main/java/org/spongepowered/common/config/category/CollisionModCategory.java @@ -35,7 +35,7 @@ public class CollisionModCategory extends ConfigCategory { @Setting(value = "enabled", comment = "Set to false if you want mod to ignore entity collision rules.") private boolean isEnabled = true; - @Setting(value = "defaults", comment = "Default max collisions used for all entities/blocks unless overidden.") + @Setting(value = "defaults", comment = "Default max collisions used for all entities/blocks unless overridden.") private Map defaultMaxCollisions = new HashMap<>(); @Setting(value = "blocks") private Map blockList = new HashMap<>(); diff --git a/src/main/java/org/spongepowered/common/config/category/DebugCategory.java b/src/main/java/org/spongepowered/common/config/category/DebugCategory.java index fae647a27d0..e83f490965e 100644 --- a/src/main/java/org/spongepowered/common/config/category/DebugCategory.java +++ b/src/main/java/org/spongepowered/common/config/category/DebugCategory.java @@ -39,7 +39,7 @@ public class DebugCategory extends ConfigCategory { @Setting(value = "dump-threads-on-warn", comment = "Dump the server thread on deadlock warning") private boolean dumpThreadsOnWarn = false; - @Setting(value = "concurrent-entity-checks", comment = "Detect and prevent certain attempts to use entities concurrently.\nWARNING: May drastically decrase server performance. Only enable this to debug a pre-existing issue") + @Setting(value = "concurrent-entity-checks", comment = "Detect and prevent certain attempts to use entities concurrently.\nWARNING: May drastically decrease server performance. Only enable this to debug a pre-existing issue") private boolean concurrentChecks = false; public boolean doConcurrentChecks() { diff --git a/src/main/java/org/spongepowered/common/config/category/EntityActivationRangeCategory.java b/src/main/java/org/spongepowered/common/config/category/EntityActivationRangeCategory.java index d3eb8468b36..381efd36356 100644 --- a/src/main/java/org/spongepowered/common/config/category/EntityActivationRangeCategory.java +++ b/src/main/java/org/spongepowered/common/config/category/EntityActivationRangeCategory.java @@ -35,7 +35,7 @@ public class EntityActivationRangeCategory extends ConfigCategory { @Setting(value = "auto-populate", comment = "If enabled, newly discovered entities will be added to this config with a default value.") private boolean autoPopulate = false; - @Setting(value = "defaults", comment = "Default activation ranges used for all entities unless overidden.") + @Setting(value = "defaults", comment = "Default activation ranges used for all entities unless overridden.") private Map defaultRanges = new HashMap<>(); @Setting(value = "mods", comment = "Per-mod overrides. Refer to the minecraft default mod for example.") private Map modList = new HashMap<>(); diff --git a/src/main/java/org/spongepowered/common/config/category/EntityCollisionCategory.java b/src/main/java/org/spongepowered/common/config/category/EntityCollisionCategory.java index 0bd64ee0127..1355bda3e4d 100644 --- a/src/main/java/org/spongepowered/common/config/category/EntityCollisionCategory.java +++ b/src/main/java/org/spongepowered/common/config/category/EntityCollisionCategory.java @@ -37,7 +37,7 @@ public class EntityCollisionCategory extends ConfigCategory { private boolean autoPopulate = false; @Setting(value = "max-entities-within-aabb", comment = "Max amount of entities any given entity or block can collide with. This improves performance when there are more than 8 entities on top of eachother such as a 1x1 spawn pen. Set to 0 to disable.") private int maxEntitiesWithinAABB = 8; - @Setting(value = "defaults", comment = "Default max collisions used for all entities/blocks unless overidden.") + @Setting(value = "defaults", comment = "Default max collisions used for all entities/blocks unless overridden.") private Map defaultMaxCollisions = new HashMap<>(); @Setting(value = "mods", comment = "Per-mod overrides. Refer to the minecraft default mod for example.") private Map modList = new HashMap<>(); diff --git a/src/main/java/org/spongepowered/common/mixin/entitycollisions/MixinEntity_Collisions.java b/src/main/java/org/spongepowered/common/mixin/entitycollisions/MixinEntity_Collisions.java index 72a60f646b3..aec2e494e80 100644 --- a/src/main/java/org/spongepowered/common/mixin/entitycollisions/MixinEntity_Collisions.java +++ b/src/main/java/org/spongepowered/common/mixin/entitycollisions/MixinEntity_Collisions.java @@ -136,7 +136,7 @@ public void initializeCollisionState(World worldObj) { Integer entityMaxCollision = null; if (this.mcEntity instanceof EntityItem) { - // check if all items are overidden + // check if all items are overridden entityMaxCollision = collisionMod.getEntityList().get(this.spongeEntityType.getName()); } diff --git a/src/main/java/org/spongepowered/common/registry/SpongeGameRegistry.java b/src/main/java/org/spongepowered/common/registry/SpongeGameRegistry.java index 399f2774354..e27e5f117d0 100644 --- a/src/main/java/org/spongepowered/common/registry/SpongeGameRegistry.java +++ b/src/main/java/org/spongepowered/common/registry/SpongeGameRegistry.java @@ -48,6 +48,7 @@ import org.spongepowered.api.registry.ExtraClassCatalogRegistryModule; import org.spongepowered.api.registry.RegistrationPhase; import org.spongepowered.api.registry.RegistryModule; +import org.spongepowered.api.registry.RegistryModuleAlreadyRegisteredException; import org.spongepowered.api.registry.util.PluginProvidedRegistryModule; import org.spongepowered.api.registry.util.RegistrationDependency; import org.spongepowered.api.resourcepack.ResourcePack; @@ -102,6 +103,8 @@ import java.util.Set; import java.util.function.Supplier; +import javax.annotation.Nullable; + @SuppressWarnings("deprecation") @Singleton public class SpongeGameRegistry implements GameRegistry { @@ -148,7 +151,11 @@ public void preRegistryInit() { @Override public SpongeGameRegistry registerModule(Class catalogClass, CatalogRegistryModule registryModule) { - checkArgument(!this.catalogRegistryMap.containsKey(catalogClass), "Already registered a registry module!"); + @Nullable final CatalogRegistryModule existingModule = (CatalogRegistryModule) this.catalogRegistryMap.get(catalogClass); + if (existingModule != null) { + throw new RegistryModuleAlreadyRegisteredException("Already registered a registry module!", existingModule); + } + this.catalogRegistryMap.put(catalogClass, registryModule); if (this.phase != RegistrationPhase.PRE_REGISTRY) { if (catalogClass.getName().contains("org.spongepowered.api") && catalogClass.getAnnotation(PluginProvidedRegistryModule.class) == null) {