begin integration with fawe

This commit is contained in:
dordsor21 2021-06-08 18:36:45 +01:00
parent 19e97a7738
commit 50d4353045
9 changed files with 281 additions and 4 deletions

View File

@ -186,6 +186,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
private Method methodUnloadChunk0; private Method methodUnloadChunk0;
private boolean methodUnloadSetup = false; private boolean methodUnloadSetup = false;
private boolean metricsStarted; private boolean metricsStarted;
private boolean faweHook = false;
private EconHandler econ; private EconHandler econ;
private Injector injector; private Injector injector;
@ -317,14 +318,28 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
// WorldEdit // WorldEdit
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) { if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
try { try {
LOGGER.info("{} hooked into WorldEdit", this.pluginName());
WorldEdit.getInstance().getEventBus().register(this.injector().getInstance(WESubscriber.class)); WorldEdit.getInstance().getEventBus().register(this.injector().getInstance(WESubscriber.class));
LOGGER.info("{} hooked into WorldEdit", this.pluginName());
} catch (Throwable e) { } catch (Throwable e) {
LOGGER.error( LOGGER.error(
"Incompatible version of WorldEdit, please upgrade: https://builds.enginehub.org/job/worldedit?branch=master"); "Incompatible version of WorldEdit, please upgrade: https://builds.enginehub.org/job/worldedit?branch=master");
} }
} }
// FAWE
if (Settings.FAWE_Components.FAWE_HOOK) {
Plugin fawe = getServer().getPluginManager().getPlugin("FastAsyncWorldEdit");
if (fawe != null) {
try {
Class.forName("com.boydti.fawe.bukkit.regions.plotsquared.FaweQueueCoordinator");
faweHook = true;
} catch (Exception ignored) {
LOGGER.error("Incompatible version of FAWE to enable hook, please upgrade: https://ci.athion" +
".net/job/FastAsyncWorldEdit-P2-V6/");
}
}
}
if (Settings.Enabled_Components.EVENTS) { if (Settings.Enabled_Components.EVENTS) {
getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener.class), this); getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener.class), this);
getServer().getPluginManager().registerEvents(injector().getInstance(BlockEventListener.class), this); getServer().getPluginManager().registerEvents(injector().getInstance(BlockEventListener.class), this);
@ -1209,4 +1224,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
return LegacyComponentSerializer.legacyAmpersand().serialize(component); return LegacyComponentSerializer.legacyAmpersand().serialize(component);
} }
@Override
public boolean isFaweHooking() {
return faweHook;
}
} }

View File

