-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 advanced chunk monitoring system #3499
Fix advanced chunk monitoring system #3499
Conversation
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor tweaks suggested, but the cleanup appears solid and I can confirm the game exits cleanly 👍
|
||
add(tabs, BorderLayout.CENTER); | ||
} | ||
|
||
/** | ||
* This method goes through three steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to start any Javadoc with a brief single sentence describing the overall goal of the method, then optionally dig into the details later. First sentence gets used in the summary box in the Javadoc site, which in this case would thus end up solely containing "This method goes through three steps:" :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Fixed! :-)
private final transient Runnable renderTask; | ||
|
||
/** | ||
* If true, the active monitoring thread in executor service should stop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the one-line format here since it is a field and tiny
* If true, the active monitoring thread in executor service should stop. | |
/** If true, the active monitoring thread in executor service should stop. */ |
(Trying out the new GitHub "Suggestion" feature, but it originates in one line yet my suggestion replaces three lines - hmm)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -105,13 +104,18 @@ public ChunkMonitorDisplay(int refreshInterval, int chunkSize) { | |||
addMouseListener(ml); | |||
addMouseMotionListener(ml); | |||
addMouseWheelListener(ml); | |||
this.followPlayer = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the removal of setFollowPlayer
this var itself might be obsolete since there's no way to change it. Probably either keep the setter in expectation that it'll be added as a toggle in the UI sometime or just remove it entirely :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to keep the setter, so we can open an issue to add that new UI functionality.
public static final Color COLOR_INVALID = Color.red; | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(ChunkMonitorDisplay.class); | ||
private static final Logger LOGGER = LoggerFactory.getLogger(ChunkMonitorDisplay.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All caps logger or not is a tricky subject. See https://stackoverflow.com/questions/1417190/should-a-static-final-logger-be-declared-in-upper-case - generally we've kept it lower case so probably best to stay consistent that way, at least for now :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, according to Java Code Style is should be lower-case. I changed it after CheckStyle scan, however CheckStyle cannot check if this object reference is never followed by a ".".
@@ -694,12 +631,12 @@ private void renderSelectedChunk(Graphics2D g, int offsetx, int offsety, Vector3 | |||
} | |||
|
|||
private void renderBox(Graphics2D g, int offsetx, int offsety, Rectangle box) { | |||
g.setColor(Color.white); | |||
g.setColor(Color.WHITE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case change on the other hand is definitely good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 😃
|
||
/** | ||
* If true, the active monitoring thread in executor service should stop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another could-be one-liner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
Hooray Jenkins reported success with all tests good! |
5 similar comments
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
9b7393e
to
d1c5439
Compare
Hooray Jenkins reported success with all tests good! |
All good, thanks! :-) |
Contains
Fixes #3010. The goal here is to fix the problem of preventing the game from close cleanly. After dive into the code I realize that the Thread created by
ExecutorService
inThreadMonitorPanel
,PerformanceMonitorPanel
andChunkMonitorDisplay
keeps running after the game closes. Therefore, I changed a little the way thread monitors work. Also the whole monitor code were cleaned up.To fix the problem I created a variable called
stopThread
for each of the three monitors. IfstopThread
istrue
then the monitor thread leaves the loop and the executor service is shutdown, which will allow the game to close gracefully.How to test
"monitoringEnabled": false
, totrue
inconfig.cfg
(run the game once to get one).