Git Product home page Git Product logo

triumph-gui's People

Contributors

blitzoffline avatar conclube avatar dersimeon avatar diego6k9 avatar dkim19375 avatar efekurbann avatar euphillya avatar fisher2911 avatar harry0198 avatar igabytm avatar kqliber avatar lichthund avatar oribuin avatar secretx33 avatar tehbrian avatar tobygascoigne avatar workinq avatar wruczek avatar zrdzn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

triumph-gui's Issues

Auto expand gui when number of added items is greater than current rows * 9

So basically, as asked in discord:

Gui gui = new Gui("My gui");
for (int i = 0; 0 < 9; ++i) {
  gui.addItem(new GuiItem(Material.GLASS));
}

gui.getFiller().fill(new GuiItem(Material.STONE));

for (int i = 0; 0 < 3; ++i) {
  gui.addItem(new GuiItem(Material.GLASS));
}

should create a 2-row gui filled with glass and stone.

I don't know if that's already handled but up for discussion is whether it should be filled as 9x glass, 3x glass and 6x empty or 9x glass, 3x glass and 6x stone. If that is not already implemented - I opt for the latter.

[Recommendation] Add GuiType.ANVIL

I think we can agree that anvils are a requirement for the trimuph gui system, now I don't know if there's an existing branch that works on that issue/recommendation, but I I would like to see if there is any possible ways to patch this in, since using Bukkits Inventory management is completely useless once your use this gui lib.

NullPointerException when clicking items inside player's inventory

[16:58:58 ERROR]: Could not pass event InventoryClickEvent to mcwarCore v0.0.6-beta
java.lang.NullPointerException: null
        at net.minecodes.mcwar.gui.guis.GuiListener.isGuiItem(GuiListener.java:176) ~[?:?]
        at net.minecodes.mcwar.gui.guis.GuiListener.onGuiClick(GuiListener.java:98) ~[?:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor47.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.16.5.jar:git-Purpur-1118]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.16.5.jar:git-Purpur-1118]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.16.5.jar:git-Purpur-1118]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:2839) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:32) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:10) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:55) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1336) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1329) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1305) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1149) ~[patched_1.16.5.jar:git-Purpur-1118]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:292) ~[patched_1.16.5.jar:git-Purpur-1118]
        at java.lang.Thread.run(Thread.java:834) [?:?]

Make Adventure Optional!

Well, Adventure is ""relatively"" new.

I don't understad why it was made "required" to be used on this project.

Isn't a good idea to add a String equivalent of each function?

The way things are now i can't use it on legacy minecraft versions. (Like 1.7.10 in my case)

Errors If you use it on many plugins

I am using this lib to simplify my work for my server, however I have noticed that for some strange reason most of the time some plugins fail on other plugins.
Ex: I have my "crystalmobarena" plugin which has a GUI I will click on and for some strange reason (as seen in the error) the "rubyutils" plugin will give an error containing the stacktrace of another plugin.
This all happens randomly and can be fixed by restarting the server, but I don't think this is normal!
I have about 4/5 plugins on my server that use this library
Error:

[19:49:36 ERROR]: Could not pass event InventoryClickEvent to RubyUtils v3.3.10
java.lang.NoSuchMethodError: dev.triumphteam.gui.builder.item.ItemBuilder.setName(Ljava/lang/String;)Ldev/triumphteam/gui/builder/item/BaseItemBuilder;
        at me.kr1s_d.crystalmobarena.creator.gui.ArenaEditorPanel.build(ArenaEditorPanel.java:83) ~[?:?]
        at me.kr1s_d.crystalmobarena.creator.gui.ArenaEditorPanel.<init>(ArenaEditorPanel.java:48) ~[?:?]
        at me.kr1s_d.crystalmobarena.creator.gui.ArenaSelectorPanel.lambda$build$3(ArenaSelectorPanel.java:76) ~[?:?]
        at dev.triumphteam.gui.guis.GuiListener.onGuiClick(GuiListener.java:102) ~[?:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor1002.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[patched_1.12.2.jar:git-Paper-1618]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.2.jar:git-Paper-1618]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.2.jar:git-Paper-1618]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:513) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:2002) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:33) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:10) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[patched_1.12.2.jar:git-Paper-1618]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_312]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_312]
        at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:850) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:774) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:666) ~[patched_1.12.2.jar:git-Paper-1618]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312]

