API - No-Not-Jaden/NotBounties GitHub Wiki
Replace version
with the most recent release
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.No-Not-Jaden</groupId>
<artifactId>NotBounties</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.No-Not-Jaden:NotBounties:VERSION'
}
This is a very brief overview. If you have any questions, reach out to the developer on Discord. An example plugin with the following items can be found here
Here are the events that can be used along with their methods
-
event.getBounty()
returns the new bounty to be set
-
event.getBounty()
returns the bounty claimed -
event.getKiller()
returns the claimer of the bounty
-
event.getBeforeEdit()
returns the bounty before the edit -
event.getAfterEdit()
returns the bounty after the edit -
event.getEditor()
returns the CommandSender who is editing the bounty
-
event.getBounty()
returns the bounty that is being removed -
event.getRemover()
returns the CommandSender who is removing the bounty -
event.isBought()
returns true if the removal was bought
// example of using the BountyClaimEvent to stop a bounty from being claimed
@EventHandler
public void onBountyClaim(BountyClaimEvent event) {
if (event.getBounty().getName().equals("Not_Jaden")) {
Bukkit.broadcastMessage("Bounties cannot be claimed on Not_Jaden");
event.setCancelled(true);
return;
}
Bukkit.broadcastMessage(event.getKiller().getName() + " Claimed the bounty on " + event.getBounty().getName());
}
Use the BountyManager class to get current bounties or add new ones.
OfflinePlayer player = ...;
// get a current bounty
if (BountyManager.hasBounty(player)) {
Bounty bounty = BountyManager.getBounty(player);
}
// add a new bounty
Player setter = ...;
double amount = 1234.56;
// the Whitelist object accepts an ArrayList of UUIDs and a boolean for blacklist mode;
// this example is for a bounty with restrictions on claiming
Whitelist whitelist = new Whitelist(new ArrayList<>(), false);
BountyManager.addBounty(setter, player, amount, whitelist);
// to set a bounty by the console
BountyManager.addBounty(player, amount, whitelist);
There are many functions in the Bounty class. Here are some examples of popular uses of the Bounty object.
// get the bounty
Bounty bounty = BountyManager.getBounty(player);
// the bounty will be null if there is no bounty for the player
if (bounty == null)
return;
// the name of who the bounty was set on
String target = bounty.getName();
// the UUID of the target
UUID uuid = bounty.getUUID;
// the total bounty regardless of whitelist
double globalBountyValue = bounty.getTotalBounty();
// the total bounty that anotherPlayer can claim
double claimableBountyValue = bounty.getTotalBounty(anotherPlayer);
To format numbers with NotBounties's number formatter, use the NumberFormatting class.
// formatting a number -> 8.69B with the default config
String formattedNumber = NumberFormatting.formatNumber(8694059678);
// adding the currency prefix and suffix around a formatted number
String totalBounty = NumberFormatting.currencyPrefix + NumberFormatting.formatNumber(bounty.getTotalBounty()) + NumberFormatting.currencySuffix;