diff --git a/src/main/java/com/sk89q/worldedit/EditSessionFactory.java b/src/main/java/com/sk89q/worldedit/EditSessionFactory.java index cf3eb79b2..420bfd8c5 100644 --- a/src/main/java/com/sk89q/worldedit/EditSessionFactory.java +++ b/src/main/java/com/sk89q/worldedit/EditSessionFactory.java @@ -19,28 +19,14 @@ package com.sk89q.worldedit; -import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.event.extent.EditSessionEvent; -import com.sk89q.worldedit.util.eventbus.EventBus; - -import static com.google.common.base.Preconditions.checkNotNull; +import com.sk89q.worldedit.extent.inventory.BlockBag; /** - * A factory for {@link EditSession}s. + * @deprecated To wrap {@link EditSession}s, please hook into {@link EditSessionEvent} */ -public final class EditSessionFactory { - - private final EventBus eventBus; - - /** - * Create a new factory. - * - * @param eventBus the event bus - */ - public EditSessionFactory(EventBus eventBus) { - checkNotNull(eventBus); - this.eventBus = eventBus; - } +@Deprecated +public class EditSessionFactory { /** * Construct an edit session with a maximum number of blocks. @@ -49,7 +35,7 @@ public final class EditSessionFactory { * @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit */ public EditSession getEditSession(LocalWorld world, int maxBlocks) { - return new EditSession(eventBus, world, maxBlocks, null, new EditSessionEvent(world, null, maxBlocks)); + throw new IllegalArgumentException("This class is being removed"); } /** @@ -60,7 +46,7 @@ public final class EditSessionFactory { * @param player the player that the {@link EditSession} is for */ public EditSession getEditSession(LocalWorld world, int maxBlocks, LocalPlayer player) { - return new EditSession(eventBus, world, maxBlocks, null, new EditSessionEvent(world, player, maxBlocks)); + throw new IllegalArgumentException("This class is being removed"); } /** @@ -71,7 +57,7 @@ public final class EditSessionFactory { * @param blockBag an optional {@link BlockBag} to use, otherwise null */ public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag) { - return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, null, maxBlocks)); + throw new IllegalArgumentException("This class is being removed"); } /** @@ -83,7 +69,7 @@ public final class EditSessionFactory { * @param player the player that the {@link EditSession} is for */ public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) { - return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, player, maxBlocks)); + throw new IllegalArgumentException("This class is being removed"); } } diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 0423172a4..839325820 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -36,6 +36,7 @@ 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; +import com.sk89q.worldedit.internal.InternalEditSessionFactory; import com.sk89q.worldedit.masks.Mask; import com.sk89q.worldedit.patterns.Pattern; import com.sk89q.worldedit.regions.RegionSelector; @@ -72,7 +73,7 @@ public class WorldEdit { private final LocalConfiguration config; private final CommandsManager commands; private final EventBus eventBus = new EventBus(); - private final EditSessionFactory editSessionFactory = new EditSessionFactory(eventBus); + private final EditSessionFactory editSessionFactory = new InternalEditSessionFactory(eventBus); private final HashMap sessions = new HashMap(); private final BlockRegistry blockRegistry = new BlockRegistry(this); diff --git a/src/main/java/com/sk89q/worldedit/internal/InternalEditSessionFactory.java b/src/main/java/com/sk89q/worldedit/internal/InternalEditSessionFactory.java new file mode 100644 index 000000000..6b4b7682b --- /dev/null +++ b/src/main/java/com/sk89q/worldedit/internal/InternalEditSessionFactory.java @@ -0,0 +1,70 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.internal; + +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.EditSessionFactory; +import com.sk89q.worldedit.LocalPlayer; +import com.sk89q.worldedit.LocalWorld; +import com.sk89q.worldedit.event.extent.EditSessionEvent; +import com.sk89q.worldedit.extent.inventory.BlockBag; +import com.sk89q.worldedit.util.eventbus.EventBus; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Internal factory for {@link EditSession}s. + */ +@SuppressWarnings("deprecation") +public final class InternalEditSessionFactory extends EditSessionFactory { + + private final EventBus eventBus; + + /** + * Create a new factory. + * + * @param eventBus the event bus + */ + public InternalEditSessionFactory(EventBus eventBus) { + checkNotNull(eventBus); + this.eventBus = eventBus; + } + + @Override + public EditSession getEditSession(LocalWorld world, int maxBlocks) { + return new EditSession(eventBus, world, maxBlocks, null, new EditSessionEvent(world, null, maxBlocks)); + } + + @Override + public EditSession getEditSession(LocalWorld world, int maxBlocks, LocalPlayer player) { + return new EditSession(eventBus, world, maxBlocks, null, new EditSessionEvent(world, player, maxBlocks)); + } + + @Override + public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag) { + return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, null, maxBlocks)); + } + + @Override + public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) { + return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, player, maxBlocks)); + } + +} \ No newline at end of file