Removed binary-incompatible changes to EditSessionFactory.

This commit is contained in:
sk89q 2014-04-03 17:56:21 -07:00
parent 9d08f266bf
commit c8e455cd6f
3 changed files with 80 additions and 23 deletions

View File

@ -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");
}
}

View File

@ -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<LocalPlayer> commands;
private final EventBus eventBus = new EventBus();
private final EditSessionFactory editSessionFactory = new EditSessionFactory(eventBus);
private final EditSessionFactory editSessionFactory = new InternalEditSessionFactory(eventBus);
private final HashMap<String, LocalSession> sessions = new HashMap<String, LocalSession>();
private final BlockRegistry blockRegistry = new BlockRegistry(this);

View File

@ -0,0 +1,70 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
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));
}
}