-
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.
Added PlaceholdersAPI support & custom placeholders
- Loading branch information
Showing
18 changed files
with
465 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
### Java ### | ||
# Compiled class file | ||
*.class | ||
|
||
# classpath | ||
*.classpath | ||
|
||
# project | ||
*.project | ||
|
||
# iml files | ||
*.iml | ||
|
||
# prefs files | ||
*.prefs | ||
|
||
# jar files | ||
*.jar | ||
|
||
# target folder | ||
target/ | ||
|
||
# .idea folder | ||
.idea/ | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* |
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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/lielamar/auth/bukkit/TwoFactorAuthenticationPlaceholders.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,47 @@ | ||
package com.lielamar.auth.bukkit; | ||
|
||
import com.lielamar.auth.shared.utils.TimeUtils; | ||
import me.clip.placeholderapi.expansion.PlaceholderExpansion; | ||
import org.bukkit.entity.Player; | ||
|
||
public class TwoFactorAuthenticationPlaceholders extends PlaceholderExpansion { | ||
|
||
private final TwoFactorAuthentication plugin; | ||
|
||
public TwoFactorAuthenticationPlaceholders(TwoFactorAuthentication plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
|
||
@Override | ||
public String getIdentifier() { | ||
return "2FA"; | ||
} | ||
|
||
@Override | ||
public String getAuthor() { | ||
return plugin.getDescription().getAuthors().get(0); | ||
} | ||
|
||
@Override | ||
public String getVersion() { | ||
return plugin.getDescription().getVersion(); | ||
} | ||
|
||
|
||
@Override | ||
public String onPlaceholderRequest(Player player, String identifier) { | ||
switch(identifier.toLowerCase()) { | ||
case "is_enabled": | ||
return plugin.getAuthHandler().is2FAEnabled(player.getUniqueId()) ? "Enabled" : "Disabled"; | ||
case "time_since_enabled": | ||
return TimeUtils.parseTime(System.currentTimeMillis() - plugin.getAuthHandler().getStorageHandler().getEnableDate(player.getUniqueId())); | ||
case "key": | ||
return plugin.getAuthHandler().getStorageHandler().getKey(player.getUniqueId()); | ||
case "is_required": | ||
return player.hasPermission("2fa.demand") ? "Required" : "Not Required"; | ||
} | ||
|
||
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
17 changes: 14 additions & 3 deletions
17
src/main/java/com/lielamar/auth/bukkit/handlers/MessageHandler.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
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
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
Oops, something went wrong.