mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 03:16:41 +00:00
Add and apply .editorconfig from P2 (#1195)
* Consistenty use javax annotations. - Unfortunately jetbrains annotations seem to be exposed transitively via core somewhere, but with the correct IDE settings, annotations can be defaulted to javax - Cleaning up of import order in #1195 - Must be merged before #1195 * Add and apply .editorconfig from P2 - Does not rearrange entries * Address some comments * add back some javadoc comments * Address final comments Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
@ -25,12 +25,12 @@ import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.security.CodeSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -109,7 +109,8 @@ public class ClassSourceValidator {
|
||||
builder.append("** the version of ").append(plugin.getName()).append(" that you downloaded, you\n");
|
||||
builder.append("** will be using a broken mix of old ").append(plugin.getName()).append(" (that came\n");
|
||||
builder.append("** with the plugin) and your downloaded version. THIS MAY\n");
|
||||
builder.append("** SEVERELY BREAK ").append(plugin.getName().toUpperCase(Locale.ROOT)).append(" AND ALL OF ITS FEATURES.\n");
|
||||
builder.append("** SEVERELY BREAK ").append(plugin.getName().toUpperCase(Locale.ROOT)).append(
|
||||
" AND ALL OF ITS FEATURES.\n");
|
||||
builder.append("**\n");
|
||||
builder.append("** This may have happened because the developer is using\n");
|
||||
builder.append("** the ").append(plugin.getName()).append(" API and thinks that including\n");
|
||||
@ -128,4 +129,5 @@ public class ClassSourceValidator {
|
||||
|
||||
LOGGER.error(builder.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,4 +29,5 @@ public interface CommandInspector {
|
||||
String getFullText(Command command);
|
||||
|
||||
boolean testPermission(CommandSender sender, Command command);
|
||||
|
||||
}
|
||||
|
@ -37,8 +37,10 @@ import java.util.Set;
|
||||
public class CommandRegistration {
|
||||
|
||||
static {
|
||||
Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class,
|
||||
new DynamicPluginCommandHelpTopic.Factory());
|
||||
Bukkit.getServer().getHelpMap().registerHelpTopicFactory(
|
||||
DynamicPluginCommand.class,
|
||||
new DynamicPluginCommandHelpTopic.Factory()
|
||||
);
|
||||
}
|
||||
|
||||
protected final Plugin plugin;
|
||||
@ -72,8 +74,14 @@ public class CommandRegistration {
|
||||
return false;
|
||||
}
|
||||
for (CommandInfo command : registered) {
|
||||
DynamicPluginCommand cmd = new DynamicPluginCommand(command.getAliases(),
|
||||
command.getDesc(), "/" + command.getAliases()[0] + " " + command.getUsage(), executor, command.getRegisteredWith(), plugin);
|
||||
DynamicPluginCommand cmd = new DynamicPluginCommand(
|
||||
command.getAliases(),
|
||||
command.getDesc(),
|
||||
"/" + command.getAliases()[0] + " " + command.getUsage(),
|
||||
executor,
|
||||
command.getRegisteredWith(),
|
||||
plugin
|
||||
);
|
||||
cmd.setPermissions(command.getPermissions());
|
||||
commandMap.register(plugin.getDescription().getName(), cmd);
|
||||
}
|
||||
@ -91,7 +99,7 @@ public class CommandRegistration {
|
||||
CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
|
||||
if (commandMap == null) {
|
||||
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName()
|
||||
+ ": Could not retrieve server CommandMap, using fallback instead!");
|
||||
+ ": Could not retrieve server CommandMap, using fallback instead!");
|
||||
fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer());
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin);
|
||||
} else {
|
||||
@ -108,7 +116,7 @@ public class CommandRegistration {
|
||||
if (knownCommands == null || aliases == null) {
|
||||
return false;
|
||||
}
|
||||
for (Iterator<org.bukkit.command.Command> i = knownCommands.values().iterator(); i.hasNext();) {
|
||||
for (Iterator<org.bukkit.command.Command> i = knownCommands.values().iterator(); i.hasNext(); ) {
|
||||
org.bukkit.command.Command cmd = i.next();
|
||||
if (cmd instanceof DynamicPluginCommand && ((DynamicPluginCommand) cmd).getOwner().equals(executor)) {
|
||||
i.remove();
|
||||
|
@ -69,7 +69,13 @@ public class CommandsManagerRegistration extends CommandRegistration {
|
||||
}
|
||||
}
|
||||
|
||||
toRegister.add(new CommandInfo(command.usage(), command.desc(), command.aliases(), commands, permissions == null ? null : permissions.toArray(new String[permissions.size()])));
|
||||
toRegister.add(new CommandInfo(
|
||||
command.usage(),
|
||||
command.desc(),
|
||||
command.aliases(),
|
||||
commands,
|
||||
permissions == null ? null : permissions.toArray(new String[permissions.size()])
|
||||
));
|
||||
}
|
||||
|
||||
return register(toRegister);
|
||||
|
@ -33,8 +33,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An implementation of a dynamically registered {@link org.bukkit.command.Command} attached to a plugin.
|
||||
*/
|
||||
* An implementation of a dynamically registered {@link org.bukkit.command.Command} attached to a plugin.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DynamicPluginCommand extends org.bukkit.command.Command implements PluginIdentifiableCommand {
|
||||
|
||||
@ -43,7 +43,14 @@ public class DynamicPluginCommand extends org.bukkit.command.Command implements
|
||||
protected final Plugin owningPlugin;
|
||||
protected String[] permissions = new String[0];
|
||||
|
||||
public DynamicPluginCommand(String[] aliases, String desc, String usage, CommandExecutor owner, Object registeredWith, Plugin plugin) {
|
||||
public DynamicPluginCommand(
|
||||
String[] aliases,
|
||||
String desc,
|
||||
String usage,
|
||||
CommandExecutor owner,
|
||||
Object registeredWith,
|
||||
Plugin plugin
|
||||
) {
|
||||
super(aliases[0], desc, usage, Arrays.asList(aliases));
|
||||
this.owner = owner;
|
||||
this.owningPlugin = plugin;
|
||||
@ -118,4 +125,5 @@ public class DynamicPluginCommand extends org.bukkit.command.Command implements
|
||||
}
|
||||
return super.testPermissionSilent(sender);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -139,10 +139,12 @@ public class DynamicPluginCommandHelpTopic extends HelpTopic {
|
||||
}
|
||||
|
||||
public static class Factory implements HelpTopicFactory<DynamicPluginCommand> {
|
||||
|
||||
@Override
|
||||
public HelpTopic createTopic(DynamicPluginCommand command) {
|
||||
return new DynamicPluginCommandHelpTopic(command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
private final YAMLProcessor config;
|
||||
private final Map<String, Set<String>> userPermissionsCache = new HashMap<>();
|
||||
private final Set<String> defaultPermissionsCache = new HashSet<>();
|
||||
@ -41,14 +42,14 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public static YAMLNode generateDefaultPerms(YAMLNode section) {
|
||||
section.setProperty("groups.default.permissions", new String[] {
|
||||
"worldedit.reload",
|
||||
"worldedit.selection",
|
||||
"worlds.creative.worldedit.region"
|
||||
section.setProperty("groups.default.permissions", new String[]{
|
||||
"worldedit.reload",
|
||||
"worldedit.selection",
|
||||
"worlds.creative.worldedit.region"
|
||||
});
|
||||
section.setProperty("groups.admins.permissions", new String[] { "*" });
|
||||
section.setProperty("users.sk89q.permissions", new String[] { "worldedit" });
|
||||
section.setProperty("users.sk89q.groups", new String[] { "admins" });
|
||||
section.setProperty("groups.admins.permissions", new String[]{"*"});
|
||||
section.setProperty("users.sk89q.permissions", new String[]{"worldedit"});
|
||||
section.setProperty("users.sk89q.groups", new String[]{"admins"});
|
||||
return section;
|
||||
}
|
||||
|
||||
|
@ -174,4 +174,5 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
public String getDetectionMessage() {
|
||||
return "Using the Bukkit Permissions API.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,10 +20,11 @@
|
||||
package com.sk89q.wepif;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
@ -123,7 +124,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
defaultPermissionsCache = userGroupPermissions.get("default");
|
||||
}
|
||||
|
||||
BufferedReader buff = null;
|
||||
BufferedReader buff = null;
|
||||
|
||||
try {
|
||||
FileReader input = new FileReader(this.userFile);
|
||||
|
@ -28,6 +28,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
public class GroupManagerResolver extends DinnerPermsResolver {
|
||||
|
||||
private final WorldsHolder worldsHolder;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
@ -128,4 +129,5 @@ public class GroupManagerResolver extends DinnerPermsResolver {
|
||||
public String getDetectionMessage() {
|
||||
return "GroupManager detected! Using GroupManager for permissions.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
} catch (Throwable t) {
|
||||
String group = Permissions.Security.getGroup(player.getWorld().getName(), player.getName());
|
||||
if (group != null) {
|
||||
groups = new String[] { group };
|
||||
groups = new String[]{group};
|
||||
}
|
||||
}
|
||||
if (groups == null) {
|
||||
|
@ -27,6 +27,7 @@ import ru.tehkode.permissions.PermissionManager;
|
||||
import ru.tehkode.permissions.PermissionUser;
|
||||
|
||||
public class PermissionsExResolver extends DinnerPermsResolver {
|
||||
|
||||
private final PermissionManager manager;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
@ -90,4 +91,5 @@ public class PermissionsExResolver extends DinnerPermsResolver {
|
||||
public String getDetectionMessage() {
|
||||
return "PermissionsEx detected! Using PermissionsEx for permissions.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.wepif;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public interface PermissionsProvider {
|
||||
|
||||
boolean hasPermission(String name, String permission);
|
||||
|
||||
boolean hasPermission(String worldName, String name, String permission);
|
||||
@ -37,4 +38,5 @@ public interface PermissionsProvider {
|
||||
boolean inGroup(OfflinePlayer player, String group);
|
||||
|
||||
String[] getGroups(OfflinePlayer player);
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,9 @@
|
||||
package com.sk89q.wepif;
|
||||
|
||||
public interface PermissionsResolver extends PermissionsProvider {
|
||||
|
||||
void load();
|
||||
|
||||
String getDetectionMessage();
|
||||
|
||||
}
|
||||
|
@ -41,23 +41,23 @@ import java.util.List;
|
||||
public class PermissionsResolverManager implements PermissionsResolver {
|
||||
|
||||
private static final String CONFIG_HEADER = "#\r\n"
|
||||
+ "# WEPIF Configuration File\r\n"
|
||||
+ "#\r\n"
|
||||
+ "# This file handles permissions configuration for every plugin using WEPIF\r\n"
|
||||
+ "#\r\n"
|
||||
+ "# About editing this file:\r\n"
|
||||
+ "# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If\r\n"
|
||||
+ "# you use an editor like Notepad++ (recommended for Windows users), you\r\n"
|
||||
+ "# must configure it to \"replace tabs with spaces.\" In Notepad++, this can\r\n"
|
||||
+ "# be changed in Settings > Preferences > Language Menu.\r\n"
|
||||
+ "# - Don't get rid of the indents. They are indented so some entries are\r\n"
|
||||
+ "# in categories (like \"enforce-single-session\" is in the \"protection\"\r\n"
|
||||
+ "# category.\r\n"
|
||||
+ "# - If you want to check the format of this file before putting it\r\n"
|
||||
+ "# into WEPIF, paste it into https://yaml-online-parser.appspot.com/\r\n"
|
||||
+ "# and see if it gives \"ERROR:\".\r\n"
|
||||
+ "# - Lines starting with # are comments and so they are ignored.\r\n"
|
||||
+ "\r\n";
|
||||
+ "# WEPIF Configuration File\r\n"
|
||||
+ "#\r\n"
|
||||
+ "# This file handles permissions configuration for every plugin using WEPIF\r\n"
|
||||
+ "#\r\n"
|
||||
+ "# About editing this file:\r\n"
|
||||
+ "# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If\r\n"
|
||||
+ "# you use an editor like Notepad++ (recommended for Windows users), you\r\n"
|
||||
+ "# must configure it to \"replace tabs with spaces.\" In Notepad++, this can\r\n"
|
||||
+ "# be changed in Settings > Preferences > Language Menu.\r\n"
|
||||
+ "# - Don't get rid of the indents. They are indented so some entries are\r\n"
|
||||
+ "# in categories (like \"enforce-single-session\" is in the \"protection\"\r\n"
|
||||
+ "# category.\r\n"
|
||||
+ "# - If you want to check the format of this file before putting it\r\n"
|
||||
+ "# into WEPIF, paste it into https://yaml-online-parser.appspot.com/\r\n"
|
||||
+ "# and see if it gives \"ERROR:\".\r\n"
|
||||
+ "# - Lines starting with # are comments and so they are ignored.\r\n"
|
||||
+ "\r\n";
|
||||
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
@ -86,15 +86,15 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
private final List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
|
||||
PluginPermissionsResolver.class,
|
||||
PermissionsExResolver.class,
|
||||
bPermissionsResolver.class,
|
||||
GroupManagerResolver.class,
|
||||
NijiPermissionsResolver.class,
|
||||
VaultResolver.class,
|
||||
DinnerPermsResolver.class,
|
||||
FlatFilePermissionsResolver.class
|
||||
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[]{
|
||||
PluginPermissionsResolver.class,
|
||||
PermissionsExResolver.class,
|
||||
bPermissionsResolver.class,
|
||||
GroupManagerResolver.class,
|
||||
NijiPermissionsResolver.class,
|
||||
VaultResolver.class,
|
||||
DinnerPermsResolver.class,
|
||||
FlatFilePermissionsResolver.class
|
||||
};
|
||||
|
||||
protected PermissionsResolverManager(Plugin plugin) {
|
||||
@ -221,7 +221,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
} else {
|
||||
List<String> disabledResolvers = config.getStringList("resolvers.disabled", new ArrayList<>());
|
||||
List<String> stagedEnabled = config.getStringList("resolvers.enabled", null);
|
||||
for (Iterator<String> i = stagedEnabled.iterator(); i.hasNext();) {
|
||||
for (Iterator<String> i = stagedEnabled.iterator(); i.hasNext(); ) {
|
||||
String nextName = i.next();
|
||||
Class<?> next = null;
|
||||
try {
|
||||
@ -242,11 +242,11 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
|
||||
for (Class<?> clazz : availableResolvers) {
|
||||
if (!stagedEnabled.contains(clazz.getSimpleName())
|
||||
&& !disabledResolvers.contains(clazz.getSimpleName())) {
|
||||
&& !disabledResolvers.contains(clazz.getSimpleName())) {
|
||||
disabledResolvers.add(clazz.getSimpleName());
|
||||
LOGGER.info("New permissions resolver: "
|
||||
+ clazz.getSimpleName() + " detected. "
|
||||
+ "Added to disabled resolvers list.");
|
||||
+ clazz.getSimpleName() + " detected. "
|
||||
+ "Added to disabled resolvers list.");
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
@ -272,9 +272,11 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public static class MissingPluginException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
class ServerListener implements org.bukkit.event.Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
@ -303,6 +305,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
void register(Plugin plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ public class PluginPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
// Looking for service
|
||||
RegisteredServiceProvider<PermissionsProvider> serviceProvider = server.getServicesManager().getRegistration(PermissionsProvider.class);
|
||||
RegisteredServiceProvider<PermissionsProvider> serviceProvider = server.getServicesManager().getRegistration(
|
||||
PermissionsProvider.class);
|
||||
|
||||
if (serviceProvider != null) {
|
||||
return new PluginPermissionsResolver(serviceProvider.getProvider(), serviceProvider.getPlugin());
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter;
|
||||
import com.fastasyncworldedit.bukkit.adapter.SimpleBukkitAdapter;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter;
|
||||
import com.fastasyncworldedit.bukkit.adapter.SimpleBukkitAdapter;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
@ -49,9 +49,9 @@ import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -89,7 +89,7 @@ public enum BukkitAdapter {
|
||||
* Checks equality between a WorldEdit BlockType and a Bukkit Material.
|
||||
*
|
||||
* @param blockType The WorldEdit BlockType
|
||||
* @param type The Bukkit Material
|
||||
* @param type The Bukkit Material
|
||||
* @return If they are equal
|
||||
*/
|
||||
public static boolean equals(BlockType blockType, Material type) {
|
||||
@ -184,11 +184,16 @@ public enum BukkitAdapter {
|
||||
return null;
|
||||
}
|
||||
switch (face) {
|
||||
case NORTH: return Direction.NORTH;
|
||||
case SOUTH: return Direction.SOUTH;
|
||||
case WEST: return Direction.WEST;
|
||||
case EAST: return Direction.EAST;
|
||||
case DOWN: return Direction.DOWN;
|
||||
case NORTH:
|
||||
return Direction.NORTH;
|
||||
case SOUTH:
|
||||
return Direction.SOUTH;
|
||||
case WEST:
|
||||
return Direction.WEST;
|
||||
case EAST:
|
||||
return Direction.EAST;
|
||||
case DOWN:
|
||||
return Direction.DOWN;
|
||||
case UP:
|
||||
default:
|
||||
return Direction.UP;
|
||||
@ -220,7 +225,8 @@ public enum BukkitAdapter {
|
||||
adapt(location.getWorld()),
|
||||
position,
|
||||
location.getYaw(),
|
||||
location.getPitch());
|
||||
location.getPitch()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,13 +242,14 @@ public enum BukkitAdapter {
|
||||
adapt((World) location.getExtent()),
|
||||
position.getX(), position.getY(), position.getZ(),
|
||||
location.getYaw(),
|
||||
location.getPitch());
|
||||
location.getPitch()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit location from a WorldEdit position with a Bukkit world.
|
||||
*
|
||||
* @param world the Bukkit world
|
||||
* @param world the Bukkit world
|
||||
* @param position the WorldEdit position
|
||||
* @return a Bukkit location
|
||||
*/
|
||||
@ -251,13 +258,14 @@ public enum BukkitAdapter {
|
||||
checkNotNull(position);
|
||||
return new org.bukkit.Location(
|
||||
world,
|
||||
position.getX(), position.getY(), position.getZ());
|
||||
position.getX(), position.getY(), position.getZ()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit location from a WorldEdit position with a Bukkit world.
|
||||
*
|
||||
* @param world the Bukkit world
|
||||
* @param world the Bukkit world
|
||||
* @param position the WorldEdit position
|
||||
* @return a Bukkit location
|
||||
*/
|
||||
@ -266,13 +274,14 @@ public enum BukkitAdapter {
|
||||
checkNotNull(position);
|
||||
return new org.bukkit.Location(
|
||||
world,
|
||||
position.getX(), position.getY(), position.getZ());
|
||||
position.getX(), position.getY(), position.getZ()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit location from a WorldEdit location with a Bukkit world.
|
||||
*
|
||||
* @param world the Bukkit world
|
||||
* @param world the Bukkit world
|
||||
* @param location the WorldEdit location
|
||||
* @return a Bukkit location
|
||||
*/
|
||||
@ -283,7 +292,8 @@ public enum BukkitAdapter {
|
||||
world,
|
||||
location.getX(), location.getY(), location.getZ(),
|
||||
location.getYaw(),
|
||||
location.getPitch());
|
||||
location.getPitch()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -392,8 +402,8 @@ public enum BukkitAdapter {
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
private static EnumMap<Material, BlockType> materialBlockTypeCache = new EnumMap<>(Material.class);
|
||||
private static EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class);
|
||||
private static final EnumMap<Material, BlockType> materialBlockTypeCache = new EnumMap<>(Material.class);
|
||||
private static final EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class);
|
||||
|
||||
/**
|
||||
* Converts a Material to a BlockType.
|
||||
@ -421,8 +431,8 @@ public enum BukkitAdapter {
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
private static Int2ObjectMap<BlockState> blockStateCache = new Int2ObjectOpenHashMap<>();
|
||||
private static Map<String, BlockState> blockStateStringCache = new HashMap<>();
|
||||
private static final Int2ObjectMap<BlockState> blockStateCache = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, BlockState> blockStateStringCache = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BlockState from a Bukkit BlockData.
|
||||
@ -436,7 +446,7 @@ public enum BukkitAdapter {
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
private static Int2ObjectMap<BlockData> blockDataCache = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<BlockData> blockDataCache = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
/**
|
||||
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder.
|
||||
|
@ -40,7 +40,7 @@ class BukkitBiomeRegistry implements BiomeRegistry {
|
||||
@Override
|
||||
public Component getRichName(BiomeType biomeType) {
|
||||
return TranslatableComponent.of(
|
||||
TranslationManager.makeTranslationKey("biome", biomeType.getId())
|
||||
TranslationManager.makeTranslationKey("biome", biomeType.getId())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,9 @@ public class BukkitBlockCategoryRegistry implements BlockCategoryRegistry {
|
||||
public Set<BlockType> getCategorisedByName(String category) {
|
||||
String[] split = category.split(":");
|
||||
String namespace = split.length > 1 ? split[0] : "minecraft";
|
||||
String key = split.length > 1 ? split[1] : category;
|
||||
String key = split.length > 1 ? split[1] : category;
|
||||
Tag<Material> tag = Bukkit.getTag(Tag.REGISTRY_BLOCKS, new NamespacedKey(namespace, key), Material.class);
|
||||
return getFromBukkitTag(tag);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,10 +33,8 @@ import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
@ -192,11 +190,13 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
|
||||
updateActive();
|
||||
} else {
|
||||
// we should update it eventually
|
||||
Bukkit.getScheduler().callSyncMethod(plugin,
|
||||
Bukkit.getScheduler().callSyncMethod(
|
||||
plugin,
|
||||
() -> {
|
||||
updateActive();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
return active;
|
||||
}
|
||||
@ -212,4 +212,5 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,8 +20,8 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
@ -30,11 +30,11 @@ import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
|
||||
@ -144,6 +144,7 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
public boolean isTranslucent() {
|
||||
return material.isTransparent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
@ -77,11 +77,12 @@ class BukkitCommandInspector implements CommandInspector {
|
||||
if (mapping.isPresent()) {
|
||||
InjectedValueStore store = MapBackedValueStore.create();
|
||||
store.injectValue(Key.of(Actor.class), context ->
|
||||
Optional.of(plugin.wrapCommandSender(sender)));
|
||||
Optional.of(plugin.wrapCommandSender(sender)));
|
||||
return mapping.get().getCondition().satisfied(store);
|
||||
} else {
|
||||
LOGGER.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -114,7 +114,8 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Override public void setPermission(String permission, boolean value) {
|
||||
@Override
|
||||
public void setPermission(String permission, boolean value) {
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@ -162,4 +163,5 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ public class BukkitConfiguration extends YAMLConfiguration {
|
||||
|
||||
public boolean noOpPermissions = false;
|
||||
public boolean commandBlockSupport = false;
|
||||
@Unreported private final WorldEditPlugin plugin;
|
||||
@Unreported
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
|
||||
super(config, LogManager.getLogger(plugin.getLogger().getName()));
|
||||
@ -72,4 +73,5 @@ public class BukkitConfiguration extends YAMLConfiguration {
|
||||
public Path getWorkingDirectoryPath() {
|
||||
return plugin.getDataFolder().toPath();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,12 +27,10 @@ import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.NullWorld;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Locale;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -136,4 +134,5 @@ public class BukkitEntity implements Entity {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -170,4 +170,5 @@ class BukkitEntityProperties implements EntityProperties {
|
||||
public boolean isWaterCreature() {
|
||||
return entity instanceof WaterMob;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,8 +39,9 @@ public class BukkitItemCategoryRegistry implements ItemCategoryRegistry {
|
||||
public Set<ItemType> getCategorisedByName(String category) {
|
||||
String[] split = category.split(":");
|
||||
String namespace = split.length > 1 ? split[0] : "minecraft";
|
||||
String key = split.length > 1 ? split[1] : category;
|
||||
String key = split.length > 1 ? split[1] : category;
|
||||
Tag<Material> tag = Bukkit.getTag(Tag.REGISTRY_ITEMS, new NamespacedKey(namespace, key), Material.class);
|
||||
return getFromBukkitTag(tag);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
class BukkitItemRegistry extends BundledItemRegistry {
|
||||
|
||||
@Override
|
||||
public Component getRichName(ItemType itemType) {
|
||||
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.util.task.RunnableVal;
|
||||
import com.fastasyncworldedit.core.util.TaskManager;
|
||||
import com.fastasyncworldedit.core.util.task.RunnableVal;
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.wepif.VaultResolver;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -63,14 +63,14 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
@ -236,7 +236,14 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
}
|
||||
org.bukkit.World finalWorld = world;
|
||||
//FAWE end
|
||||
return TaskManager.IMP.sync(() -> player.teleport(new Location(finalWorld, pos.getX(), pos.getY(), pos.getZ(), yaw, pitch)));
|
||||
return TaskManager.IMP.sync(() -> player.teleport(new Location(
|
||||
finalWorld,
|
||||
pos.getX(),
|
||||
pos.getY(),
|
||||
pos.getZ(),
|
||||
yaw,
|
||||
pitch
|
||||
)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -263,7 +270,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);
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@ -333,7 +340,8 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
getWorld(),
|
||||
position,
|
||||
nativeLocation.getYaw(),
|
||||
nativeLocation.getPitch());
|
||||
nativeLocation.getPitch()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -350,9 +358,11 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
public void sendAnnouncements() {
|
||||
if (WorldEditPlugin.getInstance().getLifecycledBukkitImplAdapter() == null) {
|
||||
//FAWE start - swap out EH download url with ours
|
||||
print(Caption.of("worldedit.version.bukkit.unsupported-adapter",
|
||||
print(Caption.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"))
|
||||
));
|
||||
//FAWE end
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
||||
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
|
||||
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
|
||||
import com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -35,7 +35,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag {
|
||||
//FAWE end
|
||||
|
||||
private Player player;
|
||||
private final Player player;
|
||||
private ItemStack[] items;
|
||||
|
||||
/**
|
||||
@ -194,7 +194,11 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
|
||||
@Override
|
||||
public void setItem(int slot, BaseItem block) {
|
||||
loadInventory();
|
||||
BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(block.getType(), block.getNbtData(), 1);
|
||||
BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(
|
||||
block.getType(),
|
||||
block.getNbtData(),
|
||||
1
|
||||
);
|
||||
items[slot] = BukkitAdapter.adapt(stack);
|
||||
}
|
||||
//FAWE end
|
||||
|
@ -23,7 +23,6 @@ import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import com.sk89q.worldedit.world.registry.BlockCategoryRegistry;
|
||||
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
||||
import com.sk89q.worldedit.world.registry.BundledRegistries;
|
||||
import com.sk89q.worldedit.world.registry.EntityRegistry;
|
||||
import com.sk89q.worldedit.world.registry.ItemCategoryRegistry;
|
||||
import com.sk89q.worldedit.world.registry.ItemRegistry;
|
||||
|
||||
|
@ -45,8 +45,9 @@ import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
@ -55,7 +56,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
|
||||
|
||||
@ -116,8 +116,7 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
|
||||
if (!type.startsWith("minecraft:")) {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
final EntityType entityType = EntityType.fromName(type.substring(10));
|
||||
@SuppressWarnings("deprecation") final EntityType entityType = EntityType.fromName(type.substring(10));
|
||||
return entityType != null && entityType.isAlive();
|
||||
}
|
||||
|
||||
@ -175,22 +174,29 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
|
||||
BukkitCommandInspector inspector = new BukkitCommandInspector(plugin, dispatcher);
|
||||
|
||||
dynamicCommands.register(dispatcher.getAllCommands()
|
||||
.map(command -> {
|
||||
String[] permissionsArray = command.getCondition()
|
||||
.as(PermissionCondition.class)
|
||||
.map(PermissionCondition::getPermissions)
|
||||
.map(s -> s.toArray(new String[0]))
|
||||
.orElseGet(() -> new String[0]);
|
||||
.map(command -> {
|
||||
String[] permissionsArray = command.getCondition()
|
||||
.as(PermissionCondition.class)
|
||||
.map(PermissionCondition::getPermissions)
|
||||
.map(s -> s.toArray(new String[0]))
|
||||
.orElseGet(() -> new String[0]);
|
||||
|
||||
String[] aliases = Stream.concat(
|
||||
Stream.of(command.getName()),
|
||||
command.getAliases().stream()
|
||||
).toArray(String[]::new);
|
||||
// TODO Handle localisation correctly
|
||||
return new CommandInfo(reduceToText(command.getUsage(), WorldEdit.getInstance().getConfiguration().defaultLocale),
|
||||
reduceToText(command.getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale), aliases,
|
||||
inspector, permissionsArray);
|
||||
}).collect(Collectors.toList()));
|
||||
String[] aliases = Stream.concat(
|
||||
Stream.of(command.getName()),
|
||||
command.getAliases().stream()
|
||||
).toArray(String[]::new);
|
||||
// TODO Handle localisation correctly
|
||||
return new CommandInfo(
|
||||
reduceToText(
|
||||
command.getUsage(),
|
||||
WorldEdit.getInstance().getConfiguration().defaultLocale
|
||||
),
|
||||
reduceToText(command.getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale),
|
||||
aliases,
|
||||
inspector,
|
||||
permissionsArray
|
||||
);
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -264,7 +270,8 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
|
||||
|
||||
//FAWE start
|
||||
@Override
|
||||
public @Nonnull RelighterFactory getRelighterFactory() {
|
||||
public @Nonnull
|
||||
RelighterFactory getRelighterFactory() {
|
||||
if (this.relighterFactory == null) {
|
||||
this.relighterFactory = this.plugin.getBukkitImplAdapter().getRelighterFactory();
|
||||
LOGGER.info("Using " + this.relighterFactory.getClass().getCanonicalName() + " as relighter factory.");
|
||||
|
@ -177,6 +177,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Get the world handle.
|
||||
*
|
||||
@ -332,7 +333,8 @@ public class BukkitWorld extends AbstractWorld {
|
||||
pt = pt.add(0, 1, 0); // bukkit skips the feature gen which does this offset normally, so we have to add it back
|
||||
}
|
||||
return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType,
|
||||
new EditSessionBlockChangeDelegate(editSession));
|
||||
new EditSessionBlockChangeDelegate(editSession)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -505,7 +507,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
} catch (Exception e) {
|
||||
if (block instanceof BaseBlock && ((BaseBlock) block).getNbt() != null) {
|
||||
LOGGER.warn("Tried to set a corrupt tile entity at " + position.toString()
|
||||
+ ": " + ((BaseBlock) block).getNbt(), e);
|
||||
+ ": " + ((BaseBlock) block).getNbt(), e);
|
||||
} else {
|
||||
LOGGER.warn("Failed to set block via adapter, falling back to generic", e);
|
||||
}
|
||||
@ -527,8 +529,10 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SideEffect> applySideEffects(BlockVector3 position, com.sk89q.worldedit.world.block.BlockState previousType,
|
||||
SideEffectSet sideEffectSet) {
|
||||
public Set<SideEffect> applySideEffects(
|
||||
BlockVector3 position, com.sk89q.worldedit.world.block.BlockState previousType,
|
||||
SideEffectSet sideEffectSet
|
||||
) {
|
||||
if (worldNativeAccess != null) {
|
||||
worldNativeAccess.applySideEffects(position, previousType, sideEffectSet);
|
||||
return Sets.intersection(
|
||||
|
@ -23,7 +23,6 @@ import com.sk89q.worldedit.LocalSession;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ import org.bukkit.block.data.BlockData;
|
||||
*/
|
||||
public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
|
||||
private EditSession editSession;
|
||||
private final EditSession editSession;
|
||||
|
||||
public EditSessionBlockChangeDelegate(EditSession editSession) {
|
||||
this.editSession = editSession;
|
||||
|
@ -76,13 +76,17 @@ public class WorldEditListener implements Listener {
|
||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
InjectedValueStore store = MapBackedValueStore.create();
|
||||
store.injectValue(Key.of(Actor.class), context ->
|
||||
Optional.of(plugin.wrapCommandSender(event.getPlayer())));
|
||||
CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandManager().getCommandManager();
|
||||
Optional.of(plugin.wrapCommandSender(event.getPlayer())));
|
||||
CommandManager commandManager = plugin
|
||||
.getWorldEdit()
|
||||
.getPlatformManager()
|
||||
.getPlatformCommandManager()
|
||||
.getCommandManager();
|
||||
event.getCommands().removeIf(name ->
|
||||
// remove if in the manager and not satisfied
|
||||
commandManager.getCommand(name)
|
||||
.filter(command -> !command.getCondition().satisfied(store))
|
||||
.isPresent()
|
||||
// remove if in the manager and not satisfied
|
||||
commandManager.getCommand(name)
|
||||
.filter(command -> !command.getCondition().satisfied(store))
|
||||
.isPresent()
|
||||
);
|
||||
}
|
||||
|
||||
@ -151,4 +155,5 @@ public class WorldEditListener implements Listener {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
plugin.getWorldEdit().getEventBus().post(new SessionIdleEvent(new BukkitPlayer.SessionKeyImpl(event.getPlayer())));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -117,9 +117,10 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins();
|
||||
for (Plugin p : plugins) {
|
||||
if (p.getName().equals("WorldEdit")) {
|
||||
LOGGER.warn("You installed WorldEdit alongside FastAsyncWorldEdit. That is unneeded and will cause unforeseen issues, " +
|
||||
"because FastAsyncWorldEdit already provides WorldEdit. " +
|
||||
"Stop your server and delete the 'worldedit-bukkit' jar from your plugins folder.");
|
||||
LOGGER.warn(
|
||||
"You installed WorldEdit alongside FastAsyncWorldEdit. That is unneeded and will cause unforeseen issues, " +
|
||||
"because FastAsyncWorldEdit already provides WorldEdit. " +
|
||||
"Stop your server and delete the 'worldedit-bukkit' jar from your plugins folder.");
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
@ -142,7 +143,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
//FAWE start - Modify WorldEdit config name
|
||||
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-legacy.yml"), true), this);
|
||||
//FAWE end
|
||||
|
||||
|
||||
//FAWE start - Setup permission attachments
|
||||
permissionAttachmentManager = new BukkitPermissionAttachmentManager(this);
|
||||
//FAWE end
|
||||
@ -202,7 +203,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new WorldInitListener(), this);
|
||||
} else {
|
||||
//FAWE start
|
||||
LOGGER.warn("Server reload detected. This may cause various issues with FastAsyncWorldEdit and dependent plugins. Reloading the server is not advised.");
|
||||
LOGGER.warn(
|
||||
"Server reload detected. This may cause various issues with FastAsyncWorldEdit and dependent plugins. Reloading the server is not advised.");
|
||||
LOGGER.warn("For more information why reloading is bad, see https://madelinemiller.dev/blog/problem-with-reload/");
|
||||
//FAWE end
|
||||
try {
|
||||
@ -235,7 +237,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent(platform));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "deprecation", "unchecked" })
|
||||
@SuppressWarnings({"deprecation", "unchecked"})
|
||||
private void initializeRegistries() {
|
||||
// Biome
|
||||
for (Biome biome : Biome.values()) {
|
||||
@ -298,7 +300,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
ItemCategory.REGISTRY.register(itemTag.getKey().toString(), new ItemCategory(itemTag.getKey().toString()));
|
||||
}
|
||||
} catch (NoSuchMethodError ignored) {
|
||||
LOGGER.warn("The version of Spigot/Paper you are using doesn't support Tags. The usage of tags with WorldEdit will not work until you update.");
|
||||
LOGGER.warn(
|
||||
"The version of Spigot/Paper you are using doesn't support Tags. The usage of tags with WorldEdit will not work until you update.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,8 +332,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
} else {
|
||||
//FAWE start - Identify as FAWE
|
||||
LOGGER.info("FastAsyncWorldEdit could not find a Bukkit adapter for this MC version, "
|
||||
+ "but it seems that you have another implementation of FastAsyncWorldEdit installed (" + platform.getPlatformName() + ") "
|
||||
+ "that handles the world editing.");
|
||||
+ "but it seems that you have another implementation of FastAsyncWorldEdit installed (" + platform.getPlatformName() + ") "
|
||||
+ "that handles the world editing.");
|
||||
//FAWE end
|
||||
}
|
||||
this.adapter.invalidate();
|
||||
@ -443,7 +446,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
/**
|
||||
* Remember an edit session.
|
||||
*
|
||||
* @param player a player
|
||||
* @param player a player
|
||||
* @param editSession an edit session
|
||||
*/
|
||||
public void remember(Player player, EditSession editSession) {
|
||||
@ -473,8 +476,9 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
public PermissionsResolverManager getPermissionsResolver() {
|
||||
return PermissionsResolverManager.getInstance();
|
||||
}
|
||||
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Get the permissions attachment manager in use
|
||||
*
|
||||
@ -565,6 +569,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
private class WorldInitListener implements Listener {
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -575,9 +580,11 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
loaded = true;
|
||||
setupWorldData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class AsyncTabCompleteListener implements Listener {
|
||||
|
||||
AsyncTabCompleteListener() {
|
||||
}
|
||||
|
||||
@ -597,7 +604,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
// Strip leading slash, if present.
|
||||
label = label.startsWith("/") ? label.substring(1) : label;
|
||||
final Optional<org.enginehub.piston.Command> command
|
||||
= WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(label);
|
||||
= WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(
|
||||
label);
|
||||
if (!command.isPresent()) {
|
||||
return;
|
||||
}
|
||||
@ -608,5 +616,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
event.setCompletions(CommandUtil.fixSuggestions(buffer, suggestEvent.getSuggestions()));
|
||||
event.setHandled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,4 +38,5 @@ public class AdapterLoadException extends Exception {
|
||||
public AdapterLoadException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ import com.fastasyncworldedit.bukkit.FaweBukkit;
|
||||
import com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter;
|
||||
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
|
||||
import com.sk89q.jnbt.AdventureNBTConverter;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
@ -59,10 +59,10 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An interface for adapters of various Bukkit implementations.
|
||||
@ -123,7 +123,7 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
* Create the given entity.
|
||||
*
|
||||
* @param location the location
|
||||
* @param state the state
|
||||
* @param state the state
|
||||
* @return the created entity or null
|
||||
*/
|
||||
@Nullable
|
||||
@ -164,8 +164,8 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
/**
|
||||
* Send the given NBT data to the player.
|
||||
*
|
||||
* @param player The player
|
||||
* @param pos The position
|
||||
* @param player The player
|
||||
* @param pos The position
|
||||
* @param nbtData The NBT Data
|
||||
*/
|
||||
void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData);
|
||||
@ -181,10 +181,10 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
/**
|
||||
* Simulates a player using an item.
|
||||
*
|
||||
* @param world the world
|
||||
* @param world the world
|
||||
* @param position the location
|
||||
* @param item the item to be used
|
||||
* @param face the direction in which to "face" when using the item
|
||||
* @param item the item to be used
|
||||
* @param face the direction in which to "face" when using the item
|
||||
* @return whether the usage was successful
|
||||
*/
|
||||
default boolean simulateItemUse(World world, BlockVector3 position, BaseItem item, Direction face) {
|
||||
@ -194,8 +194,8 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
/**
|
||||
* Gets whether the given {@link BlockState} can be placed here.
|
||||
*
|
||||
* @param world The world
|
||||
* @param position The position
|
||||
* @param world The world
|
||||
* @param position The position
|
||||
* @param blockState The blockstate
|
||||
* @return If it can be placed
|
||||
*/
|
||||
@ -243,9 +243,10 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
|
||||
/**
|
||||
* Regenerate a region in the given world, so it appears "as new".
|
||||
* @param world the world to regen in
|
||||
* @param region the region to regen
|
||||
* @param extent the extent to use for setting blocks
|
||||
*
|
||||
* @param world the world to regen in
|
||||
* @param region the region to regen
|
||||
* @param extent the extent to use for setting blocks
|
||||
* @param options the regeneration options
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
|
@ -47,15 +47,15 @@ public class BukkitImplLoader {
|
||||
private static final String CLASS_SUFFIX = ".class";
|
||||
|
||||
private static final String LOAD_ERROR_MESSAGE =
|
||||
//FAWE start - exchange WorldEdit to FAWE & suggest to update Fawe & the server software
|
||||
"\n**********************************************\n"
|
||||
+ "** This FastAsyncWorldEdit version does not fully support your version of Bukkit.\n"
|
||||
+ "** You can fix this by:\n"
|
||||
+ "** - Updating your server version (Check /version to see how many versions you are behind)\n** - Updating FAWE\n"
|
||||
+ "**\n" + "** When working with blocks or undoing, chests will be empty, signs\n"
|
||||
+ "** will be blank, and so on. There will be no support for entity\n"
|
||||
+ "** and block property-related functions.\n"
|
||||
+ "**********************************************\n";
|
||||
//FAWE start - exchange WorldEdit to FAWE & suggest to update Fawe & the server software
|
||||
"\n**********************************************\n"
|
||||
+ "** This FastAsyncWorldEdit version does not fully support your version of Bukkit.\n"
|
||||
+ "** You can fix this by:\n"
|
||||
+ "** - Updating your server version (Check /version to see how many versions you are behind)\n** - Updating FAWE\n"
|
||||
+ "**\n" + "** When working with blocks or undoing, chests will be empty, signs\n"
|
||||
+ "** will be blank, and so on. There will be no support for entity\n"
|
||||
+ "** and block property-related functions.\n"
|
||||
+ "**********************************************\n";
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
@ -164,10 +164,10 @@ public class BukkitImplLoader {
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
LOGGER.warn("Failed to load the Bukkit adapter class '" + className
|
||||
+ "' that is not supposed to be missing", e);
|
||||
+ "' that is not supposed to be missing", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
LOGGER.warn("Failed to load the Bukkit adapter class '" + className
|
||||
+ "' that is not supposed to be raising this error", e);
|
||||
+ "' that is not supposed to be raising this error", e);
|
||||
} catch (Throwable e) {
|
||||
if (className.equals(customCandidate)) {
|
||||
LOGGER.warn("Failed to load the Bukkit adapter class '" + className + "'", e);
|
||||
|
Reference in New Issue
Block a user