-
Notifications
You must be signed in to change notification settings - Fork 13
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
Kit editing #31
Kit editing #31
Conversation
Thanks sonarcloud for the approval. |
...ox Classic/src/main/java/plugily/projects/minigamesbox/classic/utils/helper/ArmorHelper.java
Outdated
Show resolved
Hide resolved
* @return Return value is true if the data value was not set and has now been set. | ||
*/ | ||
public static boolean setIfAbsent(FileConfiguration config, String key, Object data) { | ||
if (!config.isSet(key) || !config.contains(key) || config.get(key) == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 3 condition literally doing the same check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundancy in case one of them breaks for some random reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt it, using the get
method is completely sufficient. If you want a deep check, you can use the isSet
method as this checks to copy the default value or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we got this if its never used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I didn't even see it isn't used
MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/Kit.java
Outdated
Show resolved
Hide resolved
MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/Kit.java
Outdated
Show resolved
Hide resolved
MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java
Outdated
Show resolved
Hide resolved
for (Integer slot : slots) { | ||
switch (slot) { | ||
case (-5): player.getInventory().setHelmet(item); | ||
case (-4): player.getInventory().setChestplate(item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if a user using this slot -4
to set the boots for example or just a random itemStack rather than a chestPlate item?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would still put that item into that slot as the method forces it i'm pretty sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a example kits.yml which contains one kit example e.g. default kit of vd or tb
MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java
Outdated
Show resolved
Hide resolved
MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java
Outdated
Show resolved
Hide resolved
MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java
Outdated
Show resolved
Hide resolved
* @return Return value is true if the data value was not set and has now been set. | ||
*/ | ||
public static boolean setIfAbsent(FileConfiguration config, String key, Object data) { | ||
if (!config.isSet(key) || !config.contains(key) || config.get(key) == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we got this if its never used?
Changes still needed. |
It should be auto generated. |
MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/Kit.java
Outdated
Show resolved
Hide resolved
…ox/classic/kits/basekits/Kit.java Co-authored-by: montlikadani <[email protected]>
MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java
Outdated
Show resolved
Hide resolved
configurationSection.set("display_item", XItemStack.serialize(new ItemStack(Material.BEDROCK))); | ||
} | ||
|
||
ItemStack itemStack = XItemStack.deserialize(Objects.requireNonNull(configurationSection.getConfigurationSection("display_item"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless Objects.requireNonNull
, intellij suggests using it, but the above code set this section if not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want it there so I don't get yellow code 🤣 .
Co-authored-by: montlikadani <[email protected]>
MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java
Outdated
Show resolved
Hide resolved
…ox/classic/kits/KitRegistry.java Co-authored-by: montlikadani <[email protected]>
if (configurationSection.getString("unlockedOnDefault") == null) { | ||
plugin.getDebugger().debug(Level.SEVERE, "Kit " + kit_key + " does not have an unlockedOnDefault configuration."); | ||
plugin.getDebugger().debug(Level.SEVERE, "Kit" + kit_key + " will not be loaded."); | ||
return; | ||
} | ||
kit.setUnlockedOnDefault(configurationSection.getBoolean("unlockedOnDefault")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not print a warning because of this missing unlockedOnDefault
property, I would just specify a default value for this boolean. If this property missing from the config, it will return the default value, pretty useless and dumb users might also ask "what is this error" as usual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unlockOnDefault is a value set for all default kits.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if you set up the kits properly, it should print anything in console.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
…y mechanic | Fixed player chat issue & more (#32) * Bump version from 1.3.1 to 1.3.1-SNAPSHOT0 * Fixed doubled statistics, which result in 0 placeholders * Bump version from 1.3.1-SNAPSHOT0 to 1.3.1-SNAPSHOT1 * Bump version from 1.3.2 to 1.3.2-SNAPSHOT0 * Fixed bossbar did not disable (config option) * added default poms for maven building * Bump version from 1.3.2-SNAPSHOT0 to 1.3.2-SNAPSHOT1 * fixed rewards enabling * Bump version from 1.3.2-SNAPSHOT1 to 1.3.2-SNAPSHOT2 * Fixed locale registration if services are unavailable * fixed version * Bump version from 1.3.2-SNAPSHOT2 to 1.3.2-SNAPSHOT3 * Added SEPARATE_ARENA_SPECTATORS * Bump version from 1.3.2-SNAPSHOT3 to 1.3.2-SNAPSHOT4 * Fixed NPE on command usage /pluginindicator stop * Bump version from 1.3.2-SNAPSHOT4 to 1.3.2-SNAPSHOT5 * Support 1.20.2 * Bump version from 1.3.2-SNAPSHOT5 to 1.3.2-SNAPSHOT6 * prepared kits.yml file upgrade * Bump version from 1.3.2-SNAPSHOT6 to 1.3.2-SNAPSHOT7 * Kit editing (#31) * feat: added setIfAbsent method to ConfigUtils * Minor kit update. * feat: kits config foundation * Revert "feat: kits config foundation" This reverts commit 90b140d. * Java 8 compactible * Resolved 1 review. #31 (comment) * Removed 1 unnecessary method. * Moved initialize kit config to after checking if kit is enabled. * Reformatted code * Removed setting name to the config file * Reformatted inventory section of configuration file for kits.yml * Reformatted armour section of configuration file for kits.yml * Added kit item handling, allowing items to be changed while giving kit items. * Update .gitignore * Updated snapshot version * Removed Kit.restock() method. * Removed Kit.restock() method. * Fix for a NPE * Fix for another NPE * Fix for another another NPE * Bumped snapshot version * Update MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/basekits/Kit.java Co-authored-by: montlikadani <[email protected]> * Update for level kits. * Updated structure of kit loading and handling * Fixed getting the itemstack on display for the kit menu * Fixed default kit * Fixed clone kit * Merged suggestion on key_name. Co-authored-by: montlikadani <[email protected]> * Restructured code * Updated KitMenuHandler.java * Updated version * Modified how KitRegistry.handleItem is used. * Create HandleItem.java * Modified handleitem interface * Fixed optional configuration values * Update MiniGamesBox Classic/src/main/java/plugily/projects/minigamesbox/classic/kits/KitRegistry.java Co-authored-by: montlikadani <[email protected]> --------- Co-authored-by: montlikadani <[email protected]> Co-authored-by: Tigerpanzer_02 <[email protected]> * Bump version from 1.3.2-SNAPSHOT13 to 1.3.2-SNAPSHOT14 * Added method to move full hologramarmorstand * Bump version from 1.3.2-SNAPSHOT14 to 1.3.2-SNAPSHOT15 * Fixed kits startup issues * Added kits description * Added KitAction NO_AMOUR * Fixed kit name and lore on kitmenu * Fixed colour on KitMenuItems * Bump version from 1.3.2-SNAPSHOT15 to 1.3.2-SNAPSHOT16 * Fixed player name on chat is removed while PAPI enabled * Bump version from 1.3.2-SNAPSHOT16 to 1.3.2-SNAPSHOT17 * Fixed SelectKitArgument showing for plugins without kits * Bump version from 1.3.2-SNAPSHOT17 to 1.3.2-SNAPSHOT18 * Moved KitAction to KitAbility * Added kit restock method, should be used with optional configuration * Allow plugin specific KitAbilities Added KitAbilityManager Added ArmorHelper.getArmorTypes * Bump version from 1.3.2-SNAPSHOT18 to 1.3.2-SNAPSHOT19 * Renamed actions to abilities in kits.yml * Bump version from 1.3.2-SNAPSHOT19 to 1.3.2-SNAPSHOT20 --------- Co-authored-by: version-bump[github-action] <41898282+version-bump[github-action]@users.noreply.github.com> Co-authored-by: Wanbin Cao <[email protected]> Co-authored-by: montlikadani <[email protected]>
No description provided.