Fix spawner provider on 1.16 (#3412)

This commit is contained in:
pop4959 2020-06-24 23:25:14 -07:00 committed by GitHub
parent 4a471f0a93
commit c043416b11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,30 +1,32 @@
package net.ess3.provider; package net.ess3.provider;
import com.google.common.collect.ImmutableMap;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public interface SpawnerProvider extends Provider { public interface SpawnerProvider extends Provider {
ItemStack setEntityType(ItemStack is, EntityType type) throws IllegalArgumentException; ItemStack setEntityType(ItemStack is, EntityType type) throws IllegalArgumentException;
EntityType getEntityType(ItemStack is) throws IllegalArgumentException; EntityType getEntityType(ItemStack is) throws IllegalArgumentException;
Map<EntityType, String> entityToDisplayName = ImmutableMap.<EntityType, String>builder() Map<EntityType, String> entityToDisplayName = Stream.of("CAVE_SPIDER:Cave Spider", "PIG_ZOMBIE:Zombie Pigman",
.put(EntityType.CAVE_SPIDER, "Cave Spider") "ZOMBIFIED_PIGLIN:Zombie Piglin", "MAGMA_CUBE:Magma Cube", "ENDER_DRAGON:Ender Dragon",
.put(EntityType.PIG_ZOMBIE, "Zombie Pigman") "MUSHROOM_COW:Mooshroom", "SNOWMAN:Snow Golem", "OCELOT:Ocelot", "IRON_GOLEM:Iron Golem", "WITHER:Wither",
.put(EntityType.MAGMA_CUBE, "Magma Cube") "HORSE:Horse")
.put(EntityType.ENDER_DRAGON, "Ender Dragon") .filter(s -> {
.put(EntityType.MUSHROOM_COW, "Mooshroom") try {
.put(EntityType.SNOWMAN, "Snow Golem") EntityType.valueOf(s);
.put(EntityType.OCELOT, "Ocelot") return true;
.put(EntityType.IRON_GOLEM, "Iron Golem") } catch (IllegalArgumentException e) {
.put(EntityType.WITHER, "Wither") return false;
.put(EntityType.HORSE, "Horse") }
.build(); })
.collect(Collectors.toMap(s -> EntityType.valueOf(s.split(":")[0]), s -> s.split(":")[1]));
default ItemStack setDisplayName(ItemStack is, EntityType type) { default ItemStack setDisplayName(ItemStack is, EntityType type) {
ItemMeta meta = is.getItemMeta(); ItemMeta meta = is.getItemMeta();