mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 10:45:22 +01:00
Reduce complexity.
This commit is contained in:
parent
91998b4e24
commit
6127cdced1
@ -237,25 +237,7 @@ public class BlueprintPaster {
|
||||
private void pasteBlocks(Bits bits, int count, Optional<User> owner, int pasteSpeed, boolean useNMS) {
|
||||
Iterator<Entry<Vector, BlueprintBlock>> it = pasteState.equals(PasteState.BLOCKS) ? bits.it : bits.it2;
|
||||
if (it.hasNext()) {
|
||||
Map<Location, BlueprintBlock> blockMap = new HashMap<>();
|
||||
// Paste blocks
|
||||
while (count < pasteSpeed) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
Entry<Vector, BlueprintBlock> entry = it.next();
|
||||
Location pasteTo = location.clone().add(entry.getKey());
|
||||
// pos1 and pos2 update
|
||||
updatePos(pasteTo);
|
||||
|
||||
BlueprintBlock block = entry.getValue();
|
||||
blockMap.put(pasteTo, block);
|
||||
count++;
|
||||
}
|
||||
if (!blockMap.isEmpty()) {
|
||||
currentTask = useNMS ? paster.pasteBlocks(island, world, blockMap)
|
||||
: fallback.pasteBlocks(island, world, blockMap);
|
||||
}
|
||||
pasteBlocksNow(it, count, pasteSpeed, useNMS);
|
||||
} else {
|
||||
if (pasteState.equals(PasteState.BLOCKS)) {
|
||||
// Blocks done
|
||||
@ -272,6 +254,29 @@ public class BlueprintPaster {
|
||||
|
||||
}
|
||||
|
||||
private void pasteBlocksNow(Iterator<Entry<Vector, BlueprintBlock>> it, int count, int pasteSpeed, boolean useNMS) {
|
||||
Map<Location, BlueprintBlock> blockMap = new HashMap<>();
|
||||
// Paste blocks
|
||||
while (count < pasteSpeed) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
Entry<Vector, BlueprintBlock> entry = it.next();
|
||||
Location pasteTo = location.clone().add(entry.getKey());
|
||||
// pos1 and pos2 update
|
||||
updatePos(pasteTo);
|
||||
|
||||
BlueprintBlock block = entry.getValue();
|
||||
blockMap.put(pasteTo, block);
|
||||
count++;
|
||||
}
|
||||
if (!blockMap.isEmpty()) {
|
||||
currentTask = useNMS ? paster.pasteBlocks(island, world, blockMap)
|
||||
: fallback.pasteBlocks(island, world, blockMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void loadChunk() {
|
||||
long timer = System.currentTimeMillis();
|
||||
pasteState = PasteState.CHUNK_LOADING;
|
||||
|
Loading…
Reference in New Issue
Block a user