-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
2 changed files
with
20 additions
and
15 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
27 changes: 14 additions & 13 deletions
27
src/main/java/com/github/imdmk/spenttime/placeholder/PlaceholderRegistry.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,26 +1,27 @@ | ||
package com.github.imdmk.spenttime.placeholder; | ||
|
||
import com.github.imdmk.spenttime.placeholder.implementation.SpentTimeFormattedPlaceholder; | ||
import com.github.imdmk.spenttime.placeholder.implementation.SpentTimePlaceholder; | ||
import org.bukkit.plugin.PluginDescriptionFile; | ||
import me.clip.placeholderapi.expansion.PlaceholderExpansion; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class PlaceholderRegistry { | ||
|
||
private final SpentTimeFormattedPlaceholder spentTimeFormattedPlaceholder; | ||
private final SpentTimePlaceholder spentTimePlaceholder; | ||
private final Set<PlaceholderExpansion> placeholderExpansions = new HashSet<>(); | ||
|
||
public void register(PlaceholderExpansion placeholder) { | ||
this.placeholderExpansions.add(placeholder); | ||
|
||
public PlaceholderRegistry(PluginDescriptionFile pluginDescriptionFile) { | ||
this.spentTimeFormattedPlaceholder = new SpentTimeFormattedPlaceholder(pluginDescriptionFile); | ||
this.spentTimePlaceholder = new SpentTimePlaceholder(pluginDescriptionFile); | ||
placeholder.register(); | ||
} | ||
|
||
public void registerAll() { | ||
this.spentTimeFormattedPlaceholder.register(); | ||
this.spentTimePlaceholder.register(); | ||
public void unregister(PlaceholderExpansion placeholderExpansion) { | ||
this.placeholderExpansions.remove(placeholderExpansion); | ||
|
||
placeholderExpansion.unregister(); | ||
} | ||
|
||
public void unregisterAll() { | ||
this.spentTimeFormattedPlaceholder.unregister(); | ||
this.spentTimePlaceholder.unregister(); | ||
this.placeholderExpansions.forEach(this::unregister); | ||
} | ||
} |