Make BaseHologramLines implement Iterable

This commit is contained in:
filoghost 2021-08-08 16:42:01 +02:00
parent 9d70087130
commit 88bfa7c662
5 changed files with 11 additions and 10 deletions

View File

@ -37,7 +37,7 @@ public class CopyCommand extends HologramSubCommand {
InternalHologram toHologram = hologramEditor.getHologram(args[1]);
List<InternalHologramLine> clonedLines = new ArrayList<>();
for (InternalHologramLine line : fromHologram.getLines().getAll()) {
for (InternalHologramLine line : fromHologram.getLines()) {
clonedLines.add(hologramEditor.parseHologramLine(toHologram, line.getSerializedConfigValue()));
}

View File

@ -38,7 +38,7 @@ public class InfoCommand extends LineEditingCommand implements QuickEditCommand
DisplayFormat.sendTitle(sender, "Lines of the hologram '" + hologram.getName() + "'");
int index = 0;
for (InternalHologramLine line : hologram.getLines().getAll()) {
for (InternalHologramLine line : hologram.getLines()) {
index++;
sender.sendMessage(ColorScheme.SECONDARY_BOLD + index + ColorScheme.SECONDARY_DARKER + ". "
+ ColorScheme.SECONDARY + line.getSerializedConfigValue());

View File

@ -30,7 +30,7 @@ public class HologramConfig {
public HologramConfig(InternalHologram hologram) {
this.name = hologram.getName();
this.serializedLines = new ArrayList<>();
for (InternalHologramLine line : hologram.getLines().getAll()) {
for (InternalHologramLine line : hologram.getLines()) {
serializedLines.add(line.getSerializedConfigValue());
}

View File

@ -133,7 +133,7 @@ public class APIHologram extends BaseHologram implements Hologram {
}
this.allowPlaceholders = allowPlaceholders;
for (APIHologramLine line : lines.getAll()) {
for (APIHologramLine line : lines) {
line.setChanged();
}
}
@ -156,7 +156,7 @@ public class APIHologram extends BaseHologram implements Hologram {
double height = 0.0;
for (APIHologramLine line : lines.getAll()) {
for (APIHologramLine line : lines) {
height += line.getHeight();
}

View File

@ -12,7 +12,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class BaseHologramLines<T extends EditableHologramLine> {
public class BaseHologramLines<T extends EditableHologramLine> implements Iterable<T> {
private final BaseHologram hologram;
private final List<T> lines;
@ -24,6 +24,11 @@ public class BaseHologramLines<T extends EditableHologramLine> {
this.unmodifiableLinesView = Collections.unmodifiableList(lines);
}
@Override
public Iterator<T> iterator() {
return unmodifiableLinesView.iterator();
}
public int size() {
return lines.size();
}
@ -32,10 +37,6 @@ public class BaseHologramLines<T extends EditableHologramLine> {
return lines.isEmpty();
}
public List<T> getAll() {
return unmodifiableLinesView;
}
public T get(int index) {
return lines.get(index);
}