Skip to content

Commit

Permalink
Fix: rendering npe (#356)
Browse files Browse the repository at this point in the history
* Update version number in build.gradle.kts

The version number in the build.gradle.kts file was updated from 2.6.0 to 2.6.1. This minor version update likely includes bug fixes or very small changes that do not substantially alter the functionality of the project.

* Refactor PacketWorker's remove method

The remove method in PacketWorker has been simplified. The comparison of player unique identifiers is now done in a single line, eliminating the repetitive and more complex boolean logic that existed before, making the code cleaner and easier to understand.

* Refactor resolveBlocked method in RenderService class

The resolveBlocked method in RenderService class has been refactored. We removed the process method and added the remove method from worker object, making the code easier to reason about. This also fixes the issue where playerSink object might not have been correctly updated before performing the remove operation.
  • Loading branch information
rainbowdashlabs authored Jan 26, 2024
1 parent 2804baf commit 296e82a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "de.eldoria"
version = "2.6.0"
version = "2.6.1"

var publishModules = setOf("schematicbrushreborn-api",
"schematicbrushreborn-core",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,7 @@ public void queue(RenderSink renderSink) {


public void remove(Player player) {
queue.removeIf(e -> e.sinkOwner().equals(player.getUniqueId()));
}

public void process(Player player) {
queue.removeIf(e -> {
if (e.sinkOwner().equals(player.getUniqueId())) {
e.sendChanges();
return true;
}
return false;
});
queue.removeIf(e -> e == null || e.sinkOwner().equals(player.getUniqueId()));
}

public int packetQueueCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public void onPrePaste(PrePasteEvent event) {
* @param player player to resolve
*/
private void resolveBlocked(Player player) {
worker.process(player);
RenderSink playerSink = getSink(player);
worker.remove(player);
// We push and send empty changes
playerSink.pushAndSend(null);
//getChanges(player).ifPresent(change -> new PaketWorker.ChangeEntry(player, change, null).sendChanges());
Expand Down

0 comments on commit 296e82a

Please sign in to comment.