Advertisement
aspiriamc

Untitled

Aug 23rd, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. Developer API
  2. AAC has an API, here it is:
  3. Spoiler: The API
  4.  
  5. PlayerViolationEvent: Called when a player is detected for hacking (extends PlayerEvent implements Cancellable)
  6. Code (Text):
  7. import me.konsolas.aac.api.PlayerViolationEvent;
  8.  
  9. import org.bukkit.Bukkit;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13.  
  14. public class HookAAC extends JavaPlugin implements Listener {
  15. public void onEnable() {
  16. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  17. }
  18.  
  19. @EventHandler
  20. public void onPlayerViolation(PlayerViolationEvent e) {
  21. System.out.println("PlayerViolationEvent:");
  22. System.out.println("Hack Type: " + e.getHackType());
  23. System.out.println("Player: "+ e.getPlayer().getName());
  24. System.out.println("Message: "+ e.getMessage());
  25. System.out.println("Violations in the last minute" + e.getViolations());
  26. // Cancellable
  27. e.setCancelled(true);
  28. }
  29. }
  30.  
  31. PlayerViolationCommandEvent: Called when AAC kicks a player. (extends PlayerEvent implements Cancellable)
  32. Code (Text):
  33.  
  34.  
  35. import me.konsolas.aac.api.PlayerViolationCommandEvent;
  36.  
  37. import org.bukkit.Bukkit;
  38. import org.bukkit.event.EventHandler;
  39. import org.bukkit.event.Listener;
  40. import org.bukkit.plugin.java.JavaPlugin;
  41.  
  42. public class HookAAC extends JavaPlugin implements Listener {
  43. public void onEnable() {
  44. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  45. }
  46.  
  47. @EventHandler
  48. public void onPlayerViolationCommand(PlayerViolationCommandEvent e) {
  49. System.out.println("PlayerViolationCommandEvent:");
  50. System.out.println("Hack Type: " + e.getHackType());
  51. System.out.println("Player: "+ e.getPlayer().getName());
  52. System.out.println("Command" + e.getCommand());
  53. // Set the command
  54. e.setCommand("broadcast example command");
  55.  
  56. // Cancellable
  57. e.setCancelled(true);
  58. }
  59. }
  60. AACAPI (me.konsolas.aac.api.AACAPI)
  61.  
  62.  
  63. AACAPI is the interface you can use to interact with AAC's internals when you want to. It's not as simple as it was previously, but it is a lot more extensive, and faster.
  64.  
  65. Getting the API
  66. You can retrieve an instance of AACAPI with AACAPIProvider.getAPI(). This will throw an APINotLoadedException if AAC has not finished enabling itself: AACAPIProvider.isAPILoaded() returns false. Please note that a lot of work is done after the server has started, so you may have to wait. After "AAC has been enabled" is printed in the console, you will be able to retrieve the API.
  67.  
  68. Methods
  69. void reloadAAC()
  70. Reload all of AAC's checks, and the configuration file. Equivalent to /aacreload in game.
  71.  
  72. void reloadPermissionCache()
  73. Reload AAC's permission cache for all online players. This forces any changes of the AAC.bypass permission to be noticed. Normally, this permission is refreshed every 20-40 seconds.
  74.  
  75. void invalidateMovementCaches()
  76. This resets all stored data for all movement checks. This includes ground locations, expected heights, rubber-band locations, rubber-band internals and phase data. Generally useful if part of a minigame (i.e. the start) makes players glitch.
  77.  
  78. void enableCheck(HackType hackType)
  79. Enable a check. HackType enum is self-explanatory.
  80.  
  81. void disableCheck(HackType hackType)
  82. Disable a check.
  83.  
  84. boolean isEnabled(HackType hackType)
  85. Returns whether a check is enabled.
  86.  
  87. boolean isBypassed(Player player)
  88. Returns whether a player (according to the internal cache - reloadPermissionCache) is exempt from checks.
  89.  
  90. double getTPS()
  91. Returns TPS from AAC's TPS meter.
  92.  
  93. int getPing(Player player)
  94. Returns NMS ping for a player.
  95.  
  96. int getViolationLevel(Player player, HackType check)
  97. Returns the internal violation level for a specific check, for a specific player. This is shown in the log files, after "VL:"
  98.  
  99. void setViolationLevel(Player player, HackType check, int newScore);
  100. Sets the internal violation level for a specific check, for a specific player. This is shown in the log files, after "VL:". Any changes applied here will be reflected in commands executed, etc.
  101.  
  102. boolean isPlayerOnGround(Player player)
  103. General utility function which you might want, returning whether a player is on the ground according to AAC's caches and functions.
  104.  
  105. Please note that the API was updated recently, and might not be stable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement