Allow expanding the island WorldBorderLevel
This commit is contained in:
parent
05926df76e
commit
333e8e9b8d
|
|
@ -26,6 +26,7 @@ public class CometSkyBlockPlugin extends JavaPlugin implements CometSkyBlockAPI
|
||||||
@Getter private ConfigurationContainer<MessageConfiguration> messagesConfiguration;
|
@Getter private ConfigurationContainer<MessageConfiguration> messagesConfiguration;
|
||||||
@Getter private ConfigurationContainer<ChallengesConfiguration> challengesConfiguration;
|
@Getter private ConfigurationContainer<ChallengesConfiguration> challengesConfiguration;
|
||||||
@Getter private ConfigurationContainer<CobblestoneGeneratorConfiguration> cobblestoneGeneratorConfiguration;
|
@Getter private ConfigurationContainer<CobblestoneGeneratorConfiguration> cobblestoneGeneratorConfiguration;
|
||||||
|
@Getter private ConfigurationContainer<WorldBorderConfiguration> worldBorderConfiguration;
|
||||||
|
|
||||||
@Getter private IslandManager islandManager;
|
@Getter private IslandManager islandManager;
|
||||||
@Getter private MasterWorldGenerator worldGenerator;
|
@Getter private MasterWorldGenerator worldGenerator;
|
||||||
|
|
@ -75,6 +76,7 @@ public class CometSkyBlockPlugin extends JavaPlugin implements CometSkyBlockAPI
|
||||||
messagesConfiguration = ConfigurationContainer.load(logger, path, MessageConfiguration.class, "messages");
|
messagesConfiguration = ConfigurationContainer.load(logger, path, MessageConfiguration.class, "messages");
|
||||||
challengesConfiguration = ConfigurationContainer.load(logger, path, ChallengesConfiguration.class, "challenges");
|
challengesConfiguration = ConfigurationContainer.load(logger, path, ChallengesConfiguration.class, "challenges");
|
||||||
cobblestoneGeneratorConfiguration = ConfigurationContainer.load(logger, path, CobblestoneGeneratorConfiguration.class, "coblestonegenerator");
|
cobblestoneGeneratorConfiguration = ConfigurationContainer.load(logger, path, CobblestoneGeneratorConfiguration.class, "coblestonegenerator");
|
||||||
|
worldBorderConfiguration = ConfigurationContainer.load(logger, path, WorldBorderConfiguration.class, "worldborder");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadCommands() {
|
public void loadCommands() {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,13 @@ public class MessageConfiguration implements Configuration {
|
||||||
String upgraded = "Your cobblestone generation is now level <level>.";
|
String upgraded = "Your cobblestone generation is now level <level>.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
@ConfigSerializable @Getter
|
||||||
|
public static class WorldBorder {
|
||||||
|
String requiredLevel = "You must reach islandlevel <islandlevel> before you can expand the worldborder.";
|
||||||
|
String upgraded = "You have expanded your worldborder by <range> blocks.";
|
||||||
|
}
|
||||||
|
|
||||||
Level level = new Level();
|
Level level = new Level();
|
||||||
@ConfigSerializable @Getter
|
@ConfigSerializable @Getter
|
||||||
public static class Level {
|
public static class Level {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.alttd.cometskyblock.configuration;
|
||||||
|
|
||||||
|
import com.alttd.cometskyblock.island.WorldBorderLevel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ConfigSerializable
|
||||||
|
@SuppressWarnings({"CanBeFinal", "FieldMayBeFinal"})
|
||||||
|
public class WorldBorderConfiguration implements Configuration {
|
||||||
|
|
||||||
|
private List<WorldBorderLevel> levels = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
@ -172,6 +172,15 @@ public class Island extends YamlConfiguration {
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int worldBorderLevel() {
|
||||||
|
return getInt("island.worldborder.level", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void worldBorderLevel(int level) {
|
||||||
|
set("island.worldborder.level", level);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
public void teleport(Player player) {
|
public void teleport(Player player) {
|
||||||
World islandWorld = CometSkyBlockPlugin.instance().worldGenerator().loadIslandWorld(worldName());
|
World islandWorld = CometSkyBlockPlugin.instance().worldGenerator().loadIslandWorld(worldName());
|
||||||
if (islandWorld == null) {
|
if (islandWorld == null) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.alttd.cometskyblock.island;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ConfigSerializable
|
||||||
|
public class WorldBorderLevel {
|
||||||
|
|
||||||
|
private int level;
|
||||||
|
private int islandLevel;
|
||||||
|
private int range;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ import com.alttd.cometskyblock.configuration.MessageConfiguration;
|
||||||
import com.alttd.cometskyblock.gui.GUIInventory;
|
import com.alttd.cometskyblock.gui.GUIInventory;
|
||||||
import com.alttd.cometskyblock.island.CobblestoneGeneratorLevel;
|
import com.alttd.cometskyblock.island.CobblestoneGeneratorLevel;
|
||||||
import com.alttd.cometskyblock.island.Island;
|
import com.alttd.cometskyblock.island.Island;
|
||||||
|
import com.alttd.cometskyblock.island.WorldBorderLevel;
|
||||||
import com.alttd.cometskyblock.util.Experience;
|
import com.alttd.cometskyblock.util.Experience;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
|
@ -35,22 +36,34 @@ public class UpgradesGUI extends GUIInventory {
|
||||||
MessageConfiguration.Island islandMessages = CometSkyBlockPlugin.instance().messagesConfiguration().get().island();
|
MessageConfiguration.Island islandMessages = CometSkyBlockPlugin.instance().messagesConfiguration().get().island();
|
||||||
// Todo - move to handlers, add costs, validation ...
|
// Todo - move to handlers, add costs, validation ...
|
||||||
// WorldBorder
|
// WorldBorder
|
||||||
addButton(10, createMenuButton(Material.GRASS_BLOCK, "Expand The world border", new ArrayList<>(), event -> {
|
addButton(10, createMenuButton(Material.GRASS_BLOCK, "Expand the world border", new ArrayList<>(), event -> {
|
||||||
player.sendRichMessage("<red>This feature is not implemented yet - please wait for a future update.");
|
int requiredIslandLevel = getRequiredIslandWorldBorderLevel(island.worldBorderLevel() + 1);
|
||||||
// World islandWorld = CometSkyBlockPlugin.instance().worldGenerator().loadIslandWorld(island.worldName());
|
if (island.level() < requiredIslandLevel) {
|
||||||
// if (islandWorld == null) {
|
player.sendRichMessage(islandMessages.worldBorder().requiredLevel(), Placeholder.parsed("islandlevel", "<gold>" + requiredIslandLevel + "</gold>"));
|
||||||
// player.sendRichMessage("<red>Could not load islandWorld. Contact an administrator");
|
return;
|
||||||
// return;
|
}
|
||||||
// }
|
World islandWorld = CometSkyBlockPlugin.instance().worldGenerator().loadIslandWorld(island.worldName());
|
||||||
// WorldBorder worldBorder = islandWorld.getWorldBorder();
|
if (islandWorld == null) {
|
||||||
// worldBorder.setSize(worldBorder.getSize() + 250);
|
player.sendRichMessage("<red>Could not load islandWorld. Contact an administrator");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WorldBorder worldBorder = islandWorld.getWorldBorder();
|
||||||
|
island.worldBorderLevel(island.worldBorderLevel() + 1);
|
||||||
|
WorldBorderLevel worldBorderLevel = getWorldBorderLevel(island.worldBorderLevel());
|
||||||
|
if (worldBorderLevel == null) {
|
||||||
|
player.sendRichMessage("<red>You can not expand your world border.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
worldBorder.setSize(worldBorder.getSize() + worldBorderLevel.range());
|
||||||
|
player.sendRichMessage(islandMessages.worldBorder().upgraded(), Placeholder.parsed("range", "<gold>" + worldBorderLevel.range() + "</gold>"));
|
||||||
|
decorate(player);
|
||||||
}));
|
}));
|
||||||
// Cobble Gen
|
// Cobble Gen
|
||||||
addButton(11, createMenuButton(Material.COBBLESTONE, "Upgrade your cobble stone generator", List.of(
|
addButton(11, createMenuButton(Material.COBBLESTONE, "Upgrade your cobble stone generator", List.of(
|
||||||
"<white>Level: <gold>" + island.cobblegenLevel() + "</gold>",
|
"<white>Level: <gold>" + island.cobblegenLevel() + "</gold>",
|
||||||
"<white>Ore tier: <gold>" + getOreTier(island.cobblegenLevel()) + "</gold>"
|
"<white>Ore tier: <gold>" + getOreTier(island.cobblegenLevel()) + "</gold>"
|
||||||
), event -> {
|
), event -> {
|
||||||
int requiredIslandLevel = getRequiredIslandLevel(island.cobblegenLevel() + 1);
|
int requiredIslandLevel = getRequiredIslandCobbleLevel(island.cobblegenLevel() + 1);
|
||||||
if (island.level() < requiredIslandLevel) {
|
if (island.level() < requiredIslandLevel) {
|
||||||
player.sendRichMessage(islandMessages.cobbeGen().requiredLevel(), Placeholder.parsed("islandlevel", "<gold>" + requiredIslandLevel + "</gold>"));
|
player.sendRichMessage(islandMessages.cobbeGen().requiredLevel(), Placeholder.parsed("islandlevel", "<gold>" + requiredIslandLevel + "</gold>"));
|
||||||
return;
|
return;
|
||||||
|
|
@ -82,7 +95,7 @@ public class UpgradesGUI extends GUIInventory {
|
||||||
super.decorate(player);
|
super.decorate(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer getRequiredIslandLevel(int generatorLevel) {
|
Integer getRequiredIslandCobbleLevel(int generatorLevel) {
|
||||||
CobblestoneGeneratorLevel level = getLevel(generatorLevel);
|
CobblestoneGeneratorLevel level = getLevel(generatorLevel);
|
||||||
return level != null ? level.islandLevel() : 0;
|
return level != null ? level.islandLevel() : 0;
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +106,7 @@ public class UpgradesGUI extends GUIInventory {
|
||||||
}
|
}
|
||||||
CometSkyBlockPlugin plugin = CometSkyBlockPlugin.instance();
|
CometSkyBlockPlugin plugin = CometSkyBlockPlugin.instance();
|
||||||
if (plugin.cobblestoneGeneratorConfiguration().get().levels().size() < generatorLevel) {
|
if (plugin.cobblestoneGeneratorConfiguration().get().levels().size() < generatorLevel) {
|
||||||
return getLevel(generatorLevel - 1);
|
return null;
|
||||||
}
|
}
|
||||||
for (CobblestoneGeneratorLevel level : plugin.cobblestoneGeneratorConfiguration().get().levels()) {
|
for (CobblestoneGeneratorLevel level : plugin.cobblestoneGeneratorConfiguration().get().levels()) {
|
||||||
if (level.level() == generatorLevel) {
|
if (level.level() == generatorLevel) {
|
||||||
|
|
@ -107,4 +120,25 @@ public class UpgradesGUI extends GUIInventory {
|
||||||
CobblestoneGeneratorLevel level = getLevel(generatorLevel);
|
CobblestoneGeneratorLevel level = getLevel(generatorLevel);
|
||||||
return level != null ? level.type() : Material.COBBLESTONE;
|
return level != null ? level.type() : Material.COBBLESTONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer getRequiredIslandWorldBorderLevel(int generatorLevel) {
|
||||||
|
WorldBorderLevel level = getWorldBorderLevel(generatorLevel);
|
||||||
|
return level != null ? level.islandLevel() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldBorderLevel getWorldBorderLevel(int generatorLevel) {
|
||||||
|
if (generatorLevel == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
CometSkyBlockPlugin plugin = CometSkyBlockPlugin.instance();
|
||||||
|
if (plugin.worldBorderConfiguration().get().levels().size() < generatorLevel) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (WorldBorderLevel level : plugin.worldBorderConfiguration().get().levels()) {
|
||||||
|
if (level.level() == generatorLevel) {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user