Move removeLine method to Hologram instead of HologramLine
This commit is contained in:
parent
88bfa7c662
commit
36e1d44d18
|
@ -80,6 +80,15 @@ public interface Hologram {
|
|||
*/
|
||||
void removeLine(int index);
|
||||
|
||||
/**
|
||||
* Removes a line.
|
||||
*
|
||||
* @param line the line to be removed.
|
||||
* @return if the hologram contained the line
|
||||
* @since 1
|
||||
*/
|
||||
boolean removeLine(@NotNull HologramLine line);
|
||||
|
||||
/**
|
||||
* Removes all the lines from this hologram.
|
||||
*
|
||||
|
|
|
@ -22,12 +22,4 @@ public interface HologramLine {
|
|||
*/
|
||||
@NotNull Hologram getParent();
|
||||
|
||||
/**
|
||||
* Removes this line from the parent Hologram.
|
||||
* Do not call if the Hologram has been deleted, an exception will be thrown.
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
void removeLine();
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public abstract class V2HologramLineAdapter implements HologramLine {
|
|||
|
||||
@Override
|
||||
public void removeLine() {
|
||||
v3Line.removeLine();
|
||||
v3Line.getParent().removeLine(v3Line);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,7 @@ package me.filoghost.holographicdisplays.plugin.hologram.api;
|
|||
|
||||
import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
||||
import me.filoghost.holographicdisplays.api.hologram.HologramLine;
|
||||
import me.filoghost.holographicdisplays.api.hologram.HologramPosition;
|
||||
import me.filoghost.holographicdisplays.plugin.api.v2.V2HologramAdapter;
|
||||
import me.filoghost.holographicdisplays.plugin.config.Settings;
|
||||
|
@ -106,10 +107,15 @@ public class APIHologram extends BaseHologram implements Hologram {
|
|||
lines.remove(index);
|
||||
}
|
||||
|
||||
public void removeLine(APIHologramLine line) {
|
||||
@Override
|
||||
public boolean removeLine(HologramLine line) {
|
||||
checkNotDeleted();
|
||||
|
||||
lines.remove(line);
|
||||
if (line instanceof APIHologramLine) {
|
||||
return lines.remove((APIHologramLine) line);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,11 +17,6 @@ public interface APIHologramLine extends HologramLine, EditableHologramLine {
|
|||
|
||||
void setChanged();
|
||||
|
||||
@Override
|
||||
default void removeLine() {
|
||||
getParent().removeLine(this);
|
||||
}
|
||||
|
||||
V2HologramLineAdapter getV2Adapter();
|
||||
|
||||
}
|
||||
|
|
|
@ -85,12 +85,15 @@ public class BaseHologramLines<T extends EditableHologramLine> implements Iterab
|
|||
updateLinePositions();
|
||||
}
|
||||
|
||||
public void remove(T line) {
|
||||
public boolean remove(T line) {
|
||||
checkNotDeleted();
|
||||
|
||||
lines.remove(line);
|
||||
line.setDeleted();
|
||||
updateLinePositions();
|
||||
boolean removed = lines.remove(line);
|
||||
if (removed) {
|
||||
line.setDeleted();
|
||||
updateLinePositions();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
|
Loading…
Reference in New Issue