Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration Sector Cleanup #46

Merged
merged 26 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2ce5314
Create example configurations for balloons
Jun 21, 2024
66c7b06
Remove multipart example config
Jun 21, 2024
0024b65
Merge branch 'main' into meg-implementation
Jun 23, 2024
55a53ce
Create a basic implementation of MEG
Jun 23, 2024
199eb36
Remove unused single balloon type vars
Jun 23, 2024
0665d74
Fix log of material not dyeable to only trigger on non-MEG balloons
Jun 23, 2024
4642438
Fix warning messages of config file already existing
Jun 23, 2024
8e21026
Implement idle animations
Jun 23, 2024
1d8fde3
Remove armor stand debug visibility
Jun 23, 2024
039f730
Mess around with MEG dummies
Jun 23, 2024
bc0775c
Revert changes of using dummies
Jun 23, 2024
63e9dcc
Created the configurations and the fetching of them
Jun 23, 2024
5e6b75b
Set default balloon height to be 2.0
Jun 23, 2024
70be6f4
Fully comment the single balloon type class
Jun 23, 2024
e6e377d
Rearranged the methods in SingleBalloon
Jun 23, 2024
62f926e
Move example balloons out of the method for copying example balloons
Jun 23, 2024
25356c4
Clean up basic code structure of the balloon directory
Jun 23, 2024
f4bb51c
Remove more unused code and commented more variables
Jun 23, 2024
d66d278
Rename variables to make more sense and renamed classes
Jun 23, 2024
2d77350
Made fields optional for a multipart balloon types
Jun 23, 2024
7589a80
Create more optional fields for multipart balloons
Jun 23, 2024
2ee7902
Update configuration files
Jun 23, 2024
df5bbb2
Fix color field not being optional for multipart balloon models
Jun 23, 2024
3fa64e8
Fix issues in regards to configurations
Jun 23, 2024
f8738c9
Fix wiki link being invalid in config.yml
Jun 24, 2024
c724147
Merge branch 'main' into configuration-sector-cleanup
Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 16 additions & 46 deletions src/main/java/net/jeqo/bloons/balloon/BalloonCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
@Setter @Getter
public class BalloonCore {
/**
* The plugin instance that runs the balloon core, type org.bukkit.plugin.java.JavaPlugin
*/
private JavaPlugin plugin;
/**
* Contains all valid and loaded multipart balloon types/configurations
Expand All @@ -25,18 +28,15 @@ public class BalloonCore {
* Contains all valid and loaded single balloon types/configurations
*/
public ArrayList<SingleBalloonType> singleBalloonTypes = new ArrayList<>();

/**
* Creates a new instance of the balloon core manager with preset registered balloons
* @param plugin The plugin instance, type org.bukkit.plugin.java.JavaPlugin
* @param balloons The balloons to register, type java.util.ArrayList[net.jeqo.bloons.balloon.multipart.MultipartBalloonType]
* @param singleBalloons The single balloons to register, type java.util.ArrayList[net.jeqo.bloons.balloon.single.SingleBalloonType]
* Contains all example balloon files to copy to the plugin's data folder
*/
public BalloonCore(JavaPlugin plugin, ArrayList<MultipartBalloonType> balloons, ArrayList<SingleBalloonType> singleBalloons) {
this.setPlugin(plugin);
this.setMultipartBalloonTypes(balloons);
this.setSingleBalloonTypes(singleBalloons);
}
private final String[] exampleBalloons = new String[] {
"color_pack_example.yml",
"dyeable_example.yml",
"meg_example.yml",
"multipart_example.yml"
};

/**
* Creates a new empty balloon core instance
Expand Down Expand Up @@ -74,50 +74,19 @@ public void copyExampleBalloons() {
};

// Save all example files in the balloons folder in /resources
for (String example : exampleBalloons) {
File file = new File(Bloons.getInstance().getDataFolder() + File.separator + ConfigConfiguration.BALLOON_CONFIGURATION_FOLDER + example);
for (String example : this.getExampleBalloons()) {
File file = new File(Bloons.getInstance().getDataFolder() + File.separator + ConfigConfiguration.BALLOON_CONFIGURATION_FOLDER + File.separator + example);
if (file.exists()) continue;

Bloons.getInstance().saveResource(ConfigConfiguration.BALLOON_CONFIGURATION_FOLDER + example, false);
}
}

/**
* Adds a balloon to the registered balloons list
* @param balloon The balloon to add, type net.jeqo.bloons.balloon.multipart.MultipartBalloonType
*/
public void addMultipartBalloon(MultipartBalloonType balloon) {
this.getMultipartBalloonTypes().add(balloon);
}

/**
* Removes a balloon from the registered balloons list
* @param balloon The balloon to remove, type net.jeqo.bloons.balloon.multipart.MultipartBalloonType
*/
public void removeMultipartBalloon(MultipartBalloonType balloon) {
this.getMultipartBalloonTypes().remove(balloon);
}

/**
* Adds a single balloon to the registered balloons list
* @param balloon The single balloon to add, type net.jeqo.bloons.balloon.single.SingleBalloonType
*/
public void addSingleBalloon(SingleBalloonType balloon) {
this.getSingleBalloonTypes().add(balloon);
}

/**
* Removes a single balloon from the registered balloons list
* @param balloon The single balloon to remove, type net.jeqo.bloons.balloon.single.SingleBalloonType
*/
public void removeSingleBalloon(SingleBalloonType balloon) {
this.getSingleBalloonTypes().remove(balloon);
}

/**
* Retrieves a balloon by its ID from the registered balloons list
* @param ID The ID of the balloon, type java.lang.String
* @return The balloon with the specified name, type net.jeqo.bloons.balloon.multipart.MultipartBalloonType/null
* @return The balloon with the specified name, type net.jeqo.bloons.balloon.multipart.MultipartBalloonType
* Returns null if no balloon is found by the specified ID
*/
public MultipartBalloonType getMultipartBalloonByID(String ID) {
// Loop over every balloon in the registered balloons list
Expand All @@ -135,7 +104,8 @@ public MultipartBalloonType getMultipartBalloonByID(String ID) {
/**
* Retrieves a single balloon by its ID from the registered balloons list
* @param ID The ID of the balloon, type java.lang.String
* @return The single balloon with the specified ID, type net.jeqo.bloons.balloon.single.SingleBalloonType/null
* @return The single balloon with the specified ID, type net.jeqo.bloons.balloon.single.SingleBalloonType
* Returns null if no balloon is found by the specified ID
*/
public SingleBalloonType getSingleBalloonByID(String ID) {
// Loop over every single balloon in the registered balloons list
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/jeqo/bloons/balloon/model/BalloonModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* A class to handle the creation of balloon models with custom model data and color metadata
*/
public class BalloonModel {
private static final String leatherMaterialPrefix = "LEATHER_"; // A constant to define a dyeable material
private static final String LEATHER_MATERIAL_PREFIX = "LEATHER_"; // A constant to define a dyeable material

/**
* Generates a coloured model with the specified colour and custom model data
Expand All @@ -23,7 +23,7 @@ public class BalloonModel {
*/
public static ItemStack createColouredModel(Material material, Color colour, int customModelData) {
// Check if the material is dyeable and contains leather attributes
if (!material.name().contains(leatherMaterialPrefix)) {
if (!material.name().contains(LEATHER_MATERIAL_PREFIX)) {
Logger.logError("Material " + material.name() + " is not a dyeable material.");
return new ItemStack(material);
}
Expand Down Expand Up @@ -52,7 +52,7 @@ public static ItemStack createColouredModel(Material material, Color colour, int
*/
public static ItemStack createColouredModel(Material material, int colourRed, int colourGreen, int colourBlue, int customModelData) {
// Check if the material is dyeable and contains leather attributes
if (!material.name().contains(leatherMaterialPrefix)) {
if (!material.name().contains(LEATHER_MATERIAL_PREFIX)) {
Logger.logWarning(String.format(Languages.getMessage("material-not-dyeable"), material));
return new ItemStack(material);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* The type of segment that the model accommodates
*/
public enum BalloonModelType {
public enum BalloonSegmentType {
/**
* This is the head of the balloon, indexed as the last index in the multipart balloon
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import lombok.Getter;
import lombok.Setter;
import net.jeqo.bloons.balloon.model.BalloonModel;
import net.jeqo.bloons.balloon.model.BalloonModelType;
import net.jeqo.bloons.balloon.model.BalloonSegmentType;
import net.jeqo.bloons.logger.Logger;
import net.jeqo.bloons.colors.Color;
import net.jeqo.bloons.message.Languages;
Expand All @@ -15,22 +15,35 @@
*/
@Getter @Setter
public class MultipartBalloonModel {
private BalloonModelType modelType;
private String material;
private String color;
private Integer customModelData;
/**
* The type of segment that the model accommodates
* This can either be the head, body, or tail of the balloon
*/
private BalloonSegmentType segmentType;
/**
* The material used to create the model
*/
private String material; // required
/**
* The color of the model
*/
private String color = "#ffffff"; // optional
/**
* The custom model data value stored in the item metadata
*/
private Integer customModelData; // required

/**
* Creates a new model for a multipart balloon
* @param modelType The type of model (head, body, tail), type net.jeqo.bloons.balloon.model.BalloonModelType
* @param segmentType The type of model (head, body, tail), type net.jeqo.bloons.balloon.model.BalloonModelType
* @param material The name of the Bukkit Material used to create the item, type java.lang.String
* @param color The color of the model as a hex color code value, type java.lang.String
* @param customModelData The custom model data value stored in the item metadata, type int
*/
public MultipartBalloonModel(BalloonModelType modelType, String material, String color, int customModelData) {
this.setModelType(modelType);
public MultipartBalloonModel(BalloonSegmentType segmentType, String material, String color, int customModelData) {
this.setSegmentType(segmentType);
this.setMaterial(material);
this.setColor(color);
if (!color.equals(this.getColor()) && color != null && !color.isEmpty()) this.setColor(color);
this.setCustomModelData(customModelData);
}

Expand Down
Loading
Loading