-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
948ebf0
commit d1400fa
Showing
4 changed files
with
42 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 26 additions & 5 deletions
31
src/main/java/de/oliver/fancyholograms/storage/converter/HologramConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,44 @@ | ||
package de.oliver.fancyholograms.storage.converter; | ||
|
||
import de.oliver.fancyanalytics.api.events.Event; | ||
import de.oliver.fancyholograms.FancyHolograms; | ||
import de.oliver.fancyholograms.api.data.HologramData; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public interface HologramConverter { | ||
public abstract class HologramConverter { | ||
|
||
boolean canRunConverter(); | ||
public abstract @NotNull String getId(); | ||
|
||
public abstract boolean canRunConverter(); | ||
|
||
/** | ||
* Returns a list of converted holograms | ||
* @param spec Configuration of the hologram conversion | ||
* @return A list of converted holograms. | ||
*/ | ||
@NotNull List<HologramData> convert(@NotNull HologramConversionSession spec); | ||
protected abstract @NotNull List<HologramData> convertHolograms(@NotNull HologramConversionSession spec); | ||
|
||
default @NotNull List<String> getConvertableHolograms() { | ||
return List.of(); | ||
|
||
/** | ||
* Returns a list of converted holograms | ||
* @param spec Configuration of the hologram conversion | ||
* @return A list of converted holograms. | ||
*/ | ||
public final @NotNull List<HologramData> convert(@NotNull HologramConversionSession spec) { | ||
List<HologramData> converted = convertHolograms(spec); | ||
|
||
Event event = new Event("HologramsConverted") | ||
.withProperty("converter", getId()) | ||
.withProperty("target", spec.getTarget().getRegex().pattern()) | ||
.withProperty("amount", String.valueOf(converted.size())); | ||
FancyHolograms.get().getFancyAnalytics().sendEvent(event); | ||
|
||
return converted; | ||
} | ||
|
||
public @NotNull List<String> getConvertableHolograms() { | ||
return List.of(); | ||
} | ||
} |