2014-04-03 01:57:25 +00:00
|
|
|
/*
|
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
2014-04-03 01:57:25 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* 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 Lesser General Public License
|
|
|
|
* for more details.
|
2014-04-03 01:57:25 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-04-03 01:57:25 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-10-18 10:34:09 +00:00
|
|
|
package com.sk89q.worldedit;
|
|
|
|
|
2014-06-27 23:03:29 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
2014-04-03 01:57:25 +00:00
|
|
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
2014-04-04 00:56:21 +00:00
|
|
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
2014-04-04 03:48:42 +00:00
|
|
|
import com.sk89q.worldedit.util.eventbus.EventBus;
|
2014-04-05 09:59:38 +00:00
|
|
|
import com.sk89q.worldedit.world.World;
|
2014-04-04 03:48:42 +00:00
|
|
|
|
|
|
|
import static com.google.common.base.Preconditions.checkNotNull;
|
2014-04-03 01:57:25 +00:00
|
|
|
|
|
|
|
/**
|
2014-04-04 03:48:42 +00:00
|
|
|
* Creates new {@link EditSession}s. To get an instance of this factory,
|
|
|
|
* use {@link WorldEdit#getEditSessionFactory()}.
|
|
|
|
* </p>
|
|
|
|
* It is no longer possible to replace the instance of this in WorldEdit
|
|
|
|
* with a custom one. Use {@link EditSessionEvent} to override
|
|
|
|
* the creation of {@link EditSession}s.
|
2014-04-03 01:57:25 +00:00
|
|
|
*/
|
2014-04-04 00:56:21 +00:00
|
|
|
public class EditSessionFactory {
|
2012-11-13 10:07:08 +00:00
|
|
|
|
2014-04-05 09:59:38 +00:00
|
|
|
@Deprecated
|
|
|
|
public EditSession getEditSession(LocalWorld world, int maxBlocks) {
|
|
|
|
return getEditSession((World) world, maxBlocks);
|
|
|
|
}
|
|
|
|
|
2012-10-18 10:34:09 +00:00
|
|
|
/**
|
|
|
|
* Construct an edit session with a maximum number of blocks.
|
|
|
|
*
|
2014-04-03 01:57:25 +00:00
|
|
|
* @param world the world
|
|
|
|
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
|
2012-10-18 10:34:09 +00:00
|
|
|
*/
|
2014-04-05 09:59:38 +00:00
|
|
|
public EditSession getEditSession(World world, int maxBlocks) {
|
2014-04-04 00:56:21 +00:00
|
|
|
throw new IllegalArgumentException("This class is being removed");
|
2012-10-18 10:34:09 +00:00
|
|
|
}
|
2012-11-13 10:07:08 +00:00
|
|
|
|
2014-04-05 09:59:38 +00:00
|
|
|
@Deprecated
|
|
|
|
public EditSession getEditSession(LocalWorld world, int maxBlocks, LocalPlayer player) {
|
|
|
|
return getEditSession((World) world, maxBlocks, player);
|
|
|
|
}
|
|
|
|
|
2012-11-13 10:07:08 +00:00
|
|
|
/**
|
|
|
|
* Construct an edit session with a maximum number of blocks.
|
|
|
|
*
|
2014-04-03 01:57:25 +00:00
|
|
|
* @param world the world
|
|
|
|
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
|
|
|
|
* @param player the player that the {@link EditSession} is for
|
2012-11-13 10:07:08 +00:00
|
|
|
*/
|
2014-06-27 23:03:29 +00:00
|
|
|
public EditSession getEditSession(World world, int maxBlocks, Player player) {
|
2014-04-04 00:56:21 +00:00
|
|
|
throw new IllegalArgumentException("This class is being removed");
|
2012-11-13 10:07:08 +00:00
|
|
|
}
|
|
|
|
|
2014-04-05 09:59:38 +00:00
|
|
|
@Deprecated
|
|
|
|
public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag) {
|
|
|
|
return getEditSession((World) world, maxBlocks, blockBag);
|
|
|
|
}
|
|
|
|
|
2012-10-18 10:34:09 +00:00
|
|
|
/**
|
|
|
|
* Construct an edit session with a maximum number of blocks and a block bag.
|
|
|
|
*
|
2014-04-03 01:57:25 +00:00
|
|
|
* @param world the world
|
|
|
|
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
|
|
|
|
* @param blockBag an optional {@link BlockBag} to use, otherwise null
|
2012-10-18 10:34:09 +00:00
|
|
|
*/
|
2014-04-05 09:59:38 +00:00
|
|
|
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag) {
|
2014-04-04 00:56:21 +00:00
|
|
|
throw new IllegalArgumentException("This class is being removed");
|
2012-10-18 10:34:09 +00:00
|
|
|
}
|
|
|
|
|
2014-04-05 09:59:38 +00:00
|
|
|
@Deprecated
|
|
|
|
public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) {
|
|
|
|
return getEditSession((World) world, maxBlocks, blockBag, player);
|
|
|
|
}
|
|
|
|
|
2012-11-13 10:07:08 +00:00
|
|
|
/**
|
|
|
|
* Construct an edit session with a maximum number of blocks and a block bag.
|
|
|
|
*
|
2014-04-03 01:57:25 +00:00
|
|
|
* @param world the world
|
|
|
|
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
|
|
|
|
* @param blockBag an optional {@link BlockBag} to use, otherwise null
|
|
|
|
* @param player the player that the {@link EditSession} is for
|
2012-11-13 10:07:08 +00:00
|
|
|
*/
|
2014-06-27 23:03:29 +00:00
|
|
|
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag, Player player) {
|
2014-04-04 00:56:21 +00:00
|
|
|
throw new IllegalArgumentException("This class is being removed");
|
2012-11-13 10:07:08 +00:00
|
|
|
}
|
|
|
|
|
2014-04-04 03:48:42 +00:00
|
|
|
/**
|
|
|
|
* Internal factory for {@link EditSession}s.
|
|
|
|
*/
|
|
|
|
static final class EditSessionFactoryImpl extends EditSessionFactory {
|
|
|
|
|
|
|
|
private final EventBus eventBus;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new factory.
|
|
|
|
*
|
|
|
|
* @param eventBus the event bus
|
|
|
|
*/
|
|
|
|
public EditSessionFactoryImpl(EventBus eventBus) {
|
|
|
|
checkNotNull(eventBus);
|
|
|
|
this.eventBus = eventBus;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-04-05 09:59:38 +00:00
|
|
|
public EditSession getEditSession(World world, int maxBlocks) {
|
2014-04-04 03:48:42 +00:00
|
|
|
return new EditSession(eventBus, world, maxBlocks, null, new EditSessionEvent(world, null, maxBlocks, null));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-27 23:03:29 +00:00
|
|
|
public EditSession getEditSession(World world, int maxBlocks, Player player) {
|
2014-04-04 03:48:42 +00:00
|
|
|
return new EditSession(eventBus, world, maxBlocks, null, new EditSessionEvent(world, player, maxBlocks, null));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-04-05 09:59:38 +00:00
|
|
|
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag) {
|
2014-04-04 03:48:42 +00:00
|
|
|
return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, null, maxBlocks, null));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-27 23:03:29 +00:00
|
|
|
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag, Player player) {
|
2014-04-04 03:48:42 +00:00
|
|
|
return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, player, maxBlocks, null));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-10-18 10:34:09 +00:00
|
|
|
}
|