Minor upstream changes

This commit is contained in:
MattBDev 2020-01-31 17:44:50 -05:00
parent 38d5506e18
commit 6c5ac08a3c
4 changed files with 74 additions and 71 deletions

View File

@ -22,8 +22,6 @@ package com.sk89q.worldedit.bukkit;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.component.TextUtils;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.util.TaskManager;
@ -42,6 +40,7 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.component.TextUtils;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
@ -51,8 +50,6 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Locale;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
@ -65,11 +62,13 @@ import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import javax.annotation.Nullable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Locale;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nullable;
public class BukkitPlayer extends AbstractPlayerActor {
@ -214,7 +213,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
public boolean hasPermission(String perm) {
return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp())
|| plugin.getPermissionsResolver().hasPermission(
player.getWorld().getName(), player, perm);
player.getWorld().getName(), player, perm);
}
@Override
@ -249,6 +248,10 @@ public class BukkitPlayer extends AbstractPlayerActor {
player.sendPluginMessage(plugin, WorldEditPlugin.CUI_PLUGIN_CHANNEL, send.getBytes(CUIChannelListener.UTF_8_CHARSET));
}
public Player getPlayer() {
return player;
}
@Override
public boolean isAllowedToFly() {
return player.getAllowFlight();
@ -290,7 +293,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() == null) {
printError(TranslatableComponent.of("worldedit.version.bukkit.unsupported-adapter",
TextComponent.of("https://intellectualsites.github.io/download/fawe.html", TextColor.AQUA)
.clickEvent(ClickEvent.openUrl("https://intellectualsites.github.io/download/fawe.html"))));
.clickEvent(ClickEvent.openUrl("https://intellectualsites.github.io/download/fawe.html"))));
}
}
@ -374,13 +377,4 @@ public class BukkitPlayer extends AbstractPlayerActor {
player.removeMetadata("WE", WorldEditPlugin.getInstance());
}
public Player getPlayer() {
if (!player.isValid()) {
Player tmp = Bukkit.getPlayer(getUniqueId());
if (tmp != null) {
player = tmp;
}
}
return player;
}
}

View File