BROKEN INVENTORIES

Inventories break if you use a gui pages 1.8.x to 1.11.x 1.12.2 seem to work

Different NBT Attributes of Default Cooldowns, Refills, and Similar Items Compared to TriumphGUI

This guide explains the variances in NBT attributes between default cooldowns, refills, and similar items in Minecraft compared to those presented through TriumphGUI.

TriumphGUI is a plugin designed to create user interfaces (GUIs) in Minecraft, offering convenient customization options for items, including the manipulation of NBT attributes. However, it's important to note that default cooldowns, refills, and similar items may have different NBT attributes compared to those showcased in TriumphGUI.

By default, Minecraft implements specific NBT attributes for various game mechanics, such as item cooldowns and refill functionalities. These default attributes are distinct from those modified through TriumphGUI or other similar plugins. While TriumphGUI allows for extensive customization of NBT tags and item behaviors, it operates within the framework defined by the game's default attributes.

To fully understand and modify the NBT attributes of default cooldowns, refills, or other related functionalities, it's recommended to consult the official Minecraft documentation or relevant community resources. These sources will provide detailed information on default NBT attributes and any available methods for customization or modification.

Please note that this information is based on the general understanding of Minecraft gameplay mechanics and may vary depending on the specific version, configuration, or modifications applied to your Minecraft server.

NPE when clicking items in the hotbar while a Gui is open

I'm getting this on any type of Gui whenever I click on any item in the hotbar while it's open:
[14:05:15 ERROR]: Could not pass event InventoryClickEvent to BattleGamesHungerRoyale v1.16.5_alpha1 java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "dev.triumphteam.gui.components.util.ItemNbt.getString(org.bukkit.inventory.ItemStack, String)" is null at dev.triumphteam.gui.guis.GuiListener.isGuiItem(GuiListener.java:176) ~[?:?] at dev.triumphteam.gui.guis.GuiListener.onGuiClick(GuiListener.java:98) ~[?:?] at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor18.execute(Unknown Source) ~[?:?] at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.16.5.jar:git-Paper-777] at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.16.5.jar:git-Paper-777] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.16.5.jar:git-Paper-777] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:624) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:2715) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:32) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:10) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:35) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1266) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1259) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1220) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1134) ~[patched_1.16.5.jar:git-Paper-777] at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-777] at java.lang.Thread.run(Thread.java:831) [?:?]

I don't really know how to do a PR or anything but in GuiListener.java:

private boolean isGuiItem(@Nullable final ItemStack currentItem, @Nullable final GuiItem guiItem) {
        if (currentItem == null || guiItem == null) return false;

        // Checks whether or not the Item is truly a GUI Item
        return ItemNbt.getString(currentItem, "mf-gui").equals(guiItem.getUuid().toString());

    }

