mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
fix dependencies
This commit is contained in:
@ -19,14 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.internal.util.Substring;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.exception.CommandException;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
@ -40,6 +38,9 @@ import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public class CommandUtil {
|
||||
|
||||
public static Map<String, Command> getSubCommands(Command currentCommand) {
|
||||
@ -64,20 +65,37 @@ public class CommandUtil {
|
||||
* Fix {@code suggestions} to replace the last space-separated word in {@code arguments}.
|
||||
*/
|
||||
public static List<String> fixSuggestions(String arguments, List<Substring> suggestions) {
|
||||
Substring lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments));
|
||||
Substring lastArg = Iterables.getLast(
|
||||
CommandArgParser.spaceSplit(arguments)
|
||||
);
|
||||
return suggestions.stream()
|
||||
.map(suggestion -> CommandUtil.suggestLast(lastArg, suggestion))
|
||||
// Re-map suggestions to only operate on the last non-quoted word
|
||||
.map(suggestion -> onlyOnLastQuotedWord(lastArg, suggestion))
|
||||
.map(suggestion -> suggestLast(lastArg, suggestion))
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
private static Substring onlyOnLastQuotedWord(Substring lastArg, Substring suggestion) {
|
||||
if (suggestion.getSubstring().startsWith(lastArg.getSubstring())) {
|
||||
// This is already fine.
|
||||
return suggestion;
|
||||
}
|
||||
String substr = suggestion.getSubstring();
|
||||
int sp = substr.lastIndexOf(' ');
|
||||
if (sp < 0) {
|
||||
return suggestion;
|
||||
}
|
||||
return Substring.wrap(substr.substring(sp + 1), suggestion.getStart() + sp + 1, suggestion.getEnd());
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the last word of a command, mutate the suggestion to replace the last word, if
|
||||
* possible.
|
||||
*/
|
||||
private static Optional<String> suggestLast(Substring last, Substring suggestion) {
|
||||
if (suggestion.getStart() == last.getEnd()) {
|
||||
if (suggestion.getStart() == last.getEnd() && !last.getSubstring().equals("\"")) {
|
||||
// this suggestion is for the next argument.
|
||||
if (last.getSubstring().isEmpty()) {
|
||||
return Optional.of(suggestion.getSubstring());
|
||||
|
@ -32,6 +32,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -114,11 +115,12 @@ public class ServerCUIHandler {
|
||||
}
|
||||
|
||||
// Borrowed this math from FAWE
|
||||
double rotX = player.getLocation().getYaw();
|
||||
double rotY = player.getLocation().getPitch();
|
||||
final Location location = player.getLocation();
|
||||
double rotX = location.getYaw();
|
||||
double rotY = location.getPitch();
|
||||
double xz = Math.cos(Math.toRadians(rotY));
|
||||
int x = (int) (player.getLocation().getX() - (-xz * Math.sin(Math.toRadians(rotX))) * 12);
|
||||
int z = (int) (player.getLocation().getZ() - (xz * Math.cos(Math.toRadians(rotX))) * 12);
|
||||
int x = (int) (location.getX() - (-xz * Math.sin(Math.toRadians(rotX))) * 12);
|
||||
int z = (int) (location.getZ() - (xz * Math.cos(Math.toRadians(rotX))) * 12);
|
||||
int y = Math.max(0, Math.min(Math.min(255, posY + 32), posY + 3));
|
||||
|
||||
Map<String, Tag> structureTag = new HashMap<>();
|
||||
|
Reference in New Issue
Block a user