13
0
geforkt von Mirrors/Paper

Fix treasure maps discovered settings (#7627)

Dieser Commit ist enthalten in:
Jake Potrebic 2022-06-05 17:17:27 -07:00
Ursprung 382529a546
Commit 9b2964fe63
6 geänderte Dateien mit 43 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -16,8 +16,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
log("Treasure Maps will return already discovered locations");
}
treasureMapsAlreadyDiscoveredVillager = getBoolean("treasure-maps-find-already-discovered.villager-trade", treasureMapsAlreadyDiscoveredVillager);
treasureMapsAlreadyDiscoveredLootTable = getBooleanOrNull("treasure-maps-find-already-discovered.loot-tables", treasureMapsAlreadyDiscoveredLootTable);
}
+
+ public int maxCollisionsPerEntity = 8;

Datei anzeigen

@ -12,19 +12,42 @@ 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 @@ public class PaperWorldConfig {
set("despawn-ranges.hard", null);
}
+ if (this.config.isSet("world-settings.default.treasure-maps-return-already-discovered") || this.config.isSet("world-settings." + worldName + ".treasure-maps-return-already-discovered")) {
+ set("treasure-maps-return-already-discovered", null);
+ needsSave = true;
+ }
+
if (needsSave) {
saveConfig();
}
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
Bukkit.getLogger().warning("Spawn Egg and Armor Stand NBT filtering disabled, this is a potential security risk");
}
}
+
+ public boolean enableTreasureMaps = true;
+ public boolean treasureMapsAlreadyDiscovered = false;
+ public boolean treasureMapsAlreadyDiscoveredVillager = false;
+ public Boolean treasureMapsAlreadyDiscoveredLootTable = null;
+ private Boolean getBooleanOrNull(String path, Boolean defaultValue) {
+ this.config.addDefault("world-settings.default." + path, defaultValue == null ? "default" : defaultValue);
+ final Object value = this.config.get("world-settings." + worldName + "." + path, this.config.get("world-settings.default." + path));
+ if (value instanceof Boolean bool) {
+ return bool;
+ }
+ return null;
+ }
+ private void treasureMapsAlreadyDiscovered() {
+ enableTreasureMaps = getBoolean("enable-treasure-maps", true);
+ treasureMapsAlreadyDiscovered = getBoolean("treasure-maps-return-already-discovered", false);
+ if (treasureMapsAlreadyDiscovered) {
+ log("Treasure Maps will return already discovered locations");
+ if (getBoolean("treasure-maps-return-already-discovered", false, false)) {
+ treasureMapsAlreadyDiscoveredLootTable = true;
+ treasureMapsAlreadyDiscoveredVillager = true;
+ }
+ treasureMapsAlreadyDiscoveredVillager = getBoolean("treasure-maps-find-already-discovered.villager-trade", treasureMapsAlreadyDiscoveredVillager);
+ treasureMapsAlreadyDiscoveredLootTable = getBooleanOrNull("treasure-maps-find-already-discovered.loot-tables", treasureMapsAlreadyDiscoveredLootTable);
+ }
}
diff --git a/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java b/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java
@ -37,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ServerLevel serverLevel = (ServerLevel)entity.level;
- BlockPos blockPos = serverLevel.findNearestMapFeature(this.destination, entity.blockPosition(), 100, true);
+ if (!serverLevel.paperConfig.enableTreasureMaps) return null; // Paper
+ BlockPos blockPos = serverLevel.findNearestMapFeature(this.destination, entity.blockPosition(), 100, !serverLevel.paperConfig.treasureMapsAlreadyDiscovered); // Paper
+ BlockPos blockPos = serverLevel.findNearestMapFeature(this.destination, entity.blockPosition(), 100, !serverLevel.paperConfig.treasureMapsAlreadyDiscoveredVillager); // Paper
if (blockPos != null) {
ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), (byte)2, true, true);
MapItem.renderBiomePreviewMap(serverLevel, itemStack);
@ -59,7 +82,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return stack;
+ }
+ // Paper end
+ BlockPos blockPos = serverLevel.findNearestMapFeature(this.destination, new BlockPos(vec3), this.searchRadius, !serverLevel.paperConfig.treasureMapsAlreadyDiscovered && this.skipKnownStructures); // Paper
+ BlockPos blockPos = serverLevel.findNearestMapFeature(this.destination, new BlockPos(vec3), this.searchRadius, serverLevel.paperConfig.treasureMapsAlreadyDiscoveredLootTable == null ? this.skipKnownStructures : serverLevel.paperConfig.treasureMapsAlreadyDiscoveredLootTable); // Paper
if (blockPos != null) {
ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), this.zoom, true, true);
MapItem.renderBiomePreviewMap(serverLevel, itemStack);

Datei anzeigen

@ -20,8 +20,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
private boolean getBoolean(String path, boolean def) {
config.addDefault("world-settings.default." + path, def);
return config.getBoolean("world-settings." + worldName + "." + path, config.getBoolean("world-settings.default." + path));
return this.getBoolean(path, def, true);
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java

Datei anzeigen

@ -259,8 +259,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ private boolean getBoolean(String path, boolean def) {
+ config.addDefault("world-settings.default." + path, def);
+ return config.getBoolean("world-settings." + worldName + "." + path, config.getBoolean("world-settings.default." + path));
+ return this.getBoolean(path, def, true);
+ }
+ private boolean getBoolean(String path, boolean def, boolean setDefault) {
+ if (setDefault) {
+ config.addDefault("world-settings.default." + path, def);
+ }
+ return config.getBoolean("world-settings." + worldName + "." + path, config.getBoolean("world-settings.default." + path, def));
+ }
+
+ private double getDouble(String path, double def) {

Datei anzeigen

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ set("spawn-limits.water-ambient", null);
}
if (needsSave) {
if (this.config.isSet("world-settings.default.treasure-maps-return-already-discovered") || this.config.isSet("world-settings." + worldName + ".treasure-maps-return-already-discovered")) {
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance);
}

Datei anzeigen

@ -47,8 +47,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
private boolean getBoolean(String path, boolean def) {
config.addDefault("world-settings.default." + path, def);
return config.getBoolean("world-settings." + worldName + "." + path, config.getBoolean("world-settings.default." + path));
return this.getBoolean(path, def, true);
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java