mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2025-01-04 15:17:50 +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();
|
@NotNull Collection<Hologram> getHolograms();
|
||||||
|
|
||||||
|
void deleteHolograms();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 1
|
* @since 1
|
||||||
*/
|
*/
|
||||||
|
@ -163,7 +163,7 @@ public class HolographicDisplays extends FCommonsPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void load(ErrorCollector errorCollector) {
|
public void load(ErrorCollector errorCollector) {
|
||||||
internalHologramManager.clearAll();
|
internalHologramManager.deleteHolograms();
|
||||||
|
|
||||||
configManager.reloadStaticReplacements(errorCollector);
|
configManager.reloadStaticReplacements(errorCollector);
|
||||||
configManager.reloadMainSettings(errorCollector);
|
configManager.reloadMainSettings(errorCollector);
|
||||||
|
@ -71,6 +71,11 @@ class DefaultHolographicDisplaysAPI implements HolographicDisplaysAPI {
|
|||||||
return apiHologramManager.getHologramsByPlugin(plugin);
|
return apiHologramManager.getHologramsByPlugin(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteHolograms() {
|
||||||
|
apiHologramManager.deleteHologramsIf(apiHologram -> apiHologram.getCreatorPlugin().equals(plugin));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Collection<String> getRegisteredPlaceholders() {
|
public @NotNull Collection<String> getRegisteredPlaceholders() {
|
||||||
return placeholderRegistry.getRegisteredIdentifiers(plugin);
|
return placeholderRegistry.getRegisteredIdentifiers(plugin);
|
||||||
|
@ -12,6 +12,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public abstract class BaseHologramManager<H extends BaseHologram> {
|
public abstract class BaseHologramManager<H extends BaseHologram> {
|
||||||
|
|
||||||
@ -22,16 +23,27 @@ public abstract class BaseHologramManager<H extends BaseHologram> {
|
|||||||
holograms.add(hologram);
|
holograms.add(hologram);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<H> getHolograms() {
|
||||||
|
return unmodifiableHologramsView;
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteHologram(H hologram) {
|
public void deleteHologram(H hologram) {
|
||||||
hologram.setDeleted();
|
hologram.setDeleted();
|
||||||
holograms.remove(hologram);
|
holograms.remove(hologram);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<H> getHolograms() {
|
public void deleteHologramsIf(Predicate<H> condition) {
|
||||||
return unmodifiableHologramsView;
|
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();
|
Iterator<H> iterator = holograms.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
H hologram = iterator.next();
|
H hologram = iterator.next();
|
||||||
|
Loading…
Reference in New Issue
Block a user