mastercake10 / CustomOreGen

A simple yet powerful, fully customizable cobblestone generator for Bukkit
GNU General Public License v3.0
10 stars 11 forks source link

SuperiorSkyblock2 API - world list is immutable #51

Open CrypticzXI opened 1 year ago

CrypticzXI commented 1 year ago

What steps will reproduce the issue?

  1. Use with SuperiorSkyblock2 API

What was supposed to happen?

Line 56 of https://github.com/mastercake10/CustomOreGen/blob/dev/src/main/java/xyz/spaceio/hooks/HookSuperiorSkyblock.java should be able to add a new World from the visitor's spawn's World to the worlds List as defined on line 55.

What happened instead?

SuperiorSkyblock2 is setting the returned list of worlds to an immutable List, so on line 56 the add fails since the collection cannot be modified.

What version of this plugin are you using?

CustomOreGen 1.3.33

What Spigot version are you using? Paste the output of /version below.

git-Paper-1618 (MC:1.12.2)

What plugins do you have installed? Paste the output of /plugins below.

Plugins (63): ajLeaderboards, Anti-OP, Arconix, BarGamble, BlockParticles, BungeeGuard, ChatColorPlus, Citizens, CommandNPC, CrateReloaded, CrazyAuctions, DeluxeMenus, EffectLib, eGlow, Essentials, EssentialsSpawn, FastAsyncWorldEdit, FeatherBoard, HeadDatabase, HideStream, HolographicDisplays, HolographicExtension, JetsMinions, JFKey, KitGUI, LuckPerms, mcMMO, Multiverse-Core, MVdWPlaceholderAPI, NamelessMC, OnePlayerSleep, PlaceholderAPI, ProtocolLib, Quests, ReflexAPI, ServerRestorer, ShopGUIPlus, SilkSpawners, Skellett, Skript, StatsSB, SuperBoosters, SuperiorSkyblock2, SuperMobCoins, SuperPouches, SuperVanish, TAB, TitleManager, Vault, VentureChat, ViaBackwards, ViaVersion, VIPJoinMessage, VoteParty, Votifier, VotingPlugin, WildChests, WildStacker, WorldBorder, WorldEdit, WorldGuard, WorldGuardExtraFlags, XRequests

Are any errors related to this plugin in your console or logs? If so, paste below.

[02:34:03 ERROR]: Could not pass event BlockFromToEvent to CustomOreGen v1.3.33-SNAPSHOT-SNAPSHOT
org.bukkit.event.EventException: null
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:72) ~[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.BlockFlowing.b(BlockFlowing.java:142) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.WorldServer.a(WorldServer.java:793) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.WorldServer.doTick(WorldServer.java:324) ~[patched_1.12.2.jar:git-Paper-1618]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:905) ~[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:834) [?:?]
Caused by: java.lang.UnsupportedOperationException
        at java.util.AbstractList.add(AbstractList.java:153) ~[?:?]
        at java.util.AbstractList.add(AbstractList.java:111) ~[?:?]
        at xyz.spaceio.hooks.HookSuperiorSkyblock.getSkyBlockWorldNames(HookSuperiorSkyblock.java:56) ~[?:?]
        at xyz.spaceio.customoregen.CustomOreGen.getActiveWorlds(CustomOreGen.java:178) ~[?:?]
        at xyz.spaceio.customoregen.CustomOreGen.getGeneratorConfigForPlayer(CustomOreGen.java:249) ~[?:?]
        at xyz.spaceio.customoregen.Events.onFromTo(Events.java:118) ~[?:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor472.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[patched_1.12.2.jar:git-Paper-1618]
        ... 11 more

Any additional information that you would like to provide that may be relevant to the issue?

On line 55, wrap the results from the SuperiorSkyblock2 in a new ArrayList<>( ) and it will instead always be a mutable list, so line 56 will not fail.


    @Override
    public String[] getSkyBlockWorldNames() {

        List<World> worlds = new ArrayList<>( SuperiorSkyblockAPI.getGrid().getRegisteredWorlds() );
        worlds.add(SuperiorSkyblockAPI.getSpawnIsland().getVisitorsLocation().getWorld());

        return worlds.stream().map(w -> w.getName()).toArray(String[]::new);
    }
rbluer commented 1 year ago

CrypticzXI I found this bug too. The returned List collection is immuttable which causes the worlds.add() to fail.
Your solution looks like it will work fine. Thanks for submitting this report and I'm looking forward to the fix.