Reduce complexity.

This commit is contained in:
tastybento 2024-03-15 18:49:20 -07:00
parent 91998b4e24
commit 6127cdced1
1 changed files with 24 additions and 19 deletions

View File

@ -237,6 +237,24 @@ 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()) {
pasteBlocksNow(it, count, pasteSpeed, useNMS);
} else {
if (pasteState.equals(PasteState.BLOCKS)) {
// Blocks done
// Next paste attachments
pasteState = PasteState.ATTACHMENTS;
} else {
// Attachments done. Next paste entities
pasteState = PasteState.ENTITIES;
if (bits.entities.size() != 0) {
owner.ifPresent(user -> user.sendMessage("commands.island.create.pasting.entities", TextVariables.NUMBER, String.valueOf(bits.entities.size())));
}
}
}
}
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) {
@ -256,19 +274,6 @@ public class BlueprintPaster {
currentTask = useNMS ? paster.pasteBlocks(island, world, blockMap)
: fallback.pasteBlocks(island, world, blockMap);
}
} else {
if (pasteState.equals(PasteState.BLOCKS)) {
// Blocks done
// Next paste attachments
pasteState = PasteState.ATTACHMENTS;
} else {
// Attachments done. Next paste entities
pasteState = PasteState.ENTITIES;
if (bits.entities.size() != 0) {
owner.ifPresent(user -> user.sendMessage("commands.island.create.pasting.entities", TextVariables.NUMBER, String.valueOf(bits.entities.size())));
}
}
}
}