From 7463fdef79b457ec4948277f6c621e2b1eca04b1 Mon Sep 17 00:00:00 2001 From: sk89q Date: Tue, 8 Jul 2014 17:39:33 -0700 Subject: [PATCH] BlockRegistry, MaskRegistry, PatternRegistry -> *Factory 'Registry' will need to be used for the block, entity, item, and so on registries. --- .../java/com/sk89q/worldedit/WorldEdit.java | 60 +++++++++---------- .../BlockFactory.java} | 10 ++-- .../DefaultBlockParser.java | 2 +- .../DefaultMaskParser.java | 4 +- .../HashTagPatternParser.java | 2 +- .../MaskFactory.java} | 10 ++-- .../PatternFactory.java} | 10 ++-- .../RandomPatternParser.java | 4 +- .../SingleBlockPatternParser.java | 4 +- .../extension/input/ParserContext.java | 4 +- .../internal/command/WorldEditBinding.java | 6 +- ...ractRegistry.java => AbstractFactory.java} | 10 ++-- .../internal/registry/InputParser.java | 2 +- 13 files changed, 64 insertions(+), 64 deletions(-) rename src/main/java/com/sk89q/worldedit/extension/{registry/BlockRegistry.java => factory/BlockFactory.java} (88%) rename src/main/java/com/sk89q/worldedit/extension/{registry => factory}/DefaultBlockParser.java (99%) rename src/main/java/com/sk89q/worldedit/extension/{registry => factory}/DefaultMaskParser.java (97%) rename src/main/java/com/sk89q/worldedit/extension/{registry => factory}/HashTagPatternParser.java (98%) rename src/main/java/com/sk89q/worldedit/extension/{registry/MaskRegistry.java => factory/MaskFactory.java} (82%) rename src/main/java/com/sk89q/worldedit/extension/{registry/PatternRegistry.java => factory/PatternFactory.java} (83%) rename src/main/java/com/sk89q/worldedit/extension/{registry => factory}/RandomPatternParser.java (95%) rename src/main/java/com/sk89q/worldedit/extension/{registry => factory}/SingleBlockPatternParser.java (91%) rename src/main/java/com/sk89q/worldedit/internal/registry/{AbstractRegistry.java => AbstractFactory.java} (88%) diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 1a0d25a5e..2b451409d 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -27,13 +27,13 @@ import com.sk89q.worldedit.event.extent.EditSessionEvent; import com.sk89q.worldedit.event.platform.BlockInteractEvent; import com.sk89q.worldedit.event.platform.InputType; import com.sk89q.worldedit.event.platform.PlayerInputEvent; +import com.sk89q.worldedit.extension.factory.BlockFactory; +import com.sk89q.worldedit.extension.factory.MaskFactory; +import com.sk89q.worldedit.extension.factory.PatternFactory; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.PlatformManager; -import com.sk89q.worldedit.extension.registry.BlockRegistry; -import com.sk89q.worldedit.extension.registry.MaskRegistry; -import com.sk89q.worldedit.extension.registry.PatternRegistry; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.pattern.Patterns; @@ -84,9 +84,9 @@ public class WorldEdit { private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus); private final SessionManager sessions = new SessionManager(this); - private final BlockRegistry blockRegistry = new BlockRegistry(this); - private final MaskRegistry maskRegistry = new MaskRegistry(this); - private final PatternRegistry patternRegistry = new PatternRegistry(this); + private final BlockFactory blockFactory = new BlockFactory(this); + private final MaskFactory maskFactory = new MaskFactory(this); + private final PatternFactory patternFactory = new PatternFactory(this); static { WorldEditPrefixHandler.register("com.sk89q.worldedit"); @@ -132,33 +132,33 @@ public class WorldEdit { } /** - * Get the block registry from which new {@link BaseBlock}s can be + * Get the block factory from which new {@link BaseBlock}s can be * constructed. * - * @return the block registry + * @return the block factory */ - public BlockRegistry getBlockRegistry() { - return blockRegistry; + public BlockFactory getBlockFactory() { + return blockFactory; } /** - * Get the mask registry from which new {@link com.sk89q.worldedit.function.mask.Mask}s + * Get the mask factory from which new {@link com.sk89q.worldedit.function.mask.Mask}s * can be constructed. * - * @return the mask registry + * @return the mask factory */ - public MaskRegistry getMaskRegistry() { - return maskRegistry; + public MaskFactory getMaskFactory() { + return maskFactory; } /** - * Get the pattern registry from which new {@link com.sk89q.worldedit.function.pattern.Pattern}s + * Get the pattern factory from which new {@link com.sk89q.worldedit.function.pattern.Pattern}s * can be constructed. * - * @return the pattern registry + * @return the pattern factory */ - public PatternRegistry getPatternRegistry() { - return patternRegistry; + public PatternFactory getPatternFactory() { + return patternFactory; } /** @@ -211,7 +211,7 @@ public class WorldEdit { } /** - * @deprecated Use {@link #getBlockRegistry()} and {@link BlockRegistry#parseFromInput(String, ParserContext)} + * @deprecated Use {@link #getBlockFactory()} and {@link BlockFactory#parseFromInput(String, ParserContext)} */ @SuppressWarnings("deprecation") @Deprecated @@ -220,7 +220,7 @@ public class WorldEdit { } /** - * @deprecated Use {@link #getBlockRegistry()} and {@link BlockRegistry#parseFromInput(String, ParserContext)} + * @deprecated Use {@link #getBlockFactory()} and {@link BlockFactory#parseFromInput(String, ParserContext)} */ @SuppressWarnings("deprecation") @Deprecated @@ -231,11 +231,11 @@ public class WorldEdit { context.setSession(getSession(player)); context.setRestricted(!allAllowed); context.setPreferringWildcard(allowNoData); - return getBlockRegistry().parseFromInput(arg, context); + return getBlockFactory().parseFromInput(arg, context); } /** - * @deprecated Use {@link #getBlockRegistry()} and {@link BlockRegistry#parseFromInput(String, ParserContext)} + * @deprecated Use {@link #getBlockFactory()} and {@link BlockFactory#parseFromInput(String, ParserContext)} */ @SuppressWarnings("deprecation") @Deprecated @@ -244,7 +244,7 @@ public class WorldEdit { } /** - * @deprecated Use {@link #getBlockRegistry()} and {@link BlockRegistry#parseFromListInput(String, ParserContext)} + * @deprecated Use {@link #getBlockFactory()} and {@link BlockFactory#parseFromListInput(String, ParserContext)} */ @Deprecated @SuppressWarnings("deprecation") @@ -258,7 +258,7 @@ public class WorldEdit { } /** - * @deprecated Use {@link #getBlockRegistry()} and {@link BlockRegistry#parseFromInput(String, ParserContext)} + * @deprecated Use {@link #getBlockFactory()} and {@link BlockFactory#parseFromInput(String, ParserContext)} */ @Deprecated @SuppressWarnings("deprecation") @@ -267,7 +267,7 @@ public class WorldEdit { } /** - * @deprecated Use {@link #getBlockRegistry()} and {@link BlockRegistry#parseFromListInput(String, ParserContext)} + * @deprecated Use {@link #getBlockFactory()} and {@link BlockFactory#parseFromListInput(String, ParserContext)} */ @Deprecated @SuppressWarnings("deprecation") @@ -276,7 +276,7 @@ public class WorldEdit { } /** - * @deprecated Use {@link #getBlockRegistry()} and {@link BlockRegistry#parseFromListInput(String, ParserContext)} + * @deprecated Use {@link #getBlockFactory()} and {@link BlockFactory#parseFromListInput(String, ParserContext)} */ @Deprecated @SuppressWarnings("deprecation") @@ -290,7 +290,7 @@ public class WorldEdit { } /** - * @deprecated Use {@link #getPatternRegistry()} and {@link BlockRegistry#parseFromInput(String, ParserContext)} + * @deprecated Use {@link #getPatternFactory()} and {@link BlockFactory#parseFromInput(String, ParserContext)} */ @Deprecated @SuppressWarnings("deprecation") @@ -299,11 +299,11 @@ public class WorldEdit { context.setActor(player); context.setWorld(player.getWorld()); context.setSession(getSession(player)); - return Patterns.wrap(getPatternRegistry().parseFromInput(input, context)); + return Patterns.wrap(getPatternFactory().parseFromInput(input, context)); } /** - * @deprecated Use {@link #getMaskRegistry()} ()} and {@link MaskRegistry#parseFromInput(String, ParserContext)} + * @deprecated Use {@link #getMaskFactory()} ()} and {@link MaskFactory#parseFromInput(String, ParserContext)} */ @Deprecated @SuppressWarnings("deprecation") @@ -312,7 +312,7 @@ public class WorldEdit { context.setActor(player); context.setWorld(player.getWorld()); context.setSession(session); - return Masks.wrap(getMaskRegistry().parseFromInput(input, context)); + return Masks.wrap(getMaskFactory().parseFromInput(input, context)); } /** diff --git a/src/main/java/com/sk89q/worldedit/extension/registry/BlockRegistry.java b/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java similarity index 88% rename from src/main/java/com/sk89q/worldedit/extension/registry/BlockRegistry.java rename to src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java index 2bd118015..2cb5c9d1d 100644 --- a/src/main/java/com/sk89q/worldedit/extension/registry/BlockRegistry.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java @@ -17,13 +17,13 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.extension.registry; +package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.InputParseException; -import com.sk89q.worldedit.internal.registry.AbstractRegistry; +import com.sk89q.worldedit.internal.registry.AbstractFactory; import java.util.HashSet; import java.util.Set; @@ -33,16 +33,16 @@ import java.util.Set; * new blocks from input. *

* Instances of this class can be taken from - * {@link WorldEdit#getBlockRegistry()}. + * {@link WorldEdit#getBlockFactory()}. */ -public class BlockRegistry extends AbstractRegistry { +public class BlockFactory extends AbstractFactory { /** * Create a new instance. * * @param worldEdit the WorldEdit instance. */ - public BlockRegistry(WorldEdit worldEdit) { + public BlockFactory(WorldEdit worldEdit) { super(worldEdit); parsers.add(new DefaultBlockParser(worldEdit)); diff --git a/src/main/java/com/sk89q/worldedit/extension/registry/DefaultBlockParser.java b/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java similarity index 99% rename from src/main/java/com/sk89q/worldedit/extension/registry/DefaultBlockParser.java rename to src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java index fe7a63b09..3ecbc15fb 100644 --- a/src/main/java/com/sk89q/worldedit/extension/registry/DefaultBlockParser.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.extension.registry; +package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.*; import com.sk89q.worldedit.blocks.*; diff --git a/src/main/java/com/sk89q/worldedit/extension/registry/DefaultMaskParser.java b/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java similarity index 97% rename from src/main/java/com/sk89q/worldedit/extension/registry/DefaultMaskParser.java rename to src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java index 304a49b60..9b6dfdf94 100644 --- a/src/main/java/com/sk89q/worldedit/extension/registry/DefaultMaskParser.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.extension.registry; +package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.*; import com.sk89q.worldedit.extension.input.InputParseException; @@ -135,7 +135,7 @@ class DefaultMaskParser extends InputParser { ParserContext tempContext = new ParserContext(context); tempContext.setRestricted(false); tempContext.setPreferringWildcard(true); - return new BlockMask(extent, worldEdit.getBlockRegistry().parseFromListInput(component, tempContext)); + return new BlockMask(extent, worldEdit.getBlockFactory().parseFromListInput(component, tempContext)); } } diff --git a/src/main/java/com/sk89q/worldedit/extension/registry/HashTagPatternParser.java b/src/main/java/com/sk89q/worldedit/extension/factory/HashTagPatternParser.java similarity index 98% rename from src/main/java/com/sk89q/worldedit/extension/registry/HashTagPatternParser.java rename to src/main/java/com/sk89q/worldedit/extension/factory/HashTagPatternParser.java index 63da1c402..1c7a0d646 100644 --- a/src/main/java/com/sk89q/worldedit/extension/registry/HashTagPatternParser.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/HashTagPatternParser.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.extension.registry; +package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.LocalSession; diff --git a/src/main/java/com/sk89q/worldedit/extension/registry/MaskRegistry.java b/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java similarity index 82% rename from src/main/java/com/sk89q/worldedit/extension/registry/MaskRegistry.java rename to src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java index fa4fb9e58..309992bcb 100644 --- a/src/main/java/com/sk89q/worldedit/extension/registry/MaskRegistry.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java @@ -17,27 +17,27 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.extension.registry; +package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.internal.registry.AbstractRegistry; +import com.sk89q.worldedit.internal.registry.AbstractFactory; /** * A registry of known {@link Mask}s. Provides methods to instantiate * new masks from input. *

* Instances of this class can be taken from - * {@link WorldEdit#getMaskRegistry()}. + * {@link WorldEdit#getMaskFactory()}. */ -public final class MaskRegistry extends AbstractRegistry { +public final class MaskFactory extends AbstractFactory { /** * Create a new mask registry. * * @param worldEdit the WorldEdit instance */ - public MaskRegistry(WorldEdit worldEdit) { + public MaskFactory(WorldEdit worldEdit) { super(worldEdit); parsers.add(new DefaultMaskParser(worldEdit)); diff --git a/src/main/java/com/sk89q/worldedit/extension/registry/PatternRegistry.java b/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java similarity index 83% rename from src/main/java/com/sk89q/worldedit/extension/registry/PatternRegistry.java rename to src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java index daab33cac..e19891148 100644 --- a/src/main/java/com/sk89q/worldedit/extension/registry/PatternRegistry.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java @@ -17,27 +17,27 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.extension.registry; +package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.internal.registry.AbstractRegistry; +import com.sk89q.worldedit.internal.registry.AbstractFactory; /** * A registry of known {@link Pattern}s. Provides methods to instantiate * new patterns from input. *

* Instances of this class can be taken from - * {@link WorldEdit#getPatternRegistry()}. + * {@link WorldEdit#getPatternFactory()}. */ -public final class PatternRegistry extends AbstractRegistry { +public final class PatternFactory extends AbstractFactory { /** * Create a new instance. * * @param worldEdit the WorldEdit instance */ - public PatternRegistry(WorldEdit worldEdit) { + public PatternFactory(WorldEdit worldEdit) { super(worldEdit); parsers.add(new HashTagPatternParser(worldEdit)); diff --git a/src/main/java/com/sk89q/worldedit/extension/registry/RandomPatternParser.java b/src/main/java/com/sk89q/worldedit/extension/factory/RandomPatternParser.java similarity index 95% rename from src/main/java/com/sk89q/worldedit/extension/registry/RandomPatternParser.java rename to src/main/java/com/sk89q/worldedit/extension/factory/RandomPatternParser.java index d07f94e03..a850b98ff 100644 --- a/src/main/java/com/sk89q/worldedit/extension/registry/RandomPatternParser.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/RandomPatternParser.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.extension.registry; +package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.blocks.BaseBlock; @@ -36,7 +36,7 @@ class RandomPatternParser extends InputParser { @Override public Pattern parseFromInput(String input, ParserContext context) throws InputParseException { - BlockRegistry blockRegistry = worldEdit.getBlockRegistry(); + BlockFactory blockRegistry = worldEdit.getBlockFactory(); RandomPattern randomPattern = new RandomPattern(); for (String token : input.split(",")) { diff --git a/src/main/java/com/sk89q/worldedit/extension/registry/SingleBlockPatternParser.java b/src/main/java/com/sk89q/worldedit/extension/factory/SingleBlockPatternParser.java similarity index 91% rename from src/main/java/com/sk89q/worldedit/extension/registry/SingleBlockPatternParser.java rename to src/main/java/com/sk89q/worldedit/extension/factory/SingleBlockPatternParser.java index a1a11fa10..17833cf97 100644 --- a/src/main/java/com/sk89q/worldedit/extension/registry/SingleBlockPatternParser.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/SingleBlockPatternParser.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.extension.registry; +package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.ParserContext; @@ -37,7 +37,7 @@ class SingleBlockPatternParser extends InputParser { String[] items = input.split(","); if (items.length == 1) { - return new BlockPattern(worldEdit.getBlockRegistry().parseFromInput(items[0], context)); + return new BlockPattern(worldEdit.getBlockFactory().parseFromInput(items[0], context)); } else { return null; } diff --git a/src/main/java/com/sk89q/worldedit/extension/input/ParserContext.java b/src/main/java/com/sk89q/worldedit/extension/input/ParserContext.java index 9d2b56f19..383ee280e 100644 --- a/src/main/java/com/sk89q/worldedit/extension/input/ParserContext.java +++ b/src/main/java/com/sk89q/worldedit/extension/input/ParserContext.java @@ -20,8 +20,8 @@ package com.sk89q.worldedit.extension.input; import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.extension.factory.MaskFactory; import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.extension.registry.MaskRegistry; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.world.World; @@ -29,7 +29,7 @@ import javax.annotation.Nullable; /** * Contains contextual information that may be useful when constructing - * objects from a registry (such as {@link MaskRegistry}). + * objects from a registry (such as {@link MaskFactory}). *

* By default, {@link #isRestricted()} will return true. */ diff --git a/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java b/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java index 019c1cc72..7a6aa4ad3 100644 --- a/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java +++ b/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java @@ -178,7 +178,7 @@ public class WorldEditBinding extends BindingHelper { } parserContext.setSession(worldEdit.getSessionManager().get(actor)); try { - return worldEdit.getBlockRegistry().parseFromInput(context.next(), parserContext); + return worldEdit.getBlockFactory().parseFromInput(context.next(), parserContext); } catch (NoMatchException e) { throw new ParameterException(e.getMessage(), e); } @@ -207,7 +207,7 @@ public class WorldEditBinding extends BindingHelper { } parserContext.setSession(worldEdit.getSessionManager().get(actor)); try { - return worldEdit.getPatternRegistry().parseFromInput(context.next(), parserContext); + return worldEdit.getPatternFactory().parseFromInput(context.next(), parserContext); } catch (NoMatchException e) { throw new ParameterException(e.getMessage(), e); } @@ -236,7 +236,7 @@ public class WorldEditBinding extends BindingHelper { } parserContext.setSession(worldEdit.getSessionManager().get(actor)); try { - return worldEdit.getMaskRegistry().parseFromInput(context.next(), parserContext); + return worldEdit.getMaskFactory().parseFromInput(context.next(), parserContext); } catch (NoMatchException e) { throw new ParameterException(e.getMessage(), e); } diff --git a/src/main/java/com/sk89q/worldedit/internal/registry/AbstractRegistry.java b/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java similarity index 88% rename from src/main/java/com/sk89q/worldedit/internal/registry/AbstractRegistry.java rename to src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java index b466b5bb9..95563fcc0 100644 --- a/src/main/java/com/sk89q/worldedit/internal/registry/AbstractRegistry.java +++ b/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java @@ -30,22 +30,22 @@ import java.util.List; import static com.google.common.base.Preconditions.checkNotNull; /** - * An abstract implementation of a registry for internal usage. + * An abstract implementation of a factory for internal usage. * - * @param the element that the registry returns + * @param the element that the factory returns */ @SuppressWarnings("ProtectedField") -public abstract class AbstractRegistry { +public abstract class AbstractFactory { protected final WorldEdit worldEdit; protected final List> parsers = new ArrayList>(); /** - * Create a new registry. + * Create a new factory. * * @param worldEdit the WorldEdit instance */ - protected AbstractRegistry(WorldEdit worldEdit) { + protected AbstractFactory(WorldEdit worldEdit) { checkNotNull(worldEdit); this.worldEdit = worldEdit; } diff --git a/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java b/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java index afe702852..059c95ba4 100644 --- a/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java +++ b/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java @@ -24,7 +24,7 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.InputParseException; /** - * Input parser interface for {@link AbstractRegistry}. + * Input parser interface for {@link AbstractFactory}. * * @param the element */