-
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
1 parent
10325c8
commit 7b657e7
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...taff-Paper/src/main/java/com/nookure/staff/paper/placeholder/PlaceholderApiExtension.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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.nookure.staff.paper.placeholder; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.Injector; | ||
import com.nookure.staff.Constants; | ||
import com.nookure.staff.api.placeholder.Placeholder; | ||
import com.nookure.staff.api.placeholder.PlaceholderManager; | ||
import me.clip.placeholderapi.expansion.PlaceholderExpansion; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Optional; | ||
import java.util.stream.Stream; | ||
|
||
public class PlaceholderApiExtension extends PlaceholderExpansion { | ||
@Inject | ||
private PlaceholderManager placeholderManager; | ||
@Inject | ||
private Injector in; | ||
public static final String IDENTIFIER = "nkstaff"; | ||
|
||
@Override | ||
public @NotNull String getIdentifier() { | ||
return IDENTIFIER; | ||
} | ||
|
||
@Override | ||
public @NotNull String getAuthor() { | ||
return "Angelillo15"; | ||
} | ||
|
||
@Override | ||
public @NotNull String getVersion() { | ||
return Constants.VERSION; | ||
} | ||
|
||
@Override | ||
public boolean register() { | ||
Stream.of( | ||
ServerCountPlaceholder.class, | ||
StaffCountPlaceholder.class, | ||
StaffModePlaceholder.class, | ||
VanishPlaceholder.class | ||
).forEach(p -> placeholderManager.registerPlaceholder(in.getInstance(p))); | ||
|
||
return super.register(); | ||
} | ||
|
||
@Override | ||
public String onPlaceholderRequest(Player player, @NotNull String params) { | ||
Optional<Placeholder> placeholder = placeholderManager.getPlaceholder(params); | ||
|
||
if (placeholder.isEmpty()) return "Not found"; | ||
|
||
return placeholder.get().onPlaceholderRequest(player, params); | ||
} | ||
} |