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

Kit editing #31

Merged
merged 41 commits into from
Oct 10, 2023
Merged

Kit editing #31

merged 41 commits into from
Oct 10, 2023

Conversation

Lagggpixel
Copy link
Member

No description provided.

@Lagggpixel
Copy link
Member Author

Thanks sonarcloud for the approval.

* @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) {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Contributor

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

for (Integer slot : slots) {
switch (slot) {
case (-5): player.getInventory().setHelmet(item);
case (-4): player.getInventory().setChestplate(item);
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member

@Tigerpanzer02 Tigerpanzer02 left a 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

* @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) {
Copy link
Member

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?

@Lagggpixel
Copy link
Member Author

Changes still needed.

@Lagggpixel
Copy link
Member Author

Add a example kits.yml which contains one kit example e.g. default kit of vd or tb

It should be auto generated.

configurationSection.set("display_item", XItemStack.serialize(new ItemStack(Material.BEDROCK)));
}

ItemStack itemStack = XItemStack.deserialize(Objects.requireNonNull(configurationSection.getConfigurationSection("display_item")));
Copy link
Contributor

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

Copy link
Member Author

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 🤣 .

Comment on lines +152 to +157
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"));
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Member Author

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.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 14 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Tigerpanzer02 Tigerpanzer02 merged commit 71031a1 into Plugily-Projects:development Oct 10, 2023
@Lagggpixel Lagggpixel deleted the dev_kitEdit branch October 10, 2023 20:47
Tigerpanzer02 added a commit that referenced this pull request Nov 29, 2023
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants