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

Customizable GUI #328

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

Customizable GUI #328

wants to merge 12 commits into from

Conversation

RoinujNosde
Copy link
Owner

@RoinujNosde RoinujNosde commented Aug 24, 2022

Example config:

title: "gui.main.title"
rows: 3
components:
  leaderboard:
    slot: 3
    material: PAINTING
  panels:
    slots: [0, 1, 2, 3, 4, 5, 6, 7, 8]
    material: GRAY_STAINED_GLASS_PANE

To do:

  • Enable/disable components
  • Decorator components instead of panels?
  • Update XMaterial
  • Test config path for custom frames
  • Fix Exception if default components are not in the config

@RoinujNosde RoinujNosde added the enhancement New feature or request label Aug 24, 2022
public void createComponents() {
SCComponent back = new SCComponentImpl.Builder(getConfig(), "back")
.withDisplayNameKey("gui.back.title").build();
back.setListener(ClickType.LEFT, () -> InventoryDrawer.open(getParent()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

It probably doesn't make to call InventoryDrawer.open() (and put it in the listeners map consequently) if getParent() is 'null'.

Copy link
Owner Author

Choose a reason for hiding this comment

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

getParent() may or may not return null; also InventoryDrawer checks for null.

return frameConfigs.computeIfAbsent(clazz, this::readConfig);
}

private FileConfiguration readConfig(Class<? extends SCFrame> clazz) {
Copy link

Choose a reason for hiding this comment

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

Method readConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants