forked from AuthMe/AuthMeReloaded
-
Notifications
You must be signed in to change notification settings - Fork 11
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
8 changed files
with
126 additions
and
2 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
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
71 changes: 71 additions & 0 deletions
71
src/main/java/fr/xephi/authme/service/hook/papi/AuthMeExpansion.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,71 @@ | ||
package fr.xephi.authme.service.hook.papi; | ||
|
||
import fr.xephi.authme.AuthMe; | ||
import fr.xephi.authme.api.v3.AuthMeApi; | ||
import fr.xephi.authme.settings.Settings; | ||
import fr.xephi.authme.settings.properties.HooksSettings; | ||
import me.clip.placeholderapi.expansion.PlaceholderExpansion; | ||
import org.bukkit.OfflinePlayer; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* AuthMe PlaceholderAPI expansion class. | ||
* @author Kobe 8 | ||
*/ | ||
public class AuthMeExpansion extends PlaceholderExpansion { | ||
private final Settings settings = AuthMe.settings; | ||
private final AuthMeApi authMeApi = AuthMeApi.getInstance(); | ||
@Override | ||
public @NotNull String getIdentifier() { | ||
return "authme"; | ||
} | ||
|
||
@Override | ||
public @NotNull String getAuthor() { | ||
return "HaHaWTH"; | ||
} | ||
|
||
@Override | ||
public @NotNull String getVersion() { | ||
return AuthMe.getPluginVersion(); | ||
} | ||
|
||
@Override | ||
public boolean persist() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String onRequest(OfflinePlayer player, @NotNull String params) { | ||
if (!settings.getProperty(HooksSettings.PLACEHOLDER_API)) return null; | ||
if (params.equalsIgnoreCase("version")) { | ||
return getVersion(); | ||
} | ||
if (params.equalsIgnoreCase("is_registered")) { | ||
if (player != null) { | ||
Player onlinePlayer = player.getPlayer(); | ||
if (onlinePlayer != null) { | ||
return String.valueOf(authMeApi.isRegistered(onlinePlayer.getName())); | ||
} | ||
} | ||
} | ||
if (params.equalsIgnoreCase("is_authenticated")) { | ||
if (player != null) { | ||
Player onlinePlayer = player.getPlayer(); | ||
if (onlinePlayer != null) { | ||
return String.valueOf(authMeApi.isAuthenticated(onlinePlayer)); | ||
} | ||
} | ||
} | ||
if (params.equalsIgnoreCase("last_login_time")) { | ||
if (player != null) { | ||
Player onlinePlayer = player.getPlayer(); | ||
if (onlinePlayer != null) { | ||
return authMeApi.getLastLoginTime(onlinePlayer.getName()).toString(); | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} |
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