9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-25 18:09:17 +00:00

[ci skip] cleanup

stage 1
This commit is contained in:
Dreeam
2025-05-15 00:00:06 -04:00
parent a8e39fa9bc
commit 2a72c42863
20 changed files with 97 additions and 55 deletions

View File

@@ -12,7 +12,12 @@ import net.minecraft.tags.TagKey;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.structure.Structure;
import java.util.concurrent.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;

View File

@@ -1,10 +1,8 @@
package org.dreeam.leaf.async.path;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.pathfinder.Path;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
@@ -12,7 +10,13 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
/**
@@ -97,4 +101,5 @@ public class AsyncPathProcessor {
final int queueCapacity = org.dreeam.leaf.config.modules.async.AsyncPathfinding.asyncPathfindingQueueSize;
return new LinkedBlockingQueue<>(queueCapacity);
}}
}
}

View File

@@ -2,7 +2,6 @@ package org.dreeam.leaf.async.path;
import ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue;
import net.minecraft.world.level.pathfinder.NodeEvaluator;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;

View File

@@ -1,6 +1,9 @@
package org.dreeam.leaf.async.path;
import net.minecraft.world.level.pathfinder.*;
import net.minecraft.world.level.pathfinder.AmphibiousNodeEvaluator;
import net.minecraft.world.level.pathfinder.FlyNodeEvaluator;
import net.minecraft.world.level.pathfinder.NodeEvaluator;
import net.minecraft.world.level.pathfinder.SwimNodeEvaluator;
public enum NodeEvaluatorType {
WALK,

View File

@@ -16,7 +16,13 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class MultithreadedTracker {

View File

@@ -4,10 +4,15 @@ import io.papermc.paper.configuration.GlobalConfiguration;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minecraft.Util;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dreeam.leaf.config.modules.misc.SentryDSN;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import java.io.File;
import java.io.IOException;
@@ -31,13 +36,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
/*
* Yoinked from: https://github.com/xGinko/AnarchyExploitFixes/ & https://github.com/LuminolMC/Luminol
* @author: @xGinko & @MrHua269

View File

@@ -1,6 +1,10 @@
package org.dreeam.leaf.config.annotations;
import java.lang.annotation.*;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Indicates that a feature is experimental and may be removed or changed in the future.

View File

@@ -21,15 +21,15 @@ public class AsyncPathfinding extends ConfigModules {
@Override
public void onLoaded() {
config.addCommentRegionBased(getBasePath() + ".reject-policy", """
The policy to use when the queue is full and a new task is submitted.
FLUSH_ALL: All pending tasks will be run on server thread.
CALLER_RUNS: Newly submitted task will be run on server thread.
DISCARD: Newly submitted task will be dropped directly.""",
The policy to use when the queue is full and a new task is submitted.
FLUSH_ALL: All pending tasks will be run on server thread.
CALLER_RUNS: Newly submitted task will be run on server thread.
DISCARD: Newly submitted task will be dropped directly.""",
"""
当队列满时, 新提交的任务将使用以下策略处理.
FLUSH_ALL: 所有等待中的任务都将在主线程上运行.
CALLER_RUNS: 新提交的任务将在主线程上运行.
DISCARD: 新提交的任务会被直接丢弃."""
当队列满时, 新提交的任务将使用以下策略处理.
FLUSH_ALL: 所有等待中的任务都将在主线程上运行.
CALLER_RUNS: 新提交的任务将在主线程上运行.
DISCARD: 新提交的任务会被直接丢弃."""
);
if (asyncPathfindingInitialized) {
config.getConfigSection(getBasePath());

View File

@@ -2,7 +2,6 @@ package org.dreeam.leaf.config.modules.async;
import org.dreeam.leaf.config.ConfigModules;
import org.dreeam.leaf.config.EnumConfigCategory;
import org.dreeam.leaf.config.annotations.Experimental;
public class AsyncPlayerDataSave extends ConfigModules {

View File

@@ -3,7 +3,6 @@ package org.dreeam.leaf.config.modules.async;
import org.dreeam.leaf.config.ConfigModules;
import org.dreeam.leaf.config.EnumConfigCategory;
import org.dreeam.leaf.config.annotations.Experimental;
public class AsyncTargetFinding extends ConfigModules {

View File

@@ -10,7 +10,7 @@ public class ConfigurableInventoryOverflowEvent extends ConfigModules {
}
public static boolean enabled = false;
public static String listenerClass = "com.example.package.PlayerInventoryOverflowEvent" ;
public static String listenerClass = "com.example.package.PlayerInventoryOverflowEvent";
@Override
public void onLoaded() {

View File

@@ -1,7 +1,14 @@
package org.dreeam.leaf.protocol;
import com.google.common.collect.ImmutableList;
import it.unimi.dsi.fastutil.objects.*;
import it.unimi.dsi.fastutil.objects.Reference2BooleanMap;
import it.unimi.dsi.fastutil.objects.Reference2BooleanMaps;
import it.unimi.dsi.fastutil.objects.Reference2BooleanOpenHashMap;
import it.unimi.dsi.fastutil.objects.Reference2FloatMap;
import it.unimi.dsi.fastutil.objects.Reference2FloatMaps;
import it.unimi.dsi.fastutil.objects.Reference2FloatOpenHashMap;
import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap;
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
@@ -10,9 +17,16 @@ import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.server.network.ServerPlayerConnection;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bukkit.event.player.PlayerKickEvent;
import org.dreeam.leaf.protocol.DoABarrelRollPackets.*;
import org.dreeam.leaf.protocol.DoABarrelRollPackets.ConfigResponseC2SPacket;
import org.dreeam.leaf.protocol.DoABarrelRollPackets.ConfigSyncS2CPacket;
import org.dreeam.leaf.protocol.DoABarrelRollPackets.ConfigUpdateAckS2CPacket;
import org.dreeam.leaf.protocol.DoABarrelRollPackets.ConfigUpdateC2SPacket;
import org.dreeam.leaf.protocol.DoABarrelRollPackets.KineticDamage;
import org.dreeam.leaf.protocol.DoABarrelRollPackets.ModConfigServer;
import org.dreeam.leaf.protocol.DoABarrelRollPackets.RollSyncC2SPacket;
import org.dreeam.leaf.protocol.DoABarrelRollPackets.RollSyncS2CPacket;
import org.jetbrains.annotations.NotNull;
import org.bukkit.event.player.PlayerKickEvent;
import java.util.List;
import java.util.OptionalInt;

View File

@@ -9,11 +9,18 @@ import java.util.List;
interface Protocol {
String namespace();
List<Protocols.TypeAndCodec<FriendlyByteBuf, ? extends LeafCustomPayload>> c2s();
List<Protocols.TypeAndCodec<FriendlyByteBuf, ? extends LeafCustomPayload>> s2c();
void tickServer(MinecraftServer server);
void tickPlayer(ServerPlayer player);
void tickTracker(ServerPlayer player);
void disconnected(ServerPlayer conn);
void handle(ServerPlayer player, @NotNull LeafCustomPayload payload);
}

View File

@@ -23,7 +23,9 @@ public class Protocols {
PROTOCOLS.remove(protocol);
}
public record TypeAndCodec<B extends FriendlyByteBuf, T extends LeafCustomPayload>(LeafCustomPayload.Type<T> type, StreamCodec<B, T> codec) {}
public record TypeAndCodec<B extends FriendlyByteBuf, T extends LeafCustomPayload>(LeafCustomPayload.Type<T> type,
StreamCodec<B, T> codec) {
}
public static <B extends FriendlyByteBuf> void write(B byteBuf, LeafCustomPayload payload) {
for (Protocol protocol : PROTOCOLS) {

View File

@@ -2,13 +2,12 @@ package org.dreeam.leaf.util.cache;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import it.unimi.dsi.fastutil.longs.LongList;
import net.minecraft.core.BlockPos;
import java.util.Iterator;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraft.core.BlockPos;
/**
* @author 2No2Name, original implemenation by SuperCoder7979 and Gegy1000
*/

View File

@@ -2,11 +2,10 @@ package org.dreeam.leaf.util.cache;
import it.unimi.dsi.fastutil.longs.LongIterator;
import it.unimi.dsi.fastutil.longs.LongList;
import net.minecraft.core.BlockPos;
import java.util.Iterator;
import net.minecraft.core.BlockPos;
/**
* @author 2No2Name
*/

View File

@@ -1,9 +1,9 @@
package org.dreeam.leaf.util;
import java.util.List;
import java.util.Arrays;
import net.minecraft.world.entity.Entity;
import java.lang.reflect.Array; // Required for Array.newInstance
import java.util.List;
public class fastBitRadixSort {

View File

@@ -3,12 +3,13 @@ package org.dreeam.leaf.util.list;
import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import org.jetbrains.annotations.NotNull;
/**
* A List implementation that maintains a hash-based counter for O(1) element lookup.