Fixes #1810: Removes a CompassReader once the world is unloaded.

This should no longer keep a reference to a World around and potentially
keep them loaded.
Also added a finalize() to CompassRegion to ensure the file is closed on a
GC.

Some cleanup regarding member order, final, etc
This commit is contained in:
yueh
2015-08-19 19:49:56 +02:00
committed by thatsIch
parent 851878cf18
commit 20a6e7631f
3 changed files with 162 additions and 123 deletions
@@ -55,10 +55,18 @@ public final class CompassReader
public void setHasBeacon( int cx, int cz, int cdy, boolean hasBeacon )
{
CompassRegion r = this.getRegion( cx, cz );
final CompassRegion r = this.getRegion( cx, cz );
r.setHasBeacon( cx, cz, cdy, hasBeacon );
}
public boolean hasBeacon( int cx, int cz )
{
final CompassRegion r = this.getRegion( cx, cz );
return r.hasBeacon( cx, cz );
}
private CompassRegion getRegion( int cx, int cz )
{
long pos = cx >> 10;
@@ -66,6 +74,7 @@ public final class CompassReader
pos |= ( cz >> 10 );
CompassRegion cr = this.regions.get( pos );
if( cr == null )
{
cr = new CompassRegion( cx, cz, this.dimensionId, this.worldCompassFolder );
@@ -74,10 +83,4 @@ public final class CompassReader
return cr;
}
public boolean hasBeacon( int cx, int cz )
{
CompassRegion r = this.getRegion( cx, cz );
return r.hasBeacon( cx, cz );
}
}