mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-29 20:27:42 +01:00
Add deleteHolograms method to API
This commit is contained in:
parent
087105ccd1
commit
ca5644153e
@ -72,6 +72,8 @@ public interface HolographicDisplaysAPI {
|
||||
*/
|
||||
@NotNull Collection<Hologram> getHolograms();
|
||||
|
||||
void deleteHolograms();
|
||||
|
||||
/**
|
||||
* @since 1
|
||||
*/
|
||||
|
@ -163,7 +163,7 @@ public class HolographicDisplays extends FCommonsPlugin {
|
||||
}
|
||||
|
||||
public void load(ErrorCollector errorCollector) {
|
||||
internalHologramManager.clearAll();
|
||||
internalHologramManager.deleteHolograms();
|
||||
|
||||
configManager.reloadStaticReplacements(errorCollector);
|
||||
configManager.reloadMainSettings(errorCollector);
|
||||
|
@ -71,6 +71,11 @@ class DefaultHolographicDisplaysAPI implements HolographicDisplaysAPI {
|
||||
return apiHologramManager.getHologramsByPlugin(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteHolograms() {
|
||||
apiHologramManager.deleteHologramsIf(apiHologram -> apiHologram.getCreatorPlugin().equals(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<String> getRegisteredPlaceholders() {
|
||||
return placeholderRegistry.getRegisteredIdentifiers(plugin);
|
||||
|
@ -12,6 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public abstract class BaseHologramManager<H extends BaseHologram> {
|
||||
|
||||
@ -22,16 +23,27 @@ public abstract class BaseHologramManager<H extends BaseHologram> {
|
||||
holograms.add(hologram);
|
||||
}
|
||||
|
||||
public List<H> getHolograms() {
|
||||
return unmodifiableHologramsView;
|
||||
}
|
||||
|
||||
public void deleteHologram(H hologram) {
|
||||
hologram.setDeleted();
|
||||
holograms.remove(hologram);
|
||||
}
|
||||
|
||||
public List<H> getHolograms() {
|
||||
return unmodifiableHologramsView;
|
||||
public void deleteHologramsIf(Predicate<H> condition) {
|
||||
Iterator<H> iterator = holograms.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
H hologram = iterator.next();
|
||||
if (condition.test(hologram)) {
|
||||
iterator.remove();
|
||||
hologram.setDeleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAll() {
|
||||
public void deleteHolograms() {
|
||||
Iterator<H> iterator = holograms.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
H hologram = iterator.next();
|
||||
|
Loading…
Reference in New Issue
Block a user