mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 04:02:06 -07:00
Move to configurate for paper.yml (#7609)
This commit is contained in:
@@ -8,48 +8,6 @@ Allow configuring for cartographers to return the same map location
|
||||
Also allow turning off treasure maps all together as they can eat up Map ID's
|
||||
which are limited in quantity.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
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 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);
|
||||
+ 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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java
|
||||
@@ -59,8 +17,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
} else {
|
||||
ServerLevel serverLevel = (ServerLevel)entity.level;
|
||||
- BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, entity.blockPosition(), 100, true);
|
||||
+ if (!serverLevel.paperConfig.enableTreasureMaps) return null; // Paper
|
||||
+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, entity.blockPosition(), 100, !serverLevel.paperConfig.treasureMapsAlreadyDiscoveredVillager); // Paper
|
||||
+ if (!serverLevel.paperConfig().environment.treasureMaps.enabled) return null; // Paper
|
||||
+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, entity.blockPosition(), 100, !serverLevel.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager); // Paper
|
||||
if (blockPos != null) {
|
||||
ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), (byte)2, true, true);
|
||||
MapItem.renderBiomePreviewMap(serverLevel, itemStack);
|
||||
@@ -74,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
ServerLevel serverLevel = context.getLevel();
|
||||
- BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, new BlockPos(vec3), this.searchRadius, this.skipKnownStructures);
|
||||
+ // Paper start
|
||||
+ if (!serverLevel.paperConfig.enableTreasureMaps) {
|
||||
+ if (!serverLevel.paperConfig().environment.treasureMaps.enabled) {
|
||||
+ /*
|
||||
+ * NOTE: I fear users will just get a plain map as their "treasure"
|
||||
+ * This is preferable to disrespecting the config.
|
||||
@@ -82,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return stack;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, new BlockPos(vec3), this.searchRadius, serverLevel.paperConfig.treasureMapsAlreadyDiscoveredLootTable == null ? this.skipKnownStructures : serverLevel.paperConfig.treasureMapsAlreadyDiscoveredLootTable); // Paper
|
||||
+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, new BlockPos(vec3), this.searchRadius, serverLevel.paperConfig().environment.treasureMaps.findAlreadyDiscoveredLootTable.or(this.skipKnownStructures)); // Paper
|
||||
if (blockPos != null) {
|
||||
ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), this.zoom, true, true);
|
||||
MapItem.renderBiomePreviewMap(serverLevel, itemStack);
|
||||
|
Reference in New Issue
Block a user