Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 08:02:50 +02:00
synchronize char blocks
Dieser Commit ist enthalten in:
Ursprung
e661652c12
Commit
3f92f12e89
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.bukkit.adapter.mc1_14;
|
package com.boydti.fawe.bukkit.adapter.mc1_14;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
@ -210,6 +211,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateGet(BukkitGetBlocks_1_14 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
|
private void updateGet(BukkitGetBlocks_1_14 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
|
||||||
|
checkNotNull(arr);
|
||||||
synchronized (get) {
|
synchronized (get) {
|
||||||
if (this.nmsChunk != nmsChunk) {
|
if (this.nmsChunk != nmsChunk) {
|
||||||
this.nmsChunk = nmsChunk;
|
this.nmsChunk = nmsChunk;
|
||||||
|
@ -16,7 +16,6 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
public static final Section EMPTY = new Section() {
|
public static final Section EMPTY = new Section() {
|
||||||
@Override
|
@Override
|
||||||
public final char[] get(CharBlocks blocks, int layer) {
|
public final char[] get(CharBlocks blocks, int layer) {
|
||||||
blocks.sections[layer] = FULL;
|
|
||||||
char[] arr = blocks.blocks[layer];
|
char[] arr = blocks.blocks[layer];
|
||||||
if (arr == null) {
|
if (arr == null) {
|
||||||
arr = blocks.blocks[layer] = blocks.update(layer, null);
|
arr = blocks.blocks[layer] = blocks.update(layer, null);
|
||||||
@ -25,6 +24,14 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
blocks.blocks[layer] = blocks.update(layer, arr);
|
blocks.blocks[layer] = blocks.update(layer, arr);
|
||||||
|
if (blocks.blocks[layer] == null) {
|
||||||
|
throw new IllegalStateException("Array cannot be null (update): " + blocks.getClass());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
synchronized (this) {
|
||||||
|
if (blocks.blocks[layer] != null) {
|
||||||
|
blocks.sections[layer] = FULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
@ -32,11 +39,6 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
public final char[][] blocks;
|
public final char[][] blocks;
|
||||||
public final Section[] sections;
|
public final Section[] sections;
|
||||||
|
|
||||||
public CharBlocks(CharBlocks other) {
|
|
||||||
this.blocks = other.blocks;
|
|
||||||
this.sections = other.sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CharBlocks() {
|
public CharBlocks() {
|
||||||
blocks = new char[16][];
|
blocks = new char[16][];
|
||||||
sections = new Section[16];
|
sections = new Section[16];
|
||||||
@ -49,8 +51,12 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
public boolean trim(boolean aggressive) {
|
public boolean trim(boolean aggressive) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
if (sections[i] == EMPTY) {
|
if (sections[i] == EMPTY && blocks[i] != null) {
|
||||||
blocks[i] = null;
|
synchronized (this) {
|
||||||
|
if (sections[i] == EMPTY && blocks[i] != null) {
|
||||||
|
blocks[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,11 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean trim(boolean aggressive) {
|
public boolean trim(boolean aggressive) {
|
||||||
for (int i = 0; i < 16; i++) {
|
synchronized (this) {
|
||||||
sections[i] = EMPTY;
|
for (int i = 0; i < 16; i++) {
|
||||||
blocks[i] = null;
|
sections[i] = EMPTY;
|
||||||
|
blocks[i] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren