Last contribution to dungeon

Continuing from my last blog, I will be contributing to dungeon once again.


From my last blog, I mention how I ran into a problem with project setup which was later filed as an issue. I will tackle this issue quickly since this fix doesn’t seem to be a long one. One of the test fails if you have spaces in the project directory name. For some reason, the test reads the path as C:\Users\Paul%20Luu\Documents\GitHub\dungeon instead of C:\Users\Paul Luu\Documents\GitHub\dungeon. Looking up the issue I found a stackoverflow answer that was relevant to this problem. Using URLDecoder and formatting the path into UTF-8 we are able to get the correct path. The final code is like this:

resourcesDir = new File(URLDecoder.decode(resourcesUrl.getFile(), "UTF-8"));

URLDecoder also throws an exception UnsupportedEncodingException so we also catch this in the function:

public void initialize() throws Exception {

Instead of using try and catch we are able to use the throws keyword and stick it to the function. The caller of the function must use a try and catch. More information on guru99. I created a pull request and am waiting a for a respond. Now onto the main issue. Updated: The maintainer pointed my in a more better solution using URI instead URLDecoder , more details on the pull request.

Issue

Looking through the issues once again, the issues left over all seem for hard to implement. Most issues left for this project are enchantment that will need a lot of changes to implement.


The issue I chose was to implement “Better exploration-based achievements “, I have written a blog about a previous pull request that involves exploration achievement for this project. Since I work on exploration achievements before, I thought this would be a little bit easier to implement, but it wasn’t.

Implementation

Implementing this functionality was the hardest pull request I have done so far. Even though I have worked on this project for a while, I don’t understand how everything works in the project. This implementation touches a lot of different files, forcing me to try and understand how these modules connect together. Since this is a massive code change I don’t expect it to get merge right away, I may need to break this down into smaller PR or come up with better solutions.


Listing the functionality I will need to implement to get this working:

  • Currently, the achievements don’t have the functionality to check what part of the day the user discovers a new location.
  • Functionality for reading the achievement.json information for the new achievements.
  • Retrieving a list of distinct locations by part of day and returning the amount
  • Modify test to work with new functionality.
  • Extra functions to support the above functionality. (For example, Getters, Setters, etc)

It took me weeks to implement all these functionalities, there were times where I was stuck (Taking breaks in between really helped). I also had the problem of my IDE (IntelliJ IDEA) not giving me stack-traces, so I had to manually trace with System.out.println (Luckily, I have done this before a long time ago so I was able to solve find out what was causing problems). There was less googling for implementing these functionality, I mostly had to read/understand the code I was modifying. The end result is:

For more information see the pull request.

Pull request

After all the work, I finally was able to finish the pull request. I tired my best to explain what I did, but since the code change was massive it was pretty hard. Currently, I am waiting for the maintainer to respond. Most likely this pull request will not be merge, and I will need to create another pull request.

Responds from the maintainer

The maintainer responded with a review that asks for code changes. Most of the code changes are just coding standard issues. For more information see pull request. Fixing my code, I wait for the maintainer to respond to my new commit. I squash the commits to make the reviewing/git history easier for the maintainer.

Links:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s