ItemNbt.getString(currentItem, "mf-gui" needs a null check I think.

Thanks for the library I've been using it a lot.

Reopen #24 (method to clear page items)

Please merge #24, currently I have to use reflections in order to clear existing page items:

Field list = PaginatedGui.class.getDeclaredField("pageItems");
list.setAccessible(true);
ArrayList<GuiItem> actualList = (ArrayList<GuiItem>) list.get(lobbySwitcherGui);
actualList.clear();
list.set(lobbySwitcherGui, actualList);

Would be a nice feature

Package-private methods

Hello, I have a question about two methods located in the PaginatedGui. Does page number getter/setter really need to be package-private scope? I think it would be nice if (at least) getter was public since you can use it for e.g. placeholders (item lore maybe? Like, on what page are you currently on). If it is package-private for any reason - that's okay, but I guess it's not really done on purpose.

/**
* Gets the page number
*
* @return The current page number
*/
int getPageNum() {
return pageNum;
}
/**
* Sets the page number
*
* @param pageNum Sets the current page to be the specified number
*/
void setPageNum(final int pageNum) {
this.pageNum = pageNum;
}

Does it work for 1.9 to 1.19?

Does this library work for all versions from 1.8 to 1.19? And is there support on Discord or some forum or something? Thx

Plugin works in 1.8 but not in 1.18

On a server with ViaVersion, in 1.8 the plugin works correctly, but in 1.18 it does not work, idk if it's a bug or I'm doing something wrong

Specifically, in 1.8 when clicking the events work, it does not allow objects to be moved.

In 1.18 clicking does not work the events and lets steal objects

Thanks in advance

Clear GUI Items

private final Map<Integer, GuiItem> guiItems;

would like to know if there is a method to clear this list. I am developing a plugin that regenerates the GUI each time an item is clicked. I am finding it difficult to have to remove all of the guiItems.

Serialization

Would you consider including an ability to serialize GUIs to/from the file system?

adding custom items

im trying to use this to add a item but it doesnt get anything and when i print the list to the console with Bukkit.getLogger().info(list.toString()); i get [myitems:red_block] so why isnt it adding any items to the gui

for (int i = 0; i > list.size(); i++) {
    GuiItem guiItem = 
    ItemBuilder.from(CustomStack.getInstance(list.get(i)).getItemStack().getType()).name(Component.text(list.get(i))).asGuiItem();
    gui.addItem(guiItem);
}

Outdated documentation

It says here in the GitBook docmunetation that "Hopper GUI: The hopper GUI does not trigger the click event due to an issue involving InventoryHolder being null, so I decided to temporarily remove it until I can find a better fix.". This probably needs to be updated, seeing that hopper gui was readded in 3.0.5?

Documentation Grammar Errors

As I read through the documentation of this GUI framework for plugins I found some grammatical errors and I think that it would be better if I would list them here in this issue.

I don't want to hurt anyone with this issue.

If you don't like to read a lot of text, you can just skip everything and go to Simpler Form where everything is also in table form.

Text

Setup

  • In the sentence In order to include the framework in your project, you need to add the following to your pom.xml, in the plugins section. there is unfortunately a single comma to much: In order to include the framework in your project, you need to add the following to your pom.xml in the plugins section.
  • The second sentence ( Replace [YOUR PACKAGE]with your plugin's package, for example me.myplugin.plugin.) should be separated and there needs to be a comma after the example word: Replace [YOUR PACKAGE]with your plugin's package. For example, me.myplugin.plugin.

Paginated GUI

  • In "Paginated GUI" I would replace Simple GUI that allows you to have multiple pages and navigate between them with A simple GUI that allows you to have multiple pages and navigate between them.
  • To have a better flow of information I would use instead of The page size, is how big the page should be, in the example above it's 45 slots dedicated for the page, if nothing is set the lib will calculate the page size when opening. a version that is split into multiple sentences: The page size is how big the page should be. In the example above, there are 45 slots dedicated to the page. If nothing is set, the lib will calculate the page size when opening.
  • In the first sentence of the Creating the navigation section only a comma is missing and so I would change To create the navigation items we can simply do: into To create the navigation items, we can simply do:.
  • I would just use It is recommended instead of Recommended as a start of a sentence.
  • In the first sentence of the Populating the page section only a comma is missing and so I would change To add items to the page once again we use the PaginatedGui#addItem which takes a GuiItem. into To add items to the page once again, we use the PaginatedGui#addItem, which takes a GuiItem.
  • And as a more stylistic approach I would just use instead of Items added with PaginatedGui#setItem will not be counted towards the page but as static GUI items. this: Items added with PaginatedGui#setItem will be treated as static GUI items rather than page items.

Scrolling GUI

  • In "Scrolling GUI" I would replace Simple GUI that allows you to scroll on a Paginated GUI instead of going page by page. with A simple GUI that allows you to scroll on a Paginated GUI instead of going page by page.
  • The first sentence is somehow missing: To create a Scrolling G and I would just use To create a Scrolling GUI, all you need to do is:
  • In the codeblock
    ScrollingGui gui = Gui.scrolling()
            .title(Component.text("GUI Title!"))
            .rows(6)
            .pageSize(45)
            .scrollType(ScrollType.HORIZONTAL) // Not needed, defauilts to VERTICAL.
            .create();
    the word defaults has an i that is not needed:
    ScrollingGui gui = Gui.scrolling()
            .title(Component.text("GUI Title!"))
            .rows(6)
            .pageSize(45)
            .scrollType(ScrollType.HORIZONTAL) // Not needed, defaults to VERTICAL.
            .create();
  • Instead of Just like the normal GUI the first parameter is the rows the GUI should have. I would use Just like the normal GUI, the first parameter is the number of rows the GUI should have
  • And the sentence Like the Paginated GUI the second parameter is to specify the page size, as in how big the page should be, in the example above it's 45 slots dedicated for the page. I would split and reword the second part, as I don't think you meant It is 45 slots, into Like in the Paginated GUI, the second parameter is to specify the page size, as in how big the page should be. In the example above, there are 45 slots dedicated to the page.

Storage GUI

  • In "Storage GUI" I would replace GUI that does not clear it's items on close/open, any external non GuiItem added to it will stay. (it does not persist on server restart) with Any GUI that does not clear its items on open or close will have any external non-GuideItem added to it stay (it does not persist when the server is restarted).
  • I would change To create a persistent GUI all you need to do is: into To create a persistent GUI, all you need to do is:.
  • Instead of Just like the normal GUI the first parameter is the rows the GUI should have. I would use Just like the normal GUI, the first parameter is the number of rows the GUI should have
  • Instead of Differently to the normal GUI, the addItem method takes an ItemStack instead. I would use the words In contrast as it makes the sentence more lively and shows the difference: In contrast to the normal GUI, the addItem method takes an ItemStack instead.
  • The sentence Any GuiItem added will have actions applied to it, the persistent items are simple ItemStacks that have nothing associated to it. should be separated and to it is singular and it should be plural Any GuiItem added will have actions applied to it. The persistent items are simple ItemStacks that have nothing associated with them.

GUI features

  • In "GUI Features" I would replace After the basics of a GUI there is a lot more useful features you can use. with After learning the basics of a GUI, there are a lot more useful features you can use.
  • To show the difference to the reader I would change The GUI filler allows you to fill in the GUI in many ways, for example, completely filling or filling the bottom or top of the GUI. to The GUI filler allows you to fill in the GUI in many ways, for example, completely filling or just filling the bottom or top of the GUI.
  • The sentence Setting you fill item will fill the slots in your GUI that doesn't contain a GUI item. should be Setting the item will fill the slots in your GUI that don't contain a GUI item.
  • In the sentence Just like any other item these items can also have a click action, but they'll be the same for all the slots it is filled. there is just a comma and the it is filled: Just like any other item, these items can also have a click action, but they'll be the same for all the slots they fill.
  • After the for example there should be a comma and so For example if you call event.setCancelled(true) should be changed into For example, if you call event.setCancelled(true) .
  • The ever in This will display the action you set when ever the GUI is closed. is not needed in this context: This will display the action you set when the GUI is closed.
  • The ever in This will display the action you set when ever the GUI is open . is also not needed in this context and there is a space too much: This will display the action you set when the GUI is open.
  • The sentence If you want to add a click action to a specif slot without needing to have to specify the item in the slot, you can simple use the setSlotAction. should be rewritten into If you want to add a click action to a specific slot without needing to specify the item in the slot, you can simply use setSlotAction.
  • I would change The update method will update the entire GUI except the title, due to how inventories work. into Due to how inventories work, the update method will update the entire GUI except the title.
  • After the for example in This is the preferable way of making updates in your GUI, for example an item that keeps refreshing, etc. there should be a comma: This is the preferable way of making updates in your GUI, for example, an item that keeps refreshing, etc.

Simpler form

As I know that this format is a little bit harder to read, I am here adding a simpler way of accessing this information in the form of a table:

Setup

Original String New String
In order to include the framework in your project, you need to add the following to your pom.xml, in the plugins section. In order to include the framework in your project, you need to add the following to your pom.xml in the plugins section.
Replace [YOUR PACKAGE]with your plugin's package, for example me.myplugin.plugin. Replace [YOUR PACKAGE]with your plugin's package. For example, me.myplugin.plugin.

Paginated GUI

Original String New String
Simple GUI that allows you to have multiple pages and navigate between them. A simple GUI that allows you to have multiple pages and navigate between them.
The page size, is how big the page should be, in the example above it's 45 slots dedicated for the page, if nothing is set the lib will calculate the page size when opening. The page size is how big the page should be. In the example above, there are 45 slots dedicated to the page. If nothing is set, the lib will calculate the page size when opening.
To create the navigation items we can simply do: To create the navigation items, we can simply do:
Recommended It is recommended
To add items to the page once again we use the PaginatedGui#addItem which takes a GuiItem. To add items to the page once again, we use the PaginatedGui#addItem, which takes a GuiItem.
Items added with PaginatedGui#setItem will not be counted towards the page but as static GUI items. Items added with PaginatedGui#setItem will be treated as static GUI items rather than page items.

Scrolling GUI

Original String New String

Simple GUI that allows you to scroll on a Paginated GUI instead of going page by page.

A simple GUI that allows you to scroll on a Paginated GUI instead of going page by page.

To create a Scrolling G

To create a Scrolling GUI, all you need to do is:

ScrollingGui gui = Gui.scrolling()
        .title(Component.text("GUI Title!"))
        .rows(6)
        .pageSize(45)
        .scrollType(ScrollType.HORIZONTAL) // Not needed, defauilts to VERTICAL.
        .create();
 ScrollingGui gui = Gui.scrolling()
         .title(Component.text("GUI Title!"))
         .rows(6)
         .pageSize(45)
         .scrollType(ScrollType.HORIZONTAL) // Not needed, defaults to VERTICAL.
         .create();

Just like the normal GUI the first parameter is the rows the GUI should have.

Just like the normal GUI, the first parameter is the number of rows the GUI should have

Like the Paginated GUI the second parameter is to specify the page size, as in how big the page should be, in the example above it's 45 slots dedicated for the page.

Like in the Paginated GUI, the second parameter is to specify the page size, as in how big the page should be. In the example above, there are 45 slots dedicated to the page.

Storage GUI

Original String New String
GUI that does not clear it's items on close/open, any external non GuiItem added to it will stay. (it does not persist on server restart) Any GUI that does not clear its items on open or close will have any external non-GuideItem added to it stay (it does not persist when the server is restarted)
To create a persistent GUI all you need to do is: To create a persistent GUI, all you need to do is:
Differently to the normal GUI, the addItem method takes an ItemStack instead. In contrast to the normal GUI, the addItem method takes an ItemStack instead
Any GuiItem added will have actions applied to it, the persistent items are simple ItemStacks that have nothing associated to it. Any GuiItem added will have actions applied to it. The persistent items are simple ItemStacks that have nothing associated with them.

GUI Features

Original String New String
After the basics of a GUI there is a lot more useful features you can use. After learning the basics of a GUI, there are a lot more useful features you can use.
The GUI filler allows you to fill in the GUI in many ways, for example, completely filling or filling the bottom or top of the GUI. The GUI filler allows you to fill in the GUI in many ways, for example, completely filling or just filling the bottom or top of the GUI.
Just like any other item these items can also have a click action, but they'll be the same for all the slots it is filled. Just like any other item, these items can also have a click action, but they'll be the same for all the slots they fill.
For example if you call event.setCancelled(true) For example, if you call event.setCancelled(true)
This will display the action you set when ever the GUI is closed. This will display the action you set when the GUI is closed.
This will display the action you set when ever the GUI is open . This will display the action you set when the GUI is open.
If you want to add a click action to a specif slot without needing to have to specify the item in the slot, you can simple use the setSlotAction. If you want to add a click action to a specific slot without needing to specify the item in the slot, you can simply use setSlotAction.
The update method will update the entire GUI except the title, due to how inventories work. Due to how inventories work, the update method will update the entire GUI except the title.
This is the preferable way of making updates in your GUI, for example an item that keeps refreshing, etc. This is the preferable way of making updates in your GUI, for example, an item that keeps refreshing, etc.

GuiType.HOPPER doesn't work

When creating a GUI with GuiType.HOPPER, the GuiItems in it won't have their actions activated (in asGuiItem)

click event

i have this but when i click one of the items it doesnt work

		for (int i = 0; i < stack.size(); i++) {
			CustomStack item = CustomStack.getInstance(stack.get(i));
			GuiItem guiItem = ItemBuilder.from(item.getItemStack().getType())
					.name(Component.text(item.getDisplayName())).asGuiItem(event -> {
						if (event.isRightClick())
							if (event.getCurrentItem().getItemMeta().hasDisplayName()) {
								event.getCurrentItem().getItemMeta().getDisplayName();
								String namespace = event.getCurrentItem().getItemMeta().getDisplayName();
								config.getStringList("items").add(namespace);
								config.createSection(namespace.replace(":",""));
								config.set(namespace.replace(":", "") + ".whitelist", true);
								config.set(namespace.replace(":", "") + ".can-float", true);
								config.set(namespace.replace(":", "") + ".water-collision", true);
								List<String> comments = new ArrayList<String>();
								comments.add("blocks:");
								comments.add("- Material");
								config.setComments(namespace.replace(":", ""), comments);
								BlockLimiter.getInstance().reloadConfig();
								gui.update();
							}
					});
			gui.addItem(guiItem);
		}

Allow directly update of updateItem() with GuiItem as arg

Shoulden't this allow directly update?

https://github.com/TriumphTeam/triumph-gui/blob/master/core/src/main/java/dev/triumphteam/gui/guis/BaseGui.java#L515

If we have a menu, for example, with a border that spins, we need to make two codes, one for setting the guiItems and another for updating it afterwards.

SomeGif

We would have to duplicate this code bellow, one for setting it and one after to update it.

    private void drawBackground(){
        for (int backgroundSlot : backgroundSlots) {
            if (this.gui.getGuiItem(backgroundSlot) != BLACK_BACKGROUND){
                this.gui.updateItem(backgroundSlot, BLACK_BACKGROUND);
            }
        }
        
        int[] movingSlots = getNext4MovingSlots();
       
        this.gui.updateItem(movingSlots[0], BLUE_BACKGROUND);
        this.gui.updateItem(movingSlots[1], BLUE_BACKGROUND);
        this.gui.updateItem(movingSlots[2], YELLOW_BACKGROUND);
        this.gui.updateItem(movingSlots[3], GREEN_BACKGROUND);
    }

java.lang.ClassNotFoundException: net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer

Hi, i tried to create gui, but when player execute command i get this error:

Caused by: java.lang.ClassNotFoundException: net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
at java.net.URLClassLoader.findClass(URLClassLoader.java:440) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:156) ~[patched_1.12.2.jar:git-Paper-1618]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:104) ~[patched_1.12.2.jar:git-Paper-1618]
at java.lang.ClassLoader.loadClass(ClassLoader.java:587) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
at xyz.reallife.RealLife.gui.components.util.Legacy.(Legacy.java:34) ~[?:?]
at xyz.reallife.RealLife.gui.builder.gui.SimpleBuilder.create(SimpleBuilder.java:72) ~[?:?]
at xyz.reallife.commands.user.PlayerSettings.onCommand(PlayerSettings.java:33) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[patched_1.12.2.jar:git-Paper-1618]
... 15 more

