mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-10 04:48:34 +00:00
Javadoc and Formatting fixes. (#619)
Javadoc and Formatting fixes. Also, extremely minor code changes which have been tested. This commit is only part one of two commits that aim to fix problems with formatting in our project. In part two I will modify the Google Java Style Guide (since it closely matches our code style) for our project so there is guidance on how to format and document. * Updated PlotSquared URL * Removed plugin acronyms * Fixed a typo * Fixed grammar * Use modern block id's * Update YouTube video URL
This commit is contained in:
@ -286,7 +286,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
stateString = blockAndExtraData[0].substring(stateStart + 1, blockAndExtraData[0].length() - 1);
|
||||
}
|
||||
String[] stateProperties = EMPTY_STRING_ARRAY;
|
||||
if(stateString != null) {
|
||||
if (stateString != null) {
|
||||
stateProperties = stateString.split(",");
|
||||
}
|
||||
if (typeString.isEmpty()) {
|
||||
|
@ -55,8 +55,12 @@ public abstract class RichParser<E> extends InputParser<E> {
|
||||
|
||||
@Override
|
||||
public E parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
if (!input.startsWith(this.prefix)) return null;
|
||||
if (input.length() < this.prefix.length()) return null;
|
||||
if (!input.startsWith(this.prefix)) {
|
||||
return null;
|
||||
}
|
||||
if (input.length() < this.prefix.length()) {
|
||||
return null;
|
||||
}
|
||||
String[] arguments = extractArguments(input.substring(prefix.length()), true);
|
||||
return parseFromInput(arguments, context);
|
||||
}
|
||||
|
@ -29,14 +29,18 @@ public class AdjacentMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length == 0) return null;
|
||||
if (arguments.length == 0) {
|
||||
return null;
|
||||
}
|
||||
Mask subMask = worldEdit.getMaskFactory().parseFromInput(arguments[0], context);
|
||||
int min = arguments.length > 1 ? Integer.parseInt(arguments[1]) : -1;
|
||||
int max = arguments.length > 2 ? Integer.parseInt(arguments[2]) : -1;
|
||||
if (min == -1 && max == -1) {
|
||||
min = 1;
|
||||
max = 8;
|
||||
} else if (max == -1) max = min;
|
||||
} else if (max == -1) {
|
||||
max = min;
|
||||
}
|
||||
if (max >= 8 && min == 1) {
|
||||
return new AdjacentAnyMask(subMask);
|
||||
}
|
||||
|
@ -30,14 +30,15 @@ public class AngleMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) return null;
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException("Cannot combine degree with block-step");
|
||||
}
|
||||
double min, max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
@ -49,6 +50,8 @@ public class AngleMaskParser extends RichParser<Mask> {
|
||||
}
|
||||
}
|
||||
}
|
||||
double min;
|
||||
double max;
|
||||
if (degree) {
|
||||
double minDeg = Double.parseDouble(minArg.substring(0, minArg.length() - 1));
|
||||
double maxDeg = Double.parseDouble(maxArg.substring(0, maxArg.length() - 1));
|
||||
|
@ -118,7 +118,7 @@
|
||||
//// () -> {
|
||||
//// if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());
|
||||
//// return dispatcher.getAliases().stream().filter(
|
||||
//// s -> s.startsWith(command.toLowerCase())
|
||||
//// s -> s.startsWith(command.toLowerCase(Locale.ROOT))
|
||||
//// ).collect(Collectors.toList());
|
||||
//// }
|
||||
//// );
|
||||
@ -147,7 +147,7 @@
|
||||
// input = input.substring(input.indexOf(char0) + 1);
|
||||
// mask = parseFromInput(char0 + "[" + input + "]", context);
|
||||
// if (actor != null) {
|
||||
// actor.print(Caption.of("fawe.worldedit.help.command.clarifying.bracket" , char0 + "[" + input + "]"));
|
||||
// actor.print(Caption.of("fawe.worldedit.help.command.clarifying.bracket", char0 + "[" + input + "]"));
|
||||
// }
|
||||
// return mask;
|
||||
// }
|
||||
@ -164,7 +164,7 @@
|
||||
// {
|
||||
// try {
|
||||
// builder.addRegex(full);
|
||||
// } catch (InputParseException ignore) {}
|
||||
// } catch (InputParseException ignored) {}
|
||||
// }
|
||||
// if (mask == null) {
|
||||
// context.setPreferringWildcard(false);
|
||||
|
@ -30,14 +30,17 @@ public class ExtremaMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) return null;
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException("Cannot combine degree with block-step");
|
||||
}
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
|
@ -30,14 +30,17 @@ public class ROCAngleMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) return null;
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException("Cannot combine degree with block-step");
|
||||
}
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
|
@ -26,7 +26,9 @@ public class RadiusMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2) return null;
|
||||
if (arguments.length < 2) {
|
||||
return null;
|
||||
}
|
||||
int min = Integer.parseInt(arguments[0]);
|
||||
int max = Integer.parseInt(arguments[1]);
|
||||
return new RadiusMask(min, max);
|
||||
|
@ -27,7 +27,9 @@ public class SimplexMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length != 3) return null;
|
||||
if (arguments.length != 3) {
|
||||
return null;
|
||||
}
|
||||
double scale = Double.parseDouble(arguments[0]);
|
||||
double min = Double.parseDouble(arguments[1]);
|
||||
double max = Double.parseDouble(arguments[2]);
|
||||
|
@ -5,7 +5,10 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.*;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
|
@ -26,6 +26,8 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
@ -79,7 +81,7 @@ public class RandomPatternParser extends InputParser<Pattern> {
|
||||
String[] p = token.split("%", 2);
|
||||
|
||||
if (p.length < 2) {
|
||||
throw new InputParseException("Missing the type after the % symbol for '" + input + "'");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.missing-random-type", TextComponent.of(input)));
|
||||
} else {
|
||||
chance = Double.parseDouble(p[0]);
|
||||
innerPattern = worldEdit.getPatternFactory().parseFromInput(p[1], context);
|
||||
|
@ -30,6 +30,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.StateApplyingPattern;
|
||||
import com.sk89q.worldedit.function.pattern.TypeApplyingPattern;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -82,19 +84,29 @@ public class TypeOrStateApplyingPatternParser extends InputParser<Pattern> {
|
||||
worldEdit.getBlockFactory().parseFromInput(type, context).getBlockType().getDefaultState());
|
||||
} else {
|
||||
// states given
|
||||
if (!parts[1].endsWith("]")) throw new InputParseException("State is missing trailing ']'");
|
||||
if (!parts[1].endsWith("]")) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.missing-rbracket"));
|
||||
}
|
||||
final String[] states = parts[1].substring(0, parts[1].length() - 1).split(",");
|
||||
Map<String, String> statesToSet = new HashMap<>();
|
||||
for (String state : states) {
|
||||
if (state.isEmpty()) throw new InputParseException("Empty part in state");
|
||||
if (state.isEmpty()) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.empty-state"));
|
||||
}
|
||||
String[] propVal = state.split("=", 2);
|
||||
if (propVal.length != 2) throw new InputParseException("Missing '=' separator");
|
||||
if (propVal.length != 2) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.missing-equals-separator"));
|
||||
}
|
||||
final String prop = propVal[0];
|
||||
if (prop.isEmpty()) throw new InputParseException("Empty property in state");
|
||||
if (prop.isEmpty()) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.empty-property"));
|
||||
}
|
||||
final String value = propVal[1];
|
||||
if (value.isEmpty()) throw new InputParseException("Empty value in state");
|
||||
if (value.isEmpty()) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.empty-value"));
|
||||
}
|
||||
if (statesToSet.put(prop, value) != null) {
|
||||
throw new InputParseException("Duplicate properties in state");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.duplicate-property", TextComponent.of(prop)));
|
||||
}
|
||||
}
|
||||
if (type.isEmpty()) {
|
||||
|
@ -36,10 +36,14 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class ParserContext {
|
||||
|
||||
private @Nullable Extent extent;
|
||||
private @Nullable LocalSession session;
|
||||
private @Nullable World world;
|
||||
private @Nullable Actor actor;
|
||||
@Nullable
|
||||
private Extent extent;
|
||||
@Nullable
|
||||
private LocalSession session;
|
||||
@Nullable
|
||||
private World world;
|
||||
@Nullable
|
||||
private Actor actor;
|
||||
private boolean restricted = true;
|
||||
private boolean tryLegacy = true;
|
||||
private boolean preferringWildcard;
|
||||
@ -71,7 +75,8 @@ public class ParserContext {
|
||||
*
|
||||
* @return an extent
|
||||
*/
|
||||
public @Nullable Extent getExtent() {
|
||||
@Nullable
|
||||
public Extent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
|
||||
@ -89,7 +94,8 @@ public class ParserContext {
|
||||
*
|
||||
* @return a session
|
||||
*/
|
||||
public @Nullable LocalSession getSession() {
|
||||
@Nullable
|
||||
public LocalSession getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
@ -107,7 +113,8 @@ public class ParserContext {
|
||||
*
|
||||
* @return a world
|
||||
*/
|
||||
public @Nullable World getWorld() {
|
||||
@Nullable
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@ -126,7 +133,8 @@ public class ParserContext {
|
||||
*
|
||||
* @return an actor, or null
|
||||
*/
|
||||
public @Nullable Actor getActor() {
|
||||
@Nullable
|
||||
public Actor getActor() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
|
@ -76,22 +76,8 @@ import javax.annotation.Nullable;
|
||||
* players that make use of WorldEdit.
|
||||
*/
|
||||
public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
private final Map<String, Object> meta;
|
||||
|
||||
public AbstractPlayerActor(Map<String, Object> meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public AbstractPlayerActor() {
|
||||
this(new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRawMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
// Queue for async tasks
|
||||
private AtomicInteger runningCount = new AtomicInteger();
|
||||
private AsyncNotifyQueue asyncNotifyQueue = new AsyncNotifyQueue(
|
||||
@ -111,6 +97,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
}
|
||||
});
|
||||
|
||||
public AbstractPlayerActor(Map<String, Object> meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public AbstractPlayerActor() {
|
||||
this(new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Extent getExtent() {
|
||||
return getWorld();
|
||||
@ -146,6 +140,11 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRawMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHoldingPickAxe() {
|
||||
ItemType item = getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
@ -250,7 +249,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
return false;
|
||||
}
|
||||
return getWorld().getBlock(location.add(0, -1, 0)).getBlockType().getMaterial()
|
||||
.isMovementBlocker();
|
||||
.isMovementBlocker();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -522,6 +521,52 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
return getCardinalDirection(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player's current allowed WorldEdit regions.
|
||||
*
|
||||
* @return an array of allowed regions
|
||||
*/
|
||||
public Region[] getCurrentRegions() {
|
||||
return getCurrentRegions(FaweMaskManager.MaskType.MEMBER);
|
||||
}
|
||||
|
||||
public Region[] getCurrentRegions(FaweMaskManager.MaskType type) {
|
||||
return WEManager.IMP.getMask(this, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the largest region in the player's allowed WorldEdit region.
|
||||
*/
|
||||
public Region getLargestRegion() {
|
||||
long area = 0;
|
||||
Region max = null;
|
||||
for (Region region : this.getCurrentRegions()) {
|
||||
final long tmp = region.getVolume();
|
||||
if (tmp > area) {
|
||||
area = tmp;
|
||||
max = region;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setSelection(Region region) {
|
||||
RegionSelector selector;
|
||||
if (region instanceof ConvexPolyhedralRegion) {
|
||||
selector = new ConvexPolyhedralRegionSelector((ConvexPolyhedralRegion) region);
|
||||
} else if (region instanceof CylinderRegion) {
|
||||
selector = new CylinderRegionSelector((CylinderRegion) region);
|
||||
} else if (region instanceof Polygonal2DRegion) {
|
||||
selector = new Polygonal2DRegionSelector((Polygonal2DRegion) region);
|
||||
} else {
|
||||
selector = new CuboidRegionSelector(null, region.getMinimumPoint(),
|
||||
region.getMaximumPoint());
|
||||
}
|
||||
selector.setWorld(region.getWorld());
|
||||
|
||||
getSession().setRegionSelector(getWorld(), selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getCardinalDirection(int yawOffset) {
|
||||
final Location location = getLocation();
|
||||
@ -631,6 +676,36 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task either async, or on the current thread.
|
||||
*
|
||||
* @param ifFree the task to run if free
|
||||
* @param checkFree Whether to first check if a task is running
|
||||
* @param async TODO description
|
||||
* @return false if the task was ran or queued
|
||||
*/
|
||||
public boolean runAction(Runnable ifFree, boolean checkFree, boolean async) {
|
||||
if (checkFree) {
|
||||
if (runningCount.get() != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Runnable wrapped = () -> {
|
||||
try {
|
||||
runningCount.addAndGet(1);
|
||||
ifFree.run();
|
||||
} finally {
|
||||
runningCount.decrementAndGet();
|
||||
}
|
||||
};
|
||||
if (async) {
|
||||
asyncNotifyQueue.run(wrapped);
|
||||
} else {
|
||||
TaskManager.IMP.taskNow(wrapped, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDestroyBedrock() {
|
||||
return hasPermission("worldedit.override.bedrock");
|
||||
@ -690,84 +765,4 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task either async, or on the current thread.
|
||||
*
|
||||
* @param ifFree the task to run if free
|
||||
* @param checkFree Whether to first check if a task is running
|
||||
* @param async TODO description
|
||||
* @return false if the task was ran or queued
|
||||
*/
|
||||
public boolean runAction(Runnable ifFree, boolean checkFree, boolean async) {
|
||||
if (checkFree) {
|
||||
if (runningCount.get() != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Runnable wrapped = () -> {
|
||||
try {
|
||||
runningCount.addAndGet(1);
|
||||
ifFree.run();
|
||||
} finally {
|
||||
runningCount.decrementAndGet();
|
||||
}
|
||||
};
|
||||
if (async) {
|
||||
asyncNotifyQueue.run(wrapped);
|
||||
} else {
|
||||
TaskManager.IMP.taskNow(wrapped, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the player's current allowed WorldEdit regions.
|
||||
*
|
||||
* @return an array of allowed regions
|
||||
*/
|
||||
public Region[] getCurrentRegions() {
|
||||
return getCurrentRegions(FaweMaskManager.MaskType.MEMBER);
|
||||
}
|
||||
|
||||
public Region[] getCurrentRegions(FaweMaskManager.MaskType type) {
|
||||
return WEManager.IMP.getMask(this, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the largest region in the player's allowed WorldEdit region.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Region getLargestRegion() {
|
||||
long area = 0;
|
||||
Region max = null;
|
||||
for (Region region : this.getCurrentRegions()) {
|
||||
final long tmp = region.getVolume();
|
||||
if (tmp > area) {
|
||||
area = tmp;
|
||||
max = region;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setSelection(Region region) {
|
||||
RegionSelector selector;
|
||||
if (region instanceof ConvexPolyhedralRegion) {
|
||||
selector = new ConvexPolyhedralRegionSelector((ConvexPolyhedralRegion) region);
|
||||
} else if (region instanceof CylinderRegion) {
|
||||
selector = new CylinderRegionSelector((CylinderRegion) region);
|
||||
} else if (region instanceof Polygonal2DRegion) {
|
||||
selector = new Polygonal2DRegionSelector((Polygonal2DRegion) region);
|
||||
} else {
|
||||
selector = new CuboidRegionSelector(null, region.getMinimumPoint(),
|
||||
region.getMaximumPoint());
|
||||
}
|
||||
selector.setWorld(region.getWorld());
|
||||
|
||||
getSession().setRegionSelector(getWorld(), selector);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -98,7 +98,8 @@ public interface Platform {
|
||||
*
|
||||
* @return the watchdog service, or {@code null} if none
|
||||
*/
|
||||
default @Nullable Watchdog getWatchdog() {
|
||||
@Nullable
|
||||
default Watchdog getWatchdog() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -620,7 +620,9 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
|
||||
public int parseCommand(String args, InjectedValueAccess access) {
|
||||
if (args.isEmpty()) return 0;
|
||||
if (args.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
String[] split = parseArgs(args)
|
||||
.map(Substring::getSubstring)
|
||||
.toArray(String[]::new);
|
||||
@ -841,6 +843,7 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
throw t;
|
||||
}
|
||||
|
||||
event.setSuggestions(suggestions.stream()
|
||||
.map(suggestion -> {
|
||||
int noSlashLength = arguments.length() - 1;
|
||||
|
@ -77,7 +77,8 @@ public class PlatformManager {
|
||||
private final PlatformCommandManager platformCommandManager;
|
||||
private final List<Platform> platforms = new ArrayList<>();
|
||||
private final Map<Capability, Platform> preferences = new EnumMap<>(Capability.class);
|
||||
private @Nullable String firstSeenVersion;
|
||||
@Nullable
|
||||
private String firstSeenVersion;
|
||||
private final AtomicBoolean initialized = new AtomicBoolean();
|
||||
private final AtomicBoolean configured = new AtomicBoolean();
|
||||
|
||||
@ -112,9 +113,8 @@ public class PlatformManager {
|
||||
// Make sure that versions are in sync
|
||||
if (firstSeenVersion != null) {
|
||||
if (!firstSeenVersion.equals(platform.getVersion())) {
|
||||
logger.warn("Multiple ports of WorldEdit are installed but they report different versions ({} and {}). " +
|
||||
"If these two versions are truly different, then you may run into unexpected crashes and errors.",
|
||||
new Object[]{ firstSeenVersion, platform.getVersion() });
|
||||
logger.warn("Multiple ports of WorldEdit are installed but they report different versions ({} and {}). "
|
||||
+ "If these two versions are truly different, then you may run into unexpected crashes and errors.", firstSeenVersion, platform.getVersion());
|
||||
}
|
||||
} else {
|
||||
firstSeenVersion = platform.getVersion();
|
||||
@ -209,7 +209,8 @@ public class PlatformManager {
|
||||
* @param capability the capability
|
||||
* @return the most preferred platform, or null if no platform was found
|
||||
*/
|
||||
private synchronized @Nullable Platform findMostPreferred(Capability capability) {
|
||||
@Nullable
|
||||
private synchronized Platform findMostPreferred(Capability capability) {
|
||||
Platform preferred = null;
|
||||
Preference highest = null;
|
||||
|
||||
@ -352,7 +353,9 @@ public class PlatformManager {
|
||||
}
|
||||
|
||||
virtual.handleBlockInteract(player, vector.toBlockPoint(), event);
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getType() == Interaction.HIT) {
|
||||
@ -363,8 +366,8 @@ public class PlatformManager {
|
||||
if (superPickaxe != null && superPickaxe.canUse(player)) {
|
||||
player.runAction(() -> reset(superPickaxe)
|
||||
.actPrimary(queryCapability(Capability.WORLD_EDITING),
|
||||
getConfiguration(), player, session, location), false, true);
|
||||
event.setCancelled(true);
|
||||
getConfiguration(), player, session, location), false, true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -373,11 +376,11 @@ public class PlatformManager {
|
||||
if (tool instanceof DoubleActionBlockTool && tool.canUse(player)) {
|
||||
player.runAction(() -> reset((DoubleActionBlockTool) tool)
|
||||
.actSecondary(queryCapability(Capability.WORLD_EDITING),
|
||||
getConfiguration(), player, session, location), false, true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
getConfiguration(), player, session, location), false, true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
} else if (event.getType() == Interaction.OPEN) {
|
||||
} else if (event.getType() == Interaction.OPEN) {
|
||||
Tool tool = session.getTool(player);
|
||||
if (tool instanceof BlockTool && tool.canUse(player)) {
|
||||
if (player.checkAction()) {
|
||||
@ -385,14 +388,14 @@ public class PlatformManager {
|
||||
BlockTool blockTool = (BlockTool) tool;
|
||||
if (!(tool instanceof BrushTool)) {
|
||||
blockTool = reset(blockTool);
|
||||
}
|
||||
}
|
||||
blockTool.actPrimary(queryCapability(Capability.WORLD_EDITING),
|
||||
getConfiguration(), player, session, location);
|
||||
getConfiguration(), player, session, location);
|
||||
}, false, true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
handleThrowable(e, actor);
|
||||
} finally {
|
||||
@ -403,7 +406,7 @@ public class PlatformManager {
|
||||
public void handleThrowable(Throwable e, Actor actor) {
|
||||
FaweException faweException = FaweException.get(e);
|
||||
if (faweException != null) {
|
||||
actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason" , faweException.getComponent()));
|
||||
actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason", faweException.getComponent()));
|
||||
} else {
|
||||
actor.printError("Please report this error: [See console]");
|
||||
actor.printRaw(e.getClass().getName() + ": " + e.getMessage());
|
||||
@ -423,7 +426,9 @@ public class PlatformManager {
|
||||
logger.info("virtualWorld was not null in handlePlayerInput()");
|
||||
}
|
||||
virtual.handlePlayerInput(player, event);
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@ -432,10 +437,10 @@ public class PlatformManager {
|
||||
Tool tool = session.getTool(player);
|
||||
if (tool instanceof DoubleActionTraceTool && tool.canUse(player)) {
|
||||
player.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING),
|
||||
getConfiguration(), player, session));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
getConfiguration(), player, session));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -445,10 +450,10 @@ public class PlatformManager {
|
||||
if (tool instanceof TraceTool && tool.canUse(player)) {
|
||||
//todo this needs to be fixed so the event is canceled after actPrimary is used and returns true
|
||||
player.runAction(() -> reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING),
|
||||
getConfiguration(), player, session), false, true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
getConfiguration(), player, session), false, true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -456,7 +461,7 @@ public class PlatformManager {
|
||||
} catch (Throwable e) {
|
||||
FaweException faweException = FaweException.get(e);
|
||||
if (faweException != null) {
|
||||
player.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason" , faweException.getComponent()));
|
||||
player.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason", faweException.getComponent()));
|
||||
} else {
|
||||
player.printError("Please report this error: [See console]");
|
||||
player.printRaw(e.getClass().getName() + ": " + e.getMessage());
|
||||
|
@ -41,7 +41,9 @@ public class Bindings {
|
||||
private boolean register(Method method, InjectedValueStore store, CommandManager manager) {
|
||||
// Check that it has the binding
|
||||
Binding binding = method.getAnnotation(Binding.class);
|
||||
if (binding == null) return false;
|
||||
if (binding == null) {
|
||||
return false;
|
||||
}
|
||||
Annotation[] annotations = method.getAnnotations();
|
||||
|
||||
// Get the key
|
||||
@ -49,7 +51,7 @@ public class Bindings {
|
||||
Key key;
|
||||
if ( annotations.length == 1) {
|
||||
key = Key.of(ret);
|
||||
}else if (annotations.length == 2) {
|
||||
} else if (annotations.length == 2) {
|
||||
Annotation annotation = annotations[0] == binding ? annotations[1] : annotations[0];
|
||||
key = Key.of(ret, annotation);
|
||||
} else {
|
||||
|
@ -124,7 +124,7 @@ public class ConsumeBindings extends Bindings {
|
||||
uuid = Fawe.imp().getUUID(argument);
|
||||
}
|
||||
if (uuid == null) {
|
||||
throw new InputParseException(Caption.toString(Caption.of("fawe.error.player.not.found" , argument)));
|
||||
throw new InputParseException(Caption.toString(Caption.of("fawe.error.player.not.found", argument)));
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
@ -202,7 +202,9 @@ public class ConsumeBindings extends Bindings {
|
||||
public BiomeType getBiomeType(String argument) throws WorldEditException {
|
||||
if (argument != null) {
|
||||
|
||||
if (MathMan.isInteger(argument)) return BiomeTypes.getLegacy(Integer.parseInt(argument));
|
||||
if (MathMan.isInteger(argument)) {
|
||||
return BiomeTypes.getLegacy(Integer.parseInt(argument));
|
||||
}
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
Collection<BiomeType> knownBiomes = BiomeType.REGISTRY.values();
|
||||
|
@ -103,7 +103,9 @@ public class PrimitiveBindings extends Bindings {
|
||||
@Binding
|
||||
public Vector3 getVector3(String argument) {
|
||||
String[] radii = argument.split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
final double radiusX;
|
||||
final double radiusY;
|
||||
final double radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
|
||||
@ -133,7 +135,8 @@ public class PrimitiveBindings extends Bindings {
|
||||
public Vector2 getVector2(String argument) {
|
||||
String radiusString = argument;
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusZ;
|
||||
final double radiusX;
|
||||
final double radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
|
||||
@ -161,7 +164,9 @@ public class PrimitiveBindings extends Bindings {
|
||||
public BlockVector3 getBlockVector3(String argument) {
|
||||
String radiusString = argument;
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
final double radiusX;
|
||||
final double radiusY;
|
||||
final double radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
|
||||
@ -190,7 +195,8 @@ public class PrimitiveBindings extends Bindings {
|
||||
@Binding
|
||||
public BlockVector2 getBlockVector2(String argument) {
|
||||
String[] radii = argument.split(",");
|
||||
final double radiusX, radiusZ;
|
||||
final double radiusX;
|
||||
final double radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusZ = parseNumericInput(radii[0]);
|
||||
@ -214,7 +220,8 @@ public class PrimitiveBindings extends Bindings {
|
||||
* @return a number
|
||||
* @throws InputParseException thrown on parse error
|
||||
*/
|
||||
public static @Nullable Double parseNumericInput(@Nullable String input) {
|
||||
@Nullable
|
||||
public static Double parseNumericInput(@Nullable String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user