mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-02-16 19:51:27 +01:00
Add more biomes to /is biome
This commit is contained in:
parent
92846d2d75
commit
399f94009a
@ -3,11 +3,15 @@ package me.goodandevil.skyblock.island;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -30,12 +34,13 @@ import me.goodandevil.skyblock.api.utils.APIUtil;
|
||||
import me.goodandevil.skyblock.ban.Ban;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerData;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.upgrade.Upgrade;
|
||||
import me.goodandevil.skyblock.utils.StringUtil;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import me.goodandevil.skyblock.utils.world.WorldBorder;
|
||||
import me.goodandevil.skyblock.visit.Visit;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Island {
|
||||
|
||||
@ -353,8 +358,7 @@ public class Island {
|
||||
}
|
||||
|
||||
public String getBiomeName() {
|
||||
return StringUtil
|
||||
.capatilizeUppercaseLetters(WordUtils.capitalize(getBiome().name().toLowerCase()).replace("_", " "));
|
||||
return WordUtils.capitalizeFully(getBiome().name().replace("_", " "));
|
||||
}
|
||||
|
||||
public void setBiome(Biome biome) {
|
||||
|
@ -31,9 +31,8 @@ import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Biomes;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
||||
import me.goodandevil.skyblock.utils.version.SBiome;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class Biome {
|
||||
@ -102,6 +101,10 @@ public class Biome {
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (is.getItemMeta().hasEnchant(Enchantment.THORNS)) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
@ -110,8 +113,7 @@ public class Biome {
|
||||
event.setWillDestroy(false);
|
||||
} else {
|
||||
if (cooldownManager.hasPlayer(CooldownType.Biome, player) && !player.hasPermission("fabledskyblock.bypass.cooldown")) {
|
||||
CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Biome,
|
||||
player);
|
||||
CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Biome, player);
|
||||
Cooldown cooldown = cooldownPlayer.getCooldown();
|
||||
|
||||
if (cooldown.getTime() < 60) {
|
||||
@ -139,27 +141,13 @@ public class Biome {
|
||||
|
||||
return;
|
||||
}
|
||||
org.bukkit.block.Biome selectedBiomeType = null;
|
||||
|
||||
if (is.getType() == Materials.SUNFLOWER.parseMaterial()) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.PLAINS;
|
||||
} else if (is.getType() == Materials.FERN.parseMaterial()) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.FOREST;
|
||||
} else if (is.getType() == Materials.LILY_PAD.parseMaterial()) {
|
||||
selectedBiomeType = Biomes.SWAMPLAMD.bukkitBiome();
|
||||
} else if (is.getType() == Material.DEAD_BUSH) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.DESERT;
|
||||
} else if (is.getType() == Materials.SNOWBALL.parseMaterial()) {
|
||||
selectedBiomeType = Biomes.COLD_BEACH.bukkitBiome();
|
||||
} else if (is.getType() == Material.VINE) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.JUNGLE;
|
||||
} else if (is.getType() == Materials.DARK_OAK_SAPLING.parseMaterial()) {
|
||||
selectedBiomeType = Biomes.ROOFED_FOREST.bukkitBiome();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
SBiome selectedBiomeType = SBiome.getFromGuiIcon(is.getType(), is.getData().getData());
|
||||
|
||||
cooldownManager.createPlayer(CooldownType.Biome, player);
|
||||
biomeManager.setBiome(island, selectedBiomeType);
|
||||
island.setBiome(selectedBiomeType);
|
||||
biomeManager.setBiome(island, selectedBiomeType.getBiome());
|
||||
island.setBiome(selectedBiomeType.getBiome());
|
||||
island.save();
|
||||
|
||||
soundManager.playSound(island.getLocation(IslandWorld.Normal, IslandEnvironment.Island),
|
||||
@ -181,179 +169,52 @@ public class Biome {
|
||||
});
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
org.bukkit.block.Biome islandBiome = island.getBiome();
|
||||
String islandBiomeName = island.getBiomeName();
|
||||
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG, 1),
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Info.Displayname")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Info.Lore"),
|
||||
new Placeholder[] { new Placeholder("%biome_type", islandBiomeName) }, null, null), 0);
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(),
|
||||
new Placeholder[] { new Placeholder("%biome_type", islandBiomeName) }, null, null), 4);
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(),
|
||||
configLoad.getString("Menu.Biome.Item.Exit.Displayname"), null, null, null, null),
|
||||
0, 8);
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Barrier.Displayname")),
|
||||
null, null, null, null),
|
||||
1);
|
||||
9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
if (islandBiomeName.equals("Plains")) {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.SUNFLOWER.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname")
|
||||
.replace("%biome_type", islandBiomeName)),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null,
|
||||
new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }),
|
||||
2);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.SUNFLOWER.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type",
|
||||
"Plains")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 2);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Forest")) {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.FERN.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname")
|
||||
.replace("%biome_type", islandBiomeName)),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null,
|
||||
new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }),
|
||||
3);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.FERN.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type",
|
||||
"Forest")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 3);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Swampland") || islandBiomeName.equals("Swamp")) {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.LILY_PAD.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname")
|
||||
.replace("%biome_type", islandBiomeName)),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null,
|
||||
new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }),
|
||||
4);
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.LILY_PAD.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname")
|
||||
.replace("%biome_type", "Swampland")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null),
|
||||
4);
|
||||
} else {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.LILY_PAD.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname")
|
||||
.replace("%biome_type", "Swamp")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null),
|
||||
4);
|
||||
}
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Desert")) {
|
||||
nInv.addItem(
|
||||
nInv.createItem(new ItemStack(Material.DEAD_BUSH, 1),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname")
|
||||
.replace("%biome_type", islandBiomeName)),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null,
|
||||
new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }),
|
||||
5);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.DEAD_BUSH, 1),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type",
|
||||
"Desert")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 5);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Cold Beach") || islandBiomeName.equals("Snowy Beach")) {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.SNOWBALL.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname")
|
||||
.replace("%biome_type", islandBiomeName)),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null,
|
||||
new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }),
|
||||
6);
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.SNOWBALL.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname")
|
||||
.replace("%biome_type", "Cold Beach")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null),
|
||||
6);
|
||||
} else {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.SNOWBALL.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname")
|
||||
.replace("%biome_type", "Snowy Beach")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null),
|
||||
6);
|
||||
}
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Jungle")) {
|
||||
nInv.addItem(
|
||||
nInv.createItem(new ItemStack(Material.VINE, 1),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname")
|
||||
.replace("%biome_type", islandBiomeName)),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null,
|
||||
new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }),
|
||||
7);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.VINE, 1),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type",
|
||||
"Jungle")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 7);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Roofed Forest") || islandBiomeName.equals("Dark Forest")) {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.DARK_OAK_SAPLING.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname")
|
||||
.replace("%biome_type", islandBiomeName)),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null,
|
||||
new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }),
|
||||
8);
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.DARK_OAK_SAPLING.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname")
|
||||
.replace("%biome_type", "Roofed Forest")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null),
|
||||
8);
|
||||
} else {
|
||||
nInv.addItem(
|
||||
nInv.createItem(Materials.DARK_OAK_SAPLING.parseItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname")
|
||||
.replace("%biome_type", "Dark Forest")),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null),
|
||||
8);
|
||||
}
|
||||
int slotIndex = 18;
|
||||
for (SBiome biome : SBiome.values()) {
|
||||
if (!biome.isAvailable())
|
||||
continue;
|
||||
|
||||
if (islandBiome.equals(biome.getBiome())) {
|
||||
nInv.addItem(nInv.createItem(biome.getGuiIcon(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname")
|
||||
.replace("%biome_type", biome.getFormattedBiomeName())),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null,
|
||||
new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }),
|
||||
slotIndex);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(biome.getGuiIcon(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname")
|
||||
.replace("%biome_type", biome.getFormattedBiomeName())),
|
||||
configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null),
|
||||
slotIndex);
|
||||
}
|
||||
|
||||
slotIndex++;
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Title")));
|
||||
nInv.setRows(1);
|
||||
nInv.setRows(4);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
|
||||
@Override
|
||||
|
@ -109,7 +109,7 @@ public class Levelling {
|
||||
Island island = islandManager.getIsland(player);
|
||||
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
|
||||
|
||||
if (cooldownManager.hasPlayer(CooldownType.Levelling, offlinePlayer)) {
|
||||
if (cooldownManager.hasPlayer(CooldownType.Levelling, offlinePlayer) && !player.hasPermission("fabledskyblock.bypass.cooldown")) {
|
||||
CooldownPlayer cooldownPlayer = cooldownManager
|
||||
.getCooldownPlayer(CooldownType.Levelling, offlinePlayer);
|
||||
Cooldown cooldown = cooldownPlayer.getCooldown();
|
||||
|
@ -148,7 +148,8 @@ public final class StructureUtil {
|
||||
blockLocation.add(blockRotationLocation);
|
||||
BlockUtil.convertBlockDataToBlock(blockLocation.getBlock(), blockDataList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
SkyBlock.getInstance().getLogger().warning("Unable to convert BlockData to Block for type {" + blockDataList.getMaterial() +
|
||||
":" + blockDataList.getData() + "} in structure {" + structure.getStructureFile() + "}");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -171,7 +172,8 @@ public final class StructureUtil {
|
||||
blockLocation.add(blockRotationLocation);
|
||||
EntityUtil.convertEntityDataToEntity(entityDataList, blockLocation, type);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
SkyBlock.getInstance().getLogger().warning("Unable to convert EntityData to Entity for type {" + entityDataList.getEntityType() +
|
||||
"} in structure {" + structure.getStructureFile() + "}");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,29 +0,0 @@
|
||||
package me.goodandevil.skyblock.utils.version;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
public enum Biomes {
|
||||
|
||||
SWAMPLAMD("SWAMPLAND", "SWAMP"), COLD_BEACH("COLD_BEACH", "SNOWY_BEACH"),
|
||||
ROOFED_FOREST("ROOFED_FOREST", "DARK_FOREST");
|
||||
|
||||
private String pre19biome;
|
||||
private String post19biome;
|
||||
private Biome resolvedBiome = null;
|
||||
|
||||
Biomes(String pre19biome, String post19biome) {
|
||||
this.pre19biome = pre19biome;
|
||||
this.post19biome = post19biome;
|
||||
}
|
||||
|
||||
public Biome bukkitBiome() {
|
||||
if (resolvedBiome != null)
|
||||
return resolvedBiome;
|
||||
|
||||
try {
|
||||
return resolvedBiome = Biome.valueOf(post19biome);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return resolvedBiome = Biome.valueOf(pre19biome);
|
||||
}
|
||||
}
|
||||
}
|
113
src/main/java/me/goodandevil/skyblock/utils/version/SBiome.java
Normal file
113
src/main/java/me/goodandevil/skyblock/utils/version/SBiome.java
Normal file
@ -0,0 +1,113 @@
|
||||
package me.goodandevil.skyblock.utils.version;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* A Biome wrapper for supporting Biomes in 1.8-1.13+
|
||||
*/
|
||||
public enum SBiome {
|
||||
|
||||
BADLANDS(true, Materials.DEAD_BUSH),
|
||||
COLD_OCEAN(true, Materials.ICE),
|
||||
DARK_FOREST("ROOFED_FOREST", Materials.DARK_OAK_SAPLING),
|
||||
DESERT(Materials.SAND),
|
||||
FOREST(Materials.FERN),
|
||||
JUNGLE(Materials.VINE),
|
||||
MOUNTAINS("EXTREME_HILLS", Materials.EMERALD_ORE),
|
||||
MUSHROOM_FIELDS("MUSHROOM_ISLAND", Materials.RED_MUSHROOM),
|
||||
NETHER("HELL", Materials.NETHERRACK),
|
||||
PLAINS(Materials.SUNFLOWER),
|
||||
RIVER(Materials.COD),
|
||||
SAVANNA(Materials.ACACIA_SAPLING),
|
||||
SNOWY_BEACH("COLD_BEACH", Materials.SNOWBALL),
|
||||
SWAMP("SWAMPLAND", Materials.SLIME_BALL),
|
||||
TAIGA(Materials.SPRUCE_SAPLING),
|
||||
THE_END(true, Materials.END_STONE),
|
||||
THE_VOID("SKY", Materials.OBSIDIAN),
|
||||
WARM_OCEAN(true, Materials.TROPICAL_FISH);
|
||||
|
||||
private static boolean isPostVersion = NMSUtil.getVersionNumber() >= 13;
|
||||
|
||||
private String legacyName;
|
||||
private boolean isPost13;
|
||||
private Materials guiIcon;
|
||||
|
||||
SBiome(Materials guiIcon) {
|
||||
this(null, false, guiIcon);
|
||||
}
|
||||
|
||||
SBiome(String legacyName, Materials guiIcon) {
|
||||
this(legacyName, false, guiIcon);
|
||||
}
|
||||
|
||||
SBiome(boolean isPost13, Materials guiIcon) {
|
||||
this(null, isPost13, guiIcon);
|
||||
}
|
||||
|
||||
SBiome(String legacyName, boolean is13only, Materials guiIcon) {
|
||||
this.legacyName = legacyName;
|
||||
this.isPost13 = is13only;
|
||||
this.guiIcon = guiIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this Biome can be used in the current server version
|
||||
*
|
||||
* @return True if the current server version supports this Biome, otherwise false
|
||||
*/
|
||||
public boolean isAvailable() {
|
||||
return !this.isPost13 || isPostVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an SBiome as it's Bukkit Biome counterpart
|
||||
*
|
||||
* @return The Biome this SBiome represents, or null if it is not available in this server version
|
||||
*/
|
||||
public Biome getBiome() {
|
||||
if (!this.isAvailable())
|
||||
return null;
|
||||
if (isPostVersion || this.legacyName == null)
|
||||
return Biome.valueOf(this.name());
|
||||
return Biome.valueOf(this.legacyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the Biome formatted for a Gui
|
||||
*
|
||||
* @return The formatted Biome name
|
||||
*/
|
||||
public String getFormattedBiomeName() {
|
||||
if (!this.isAvailable())
|
||||
return null;
|
||||
return WordUtils.capitalizeFully(this.getBiome().name().replaceAll("_", " "));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Gui icon that represents this Biome
|
||||
*
|
||||
* @return The Gui icon that represents this Biome
|
||||
*/
|
||||
public ItemStack getGuiIcon() {
|
||||
if (!this.isAvailable())
|
||||
return null;
|
||||
return this.guiIcon.parseItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an SBiome based on its Gui icon
|
||||
*
|
||||
* @return An SBiome with a matching Gui icon
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static SBiome getFromGuiIcon(Material material, byte data) {
|
||||
for (SBiome biome : values())
|
||||
if (biome.isAvailable() && biome.getGuiIcon().getType().equals(material) && (isPostVersion || biome.getGuiIcon().getData().getData() == data))
|
||||
return biome;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1706,12 +1706,14 @@ Menu:
|
||||
Biome:
|
||||
Title: "&8Select a Biome"
|
||||
Item:
|
||||
Exit:
|
||||
Displayname: "&cExit Biome Selection"
|
||||
Info:
|
||||
Displayname: "&bCurrent Biome"
|
||||
Lore:
|
||||
- "&7Type&8: &e%biome_type"
|
||||
Barrier:
|
||||
Displayname: "&cSelect a Biome >"
|
||||
Displayname: "&cSelect a Biome"
|
||||
Biome:
|
||||
Current:
|
||||
Displayname: "&a&mBiome: &e&m%biome_type"
|
||||
|
Loading…
Reference in New Issue
Block a user