Klasse ZenithAPI
This API provides access to all functionality of the Zenith-Mod plugin, including moderation tools, player management, and module access.
To obtain an instance of this API, use getInstance().
Example usage:
// Get the API instance
ZenithAPI api = ZenithAPI.getInstance();
// Check if API is available
if (api != null && api.isAvailable()) {
// Use the API
String version = api.getVersion();
ZenithMod plugin = api.getPlugin();
}
- Seit:
- 1.2.3
- Autor:
- Zenith-Studios
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibung@NotNull AltLimitAPIGets the alt limit API instance.@NotNull BanAPIGets the ban API instance.@NotNull BanTemplateAPIGets the ban template API instance.@NotNull ChatFreezeAPIGets the chat freeze API instance.@NotNull EssentialsAPIGets the essentials API instance.@NotNull FreezeAPIGets the freeze API instance.@NotNull HistoryAPIGets the history API instance.static @Nullable ZenithAPIGets the singleton instance of the Zenith-API.@NotNull IPAPIgetIPAPI()Gets the IP API instance.@NotNull KickAPIGets the kick API instance.@NotNull MuteAPIGets the mute API instance.@NotNull MuteTemplateAPIGets the mute template API instance.@NotNull NotesAPIGets the notes API instance.@NotNull me.kzlyth.ZenithModGets the plugin instance associated with this API.@NotNull PunishmentStatusAPIGets the punishment status API instance.@NotNull StatisticsAPIGets the statistics API instance.@NotNull UserInfoAPIGets the user info API instance.@NotNull VanishAPIGets the vanish API instance.@NotNull StringGets the version of the plugin.@NotNull WarnAPIGets the warn API instance.@NotNull WarnTemplateAPIGets the warn template API instance.booleanChecks if the API is available and the plugin is enabled.
-
Methodendetails
-
getInstance
Gets the singleton instance of the Zenith-API.Returns
nullif the plugin is not loaded or enabled.Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api == null) { getLogger().warning("Zenith-Mod API is not available!"); return; }- Gibt zurück:
- The API instance, or
nullif not available
-
getPlugin
@NotNull public @NotNull me.kzlyth.ZenithMod getPlugin()Gets the plugin instance associated with this API.Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { ZenithMod plugin = api.getPlugin(); // Use plugin instance for advanced operations }- Gibt zurück:
- The ZenithMod plugin instance
-
isAvailable
public boolean isAvailable()Checks if the API is available and the plugin is enabled.Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null && api.isAvailable()) { // API is ready to use String version = api.getVersion(); }- Gibt zurück:
trueif the API is available,falseotherwise
-
getVersion
Gets the version of the plugin.Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { String version = api.getVersion(); getLogger().info("Zenith-Mod version: " + version); // Output: "Zenith-Mod version: 1.2.3" }- Gibt zurück:
- The plugin version as a string (e.g., "1.2.3")
-
getAltLimitAPI
Gets the alt limit API instance.The alt limit API provides methods to retrieve custom alt limits for players and access the default alt limit from the configuration.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { AltLimitAPI altLimitAPI = api.getAltLimitAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); altLimitAPI.getAltLimit(uuid).thenAccept(altLimit -> { int effectiveLimit = altLimit != null ? altLimit : altLimitAPI.getDefaultAltLimit(); getLogger().info("Effective alt limit: " + effectiveLimit); }); }- Gibt zurück:
- The alt limit API instance
-
getUserInfoAPI
Gets the user info API instance.The user info API provides methods to retrieve user information including UUID, player name, IP addresses, timestamps, and active case information.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { UserInfoAPI userInfoAPI = api.getUserInfoAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); userInfoAPI.getUser(uuid).thenAccept(user -> { if (user != null) { getLogger().info("Player: " + user.getPlayerName()); getLogger().info("Latest IP: " + user.getLatestIp()); } }); }- Gibt zurück:
- The user info API instance
-
getIPAPI
Gets the IP API instance.The IP API provides methods to check IP ban status, mute status, and retrieve active cases associated with IP addresses.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { IPAPI ipAPI = api.getIPAPI(); ipAPI.isIpBanned("192.168.1.1").thenAccept(banned -> { if (banned) { getLogger().info("IP is banned"); } }); }- Gibt zurück:
- The IP API instance
-
getStatisticsAPI
Gets the statistics API instance.The statistics API provides access to specialized sub-APIs for different types of statistics:
- Global statistics - total users, punishments, bans, mutes, warns, kicks, notes
- User statistics - punishments received by a user
- Staff statistics - punishments given by a staff member
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { StatisticsAPI statisticsAPI = api.getStatisticsAPI(); // Get global statistics GlobalStatisticsAPI globalStats = statisticsAPI.getGlobalStatistics(); globalStats.getTotalUsers().thenAccept(total -> { getLogger().info("Total registered users: " + total); }); // Get user statistics UserStatisticsAPI userStats = statisticsAPI.getUserStatistics(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); userStats.getPunishmentCount(uuid).thenAccept(count -> { getLogger().info("User has " + count + " total punishments"); }); // Get staff statistics StaffStatisticsAPI staffStats = statisticsAPI.getStaffStatistics(); staffStats.getPunishmentsGiven(uuid).thenAccept(count -> { getLogger().info("Staff member has given " + count + " punishments"); }); }- Gibt zurück:
- The statistics API instance
-
getHistoryAPI
Gets the history API instance.The history API provides methods to retrieve punishment history entries including complete history, history by type, by date range, by case ID, active punishments, and by staff member.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { HistoryAPI historyAPI = api.getHistoryAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); // Get complete history historyAPI.getHistory(uuid).thenAccept(history -> { getLogger().info("User has " + history.size() + " history entries"); }); // Get active punishments historyAPI.getActiveHistory(uuid).thenAccept(active -> { getLogger().info("User has " + active.size() + " active punishments"); }); // Get history by type historyAPI.getHistoryByType(uuid, "BAN").thenAccept(bans -> { getLogger().info("User has been banned " + bans.size() + " times"); }); // Get history by case ID historyAPI.getHistoryByCaseId(123).thenAccept(entry -> { if (entry != null) { getLogger().info("Case #" + entry.getCaseId() + ": " + entry.getPunishmentType()); } }); }- Gibt zurück:
- The history API instance
-
getNotesAPI
Gets the notes API instance.The notes API provides methods to manage player notes including creating, retrieving, searching, and deleting notes.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { NotesAPI notesAPI = api.getNotesAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); // Get all notes for a player notesAPI.getNotes(uuid).thenAccept(notes -> { getLogger().info("Player has " + notes.size() + " notes"); }); // Add a new note notesAPI.addNote(uuid, "Player was caught cheating", "Admin").thenAccept(success -> { if (success) { getLogger().info("Note added successfully"); } }); // Search notes by content notesAPI.searchNotesByContent("cheating").thenAccept(results -> { getLogger().info("Found " + results.size() + " notes containing 'cheating'"); }); // Get notes by staff member notesAPI.getNotesByStaff("Admin").thenAccept(notes -> { getLogger().info("Staff member has created " + notes.size() + " notes"); }); // Get notes from last 7 days notesAPI.getNotesSinceDays(7).thenAccept(notes -> { getLogger().info("Found " + notes.size() + " notes in the last 7 days"); }); }- Gibt zurück:
- The notes API instance
-
getPunishmentStatusAPI
Gets the punishment status API instance.The punishment status API provides methods to check if players are banned, muted, IP-banned, or IP-muted, as well as retrieve active punishment information and case IDs.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { PunishmentStatusAPI statusAPI = api.getPunishmentStatusAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); // Check if player is banned statusAPI.isBanned(uuid).thenAccept(banned -> { if (banned) { getLogger().info("Player is banned"); } }); // Check if player is muted statusAPI.isMuted(uuid).thenAccept(muted -> { if (muted) { getLogger().info("Player is muted"); } }); // Get complete punishment status statusAPI.getPunishmentStatus(uuid).thenAccept(status -> { if (status != null && status.hasActivePunishment()) { getLogger().info("Player has an active punishment"); if (status.getActiveBanCase() != null) { getLogger().info("Active ban case: " + status.getActiveBanCase()); } if (status.getActiveMuteCase() != null) { getLogger().info("Active mute case: " + status.getActiveMuteCase()); } } }); // Get active punishment by type statusAPI.getActivePunishment(uuid, "BAN").thenAccept(entry -> { if (entry != null) { getLogger().info("Active ban: " + entry.getReason()); } }); // Check for any active punishment statusAPI.hasActivePunishment(uuid).thenAccept(hasPunishment -> { if (hasPunishment) { getLogger().info("Player has an active punishment"); } }); }- Gibt zurück:
- The punishment status API instance
-
getKickAPI
Gets the kick API instance.The kick API provides methods to kick players from the server. All kicks are automatically recorded in the history database with a case ID.
Important Notes:
- Players must be online to be kicked
- Players with the
zenith.kick.bypasspermission cannot be kicked - All kicks are recorded in the history database (zn_history)
- Each kick receives a unique case ID
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { KickAPI kickAPI = api.getKickAPI(); UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); // Kick a player with a reason kickAPI.kick(playerUuid, staffUuid, "Inappropriate behavior").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player kicked successfully. Case ID: " + caseId); } else { getLogger().warning("Failed to kick player (player may be offline or have bypass permission)"); } }); // Kick a player from console (no staff member) kickAPI.kick(playerUuid, "Server maintenance").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player kicked by console. Case ID: " + caseId); } }); // Kick with additional data String additionalData = "{\"source\":\"api\",\"custom_field\":\"value\"}"; kickAPI.kick(playerUuid, staffUuid, "Inappropriate behavior", additionalData).thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player kicked with additional data. Case ID: " + caseId); } }); }- Gibt zurück:
- The kick API instance
-
getBanAPI
Gets the ban API instance.The ban API provides methods to ban players (regular and IP bans), ban using templates (custom bans with escalation support), and unban players. All bans are automatically recorded in the history database with a case ID.
Features:
- Regular bans and IP bans
- Template-based bans with escalation support
- Online and offline player banning
- Unban functionality
- Custom duration formats (e.g., "1d", "2h", "30m", "permanent")
Important Notes:
- Players with the
zenith.ban.bypasspermission cannot be banned - All bans are recorded in the history database (zn_history)
- Each ban receives a unique case ID
- Templates support escalation (duration increases with repeat offenses)
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { BanAPI banAPI = api.getBanAPI(); UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); // Regular ban with duration banAPI.ban(playerUuid, staffUuid, "Cheating", "7d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player banned successfully. Case ID: " + caseId); } }); // IP ban banAPI.ipBan(playerUuid, staffUuid, "Cheating", "30d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player IP banned successfully. Case ID: " + caseId); } }); // Ban using template (with escalation) banAPI.banWithTemplate(playerUuid, staffUuid, "cheating", "Using hacks").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player banned with template. Case ID: " + caseId); } }); // Unban banAPI.unban(playerUuid, staffUuid, "Appeal accepted").thenAccept(success -> { if (success) { getLogger().info("Player unbanned successfully"); } }); }- Gibt zurück:
- The ban API instance
-
getBanTemplateAPI
Gets the ban template API instance.The ban template API provides methods to access ban template information, check offense levels, calculate template results with escalation, and query template availability.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { BanTemplateAPI templateAPI = api.getBanTemplateAPI(); // Get all templates templateAPI.getAllTemplates().thenAccept(templates -> { getLogger().info("Available templates: " + templates.size()); for (BanTemplate template : templates) { getLogger().info("Template: " + template.getName() + " (" + template.getKey() + ")"); } }); // Get specific template templateAPI.getTemplate("cheating").thenAccept(template -> { if (template != null) { getLogger().info("Template: " + template.getName()); getLogger().info("Auto IP ban: " + template.isAutoIpBan()); getLogger().info("Duration levels: " + template.getDurations().size()); } }); // Check offense level for a player UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); templateAPI.getOffenseLevel(playerUuid, "cheating").thenAccept(level -> { getLogger().info("Player offense level: " + level); }); // Calculate template result (with escalation) templateAPI.getTemplateResult(playerUuid, "cheating", "Using hacks").thenAccept(result -> { if (result != null) { getLogger().info("Would ban for: " + result.getFormattedDuration()); getLogger().info("Reason: " + result.getReason()); getLogger().info("Offense level: " + result.getOffenseLevel()); } }); }- Gibt zurück:
- The ban template API instance
-
getMuteTemplateAPI
Gets the mute template API instance.The mute template API provides methods to access mute template information, check offense levels, calculate template results with escalation, and query template availability.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { MuteTemplateAPI templateAPI = api.getMuteTemplateAPI(); // Get all templates templateAPI.getAllTemplates().thenAccept(templates -> { getLogger().info("Available templates: " + templates.size()); for (MuteTemplate template : templates) { getLogger().info("Template: " + template.getName() + " (" + template.getKey() + ")"); } }); // Get specific template templateAPI.getTemplate("spam").thenAccept(template -> { if (template != null) { getLogger().info("Template: " + template.getName()); getLogger().info("Auto IP mute: " + template.isAutoIpMute()); getLogger().info("Duration levels: " + template.getDurations().size()); } }); // Check offense level for a player UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); templateAPI.getOffenseLevel(playerUuid, "spam").thenAccept(level -> { getLogger().info("Player offense level: " + level); }); // Calculate template result (with escalation) templateAPI.getTemplateResult(playerUuid, "spam", "Spamming in chat").thenAccept(result -> { if (result != null) { getLogger().info("Would mute for: " + result.getFormattedDuration()); getLogger().info("Reason: " + result.getReason()); getLogger().info("Offense level: " + result.getOffenseLevel()); } }); }- Gibt zurück:
- The mute template API instance
-
getWarnTemplateAPI
Gets the warn template API instance.The warn template API provides methods to access warn template information and query template availability. Warn templates are simpler than ban/mute templates as they don't have duration levels.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { WarnTemplateAPI templateAPI = api.getWarnTemplateAPI(); // Get all templates templateAPI.getAllTemplates().thenAccept(templates -> { getLogger().info("Available templates: " + templates.size()); for (WarnTemplate template : templates) { getLogger().info("Template: " + template.getName() + " - " + template.getReason()); } }); // Get specific template templateAPI.getTemplate("toxicity").thenAccept(template -> { if (template != null) { getLogger().info("Template: " + template.getName()); getLogger().info("Reason: " + template.getReason()); getLogger().info("Description: " + template.getDescription()); getLogger().info("Has escalation: " + template.hasEscalation()); } }); // Get template reason templateAPI.getTemplateReason("toxicity").thenAccept(reason -> { if (reason != null) { getLogger().info("Template reason: " + reason); } }); }- Gibt zurück:
- The warn template API instance
-
getMuteAPI
Gets the mute API instance.The mute API provides methods to mute players (regular and IP mutes), mute using templates (custom mutes), and unmute players. All mutes are automatically recorded in the history database with a case ID.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { MuteAPI muteAPI = api.getMuteAPI(); UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); // Regular mute with duration muteAPI.mute(playerUuid, staffUuid, "Spam", "7d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player muted successfully. Case ID: " + caseId); } }); // IP mute muteAPI.ipMute(playerUuid, staffUuid, "Toxicity", "30d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player IP muted successfully. Case ID: " + caseId); } }); // Mute using template (with escalation) muteAPI.muteWithTemplate(playerUuid, staffUuid, "spam", "Spamming in chat").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player muted with template. Case ID: " + caseId); } }); // Unmute muteAPI.unmute(playerUuid, staffUuid, "Appeal accepted").thenAccept(success -> { if (success) { getLogger().info("Player unmuted successfully"); } }); }- Gibt zurück:
- The mute API instance
-
getWarnAPI
Gets the warn API instance.The warn API provides methods to warn players manually or using templates (custom warns). All warnings are automatically recorded in the history database with a case ID.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { WarnAPI warnAPI = api.getWarnAPI(); UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); // Manual warn warnAPI.warn(playerUuid, staffUuid, "Toxic behavior").thenAccept(success -> { if (success) { getLogger().info("Player warned successfully"); } }); // Warn using template warnAPI.warnWithTemplate(playerUuid, staffUuid, "toxicity").thenAccept(success -> { if (success) { getLogger().info("Player warned with template successfully"); } }); }- Gibt zurück:
- The warn API instance
-
getFreezeAPI
Gets the freeze API instance.The freeze API provides methods to freeze and unfreeze players. All freeze actions are automatically recorded in the history database with a case ID, and staff notifications are automatically sent.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { FreezeAPI freezeAPI = api.getFreezeAPI(); UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); // Freeze a player freezeAPI.freeze(playerUuid, staffUuid, "Investigation").thenAccept(success -> { if (success) { getLogger().info("Player frozen successfully"); } }); // Unfreeze a player freezeAPI.unfreeze(playerUuid, staffUuid, "Investigation complete").thenAccept(success -> { if (success) { getLogger().info("Player unfrozen successfully"); } }); // Check if player is frozen freezeAPI.isFrozen(playerUuid).thenAccept(frozen -> { if (frozen) { getLogger().info("Player is frozen"); } }); // Get all frozen players freezeAPI.getFrozenPlayers().thenAccept(frozenPlayers -> { getLogger().info("Currently frozen players: " + frozenPlayers.size()); }); }- Gibt zurück:
- The freeze API instance
-
getChatFreezeAPI
Gets the chat freeze API instance.The chat freeze API provides methods to freeze and unfreeze the entire server chat. When the chat is frozen, all players (except those with the bypass permission) are prevented from sending chat messages. All actions are automatically recorded in the history database with a case ID, and player notifications are sent if configured.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { ChatFreezeAPI chatFreezeAPI = api.getChatFreezeAPI(); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); // Freeze the chat chatFreezeAPI.freezeChat(staffUuid, "Server announcement incoming").thenAccept(success -> { if (success) { getLogger().info("Chat frozen successfully"); } }); // Check if chat is frozen chatFreezeAPI.isChatFrozen().thenAccept(frozen -> { if (frozen) { getLogger().info("Chat is currently frozen"); } }); // Unfreeze the chat chatFreezeAPI.unfreezeChat(staffUuid, "Server announcement complete").thenAccept(success -> { if (success) { getLogger().info("Chat unfrozen successfully"); } }); }- Gibt zurück:
- The chat freeze API instance
-
getEssentialsAPI
Gets the essentials API instance.The essentials API provides methods to manage player essentials like god mode, fly mode, healing, feeding, clearing inventories, and teleportation. All actions support staff notifications.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { EssentialsAPI essentialsAPI = api.getEssentialsAPI(); UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); // Set god mode essentialsAPI.setGodMode(playerUuid, staffUuid, true).thenAccept(success -> { if (success) { getLogger().info("God mode enabled"); } }); // Heal player essentialsAPI.heal(playerUuid, staffUuid).thenAccept(success -> { if (success) { getLogger().info("Player healed"); } }); // Teleport player UUID destinationUuid = UUID.fromString("987e6543-e21b-12d3-a456-426614174999"); essentialsAPI.teleport(playerUuid, destinationUuid, staffUuid).thenAccept(success -> { if (success) { getLogger().info("Player teleported"); } }); }- Gibt zurück:
- The essentials API instance
-
getVanishAPI
Gets the vanish API instance.The vanish API provides methods to make players invisible (vanished) or visible again. When a player is vanished, they are hidden from other players (except those with the see permission), and staff notifications are automatically sent if configured.
Example:
ZenithAPI api = ZenithAPI.getInstance(); if (api != null) { VanishAPI vanishAPI = api.getVanishAPI(); UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); // Vanish player vanishAPI.vanish(playerUuid).thenAccept(success -> { if (success) { getLogger().info("Player vanished"); } }); // Check if vanished vanishAPI.isVanished(playerUuid).thenAccept(vanished -> { if (vanished) { getLogger().info("Player is vanished"); } }); // Unvanish player vanishAPI.unvanish(playerUuid).thenAccept(success -> { if (success) { getLogger().info("Player unvanished"); } }); // Get all vanished players vanishAPI.getVanishedPlayers().thenAccept(vanishedPlayers -> { getLogger().info("Currently vanished players: " + vanishedPlayers.size()); }); }- Gibt zurück:
- The vanish API instance
-