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

IllegalArgumentException when using a paginated gui #84

Closed
superbiebel opened this issue Aug 21, 2020 · 4 comments · Fixed by #112
Closed

IllegalArgumentException when using a paginated gui #84

superbiebel opened this issue Aug 21, 2020 · 4 comments · Fixed by #112

Comments

@superbiebel
Copy link

i had an IllegalArgumentException when opening a paginated gui and i think it is caused by this:
Schermafbeelding 2020-08-21 om 14 45 24
As you can see there the material names are not valid. this is in the StandardSchemeMappings class.

Here is the error:
[22:47:54] [Server thread/ERROR]: [PunishmentManager] [EVENTS] Exception thrown whilst handling event: org.bukkit.event.inventory.InventoryClickEvent
[22:47:54] [Server thread/WARN]: java.lang.NoSuchFieldError: STAINED_GLASS_PANE
[22:47:54] [Server thread/WARN]: at me.lucko.helper.menu.scheme.StandardSchemeMappings.(StandardSchemeMappings.java:41)
[22:47:54] [Server thread/WARN]: at me.lucko.helper.menu.scheme.MenuScheme.(MenuScheme.java:52)
[22:47:54] [Server thread/WARN]: at me.lucko.helper.menu.scheme.MenuScheme.(MenuScheme.java:58)
[22:47:54] [Server thread/WARN]: at me.lucko.helper.menu.paginated.PaginatedGuiBuilder.(PaginatedGuiBuilder.java:52)
[22:47:54] [Server thread/WARN]: at me.superbiebel.punishmentmanager.menusystem.menu.ActionsListGUI.lambda$redraw$0(ActionsListGUI.java:46)
[22:47:54] [Server thread/WARN]: at me.lucko.helper.menu.SimpleSlot.handle(SimpleSlot.java:70)
[22:47:54] [Server thread/WARN]: at me.lucko.helper.menu.Gui.lambda$startListening$10(Gui.java:357)
[22:47:54] [Server thread/WARN]: at me.lucko.helper.utils.Delegates$ConsumerToBiConsumerSecond.accept(Delegates.java:147)
[22:47:54] [Server thread/WARN]: at me.lucko.helper.event.functional.single.HelperEventListener.execute(HelperEventListener.java:133)
[22:47:54] [Server thread/WARN]: at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
[22:47:54] [Server thread/WARN]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
[22:47:54] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.PlayerConnection.a(PlayerConnection.java:2423)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.PacketPlayInWindowClick.a(SourceFile:32)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.PacketPlayInWindowClick.a(SourceFile:10)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:23)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.TickTask.run(SourceFile:18)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.MinecraftServer.aZ(MinecraftServer.java:1137)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.MinecraftServer.executeNext(MinecraftServer.java:1130)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.executeAll(IAsyncTaskHandler.java:95)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.MinecraftServer.a(MinecraftServer.java:1266)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:1001)
[22:47:54] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$a$0(MinecraftServer.java:177)
[22:47:54] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:832)

@DynamicField
Copy link
Contributor

This is because helper doesn't support the new materials introduced in minecraft 1.13.
There is a workaround though (phew), you can straight up use the standalone helper plugin and put it inside your plugins folder. Remember to not shade the helper library into your plugin.

@conclube
Copy link

If you now want to use those classes shaded you might want to fork helper and add support for libraries like XSeries. Else go with what @jeuxjeux20 said.

@superbiebel
Copy link
Author

I’ll try to use the standalone version of the plugin, and I really hope it works, cuz I do not want to reinvent the wheel by writing a paginated gui from scratch. Thank you both for ur fast response.

@Stijn-van-Nieulande
Copy link

Stijn-van-Nieulande commented Oct 13, 2020

(Sorry for the very late response)
I had the same problem and I cloned the project and modified the StandardSchemeMappings to work with 1.13+.

public final class StandardSchemeMappings
{
    public static final List<String> COLOR_MAPPINGS = Collections.unmodifiableList(Arrays.asList("WHITE", "ORANGE", "MAGENTA", "LIGHT_BLUE", "YELLOW", "LIME", "PINK", "GRAY", "LIGHT_GRAY", "CYAN", "PURPLE", "BLUE", "BROWN", "GREEN", "RED", "BLACK"));
    public static final List<Material> REMAPPED_STAINED_GLASS_PANE = Collections.unmodifiableList(COLOR_MAPPINGS.stream().map(s -> Material.getMaterial(s + "_STAINED_GLASS_PANE")).collect(Collectors.toList()));
    public static final List<Material> REMAPPED_STAINED_GLASS = Collections.unmodifiableList(COLOR_MAPPINGS.stream().map(s -> Material.getMaterial(s + "_STAINED_GLASS")).collect(Collectors.toList()));
    public static final List<Material> REMAPPED_TERRACOTTA = Collections.unmodifiableList(COLOR_MAPPINGS.stream().map(s -> Material.getMaterial(s + "_TERRACOTTA")).collect(Collectors.toList()));
    public static final List<Material> REMAPPED_WOOL = Collections.unmodifiableList(COLOR_MAPPINGS.stream().map(s -> Material.getMaterial(s + "_WOOL")).collect(Collectors.toList()));

    public static final SchemeMapping EMPTY = new EmptySchemeMapping();
    private static final Range<Integer> COLORED_MATERIAL_RANGE = Range.closed(0, 15);
    public static final SchemeMapping STAINED_GLASS = forColoredMaterial(REMAPPED_STAINED_GLASS_PANE);
    public static final SchemeMapping STAINED_GLASS_BLOCK = forColoredMaterial(REMAPPED_STAINED_GLASS);
    public static final SchemeMapping TERRACOTTA = forColoredMaterial(REMAPPED_TERRACOTTA);
    public static final SchemeMapping WOOL = forColoredMaterial(REMAPPED_WOOL);

    private StandardSchemeMappings()
    {
        throw new UnsupportedOperationException("This class cannot be instantiated");
    }

    private static SchemeMapping forColoredMaterial(List<Material> coloredMaterials)
    {
        return FunctionalSchemeMapping.of(
                data -> ItemStackBuilder.of(coloredMaterials.get(data)).name("&f").data(data).build(null),
                COLORED_MATERIAL_RANGE
        );
    }
}

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

Successfully merging a pull request may close this issue.

4 participants