DevNatan / inventory-framework

Minecraft Inventory API framework
MIT License
128 stars 22 forks source link

v3.1.0-beta IllegalStateModificationException 1.20.4 #623

Closed ch4ika closed 9 months ago

ch4ika commented 9 months ago

Is there an existing issue for this?

🐛 Describe the bug

[20:24:55 INFO]: [InventoryFramework] [DEBUG] State value initialized in me.devnatan.inventoryframework.context.OpenContext (id = 13, initialValue = AbstractStateValue{internalId=13})
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF] Exception in command: plot settings
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF] me.devnatan.inventoryframework.state.IllegalStateModificationException: Immutable
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.state.AbstractStateValue.set(AbstractStateValue.java:28)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.state.InitialDataStateValue.set(InitialDataStateValue.java:47)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.pipeline.PlatformOpenInterceptor.lambda$createRenderContext$3(PlatformOpenInterceptor.java:99)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at java.base/java.util.HashMap.forEach(HashMap.java:1421)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.pipeline.PlatformOpenInterceptor.createRenderContext(PlatformOpenInterceptor.java:96)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.pipeline.PlatformOpenInterceptor.finishOpen(PlatformOpenInterceptor.java:58)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.pipeline.PlatformOpenInterceptor.intercept(PlatformOpenInterceptor.java:34)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.pipeline.PlatformOpenInterceptor.intercept(PlatformOpenInterceptor.java:14)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.pipeline.PipelineContext.loop(PipelineContext.java:43)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.pipeline.PipelineContext.proceed(PipelineContext.java:53)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.pipeline.PipelineContext.execute(PipelineContext.java:59)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.pipeline.Pipeline.execute(Pipeline.java:124)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.PlatformView.open(PlatformView.java:103)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.IFViewFrame.internalOpen(IFViewFrame.java:164)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.ViewFrame.open(ViewFrame.java:110)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//me.devnatan.inventoryframework.ViewFrame.open(ViewFrame.java:72)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//de.primecodes.plotadditions.command.PlotSquaredCommand.onSettings(PlotSquaredCommand.java:145)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimePlotAdditions-2.0.0-SNAPSHOT.jar//de.primecodes.plotadditions.command.PlotBaseCommand.onSettings(PlotBaseCommand.java:87)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimeCorePlugin-0.2.0-SNAPSHOT.jar//co.aikar.commands.RegisteredCommand.invoke(RegisteredCommand.java:152)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimeCorePlugin-0.2.0-SNAPSHOT.jar//co.aikar.commands.BaseCommand.executeCommand(BaseCommand.java:578)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimeCorePlugin-0.2.0-SNAPSHOT.jar//co.aikar.commands.BaseCommand.execute(BaseCommand.java:513)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimeCorePlugin-0.2.0-SNAPSHOT.jar//co.aikar.commands.RootCommand.execute(RootCommand.java:99)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at PrimeCorePlugin-0.2.0-SNAPSHOT.jar//co.aikar.commands.BukkitRootCommand.execute(BukkitRootCommand.java:84)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at org.bukkit.craftbukkit.v1_20_R3.CraftServer.dispatchCommand(CraftServer.java:987)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at org.bukkit.craftbukkit.v1_20_R3.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.commands.execution.tasks.ExecuteCommand.a(ExecuteCommand.java:32)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:19)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.commands.execution.UnboundEntryAction.a(UnboundEntryAction.java:8)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.commands.execution.CommandQueueEntry.a(CommandQueueEntry.java:5)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.commands.execution.ExecutionContext.a(ExecutionContext.java:101)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.commands.CommandDispatcher.a(CommandDispatcher.java:435)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.commands.CommandDispatcher.performCommand(CommandDispatcher.java:336)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.commands.CommandDispatcher.a(CommandDispatcher.java:323)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:2231)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.server.network.PlayerConnection.lambda$handleChatCommand$16(PlayerConnection.java:2191)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.util.thread.IAsyncTaskHandler.b(IAsyncTaskHandler.java:59)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.server.TickTask.run(TickTask.java:18)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.util.thread.IAsyncTaskHandler.d(IAsyncTaskHandler.java:153)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(IAsyncTaskHandlerReentrant.java:24)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1452)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:194)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.util.thread.IAsyncTaskHandler.x(IAsyncTaskHandler.java:126)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.server.MinecraftServer.bl(MinecraftServer.java:1429)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1352)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.util.thread.IAsyncTaskHandler.c(IAsyncTaskHandler.java:136)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.server.MinecraftServer.w_(MinecraftServer.java:1330)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1220)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321)
[20:24:55 ERROR]: [PrimePlotAdditions] [ACF]    at java.base/java.lang.Thread.run(Thread.java:840)
>

