From 4ed27a6eca4ffa2db0d992c3c508cc59a1c44d81 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Mon, 6 May 2019 08:40:10 +1000 Subject: [PATCH] SPIGOT-4872: LootTables missing a few loot tables By: md_5 --- paper-api/README.md | 19 ++++++-- paper-api/pom.xml | 6 +-- .../src/main/java/org/bukkit/Registry.java | 14 ++++-- .../main/java/org/bukkit/loot/LootTables.java | 45 ++++++++++++++++++- 4 files changed, 73 insertions(+), 11 deletions(-) diff --git a/paper-api/README.md b/paper-api/README.md index 39687f9913..31c5e1cdd1 100644 --- a/paper-api/README.md +++ b/paper-api/README.md @@ -30,9 +30,13 @@ Contributions of all sorts are welcome. To manage community contributions, we us * Create an account on [JIRA](http://hub.spigotmc.org/jira/). * Fill in the [SpigotMC CLA](http://www.spigotmc.org/go/cla) and wait up to 24 hours for your Stash account to be activated. Please ensure that your username and email addresses match. * Log into Stash using your JIRA credentials. - + Once you have performed these steps you can create a fork, push your code changes, and then submit it for review. +If you submit a PR involving both Bukkit and CraftBukkit, each PR should link the other. + +Although the minimum requirement for compilation & usage is Java 8, we prefer all contributions to be written in Java 7 style code unless there is a compelling reason otherwise. + Bukkit's Goals -------------- As a rough guideline, ask yourself the following questions to determine if the proposed change fits the Bukkit project's goals. Please remember that this is only a rough guideline @@ -64,10 +68,15 @@ Code Requirements * Empty lines should contain no spaces. * No trailing whitespaces. * No 80 character column limit, or 'weird' mid-statement newlines unless absolutely necessary. + * The 80 character column limit still applies to documentation. * No one-line methods. -* All major additions should have documentation(e.g. javadocs). +* All major additions should have documentation. * Try to follow test driven development where available. * All code should be free of magic values. If this is not possible, it should be marked with a TODO comment indicating it should be addressed in the future. + * If magic values are absolutely necessary for your change, what those values represent should be documented in the code as well as an explanation in the Pull Request description on why those values are necessary. +* No unnecessary code changes. Look through all your changes before you submit it. +* Do not attempt to fix multiple problems with a single patch or pull request. +* Avoid moving or renaming classes. * All non-private methods and constructors must have specified nullability through [annotations](https://github.com/JetBrains/java-annotations) Bukkit/CraftBukkit employs [JUnit 4](http://www.vogella.com/articles/JUnit/article.html) for testing. Pull Requests(PR) should attempt to integrate within that framework as appropriate. @@ -75,4 +84,8 @@ Bukkit is a large project and what seems simple to a PR author at the time of wr will help to ensure the PR can be easily maintained over time and encourage the Spigot team to pull the PR. * There needs to be a new line at the end of every file. -* Absolutely no wildcard imports. +* Imports should be organised in a logical manner. + * Do not group packages + * __Absolutely no wildcard imports outside of tests.__ + +Any questions about these requirements can be asked in #spigot-dev in IRC. diff --git a/paper-api/pom.xml b/paper-api/pom.xml index d5b950fc1e..4417dcab9a 100644 --- a/paper-api/pom.xml +++ b/paper-api/pom.xml @@ -14,8 +14,8 @@ true - 1.7 - 1.7 + 1.8 + 1.8 UTF-8 @@ -203,7 +203,7 @@ org.codehaus.mojo.signature - java17 + java18 1.0 diff --git a/paper-api/src/main/java/org/bukkit/Registry.java b/paper-api/src/main/java/org/bukkit/Registry.java index a36b890bd1..1941df36ca 100644 --- a/paper-api/src/main/java/org/bukkit/Registry.java +++ b/paper-api/src/main/java/org/bukkit/Registry.java @@ -1,9 +1,11 @@ package org.bukkit; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; import java.util.Arrays; import java.util.Iterator; import java.util.Map; +import java.util.function.Predicate; import org.bukkit.advancement.Advancement; import org.bukkit.block.Biome; import org.bukkit.boss.KeyedBossBar; @@ -98,7 +100,7 @@ public interface Registry extends Iterable { * * @see EntityType */ - Registry ENTITY_TYPE = new SimpleRegistry<>(EntityType.class); + Registry ENTITY_TYPE = new SimpleRegistry<>(EntityType.class, (entity) -> entity != EntityType.UNKNOWN); /** * Default server loot tables. * @@ -110,7 +112,7 @@ public interface Registry extends Iterable { * * @see Material */ - Registry MATERIAL = new SimpleRegistry<>(Material.class); + Registry MATERIAL = new SimpleRegistry<>(Material.class, (mat) -> !mat.isLegacy()); /** * Server statistics. * @@ -144,10 +146,16 @@ public interface Registry extends Iterable { private final Map map; protected SimpleRegistry(@NotNull Class type) { + this(type, Predicates.alwaysTrue()); + } + + protected SimpleRegistry(@NotNull Class type, @NotNull Predicate predicate) { ImmutableMap.Builder builder = ImmutableMap.builder(); for (T entry : type.getEnumConstants()) { - builder.put(entry.getKey(), entry); + if (predicate.test(entry)) { + builder.put(entry.getKey(), entry); + } } map = builder.build(); diff --git a/paper-api/src/main/java/org/bukkit/loot/LootTables.java b/paper-api/src/main/java/org/bukkit/loot/LootTables.java index 7b7dcfa273..7e83073997 100644 --- a/paper-api/src/main/java/org/bukkit/loot/LootTables.java +++ b/paper-api/src/main/java/org/bukkit/loot/LootTables.java @@ -25,6 +25,7 @@ public enum LootTables implements Keyed { JUNGLE_TEMPLE("chests/jungle_temple"), JUNGLE_TEMPLE_DISPENSER("chests/jungle_temple_dispenser"), NETHER_BRIDGE("chests/nether_bridge"), + PILLAGER_OUTPOST("chests/pillager_outpost"), SHIPWRECK_MAP("chests/shipwreck_map"), SHIPWRECK_SUPPLY("chests/shipwreck_supply"), SHIPWRECK_TREASURE("chests/shipwreck_treasure"), @@ -35,11 +36,28 @@ public enum LootTables implements Keyed { STRONGHOLD_LIBRARY("chests/stronghold_library"), UNDERWATER_RUIN_BIG("chests/underwater_ruin_big"), UNDERWATER_RUIN_SMALL("chests/underwater_ruin_small"), - VILLAGE_BLACKSMITH("chests/village_blacksmith"), + VILLAGE_ARMORER("chests/village/village_armorer"), + VILLAGE_BUTCHER("chests/village/village_butcher"), + VILLAGE_CARTOGRAPHER("chests/village/village_cartographer"), + VILLAGE_DESERT_HOUSE("chests/village/village_desert_house"), + VILLAGE_FISHER("chests/village/village_fisher"), + VILLAGE_FLETCHER("chests/village/village_fletcher"), + VILLAGE_MASON("chests/village/village_mason"), + VILLAGE_PLAINS_HOUSE("chests/village/village_plains_house"), + VILLAGE_SAVANNA_HOUSE("chests/village/village_savanna_house"), + VILLAGE_SHEPHERD("chests/village/village_shepherd"), + VILLAGE_SNOWY_HOUSE("chests/village/village_snowy_house"), + VILLAGE_TAIGA_HOUSE("chests/village/village_taiga_house"), + VILLAGE_TANNERY("chests/village/village_tannery"), + VILLAGE_TEMPLE("chests/village/village_temple"), + VILLAGE_TOOLSMITH("chests/village/village_toolsmith"), + VILLAGE_WEAPONSMITH("chests/village/village_weaponsmith"), WOODLAND_MANSION("chests/woodland_mansion"), // Entities + ARMOR_STAND("entities/armor_stand"), BAT("entities/bat"), BLAZE("entities/blaze"), + CAT("entities/cat"), CAVE_SPIDER("entities/cave_spider"), CHICKEN("entities/chicken"), COD("entities/cod"), @@ -53,23 +71,28 @@ public enum LootTables implements Keyed { ENDERMITE("entities/endermite"), ENDER_DRAGON("entities/ender_dragon"), EVOKER("entities/evoker"), + FOX("entities/fox"), GHAST("entities/ghast"), GIANT("entities/giant"), GUARDIAN("entities/guardian"), HORSE("entities/horse"), HUSK("entities/husk"), + ILLUSIONER("entities/illusioner"), IRON_GOLEM("entities/iron_golem"), LLAMA("entities/llama"), MAGMA_CUBE("entities/magma_cube"), + MOOSHROOM("entities/mooshroom"), MULE("entities/mule"), - MUSHROOM_COW("entities/mushroom_cow"), OCELOT("entities/ocelot"), + PANDA("entities/panda"), PARROT("entities/parrot"), PHANTOM("entities/phantom"), PIG("entities/pig"), + PILLAGER("entities/pillager"), POLAR_BEAR("entities/polar_bear"), PUFFERFISH("entities/pufferfish"), RABBIT("entities/rabbit"), + RAVAGER("entities/ravager"), SALMON("entities/salmon"), // Sheep entry here, moved below for organizational purposes SHULKER("entities/shulker"), @@ -81,12 +104,15 @@ public enum LootTables implements Keyed { SPIDER("entities/spider"), SQUID("entities/squid"), STRAY("entities/stray"), + TRADER_LLAMA("entities/trader_llama"), TROPICAL_FISH("entities/tropical_fish"), TURTLE("entities/turtle"), VEX("entities/vex"), VILLAGER("entities/villager"), VINDICATOR("entities/vindicator"), + WANDERING_TRADER("entities/wandering_trader"), WITCH("entities/witch"), + WITHER("entities/wither"), WITHER_SKELETON("entities/wither_skeleton"), WOLF("entities/wolf"), ZOMBIE("entities/zombie"), @@ -94,10 +120,24 @@ public enum LootTables implements Keyed { ZOMBIE_PIGMAN("entities/zombie_pigman"), ZOMBIE_VILLAGER("entities/zombie_villager"), // Gameplay + ARMORER_GIFT("gameplay/hero_of_the_village/armorer_gift"), + BUTCHER_GIFT("gameplay/hero_of_the_village/butcher_gift"), + CARTOGRAPHER_GIFT("gameplay/hero_of_the_village/cartographer_gift"), + CAT_MORNING_GIFT("gameplay/cat_morning_gift"), + CLERIC_GIFT("gameplay/hero_of_the_village/cleric_gift"), + FARMER_GIFT("gameplay/hero_of_the_village/farmer_gift"), + FISHERMAN_GIFT("gameplay/hero_of_the_village/fisherman_gift"), FISHING("gameplay/fishing"), FISHING_FISH("gameplay/fishing/fish"), FISHING_JUNK("gameplay/fishing/junk"), FISHING_TREASURE("gameplay/fishing/treasure"), + FLETCHER_GIFT("gameplay/hero_of_the_village/fletcher_gift"), + LEATHERWORKER_GIFT("gameplay/hero_of_the_village/leatherworker_gift"), + LIBRARIAN_GIFT("gameplay/hero_of_the_village/librarian_gift"), + MASON_GIFT("gameplay/hero_of_the_village/mason_gift"), + SHEPHERD_GIFT("gameplay/hero_of_the_village/shepherd_gift"), + TOOLSMITH_GIFT("gameplay/hero_of_the_village/toolsmith_gift"), + WEAPONSMITH_GIFT("gameplay/hero_of_the_village/weaponsmith_gift"), // Sheep SHEEP("entities/sheep"), SHEEP_BLACK("entities/sheep/black"), @@ -107,6 +147,7 @@ public enum LootTables implements Keyed { SHEEP_GRAY("entities/sheep/gray"), SHEEP_GREEN("entities/sheep/green"), SHEEP_LIGHT_BLUE("entities/sheep/light_blue"), + SHEEP_LIGHT_GRAY("entities/sheep/light_gray"), SHEEP_LIME("entities/sheep/lime"), SHEEP_MAGENTA("entities/sheep/magenta"), SHEEP_ORANGE("entities/sheep/orange"),