3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 10:30:04 +01:00

Address some requested changes

Dieser Commit ist enthalten in:
BuildTools 2021-04-11 14:33:18 +02:00
Ursprung a74e5fe122
Commit 3878269a41
8 geänderte Dateien mit 52 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -8,10 +8,11 @@ import com.boydti.fawe.beta.implementation.lighting.RelighterFactory;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.RelightMode;
import com.sk89q.worldedit.world.World;
import org.jetbrains.annotations.NotNull;
public class NMSRelighterFactory implements RelighterFactory {
@Override
public Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent<IQueueChunk> queue) {
public @NotNull Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent<IQueueChunk> queue) {
return new NMSRelighter(queue, Settings.IMP.LIGHTING.DO_HEIGHTMAPS,
relightMode != null ? relightMode : RelightMode.valueOf(Settings.IMP.LIGHTING.MODE));
}

Datei anzeigen

@ -9,10 +9,11 @@ import com.boydti.fawe.object.RelightMode;
import com.sk89q.worldedit.world.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
import org.jetbrains.annotations.NotNull;
public class TuinityRelighterFactory_1_16_5 implements RelighterFactory {
@Override
public Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent<IQueueChunk> queue) {
public @NotNull Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent<IQueueChunk> queue) {
org.bukkit.World w = Bukkit.getWorld(world.getName());
if (w == null) return NullRelighter.INSTANCE;
return new TuinityRelighter_1_16_5(((CraftWorld) w).getHandle(), queue);

Datei anzeigen

@ -6,11 +6,13 @@ import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.chunk.ChunkHolder;
import com.boydti.fawe.beta.implementation.lighting.Relighter;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import net.minecraft.server.v1_16_R3.BlockPosition;
import net.minecraft.server.v1_16_R3.ChunkCoordIntPair;
import net.minecraft.server.v1_16_R3.LightEngineThreaded;
import net.minecraft.server.v1_16_R3.MCUtil;
import net.minecraft.server.v1_16_R3.WorldServer;
import org.apache.logging.log4j.Logger;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
@ -24,6 +26,8 @@ import java.util.function.IntConsumer;
public class TuinityRelighter_1_16_5 implements Relighter {
private static final Logger LOGGER = LogManagerCompat.getLogger();
private static final IntConsumer nothingIntConsumer = i -> {};
private static final MethodHandle relight;
@ -43,7 +47,8 @@ public class TuinityRelighter_1_16_5 implements Relighter {
);
tmp = MethodHandles.lookup().unreflect(relightMethod);
} catch (NoSuchMethodException | IllegalAccessException e) {
e.printStackTrace();
LOGGER.error("Failed to locate relight method in LightEngineThreaded on Tuinity. " +
"Is everything up to date?", e);
}
relight = tmp;
}
@ -66,7 +71,7 @@ public class TuinityRelighter_1_16_5 implements Relighter {
nothingIntConsumer
);
} catch (Throwable throwable) {
throwable.printStackTrace();
LOGGER.error("Error occurred on relighting", throwable);
}
}
);

Datei anzeigen

@ -35,15 +35,18 @@ import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.MultiUserPlatform;
import com.sk89q.worldedit.extension.platform.Preference;
import com.sk89q.worldedit.extension.platform.Watchdog;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.registry.Registries;
import org.apache.logging.log4j.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.enginehub.piston.CommandManager;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
@ -59,6 +62,8 @@ import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
public class BukkitServerInterface extends AbstractPlatform implements MultiUserPlatform {
private static final Logger LOGGER = LogManagerCompat.getLogger();
public final Server server;
public final WorldEditPlugin plugin;
private final CommandRegistration dynamicCommands;
@ -82,8 +87,10 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
try {
Class.forName("com.tuinity.tuinity.config.TuinityConfig");
tempFactory = new TuinityRelighterFactory_1_16_5();
LOGGER.info("Using Tuinity internals for relighting");
} catch (ClassNotFoundException e) {
tempFactory = new NMSRelighterFactory();
LOGGER.info("Using FAWE for relighting");
}
this.religherFactory = tempFactory;
}
@ -257,7 +264,7 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
}
@Override
public RelighterFactory getRelighterFactory() {
public @NotNull RelighterFactory getRelighterFactory() {
return this.religherFactory;
}

Datei anzeigen

@ -32,6 +32,7 @@ import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.registry.Registries;
import org.enginehub.piston.CommandManager;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.EnumMap;
@ -163,7 +164,7 @@ class CLIPlatform extends AbstractPlatform {
}
@Override
public RelighterFactory getRelighterFactory() {
public @NotNull RelighterFactory getRelighterFactory() {
return (_a, _b, _c) -> NullRelighter.INSTANCE;
}

Datei anzeigen

@ -29,11 +29,13 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.World;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
import java.io.File;
@ -56,6 +58,8 @@ import java.util.UUID;
*/
public class FaweAPI {
private static final Logger LOGGER = LogManagerCompat.getLogger();
/**
* Offers a lot of options for building an EditSession.
*
@ -364,8 +368,8 @@ public class FaweAPI {
} else {
relighter.removeLighting();
}
} catch (Exception ignored) {
} catch (Exception e) {
LOGGER.error("Error occurred on fix lighting", e);
}
return count;
}

Datei anzeigen

@ -4,9 +4,26 @@ import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.RelightMode;
import com.sk89q.worldedit.world.World;
import org.jetbrains.annotations.NotNull;
/**
* This abstracts the creation of {@link Relighter}s to allow more modular code.
*/
@FunctionalInterface
public interface RelighterFactory {
/**
* Create a new {@link Relighter} that can be used by a {@link RelightProcessor}.
* <p>
* Implementations are meant to configure an appropriate Relighter using the specified
* parameters. There are no guarantees about the returned objects other than being non-null.
* If no valid Relighter can be created, {@link NullRelighter#INSTANCE} should be returned.
*
* @param relightMode the relight mode to use during relighting.
* @param world the world in which relighting should be done.
* @param queue the queue extent to work with.
* @return a new Relighter instance with the specified settings.
*/
@NotNull
Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent<IQueueChunk> queue);
}

Datei anzeigen

@ -30,6 +30,7 @@ import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.registry.Registries;
import org.enginehub.piston.CommandManager;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Locale;
@ -208,5 +209,12 @@ public interface Platform extends Keyed {
*/
Set<SideEffect> getSupportedSideEffects();
/**
* Get the {@link RelighterFactory} that can be used to obtain
* {@link com.boydti.fawe.beta.implementation.lighting.Relighter}s. *
*
* @return the relighter factory to be used.
*/
@NotNull
RelighterFactory getRelighterFactory();
}