✔️ Expected behavior

No response

👣 Steps to Reproduce

package de.primecodes.plotadditions.view.setting;

import com.google.inject.Inject;
import com.plotsquared.core.plot.Plot;
import de.primecodes.core.api.message.IMessageService;
import de.primecodes.core.api.util.ItemBuilder;
import de.primecodes.plotadditions.common.CustomSound;
import de.primecodes.plotadditions.message.Message;
import de.primecodes.plotadditions.message.MultiMessage;
import de.primecodes.plotadditions.view.setting.description.PlotDescriptionView;
import de.primecodes.plotadditions.view.setting.title.PlotTitleView;
import de.primecodes.plotadditions.view.util.ViewUtils;
import me.devnatan.inventoryframework.View;
import me.devnatan.inventoryframework.ViewConfigBuilder;
import me.devnatan.inventoryframework.context.RenderContext;
import me.devnatan.inventoryframework.context.SlotClickContext;
import me.devnatan.inventoryframework.state.MutableState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

import java.util.Locale;
import java.util.Map;

public class PlotSettingsView extends View {

    private final IMessageService messageService;
    private final MutableState<Plot> plot = initialState("plot");

    @Inject
    public PlotSettingsView(IMessageService messageService) {
        this.messageService = messageService;
    }

    @Override
    public void onInit(@NotNull ViewConfigBuilder config) {
        config.title("Einstellungen");
        config.layout("GGGGGGGGG", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "GGGGGGGGG");
    }

    @Override
    public void onFirstRender(@NotNull RenderContext render) {
        Player player = render.getPlayer();
        Locale locale = player.locale();

        render.layoutSlot('X', ViewUtils.placeholder(Material.GRAY_STAINED_GLASS_PANE));
        render.layoutSlot('G', ViewUtils.placeholder(Material.BLACK_STAINED_GLASS_PANE));
        render.slot(3, 2, wall(locale)).onClick(this::onClickWall);
        render.slot(3, 4, interactions(locale)).onClick(this::onClickInteraction);
        render.slot(3, 6, titles(locale)).onClick(this::onClickTitles);
        render.slot(3, 8, biomes(locale)).onClick(this::onClickBiome);
        render.slot(4, 2, border(locale)).onClick(this::onClickBorder);
        render.slot(4, 4, description(locale)).onClick(this::onClickDescription);
        render.slot(4, 6, flags(locale)).onClick(this::onClickFlags);
        render.slot(4, 8, vegetation(locale)).onClick(this::onClickVegetation);
        render.slot(6, 5, delete(locale)).onClick(this::onClickDelete);
        render.slot(6, 0, ViewUtils.back(messageService, locale))
                .onClick(ViewUtils::onBack);
    }

    private void onClickWall(SlotClickContext context) {
        CustomSound.BUTTON.play(context.getPlayer());
        context.openForPlayer(PlotWallView.class, Map.of("plot", plot.get(context)));
    }

    private void onClickBorder(SlotClickContext context) {
        CustomSound.BUTTON.play(context.getPlayer());
        context.openForPlayer(PlotBorderView.class, Map.of("plot", plot.get(context)));
    }

    private void onClickBiome(SlotClickContext context) {
        CustomSound.BUTTON.play(context.getPlayer());
        context.openForPlayer(PlotBiomeView.class, Map.of("plot", plot.get(context)));
    }

    private void onClickVegetation(SlotClickContext context) {
        CustomSound.BUTTON.play(context.getPlayer());
        context.openForPlayer(PlotVegetationView.class, Map.of("plot", plot.get(context)));
    }

    private void onClickInteraction(SlotClickContext context) {
        CustomSound.BUTTON.play(context.getPlayer());
        context.openForPlayer(PlotInteractionView.class, Map.of("plot", plot.get(context)));
    }

