-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #559 from Shynixn/development
Merge changes to master --release
- Loading branch information
Showing
15 changed files
with
328 additions
and
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Api | ||
|
||
PetBlocks offers a Developer Api, however it is not published to Maven Central or any other distribution system yet. | ||
You need to directly reference the PetBlocks.jar file. | ||
|
||
## Usage | ||
|
||
Add a dependency in your plugin.yml | ||
|
||
```yaml | ||
softdepend: [ PetBlocks] | ||
``` | ||
Take a look at the following example: | ||
```java | ||
public class YourPlugin extends JavaPlugin { | ||
@Override | ||
public void onEnable() { | ||
// Always gets the same instance of the PetService. | ||
PetService petService = Bukkit.getServicesManager().load(PetService.class); | ||
|
||
Player player = Bukkit.getPlayer("YourPlayerName"); | ||
Plugin plugin = this; | ||
|
||
// GetPetsFromPlayerAsync may retrieve the pet from the Database or the InMemory cache. | ||
petService.getPetsFromPlayerAsync(player).thenAccept(pets -> { | ||
// Main Thread | ||
if (pets.size() > 0) { | ||
// Do not keep the pet instance in your plugin (e.g. in fields). Always retrieve it with getPetsFromPlayerAsync. | ||
// If you need to keep the pet instance in high performance scenarios, check if the pet has already been disposed before using it with pet.isDisposed(). | ||
Pet pet = pets.get(0); | ||
|
||
// All pet methods are safe to be called regardless if the pet is currently spawned or not. | ||
pet.call(); | ||
// Changes are automatically applied to the pet if it is spawned and automatically persisted. | ||
pet.setDisplayName("Hello World"); | ||
pet.setLoop("idle"); | ||
} | ||
}).exceptionally(error -> { | ||
plugin.getLogger().log(Level.SEVERE, "Failed to load pets.", error); | ||
return null; | ||
}); | ||
} | ||
} | ||
``` |
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
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
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 |
---|---|---|
|
@@ -212,6 +212,7 @@ class PetImpl( | |
} | ||
set(value) { | ||
petMeta.loop = value | ||
petEntity?.cancelLoop() | ||
} | ||
|
||
/** | ||
|
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
Oops, something went wrong.