mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Simplify processor ordering (#2651)
This commit is contained in:
parent
c68544d66d
commit
8095111eff
@ -19,12 +19,9 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -80,28 +77,18 @@ public class MultiBatchProcessor implements IBatchProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||||
Map<Integer, Set<IBatchProcessor>> ordered = new HashMap<>();
|
Map<Integer, List<IBatchProcessor>> ordered = new HashMap<>();
|
||||||
IChunkSet chunkSet = set;
|
IChunkSet chunkSet = set;
|
||||||
for (IBatchProcessor processor : processors) {
|
for (IBatchProcessor processor : processors) {
|
||||||
if (processor.getScope() != ProcessorScope.ADDING_BLOCKS) {
|
if (processor.getScope() != ProcessorScope.ADDING_BLOCKS) {
|
||||||
ordered.merge(
|
ordered.computeIfAbsent(processor.getScope().intValue(), k -> new ArrayList<>())
|
||||||
processor.getScope().intValue(),
|
.add(processor);
|
||||||
new HashSet<>(Collections.singleton(processor)),
|
|
||||||
(existing, theNew) -> {
|
|
||||||
existing.add(processor);
|
|
||||||
return existing;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
chunkSet = processSet(processor, chunk, get, chunkSet);
|
chunkSet = processSet(processor, chunk, get, chunkSet);
|
||||||
}
|
}
|
||||||
if (ordered.size() > 0) {
|
if (!ordered.isEmpty()) {
|
||||||
for (int i = 1; i <= 4; i++) {
|
for (List<IBatchProcessor> processors : ordered.values()) {
|
||||||
Set<IBatchProcessor> processors = ordered.get(i);
|
|
||||||
if (processors == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (IBatchProcessor processor : processors) {
|
for (IBatchProcessor processor : processors) {
|
||||||
chunkSet = processSet(processor, chunk, get, chunkSet);
|
chunkSet = processSet(processor, chunk, get, chunkSet);
|
||||||
if (chunkSet == null) {
|
if (chunkSet == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user