@ -41,7 +41,10 @@ import com.plotsquared.bukkit.util.BukkitInventoryUtil;
import com.plotsquared.bukkit.util.BukkitRegionManager; import com.plotsquared.bukkit.util.BukkitRegionManager;
import com.plotsquared.bukkit.util.BukkitSetupUtils; import com.plotsquared.bukkit.util.BukkitSetupUtils;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.fawe.FaweRegionManager;
import com.plotsquared.bukkit.util.fawe.FaweSchematicHandler;
import com.plotsquared.core.PlotPlatform; import com.plotsquared.core.PlotPlatform;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.generator.HybridGen; import com.plotsquared.core.generator.HybridGen;
import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.generator.IndependentPlotGenerator;
@ -99,10 +102,15 @@ public class BukkitModule extends AbstractModule {
install(new FactoryModuleBuilder() install(new FactoryModuleBuilder()
.implement(ProgressSubscriber.class, DefaultProgressSubscriber.class) .implement(ProgressSubscriber.class, DefaultProgressSubscriber.class)
.build(ProgressSubscriberFactory.class)); .build(ProgressSubscriberFactory.class));
bind(GlobalBlockQueue.class).toInstance(new GlobalBlockQueue(QueueProvider.of(BukkitQueueCoordinator.class)));
bind(ChunkManager.class).to(BukkitChunkManager.class); bind(ChunkManager.class).to(BukkitChunkManager.class);
bind(RegionManager.class).to(BukkitRegionManager.class); if (PlotSquared.platform().isFaweHooking()) {
bind(SchematicHandler.class).to(FaweSchematicHandler.class);
bind(RegionManager.class).to(FaweRegionManager.class);
} else {
bind(SchematicHandler.class).to(BukkitSchematicHandler.class); bind(SchematicHandler.class).to(BukkitSchematicHandler.class);
bind(RegionManager.class).to(BukkitRegionManager.class);
}
bind(GlobalBlockQueue.class).toInstance(new GlobalBlockQueue(QueueProvider.of(BukkitQueueCoordinator.class)));
if (Settings.Enabled_Components.WORLDS) { if (Settings.Enabled_Components.WORLDS) {
bind(PlotAreaManager.class).to(SinglePlotAreaManager.class); bind(PlotAreaManager.class).to(SinglePlotAreaManager.class);
try { try {

View File

@ -0,0 +1,130 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) ${year} IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util.fawe;
import com.boydti.fawe.bukkit.regions.plotsquared.FaweDelegateRegionManager;
import com.google.inject.Inject;
import com.plotsquared.bukkit.util.BukkitRegionManager;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.generator.HybridPlotManager;
import com.plotsquared.core.inject.factory.ProgressSubscriberFactory;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.QueueCoordinator;
import com.plotsquared.core.util.WorldUtil;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
public class FaweRegionManager extends BukkitRegionManager {
private final FaweDelegateRegionManager delegate = new FaweDelegateRegionManager();
@Inject
public FaweRegionManager(
@NonNull WorldUtil worldUtil, @NonNull GlobalBlockQueue blockQueue, @NonNull
ProgressSubscriberFactory subscriberFactory
) {
super(worldUtil, blockQueue, subscriberFactory);
}
@Override
public boolean setCuboids(
final @NonNull PlotArea area,
final @NonNull Set<CuboidRegion> regions,
final @NonNull Pattern blocks,
int minY,
int maxY,
@org.checkerframework.checker.nullness.qual.Nullable PlotPlayer<?> actor,
@org.checkerframework.checker.nullness.qual.Nullable QueueCoordinator queue
) {
return delegate.setCuboids(area, regions, blocks, minY, maxY);
}
@Override
public boolean notifyClear(PlotManager manager) {
if (!Settings.FAWE_Components.CLEAR || !(manager instanceof HybridPlotManager)) {
return false;
}
return delegate.notifyClear(manager);
}
@Override
public boolean handleClear(
@NotNull Plot plot,
@Nullable Runnable whenDone,
@NotNull PlotManager manager,
final @Nullable PlotPlayer<?> player
) {
if (!Settings.FAWE_Components.CLEAR || !(manager instanceof HybridPlotManager)) {
return false;
}
return delegate.handleClear(plot, whenDone, manager);
}
@Override
public void swap(
Location pos1,
Location pos2,
Location swapPos,
final @Nullable PlotPlayer<?> player,
final Runnable whenDone
) {
delegate.swap(pos1, pos2, swapPos, whenDone);
}
@Override
public void setBiome(CuboidRegion region, int extendBiome, BiomeType biome, String world, Runnable whenDone) {
delegate.setBiome(region, extendBiome, biome, world, whenDone);
}
@Override
public boolean copyRegion(
final @NonNull Location pos1,
final @NonNull Location pos2,
final @NonNull Location pos3,
final @Nullable PlotPlayer<?> player,
final @NonNull Runnable whenDone
) {
return delegate.copyRegion(pos1, pos2, pos3, whenDone);
}
@Override
public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) {
return delegate.regenerateRegion(pos1, pos2, ignore, whenDone);
}
}

View File

@ -0,0 +1,90 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) ${year} IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util.fawe;
import com.boydti.fawe.bukkit.regions.plotsquared.FaweDelegateSchematicHandler;
import com.google.inject.Inject;
import com.plotsquared.core.inject.factory.ProgressSubscriberFactory;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.schematic.Schematic;
import com.plotsquared.core.queue.QueueCoordinator;
import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.sk89q.jnbt.CompoundTag;
import org.jetbrains.annotations.NotNull;
import java.io.InputStream;
import java.net.URL;
import java.util.UUID;
public class FaweSchematicHandler extends SchematicHandler {
private final FaweDelegateSchematicHandler delegate = new FaweDelegateSchematicHandler();
@Inject
public FaweSchematicHandler(@NotNull WorldUtil worldUtil, @NotNull ProgressSubscriberFactory subscriberFactory) {
super(worldUtil, subscriberFactory);
}
@Override
public boolean restoreTile(QueueCoordinator queue, CompoundTag tag, int x, int y, int z) {
return false;
}
@Override
public void paste(
final Schematic schematic,
final Plot plot,
final int xOffset,
final int yOffset,
final int zOffset,
final boolean autoHeight,
final PlotPlayer<?> actor,
final RunnableVal<Boolean> whenDone
) {
delegate.paste(schematic, plot, xOffset, yOffset, zOffset, autoHeight, whenDone);
}
@Override
public boolean save(CompoundTag tag, String path) {
return delegate.save(tag, path);
}
@Override
public void upload(final CompoundTag tag, final UUID uuid, final String file, final RunnableVal<URL> whenDone) {
delegate.upload(tag, uuid, file, whenDone);
}
@Override
public Schematic getSchematic(@NotNull InputStream is) {
return delegate.getSchematic(is);
}
}

View File

@ -37,6 +37,8 @@ dependencies {
exclude(group = "dummypermscompat") exclude(group = "dummypermscompat")
} }
testImplementation(libs.worldeditCore) testImplementation(libs.worldeditCore)
compileOnlyApi(libs.fastasyncworldeditBukkit)
testImplementation(libs.fastasyncworldeditBukkit)
// Logging // Logging
compileOnlyApi(libs.log4j) { compileOnlyApi(libs.log4j) {

View File

@ -323,4 +323,13 @@ public interface PlotPlatform<P> extends LocaleHolder {
*/ */
@NonNull String toLegacyPlatformString(@NonNull Component component); @NonNull String toLegacyPlatformString(@NonNull Component component);
/**
* Returns if the FAWE-P2 hook is active/enabled
*
* @return status of FAWE-P2 hook
*/
default boolean isFaweHooking() {
return false;
}
} }

View File

@ -608,6 +608,17 @@ public class Settings extends Config {
} }
@Comment("Enable or disable all of or parts of the FAWE-P2 hook")
public static final class FAWE_Components {
@Comment("Use FAWE for queue handling.")
public static boolean FAWE_HOOK = true;
public static boolean CUBOIDS = true;
public static boolean CLEAR = true;
public static boolean COPY_AND_SWAP = true;
public static boolean SET_BIOME = true;
}
@Comment("Enable or disable parts of the plugin specific to using Paper") @Comment("Enable or disable parts of the plugin specific to using Paper")
public static final class Paper_Components { public static final class Paper_Components {

View File

@ -39,6 +39,11 @@ allprojects {
url = uri("https://jitpack.io") url = uri("https://jitpack.io")
} }
maven {
name = "IntellectualSites Releases Repository"
url = uri("https://mvn.intellectualsites.com/content/repositories/releases")
}
maven { maven {
name = "IntellectualSites Snapshots Repository" name = "IntellectualSites Snapshots Repository"
url = uri("https://mvn.intellectualsites.com/content/repositories/snapshots") url = uri("https://mvn.intellectualsites.com/content/repositories/snapshots")

View File

@ -14,6 +14,7 @@ guice = "5.0.1"
findbugs = "3.0.1" findbugs = "3.0.1"
worldedit = "7.2.5" worldedit = "7.2.5"
fawe = "p2v6-8"
vault = "1.7" vault = "1.7"
placeholderapi = "2.10.9" placeholderapi = "2.10.9"
luckperms = "5.3" luckperms = "5.3"
@ -63,6 +64,7 @@ findbugs = { group = "com.google.code.findbugs", name = "annotations", version.r
# Plugins # Plugins
worldeditCore = { group = "com.sk89q.worldedit", name = "worldedit-core", version.ref = "worldedit" } worldeditCore = { group = "com.sk89q.worldedit", name = "worldedit-core", version.ref = "worldedit" }
worldeditBukkit = { group = "com.sk89q.worldedit", name = "worldedit-bukkit", version.ref = "worldedit" } worldeditBukkit = { group = "com.sk89q.worldedit", name = "worldedit-bukkit", version.ref = "worldedit" }
fastasyncworldeditBukkit = { group = "com.intellectualsites.fawe", name = "FAWE-Bukkit", version.ref = "fawe" }
vault = { group = "com.github.MilkBowl", name = "VaultAPI", version.ref = "vault" } vault = { group = "com.github.MilkBowl", name = "VaultAPI", version.ref = "vault" }
placeholderapi = { group = "me.clip", name = "placeholderapi", version.ref = "placeholderapi" } placeholderapi = { group = "me.clip", name = "placeholderapi", version.ref = "placeholderapi" }
luckperms = { group = "net.luckperms", name = "api", version.ref = "luckperms" } luckperms = { group = "net.luckperms", name = "api", version.ref = "luckperms" }