mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-16 03:34:03 +00:00
Major command changes that don't work yet.
This commit is contained in:
@@ -19,9 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import static com.sk89q.worldedit.event.platform.Interaction.HIT;
|
||||
import static com.sk89q.worldedit.event.platform.Interaction.OPEN;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.BlockInteractEvent;
|
||||
@@ -48,6 +52,7 @@ import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
||||
import com.sk89q.worldedit.session.SessionManager;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors;
|
||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
@@ -60,11 +65,6 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import com.sk89q.worldedit.world.registry.BundledItemData;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.script.ScriptException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -76,10 +76,12 @@ import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.sk89q.worldedit.event.platform.Interaction.HIT;
|
||||
import static com.sk89q.worldedit.event.platform.Interaction.OPEN;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.script.ScriptException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The entry point and container for a working implementation of WorldEdit.
|
||||
@@ -105,6 +107,7 @@ public final class WorldEdit {
|
||||
private final PlatformManager platformManager = new PlatformManager(this);
|
||||
private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus);
|
||||
private final SessionManager sessions = new SessionManager(this);
|
||||
private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20));
|
||||
private final Supervisor supervisor = new SimpleSupervisor();
|
||||
|
||||
private final BlockFactory blockFactory = new BlockFactory(this);
|
||||
@@ -155,7 +158,7 @@ public final class WorldEdit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the supervisor.
|
||||
* Get the supervisor. Internal, not for API use.
|
||||
*
|
||||
* @return the supervisor
|
||||
*/
|
||||
@@ -163,6 +166,15 @@ public final class WorldEdit {
|
||||
return supervisor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the executor service. Internal, not for API use.
|
||||
*
|
||||
* @return the executor service
|
||||
*/
|
||||
public ListeningExecutorService getExecutorService() {
|
||||
return executorService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block factory from which new {@link BlockStateHolder}s can be
|
||||
* constructed.
|
||||
@@ -307,6 +319,17 @@ public final class WorldEdit {
|
||||
if (exts.size() != 1) {
|
||||
exts = exts.subList(0, 1);
|
||||
}
|
||||
} else {
|
||||
int dot = filename.lastIndexOf('.');
|
||||
if (dot < 0 || dot == filename.length() - 1) {
|
||||
String currentExt = filename.substring(dot + 1);
|
||||
if (exts.contains(currentExt) && checkFilename(filename)) {
|
||||
File f = new File(dir, filename);
|
||||
if (f.exists()) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File result = null;
|
||||
for (Iterator<String> iter = exts.iterator(); iter.hasNext() && (result == null || (!isSave && !result.exists()));) {
|
||||
@@ -321,7 +344,7 @@ public final class WorldEdit {
|
||||
private File getSafeFileWithExtension(File dir, String filename, String extension) {
|
||||
if (extension != null) {
|
||||
int dot = filename.lastIndexOf('.');
|
||||
if (dot < 0 || !filename.substring(dot).equalsIgnoreCase(extension)) {
|
||||
if (dot < 0 || dot == filename.length() - 1 || !filename.substring(dot + 1).equalsIgnoreCase(extension)) {
|
||||
filename += "." + extension;
|
||||
}
|
||||
}
|
||||
@@ -396,16 +419,15 @@ public final class WorldEdit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the direction vector for a player's direction. May return
|
||||
* null if a direction could not be found.
|
||||
* Get the direction vector for a player's direction.
|
||||
*
|
||||
* @param player the player
|
||||
* @param dirStr the direction string
|
||||
* @return a direction vector
|
||||
* @throws UnknownDirectionException thrown if the direction is not known
|
||||
* @throws UnknownDirectionException thrown if the direction is not known, or a relative direction is used with null player
|
||||
*/
|
||||
public BlockVector3 getDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||
dirStr = dirStr.toLowerCase();
|
||||
public BlockVector3 getDirection(@Nullable Player player, String dirStr) throws UnknownDirectionException {
|
||||
dirStr = dirStr.toLowerCase(Locale.ROOT);
|
||||
|
||||
final Direction dir = getPlayerDirection(player, dirStr);
|
||||
|
||||
@@ -417,16 +439,15 @@ public final class WorldEdit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the direction vector for a player's direction. May return
|
||||
* null if a direction could not be found.
|
||||
* Get the direction vector for a player's direction.
|
||||
*
|
||||
* @param player the player
|
||||
* @param dirStr the direction string
|
||||
* @return a direction vector
|
||||
* @throws UnknownDirectionException thrown if the direction is not known
|
||||
* @throws UnknownDirectionException thrown if the direction is not known, or a relative direction is used with null player
|
||||
*/
|
||||
public BlockVector3 getDiagonalDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||
dirStr = dirStr.toLowerCase();
|
||||
public BlockVector3 getDiagonalDirection(@Nullable Player player, String dirStr) throws UnknownDirectionException {
|
||||
dirStr = dirStr.toLowerCase(Locale.ROOT);
|
||||
|
||||
final Direction dir = getPlayerDirection(player, dirStr);
|
||||
|
||||
@@ -438,15 +459,14 @@ public final class WorldEdit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the direction vector for a player's direction. May return
|
||||
* null if a direction could not be found.
|
||||
* Get the direction vector for a player's direction.
|
||||
*
|
||||
* @param player the player
|
||||
* @param dirStr the direction string
|
||||
* @return a direction enum value
|
||||
* @throws UnknownDirectionException thrown if the direction is not known
|
||||
* @throws UnknownDirectionException thrown if the direction is not known, or a relative direction is used with null player
|
||||
*/
|
||||
private Direction getPlayerDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||
private Direction getPlayerDirection(@Nullable Player player, String dirStr) throws UnknownDirectionException {
|
||||
final Direction dir;
|
||||
|
||||
switch (dirStr.charAt(0)) {
|
||||
@@ -490,19 +510,19 @@ public final class WorldEdit {
|
||||
|
||||
case 'm': // me
|
||||
case 'f': // forward
|
||||
dir = player.getCardinalDirection(0);
|
||||
dir = getDirectionRelative(player, 0);
|
||||
break;
|
||||
|
||||
case 'b': // back
|
||||
dir = player.getCardinalDirection(180);
|
||||
dir = getDirectionRelative(player, 180);
|
||||
break;
|
||||
|
||||
case 'l': // left
|
||||
dir = player.getCardinalDirection(-90);
|
||||
dir = getDirectionRelative(player, -90);
|
||||
break;
|
||||
|
||||
case 'r': // right
|
||||
dir = player.getCardinalDirection(90);
|
||||
dir = getDirectionRelative(player, 90);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -511,6 +531,13 @@ public final class WorldEdit {
|
||||
return dir;
|
||||
}
|
||||
|
||||
private Direction getDirectionRelative(Player player, int yawOffset) throws UnknownDirectionException {
|
||||
if (player != null) {
|
||||
return player.getCardinalDirection(yawOffset);
|
||||
}
|
||||
throw new UnknownDirectionException("Only a player can use relative directions");
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush a block bag's changes to a player.
|
||||
*
|
||||
@@ -650,9 +677,9 @@ public final class WorldEdit {
|
||||
|
||||
try {
|
||||
engine = new RhinoCraftScriptEngine();
|
||||
} catch (NoClassDefFoundError e) {
|
||||
} catch (NoClassDefFoundError ignored) {
|
||||
player.printError("Failed to find an installed script engine.");
|
||||
player.printError("Please see http://wiki.sk89q.com/wiki/WorldEdit/Installation");
|
||||
player.printError("Please see https://worldedit.readthedocs.io/en/latest/usage/other/craftscripts/");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user