My shade config:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <configuration>
                    <relocations>
                        <relocation>
                            <pattern>dev.triumphteam.gui</pattern>
                            <shadedPattern>xyz.reallife.RealLife.gui</shadedPattern> <!-- Replace package here here -->
                        </relocation>
                        <relocation>
                            <pattern>net.kyori.adventure</pattern>
                            <shadedPattern>xyz.reallife.RealLife.adventure</shadedPattern> <!-- Replace package here here -->
                        </relocation>
                    </relocations>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

And my command:

    Gui gui = Gui.gui()
            .title(Component.text("GUI Title!"))
            .rows(6)
            .create();

    gui.open(player);
    return true;

Im new, don't hit me :(

Add method to ItemBuilder

My suggestion is to add a method enchants(Map<Enchantment, Integer> enchantments) to the ItemBuilder so you could prevent from doing something like that:

            ItemBuilder builder = ItemBuilder
                .from(type)
                .name(displayName)
                .lore(lore);

            enchantments.forEach(builder::enchant);

            GuiItem item = builder.asGuiItem();

and instead, allow to do something like this:

            GuiItem item = ItemBuilder
                .from(type)
                .name(displayName)
                .lore(lore)
                .enchants(enchantments)
                .asGuiItem();

I think it would be great to have that method since even ItemStack has a method to add a collection of enchantments. Also, unsafeEnchants() method which would ignore level restrictions should be added with the method above.

