From c1ecaa2ff772cb60bc8842267d3649564c21738c Mon Sep 17 00:00:00 2001 From: Ugleh Date: Mon, 24 Sep 2018 19:32:34 +1000 Subject: API to generate filled explorer maps --- .../java/org/bukkit/craftbukkit/CraftServer.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 2d5dff3d..a0eefe04 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -37,6 +37,7 @@ import org.bukkit.Server; import org.bukkit.UnsafeValues; import org.bukkit.Warning.WarningState; import org.bukkit.World; +import org.bukkit.StructureType; import org.bukkit.World.Environment; import org.bukkit.WorldCreator; import org.bukkit.boss.BarColor; @@ -59,6 +60,7 @@ import org.bukkit.craftbukkit.generator.CraftChunkData; import org.bukkit.craftbukkit.help.SimpleHelpMap; import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe; import org.bukkit.craftbukkit.inventory.CraftInventoryCustom; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemFactory; import org.bukkit.craftbukkit.inventory.CraftMerchantCustom; import org.bukkit.craftbukkit.inventory.CraftRecipe; @@ -96,6 +98,7 @@ import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapelessRecipe; import org.bukkit.loot.LootTable; +import org.bukkit.map.MapView; import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permission; import org.bukkit.plugin.Plugin; @@ -1254,6 +1257,30 @@ public final class CraftServer implements Server { return worldmap.mapView; } + @Override + public ItemStack createExplorerMap(World world, Location location, StructureType structureType) { + return this.createExplorerMap(world, location, structureType, 100, true); + } + + @Override + public ItemStack createExplorerMap(World world, Location location, StructureType structureType, int radius, boolean findUnexplored) { + Validate.notNull(world, "World cannot be null"); + Validate.notNull(structureType, "StructureType cannot be null"); + Validate.notNull(structureType.getMapIcon(), "Cannot create explorer maps for StructureType " + structureType.getName()); + + WorldServer worldServer = ((CraftWorld) world).getHandle(); + Location structureLocation = world.locateNearestStructure(location, structureType, radius, findUnexplored); + BlockPosition structurePosition = new BlockPosition(structureLocation.getBlockX(), structureLocation.getBlockY(), structureLocation.getBlockZ()); + + // Create map with trackPlayer = true, unlimitedTracking = true + net.minecraft.server.ItemStack stack = ItemWorldMap.a(worldServer, structurePosition.getX(), structurePosition.getZ(), MapView.Scale.NORMAL.getValue(), true, true); //PAIL rename setFilledMapView + ItemWorldMap.a(worldServer, stack); // PAIL rename sepiaMapFilter + // "+" map ID taken from EntityVillager + ItemWorldMap.getSavedMap(stack, worldServer).a(stack, structurePosition, "+", MapIcon.Type.a(structureType.getMapIcon().getValue())); // PAIL rename decorateMap + + return CraftItemStack.asBukkitCopy(stack); + } + @Override public void shutdown() { console.safeShutdown(); -- cgit v1.2.3