Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
j1sk1ss committed May 12, 2024
2 parents 9e9d981 + d99c6f5 commit ecad244
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 7 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Nikolay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
96 changes: 89 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ As you can see, panels should take **Components**. **Components** is a UI object
- **Bar**
- **ClickArea**
- **LittleButton**
- **Icon**
</br>


Expand Down Expand Up @@ -59,14 +60,20 @@ Also, example of adding delegate to **button**:

var slider = new Slider(ArrayList<Integer> coordinates, ArrayList<String> Options, String lore, String name, Action action);

Note, that slider has default delegate. This "default" delegate regenerate **slider** body on click when chosen parametr changes. </br>
<p align="center">
<img width="600" height="800" src="https://github.com/j1sk1ss/MenuFramework.PC/blob/master/covers/SliderCover.png">
</br><text> Red slot - chosen option in slider </text>
</p>

Note, that slider has default delegate. This "default" delegate regenerate **slider** body on click when chosen parameter changes. </br>
If you need to take chosen param from **Slider**, you can use next code:</br>

var slider = new Slider(panelWhereStoredSlider.getSliders("SliderName"), event.getInventory());
var parameter = slider.getChose(event); // parameter is a String lore line from Options

This **slider`s** ability give us a opportunity to connect **Buttons** and **Sliders** like in example below:</br>

public static MenuWindow Menu = new MenuWindow(Arrays.asList(
var panel = new Panel(Arrays.asList(
new Slider(Arrays.asList(
0, 1, 2, 3, 4, 5
Expand All @@ -77,12 +84,12 @@ This **slider`s** ability give us a opportunity to connect **Buttons** and **Sli
new Button(9, 21, "TestButton", "Lore",
(event) -> {
var player = (Player)event.getWhoClicked();
var slider = new Slider(Menu.getPanel("TestPanel").getSliders("Slider"), event.getInventory());
if (slider.getChose(event).equals("none")) return;
var sliderChose = Menu.getPanel("TestPanel").getSliders("Slider").getChose(event);
if (sliderChose.equals("none")) return;

player.sendMessage(slider.getChose(event)); // It will prints current slider parameter
player.sendMessage(sliderChose); // Will prints current slider parameter
}),
), "TestPanel"),
), "TestPanel")));



Expand All @@ -92,10 +99,67 @@ This **slider`s** ability give us a opportunity to connect **Buttons** and **Sli

var checkbox = new Checkbox(int firstSlot, int secondSlot, String name, String lore, Action action);

<p align="center">
<img width="600" height="800" src="https://github.com/j1sk1ss/MenuFramework.PC/blob/master/covers/CheckBoxCover.png">
</p>

Note, that checkbox has default delegate too. This "default" delegate regenerate **checkbox** body on click (Checked and unchecked). </br>
Here first slot and second slot works like in **Button** part. One difference in method *isChecked*.

var check = checkbox.isChecked(event) // event -> InventoryClickEvent

<h2 align="center"> Click area </h2>

**ClickArea** can be created by next code:</br>

var clickArea = ClickArea(firstCoordinate, secondCoordinate, action, name, lore);
var clickArea = ClickArea(coordinates, action, name, lore);

**ClickArea** solves problem with generated (non-static) buttons. You can just put **ClickArea** where will be generated non-static **Components** then just handle any clicks in action delegate. </br>
For example next code shoulde handle clicks on generated options in menu:

new ClickArea(0, 44,
(event) -> {
var player = (Player) event.getWhoClicked();
var option = event.getCurrentItem();
if (option == null) return;

if (option.getLoreLines().size() < 2) return;
var amount = option.getDoubleFromContainer("item-bank-value");

func1(Math.abs(amount), player);
openMenu(player, event.getInventory());
}),

*Note*: **Component** class has his own **PDC**. You can use it with next methods:

public void setDouble2Container(value, key);
public void setInteger2Container(value, key);
public double getDoubleFromContainer(key);
public int getIntegerFromContainer(key);
public void deleteKeyFromContainer(key);

<p align="center">
<img width="600" height="800" src="https://github.com/j1sk1ss/MenuFramework.PC/blob/master/covers/ClickAreaCover.png">
</p>

<h2 align="center"> Little buttons </h2>

**LittleButton** can be created by next code:</br>

var button = new LittleButton(41, "LB", "\n" + Math.round(playerBalance * 100) / 100 + CashManager.currencySigh);

<p align="center">
<img width="600" height="800" src="https://github.com/j1sk1ss/MenuFramework.PC/blob/master/covers/LittleButtonCover.png">
</p>

**LittleButton** works like **Button**, but this component has onlu one position.

<h2 align="center"> Icons </h2>

**Icon** can be created by next code:</br>

var icon = Icon(position, name, lore, material, dataModel);

<h2 align="center"> How to use it? </h2>

Expand All @@ -109,7 +173,25 @@ After this, MenuFramework listen all inventory clicks and anvoke functions that

**Panel** is a representation of every inventory that used as menu in your plugin. Creation of panel is simple:

var panel = new Panel(Arrays.asList( ... ), "InventoryTitlePart");
var panel = new Panel(Arrays.asList( ... ), "InventoryTitlePart", MenuSizes.SixLines);

<p align="center">
<img width="600" height="800" src="https://github.com/j1sk1ss/MenuFramework.PC/blob/master/covers/PanelCover.png">
</br><text> Example of panel with click area, stider, checkbox \ button and little button \ icon </text>
</p>

Remember that **MenuFramework** will execute linked function in situation, when used inventory have same name with panel. (Or **panel** name is a part of inventory title). </br>
To place all components to inventory you shoukd use next code:

public void getView(player);
public void getView(player, inventory);

// Or

Remember that **MenuFramework** will execute linked function in situation, when used inventory have same name with panel. (Or **panel** name is a part of inventory title).
public void getView(player, lore);
public void getView(player, customLore, names);
public void getViewWith(player, newComponents); // newComponents - non-static components
public void getView(player, lore, inventory);
public void getView(player, customLore, names, inventory); // customLore - lore for components with names from names
public void getViewWith(player, newComponents, inventory); // newComponents - non-static components

Binary file added covers/CheckBoxCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added covers/ClickAreaCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added covers/LittleButtonCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added covers/PanelCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added covers/SliderCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ecad244

Please sign in to comment.