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

More deobfuscation, code quality improvements, and Applet decoupling #130

Merged
merged 9 commits into from
Dec 31, 2024

Conversation

StenAL
Copy link

@StenAL StenAL commented Dec 28, 2024

This PR contains the following changes:

  • More deobfuscation
  • Minor code quality improvements suggested by IntelliJ. These are minor things that have bothered me when doing other work but have been small enough to not fix in other PRs so they're all grouped in one big commit here.
  • More decoupling from Applet APIs, mostly moving from getAppletContext().showDocument() to Desktop.browse(). This will enable completely dropping Applet from the codebase soon as there's only minor things remaining.

Copy link
Owner

@PhilippvK PhilippvK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for the efforts!

client/src/main/java/com/aapeli/applet/AdCanvasText.java Outdated Show resolved Hide resolved
- Unused static fields that are never set are removed
- Deobfuscated unused methods and constructors are removed
- Deobfuscated empty methods are removed
- Unused local variables are removed
- Identical catch clauses are combined
- For loops are converted into for-each loops
- Redundant variables are inlined
- Unused method parameters are removed
- The unused FileUtil class is removed
- The Stub inner class in Game is converted to static
- Redundant throws clauses are removed
- Large if-elses are converted to switch statements
- Unnecessary multiplications by 1.0D to cast to double are removed
Url opening with Desktop.browse()
This enables removing a dependency on Applet APIs which are deprecated
since Java 9. The browse API can only open URIs so this required
changing existing code to construct URIs instead of URLs.
The Applet API is deprecated since Java 9. There were two fields in
Parameters referencing the Applet host, documentBaseHost and
codeBaseHost, and both are safe to remove:
- codeBaseHost was used as a fallback for the server parameter, but
  since that is always set in Game, the field is not necessary
- documentBaseHost was used as a fallback for the sitename parameter,
  but that parameter is hardcoded to "playray" in Game so the field is
  not necessary
Applet APIs are deprecated since Java 9. Instead of using an AppletStub
to pass parameters to the applet, we can just construct a map and pass
that to the Parameters class.

This initially broke retrying a connection in case of server restarts
since previously the Parameters were constructed every time in AApplet's
run method but now they're only constructed once upon start-up. The
retries were fixed fixed by removing the nulling of the params field in
AApplet's destroy field.
This is no longer used.
The only place that uses the applet is TellFriendHandler and the method
it calls opens a pop-up and accepts any Java AWT component. Therefore,
it is safe to rename to applet field in Parameters is to rootComponent
to remove the coupling from the deprecated Applet class.
@PhilippvK PhilippvK merged commit 77f4aac into PhilippvK:master Dec 31, 2024
2 checks passed
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.

2 participants