issues

this is my code and for some reason i get this error

[16:17:36 INFO]: Jonathan_Nathan issued server command: /bedit
[16:17:36 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'bedit' in plugin BlockLimiter v1.0.0
	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchCommand(CraftServer.java:897) ~[paper-1.18.1.jar:git-Paper-177]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2287) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2098) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2079) ~[?:?]
	at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[?:?]
	at net.minecraft.network.protocol.game.ServerboundChatPacket.a(ServerboundChatPacket.java:6) ~[?:?]
	at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[?:?]
	at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.1.jar:git-Paper-177]
	at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[?:?]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[?:?]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1413) ~[paper-1.18.1.jar:git-Paper-177]
	at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:189) ~[paper-1.18.1.jar:git-Paper-177]
	at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[?:?]
	at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1391) ~[paper-1.18.1.jar:git-Paper-177]
	at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1384) ~[paper-1.18.1.jar:git-Paper-177]
	at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[?:?]
	at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1362) ~[paper-1.18.1.jar:git-Paper-177]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1268) ~[paper-1.18.1.jar:git-Paper-177]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-177]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Material cannot be null
	at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[commons-lang-2.6.jar:2.6]
	at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:86) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:74) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:61) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:47) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
	at me.jonathan.BlockLimiter.gui.builder.item.ItemBuilder.from(ItemBuilder.java:75) ~[BlockLimiter-1.0.0.jar:?]
	at editor.editorgui.openEditor(editorgui.java:144) ~[BlockLimiter-1.0.0.jar:?]
	at me.jonathan.commands.Edit.onCommand(Edit.java:24) ~[BlockLimiter-1.0.0.jar:?]
	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
	... 21 more
	public static void openEditor(Player player) {
		FileConfiguration config = BlockLimiter.getInstance().getConfig();
		if (!config.getBoolean("in-game-editor.enabled")) return;
		// 18 >= 18
		List<String> list = BlockLimiter.getInstance().getConfig().getStringList("items");
		Gui gui = Gui.gui()
				.title(Component.translatable("BlockLimiter - Editor",TextColor.fromHexString("#000C3A")))
				.rows(rows())
				.disableAllInteractions()
				.create();

		
		Material nextpagemat = Material.getMaterial( config.getString("in-game-editor.nextpage.material"));
		Material prevpagemat = Material.getMaterial( config.getString("in-game-editor.prevpage.material"));
		Material exitmat = Material.getMaterial( config.getString("in-game-editor.exit.material"));
		Material blockermat = Material.getMaterial( config.getString("in-game-editor.blockers.material"));
		Material undefinedmat = Material.getMaterial( config.getString("in-game-editor.undefined.material"));
		
		if (nextpagemat == null) nextpagemat = Material.ARROW;
		if (prevpagemat == null) prevpagemat = Material.ARROW;
		if (exitmat == null) exitmat = Material.BARRIER;
		if (blockermat == null) blockermat = Material.PISTON;
		if (undefinedmat == null) undefinedmat = Material.BOOK;
		
		
		
		
		List<Integer> nextpage = Arrays.asList();
		List<Integer> blockers = Arrays.asList();
		List<Integer> prevpage = Arrays.asList();
		List<Integer> exit = Arrays.asList();
		List<Integer> undefined = Arrays.asList();
		switch (rows()) {
		case 3:
			blockers = Arrays.asList(9,10,11,12,13,14,15,16,17);
			prevpage = Arrays.asList(18);
			nextpage = Arrays.asList(26);
			exit =     Arrays.asList(22);
			undefined =Arrays.asList(23);
			break;
		case 4:
			blockers = Arrays.asList(18,19,20,21,22,23,24,25,26);
			prevpage = Arrays.asList(27);
			nextpage = Arrays.asList(35);
			exit =     Arrays.asList(31);
			undefined =Arrays.asList(32);
			break;
		case 5:
			blockers = Arrays.asList(27,28,29,30,31,32,33,34,35);
			prevpage = Arrays.asList(36);
			nextpage = Arrays.asList(44);
			exit =     Arrays.asList(40);
			undefined =Arrays.asList(41);
			break;
		case 6:
			blockers = Arrays.asList(36,37,38,39,40,41,42,43,44);
			prevpage = Arrays.asList(45);
			nextpage = Arrays.asList(53);
			exit =     Arrays.asList(49);
			undefined =Arrays.asList(50);
			break;
		default:
			break;
		}

		// next page button
		GuiItem nextpageb = ItemBuilder.from(nextpagemat).name(Component.text(" ")).asGuiItem(event -> {
			
		});
		gui.setItem(nextpage, nextpageb);
		
		// prev page button
		GuiItem prevpageb = ItemBuilder.from(prevpagemat).name(Component.text(" ")).asGuiItem(event -> {
			
		});
		gui.setItem(prevpage, prevpageb);
		
		// the pistons
		GuiItem blockersb = ItemBuilder.from(blockermat).name(Component.text(" ")).asGuiItem();
		gui.setItem(blockers, blockersb);
		
		// exit button
		GuiItem exitb = ItemBuilder.from(exitmat).name(Component.text(" ")).asGuiItem(event -> {
			
		});
		gui.setItem(exit, exitb);
		
		// undefined items button
		GuiItem undefinedb = ItemBuilder.from(undefinedmat).name(Component.text("")).asGuiItem(event -> {
			
		});
		gui.setItem(undefined, undefinedb);
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		for (int i = 0; i > list.size(); i++) {
			Bukkit.getLogger().warning(list.get(i));
			GuiItem guiItem = ItemBuilder.from(Material.STONE)
					.name(Component.text(list.get(i)))
					
					.asGuiItem(event -> {
						event.getWhoClicked().sendMessage("you clicked which means this is working");
						event.getClick().isLeftClick();
					});
			gui.addItem(guiItem);
		}
		if (gui.getGuiItems().size() >= 1) {
			gui.open(player);
		} else { player.sendMessage("There are no config items :(");}
	}

