How to use the API for developers

Setup

In order to use this API in your plugin you need to first give your plugin access to it.

  1. Right click on your project name in Eclipse.
  2. Click on Build path -> Configure build path...

Build path

  1. Click on Libraries then add external JARs...

Add external JARs...

  1. Choose this plugin.
  2. Click OK
  3. Go to your plugin.yml and add this to the bottom "depend: [TimesAPI]"
  4. Finally put this line where ever you want in your code.
TimesAPI times = (TimesAPI) Bukkit.getServer().getPluginManager().getPlugin("TimesAPI");

Using the API

Now you should have a variable type of TimesAPI. You will need to use what ever the name of the variable is in this part. In this case I will have my variable be 'times'.

TimesAPI times = (TimesAPI) Bukkit.getServer().getPluginManager().getPlugin("TimesAPI");

To use the API all you have to do is do

times.[METHOD_HERE]();

This will call a method from within the API. For this example we will get when a player moved from block to block. Create a long called time. It will then equal the time in milliseconds that a player has last moved from block to block.

long time = times.getLastPlayerMoveBlock(p.getName()); //Gets the last time p.getName() moved to another block

Now you can use that long for whatever you need.

Methods

Note all the methods require one arg. A string that is the player's name. They all will return a long (Time in milliseconds). If it returns -1 it means that player you checked for did not ever get added to the HashMap that contains this data. In other words they never did what you were trying to get. Please notice that all this data is cleared on reload and shutdown.

  • getLastCommandUse - Gets the last time a player used a command.
  • getLastBlockBreak - Gets the last time a player broke a block.
  • getLastPlayerDamage - Gets the last time a player was damaged.
  • getLastPlayerTeleport - Gets the last time a player teleported.
  • getLastPlayerMoveBlock - Gets the last time a player moved to another block.
  • getLastPlayerDeath - Gets the last time a player died.
  • getLastPlayerJoin - Gets the last time a player joined.
  • getLastPlayerLeave - Gets the last time a player quit.
  • getLastPlayerInteractLeft - Gets the last time a player interacted left.
  • getLastPlayerInteractRight - Gets the last time a player interacted right.
  • getLastPlayerInteractOther - Gets the last time a player interacted physical.
  • getLastPlayerPlaceBlock - Gets the last time a player placed a block.
  • getLastPlayerEnterPortal - Gets the last time a player entered a portal.
  • getLastPlayerCreatePortal - Gets the last time a player created a portal.
  • getLastPlayerBurn - Gets the last time a player was on fire.
  • getLastPlayerDamageByEntity - Gets the last time a player was damaged by an entity.
  • getLastPlayerRegainHealth - Gets the last time a player regain health.
  • getLastPlayerBowShoot - Gets the last time a player shot a bow.
  • getLastPlayerFoodChange - Gets the last time a player's food level changed.
  • getLastPlayerCraft - Gets the last time a player crafted something.
  • getLastPlayerInventoryClick - Gets the last time a player clicked in their inventory.
  • getLastPlayerInventoryClose - Gets the last time a player closed their inventory.
  • getLastPlayerInventoryOpen - Gets the last time a player opened their inventory.
  • getLastPlayerChat - Gets the last time a player said something in chat.
  • getLastPlayerEnterBed - Gets the last time a player entered a bed.
  • getLastPlayerLeaveBed - Gets the last time a player left a bed.
  • getLastPlayerEmptyBucket - Gets the last time a player emptied a bucket.
  • getLastPlayerFillBucket - Gets the last time a player filled a bucket.
  • getLastPlayerDropItem - Gets the last time a player dropped an item.
  • getLastPlayerThrowEgg - Gets the last time a player threw an egg.
  • getLastPlayerExpChange - Gets the last time a player had their exp change.
  • getLastPlayerFish - Gets the last time a player fished.
  • getLastPlayerGameModeChange - Gets the last time a player had their GameMode changed.
  • getLastPlayerInteractEntity - Gets the last time a player interacted with an entity.
  • getLastPlayerItemBreak - Gets the last time a player's item broke (Ex: Stone pickax broke due to durability.)
  • getLastPlayerItemHeld - Gets the last time a player changes the item they are holding.
  • getLastPlayerKick - Gets the last time a player was kicked.
  • getLastPlayerLevelChange - Gets the last time a player exp level was changed.
  • getLastPlayerItemPickup - Gets the last time a player picked up an item.
  • getLastPlayerPortalGoThrough - Gets the last time a player went through a portal.
  • getLastPlayerToggleFligh - Gets the last time a player toggled flight.
  • getLastPlayerCommandIssue - Gets the last time a player issued a command.
  • getLastPlayerToggleSprint - Gets the last time a player toggled sprint.
  • getLastPlayerDestroyVehicle - Gets the last time a player destroyed a vehicle.
  • getLastPlayerEnterVehicle - Gets the last time a player entered a vehicle.
  • getLastPlayerExitVehicle - Gets the last time a player exited a vehicle.

Comments

Posts Quoted:
Reply
Clear All Quotes