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:
dordsor21
2021-07-24 16:34:05 +01:00
committed by GitHub
parent 3b4beba7d6
commit 8c0195970b
1143 changed files with 143599 additions and 9952 deletions

View File

@ -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.

View File

@ -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())
);
}

View File

@ -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);
}
}

View File

@ -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
}
};
}
}

View File

@ -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

View File

@ -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;
}
}
}

View File

@ -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 {
}
};
}
}

View File

@ -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();
}
}

View File

@ -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;
}
}
}

View File

@ -170,4 +170,5 @@ class BukkitEntityProperties implements EntityProperties {
public boolean isWaterCreature() {
return entity instanceof WaterMob;
}
}

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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
}
}

View File

@ -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

View File

@ -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;

View File

@ -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.");

View File

@ -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(

View File

@ -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;
/**

View File

@ -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;

View File

@ -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())));
}
}

View File

@ -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);
}
}
}

View File

@ -38,4 +38,5 @@ public class AdapterLoadException extends Exception {
public AdapterLoadException(Throwable cause) {
super(cause);
}
}

View File

@ -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
*/

View File

@ -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);