-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from XXY233/placeholder-api-support
add papi support
- Loading branch information
Showing
7 changed files
with
79 additions
and
0 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
39 changes: 39 additions & 0 deletions
39
src/main/java/io/github/schntgaispock/slimehud/placeholder/PlaceholderHook.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,39 @@ | ||
package io.github.schntgaispock.slimehud.placeholder; | ||
|
||
import io.github.schntgaispock.slimehud.SlimeHUD; | ||
import me.clip.placeholderapi.expansion.PlaceholderExpansion; | ||
import org.bukkit.entity.Player; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class PlaceholderHook extends PlaceholderExpansion { | ||
@Override | ||
public @Nonnull String getIdentifier() { | ||
return "slimehud"; | ||
} | ||
|
||
@Override | ||
public @Nonnull String getAuthor() { | ||
return "TheLittle_Yang"; | ||
} | ||
|
||
@Override | ||
public @Nonnull String getVersion() { | ||
return "1.0.0"; | ||
} | ||
|
||
@Override | ||
public boolean persist() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public @Nullable String onPlaceholderRequest(Player player, @Nonnull String params) { | ||
if (params.equalsIgnoreCase("toggle")) { | ||
return SlimeHUD.getInstance().getPlayerData().getString(player.getUniqueId() + ".waila", "true"); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/io/github/schntgaispock/slimehud/placeholder/PlaceholderManager.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,16 @@ | ||
package io.github.schntgaispock.slimehud.placeholder; | ||
|
||
import io.github.schntgaispock.slimehud.SlimeHUD; | ||
import org.bukkit.Bukkit; | ||
|
||
public class PlaceholderManager { | ||
public static void setup() { | ||
if (SlimeHUD.getInstance().getConfig().getBoolean("options.placeholder-api-support", true)) { | ||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { | ||
new PlaceholderHook().register(); | ||
} else { | ||
SlimeHUD.getInstance().getLogger().info("PlaceholderAPI is not installed and has been ignored."); | ||
} | ||
} | ||
} | ||
} |
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