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

Fix "illegal data type conversion to int" and change BANNED_PACKETS to HashSet #961

Merged
2 commits merged into from
May 17, 2022

Conversation

4Benj
Copy link
Member

@4Benj 4Benj commented May 17, 2022

Description

When DebugMode is set to MISSING (Not tested with ALL), an error (listed below) because PacketOpcodesUtil was expecting everything inside PacketOpcodes to be an int. However, it found a list causing the error below. This list was added in #582 and must have went unnoticed until now.

After a request from Melledy, I have also changed BANNED_PACKETS from a List to a HashSet

java.lang.IllegalArgumentException: Attempt to get java.util.List field "emu.grasscutter.net.packet.PacketOpcodes.BANNED_PACKETS" with illegal data type conversion to int
        at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.newGetIllegalArgumentException(UnsafeFieldAccessorImpl.java:69)
        at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.newGetIntIllegalArgumentException(UnsafeFieldAccessorImpl.java:132)
        at java.base/jdk.internal.reflect.UnsafeQualifiedStaticObjectFieldAccessorImpl.getInt(UnsafeQualifiedStaticObjectFieldAccessorImpl.java:58)
        at java.base/java.lang.reflect.Field.getInt(Field.java:601)
        at emu.grasscutter.net.packet.PacketOpcodesUtil.<clinit>(PacketOpcodesUtil.java:22)
        at emu.grasscutter.server.game.GameServerPacketHandler.handle(GameServerPacketHandler.java:98)
        at emu.grasscutter.server.game.GameSession.onMessage(GameSession.java:250)
        at emu.grasscutter.netty.KcpChannel.channelRead(KcpChannel.java:43)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
        at io.jpower.kcp.netty.UkcpServerChannel$UkcpServerUnsafe.read(UkcpServerChannel.java:603)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:833)

Please carefully read the Contributing note and Code of conduct before making any pull requests.
And, Do not make a pull request to merge into stable unless it is a hotfix. Use the development branch instead.

Issues fixed by this PR

No related issues within the issue tracker (from what I could see anyway). However, look at the description for the issue that is being fixed by this PR.

Type of changes

  • Bug fix
  • New feature
  • Enhancement
  • Documentation

Checklist:

  • My code follows the style guidelines of this project
  • My pull request is unique and no other pull requests have been opened for these changes
  • I have read the Contributing note and Code of conduct
  • I am responsible for any copyright issues with my code if it occurs in the future.

@4Benj 4Benj changed the title Fix "Attempt to get java.util.List field 'PacketOpcodes.BANNED_PACKETS' with illegal data type conversion to int" Fix "illegal data type conversion to int" and change BANNED_PACKETS to HashSet May 17, 2022
@ghost ghost merged commit aca3795 into Grasscutters:development May 17, 2022
This pull request was closed.
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 this pull request may close these issues.

None yet

1 participant