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

Show player if they have enough supplies #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PeaceBear0
Copy link

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

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.
@GKingsbury
Copy link

@TheStonedTurtle Could we get this reviewed/merged in? I think this would be a great addition to the plugin.

@SeaifanAladdin
Copy link
Contributor

Do you think we can get this reviewed and merged? This works great and would solve the first suggestion on #12 .

Copy link
Owner

@TheStonedTurtle TheStonedTurtle left a 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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are multiple checkstyle errors in this file.

To avoid these in the future, and see what to fix currently, you should add the checkstyle.xml file in the root directory to your intelij settings.

  1. Settings (ctrl+alt+s)
  2. Tools -> Checkstyle
  3. Add the local checkstyle file and give it a name.

Ex:
image

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
Copy link
Owner

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());
Copy link
Owner

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;

@TheStonedTurtle
Copy link
Owner

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.

@SeaifanAladdin
Copy link
Contributor

As we haven't had any updates, I had applied your requested changes to PR #28 in behalf of @PeaceBear0 .

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.

4 participants