-
Notifications
You must be signed in to change notification settings - Fork 4
API
egg82 edited this page Jun 12, 2019
·
1 revision
The developer API is fairly simple and straight-forward, so I'll leave you with some basic documentation and some examples.
To include the plugin into your Maven project, just use the repository and link below.
<repository>
<id>egg82-ninja</id>
<url>https://www.myget.org/F/egg82-java/maven/</url>
</repository>
Link to latest version is available here.
Make sure to use <scope>provided</scope>
when adding the dependency!
Get the API instance.
ExternalAPI api = ExternalAPI.getInstance();
API methods
long getCurrentSQLTime() throws APIException;
void addPlayerData(UUID uuid, String ip, String server) throws APIException;
void removePlayerData(UUID uuid) throws APIException;
void removePlayerData(String ip) throws APIException;
Set<PlayerData> getPlayerData(UUID uuid) throws APIException;
Set<PlayerData> getPlayerData(String ip) throws APIException;
for (PlayerData data : api.getPlayerData(playerIp)) {
data.getUUID();
data.getIP();
data.getCount();
data.getServer();
data.getCreated();
data.getUpdated();
}
Find alts (get all UUIDs logged into all IPs that a specified UUID has ever logged in on)
ExternalAPI api = ExternalAPI.getInstance();
try {
Set<PlayerData> uuidData = api.getPlayerData(uuid);
Set<PlayerData> altData = new HashSet<>(uuidData);
for (PlayerData data : uuidData) {
altData.addAll(api.getPlayerData(data.getIP()));
}
altData.removeIf(v -> uuid.equals(v.getUUID())); // This now contains all potential alts, minus the original uuid that was searched for
} catch (APIException ex) {
// Handle exception
}
emulate Essentials /seen
ExternalAPI api = ExternalAPI.getInstance();
try {
Set<PlayerData> data = api.getPlayerData(ip);
for (PlayerData d : data) {
getName(d.getUUID());
}
List<PlayerData> sorted = new ArrayList<>(data);
sorted.sort(Comparator.comparingLong(PlayerData::getCreated));
if (data.isEmpty()) {
sender.sendMessage("No players have logged in from " + ip);
} else {
for (PlayerData data : sorted) {
String name = getName(data.getUUID());
sender.sendMessage("Player: " + (name != null ? ChatColor.GREEN + name : ChatColor.RED + "UNKNOWN"));
sender.sendMessage(" - First seen: " + getTime(data.getCreated(), api.getCurrentSQLTime()) + " ago");
sender.sendMessage(" - Last seen: " + getTime(data.getUpdated(), api.getCurrentSQLTime()) + " ago on " + data.getServer());
sender.sendMessage(" - IP Login Count: " + data.getCount());
}
}
} catch (APIException ex) {
// Handle exception
}
- Home
- Why AltFinder?
- Installation
- Usage
- Configuration
- Commands
- Permissions
- FAQ
- Errors
- Plugin Support
- PLAN