Skip to content

Commit

Permalink
Finalize the initial changes to change configuration structure
Browse files Browse the repository at this point in the history
  • Loading branch information
IanTapply22 committed Jun 19, 2024
1 parent 54b9b11 commit 0d4ae26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/main/java/net/jeqo/bloons/commands/CommandForceEquip.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.jeqo.bloons.balloon.multipart.balloon.MultipartBalloon;
import net.jeqo.bloons.balloon.multipart.balloon.MultipartBalloonBuilder;
import net.jeqo.bloons.balloon.single.SingleBalloon;
import net.jeqo.bloons.balloon.single.SingleBalloonType;
import net.jeqo.bloons.commands.manager.Command;
import net.jeqo.bloons.commands.manager.types.CommandPermission;
import net.jeqo.bloons.configuration.ConfigConfiguration;
Expand Down Expand Up @@ -48,7 +49,7 @@ public boolean execute(CommandSender sender, String[] args) {
}

String balloonID = args[1];
if (!this.getPlugin().getConfig().contains(ConfigConfiguration.SINGLE_BALLOON_SECTION + balloonID) && !this.getPlugin().getConfig().contains(ConfigConfiguration.MULTIPART_BALLOON_SECTION + balloonID)) {
if (!Bloons.getBalloonCore().containsSingleBalloon(balloonID) && !Bloons.getBalloonCore().containsMultipartBalloon(balloonID)) {
Component balloonNotFoundMessage = messageTranslations.getSerializedString(messageTranslations.getMessage("prefix"), messageTranslations.getMessage("balloon-not-found"));
sender.sendMessage(balloonNotFoundMessage);
return false;
Expand Down Expand Up @@ -80,10 +81,10 @@ public boolean execute(CommandSender sender, String[] args) {

MultipartBalloonManagement.setPlayerBalloon(player.getUniqueId(), balloon);

String balloonName = messageTranslations.getString(ConfigConfiguration.MULTIPART_BALLOON_SECTION + balloonID + ".name");
Component equippedMessage = messageTranslations.getSerializedString(messageTranslations.getMessage("prefix"), messageTranslations.getMessage("equipped", balloonName));
Component equippedMessage = messageTranslations.getSerializedString(messageTranslations.getMessage("prefix"), messageTranslations.getMessage("equipped", type.getName()));
player.sendMessage(equippedMessage);
} else {
SingleBalloonType singleBalloonType = Bloons.getBalloonCore().getSingleBalloonByID(balloonID);

// Call the equip event and check if it's cancelled, if it is, don't spawn the balloon or do anything
SingleBalloonEquipEvent singleBalloonEquipEvent = new SingleBalloonEquipEvent(player, balloonID);
Expand All @@ -95,8 +96,7 @@ public boolean execute(CommandSender sender, String[] args) {
SingleBalloonManagement.removeBalloon(player, Bloons.getPlayerSingleBalloons().get(player.getUniqueId()));
SingleBalloon.checkBalloonRemovalOrAdd(player, balloonID);

String balloonName = messageTranslations.getString(ConfigConfiguration.SINGLE_BALLOON_SECTION + balloonID + ".name");
Component equippedMessage = messageTranslations.getSerializedString(messageTranslations.getMessage("prefix"), messageTranslations.getMessage("equipped", balloonName));
Component equippedMessage = messageTranslations.getSerializedString(messageTranslations.getMessage("prefix"), messageTranslations.getMessage("equipped", singleBalloonType.getName()));
player.sendMessage(equippedMessage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,19 @@ public static ArrayList<SingleBalloonType> getSingleBalloons() {
// For every file in the balloon configuration folder, if a configuration type is single, add it to an array list
for (File file : Objects.requireNonNull(new File(Bloons.getInstance().getDataFolder() + File.separator + BALLOON_CONFIGURATION_FOLDER).listFiles())) {
// For every section in the configuration file
for (String section : Objects.requireNonNull(Bloons.getInstance().getConfig().getConfigurationSection(file.getName())).getKeys(false)) {
for (String key : Objects.requireNonNull(Bloons.getInstance().getConfig().getConfigurationSection(file.getName())).getKeys(false)) {
// If the section is a single balloon type, add it to the array list
if (section.equals(BalloonConfiguration.SINGLE_BALLOON_TYPE_IDENTIFIER)) {
if (key.equals(BalloonConfiguration.SINGLE_BALLOON_TYPE_IDENTIFIER)) {
// Add the single balloon type to the array list
singleBalloons.add(new SingleBalloonType(
Bloons.getInstance().getConfig().getString(file.getName() + "." + section + ".id"),
Bloons.getInstance().getConfig().getString(file.getName() + "." + section + ".permission"),
Bloons.getInstance().getConfig().getString(file.getName() + "." + section + ".material"),
Bloons.getInstance().getConfig().getString(file.getName() + "." + section + ".color"),
Bloons.getInstance().getConfig().getInt(file.getName() + "." + section + ".customModelData"),
Bloons.getInstance().getConfig().getString(file.getName() + "." + section + ".name"),
Bloons.getInstance().getConfig().getStringList(file.getName() + "." + section + ".lore").toArray(new String[0])
key,
Bloons.getInstance().getConfig().getString(file.getName() + "." + key + ".id"),
Bloons.getInstance().getConfig().getString(file.getName() + "." + key + ".permission"),
Bloons.getInstance().getConfig().getString(file.getName() + "." + key + ".material"),
Bloons.getInstance().getConfig().getString(file.getName() + "." + key + ".color"),
Bloons.getInstance().getConfig().getInt(file.getName() + "." + key + ".customModelData"),
Bloons.getInstance().getConfig().getString(file.getName() + "." + key + ".name"),
Bloons.getInstance().getConfig().getStringList(file.getName() + "." + key + ".lore").toArray(new String[0])
));
}
}
Expand Down

0 comments on commit 0d4ae26

Please sign in to comment.