-
Notifications
You must be signed in to change notification settings - Fork 15
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
Show player if they have enough supplies #25
base: master
Are you sure you want to change the base?
Conversation
Add an option to show the player if they have enough supplies in their inventory to complete their current contract. If turned on, it shows it on the right side of the overlay. If the Plank Sack plugin is installed, it also counts planks in the plank sack.
@TheStonedTurtle Could we get this reviewed/merged in? I think this would be a great addition to the plugin. |
Do you think we can get this reviewed and merged? This works great and would solve the first suggestion on #12 . |
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.
Mostly just minor styling issues but one main issue within the overlay that needs to be resolved before I will merge this.
// Adds a line to the panel describing a material. type is the | ||
// un-pluralized name of the material, min and max are the range | ||
// required, and have is the number in the player's inventory. | ||
void addMaterialLine(String type, int min, int max, int have) { |
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.
name = "Check Supplies", | ||
description = "Checks if you have enough supplies in your inventory to complete your current contract.<br/>" + | ||
"If the Plank Sack plugin is installed, it will include planks in the plank sack.", | ||
position = 10 |
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.
Please match existing indent levels
} | ||
|
||
addMaterialLine("Plank", mats.MinPlanks, mats.MaxPlanks, plugin.getNumPlanksInInventory()); | ||
addMaterialLine("Steel Bar", mats.MinSteelBars, mats.MaxSteelBars, plugin.getNumSteelBarsInInventory()); |
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 plugin.getNum...
functions will be called every time the overlay is redrawn, which is very often. Instead of recalculating these values every time the overlay is redrawn please cache these and update them when the inventory or plank sack contents change.
The easiest way to do this would be to add this to the MahoganyHomesPlugin.java
file, update the existing functions to something like calculateNum...
and then call them when necessary.
@Getter
private int numPlanksInInventory = 0;
@Getter
private int numBarsInInventory = 0;
Sorry for the very long delay on the PR review, life happens sometimes. @PeaceBear0, if you don't want to make the requested changes just let me know. I will eventually merge this but I would need to resolve the issues myself first which who knows when that will be. |
As we haven't had any updates, I had applied your requested changes to PR #28 in behalf of @PeaceBear0 . |
Add an option to show the player if they have enough supplies in their inventory to complete their current contract. If turned on, it shows it on the right side of the overlay. If the Plank Sack plugin is installed, it also counts planks in the plank sack.
Some pictures showing what it looks like: https://imgur.com/a/rpGHKEN