Add Sponge Support

I think the title speaks for itself, but I find this library perfect for the most part, but could definitely use Sponge support before utilizing fully.

add refresh inventory

Hello, I wanted to make a refreshing player counter, but when the player count changes, the item doesn't work

`Component.text` not showing up

Hello!

I've been dealing with this issue for awhile i am trying to use Component#text but it doesnt exist but in another project i have i use the same build and everything but it shows up

build

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>info.sokobot.Chamber</groupId>
  <artifactId>Chamber</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  

  <dependencies>
  
 <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.19-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    	<dependency>
 			<groupId>dev.triumphteam</groupId>
  			<artifactId>triumph-gui</artifactId>
  			<version>3.1.3</version>
		</dependency>
  </dependencies>
    	<repositories>
		<!-- This adds the Spigot Maven repository to the build -->
		<repository>
			<id>spigot-repo</id>
			<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
		</repository>
		<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
	</repositories>

<build>
<plugins>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.2.4</version>
    <configuration>
        <relocations>
            <relocation>
                <pattern>dev.triumphteam.gui</pattern>
                <shadedPattern>info.sokobot.chamber.Main</shadedPattern> <!-- Replace package here here -->
            </relocation>
        </relocations>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
        </execution>
    </executions>
</plugin>
</plugins>
</build>
</project>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.