-
Notifications
You must be signed in to change notification settings - Fork 35
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
RoinujNosde
wants to merge
12
commits into
master
Choose a base branch
from
customizable-gui
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Customizable GUI #328
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6a570cf
Added example config and readConfig() method
RoinujNosde dd67656
Made realistic changes to GUI config
RoinujNosde 45ef2ce
Added ArrayBuilder - WIP
RoinujNosde 91c701a
Merge branch 'master' into customizable-gui
RoinujNosde edd4c46
Generified Paginator, added PageableFrame
RoinujNosde b332457
Refactored AddPermissionFrame
RoinujNosde 56b4b64
Enabled state for Components, XMaterial updated
RoinujNosde 949943f
Decorations
RoinujNosde 7cb55f6
Move getConfig() to SettingsManager
RoinujNosde 91845ab
Some refactoring
RoinujNosde f5ae7e2
Fixed error when config was missing
RoinujNosde 707a6bf
Refactored processLang
RoinujNosde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/net/sacredlabyrinth/phaed/simpleclans/ui/PageableFrame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package net.sacredlabyrinth.phaed.simpleclans.ui; | ||
|
||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.inventory.ClickType; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.annotation.OverridingMethodsMustInvokeSuper; | ||
|
||
public abstract class PageableFrame<T> extends SCFrame { | ||
|
||
public PageableFrame(@Nullable SCFrame parent, @NotNull Player viewer) { | ||
super(parent, viewer); | ||
} | ||
|
||
@Override | ||
@OverridingMethodsMustInvokeSuper | ||
public void createComponents() { | ||
super.createComponents(); | ||
SCComponent nextPage = new SCComponentImpl.Builder(getConfig(), "next_page") | ||
.withDisplayNameKey("gui.next.page.title").build(); | ||
setOneTimeListener(nextPage, this::nextPage, getPaginator().hasNextPage()); | ||
add(nextPage); | ||
|
||
SCComponent previousPage = new SCComponentImpl.Builder(getConfig(), "previous_page") | ||
.withDisplayNameKey("gui.previous.page.title").build(); | ||
setOneTimeListener(previousPage, this::previousPage, getPaginator().hasPreviousPage()); | ||
add(previousPage); | ||
} | ||
|
||
public abstract Paginator<T> getPaginator(); | ||
|
||
public int getPageSize() { | ||
return getConfig().getIntegerList("components.list.slots").size(); | ||
} | ||
|
||
private void nextPage() { | ||
if (getPaginator().nextPage()) { | ||
update(); | ||
} | ||
} | ||
|
||
private void previousPage() { | ||
if (getPaginator().previousPage()) { | ||
update(); | ||
} | ||
} | ||
|
||
private void setOneTimeListener(final SCComponent component, final Runnable runnable, boolean pageCheck) { | ||
if (!pageCheck) { | ||
return; | ||
} | ||
component.setListener(ClickType.LEFT, () -> { | ||
component.setListener(ClickType.LEFT, null); | ||
runnable.run(); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Method
readConfig
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.