-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for CMI and checking its API for AFK
- Loading branch information
Showing
4 changed files
with
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package me.staartvin.plugins.pluginlibrary.hooks; | ||
|
||
import com.Zrips.CMI.CMI; | ||
import com.Zrips.CMI.Containers.CMIUser; | ||
import me.staartvin.plugins.pluginlibrary.Library; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* CMI library, | ||
* <a href="https://www.spigotmc.org/resources/cmi-270-commands-insane-kits-portals-essentials-economy-mysql-sqlite-much-more.3742/">link</a>. | ||
* <p> | ||
* | ||
* @author Staartvin | ||
* | ||
*/ | ||
public class CMIHook extends LibraryHook { | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() | ||
*/ | ||
@Override | ||
public boolean isAvailable() { | ||
return this.getPlugin().getServer().getPluginManager().isPluginEnabled(Library.CMI.getInternalPluginName()); | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() | ||
*/ | ||
@Override | ||
public boolean hook() { | ||
// All api calls are done static, so there is no need to get the plugin | ||
// class. | ||
// We only check if the plugin is available. | ||
return isAvailable(); | ||
} | ||
|
||
/** | ||
* Check whether a user is AFK or not. | ||
* | ||
* @param uuid | ||
* UUID of the player to check. | ||
* @return true if the user is AFK, false otherwise. | ||
*/ | ||
public boolean isAFK(UUID uuid) { | ||
if (!this.isAvailable()) return false; | ||
|
||
CMIUser user = CMI.getInstance().getPlayerManager().getUser(uuid); | ||
|
||
if (user == null) return false; | ||
|
||
return user.isAfk(); | ||
} | ||
|
||
} |
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