Fixes startup issues because of renamed Enum constants

The constants #name() was used when reading various plugin configurations.
After me renaming them in 308d8ca7b9 they stopped
matching in the configurations and broke everything horibly.

This commit introduces a friendly name to keep the new names but still support existing configuration files.
This commit is contained in:
Christian Koop 2023-08-16 17:27:05 +02:00
parent b29111b96d
commit 4df43fccad
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
37 changed files with 339 additions and 182 deletions

View File

@ -152,7 +152,7 @@ public class SkyBlock extends SongodaPlugin {
@Override
public void onPluginEnable() {
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_19) || ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) {
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_20) || ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) {
this.getLogger().warning("This Minecraft version is not officially supported.");
}

View File

@ -65,7 +65,7 @@ public class AddUpgradeCommand extends SubCommand {
Upgrade.Type upgrade = null;
for (Upgrade.Type type : Upgrade.Type.values()) {
if (type.name().equalsIgnoreCase(args[1])) {
if (type.getFriendlyName().equalsIgnoreCase(args[1])) {
upgrade = type;
break;
}
@ -102,7 +102,7 @@ public class AddUpgradeCommand extends SubCommand {
FileConfiguration islandDataConfigLoad = YamlConfiguration.loadConfiguration(islandDataFile);
if (islandDataConfigLoad.getString("Upgrade." + upgrade.name()) != null) {
if (islandDataConfigLoad.getString("Upgrade." + upgrade.getFriendlyName()) != null) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Already.Message"));
soundManager.playSound(sender, XSound.BLOCK_ANVIL_LAND);
@ -110,7 +110,7 @@ public class AddUpgradeCommand extends SubCommand {
return;
}
islandDataConfigLoad.set("Upgrade." + upgrade.name(), true);
islandDataConfigLoad.set("Upgrade." + upgrade.getFriendlyName(), true);
try {
islandDataConfigLoad.save(islandDataFile);
@ -121,7 +121,7 @@ public class AddUpgradeCommand extends SubCommand {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.AddUpgrade.Added.Message")
.replace("%player", targetPlayerName).replace("%upgrade", upgrade.name()));
.replace("%player", targetPlayerName).replace("%upgrade", upgrade.getFriendlyName()));
soundManager.playSound(sender, XSound.BLOCK_NOTE_BLOCK_PLING);
}
} else {

View File

@ -63,11 +63,11 @@ public class RemoveHologramCommand extends SubCommand {
Config locationsConfig = fileManager.getConfig(new File(this.plugin.getDataFolder(), "locations.yml"));
FileConfiguration locationsConfigLoad = locationsConfig.getFileConfiguration();
if (locationsConfigLoad.getString("Location.Hologram.Leaderboard." + hologramType.name()) == null) {
if (locationsConfigLoad.getString("Location.Hologram.Leaderboard." + hologramType.getFriendlyName()) == null) {
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Set.Message"));
soundManager.playSound(sender, XSound.BLOCK_ANVIL_LAND);
} else {
locationsConfigLoad.set("Location.Hologram.Leaderboard." + hologramType.name(), null);
locationsConfigLoad.set("Location.Hologram.Leaderboard." + hologramType.getFriendlyName(), null);
try {
locationsConfigLoad.save(locationsConfig.getFile());
@ -84,7 +84,7 @@ public class RemoveHologramCommand extends SubCommand {
}
});
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Removed.Message").replace("%type", hologramType.name()));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Removed.Message").replace("%type", hologramType.getFriendlyName()));
soundManager.playSound(sender, XSound.BLOCK_NOTE_BLOCK_PLING);
}

View File

@ -64,7 +64,7 @@ public class RemoveUpgradeCommand extends SubCommand {
Upgrade.Type upgrade = null;
for (Upgrade.Type type : Upgrade.Type.values()) {
if (type.name().equalsIgnoreCase(args[1])) {
if (type.getFriendlyName().equalsIgnoreCase(args[1])) {
upgrade = type;
break;
}
@ -105,7 +105,7 @@ public class RemoveUpgradeCommand extends SubCommand {
FileConfiguration islandDataConfigLoad = YamlConfiguration.loadConfiguration(islandDataFile);
if (islandDataConfigLoad.getString("Upgrade." + upgrade.name()) == null) {
if (islandDataConfigLoad.getString("Upgrade." + upgrade.getFriendlyName()) == null) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Upgrade.Missing.Message"));
soundManager.playSound(sender, XSound.BLOCK_ANVIL_LAND);
@ -113,7 +113,7 @@ public class RemoveUpgradeCommand extends SubCommand {
return;
}
islandDataConfigLoad.set("Upgrade." + upgrade.name(), null);
islandDataConfigLoad.set("Upgrade." + upgrade.getFriendlyName(), null);
try {
islandDataConfigLoad.save(islandDataFile);
@ -124,7 +124,7 @@ public class RemoveUpgradeCommand extends SubCommand {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Removed.Message")
.replace("%player", targetPlayerName).replace("%upgrade", upgrade.name()));
.replace("%player", targetPlayerName).replace("%upgrade", upgrade.getFriendlyName()));
soundManager.playSound(sender, XSound.BLOCK_NOTE_BLOCK_PLING);
}
} else {

View File

@ -57,7 +57,7 @@ public class SetBiomeCommand extends SubCommand {
if (args.length > 2) {
String worldName = args[2].toUpperCase().trim();
for (IslandWorld islandWorld : IslandWorld.values()) {
if (islandWorld.name().equalsIgnoreCase(worldName)) {
if (islandWorld.getFriendlyName().equalsIgnoreCase(worldName)) {
world = islandWorld;
}
}

View File

@ -51,7 +51,7 @@ public class SetHologramCommand extends SubCommand {
if (hologramType != null) {
fileManager.setLocation(
fileManager.getConfig(new File(this.plugin.getDataFolder(), "locations.yml")),
"Location.Hologram.Leaderboard." + hologramType.name(), player.getLocation(), true);
"Location.Hologram.Leaderboard." + hologramType.getFriendlyName(), player.getLocation(), true);
Bukkit.getServer().getScheduler().runTask(this.plugin, () -> {
@ -64,7 +64,7 @@ public class SetHologramCommand extends SubCommand {
hologramManager.spawnHologram(hologramType1);
});
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetHologram.Set.Message").replace("%type", hologramType.name()));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetHologram.Set.Message").replace("%type", hologramType.getFriendlyName()));
soundManager.playSound(player, XSound.BLOCK_NOTE_BLOCK_PLING);
return;

View File

@ -92,7 +92,7 @@ public class SetSpawnCommand extends SubCommand {
|| island.hasRole(IslandRole.OWNER, player.getUniqueId())) {
if ((island.hasRole(IslandRole.OPERATOR, player.getUniqueId())
&& (this.plugin.getPermissionManager().hasPermission(island,
environment.name() + "Spawn", IslandRole.OPERATOR)))
environment.getFriendlyName() + "Spawn", IslandRole.OPERATOR)))
|| island.hasRole(IslandRole.OWNER, player.getUniqueId())) {
if (islandManager.isPlayerAtIsland(island, player)) {
IslandWorld world = this.plugin.getWorldManager().getIslandWorld(player.getWorld());
@ -153,23 +153,23 @@ public class SetSpawnCommand extends SubCommand {
island.setLocation(world, environment, newSpawnLocation);
messageManager.sendMessage(player,
configLoad.getString("Command.Island.SetSpawn.Set.Message").replace("%spawn", environment.name().toLowerCase()));
configLoad.getString("Command.Island.SetSpawn.Set.Message").replace("%spawn", environment.getFriendlyName().toLowerCase()));
soundManager.playSound(player, XSound.BLOCK_NOTE_BLOCK_PLING);
return;
}
messageManager.sendMessage(player,
configLoad.getString("Command.Island.SetSpawn.Island.Message").replace("%spawn", environment.name().toLowerCase()));
configLoad.getString("Command.Island.SetSpawn.Island.Message").replace("%spawn", environment.getFriendlyName().toLowerCase()));
soundManager.playSound(player, XSound.BLOCK_ANVIL_LAND);
} else {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.SetSpawn.Permission.Message").replace("%spawn", environment.name().toLowerCase()));
configLoad.getString("Command.Island.SetSpawn.Permission.Message").replace("%spawn", environment.getFriendlyName().toLowerCase()));
soundManager.playSound(player, XSound.ENTITY_VILLAGER_NO);
}
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Role.Message")
.replace("%spawn", environment.name().toLowerCase()));
.replace("%spawn", environment.getFriendlyName().toLowerCase()));
soundManager.playSound(player, XSound.BLOCK_ANVIL_LAND);
}
}

View File

@ -55,7 +55,7 @@ public class UnlockCommand extends SubCommand {
}
Island island = islandManager.getIsland(player);
IslandWorld islandWorld = IslandWorld.valueOf(type);
IslandWorld islandWorld = IslandWorld.valueOf(type.toUpperCase());
if (island == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Owner.Message"));
@ -70,7 +70,7 @@ public class UnlockCommand extends SubCommand {
}
double price = fileManager.getConfig(new File(this.plugin.getDataFolder(), "config.yml"))
.getFileConfiguration().getDouble("Island.World." + islandWorld.name() + ".UnlockPrice");
.getFileConfiguration().getDouble("Island.World." + islandWorld.getFriendlyName() + ".UnlockPrice");
if (!economy.hasBalance(player, price)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Money.Message").replace(

View File

@ -147,9 +147,9 @@ public class FileManager {
FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration();
for (IslandWorld worldList : IslandWorld.values()) {
if (mainConfigLoad.getString("World." + worldList.name()) != null) {
configLoad.set("World." + worldList.name() + ".nextAvailableLocation.x", mainConfigLoad.getDouble("World." + worldList.name() + ".nextAvailableLocation.x"));
configLoad.set("World." + worldList.name() + ".nextAvailableLocation.z", mainConfigLoad.getDouble("World." + worldList.name() + ".nextAvailableLocation.z"));
if (mainConfigLoad.getString("World." + worldList.getFriendlyName()) != null) {
configLoad.set("World." + worldList.getFriendlyName() + ".nextAvailableLocation.x", mainConfigLoad.getDouble("World." + worldList.getFriendlyName() + ".nextAvailableLocation.x"));
configLoad.set("World." + worldList.getFriendlyName() + ".nextAvailableLocation.z", mainConfigLoad.getDouble("World." + worldList.getFriendlyName() + ".nextAvailableLocation.z"));
}
}

View File

@ -72,16 +72,16 @@ public class CooldownManager {
.getConfig(new File(new File(this.plugin.getDataFolder(), "player-data"), player.getUniqueId() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Island." + cooldownType.name() + ".Cooldown") != null) {
return new CooldownPlayer(player.getUniqueId(), new Cooldown(configLoad.getInt("Island." + cooldownType.name() + ".Cooldown")));
if (configLoad.getString("Island." + cooldownType.getFriendlyName() + ".Cooldown") != null) {
return new CooldownPlayer(player.getUniqueId(), new Cooldown(configLoad.getInt("Island." + cooldownType.getFriendlyName() + ".Cooldown")));
}
} else if (cooldownType == CooldownType.LEVELLING || cooldownType == CooldownType.OWNERSHIP) {
FileManager.Config config = this.plugin.getFileManager()
.getConfig(new File(new File(this.plugin.getDataFolder(), "island-data"), player.getUniqueId() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString(cooldownType.name() + ".Cooldown") != null) {
return new CooldownPlayer(player.getUniqueId(), new Cooldown(configLoad.getInt(cooldownType.name() + ".Cooldown")));
if (configLoad.getString(cooldownType.getFriendlyName() + ".Cooldown") != null) {
return new CooldownPlayer(player.getUniqueId(), new Cooldown(configLoad.getInt(cooldownType.getFriendlyName() + ".Cooldown")));
}
}
@ -101,14 +101,14 @@ public class CooldownManager {
if (cooldownType == CooldownType.BIOME || cooldownType == CooldownType.CREATION || cooldownType == CooldownType.DELETION || cooldownType == CooldownType.PREVIEW) {
time = this.plugin.getConfiguration()
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
.getInt("Island." + cooldownType.getFriendlyName() + ".Cooldown.Time");
FileManager.Config config = fileManager
.getConfig(new File(new File(this.plugin.getDataFolder(), "player-data"), player.getUniqueId() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Island." + cooldownType.name() + ".Cooldown", time);
configLoad.set("Island." + cooldownType.getFriendlyName() + ".Cooldown", time);
try {
configLoad.save(configFile);
@ -117,14 +117,14 @@ public class CooldownManager {
}
} else if (cooldownType == CooldownType.LEVELLING || cooldownType == CooldownType.OWNERSHIP) {
time = this.plugin.getConfiguration()
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
.getInt("Island." + cooldownType.getFriendlyName() + ".Cooldown.Time");
FileManager.Config config = this.plugin.getFileManager()
.getConfig(new File(new File(this.plugin.getDataFolder(), "island-data"), player.getUniqueId() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set(cooldownType.name() + ".Cooldown", time);
configLoad.set(cooldownType.getFriendlyName() + ".Cooldown", time);
try {
configLoad.save(configFile);
@ -143,11 +143,11 @@ public class CooldownManager {
this.plugin.getFileManager()
.getConfig(new File(new File(this.plugin.getDataFolder().toString() + "/player-data"),
player.getUniqueId().toString() + ".yml"))
.getFileConfiguration().set("Island." + cooldownType.name() + ".Cooldown", null);
.getFileConfiguration().set("Island." + cooldownType.getFriendlyName() + ".Cooldown", null);
} else if (cooldownType == CooldownType.LEVELLING || cooldownType == CooldownType.OWNERSHIP) {
this.plugin.getFileManager().getConfig(
new File(new File(this.plugin.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml"))
.getFileConfiguration().set(cooldownType.name() + ".Cooldown", null);
new File(new File(this.plugin.getDataFolder() + "/island-data"), player.getUniqueId() + ".yml"))
.getFileConfiguration().set(cooldownType.getFriendlyName() + ".Cooldown", null);
}
it.remove();
break;
@ -198,13 +198,12 @@ public class CooldownManager {
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
if (cooldownType == CooldownType.BIOME || cooldownType == CooldownType.CREATION || cooldownType == CooldownType.DELETION) {
this.plugin.getFileManager()
.getConfig(new File(new File(this.plugin.getDataFolder().toString() + "/player-data"),
player.getUniqueId().toString() + ".yml"))
.getConfig(new File(new File(this.plugin.getDataFolder() + "/player-data"), player.getUniqueId() + ".yml"))
.getFileConfiguration().set("Island." + cooldownType + ".Cooldown", cooldownPlayerList.getCooldown().getTime());
} else if (cooldownType == CooldownType.LEVELLING || cooldownType == CooldownType.OWNERSHIP) {
this.plugin.getFileManager()
.getConfig(new File(new File(this.plugin.getDataFolder(), "island-data"), player.getUniqueId() + ".yml"))
.getFileConfiguration().set(cooldownType.name() + ".Cooldown", cooldownPlayerList.getCooldown().getTime());
.getFileConfiguration().set(cooldownType.getFriendlyName() + ".Cooldown", cooldownPlayerList.getCooldown().getTime());
}
break;
}

View File

@ -5,13 +5,23 @@ import java.util.EnumSet;
import java.util.Set;
public enum CooldownType {
BIOME,
CREATION,
DELETION,
PREVIEW,
LEVELLING,
OWNERSHIP,
TELEPORT;
BIOME("Biome"),
CREATION("Creation"),
DELETION("Deletion"),
PREVIEW("Preview"),
LEVELLING("Levelling"),
OWNERSHIP("Ownership"),
TELEPORT("Teleport");
private final String friendlyName;
CooldownType(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
private static final Set<CooldownType> TYPES = Collections.unmodifiableSet(EnumSet.allOf(CooldownType.class));

View File

@ -60,7 +60,7 @@ public class GeneratorManager {
}
this.generatorStorage.add(new Generator(configLoad.getString("Generators." + generatorList + ".Name"),
IslandWorld.valueOf(configLoad.getString("Generators." + generatorList + ".World", "Normal")),
IslandWorld.valueOf(configLoad.getString("Generators." + generatorList + ".World", "Normal").toUpperCase()),
icon, generatorMaterials,
configLoad.getLong("Generators." + generatorList + ".UnlockLevel", 0L),
configLoad.getBoolean("Generators." + generatorList + ".Permission")));

View File

@ -37,7 +37,7 @@ public class GuiAdminPermissions extends Gui {
this.configLoad = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
this.settingsConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "settings.yml"));
this.settingsConfigLoad = this.settingsConfig.getFileConfiguration();
setTitle(TextUtils.formatText(this.configLoad.getString("Menu.Settings." + role.name() + ".Title")));
setTitle(TextUtils.formatText(this.configLoad.getString("Menu.Settings." + role.getFriendlyName() + ".Title")));
setDefaultItem(null);
paint();
}
@ -95,7 +95,7 @@ public class GuiAdminPermissions extends Gui {
continue;
}
final String path = "Settings." + this.role.name() + "." + permission.getName();
final String path = "Settings." + this.role.getFriendlyName() + "." + permission.getName();
boolean setting = this.settingsConfigLoad.getBoolean(path);
setButton(i, permission.getItem(setting, this.role), (event) -> {
this.settingsConfigLoad.set(path, !setting);

View File

@ -48,7 +48,7 @@ public class GuiPermissions extends Gui {
this.languageLoad = plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
this.configLoad = this.plugin.getConfiguration();
setTitle(TextUtils.formatText(this.languageLoad.getString("Menu.Settings." + role.name() + ".Title")));
setTitle(TextUtils.formatText(this.languageLoad.getString("Menu.Settings." + role.getFriendlyName() + ".Title")));
setDefaultItem(null);
paint();
}
@ -137,7 +137,7 @@ public class GuiPermissions extends Gui {
if (this.configLoad.getBoolean("Island.Settings.Permission")) {
permissions.removeIf(permission -> !this.player.hasPermission("fabledskyblock.settings." +
this.role.name().toLowerCase() + "." + permission.getName().toLowerCase()));
this.role.getFriendlyName().toLowerCase() + "." + permission.getName().toLowerCase()));
}
double itemCount = permissions.size();
@ -195,7 +195,7 @@ public class GuiPermissions extends Gui {
PermissionManager permissionManager = SkyBlock.getInstance().getPermissionManager();
if (role == IslandRole.VISITOR || role == IslandRole.MEMBER || role == IslandRole.COOP
|| role == IslandRole.OWNER) {
String roleName = role.name();
String roleName = role.getFriendlyName();
if (role == IslandRole.OWNER) {
roleName = "Island";

View File

@ -1,5 +1,17 @@
package com.craftaro.skyblock.hologram;
public enum HologramType {
LEVEL, BANK, VOTES
LEVEL("Level"),
BANK("Bank"),
VOTES("Votes");
private final String friendlyName;
HologramType(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
}

View File

@ -203,13 +203,13 @@ public class Island {
for (BasicPermission permission : allPermissions) {
if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration()
.getString("Settings." + roleList.name() + "." + permission.getName()) == null) {
.getString("Settings." + roleList.getFriendlyName() + "." + permission.getName()) == null) {
permissions.add(
new IslandPermission(permission, this.plugin.getSettings()
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
.getBoolean("Settings." + roleList.getFriendlyName() + "." + permission.getName(), true)));
} else {
permissions.add(new IslandPermission(permission, settingsDataConfig.getFileConfiguration()
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
.getBoolean("Settings." + roleList.getFriendlyName() + "." + permission.getName(), true)));
}
}
@ -261,7 +261,7 @@ public class Island {
for (BasicPermission permission : allPermissions) {
permissions.add(
new IslandPermission(permission, this.plugin.getSettings()
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
.getBoolean("Settings." + roleList.getFriendlyName() + "." + permission.getName(), true)));
}
this.islandPermissions.put(roleList, permissions);
@ -419,15 +419,15 @@ public class Island {
if (environment == IslandEnvironment.ISLAND) {
fileManager.setLocation(
fileManager
.getConfig(new File(new File(this.plugin.getDataFolder().toString() + "/island-data"),
.getConfig(new File(new File(this.plugin.getDataFolder() + "/island-data"),
getOwnerUUID().toString() + ".yml")),
"Location." + world.name() + "." + environment.name(), location, true);
"Location." + world.getFriendlyName() + "." + environment.getFriendlyName(), location, true);
} else {
fileManager.setLocation(
fileManager
.getConfig(new File(new File(this.plugin.getDataFolder().toString() + "/island-data"),
.getConfig(new File(new File(this.plugin.getDataFolder() + "/island-data"),
getOwnerUUID().toString() + ".yml")),
"Location." + world.name() + ".Spawn." + environment.name(), location, true);
"Location." + world.getFriendlyName() + ".Spawn." + environment.getFriendlyName(), location, true);
}
islandLocationList.setLocation(location);
@ -606,8 +606,8 @@ public class Island {
new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString(role.name() + "s") != null) {
for (String playerList : configLoad.getStringList(role.name() + "s")) {
if (configLoad.getString(role.getFriendlyName() + "s") != null) {
for (String playerList : configLoad.getStringList(role.getFriendlyName() + "s")) {
islandRoles.add(FastUUID.parseUUID(playerList));
}
}
@ -654,14 +654,14 @@ public class Island {
List<String> islandMembers;
if (configLoad.getString(role.name() + "s") == null) {
if (configLoad.getString(role.getFriendlyName() + "s") == null) {
islandMembers = new ArrayList<>();
} else {
islandMembers = configLoad.getStringList(role.name() + "s");
islandMembers = configLoad.getStringList(role.getFriendlyName() + "s");
}
islandMembers.add(FastUUID.toString(uuid));
configLoad.set(role.name() + "s", islandMembers);
configLoad.set(role.getFriendlyName() + "s", islandMembers);
try {
configLoad.save(configFile);
@ -684,10 +684,10 @@ public class Island {
Config config = this.plugin.getFileManager().getConfig(new File(new File(this.plugin.getDataFolder(), "island-data"), getOwnerUUID().toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
List<String> islandMembers = configLoad.getStringList(role.name() + "s");
List<String> islandMembers = configLoad.getStringList(role.getFriendlyName() + "s");
islandMembers.remove(FastUUID.toString(uuid));
configLoad.set(role.name() + "s", islandMembers);
configLoad.set(role.getFriendlyName() + "s", islandMembers);
try {
configLoad.save(configFile);
@ -713,7 +713,7 @@ public class Island {
public void setUpgrade(Player player, Upgrade.Type type, boolean status) {
this.plugin.getFileManager().getConfig(
new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Upgrade." + type.name(), status);
.getFileConfiguration().set("Upgrade." + type.getFriendlyName(), status);
Bukkit.getServer().getPluginManager()
.callEvent(new IslandUpgradeEvent(getAPIWrapper(), player, APIUtil.fromImplementation(type)));
@ -722,19 +722,19 @@ public class Island {
public void removeUpgrade(Upgrade.Type type) {
this.plugin.getFileManager().getConfig(
new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Upgrade." + type.name(), null);
.getFileConfiguration().set("Upgrade." + type.getFriendlyName(), null);
}
public boolean hasUpgrade(Upgrade.Type type) {
return this.plugin.getFileManager().getConfig(
new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Upgrade." + type.name()) != null;
.getFileConfiguration().getString("Upgrade." + type.getFriendlyName()) != null;
}
public boolean isUpgrade(Upgrade.Type type) {
return this.plugin.getFileManager().getConfig(
new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"))
.getFileConfiguration().getBoolean("Upgrade." + type.name());
.getFileConfiguration().getBoolean("Upgrade." + type.getFriendlyName());
}
public boolean hasPermission(IslandRole role, BasicPermission permission) {
@ -821,8 +821,8 @@ public class Island {
new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Visitor." + message.name() + ".Message") != null) {
islandMessage = configLoad.getStringList("Visitor." + message.name() + ".Message");
if (configLoad.getString("Visitor." + message.getFriendlyName() + ".Message") != null) {
islandMessage = configLoad.getStringList("Visitor." + message.getFriendlyName() + ".Message");
}
return islandMessage;
@ -833,8 +833,8 @@ public class Island {
new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Visitor." + message.name() + ".Author") != null) {
return configLoad.getString("Visitor." + message.name() + ".Author");
if (configLoad.getString("Visitor." + message.getFriendlyName() + ".Author") != null) {
return configLoad.getString("Visitor." + message.getFriendlyName() + ".Author");
}
return "";
}
@ -848,8 +848,8 @@ public class Island {
Config config = this.plugin.getFileManager().getConfig(
new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Visitor." + message.name() + ".Message", islandMessageChangeEvent.getLines());
configLoad.set("Visitor." + message.name() + ".Author", islandMessageChangeEvent.getAuthor());
configLoad.set("Visitor." + message.getFriendlyName() + ".Message", islandMessageChangeEvent.getLines());
configLoad.set("Visitor." + message.getFriendlyName() + ".Author", islandMessageChangeEvent.getAuthor());
if (message == IslandMessage.SIGNATURE) {
getVisit().setSignature(lines);
@ -962,19 +962,19 @@ public class Island {
Config islandData = fileManager
.getConfig(new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"));
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
double price = configLoad.getDouble("Island.World." + type.name() + ".UnlockPrice");
double price = configLoad.getDouble("Island.World." + type.getFriendlyName() + ".UnlockPrice");
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type.name());
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type.getFriendlyName());
if (price == -1) {
configLoadIslandData.set("Unlocked." + type.name(), true);
configLoadIslandData.set("Unlocked." + type.getFriendlyName(), true);
unlocked = true;
}
if (!unlocked && player != null) {
messageManager.sendMessage(player,
this.plugin.getLanguage()
.getString("Island.Unlock." + type.name() + ".Message").replace(
"%cost%", NumberUtils.formatNumber(price)));
.getString("Island.Unlock." + type.getFriendlyName() + ".Message")
.replace("%cost%", NumberUtils.formatNumber(price)));
soundManager.playSound(player, XSound.BLOCK_ANVIL_LAND);
if (type == IslandWorld.END) {

View File

@ -1,5 +1,17 @@
package com.craftaro.skyblock.island;
public enum IslandEnvironment {
ISLAND, VISITOR, MAIN
ISLAND("Island"),
VISITOR("Visitor"),
MAIN("Main");
private final String friendlyName;
IslandEnvironment(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
}

View File

@ -94,7 +94,7 @@ public class IslandManager {
this.offset = plugin.getConfiguration().getInt("Island.Creation.Distance", 1200);
for (IslandWorld worldList : IslandWorld.values()) {
ConfigurationSection configSection = configLoad.getConfigurationSection("World." + worldList.name() + ".nextAvailableLocation");
ConfigurationSection configSection = configLoad.getConfigurationSection("World." + worldList.getFriendlyName() + ".nextAvailableLocation");
this.islandPositions.add(new IslandPosition(worldList, configSection.getDouble("x"), configSection.getDouble("z")));
}
@ -124,8 +124,8 @@ public class IslandManager {
FileConfiguration configLoad = config.getFileConfiguration();
for (IslandPosition islandPositionList : this.islandPositions) {
if (islandPositionList.getWorld() == world) {
int island_number = (int) configLoad.get("World." + world.name() + ".nextAvailableLocation.island_number");
ConfigurationSection configSection = configLoad.createSection("World." + world.name() + ".nextAvailableLocation");
int island_number = (int) configLoad.get("World." + world.getFriendlyName() + ".nextAvailableLocation.island_number");
ConfigurationSection configSection = configLoad.createSection("World." + world.getFriendlyName() + ".nextAvailableLocation");
configSection.set("x", islandPositionList.getX());
configSection.set("z", islandPositionList.getZ());
configSection.set("island_number", (island_number + 1));
@ -156,8 +156,8 @@ public class IslandManager {
FileConfiguration configLoad_world = config_world.getFileConfiguration();
FileConfiguration configLoad_config = this.plugin.getConfiguration();
int x = (int) configLoad_world.get("World." + world.name() + ".nextAvailableLocation.island_number");
int islandHeight = configLoad_config.getInt("Island.World." + world.name() + ".IslandSpawnHeight", 72);
int x = (int) configLoad_world.get("World." + world.getFriendlyName() + ".nextAvailableLocation.island_number");
int islandHeight = configLoad_config.getInt("Island.World." + world.getFriendlyName() + ".IslandSpawnHeight", 72);
while (true) {
double r = Math.floor((Math.sqrt(x + 1) - 1) / 2) + 1;
double p = (8 * r * (r - 1)) / 2;
@ -1037,7 +1037,7 @@ public class IslandManager {
FileManager.Config config = fileManager.getConfig(new File(this.plugin.getDataFolder().toString() + "/island-data", island.getOwnerUUID() + ".yml"));
if (config.getFileConfiguration().getString("Location." + world.name()) == null) {
if (config.getFileConfiguration().getString("Location." + world.getFriendlyName()) == null) {
pasteStructure(island, world);
return;
}
@ -1046,9 +1046,9 @@ public class IslandManager {
org.bukkit.Location location;
if (environmentList == IslandEnvironment.ISLAND) {
location = fileManager.getLocation(config, "Location." + world.name() + "." + environmentList.name(), true);
location = fileManager.getLocation(config, "Location." + world.getFriendlyName() + "." + environmentList.getFriendlyName(), true);
} else {
location = fileManager.getLocation(config, "Location." + world.name() + ".Spawn." + environmentList.name(), true);
location = fileManager.getLocation(config, "Location." + world.getFriendlyName() + ".Spawn." + environmentList.getFriendlyName(), true);
}
island.addLocation(world, environmentList, worldManager.getLocation(location, world));
@ -1088,10 +1088,10 @@ public class IslandManager {
for (IslandEnvironment environmentList : IslandEnvironment.values()) {
if (environmentList == IslandEnvironment.ISLAND) {
island.addLocation(world, environmentList, islandLocation);
fileManager.setLocation(config, "Location." + world.name() + "." + environmentList.name(), islandLocation, true);
fileManager.setLocation(config, "Location." + world.getFriendlyName() + "." + environmentList.getFriendlyName(), islandLocation, true);
} else {
island.addLocation(world, environmentList, islandLocation.clone().add(0.5D, 0.0D, 0.5D));
fileManager.setLocation(config, "Location." + world.name() + ".Spawn." + environmentList.name(), islandLocation.clone().add(0.5D, 0.0D, 0.5D), true);
fileManager.setLocation(config, "Location." + world.getFriendlyName() + ".Spawn." + environmentList.getFriendlyName(), islandLocation.clone().add(0.5D, 0.0D, 0.5D), true);
}
}
@ -1147,7 +1147,7 @@ public class IslandManager {
FileManager.Config islandData = fileManager.getConfig(new File(new File(this.plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml"));
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
configLoadIslandData.set("Unlocked." + islandWorld.name(), true);
configLoadIslandData.set("Unlocked." + islandWorld.getFriendlyName(), true);
pasteStructure(island, islandWorld);
@ -1172,11 +1172,11 @@ public class IslandManager {
FileManager fileManager = this.plugin.getFileManager();
FileManager.Config islandData = fileManager.getConfig(new File(new File(this.plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml"));
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + islandWorld.name());
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + islandWorld.getFriendlyName());
if (!unlocked) {
FileConfiguration configLoad = this.plugin.getConfiguration();
double price = configLoad.getDouble("Island.World." + islandWorld.name() + ".UnlockPrice");
double price = configLoad.getDouble("Island.World." + islandWorld.getFriendlyName() + ".UnlockPrice");
if (price == -1) {
unlocked = true;
}

View File

@ -1,5 +1,17 @@
package com.craftaro.skyblock.island;
public enum IslandMessage {
WELCOME, SIGNATURE, SIGN
WELCOME("Welcome"),
SIGNATURE("Signature"),
SIGN("Sign");
private final String friendlyName;
IslandMessage(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
}

View File

@ -5,11 +5,21 @@ import java.util.EnumSet;
import java.util.Set;
public enum IslandRole {
COOP,
VISITOR,
MEMBER,
OPERATOR,
OWNER;
COOP("Coop"),
VISITOR("Visitor"),
MEMBER("Member"),
OPERATOR("Operator"),
OWNER("Owner");
private final String friendlyName;
IslandRole(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
private static final Set<IslandRole> ROLES = Collections.unmodifiableSet(EnumSet.allOf(IslandRole.class));

View File

@ -8,7 +8,17 @@ import java.util.ArrayList;
import java.util.List;
public enum IslandWorld {
NORMAL, NETHER, END;
NORMAL("Normal"), NETHER("Nether"), END("End");
private final String friendlyName;
IslandWorld(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
public static List<IslandWorld> getIslandWorlds() {
List<IslandWorld> islandWorlds = new ArrayList<>(3);

View File

@ -65,10 +65,10 @@ public class MoveListeners implements Listener {
IslandWorld world = worldManager.getIslandWorld(player.getWorld());
if (world == IslandWorld.NETHER || world == IslandWorld.END) {
if (!this.plugin.getConfiguration().getBoolean("Island.World." + world.name() + ".Enable")) {
if (!this.plugin.getConfiguration().getBoolean("Island.World." + world.getFriendlyName() + ".Enable")) {
FileConfiguration configLoad = this.plugin.getLanguage();
messageManager.sendMessage(player, configLoad.getString("Island.World.Message").replace(configLoad.getString("Island.World.Word." + world.name()), world.name()));
messageManager.sendMessage(player, configLoad.getString("Island.World.Message").replace(configLoad.getString("Island.World.Word." + world.getFriendlyName()), world.getFriendlyName()));
if (playerDataManager.hasPlayerData(player)) {
PlayerData playerData = playerDataManager.getPlayerData(player);
@ -107,8 +107,8 @@ public class MoveListeners implements Listener {
keepItemsOnDeath = configLoad.getBoolean("Island.KeepItemsOnDeath.Enable");
}
if (configLoad.getBoolean("Island.World." + world.name() + ".Liquid.Enable")) {
if (to.getY() <= configLoad.getInt("Island.World." + world.name() + ".Liquid.Height")) {
if (configLoad.getBoolean("Island.World." + world.getFriendlyName() + ".Liquid.Enable")) {
if (to.getY() <= configLoad.getInt("Island.World." + world.getFriendlyName() + ".Liquid.Height")) {
if (keepItemsOnDeath && configLoad.getBoolean("Island.Liquid.Teleport.Enable")) {
player.setFallDistance(0.0F);
teleportPlayerToIslandSpawn(player, soundManager, island);

View File

@ -139,7 +139,7 @@ public class PortalListeners implements Listener {
switch (toWorld) {
case END:
case NETHER:
if (configLoad.getBoolean("Island.World." + toWorld.name() + ".Enable") && island.isRegionUnlocked(player, toWorld)) {
if (configLoad.getBoolean("Island.World." + toWorld.getFriendlyName() + ".Enable") && island.isRegionUnlocked(player, toWorld)) {
teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld);
}
break;

View File

@ -1,6 +1,7 @@
package com.craftaro.skyblock.localization;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
import com.craftaro.skyblock.island.IslandRole;
import com.craftaro.skyblock.localization.type.Localization;
@ -20,7 +21,7 @@ public final class LocalizationManager {
public LocalizationManager() {
this.map = new HashMap<>();
registerLocalizationFor(CompatibleMaterial.class, new MaterialsLocalization("Materials"));
registerLocalizationFor(XMaterial.class, new MaterialsLocalization("Materials"));
registerLocalizationFor(IslandRole.class, new EnumLocalization<>("IslandRoles", IslandRole.class));
}

View File

@ -37,6 +37,6 @@ public class EnumLocalization<T extends Enum<T>> extends Localization<T> {
}
protected T parseEnum(String input) {
return Enum.valueOf(getType(), input);
return Enum.valueOf(getType(), input.toUpperCase());
}
}

View File

@ -65,7 +65,7 @@ public class Leaderboard {
if ((XMaterial.OAK_FENCE_GATE.isSimilar(is)) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
.equals(plugin.formatText(configLoad.getString("Menu.Leaderboard." + Viewer.Type.BROWSE.name()
.equals(plugin.formatText(configLoad.getString("Menu.Leaderboard." + Viewer.Type.BROWSE.getFriendlyName()
+ ".Item.Exit.Displayname"))))) {
soundManager.playSound(player, XSound.BLOCK_CHEST_CLOSE);
@ -74,25 +74,25 @@ public class Leaderboard {
&& (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad
.getString("Menu.Leaderboard." + Viewer.Type.BROWSE.name()
.getString("Menu.Leaderboard." + Viewer.Type.BROWSE.getFriendlyName()
+ ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.LEVEL.name()))))) {
.replace("%leaderboard", Viewer.Type.LEVEL.getFriendlyName()))))) {
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.LEVEL));
} else if ((is.getType() == Material.GOLD_INGOT) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad
.getString("Menu.Leaderboard." + Viewer.Type.BROWSE.name()
.getString("Menu.Leaderboard." + Viewer.Type.BROWSE.getFriendlyName()
+ ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.BANK.name()))))) {
.replace("%leaderboard", Viewer.Type.BANK.getFriendlyName()))))) {
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.BANK));
} else if ((is.getType() == Material.EMERALD) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad
.getString("Menu.Leaderboard." + Viewer.Type.BROWSE.name()
.getString("Menu.Leaderboard." + Viewer.Type.BROWSE.getFriendlyName()
+ ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.VOTES.name()))))) {
.replace("%leaderboard", Viewer.Type.VOTES.getFriendlyName()))))) {
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.VOTES));
}
@ -103,16 +103,16 @@ public class Leaderboard {
});
nInv.addItem(nInv.createItem(XMaterial.OAK_FENCE_GATE.parseItem(),
configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Item.Exit.Displayname"),
configLoad.getString("Menu.Leaderboard." + viewer.getType().getFriendlyName() + ".Item.Exit.Displayname"),
null, null, null, null), 0, 4);
nInv.addItem(
nInv.createItem(new ItemStack(Material.DIAMOND), configLoad
.getString(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.LEVEL.name()),
"Menu.Leaderboard." + viewer.getType().getFriendlyName() + ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.LEVEL.getFriendlyName()),
configLoad.getStringList(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"),
new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.LEVEL.name())}, null,
"Menu.Leaderboard." + viewer.getType().getFriendlyName() + ".Item.Leaderboard.Lore"),
new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.LEVEL.getFriendlyName())}, null,
null),
1);
@ -120,11 +120,11 @@ public class Leaderboard {
nInv.addItem(
nInv.createItem(new ItemStack(Material.GOLD_INGOT), configLoad
.getString(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.BANK.name()),
"Menu.Leaderboard." + viewer.getType().getFriendlyName() + ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.BANK.getFriendlyName()),
configLoad.getStringList(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"),
new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.BANK.name())}, null,
"Menu.Leaderboard." + viewer.getType().getFriendlyName() + ".Item.Leaderboard.Lore"),
new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.BANK.getFriendlyName())}, null,
null),
2);
} else {
@ -134,16 +134,16 @@ public class Leaderboard {
nInv.addItem(
nInv.createItem(new ItemStack(Material.EMERALD), configLoad
.getString(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.VOTES.name()),
"Menu.Leaderboard." + viewer.getType().getFriendlyName() + ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.VOTES.getFriendlyName()),
configLoad.getStringList(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"),
new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.VOTES.name())}, null,
"Menu.Leaderboard." + viewer.getType().getFriendlyName() + ".Item.Leaderboard.Lore"),
new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.VOTES.getFriendlyName())}, null,
null),
3);
nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Title")));
configLoad.getString("Menu.Leaderboard." + viewer.getType().getFriendlyName() + ".Title")));
nInv.setType(InventoryType.HOPPER);
} else {
@ -200,7 +200,7 @@ public class Leaderboard {
if (leaderboardPosition != -1) {
List<com.craftaro.skyblock.leaderboard.Leaderboard> leaderboardIslands = plugin
.getLeaderboardManager().getLeaderboard(
com.craftaro.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().name()));
com.craftaro.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().getFriendlyName()));
if (leaderboardIslands.size() > leaderboardPosition) {
com.craftaro.skyblock.leaderboard.Leaderboard leaderboard = leaderboardIslands.get(leaderboardPosition);
@ -236,7 +236,7 @@ public class Leaderboard {
List<com.craftaro.skyblock.leaderboard.Leaderboard> leaderboardIslands = plugin
.getLeaderboardManager().getLeaderboard(
com.craftaro.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().name()));
com.craftaro.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().getFriendlyName()));
for (com.craftaro.skyblock.leaderboard.Leaderboard leaderboard : leaderboardIslands) {
Visit visit = leaderboard.getVisit();
@ -287,7 +287,7 @@ public class Leaderboard {
List<String> itemLore = new ArrayList<>();
for (String itemLoreList : configLoad.getStringList(
"Menu.Leaderboard.Leaderboard.Item.Island." + viewer.getType().name() + ".Lore")) {
"Menu.Leaderboard.Leaderboard.Item.Island." + viewer.getType().getFriendlyName() + ".Lore")) {
if (itemLoreList.contains("%signature")) {
if (visit.getSignature() == null || visit.getSignature().isEmpty()) {
itemLore.add(
@ -339,7 +339,7 @@ public class Leaderboard {
}
nInv.setTitle(plugin.formatText(configLoad.getString("Menu.Leaderboard.Leaderboard.Title").replace("%leaderboard",
viewer.getType().name())));
viewer.getType().getFriendlyName())));
nInv.setRows(6);
}
@ -359,7 +359,20 @@ public class Leaderboard {
}
public enum Type {
BROWSE, LEVEL, BANK, VOTES
BROWSE("Browse"),
LEVEL("Level"),
BANK("Bank"),
VOTES("Votes");
private final String friendlyName;
Type(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
}
}
}

View File

@ -328,7 +328,7 @@ public class Members {
nInv.addItem(nInv.createItem(new ItemStack(Material.HOPPER),
configLoad.getString("Menu.Members.Item.Type.Displayname"),
configLoad.getStringList("Menu.Members.Item.Type.Lore"),
new Placeholder[]{new Placeholder("%type", type.name())}, null, null), 3);
new Placeholder[]{new Placeholder("%type", type.getFriendlyName())}, null, null), 3);
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING),
configLoad.getString("Menu.Members.Item.Statistics.Displayname"),
configLoad.getStringList("Menu.Members.Item.Statistics.Lore"),
@ -343,7 +343,7 @@ public class Members {
nInv.addItem(nInv.createItem(new ItemStack(Material.HOPPER),
configLoad.getString("Menu.Members.Item.Sort.Displayname"),
configLoad.getStringList("Menu.Members.Item.Sort.Lore"),
new Placeholder[]{new Placeholder("%sort", StringUtil.capitalizeUppercaseLetters(sort.name()))},
new Placeholder[]{new Placeholder("%sort", StringUtil.capitalizeUppercaseLetters(sort.getFriendlyName()))},
null, null), 5);
nInv.addItem(
nInv.createItem(XMaterial.BLACK_STAINED_GLASS_PANE.parseItem(),
@ -585,10 +585,36 @@ public class Members {
}
public enum Type {
DEFAULT, MEMBERS, OPERATORS, OWNER
DEFAULT("Default"),
MEMBERS("Members"),
OPERATORS("Operators"),
OWNER("Owner");
private final String friendlyName;
Type(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
}
public enum Sort {
DEFAULT, PLAYTIME, MEMBER_SINCE, LAST_ONLINE
DEFAULT("Default"),
PLAYTIME("Playtime"),
MEMBER_SINCE("MemberSince"),
LAST_ONLINE("LastOnline");
private final String friendlyName;
Sort(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
}
}

View File

@ -241,7 +241,7 @@ public class Settings {
return;
} else if (island14.hasRole(IslandRole.OPERATOR, player.getUniqueId())
&& !permissionManager.hasPermission(island14, role.name(), IslandRole.OPERATOR)) {
&& !permissionManager.hasPermission(island14, role.getFriendlyName(), IslandRole.OPERATOR)) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
soundManager.playSound(player, XSound.BLOCK_ANVIL_LAND);
@ -262,7 +262,7 @@ public class Settings {
if ((XMaterial.OAK_FENCE_GATE.isSimilar(is)) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
.equals(plugin.formatText(configLoad.getString("Menu.Settings." + role.name() + ".Item.Return.Displayname"))))) {
.equals(plugin.formatText(configLoad.getString("Menu.Settings." + role.getFriendlyName() + ".Item.Return.Displayname"))))) {
soundManager.playSound(player, XSound.ENTITY_ARROW_HIT);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.CATEGORIES, null, null), 1L);
@ -473,7 +473,7 @@ public class Settings {
nInv.addItemStack(createItem(island, role, "ExperienceOrbPickup", XMaterial.EXPERIENCE_BOTTLE.parseItem()), 53);
nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Settings." + role.name() + ".Title")));
configLoad.getString("Menu.Settings." + role.getFriendlyName() + ".Title")));
nInv.setRows(6);
} else if (role == IslandRole.OPERATOR) {
if (mainConfig.getBoolean("Island.Visitor.Banning")) {
@ -683,7 +683,7 @@ public class Settings {
}
nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Settings." + role.name() + ".Title")));
configLoad.getString("Menu.Settings." + role.getFriendlyName() + ".Title")));
} else if (role == IslandRole.OWNER) {
if (mainConfig.getBoolean("Island.Settings.PvP.Enable")) {
if (mainConfig.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
@ -1012,12 +1012,12 @@ public class Settings {
}
nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Settings." + role.name() + ".Title")));
configLoad.getString("Menu.Settings." + role.getFriendlyName() + ".Title")));
nInv.setRows(2);
}
nInv.addItem(nInv.createItem(XMaterial.OAK_FENCE_GATE.parseItem(),
configLoad.getString("Menu.Settings." + role.name() + ".Item.Return.Displayname"), null, null,
configLoad.getString("Menu.Settings." + role.getFriendlyName() + ".Item.Return.Displayname"), null, null,
null, null), 0, 8);
Bukkit.getServer().getScheduler().runTask(plugin, nInv::open);
@ -1475,7 +1475,7 @@ public class Settings {
ItemMeta im = is.getItemMeta();
String roleName = role.name();
String roleName = role.getFriendlyName();
if (role == IslandRole.VISITOR || role == IslandRole.MEMBER || role == IslandRole.COOP) {
roleName = "Default";
@ -1508,14 +1508,14 @@ public class Settings {
return "Default";
}
return role.name();
return role.getFriendlyName();
}
private boolean hasPermission(Island island, Player player, IslandRole role) {
PermissionManager permissionManager = SkyBlock.getPlugin(SkyBlock.class).getPermissionManager();
if (role == IslandRole.VISITOR || role == IslandRole.MEMBER || role == IslandRole.COOP
|| role == IslandRole.OWNER) {
String roleName = role.name();
String roleName = role.getFriendlyName();
if (role == IslandRole.OWNER) {
roleName = "Island";

View File

@ -489,7 +489,7 @@ public class Upgrade {
ItemStack potion = new ItemStack(Material.POTION);
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.SPEED.name().toLowerCase())) {
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.SPEED.getFriendlyName().toLowerCase())) {
upgrades = upgradeManager.getUpgrades(com.craftaro.skyblock.upgrade.Upgrade.Type.SPEED);
if (upgrades != null && !upgrades.isEmpty() && upgrades.get(0).isEnabled()) {
@ -541,7 +541,7 @@ public class Upgrade {
}
}
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.JUMP.name().toLowerCase())) {
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.JUMP.getFriendlyName().toLowerCase())) {
upgrades = upgradeManager.getUpgrades(com.craftaro.skyblock.upgrade.Upgrade.Type.JUMP);
if (upgrades != null && !upgrades.isEmpty() && upgrades.get(0).isEnabled()) {
@ -594,7 +594,7 @@ public class Upgrade {
}
}
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.CROP.name().toLowerCase())) {
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.CROP.getFriendlyName().toLowerCase())) {
upgrades = upgradeManager.getUpgrades(com.craftaro.skyblock.upgrade.Upgrade.Type.CROP);
if (upgrades != null && !upgrades.isEmpty() && upgrades.get(0).isEnabled()) {
@ -632,7 +632,7 @@ public class Upgrade {
}
}
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.FLY.name().toLowerCase())) {
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.FLY.getFriendlyName().toLowerCase())) {
upgrades = upgradeManager.getUpgrades(com.craftaro.skyblock.upgrade.Upgrade.Type.FLY);
if (upgrades != null && !upgrades.isEmpty() && upgrades.get(0).isEnabled()) {
@ -670,7 +670,7 @@ public class Upgrade {
}
}
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.DROPS.name().toLowerCase())) {
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.DROPS.getFriendlyName().toLowerCase())) {
upgrades = upgradeManager.getUpgrades(com.craftaro.skyblock.upgrade.Upgrade.Type.DROPS);
if (upgrades != null && !upgrades.isEmpty() && upgrades.get(0).isEnabled()) {
@ -708,7 +708,7 @@ public class Upgrade {
}
}
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.MEMBERS.name().toLowerCase())) {
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.MEMBERS.getFriendlyName().toLowerCase())) {
upgrades = upgradeManager.getUpgrades(com.craftaro.skyblock.upgrade.Upgrade.Type.MEMBERS);
if (upgrades != null && !upgrades.isEmpty()) {
@ -770,7 +770,7 @@ public class Upgrade {
}
}
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.SIZE.name().toLowerCase())) {
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.SIZE.getFriendlyName().toLowerCase())) {
upgrades = upgradeManager.getUpgrades(com.craftaro.skyblock.upgrade.Upgrade.Type.SIZE);
if (upgrades != null && !upgrades.isEmpty()) {
@ -832,7 +832,7 @@ public class Upgrade {
}
}
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.SPAWNER.name().toLowerCase())) {
if (player.hasPermission("fabledskyblock.upgrade." + com.craftaro.skyblock.upgrade.Upgrade.Type.SPAWNER.getFriendlyName().toLowerCase())) {
upgrades = upgradeManager.getUpgrades(com.craftaro.skyblock.upgrade.Upgrade.Type.SPAWNER);
if (upgrades != null && !upgrades.isEmpty() && upgrades.get(0).isEnabled()) {

View File

@ -331,7 +331,7 @@ public class Visit {
nInv.addItem(nInv.createItem(new ItemStack(Material.HOPPER),
configLoad.getString("Menu.Visit.Item.Type.Displayname"),
configLoad.getStringList("Menu.Visit.Item.Type.Lore"),
new Placeholder[]{new Placeholder("%type", StringUtil.capitalizeUppercaseLetters(type.name()))},
new Placeholder[]{new Placeholder("%type", StringUtil.capitalizeUppercaseLetters(type.getFriendlyName()))},
null, null), 3);
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING),
configLoad.getString("Menu.Visit.Item.Statistics.Displayname"),
@ -345,7 +345,7 @@ public class Visit {
nInv.addItem(nInv.createItem(new ItemStack(Material.HOPPER),
configLoad.getString("Menu.Visit.Item.Sort.Displayname"),
configLoad.getStringList("Menu.Visit.Item.Sort.Lore"),
new Placeholder[]{new Placeholder("%sort", StringUtil.capitalizeUppercaseLetters(sort.name()))},
new Placeholder[]{new Placeholder("%sort", StringUtil.capitalizeUppercaseLetters(sort.getFriendlyName()))},
null, null), 5);
nInv.addItem(
nInv.createItem(XMaterial.BLACK_STAINED_GLASS_PANE.parseItem(),
@ -527,10 +527,37 @@ public class Visit {
}
public enum Type {
DEFAULT, SOLO, TEAM
DEFAULT("Default"),
SOLO("Solo"),
TEAM("Team");
private final String friendlyName;
Type(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
}
public enum Sort {
DEFAULT, PLAYERS, LEVEL, MEMBERS, VISITS, VOTES
DEFAULT("Default"),
PLAYERS("Players"),
LEVEL("Level"),
MEMBERS("Members"),
VISITS("Visits"),
VOTES("Votes");
private final String friendlyName;
Sort(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
}
}

View File

@ -144,14 +144,10 @@ public class Upgrade {
boolean enabled = upgrade.isEnabled();
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
() -> {
Config config = fileManager.getConfig(new File(
plugin.getDataFolder(), "upgrades.yml"));
FileConfiguration configLoad1 = config
.getFileConfiguration();
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "upgrades.yml"));
FileConfiguration configLoad1 = config.getFileConfiguration();
configLoad1.set(
"Upgrades." + upgradeType.name() + ".Enable",
enabled);
configLoad1.set("Upgrades." + upgradeType.getFriendlyName() + ".Enable", enabled);
try {
configLoad1.save(config.getFile());
@ -207,7 +203,7 @@ public class Upgrade {
.getFileConfiguration();
configLoad1.set(
"Upgrades." + upgradeType.name() + ".Cost",
"Upgrades." + upgradeType.getFriendlyName() + ".Cost",
upgradeCost);
try {

View File

@ -37,7 +37,7 @@ public abstract class BasicPermission {
ItemMeta im = is.getItemMeta();
String roleName = role.name();
String roleName = role.getFriendlyName();
if (role == IslandRole.VISITOR || role == IslandRole.MEMBER || role == IslandRole.COOP) {
roleName = "Default";

View File

@ -100,7 +100,7 @@ public class HologramTask extends BukkitRunnable {
}
hologramLines.add(TextUtils.formatText(
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Header")));
languageConfigLoad.getString("Hologram.Leaderboard." + type.getFriendlyName() + ".Header")));
for (int i = 0; i < 10; i++) {
Leaderboard leaderboard = leaderboardManager.getLeaderboardFromPosition(leaderboardType, i);
@ -118,21 +118,21 @@ public class HologramTask extends BukkitRunnable {
if (type == HologramType.LEVEL) {
IslandLevel level = visit.getLevel();
hologramLines.add(TextUtils.formatText(
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
languageConfigLoad.getString("Hologram.Leaderboard." + type.getFriendlyName() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%level", NumberUtils.formatNumber(level.getLevel()))
.replace("%points", NumberUtils.formatNumber(level.getPoints()))));
} else if (type == HologramType.BANK) {
hologramLines.add(TextUtils.formatText(
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
languageConfigLoad.getString("Hologram.Leaderboard." + type.getFriendlyName() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%balance",
"" + NumberUtils.formatNumber(visit.getBankBalance()))));
} else if (type == HologramType.VOTES) {
hologramLines.add(TextUtils.formatText(
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
languageConfigLoad.getString("Hologram.Leaderboard." + type.getFriendlyName() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%votes",
@ -140,7 +140,7 @@ public class HologramTask extends BukkitRunnable {
}
}
String hologramFooter = languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Footer");
String hologramFooter = languageConfigLoad.getString("Hologram.Leaderboard." + type.getFriendlyName() + ".Footer");
if (!hologramFooter.isEmpty()) {
hologramLines.add(TextUtils.formatText(hologramFooter));

View File

@ -39,6 +39,23 @@ public class Upgrade {
}
public enum Type {
CROP, SPAWNER, FLY, DROPS, SIZE, SPEED, JUMP, MEMBERS
CROP("Crop"),
SPAWNER("Spawner"),
FLY("Fly"),
DROPS("Drops"),
SIZE("Size"),
SPEED("Speed"),
JUMP("Jump"),
MEMBERS("Members");
private final String friendlyName;
Type(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
}
}

View File

@ -32,8 +32,8 @@ public class UpgradeManager {
if (typeList != Upgrade.Type.SIZE && typeList != Upgrade.Type.MEMBERS) {
List<Upgrade> upgrades = new ArrayList<>();
Upgrade upgrade = new Upgrade(configLoad.getDouble("Upgrades." + typeList.name() + ".Cost"));
upgrade.setEnabled(configLoad.getBoolean("Upgrades." + typeList.name() + ".Enable"));
Upgrade upgrade = new Upgrade(configLoad.getDouble("Upgrades." + typeList.getFriendlyName() + ".Cost"));
upgrade.setEnabled(configLoad.getBoolean("Upgrades." + typeList.getFriendlyName() + ".Enable"));
upgrades.add(upgrade);
this.upgradeStorage.put(typeList, upgrades);

View File

@ -152,7 +152,7 @@ public class VisitManager {
LocationUtil.teleportPlayerToSpawn(targetPlayer);
messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit." + removal.name() + ".Message"));
messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit." + removal.getFriendlyName() + ".Message"));
soundManager.playSound(targetPlayer, XSound.ENTITY_ENDERMAN_TELEPORT);
}
}
@ -249,6 +249,18 @@ public class VisitManager {
}
public enum Removal {
UNLOADED, KICKED, DELETED
UNLOADED("Unloaded"),
KICKED("Kicked"),
DELETED("Deleted");
private final String friendlyName;
Removal(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getFriendlyName() {
return this.friendlyName;
}
}
}

View File

@ -62,7 +62,7 @@ public class VoidGenerator extends ChunkGenerator {
setChunkBiome2D(biome, biomeGrid);
}
ConfigurationSection section = worldSection.getConfigurationSection(this.islandWorld.name());
ConfigurationSection section = worldSection.getConfigurationSection(this.islandWorld.getFriendlyName());
if (section.getBoolean("Liquid.Enable")) {
if (section.getBoolean("Liquid.Lava")) {