@ -19,8 +19,6 @@
package com.sk89q.worldedit.bukkit;
import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
import com.sk89q.bukkit.util.CommandInfo;
import com.sk89q.bukkit.util.CommandRegistration;
import com.sk89q.worldedit.LocalConfiguration;
@ -35,6 +33,13 @@ import com.sk89q.worldedit.extension.platform.Watchdog;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.registry.Registries;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.enginehub.piston.CommandManager;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
@ -43,12 +48,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.bukkit.Bukkit;
import javax.annotation.Nullable;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.enginehub.piston.CommandManager;
import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
public class BukkitServerInterface implements MultiUserPlatform {
public Server server;
@ -70,6 +71,10 @@ public class BukkitServerInterface implements MultiUserPlatform {
dynamicCommands = new CommandRegistration(plugin);
}
CommandRegistration getDynamicCommands() {
return dynamicCommands;
}
boolean isHookingEvents() {
return hookingEvents;
}

View File

@ -19,8 +19,6 @@
package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.FaweBukkit;
@ -43,8 +41,8 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.anvil.ChunkDeleter;
import com.sk89q.worldedit.internal.command.CommandUtil;
import com.sk89q.worldedit.internal.anvil.ChunkDeleter;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.entity.EntityType;
@ -52,25 +50,9 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemCategory;
import com.sk89q.worldedit.world.weather.WeatherTypes;
import io.papermc.lib.PaperLib;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.zip.ZipEntry;
import javax.annotation.Nullable;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -95,6 +77,26 @@ import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.zip.ZipEntry;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME;
/**
* Plugin for Bukkit.
*/
@ -103,6 +105,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
private static final Logger log = LoggerFactory.getLogger(WorldEditPlugin.class);
public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui";
private static WorldEditPlugin INSTANCE;
///The BSTATS_ID needs to be modified for FAWE to prevent contaminating WorldEdit stats
private static final int BSTATS_ID = 1403;
private BukkitImplAdapter bukkitAdapter;
@ -125,8 +128,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
public boolean add(Plugin plugin) {
if (plugin.getName().startsWith("AsyncWorldEdit")) {
log.debug("Disabling `" + plugin.getName() + "` as it is incompatible");
} else if (plugin.getName().startsWith("BetterShutdown")) {
log.debug("Disabling `" + plugin.getName() + "` as it is incompatible (Improperly shaded classes from com.sk89q.minecraft.util.commands)");
} else {
return super.add(plugin);
}
@ -136,7 +137,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
lookupNamesField.set(manager, lookupNames = new ConcurrentHashMap<String, Plugin>(lookupNames) {
@Override
public Plugin put(@NotNull String key, @NotNull Plugin plugin) {
if (plugin.getName().startsWith("AsyncWorldEdit") || plugin.getName().startsWith("BetterShutdown")) {
if (plugin.getName().startsWith("AsyncWorldEdit")) {
return null;
}
return super.put(key, plugin);
@ -420,22 +421,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
this.getServer().getScheduler().cancelTasks(this);
}
/*
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) {
// Add the command to the array because the underlying command handling
// code of WorldEdit expects it
String[] split = new String[args.length + 1];
System.arraycopy(args, 0, split, 1, args.length);
split[0] = commandLabel;
String arguments = Joiner.on(" ").join(split);
CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments);
getWorldEdit().getEventBus().post(event);
return CommandUtil.fixSuggestions(arguments, event.getSuggestions());
}
*/
/**
* Loads and reloads all configuration.
*/
@ -491,6 +476,25 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
return true;
}
/*
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) {
int plSep = commandLabel.indexOf(":");
if (plSep >= 0 && plSep < commandLabel.length() + 1) {
commandLabel = commandLabel.substring(plSep + 1);
}
StringBuilder sb = new StringBuilder("/").append(commandLabel);
if (args.length > 0) {
sb.append(" ");
}
String arguments = Joiner.on(" ").appendTo(sb, args).toString();
CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments);
getWorldEdit().getEventBus().post(event);
return CommandUtil.fixSuggestions(arguments, event.getSuggestions());
}
*/
/**
* Gets the session for the player.
*
@ -647,7 +651,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
String buffer = event.getBuffer();
int firstSpace = buffer.indexOf(' ');
if (firstSpace < 0) return;
final String label = buffer.substring(0, firstSpace);
String label = buffer.substring(0, firstSpace);
final Optional<org.enginehub.piston.Command> command
= WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(label);
if (!command.isPresent()) return;

View File

@ -57,7 +57,7 @@ public class ReflectionUtils {
}
public static void setFailsafeFieldValue(Field field, Object target, Object value)
throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
setAccessibleNonFinal(field);
field.set(target,value);
@ -635,9 +635,9 @@ public class ReflectionUtils {
* Constructor wrapper
*/
public static class RefConstructor {
private final Constructor constructor;
private final Constructor<?> constructor;
private RefConstructor(Constructor constructor) {
private RefConstructor(Constructor<?> constructor) {
this.constructor = constructor;
constructor.setAccessible(true);
}
@ -645,7 +645,7 @@ public class ReflectionUtils {
/**
* @return passed constructor
*/
public Constructor getRealConstructor() {
public Constructor<?> getRealConstructor() {
return this.constructor;
}
@ -702,7 +702,7 @@ public class ReflectionUtils {
}
/**
* apply fiend for object
* Apply field for object
*
* @param e applied object
* @return RefExecutor with getter and setter
@ -719,7 +719,7 @@ public class ReflectionUtils {
}
/**
* set field value for applied object
* Set field value for applied object
*
* @param param value
*/
@ -732,7 +732,7 @@ public class ReflectionUtils {
}
/**
* get field value for applied object
* Get field value for the applied object..
*
* @return value of field
*/