mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
11
README.md
11
README.md
@ -52,6 +52,15 @@ https://ci.codemc.org/job/Games647/job/FastLogin/changes
|
|||||||
fastlogin.command.premium.other
|
fastlogin.command.premium.other
|
||||||
fastlogin.command.cracked.other
|
fastlogin.command.cracked.other
|
||||||
|
|
||||||
|
## Placeholder
|
||||||
|
|
||||||
|
This plugin supports `PlaceholderAPI` on `Spigot`. It exports the following variable
|
||||||
|
`%fastlogin_status%`. In BungeeCord environments, the status of a player will be delivered with a delay after the player
|
||||||
|
already successful joined the server. This takes about a couple of milliseconds. In this case the value
|
||||||
|
will be `Unknown`.
|
||||||
|
|
||||||
|
Possible values: `Premium`, `Cracked`, `Unknown`
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* Plugin:
|
* Plugin:
|
||||||
@ -59,7 +68,7 @@ https://ci.codemc.org/job/Games647/job/FastLogin/changes
|
|||||||
* [ProtocolSupport](https://www.spigotmc.org/resources/protocolsupport.7201/)
|
* [ProtocolSupport](https://www.spigotmc.org/resources/protocolsupport.7201/)
|
||||||
* [Spigot](https://www.spigotmc.org) 1.8.8+
|
* [Spigot](https://www.spigotmc.org) 1.8.8+
|
||||||
* Java 8+
|
* Java 8+
|
||||||
* Run Spigot and/or BungeeCord/Waterfall in offline mode (see server.properties or config.yml)
|
* Run Spigot (or a fork e.g. Paper) and/or BungeeCord (or a fork e.g. Waterfall) in offline mode
|
||||||
* An auth plugin. Supported plugins
|
* An auth plugin. Supported plugins
|
||||||
|
|
||||||
### Bukkit/Spigot/Paper
|
### Bukkit/Spigot/Paper
|
||||||
|
@ -89,8 +89,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
getCommand("cracked").setExecutor(new CrackedCommand(this));
|
getCommand("cracked").setExecutor(new CrackedCommand(this));
|
||||||
|
|
||||||
if (pluginManager.isPluginEnabled("PlaceholderAPI")) {
|
if (pluginManager.isPluginEnabled("PlaceholderAPI")) {
|
||||||
//prevents NoClassDef errors if it's not available
|
new PremiumPlaceholder(this).register();
|
||||||
PremiumPlaceholder.register(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package com.github.games647.fastlogin.bukkit;
|
package com.github.games647.fastlogin.bukkit;
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class PremiumPlaceholder extends PlaceholderExpansion {
|
public class PremiumPlaceholder extends PlaceholderExpansion {
|
||||||
|
|
||||||
private static final String PLACEHOLDER_VARIABLE = "fastlogin_status";
|
private static final String PLACEHOLDER_VARIABLE = "status";
|
||||||
|
|
||||||
private final FastLoginBukkit plugin;
|
private final FastLoginBukkit plugin;
|
||||||
|
|
||||||
@ -15,27 +14,23 @@ public class PremiumPlaceholder extends PlaceholderExpansion {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register(FastLoginBukkit plugin) {
|
|
||||||
PremiumPlaceholder placeholderHook = new PremiumPlaceholder(plugin);
|
|
||||||
PlaceholderAPI.registerPlaceholderHook(PLACEHOLDER_VARIABLE, placeholderHook);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String onPlaceholderRequest(Player player, String variable) {
|
public String onPlaceholderRequest(Player player, String identifier) {
|
||||||
if (player != null && PLACEHOLDER_VARIABLE.equals(variable)) {
|
// player is null if offline
|
||||||
return plugin.getStatus(player.getUniqueId()).name();
|
if (player != null && PLACEHOLDER_VARIABLE.equals(identifier)) {
|
||||||
|
return plugin.getStatus(player.getUniqueId()).getReadableName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
return PLACEHOLDER_VARIABLE;
|
return plugin.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlugin() {
|
public String getRequiredPlugin() {
|
||||||
return plugin.getName();
|
return plugin.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +41,6 @@ public class PremiumPlaceholder extends PlaceholderExpansion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return plugin.getName();
|
return plugin.getDescription().getVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,19 @@ package com.github.games647.fastlogin.core;
|
|||||||
|
|
||||||
public enum PremiumStatus {
|
public enum PremiumStatus {
|
||||||
|
|
||||||
PREMIUM,
|
PREMIUM("Premium"),
|
||||||
|
|
||||||
CRACKED,
|
CRACKED("Cracked"),
|
||||||
|
|
||||||
UNKNOWN
|
UNKNOWN("Unknown");
|
||||||
|
|
||||||
|
private final String readableName;
|
||||||
|
|
||||||
|
PremiumStatus(String readableName) {
|
||||||
|
this.readableName = readableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReadableName() {
|
||||||
|
return readableName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class RateLimiter {
|
|||||||
/**
|
/**
|
||||||
* Ask if access is allowed. If so register the request.
|
* Ask if access is allowed. If so register the request.
|
||||||
*
|
*
|
||||||
* @return true if allowed
|
* @return true if allowed - false otherwise without any side effects
|
||||||
*/
|
*/
|
||||||
public boolean tryAcquire() {
|
public boolean tryAcquire() {
|
||||||
// current time millis is not monotonic - it can jump back depending on user choice or NTP
|
// current time millis is not monotonic - it can jump back depending on user choice or NTP
|
||||||
|
Reference in New Issue
Block a user