    private void onClickTitles(SlotClickContext context) {
        CustomSound.BUTTON.play(context.getPlayer());
        context.openForPlayer(PlotTitleView.class, Map.of("plot", plot.get(context)));
    }

    private void onClickDescription(SlotClickContext context) {
        CustomSound.BUTTON.play(context.getPlayer());
        context.openForPlayer(PlotDescriptionView.class, Map.of("plot", plot.get(context)));
    }

    private void onClickFlags(SlotClickContext context) {
        CustomSound.BUTTON.play(context.getPlayer());
        context.openForPlayer(PlotFlagsView.class, Map.of("plot", plot.get(context)));
    }

    private void onClickDelete(SlotClickContext context) {
        CustomSound.BUTTON.play(context.getPlayer());
        context.openForPlayer(PlotDeleteView.class, Map.of("plot", plot.get(context)));
    }

    private ItemStack wall(Locale locale) {
        ItemBuilder item = new ItemBuilder(Material.POLISHED_BLACKSTONE_BRICK_WALL);
        item.setDisplayName(messageService.getMessage(Message.VIEW_WALLS, locale));
        item.setLore(messageService.getMultiMessage(MultiMessage.VIEW_WALL, locale));
        return item.build();
    }

    private ItemStack border(Locale locale) {
        ItemBuilder item = new ItemBuilder(Material.POLISHED_BLACKSTONE_BRICK_SLAB);
        item.setDisplayName(messageService.getMessage(Message.VIEW_BORDERS, locale));
        item.setLore(messageService.getMultiMessage(MultiMessage.VIEW_BORDER, locale));
        return item.build();
    }

    private ItemStack interactions(Locale locale) {
        ItemBuilder item = new ItemBuilder(Material.JUNGLE_DOOR);
        item.setDisplayName(messageService.getMessage(Message.VIEW_INTERACTION, locale));
        item.setLore(messageService.getMultiMessage(MultiMessage.VIEW_INTERACTION, locale));
        return item.build();
    }

    private ItemStack description(Locale locale) {
        ItemBuilder item = new ItemBuilder(Material.JUNGLE_HANGING_SIGN);
        item.setDisplayName(messageService.getMessage(Message.VIEW_DESCRIPTION, locale));
        item.setLore(messageService.getMultiMessage(MultiMessage.VIEW_DESCRIPTION, locale));
        return item.build();
    }

    private ItemStack flags(Locale locale) {
        ItemBuilder item = new ItemBuilder(Material.ARMOR_STAND);
        item.setDisplayName(messageService.getMessage(Message.VIEW_FLAGS, locale));
        item.setLore(messageService.getMultiMessage(MultiMessage.VIEW_FLAGS, locale));
        return item.build();
    }

    private ItemStack titles(Locale locale) {
        ItemBuilder item = new ItemBuilder(Material.NAME_TAG);
        item.setDisplayName(messageService.getMessage(Message.VIEW_TITLE, locale));
        item.setLore(messageService.getMultiMessage(MultiMessage.VIEW_TITLE, locale));
        return item.build();
    }

    private ItemStack biomes(Locale locale) {
        ItemBuilder item = new ItemBuilder(Material.SPYGLASS);
        item.setDisplayName(messageService.getMessage(Message.VIEW_BIOME, locale));
        item.setLore(messageService.getMultiMessage(MultiMessage.VIEW_BIOME, locale));
        return item.build();
    }

    private ItemStack vegetation(Locale locale) {
        ItemBuilder item = new ItemBuilder(Material.OAK_SAPLING);
        item.setDisplayName(messageService.getMessage(Message.VIEW_VEGETATION, locale));
        item.setLore(messageService.getMultiMessage(MultiMessage.VIEW_VEGETATION, locale));
        return item.build();
    }

    private ItemStack delete(Locale locale) {
        ItemBuilder item = new ItemBuilder(Material.LAVA_BUCKET);
        item.setDisplayName(messageService.getMessage(Message.VIEW_DELETE, locale));
        item.setLore(messageService.getMultiMessage(MultiMessage.VIEW_DELETE, locale));
        return item.build();
    }
}

💻 Platform

⭐ Server Version

1.20.4 paper

📚 Library Version

v3.1.0-beta

✍️ Additional context

No response