2010-09-30 06:41:05 +00:00
|
|
|
/*
|
2014-04-04 22:03:18 +00:00
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
2010-09-30 06:41:05 +00:00
|
|
|
*
|
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
|
2010-09-30 06:41:05 +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.
|
2010-09-30 06:41:05 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2010-09-30 06:41:05 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-04-04 22:03:18 +00:00
|
|
|
*/
|
2010-09-30 06:41:05 +00:00
|
|
|
|
2011-01-01 01:40:07 +00:00
|
|
|
package com.sk89q.worldedit;
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
import static com.google.common.base.Preconditions.checkNotNull;
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.boydti.fawe.Fawe;
|
|
|
|
import com.boydti.fawe.config.Settings;
|
|
|
|
import com.boydti.fawe.object.FaweInputStream;
|
|
|
|
import com.boydti.fawe.object.FaweLimit;
|
|
|
|
import com.boydti.fawe.object.FaweOutputStream;
|
|
|
|
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
|
|
|
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
|
|
|
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
|
|
|
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
|
|
|
import com.boydti.fawe.object.collection.SparseBitSet;
|
|
|
|
import com.boydti.fawe.object.extent.ResettableExtent;
|
2019-06-28 22:03:24 +00:00
|
|
|
import com.boydti.fawe.util.BrushCache;
|
|
|
|
import com.boydti.fawe.util.EditSessionBuilder;
|
|
|
|
import com.boydti.fawe.util.MainUtil;
|
|
|
|
import com.boydti.fawe.util.StringMan;
|
|
|
|
import com.boydti.fawe.util.TextureHolder;
|
|
|
|
import com.boydti.fawe.util.TextureUtil;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.boydti.fawe.wrappers.WorldWrapper;
|
2019-10-30 11:58:21 +00:00
|
|
|
import com.google.common.collect.Maps;
|
2011-03-14 03:23:55 +00:00
|
|
|
import com.sk89q.jchronic.Chronic;
|
|
|
|
import com.sk89q.jchronic.Options;
|
|
|
|
import com.sk89q.jchronic.utils.Span;
|
|
|
|
import com.sk89q.jchronic.utils.Time;
|
2019-01-09 07:13:44 +00:00
|
|
|
import com.sk89q.jnbt.IntTag;
|
|
|
|
import com.sk89q.jnbt.Tag;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BaseItem;
|
|
|
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
2019-06-28 22:03:24 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.BlockTool;
|
|
|
|
import com.sk89q.worldedit.command.tool.BrushTool;
|
|
|
|
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
2019-10-23 04:23:52 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.NavigationWand;
|
|
|
|
import com.sk89q.worldedit.command.tool.SelectionWand;
|
2019-06-28 22:03:24 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.SinglePickaxe;
|
|
|
|
import com.sk89q.worldedit.command.tool.Tool;
|
2014-06-27 23:03:29 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
2014-04-05 09:59:38 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.Actor;
|
2019-08-06 15:29:09 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.Locatable;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.function.mask.Mask;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
|
|
|
|
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
2014-04-04 00:52:53 +00:00
|
|
|
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
2018-12-23 16:19:33 +00:00
|
|
|
import com.sk89q.worldedit.internal.cui.ServerCUIHandler;
|
|
|
|
import com.sk89q.worldedit.math.BlockVector3;
|
2010-10-14 08:31:05 +00:00
|
|
|
import com.sk89q.worldedit.regions.Region;
|
2014-04-04 02:50:05 +00:00
|
|
|
import com.sk89q.worldedit.regions.RegionSelector;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
2014-07-29 03:53:17 +00:00
|
|
|
import com.sk89q.worldedit.regions.selector.RegionSelectorType;
|
2014-07-02 09:56:21 +00:00
|
|
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.util.Countable;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.util.HandSide;
|
2019-08-26 04:45:03 +00:00
|
|
|
import com.sk89q.worldedit.util.Identifiable;
|
2014-04-05 09:59:38 +00:00
|
|
|
import com.sk89q.worldedit.world.World;
|
2019-06-28 22:03:24 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BlockState;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.world.item.ItemType;
|
|
|
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
2014-04-04 00:52:53 +00:00
|
|
|
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
2019-10-23 04:23:52 +00:00
|
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
2019-04-03 11:28:57 +00:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.IOException;
|
2019-07-06 00:46:48 +00:00
|
|
|
import java.time.ZoneId;
|
2014-07-09 21:14:17 +00:00
|
|
|
import java.util.Calendar;
|
2019-10-30 11:58:21 +00:00
|
|
|
import java.util.Collection;
|
2019-04-03 11:28:57 +00:00
|
|
|
import java.util.Collections;
|
2019-10-30 11:58:21 +00:00
|
|
|
import java.util.HashMap;
|
2019-10-23 04:23:52 +00:00
|
|
|
import java.util.IdentityHashMap;
|
2014-07-09 21:14:17 +00:00
|
|
|
import java.util.LinkedList;
|
2019-04-03 11:28:57 +00:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.ListIterator;
|
2014-07-09 21:14:17 +00:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.TimeZone;
|
2019-04-03 11:28:57 +00:00
|
|
|
import java.util.UUID;
|
2014-07-28 03:44:05 +00:00
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
2019-07-06 00:46:48 +00:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
import javax.annotation.Nullable;
|
2014-07-28 03:44:05 +00:00
|
|
|
|
2010-09-30 06:41:05 +00:00
|
|
|
/**
|
2014-07-28 03:44:05 +00:00
|
|
|
* Stores session information.
|
2010-09-30 06:41:05 +00:00
|
|
|
*/
|
2018-08-12 14:03:07 +00:00
|
|
|
public class LocalSession implements TextureHolder {
|
2014-07-19 22:40:44 +00:00
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
public static transient int MAX_HISTORY_SIZE = 15;
|
2014-07-28 03:44:05 +00:00
|
|
|
|
|
|
|
// Non-session related fields
|
|
|
|
private transient LocalConfiguration config;
|
2019-07-06 00:46:48 +00:00
|
|
|
private final transient AtomicBoolean dirty = new AtomicBoolean();
|
2018-02-28 00:59:00 +00:00
|
|
|
private transient int failedCuiAttempts = 0;
|
2014-07-28 03:44:05 +00:00
|
|
|
|
|
|
|
// Session related
|
|
|
|
private transient RegionSelector selector = new CuboidRegionSelector();
|
|
|
|
private transient boolean placeAtPos1 = false;
|
2018-08-12 14:03:07 +00:00
|
|
|
private transient List<Object> history = Collections.synchronizedList(new LinkedList<Object>() {
|
|
|
|
@Override
|
|
|
|
public Object get(int index) {
|
|
|
|
Object value = super.get(index);
|
|
|
|
if (value instanceof Integer) {
|
|
|
|
value = getChangeSet(value);
|
|
|
|
set(index, value);
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object remove(int index) {
|
|
|
|
return getChangeSet(super.remove(index));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
private transient volatile Integer historyNegativeIndex;
|
2014-07-28 03:44:05 +00:00
|
|
|
private transient ClipboardHolder clipboard;
|
|
|
|
private transient boolean superPickaxe = false;
|
|
|
|
private transient BlockTool pickaxeMode = new SinglePickaxe();
|
2019-10-23 04:23:52 +00:00
|
|
|
private transient final Int2ObjectOpenHashMap<Tool> tools = new Int2ObjectOpenHashMap<>(0);
|
2014-07-28 03:44:05 +00:00
|
|
|
private transient int maxBlocksChanged = -1;
|
2019-03-07 00:58:32 +00:00
|
|
|
private transient int maxTimeoutTime;
|
2014-07-28 03:44:05 +00:00
|
|
|
private transient boolean useInventory;
|
|
|
|
private transient Snapshot snapshot;
|
|
|
|
private transient boolean hasCUISupport = false;
|
|
|
|
private transient int cuiVersion = -1;
|
|
|
|
private transient boolean fastMode = false;
|
|
|
|
private transient Mask mask;
|
2018-08-12 14:03:07 +00:00
|
|
|
private transient Mask sourceMask;
|
|
|
|
private transient TextureUtil texture;
|
|
|
|
private transient ResettableExtent transform = null;
|
2019-07-06 00:46:48 +00:00
|
|
|
private transient ZoneId timezone = ZoneId.systemDefault();
|
2018-08-12 14:03:07 +00:00
|
|
|
private transient World currentWorld;
|
|
|
|
private transient UUID uuid;
|
|
|
|
private transient volatile long historySize = 0;
|
|
|
|
|
|
|
|
private transient VirtualWorld virtual;
|
2018-12-23 16:19:33 +00:00
|
|
|
private transient BlockVector3 cuiTemporaryBlock;
|
2019-07-06 00:46:48 +00:00
|
|
|
private transient List<Countable<BlockState>> lastDistribution;
|
2019-09-02 19:22:43 +00:00
|
|
|
private transient World worldOverride;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2019-10-23 04:23:52 +00:00
|
|
|
private transient boolean loadDefaults = true;
|
|
|
|
|
2014-07-28 03:44:05 +00:00
|
|
|
// Saved properties
|
2011-01-23 10:09:51 +00:00
|
|
|
private String lastScript;
|
2014-07-29 03:53:17 +00:00
|
|
|
private RegionSelectorType defaultSelector;
|
2019-01-09 07:13:44 +00:00
|
|
|
private boolean useServerCUI = false; // Save this to not annoy players.
|
2019-10-23 04:23:52 +00:00
|
|
|
private ItemType wandItem;
|
|
|
|
private ItemType navWandItem;
|
2019-10-30 11:58:21 +00:00
|
|
|
private Map<String, String> macros = new HashMap<>();
|
2011-03-14 03:23:55 +00:00
|
|
|
|
2011-01-31 08:58:29 +00:00
|
|
|
/**
|
|
|
|
* Construct the object.
|
2018-12-20 16:00:27 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* <p>{@link #setConfiguration(LocalConfiguration)} should be called
|
|
|
|
* later with configuration.</p>
|
|
|
|
*/
|
|
|
|
public LocalSession() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct the object.
|
|
|
|
*
|
|
|
|
* @param config the configuration
|
|
|
|
*/
|
|
|
|
public LocalSession(@Nullable LocalConfiguration config) {
|
|
|
|
this.config = config;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the configuration.
|
|
|
|
*
|
|
|
|
* @param config the configuration
|
2011-01-31 08:58:29 +00:00
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
public void setConfiguration(LocalConfiguration config) {
|
|
|
|
checkNotNull(config);
|
2011-01-31 08:58:29 +00:00
|
|
|
this.config = config;
|
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2014-07-29 03:53:17 +00:00
|
|
|
/**
|
|
|
|
* Called on post load of the session from persistent storage.
|
|
|
|
*/
|
|
|
|
public void postLoad() {
|
|
|
|
if (defaultSelector != null) {
|
|
|
|
this.selector = defaultSelector.createSelector();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
public boolean loadSessionHistoryFromDisk(UUID uuid, World world) {
|
|
|
|
if (world == null || uuid == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (Settings.IMP.HISTORY.USE_DISK) {
|
|
|
|
MAX_HISTORY_SIZE = Integer.MAX_VALUE;
|
|
|
|
}
|
|
|
|
world = WorldWrapper.unwrap(world);
|
|
|
|
if (!world.equals(currentWorld)) {
|
|
|
|
this.uuid = uuid;
|
|
|
|
// Save history
|
|
|
|
saveHistoryNegativeIndex(uuid, currentWorld);
|
|
|
|
history.clear();
|
|
|
|
currentWorld = world;
|
|
|
|
// Load history
|
|
|
|
if (loadHistoryChangeSets(uuid, currentWorld)) {
|
|
|
|
loadHistoryNegativeIndex(uuid, currentWorld);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
historyNegativeIndex = 0;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean loadHistoryChangeSets(UUID uuid, World world) {
|
|
|
|
SparseBitSet set = new SparseBitSet();
|
2019-06-19 03:43:06 +00:00
|
|
|
final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid);
|
2018-08-12 14:03:07 +00:00
|
|
|
if (folder.isDirectory()) {
|
2019-06-12 00:40:33 +00:00
|
|
|
folder.listFiles(pathname -> {
|
|
|
|
String name = pathname.getName();
|
|
|
|
Integer val = null;
|
|
|
|
if (pathname.isDirectory()) {
|
|
|
|
val = StringMan.toInteger(name, 0, name.length());
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2019-06-12 00:40:33 +00:00
|
|
|
} else {
|
|
|
|
int i = name.lastIndexOf('.');
|
|
|
|
if (i != -1) val = StringMan.toInteger(name, 0, i);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2019-06-12 00:40:33 +00:00
|
|
|
if (val != null) set.set(val);
|
|
|
|
return false;
|
2018-08-12 14:03:07 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
if (!set.isEmpty()) {
|
|
|
|
historySize = MainUtil.getTotalSize(folder.toPath());
|
|
|
|
for (int index = set.nextSetBit(0); index != -1; index = set.nextSetBit(index + 1)) {
|
|
|
|
history.add(index);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
historySize = 0;
|
|
|
|
}
|
|
|
|
return !set.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void loadHistoryNegativeIndex(UUID uuid, World world) {
|
|
|
|
if (!Settings.IMP.HISTORY.USE_DISK) {
|
|
|
|
return;
|
|
|
|
}
|
2019-06-19 03:43:06 +00:00
|
|
|
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid + File.separator + "index");
|
2018-08-12 14:03:07 +00:00
|
|
|
if (file.exists()) {
|
2019-06-12 00:40:33 +00:00
|
|
|
try (FaweInputStream is = new FaweInputStream(new FileInputStream(file))) {
|
2018-08-12 14:03:07 +00:00
|
|
|
historyNegativeIndex = Math.min(Math.max(0, is.readInt()), history.size());
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
historyNegativeIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void saveHistoryNegativeIndex(UUID uuid, World world) {
|
|
|
|
if (world == null || !Settings.IMP.HISTORY.USE_DISK) {
|
|
|
|
return;
|
|
|
|
}
|
2019-06-19 03:43:06 +00:00
|
|
|
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid + File.separator + "index");
|
2018-08-12 14:03:07 +00:00
|
|
|
if (getHistoryNegativeIndex() != 0) {
|
|
|
|
try {
|
|
|
|
if (!file.exists()) {
|
|
|
|
file.getParentFile().mkdirs();
|
|
|
|
file.createNewFile();
|
|
|
|
}
|
2019-06-12 00:40:33 +00:00
|
|
|
try (FaweOutputStream os = new FaweOutputStream(new FileOutputStream(file))) {
|
|
|
|
os.writeInt(getHistoryNegativeIndex());
|
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
} else if (file.exists()) {
|
|
|
|
file.delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-30 11:58:21 +00:00
|
|
|
public Map<String, String> getMacros() {
|
|
|
|
return Collections.unmodifiableMap(this.macros);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMacro(String key, String value) {
|
|
|
|
this.macros.put(key, value);
|
|
|
|
setDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getMacro(String key) {
|
|
|
|
return this.macros.get(key);
|
|
|
|
}
|
|
|
|
|
2014-07-28 03:44:05 +00:00
|
|
|
/**
|
|
|
|
* Get whether this session is "dirty" and has changes that needs to
|
|
|
|
* be committed.
|
|
|
|
*
|
|
|
|
* @return true if dirty
|
|
|
|
*/
|
|
|
|
public boolean isDirty() {
|
|
|
|
return dirty.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set this session as dirty.
|
|
|
|
*/
|
|
|
|
private void setDirty() {
|
|
|
|
dirty.set(true);
|
|
|
|
}
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
public int getHistoryIndex() {
|
|
|
|
return history.size() - 1 - (historyNegativeIndex == null ? 0 : historyNegativeIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getHistoryNegativeIndex() {
|
|
|
|
return (historyNegativeIndex == null ? historyNegativeIndex = 0 : historyNegativeIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean save() {
|
|
|
|
saveHistoryNegativeIndex(uuid, currentWorld);
|
|
|
|
if (defaultSelector == RegionSelectorType.CUBOID) {
|
|
|
|
defaultSelector = null;
|
|
|
|
}
|
|
|
|
if (lastScript != null || defaultSelector != null) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-28 03:44:05 +00:00
|
|
|
/**
|
|
|
|
* Get whether this session is "dirty" and has changes that needs to
|
|
|
|
* be committed, and reset it to {@code false}.
|
|
|
|
*
|
|
|
|
* @return true if the dirty value was {@code true}
|
|
|
|
*/
|
|
|
|
public boolean compareAndResetDirty() {
|
|
|
|
return dirty.compareAndSet(true, false);
|
|
|
|
}
|
|
|
|
|
2011-03-14 03:23:55 +00:00
|
|
|
/**
|
|
|
|
* Get the session's timezone.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return the timezone
|
2011-03-14 03:23:55 +00:00
|
|
|
*/
|
2019-07-06 00:46:48 +00:00
|
|
|
public ZoneId getTimeZone() {
|
2011-03-14 03:23:55 +00:00
|
|
|
return timezone;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the session's timezone.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param timezone the user's timezone
|
2011-03-14 03:23:55 +00:00
|
|
|
*/
|
2019-07-06 00:46:48 +00:00
|
|
|
public void setTimezone(ZoneId timezone) {
|
2014-07-28 03:44:05 +00:00
|
|
|
checkNotNull(timezone);
|
2011-03-14 03:23:55 +00:00
|
|
|
this.timezone = timezone;
|
|
|
|
}
|
2010-10-02 21:52:42 +00:00
|
|
|
|
2010-10-02 23:13:52 +00:00
|
|
|
/**
|
|
|
|
* Clear history.
|
|
|
|
*/
|
|
|
|
public void clearHistory() {
|
|
|
|
history.clear();
|
2018-08-12 14:03:07 +00:00
|
|
|
historyNegativeIndex = 0;
|
|
|
|
historySize = 0;
|
|
|
|
currentWorld = null;
|
2010-10-02 23:13:52 +00:00
|
|
|
}
|
|
|
|
|
2010-10-02 21:52:42 +00:00
|
|
|
/**
|
2011-02-18 23:14:43 +00:00
|
|
|
* Remember an edit session for the undo history. If the history maximum
|
|
|
|
* size is reached, old edit sessions will be discarded.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param editSession the edit session
|
2010-10-02 21:52:42 +00:00
|
|
|
*/
|
|
|
|
public void remember(EditSession editSession) {
|
2019-06-08 00:58:48 +00:00
|
|
|
checkNotNull(editSession);
|
|
|
|
|
2019-09-21 01:52:35 +00:00
|
|
|
Player player = editSession.getPlayer();
|
|
|
|
int limit = player == null ? Integer.MAX_VALUE : player.getLimit().MAX_HISTORY;
|
2018-08-12 14:03:07 +00:00
|
|
|
remember(editSession, true, limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
private FaweChangeSet getChangeSet(Object o) {
|
|
|
|
if (o instanceof FaweChangeSet) {
|
|
|
|
FaweChangeSet cs = (FaweChangeSet) o;
|
|
|
|
cs.close();
|
|
|
|
return cs;
|
|
|
|
}
|
|
|
|
if (o instanceof Integer) {
|
2019-06-19 03:43:06 +00:00
|
|
|
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + currentWorld.getName() + File.separator + uuid);
|
2018-08-12 14:03:07 +00:00
|
|
|
File specific = new File(folder, o.toString());
|
|
|
|
if (specific.isDirectory()) {
|
2019-08-10 06:01:42 +00:00
|
|
|
// TODO NOT IMPLEMENTED
|
|
|
|
// return new AnvilHistory(currentWorld.getName(), specific);
|
2018-08-12 14:03:07 +00:00
|
|
|
} else {
|
|
|
|
return new DiskStorageHistory(currentWorld, this.uuid, (Integer) o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-08-26 04:45:03 +00:00
|
|
|
public synchronized void remember(Identifiable player, World world, ChangeSet changeSet, FaweLimit limit) {
|
2018-08-12 14:03:07 +00:00
|
|
|
if (Settings.IMP.HISTORY.USE_DISK) {
|
|
|
|
LocalSession.MAX_HISTORY_SIZE = Integer.MAX_VALUE;
|
|
|
|
}
|
|
|
|
if (changeSet.size() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
loadSessionHistoryFromDisk(player.getUniqueId(), world);
|
|
|
|
if (changeSet instanceof FaweChangeSet) {
|
|
|
|
ListIterator<Object> iter = history.listIterator();
|
|
|
|
int i = 0;
|
|
|
|
int cutoffIndex = history.size() - getHistoryNegativeIndex();
|
|
|
|
while (iter.hasNext()) {
|
|
|
|
Object item = iter.next();
|
|
|
|
if (++i > cutoffIndex) {
|
|
|
|
FaweChangeSet oldChangeSet;
|
|
|
|
if (item instanceof FaweChangeSet) {
|
|
|
|
oldChangeSet = (FaweChangeSet) item;
|
|
|
|
} else {
|
|
|
|
oldChangeSet = getChangeSet(item);
|
|
|
|
}
|
|
|
|
historySize -= MainUtil.getSize(oldChangeSet);
|
|
|
|
iter.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
historySize += MainUtil.getSize(changeSet);
|
|
|
|
history.add(changeSet);
|
|
|
|
if (getHistoryNegativeIndex() != 0) {
|
|
|
|
setDirty();
|
|
|
|
historyNegativeIndex = 0;
|
|
|
|
}
|
|
|
|
if (limit != null) {
|
|
|
|
int limitMb = limit.MAX_HISTORY;
|
|
|
|
while (((!Settings.IMP.HISTORY.USE_DISK && history.size() > MAX_HISTORY_SIZE) || (historySize >> 20) > limitMb) && history.size() > 1) {
|
|
|
|
FaweChangeSet item = (FaweChangeSet) history.remove(0);
|
|
|
|
item.delete();
|
|
|
|
long size = MainUtil.getSize(item);
|
|
|
|
historySize -= size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-28 03:44:05 +00:00
|
|
|
|
2019-08-26 04:45:03 +00:00
|
|
|
public synchronized void remember(EditSession editSession, boolean append, int limitMb) {
|
2018-08-12 14:03:07 +00:00
|
|
|
if (Settings.IMP.HISTORY.USE_DISK) {
|
|
|
|
LocalSession.MAX_HISTORY_SIZE = Integer.MAX_VALUE;
|
|
|
|
}
|
|
|
|
// It should have already been flushed, but just in case!
|
|
|
|
editSession.flushQueue();
|
2019-06-08 00:58:48 +00:00
|
|
|
if (editSession.getChangeSet() == null || limitMb == 0 || historySize >> 20 > limitMb && !append) {
|
2018-08-12 14:03:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-10-02 21:52:42 +00:00
|
|
|
// Don't store anything if no changes were made
|
2019-07-06 00:46:48 +00:00
|
|
|
if (editSession.size() == 0) return;
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
FaweChangeSet changeSet = (FaweChangeSet) editSession.getChangeSet();
|
|
|
|
if (changeSet.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2010-10-02 21:52:42 +00:00
|
|
|
|
2019-11-02 19:53:25 +00:00
|
|
|
Player player = editSession.getPlayer();
|
|
|
|
if (player != null) {
|
|
|
|
loadSessionHistoryFromDisk(player.getUniqueId(), editSession.getWorld());
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2010-10-02 21:52:42 +00:00
|
|
|
// Destroy any sessions after this undo point
|
2018-08-12 14:03:07 +00:00
|
|
|
if (append) {
|
|
|
|
ListIterator<Object> iter = history.listIterator();
|
|
|
|
int i = 0;
|
|
|
|
int cutoffIndex = history.size() - getHistoryNegativeIndex();
|
|
|
|
while (iter.hasNext()) {
|
|
|
|
Object item = iter.next();
|
|
|
|
if (++i > cutoffIndex) {
|
|
|
|
FaweChangeSet oldChangeSet;
|
|
|
|
if (item instanceof FaweChangeSet) {
|
|
|
|
oldChangeSet = (FaweChangeSet) item;
|
|
|
|
} else {
|
|
|
|
oldChangeSet = getChangeSet(item);
|
|
|
|
}
|
|
|
|
historySize -= MainUtil.getSize(oldChangeSet);
|
|
|
|
iter.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
historySize += MainUtil.getSize(changeSet);
|
|
|
|
if (append) {
|
|
|
|
history.add(changeSet);
|
|
|
|
if (getHistoryNegativeIndex() != 0) {
|
|
|
|
setDirty();
|
|
|
|
historyNegativeIndex = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
history.add(0, changeSet);
|
2010-10-02 21:52:42 +00:00
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
while (((!Settings.IMP.HISTORY.USE_DISK && history.size() > MAX_HISTORY_SIZE) || (historySize >> 20) > limitMb) && history.size() > 1) {
|
|
|
|
FaweChangeSet item = (FaweChangeSet) history.remove(0);
|
|
|
|
item.delete();
|
|
|
|
long size = MainUtil.getSize(item);
|
|
|
|
historySize -= size;
|
2010-10-02 21:52:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-28 08:01:49 +00:00
|
|
|
/**
|
|
|
|
* Performs an undo.
|
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param newBlockBag a new block bag
|
2019-08-06 15:29:09 +00:00
|
|
|
* @param actor the actor
|
2014-06-28 08:01:49 +00:00
|
|
|
* @return whether anything was undone
|
|
|
|
*/
|
2019-08-06 15:29:09 +00:00
|
|
|
public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) {
|
|
|
|
checkNotNull(actor);
|
2019-09-14 03:05:16 +00:00
|
|
|
loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player) actor).getWorldForEditing());
|
2018-08-12 14:03:07 +00:00
|
|
|
if (getHistoryNegativeIndex() < history.size()) {
|
|
|
|
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
|
2019-07-06 00:46:48 +00:00
|
|
|
try (EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
|
2018-08-12 14:03:07 +00:00
|
|
|
.allowedRegionsEverywhere()
|
|
|
|
.checkMemory(false)
|
|
|
|
.changeSetNull()
|
|
|
|
.fastmode(false)
|
2019-09-14 03:05:16 +00:00
|
|
|
.limitUnprocessed((Player)actor)
|
|
|
|
.player((Player)actor)
|
2019-08-06 15:29:09 +00:00
|
|
|
.blockBag(getBlockBag((Player)actor))
|
2019-07-06 00:46:48 +00:00
|
|
|
.build()) {
|
|
|
|
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.UNDO);
|
|
|
|
setDirty();
|
|
|
|
historyNegativeIndex++;
|
|
|
|
return newEditSession;
|
|
|
|
}
|
2010-10-02 21:52:42 +00:00
|
|
|
} else {
|
2018-08-12 14:03:07 +00:00
|
|
|
int size = history.size();
|
|
|
|
if (getHistoryNegativeIndex() != size) {
|
|
|
|
historyNegativeIndex = history.size();
|
|
|
|
setDirty();
|
|
|
|
}
|
2010-12-31 22:31:49 +00:00
|
|
|
return null;
|
2010-10-02 21:52:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-28 08:01:49 +00:00
|
|
|
/**
|
|
|
|
* Performs a redo
|
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param newBlockBag a new block bag
|
2019-08-06 15:29:09 +00:00
|
|
|
* @param actor the actor
|
2014-06-28 08:01:49 +00:00
|
|
|
* @return whether anything was redone
|
|
|
|
*/
|
2019-08-06 15:29:09 +00:00
|
|
|
public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) {
|
|
|
|
checkNotNull(actor);
|
2019-09-14 03:05:16 +00:00
|
|
|
loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player)actor).getWorldForEditing());
|
2018-08-12 14:03:07 +00:00
|
|
|
if (getHistoryNegativeIndex() > 0) {
|
|
|
|
setDirty();
|
|
|
|
historyNegativeIndex--;
|
|
|
|
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
|
2019-07-06 00:46:48 +00:00
|
|
|
try (EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
|
2018-08-12 14:03:07 +00:00
|
|
|
.allowedRegionsEverywhere()
|
|
|
|
.checkMemory(false)
|
|
|
|
.changeSetNull()
|
|
|
|
.fastmode(false)
|
2019-09-14 03:05:16 +00:00
|
|
|
.limitUnprocessed((Player)actor)
|
|
|
|
.player((Player)actor)
|
2019-08-06 15:29:09 +00:00
|
|
|
.blockBag(getBlockBag((Player)actor))
|
2019-07-06 00:46:48 +00:00
|
|
|
.build()) {
|
|
|
|
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.REDO);
|
|
|
|
return newEditSession;
|
|
|
|
}
|
2010-10-02 21:52:42 +00:00
|
|
|
}
|
2019-06-06 22:39:51 +00:00
|
|
|
|
2010-12-31 22:31:49 +00:00
|
|
|
return null;
|
2010-10-02 21:52:42 +00:00
|
|
|
}
|
2010-09-30 06:41:05 +00:00
|
|
|
|
2019-09-02 19:22:43 +00:00
|
|
|
public boolean hasWorldOverride() {
|
|
|
|
return this.worldOverride != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public World getWorldOverride() {
|
|
|
|
return this.worldOverride;
|
|
|
|
}
|
2019-09-14 03:05:16 +00:00
|
|
|
|
2019-09-02 19:22:43 +00:00
|
|
|
public void setWorldOverride(@Nullable World worldOverride) {
|
|
|
|
this.worldOverride = worldOverride;
|
|
|
|
}
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
public void unregisterTools(Player player) {
|
2019-10-23 04:23:52 +00:00
|
|
|
synchronized (tools) {
|
|
|
|
for (Tool tool : tools.values()) {
|
|
|
|
if (tool instanceof BrushTool) {
|
|
|
|
((BrushTool) tool).clear(player);
|
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSize() {
|
|
|
|
return history.size();
|
|
|
|
}
|
|
|
|
|
2014-07-29 03:53:17 +00:00
|
|
|
/**
|
|
|
|
* Get the default region selector.
|
|
|
|
*
|
|
|
|
* @return the default region selector
|
|
|
|
*/
|
|
|
|
public RegionSelectorType getDefaultRegionSelector() {
|
|
|
|
return defaultSelector;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the default region selector.
|
|
|
|
*
|
|
|
|
* @param defaultSelector the default region selector
|
|
|
|
*/
|
|
|
|
public void setDefaultRegionSelector(RegionSelectorType defaultSelector) {
|
|
|
|
checkNotNull(defaultSelector);
|
|
|
|
this.defaultSelector = defaultSelector;
|
|
|
|
setDirty();
|
|
|
|
}
|
|
|
|
|
2010-10-03 19:43:30 +00:00
|
|
|
/**
|
2011-02-20 01:44:39 +00:00
|
|
|
* Get the region selector for defining the selection. If the selection
|
|
|
|
* was defined for a different world, the old selection will be discarded.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param world the world
|
|
|
|
* @return position the position
|
2010-10-03 19:43:30 +00:00
|
|
|
*/
|
2014-04-05 09:59:38 +00:00
|
|
|
public RegionSelector getRegionSelector(World world) {
|
2014-07-28 03:44:05 +00:00
|
|
|
checkNotNull(world);
|
2019-09-21 01:52:35 +00:00
|
|
|
if (selector.getWorld() == null || !selector.getWorld().equals(world)) {
|
|
|
|
selector.setWorld(world);
|
2011-03-12 06:43:02 +00:00
|
|
|
selector.clear();
|
2019-09-21 01:52:35 +00:00
|
|
|
if (hasWorldOverride() && !world.equals(getWorldOverride())) {
|
|
|
|
setWorldOverride(null);
|
|
|
|
}
|
2010-09-30 06:41:05 +00:00
|
|
|
}
|
2011-03-12 06:43:02 +00:00
|
|
|
return selector;
|
2010-09-30 06:41:05 +00:00
|
|
|
}
|
2010-11-16 09:01:37 +00:00
|
|
|
|
|
|
|
/**
|
2011-02-20 01:44:39 +00:00
|
|
|
* Set the region selector.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2018-12-20 16:00:27 +00:00
|
|
|
* @param world the world
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param selector the selector
|
2010-11-16 09:01:37 +00:00
|
|
|
*/
|
2014-04-05 09:59:38 +00:00
|
|
|
public void setRegionSelector(World world, RegionSelector selector) {
|
2014-07-28 03:44:05 +00:00
|
|
|
checkNotNull(world);
|
|
|
|
checkNotNull(selector);
|
2014-07-29 03:53:17 +00:00
|
|
|
selector.setWorld(world);
|
2011-03-12 06:43:02 +00:00
|
|
|
this.selector = selector;
|
2019-09-02 19:22:43 +00:00
|
|
|
if (hasWorldOverride() && !world.equals(getWorldOverride())) {
|
|
|
|
setWorldOverride(null);
|
|
|
|
}
|
2010-11-16 09:01:37 +00:00
|
|
|
}
|
|
|
|
|
2010-10-03 19:43:30 +00:00
|
|
|
/**
|
2011-02-20 01:44:39 +00:00
|
|
|
* Returns true if the region is fully defined for the specified world.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param world the world
|
|
|
|
* @return true if a region selection is defined
|
2010-10-03 19:43:30 +00:00
|
|
|
*/
|
2014-04-05 09:59:38 +00:00
|
|
|
public boolean isSelectionDefined(World world) {
|
2014-07-28 03:44:05 +00:00
|
|
|
checkNotNull(world);
|
2011-12-13 03:20:31 +00:00
|
|
|
if (selector.getIncompleteRegion().getWorld() == null || !selector.getIncompleteRegion().getWorld().equals(world)) {
|
2011-02-20 01:44:39 +00:00
|
|
|
return false;
|
2010-10-13 04:41:06 +00:00
|
|
|
}
|
2011-03-12 06:43:02 +00:00
|
|
|
return selector.isDefined();
|
2010-10-03 23:45:54 +00:00
|
|
|
}
|
|
|
|
|
2010-10-13 04:41:06 +00:00
|
|
|
/**
|
2011-02-20 01:44:39 +00:00
|
|
|
* Get the selection region. If you change the region, you should
|
|
|
|
* call learnRegionChanges(). If the selection is defined in
|
2014-07-28 03:44:05 +00:00
|
|
|
* a different world, the {@code IncompleteRegionException}
|
2011-02-20 01:44:39 +00:00
|
|
|
* exception will be thrown.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param world the world
|
|
|
|
* @return a region
|
|
|
|
* @throws IncompleteRegionException if no region is selected
|
2010-10-03 19:43:30 +00:00
|
|
|
*/
|
2014-04-05 09:59:38 +00:00
|
|
|
public Region getSelection(World world) throws IncompleteRegionException {
|
2014-07-28 03:44:05 +00:00
|
|
|
checkNotNull(world);
|
2011-12-13 03:20:31 +00:00
|
|
|
if (selector.getIncompleteRegion().getWorld() == null || !selector.getIncompleteRegion().getWorld().equals(world)) {
|
2019-10-26 13:21:49 +00:00
|
|
|
throw new IncompleteRegionException() {
|
|
|
|
@Override
|
|
|
|
public synchronized Throwable fillInStackTrace() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
};
|
2010-10-13 17:08:53 +00:00
|
|
|
}
|
2011-03-12 06:43:02 +00:00
|
|
|
return selector.getRegion();
|
2010-10-05 20:46:31 +00:00
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
public @Nullable VirtualWorld getVirtualWorld() {
|
|
|
|
synchronized (dirty) {
|
|
|
|
return virtual;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setVirtualWorld(@Nullable VirtualWorld world) {
|
|
|
|
VirtualWorld tmp;
|
|
|
|
synchronized (dirty) {
|
|
|
|
tmp = this.virtual;
|
2019-11-08 22:30:39 +00:00
|
|
|
if (tmp == world) {
|
|
|
|
return;
|
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
this.virtual = world;
|
|
|
|
}
|
|
|
|
if (tmp != null) {
|
|
|
|
try {
|
|
|
|
tmp.close(world == null);
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (world != null) {
|
2019-11-08 05:27:04 +00:00
|
|
|
Fawe.imp().registerPacketListener();
|
2018-08-12 14:03:07 +00:00
|
|
|
world.update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-12 08:28:19 +00:00
|
|
|
/**
|
|
|
|
* Get the selection world.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return the the world of the selection
|
2011-03-12 08:28:19 +00:00
|
|
|
*/
|
2014-04-05 09:59:38 +00:00
|
|
|
public World getSelectionWorld() {
|
2018-08-12 14:03:07 +00:00
|
|
|
World world = selector.getIncompleteRegion().getWorld();
|
|
|
|
if (world instanceof WorldWrapper) {
|
|
|
|
return ((WorldWrapper) world).getParent();
|
|
|
|
}
|
|
|
|
return world;
|
|
|
|
}
|
|
|
|
|
2010-10-02 23:11:44 +00:00
|
|
|
/**
|
2010-10-03 19:43:30 +00:00
|
|
|
* Gets the clipboard.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return clipboard
|
2014-07-09 21:14:17 +00:00
|
|
|
* @throws EmptyClipboardException thrown if no clipboard is set
|
2010-10-02 23:11:44 +00:00
|
|
|
*/
|
2019-10-23 04:23:52 +00:00
|
|
|
public synchronized ClipboardHolder getClipboard() throws EmptyClipboardException {
|
2010-10-13 17:08:53 +00:00
|
|
|
if (clipboard == null) {
|
|
|
|
throw new EmptyClipboardException();
|
|
|
|
}
|
2010-10-02 23:11:44 +00:00
|
|
|
return clipboard;
|
|
|
|
}
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
@Nullable
|
2019-10-23 04:23:52 +00:00
|
|
|
public synchronized ClipboardHolder getExistingClipboard() {
|
2018-08-12 14:03:07 +00:00
|
|
|
return clipboard;
|
|
|
|
}
|
|
|
|
|
2019-10-23 04:23:52 +00:00
|
|
|
public synchronized void addClipboard(@Nonnull MultiClipboardHolder toAppend) {
|
2018-08-12 14:03:07 +00:00
|
|
|
checkNotNull(toAppend);
|
|
|
|
ClipboardHolder existing = getExistingClipboard();
|
|
|
|
MultiClipboardHolder multi;
|
|
|
|
if (existing instanceof MultiClipboardHolder) {
|
|
|
|
multi = (MultiClipboardHolder) existing;
|
|
|
|
for (ClipboardHolder holder : toAppend.getHolders()) {
|
|
|
|
multi.add(holder);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
multi = toAppend;
|
|
|
|
if (existing != null) {
|
|
|
|
multi.add(existing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setClipboard(multi);
|
|
|
|
}
|
|
|
|
|
2010-10-02 23:11:44 +00:00
|
|
|
/**
|
2010-10-03 19:43:30 +00:00
|
|
|
* Sets the clipboard.
|
2018-12-20 16:00:27 +00:00
|
|
|
*
|
2014-07-09 21:14:17 +00:00
|
|
|
* <p>Pass {@code null} to clear the clipboard.</p>
|
|
|
|
*
|
|
|
|
* @param clipboard the clipboard, or null if the clipboard is to be cleared
|
2010-10-02 23:11:44 +00:00
|
|
|
*/
|
2019-10-23 04:23:52 +00:00
|
|
|
public synchronized void setClipboard(@Nullable ClipboardHolder clipboard) {
|
2018-08-12 14:03:07 +00:00
|
|
|
if (this.clipboard == clipboard) return;
|
|
|
|
|
|
|
|
if (this.clipboard != null) {
|
|
|
|
if (clipboard == null || !clipboard.contains(this.clipboard.getClipboard())) {
|
|
|
|
this.clipboard.close();
|
|
|
|
}
|
|
|
|
}
|
2014-07-09 21:14:17 +00:00
|
|
|
this.clipboard = clipboard;
|
2010-10-02 23:11:44 +00:00
|
|
|
}
|
2010-10-03 23:45:54 +00:00
|
|
|
|
|
|
|
/**
|
2019-07-06 00:46:48 +00:00
|
|
|
* @return true always - see deprecation notice
|
|
|
|
* @deprecated The wand is now a tool that can be bound/unbound.
|
2010-10-03 23:45:54 +00:00
|
|
|
*/
|
2019-07-06 00:46:48 +00:00
|
|
|
@Deprecated
|
2010-10-03 23:45:54 +00:00
|
|
|
public boolean isToolControlEnabled() {
|
2019-07-06 00:46:48 +00:00
|
|
|
return true;
|
2010-10-03 23:45:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-06 00:46:48 +00:00
|
|
|
* @param toolControl unused - see deprecation notice
|
|
|
|
* @deprecated The wand is now a tool that can be bound/unbound.
|
2010-10-03 23:45:54 +00:00
|
|
|
*/
|
2019-07-06 00:46:48 +00:00
|
|
|
@Deprecated
|
2010-10-03 23:45:54 +00:00
|
|
|
public void setToolControl(boolean toolControl) {
|
|
|
|
}
|
|
|
|
|
2010-10-04 23:39:35 +00:00
|
|
|
/**
|
|
|
|
* Get the maximum number of blocks that can be changed in an edit session.
|
2010-10-11 15:56:19 +00:00
|
|
|
*
|
|
|
|
* @return block change limit
|
2010-10-04 23:39:35 +00:00
|
|
|
*/
|
|
|
|
public int getBlockChangeLimit() {
|
|
|
|
return maxBlocksChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the maximum number of blocks that can be changed.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param maxBlocksChanged the maximum number of blocks changed
|
2010-10-04 23:39:35 +00:00
|
|
|
*/
|
|
|
|
public void setBlockChangeLimit(int maxBlocksChanged) {
|
|
|
|
this.maxBlocksChanged = maxBlocksChanged;
|
|
|
|
}
|
2010-10-13 18:26:07 +00:00
|
|
|
|
2019-03-07 00:58:32 +00:00
|
|
|
/**
|
|
|
|
* Get the maximum time allowed for certain executions to run before cancelling them, such as expressions.
|
|
|
|
*
|
|
|
|
* @return timeout time, in milliseconds
|
|
|
|
*/
|
|
|
|
public int getTimeout() {
|
|
|
|
return maxTimeoutTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the maximum number of blocks that can be changed.
|
|
|
|
*
|
|
|
|
* @param timeout the time, in milliseconds, to limit certain executions to, or -1 to disable
|
|
|
|
*/
|
|
|
|
public void setTimeout(int timeout) {
|
|
|
|
this.maxTimeoutTime = timeout;
|
|
|
|
}
|
|
|
|
|
2010-10-13 18:26:07 +00:00
|
|
|
/**
|
|
|
|
* Checks whether the super pick axe is enabled.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2010-10-13 18:26:07 +00:00
|
|
|
* @return status
|
|
|
|
*/
|
|
|
|
public boolean hasSuperPickAxe() {
|
2011-01-02 05:50:31 +00:00
|
|
|
return superPickaxe;
|
2010-10-13 18:26:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable super pick axe.
|
|
|
|
*/
|
|
|
|
public void enableSuperPickAxe() {
|
2011-01-02 05:50:31 +00:00
|
|
|
superPickaxe = true;
|
2010-10-13 18:26:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable super pick axe.
|
|
|
|
*/
|
|
|
|
public void disableSuperPickAxe() {
|
2011-01-02 05:50:31 +00:00
|
|
|
superPickaxe = false;
|
2010-10-13 18:26:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle the super pick axe.
|
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return whether the super pick axe is now enabled
|
2010-10-13 18:26:07 +00:00
|
|
|
*/
|
|
|
|
public boolean toggleSuperPickAxe() {
|
2011-01-02 05:50:31 +00:00
|
|
|
superPickaxe = !superPickaxe;
|
|
|
|
return superPickaxe;
|
2010-10-13 18:26:07 +00:00
|
|
|
}
|
2010-10-14 09:14:18 +00:00
|
|
|
|
|
|
|
/**
|
2014-07-28 03:44:05 +00:00
|
|
|
* Get the position use for commands that take a center point
|
|
|
|
* (i.e. //forestgen, etc.).
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2019-08-06 15:29:09 +00:00
|
|
|
* @param actor the actor
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return the position to use
|
|
|
|
* @throws IncompleteRegionException thrown if a region is not fully selected
|
2010-10-14 09:14:18 +00:00
|
|
|
*/
|
2019-08-06 15:29:09 +00:00
|
|
|
public BlockVector3 getPlacementPosition(Actor actor) throws IncompleteRegionException {
|
|
|
|
checkNotNull(actor);
|
2010-10-14 09:14:18 +00:00
|
|
|
if (!placeAtPos1) {
|
2019-08-06 15:29:09 +00:00
|
|
|
if (actor instanceof Locatable) {
|
|
|
|
return ((Locatable) actor).getBlockLocation().toVector().toBlockPoint();
|
|
|
|
} else {
|
|
|
|
throw new IncompleteRegionException();
|
|
|
|
}
|
2010-10-14 09:14:18 +00:00
|
|
|
}
|
|
|
|
|
2011-03-12 06:43:02 +00:00
|
|
|
return selector.getPrimaryPosition();
|
2010-10-14 09:14:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-18 23:14:43 +00:00
|
|
|
* Toggle placement position.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return whether "place at position 1" is now enabled
|
2010-10-14 09:14:18 +00:00
|
|
|
*/
|
|
|
|
public boolean togglePlacementPosition() {
|
|
|
|
placeAtPos1 = !placeAtPos1;
|
|
|
|
return placeAtPos1;
|
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2010-12-31 22:31:49 +00:00
|
|
|
/**
|
|
|
|
* Get a block bag for a player.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param player the player to get the block bag for
|
|
|
|
* @return a block bag
|
2010-12-31 22:31:49 +00:00
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
@Nullable
|
2014-06-27 23:03:29 +00:00
|
|
|
public BlockBag getBlockBag(Player player) {
|
2014-07-28 03:44:05 +00:00
|
|
|
checkNotNull(player);
|
2019-09-14 03:05:16 +00:00
|
|
|
if (!useInventory && player.getLimit().INVENTORY_MODE == 0) {
|
2010-12-31 22:31:49 +00:00
|
|
|
return null;
|
|
|
|
}
|
2011-01-01 01:06:42 +00:00
|
|
|
return player.getInventoryBlockBag();
|
2010-12-31 22:31:49 +00:00
|
|
|
}
|
2010-10-20 23:15:20 +00:00
|
|
|
|
|
|
|
/**
|
2011-02-18 23:14:43 +00:00
|
|
|
* Get the snapshot that has been selected.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2011-02-18 23:14:43 +00:00
|
|
|
* @return the snapshot
|
2010-10-20 23:15:20 +00:00
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
@Nullable
|
2010-10-20 23:15:20 +00:00
|
|
|
public Snapshot getSnapshot() {
|
|
|
|
return snapshot;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-18 23:14:43 +00:00
|
|
|
* Select a snapshot.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param snapshot a snapshot
|
2010-10-20 23:15:20 +00:00
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
public void setSnapshot(@Nullable Snapshot snapshot) {
|
2010-10-20 23:15:20 +00:00
|
|
|
this.snapshot = snapshot;
|
|
|
|
}
|
2010-11-07 06:17:32 +00:00
|
|
|
|
|
|
|
/**
|
2014-07-28 03:44:05 +00:00
|
|
|
* Get the assigned block tool.
|
|
|
|
*
|
|
|
|
* @return the super pickaxe tool mode
|
2010-11-07 06:17:32 +00:00
|
|
|
*/
|
2011-02-18 23:14:43 +00:00
|
|
|
public BlockTool getSuperPickaxe() {
|
|
|
|
return pickaxeMode;
|
2010-11-07 06:17:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-28 03:44:05 +00:00
|
|
|
* Set the super pick axe tool.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param tool the tool to set
|
2010-11-07 06:17:32 +00:00
|
|
|
*/
|
2011-02-18 23:14:43 +00:00
|
|
|
public void setSuperPickaxe(BlockTool tool) {
|
2014-07-28 03:44:05 +00:00
|
|
|
checkNotNull(tool);
|
2011-02-18 23:14:43 +00:00
|
|
|
this.pickaxeMode = tool;
|
2010-11-07 06:17:32 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 22:39:51 +00:00
|
|
|
/**
|
|
|
|
* Get the tool assigned to the item.
|
|
|
|
*
|
|
|
|
* @param item the item type
|
|
|
|
* @return the tool, which may be {@code null}
|
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
@Nullable
|
2019-10-23 04:23:52 +00:00
|
|
|
@Deprecated
|
2018-06-17 07:50:04 +00:00
|
|
|
public Tool getTool(ItemType item) {
|
2019-10-23 04:23:52 +00:00
|
|
|
synchronized (this.tools) {
|
|
|
|
return tools.get(item.getInternalId());
|
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public Tool getTool(Player player) {
|
2019-10-23 04:23:52 +00:00
|
|
|
loadDefaults(player, false);
|
|
|
|
if (!Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && tools.isEmpty()) {
|
2019-07-17 16:31:13 +00:00
|
|
|
return null;
|
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
|
|
|
return getTool(item, player);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Tool getTool(BaseItem item, Player player) {
|
2019-07-17 16:31:13 +00:00
|
|
|
if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
|
2018-08-12 14:03:07 +00:00
|
|
|
BrushTool tool = BrushCache.getTool(player, this, item);
|
|
|
|
if (tool != null) return tool;
|
|
|
|
}
|
2019-10-23 04:23:52 +00:00
|
|
|
loadDefaults(player, false);
|
2018-08-12 14:03:07 +00:00
|
|
|
return getTool(item.getType());
|
2011-01-09 19:14:55 +00:00
|
|
|
}
|
|
|
|
|
2019-10-23 04:23:52 +00:00
|
|
|
public void loadDefaults(Actor actor, boolean force) {
|
|
|
|
if (loadDefaults || force) {
|
|
|
|
loadDefaults = false;
|
|
|
|
LocalConfiguration config = WorldEdit.getInstance().getConfiguration();
|
|
|
|
if (wandItem == null) {
|
|
|
|
wandItem = ItemTypes.parse(config.wandItem);
|
|
|
|
}
|
|
|
|
if (navWandItem == null) {
|
|
|
|
navWandItem = ItemTypes.parse(config.navigationWand);
|
|
|
|
}
|
|
|
|
synchronized (this.tools) {
|
|
|
|
if (tools.get(navWandItem.getInternalId()) == null && NavigationWand.INSTANCE.canUse(actor)) {
|
|
|
|
tools.put(navWandItem.getInternalId(), NavigationWand.INSTANCE);
|
|
|
|
}
|
|
|
|
if (tools.get(wandItem.getInternalId()) == null && SelectionWand.INSTANCE.canUse(actor)) {
|
|
|
|
tools.put(wandItem.getInternalId(), SelectionWand.INSTANCE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-09 19:14:55 +00:00
|
|
|
/**
|
2011-02-18 23:14:43 +00:00
|
|
|
* Get the brush tool assigned to the item. If there is no tool assigned
|
|
|
|
* or the tool is not assigned, the slot will be replaced with the
|
|
|
|
* brush tool.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2019-07-17 16:31:13 +00:00
|
|
|
* @deprecated FAWE binds to the item, not the type - this allows brushes to persist
|
2018-12-20 16:00:27 +00:00
|
|
|
* @param item the item type
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return the tool, or {@code null}
|
|
|
|
* @throws InvalidToolBindException if the item can't be bound to that item
|
2011-01-09 19:14:55 +00:00
|
|
|
*/
|
2019-07-17 16:31:13 +00:00
|
|
|
@Deprecated
|
2018-06-17 07:50:04 +00:00
|
|
|
public BrushTool getBrushTool(ItemType item) throws InvalidToolBindException {
|
2019-07-17 16:31:13 +00:00
|
|
|
return getBrushTool(item.getDefaultState(), null, true);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public BrushTool getBrushTool(Player player) throws InvalidToolBindException {
|
|
|
|
return getBrushTool(player, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public BrushTool getBrushTool(Player player, boolean create) throws InvalidToolBindException {
|
2019-07-17 16:31:13 +00:00
|
|
|
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
2018-08-12 14:03:07 +00:00
|
|
|
return getBrushTool(item, player, create);
|
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2019-07-17 16:31:13 +00:00
|
|
|
public BrushTool getBrushTool(BaseItem item, Player player, boolean create) throws InvalidToolBindException {
|
|
|
|
Tool tool = getTool(item, player);
|
2019-06-08 00:58:48 +00:00
|
|
|
if (!(tool instanceof BrushTool)) {
|
2018-08-12 14:03:07 +00:00
|
|
|
if (create) {
|
2019-06-28 15:39:58 +00:00
|
|
|
tool = new BrushTool();
|
2019-07-17 16:31:13 +00:00
|
|
|
setTool(item, tool, player);
|
2018-08-12 14:03:07 +00:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2011-02-18 23:14:43 +00:00
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2011-11-23 01:29:48 +00:00
|
|
|
return (BrushTool) tool;
|
2011-01-09 19:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-18 23:14:43 +00:00
|
|
|
* Set the tool.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2018-12-20 16:00:27 +00:00
|
|
|
* @param item the item type
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param tool the tool to set, which can be {@code null}
|
|
|
|
* @throws InvalidToolBindException if the item can't be bound to that item
|
2011-02-19 04:50:40 +00:00
|
|
|
*/
|
2018-06-17 07:50:04 +00:00
|
|
|
public void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindException {
|
2019-06-08 00:58:48 +00:00
|
|
|
if (item.hasBlockType()) {
|
|
|
|
throw new InvalidToolBindException(item, "Blocks can't be used");
|
2019-10-23 04:23:52 +00:00
|
|
|
} else if (tool instanceof SelectionWand) {
|
|
|
|
changeTool(this.wandItem, this.wandItem = item, tool);
|
|
|
|
setDirty();
|
|
|
|
return;
|
|
|
|
} else if (tool instanceof NavigationWand) {
|
|
|
|
changeTool(this.navWandItem, this.navWandItem = item, tool);
|
|
|
|
setDirty();
|
|
|
|
return;
|
2019-06-08 00:58:48 +00:00
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
setTool(item.getDefaultState(), tool, null);
|
|
|
|
}
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
public void setTool(Player player, @Nullable Tool tool) throws InvalidToolBindException {
|
2018-08-12 14:03:07 +00:00
|
|
|
BaseItemStack item = player.getItemInHand(HandSide.MAIN_HAND);
|
|
|
|
setTool(item, tool, player);
|
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2019-10-23 04:23:52 +00:00
|
|
|
private void changeTool(ItemType oldType, ItemType newType, Tool newTool) {
|
|
|
|
if (oldType != null) {
|
|
|
|
synchronized (this.tools) {
|
|
|
|
this.tools.remove(oldType.getInternalId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
synchronized (this.tools) {
|
|
|
|
if (newTool == null) {
|
|
|
|
this.tools.remove(newType.getInternalId());
|
|
|
|
} else {
|
|
|
|
this.tools.put(newType.getInternalId(), newTool);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
public void setTool(BaseItem item, @Nullable Tool tool, Player player) throws InvalidToolBindException {
|
2019-01-31 15:08:58 +00:00
|
|
|
ItemType type = item.getType();
|
2019-06-28 15:39:58 +00:00
|
|
|
if (type.hasBlockType() && type.getBlockType().getMaterial().isAir()) {
|
2018-08-12 14:03:07 +00:00
|
|
|
throw new InvalidToolBindException(type, "Blocks can't be used");
|
2019-10-23 04:23:52 +00:00
|
|
|
} else if (tool instanceof SelectionWand) {
|
|
|
|
changeTool(this.wandItem, this.wandItem = item.getType(), tool);
|
|
|
|
setDirty();
|
|
|
|
return;
|
|
|
|
} else if (tool instanceof NavigationWand) {
|
|
|
|
changeTool(this.navWandItem, this.navWandItem = item.getType(), tool);
|
|
|
|
setDirty();
|
|
|
|
return;
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2019-09-21 01:52:35 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
Tool previous;
|
2019-07-17 16:31:13 +00:00
|
|
|
if (player != null && (tool instanceof BrushTool || tool == null) && Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
|
2018-08-12 14:03:07 +00:00
|
|
|
previous = BrushCache.getCachedTool(item);
|
2018-09-07 17:17:27 +00:00
|
|
|
BrushCache.setTool(item, (BrushTool) tool);
|
2018-08-12 14:03:07 +00:00
|
|
|
if (tool != null) {
|
|
|
|
((BrushTool) tool).setHolder(item);
|
2019-04-11 01:28:06 +00:00
|
|
|
} else {
|
2019-10-23 04:23:52 +00:00
|
|
|
synchronized (this.tools) {
|
|
|
|
this.tools.remove(type.getInternalId());
|
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
2019-10-23 04:23:52 +00:00
|
|
|
synchronized (this.tools) {
|
|
|
|
previous = this.tools.get(type.getInternalId());
|
|
|
|
if (tool != null) {
|
|
|
|
this.tools.put(type.getInternalId(), tool);
|
|
|
|
} else {
|
|
|
|
this.tools.remove(type.getInternalId());
|
2018-10-13 04:15:20 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2019-07-06 00:46:48 +00:00
|
|
|
if (player != null && previous instanceof BrushTool) {
|
2018-08-12 14:03:07 +00:00
|
|
|
BrushTool brushTool = (BrushTool) previous;
|
|
|
|
brushTool.clear(player);
|
|
|
|
}
|
2010-11-07 06:17:32 +00:00
|
|
|
}
|
2010-12-31 22:31:49 +00:00
|
|
|
|
|
|
|
/**
|
2011-02-18 23:14:43 +00:00
|
|
|
* Returns whether inventory usage is enabled for this session.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return if inventory is being used
|
2010-12-31 22:31:49 +00:00
|
|
|
*/
|
|
|
|
public boolean isUsingInventory() {
|
|
|
|
return useInventory;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-18 23:14:43 +00:00
|
|
|
* Set the state of inventory usage.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param useInventory if inventory is to be used
|
2010-12-31 22:31:49 +00:00
|
|
|
*/
|
|
|
|
public void setUseInventory(boolean useInventory) {
|
|
|
|
this.useInventory = useInventory;
|
|
|
|
}
|
2011-01-23 10:09:51 +00:00
|
|
|
|
|
|
|
/**
|
2011-02-18 23:14:43 +00:00
|
|
|
* Get the last script used.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return the last script's name
|
2011-01-23 10:09:51 +00:00
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
@Nullable
|
2011-01-23 10:09:51 +00:00
|
|
|
public String getLastScript() {
|
|
|
|
return lastScript;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-18 23:14:43 +00:00
|
|
|
* Set the last script used.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param lastScript the last script's name
|
2011-01-23 10:09:51 +00:00
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
public void setLastScript(@Nullable String lastScript) {
|
2011-01-23 10:09:51 +00:00
|
|
|
this.lastScript = lastScript;
|
2014-07-28 03:44:05 +00:00
|
|
|
setDirty();
|
2011-01-23 10:09:51 +00:00
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2011-01-31 08:58:29 +00:00
|
|
|
/**
|
|
|
|
* Tell the player the WorldEdit version.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2019-08-06 15:29:09 +00:00
|
|
|
* @param actor the actor
|
2011-01-31 08:58:29 +00:00
|
|
|
*/
|
2019-08-06 15:29:09 +00:00
|
|
|
public void tellVersion(Actor actor) {
|
2011-01-31 08:58:29 +00:00
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2018-12-23 16:19:33 +00:00
|
|
|
public boolean shouldUseServerCUI() {
|
|
|
|
return this.useServerCUI;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUseServerCUI(boolean useServerCUI) {
|
|
|
|
this.useServerCUI = useServerCUI;
|
|
|
|
setDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update server-side WorldEdit CUI.
|
|
|
|
*
|
|
|
|
* @param actor The player
|
|
|
|
*/
|
|
|
|
public void updateServerCUI(Actor actor) {
|
|
|
|
if (!actor.isPlayer()) {
|
|
|
|
return; // This is for players only.
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!config.serverSideCUI) {
|
|
|
|
return; // Disabled in config.
|
|
|
|
}
|
|
|
|
|
|
|
|
Player player = (Player) actor;
|
|
|
|
|
|
|
|
if (!useServerCUI || hasCUISupport) {
|
|
|
|
if (cuiTemporaryBlock != null) {
|
|
|
|
player.sendFakeBlock(cuiTemporaryBlock, null);
|
|
|
|
cuiTemporaryBlock = null;
|
|
|
|
}
|
|
|
|
return; // If it's not enabled, ignore this.
|
|
|
|
}
|
|
|
|
|
|
|
|
BaseBlock block = ServerCUIHandler.createStructureBlock(player);
|
|
|
|
if (block != null) {
|
|
|
|
// If it's null, we don't need to do anything. The old was already removed.
|
|
|
|
Map<String, Tag> tags = block.getNbtData().getValue();
|
2018-12-26 08:15:17 +00:00
|
|
|
BlockVector3 tempCuiTemporaryBlock = BlockVector3.at(
|
2018-12-23 16:19:33 +00:00
|
|
|
((IntTag) tags.get("x")).getValue(),
|
|
|
|
((IntTag) tags.get("y")).getValue(),
|
|
|
|
((IntTag) tags.get("z")).getValue()
|
|
|
|
);
|
2018-12-26 08:15:17 +00:00
|
|
|
if (cuiTemporaryBlock != null && !tempCuiTemporaryBlock.equals(cuiTemporaryBlock)) {
|
|
|
|
// Update the existing block if it's the same location
|
|
|
|
player.sendFakeBlock(cuiTemporaryBlock, null);
|
|
|
|
}
|
|
|
|
cuiTemporaryBlock = tempCuiTemporaryBlock;
|
2018-12-23 16:19:33 +00:00
|
|
|
player.sendFakeBlock(cuiTemporaryBlock, block);
|
2018-12-26 08:15:17 +00:00
|
|
|
} else if (cuiTemporaryBlock != null) {
|
|
|
|
// Remove the old block
|
|
|
|
player.sendFakeBlock(cuiTemporaryBlock, null);
|
|
|
|
cuiTemporaryBlock = null;
|
2018-12-23 16:19:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-12 06:43:02 +00:00
|
|
|
/**
|
2014-07-28 03:44:05 +00:00
|
|
|
* Dispatch a CUI event but only if the actor has CUI support.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param actor the actor
|
|
|
|
* @param event the event
|
2011-03-12 06:43:02 +00:00
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
public void dispatchCUIEvent(Actor actor, CUIEvent event) {
|
|
|
|
checkNotNull(actor);
|
|
|
|
checkNotNull(event);
|
|
|
|
|
2011-03-12 06:43:02 +00:00
|
|
|
if (hasCUISupport) {
|
2014-07-28 03:44:05 +00:00
|
|
|
actor.dispatchCUIEvent(event);
|
2019-06-06 22:39:51 +00:00
|
|
|
} else if (useServerCUI) {
|
|
|
|
updateServerCUI(actor);
|
2011-03-12 06:43:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2011-03-12 06:43:02 +00:00
|
|
|
/**
|
|
|
|
* Dispatch the initial setup CUI messages.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param actor the actor
|
2011-03-12 06:43:02 +00:00
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
public void dispatchCUISetup(Actor actor) {
|
2011-03-12 06:43:02 +00:00
|
|
|
if (selector != null) {
|
2014-07-28 03:44:05 +00:00
|
|
|
dispatchCUISelection(actor);
|
2011-03-12 10:27:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2011-03-12 10:27:43 +00:00
|
|
|
/**
|
|
|
|
* Send the selection information.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param actor the actor
|
2011-03-12 10:27:43 +00:00
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
public void dispatchCUISelection(Actor actor) {
|
|
|
|
checkNotNull(actor);
|
2018-12-26 08:15:17 +00:00
|
|
|
|
|
|
|
if (!hasCUISupport && useServerCUI) {
|
|
|
|
updateServerCUI(actor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-01 04:16:39 +00:00
|
|
|
if (selector instanceof CUIRegion) {
|
|
|
|
CUIRegion tempSel = (CUIRegion) selector;
|
|
|
|
|
|
|
|
if (tempSel.getProtocolVersion() > cuiVersion) {
|
2019-06-06 22:39:51 +00:00
|
|
|
actor.dispatchCUIEvent(new SelectionShapeEvent(tempSel.getLegacyTypeID()));
|
2014-07-28 03:44:05 +00:00
|
|
|
tempSel.describeLegacyCUI(this, actor);
|
2012-01-01 04:16:39 +00:00
|
|
|
} else {
|
2019-06-06 22:39:51 +00:00
|
|
|
actor.dispatchCUIEvent(new SelectionShapeEvent(tempSel.getTypeID()));
|
2014-07-28 03:44:05 +00:00
|
|
|
tempSel.describeCUI(this, actor);
|
2012-01-01 04:16:39 +00:00
|
|
|
}
|
2019-06-06 22:39:51 +00:00
|
|
|
|
2011-12-30 10:59:33 +00:00
|
|
|
}
|
2012-01-01 04:16:39 +00:00
|
|
|
}
|
2012-04-20 04:46:18 +00:00
|
|
|
|
2014-07-28 03:44:05 +00:00
|
|
|
/**
|
|
|
|
* Describe the selection to the CUI actor.
|
|
|
|
*
|
|
|
|
* @param actor the actor
|
|
|
|
*/
|
|
|
|
public void describeCUI(Actor actor) {
|
|
|
|
checkNotNull(actor);
|
2019-06-06 22:39:51 +00:00
|
|
|
|
2019-10-26 13:21:49 +00:00
|
|
|
// TODO preload
|
|
|
|
|
2019-06-06 22:39:51 +00:00
|
|
|
if (!hasCUISupport) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-01 04:16:39 +00:00
|
|
|
if (selector instanceof CUIRegion) {
|
|
|
|
CUIRegion tempSel = (CUIRegion) selector;
|
|
|
|
|
|
|
|
if (tempSel.getProtocolVersion() > cuiVersion) {
|
2014-07-28 03:44:05 +00:00
|
|
|
tempSel.describeLegacyCUI(this, actor);
|
2012-01-01 04:16:39 +00:00
|
|
|
} else {
|
2014-07-28 03:44:05 +00:00
|
|
|
tempSel.describeCUI(this, actor);
|
2012-01-01 04:16:39 +00:00
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2011-03-12 06:43:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2014-07-28 03:44:05 +00:00
|
|
|
/**
|
|
|
|
* Handle a CUI initialization message.
|
|
|
|
*
|
|
|
|
* @param text the message
|
|
|
|
*/
|
2019-07-06 00:46:48 +00:00
|
|
|
public void handleCUIInitializationMessage(String text, Actor actor) {
|
2014-07-28 03:44:05 +00:00
|
|
|
checkNotNull(text);
|
2019-07-06 00:46:48 +00:00
|
|
|
if (this.hasCUISupport || this.failedCuiAttempts > 3) {
|
2018-02-28 00:59:00 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-07-28 03:44:05 +00:00
|
|
|
|
2018-02-28 00:59:00 +00:00
|
|
|
String[] split = text.split("\\|", 2);
|
2012-08-05 03:22:55 +00:00
|
|
|
if (split.length > 1 && split[0].equalsIgnoreCase("v")) { // enough fields and right message
|
2018-02-28 00:59:00 +00:00
|
|
|
if (split[1].length() > 4) {
|
2019-06-06 22:39:51 +00:00
|
|
|
this.failedCuiAttempts ++;
|
2018-02-28 00:59:00 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-07-06 00:46:48 +00:00
|
|
|
|
|
|
|
int version;
|
2012-08-05 03:22:55 +00:00
|
|
|
try {
|
2019-07-06 00:46:48 +00:00
|
|
|
version = Integer.parseInt(split[1]);
|
2012-08-05 03:22:55 +00:00
|
|
|
} catch (NumberFormatException e) {
|
2019-06-06 22:39:51 +00:00
|
|
|
WorldEdit.logger.warn("Error while reading CUI init message: " + e.getMessage());
|
|
|
|
this.failedCuiAttempts ++;
|
2019-07-06 00:46:48 +00:00
|
|
|
return;
|
2012-08-05 03:22:55 +00:00
|
|
|
}
|
2019-07-06 00:46:48 +00:00
|
|
|
setCUISupport(true);
|
|
|
|
setCUIVersion(version);
|
|
|
|
dispatchCUISelection(actor);
|
2012-08-05 03:22:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-31 03:58:32 +00:00
|
|
|
/**
|
|
|
|
* Gets the status of CUI support.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return true if CUI is enabled
|
2011-05-31 03:58:32 +00:00
|
|
|
*/
|
|
|
|
public boolean hasCUISupport() {
|
|
|
|
return hasCUISupport;
|
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2011-03-12 06:43:02 +00:00
|
|
|
/**
|
|
|
|
* Sets the status of CUI support.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param support true if CUI is enabled
|
2011-03-12 06:43:02 +00:00
|
|
|
*/
|
|
|
|
public void setCUISupport(boolean support) {
|
2012-08-05 03:22:55 +00:00
|
|
|
hasCUISupport = support;
|
2011-03-12 06:43:02 +00:00
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2012-01-01 04:16:39 +00:00
|
|
|
/**
|
|
|
|
* Gets the client's CUI protocol version
|
2012-04-20 04:46:18 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return the CUI version
|
2012-01-01 04:16:39 +00:00
|
|
|
*/
|
|
|
|
public int getCUIVersion() {
|
|
|
|
return cuiVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the client's CUI protocol version
|
2012-04-20 04:46:18 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param cuiVersion the CUI version
|
2012-01-01 04:16:39 +00:00
|
|
|
*/
|
2014-04-04 23:09:05 +00:00
|
|
|
public void setCUIVersion(int cuiVersion) {
|
|
|
|
this.cuiVersion = cuiVersion;
|
2012-01-01 04:16:39 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 03:23:55 +00:00
|
|
|
/**
|
|
|
|
* Detect date from a user's input.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param input the input to parse
|
|
|
|
* @return a date
|
2011-03-14 03:23:55 +00:00
|
|
|
*/
|
2014-07-28 03:44:05 +00:00
|
|
|
@Nullable
|
2011-03-14 03:23:55 +00:00
|
|
|
public Calendar detectDate(String input) {
|
2014-07-28 03:44:05 +00:00
|
|
|
checkNotNull(input);
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
TimeZone tz = TimeZone.getTimeZone(getTimeZone());
|
|
|
|
Time.setTimeZone(tz);
|
2011-03-14 03:23:55 +00:00
|
|
|
Options opt = new com.sk89q.jchronic.Options();
|
2019-07-06 00:46:48 +00:00
|
|
|
opt.setNow(Calendar.getInstance(tz));
|
2011-03-14 03:23:55 +00:00
|
|
|
Span date = Chronic.parse(input, opt);
|
|
|
|
if (date == null) {
|
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
return date.getBeginCalendar();
|
|
|
|
}
|
|
|
|
}
|
2011-09-24 19:32:03 +00:00
|
|
|
|
2014-06-27 23:03:29 +00:00
|
|
|
/**
|
|
|
|
* Construct a new edit session.
|
|
|
|
*
|
2019-09-02 19:22:43 +00:00
|
|
|
* @param actor the actor
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return an edit session
|
2014-06-27 23:03:29 +00:00
|
|
|
*/
|
2019-09-02 19:22:43 +00:00
|
|
|
public EditSession createEditSession(Actor actor) {
|
|
|
|
checkNotNull(actor);
|
2019-09-21 01:52:35 +00:00
|
|
|
|
2019-09-02 19:22:43 +00:00
|
|
|
World world = null;
|
|
|
|
if (hasWorldOverride()) {
|
|
|
|
world = getWorldOverride();
|
|
|
|
} else if (actor instanceof Locatable && ((Locatable) actor).getExtent() instanceof World) {
|
|
|
|
world = (World) ((Locatable) actor).getExtent();
|
|
|
|
}
|
2019-09-21 01:52:35 +00:00
|
|
|
|
|
|
|
// Create an edit session
|
|
|
|
EditSession editSession;
|
2019-07-17 16:31:13 +00:00
|
|
|
EditSessionBuilder builder = new EditSessionBuilder(world);
|
2019-09-21 01:52:35 +00:00
|
|
|
if (actor.isPlayer() && actor instanceof Player) {
|
|
|
|
BlockBag blockBag = getBlockBag((Player) actor);
|
|
|
|
builder.player((Player) actor);
|
|
|
|
builder.blockBag(blockBag);
|
|
|
|
}
|
2019-07-17 16:31:13 +00:00
|
|
|
builder.fastmode(fastMode);
|
|
|
|
|
2019-09-21 01:52:35 +00:00
|
|
|
editSession = builder.build();
|
2019-07-06 00:46:48 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
if (mask != null) {
|
|
|
|
editSession.setMask(mask);
|
|
|
|
}
|
|
|
|
if (sourceMask != null) {
|
|
|
|
editSession.setSourceMask(sourceMask);
|
|
|
|
}
|
|
|
|
if (transform != null) {
|
|
|
|
editSession.addTransform(transform);
|
|
|
|
}
|
2019-07-06 00:46:48 +00:00
|
|
|
|
2011-06-04 17:30:45 +00:00
|
|
|
return editSession;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the session has fast mode enabled.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @return true if fast mode is enabled
|
2011-06-04 17:30:45 +00:00
|
|
|
*/
|
|
|
|
public boolean hasFastMode() {
|
|
|
|
return fastMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set fast mode.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2014-07-28 03:44:05 +00:00
|
|
|
* @param fastMode true if fast mode is enabled
|
2011-06-04 17:30:45 +00:00
|
|
|
*/
|
|
|
|
public void setFastMode(boolean fastMode) {
|
|
|
|
this.fastMode = fastMode;
|
|
|
|
}
|
2011-06-04 19:16:10 +00:00
|
|
|
|
2019-07-21 11:39:36 +00:00
|
|
|
/**
|
|
|
|
* Gets the reorder mode of the session.
|
|
|
|
*
|
|
|
|
* @return The reorder mode
|
|
|
|
*/
|
|
|
|
public EditSession.ReorderMode getReorderMode() {
|
2019-04-03 13:25:16 +00:00
|
|
|
// return reorderMode;
|
2019-07-21 11:39:36 +00:00
|
|
|
return EditSession.ReorderMode.FAST;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the reorder mode of the session.
|
|
|
|
*
|
|
|
|
* @param reorderMode The reorder mode
|
|
|
|
*/
|
|
|
|
public void setReorderMode(EditSession.ReorderMode reorderMode) {
|
2019-04-03 13:25:16 +00:00
|
|
|
// this.reorderMode = reorderMode;
|
2019-07-21 11:39:36 +00:00
|
|
|
}
|
2018-12-04 10:20:27 +00:00
|
|
|
|
2011-06-04 19:16:10 +00:00
|
|
|
/**
|
|
|
|
* Get the mask.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2011-06-04 19:16:10 +00:00
|
|
|
* @return mask, may be null
|
|
|
|
*/
|
|
|
|
public Mask getMask() {
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
/**
|
|
|
|
* Get the mask.
|
|
|
|
*
|
|
|
|
* @return mask, may be null
|
|
|
|
*/
|
|
|
|
public Mask getSourceMask() {
|
|
|
|
return sourceMask;
|
|
|
|
}
|
|
|
|
|
2011-06-04 19:16:10 +00:00
|
|
|
/**
|
|
|
|
* Set a mask.
|
2011-09-24 19:32:03 +00:00
|
|
|
*
|
2011-06-04 19:16:10 +00:00
|
|
|
* @param mask mask or null
|
|
|
|
*/
|
|
|
|
public void setMask(Mask mask) {
|
|
|
|
this.mask = mask;
|
|
|
|
}
|
2014-06-28 08:01:49 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
/**
|
|
|
|
* Set a mask.
|
|
|
|
*
|
|
|
|
* @param mask mask or null
|
|
|
|
*/
|
|
|
|
public void setSourceMask(Mask mask) {
|
|
|
|
this.sourceMask = mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTextureUtil(TextureUtil texture) {
|
|
|
|
synchronized (this) {
|
|
|
|
this.texture = texture;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the TextureUtil currently being used
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public TextureUtil getTextureUtil() {
|
|
|
|
TextureUtil tmp = texture;
|
|
|
|
if (tmp == null) {
|
|
|
|
synchronized (this) {
|
|
|
|
tmp = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
|
|
|
this.texture = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
/**
|
|
|
|
* Get the preferred wand item for this user, or {@code null} to use the default
|
|
|
|
* @return item id of wand item, or {@code null}
|
|
|
|
*/
|
|
|
|
public String getWandItem() {
|
2019-10-23 04:23:52 +00:00
|
|
|
return wandItem.getId();
|
2019-07-06 00:46:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the preferred navigation wand item for this user, or {@code null} to use the default
|
|
|
|
* @return item id of nav wand item, or {@code null}
|
|
|
|
*/
|
|
|
|
public String getNavWandItem() {
|
2019-10-23 04:23:52 +00:00
|
|
|
return navWandItem.getId();
|
2019-07-06 00:46:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the last block distribution stored in this session.
|
|
|
|
*
|
|
|
|
* @return block distribution or {@code null}
|
|
|
|
*/
|
|
|
|
public List<Countable<BlockState>> getLastDistribution() {
|
|
|
|
return lastDistribution == null ? null : Collections.unmodifiableList(lastDistribution);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a block distribution in this session.
|
|
|
|
*/
|
|
|
|
public void setLastDistribution(List<Countable<BlockState>> dist) {
|
|
|
|
lastDistribution = dist;
|
|
|
|
}
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
public ResettableExtent getTransform() {
|
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTransform(ResettableExtent transform) {
|
|
|
|
this.transform = transform;
|
|
|
|
}
|
|
|
|
|
2018-08-12 16:36:39 +00:00
|
|
|
|
2019-04-02 22:21:02 +00:00
|
|
|
}
|