|
3 | 3 |
|
4 | 4 | An API to create Display Entity User Interfaces similar to web pages. |
5 | 5 |
|
| 6 | +To view an example plugin - check this out: [InteractiveMenuAPI Example Plugin](https://github.com/ArcticRaven/InteractiveMenuAPI-ExamplePlugin) |
| 7 | +Its filled with commentary and tips on how to get started and use the API. |
| 8 | + |
| 9 | +For support - please use Github Issues or (preferably) join my support discord with the following invite link |
| 10 | +[Discord](https://discord.gg/xErSpeWa8d) |
| 11 | + |
6 | 12 | ## Features |
7 | 13 |
|
8 | 14 | - Create interactive menus with buttons, text, and images. |
@@ -81,101 +87,5 @@ the Child classes. |
81 | 87 |
|
82 | 88 | ## In Code this time... |
83 | 89 |
|
84 | | -### Example Menu Implementation |
85 | | -Note that this code is also available inside of the "examplePlugin" module. |
86 | | - |
87 | | -```java |
88 | | -package dev.arctic.exampleMenu.menu; |
89 | | - |
90 | | -import dev.arctic.exampleMenu.ExampleMenu; |
91 | | -import dev.arctic.interactivemenuapi.builders.*; |
92 | | -import dev.arctic.interactivemenuapi.interfaces.*; |
93 | | -import dev.arctic.interactivemenuapi.animation.AnimationType; |
94 | | -import dev.arctic.interactivemenuapi.objects.Division; |
95 | | -import dev.arctic.interactivemenuapi.objects.Menu; |
96 | | -import dev.arctic.interactivemenuapi.objects.elements.DisplayElement; |
97 | | -import dev.arctic.interactivemenuapi.objects.elements.TextElement; |
98 | | -import dev.arctic.interactivemenuapi.objects.elements.ToggleElement; |
99 | | -import net.kyori.adventure.text.Component; |
100 | | -import org.bukkit.Location; |
101 | | -import org.bukkit.Material; |
102 | | -import org.bukkit.entity.Player; |
103 | | -import org.bukkit.inventory.ItemStack; |
104 | | -import org.bukkit.util.Vector; |
105 | | - |
106 | | -import java.util.ArrayList; |
107 | | - |
108 | | -public class ExampleMenuUI { |
109 | | - |
110 | | - public static IMenu createMenu(Location rootLocation, Player owner) { |
111 | | - |
112 | | - /* |
113 | | - Build your Menu in this order |
114 | | - { Menu -> Division -> Elements -> Add Elements to Division -> Add Division to Menu -> Return Menu} |
115 | | - This will prevent null values when creating your elements. |
116 | | - */ |
117 | | - |
118 | | - |
119 | | - // Create the menu and add the division |
120 | | - Menu menu = new MenuBuilder() |
121 | | - .setRootLocation(rootLocation) |
122 | | - .setPlugin(ExampleMenu.getPlugin(ExampleMenu.class)) |
123 | | - .setDoCleanup(true) |
124 | | - .setOwner(owner) |
125 | | - .setDivisions(new ArrayList<>()) |
126 | | - .setTimeoutSeconds(60) |
127 | | - .build(); |
128 | | - |
129 | | - // Create division |
130 | | - Division division = new DivisionBuilder() |
131 | | - .setAnimationType(AnimationType.LEFT) |
132 | | - .setAnimationStepper(0.1f) |
133 | | - .setElements(new ArrayList<>()) |
134 | | - .setInitialLocation(rootLocation) //this should usually just be the root location, then apply offset |
135 | | - .setOffset(new Vector(0,0,0)) |
136 | | - .setParentMenu(menu) |
137 | | - .build(); |
138 | | - |
139 | | - // Create display element |
140 | | - DisplayElement displayElement = new DisplayElementBuilder() |
141 | | - .setDisplayItem(new ItemStack(Material.DIAMOND)) |
142 | | - .setParentMenu(menu) |
143 | | - .setParentDivision(division) |
144 | | - .setOffset(new Vector(0, 0, 1)) |
145 | | - .build(); |
146 | | - |
147 | | - // Create text element |
148 | | - TextElement textElement = new TextElementBuilder() |
149 | | - .setText(Component.text("Test Text Element :D")) |
150 | | - .setParentMenu(menu) |
151 | | - .setParentDivision(division) |
152 | | - .setOffset(new Vector(0, 0, 0.5)) |
153 | | - .build(); |
154 | | - |
155 | | - // Create toggle element |
156 | | - ToggleElement toggleElement = new ToggleElementBuilder() |
157 | | - .setPrimaryText(Component.text("Primary Text")) |
158 | | - .setSecondaryText(Component.text("Secondary Text")) |
159 | | - .setPressAnimationType(AnimationType.PRESSED) |
160 | | - .setPressAnimationStepper(0.1f) |
161 | | - .setOffset(new Vector(0, 0, 0)) |
162 | | - .setParentMenu(menu) |
163 | | - .setParentDivision(division) |
164 | | - .build(); |
165 | | - |
166 | | - |
167 | | - /* |
168 | | - Add the elements to the division |
169 | | - This is important to do before adding the division to the menu |
170 | | - Essentially reversing the order of creation :D |
171 | | - */ |
172 | | - division.addElement(toggleElement); |
173 | | - division.addElement(textElement); |
174 | | - division.addElement(displayElement); |
175 | | - |
176 | | - menu.addDivision(division); |
177 | | - |
178 | | - return menu; |
179 | | - } |
180 | | -} |
181 | | -``` |
| 90 | +The best place to get a good look at how to use is the example [InteractiveMenuAPI Example Plugin](https://github.com/ArcticRaven/InteractiveMenuAPI-ExamplePlugin). |
| 91 | +I've filled it with comments and kept the example pretty straightforward. |
0 commit comments