Port Anti-Xray to 1.18 (#6947)

This commit is contained in:
stonar96
2021-11-29 12:55:13 +01:00
parent 9403115c81
commit 0f6ca558f1
15 changed files with 1690 additions and 80 deletions

View File

@@ -12,22 +12,20 @@ diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/m
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ import java.util.stream.Collectors;
import it.unimi.dsi.fastutil.objects.Reference2IntMap;
@@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.objects.Reference2IntMap;
import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
import net.minecraft.world.entity.MobCategory;
import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode;
+import java.util.HashMap;
+import java.util.Map;
import net.minecraft.world.Difficulty;
+import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.monster.Vindicator;
import net.minecraft.world.entity.monster.Zombie;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.spigotmc.SpigotWorldConfig;
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
);
}
+ public Map<EntityType<?>, Integer> entityPerChunkSaveLimits = new HashMap<>();
+ public Map<net.minecraft.world.entity.EntityType<?>, Integer> entityPerChunkSaveLimits = new HashMap<>();
+ private void entityPerChunkSaveLimits() {
+ getInt("entity-per-chunk-save-limit.experience_orb", -1);
+ getInt("entity-per-chunk-save-limit.snowball", -1);
@@ -40,13 +38,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ addEntityPerChunkSaveLimitsFromSection(config.getConfigurationSection("world-settings." + worldName + ".entity-per-chunk-save-limit"), entityPerChunkSaveLimits);
+ }
+
+ private static void addEntityPerChunkSaveLimitsFromSection(final org.bukkit.configuration.ConfigurationSection section, final Map<EntityType<?>, Integer> limitMap) {
+ private static void addEntityPerChunkSaveLimitsFromSection(final org.bukkit.configuration.ConfigurationSection section, final Map<net.minecraft.world.entity.EntityType<?>, Integer> limitMap) {
+ if (section == null) {
+ return;
+ }
+ for (final String key : section.getKeys(false)) {
+ final int value = section.getInt(key);
+ final EntityType<?> type = EntityType.byString(key).orElse(null);
+ final net.minecraft.world.entity.EntityType<?> type = net.minecraft.world.entity.EntityType.byString(key).orElse(null);
+ if (type == null) {
+ logError("Invalid entity-per-chunk-save-limit config, '" + key+ "' is not a valid entity type. Correct this in paper.yml.");
+ continue;