ZelBounty fires custom events that you can listen to for custom logic. All events are cancellable.
Event Package
All events are located in com.kammoun.api.events.
Available Events
BountyAddEvent
Fired when a bounty is added to a player.
publicclassBountyAddEventextendsEventimplementsCancellable {PlayergetPlayer(); // Player adding the bountyPlayergetTarget(); // Player receiving the bountydoublegetAmount(); // Amount being addedvoidsetAmount(double); // Modify the amountbooleanisAdmin(); // True if added by admin commandbooleanisCancelled();voidsetCancelled(boolean);}
Example:
BountyRemoveEvent
Fired when a bounty is removed from a player.
Example:
BountyResetEvent
Fired when a player's bounty is reset to 0.
Example:
BountyClaimEvent
Fired when a bounty is claimed (target is killed).
Example:
Registering Listeners
Register your event listeners like any other Bukkit event:
Event Priority
Use standard Bukkit event priorities:
Cancelling Events
When you cancel an event:
BountyAddEvent: Bounty is not added, money is not deducted
BountyRemoveEvent: Bounty is not removed
BountyResetEvent: Bounty is not reset
BountyClaimEvent: Reward is not given, bounty remains active
@EventHandler
public void onBountyAdd(BountyAddEvent event) {
Player adder = event.getPlayer();
Player target = event.getTarget();
double amount = event.getAmount();
// Prevent bounties on players with a specific permission
if (target.hasPermission("bounty.immune")) {
event.setCancelled(true);
adder.sendMessage("This player is immune to bounties!");
return;
}
// Double bounties on weekends
if (isWeekend()) {
event.setAmount(amount * 2);
adder.sendMessage("Weekend bonus! Bounty doubled!");
}
}
public class BountyRemoveEvent extends Event implements Cancellable {
Player getPlayer(); // Player removing the bounty
Player getTarget(); // Player losing the bounty
double getAmount(); // Amount being removed
void setAmount(double); // Modify the amount
boolean isAdmin(); // True if removed by admin command
boolean isCancelled();
void setCancelled(boolean);
}
@EventHandler
public void onBountyRemove(BountyRemoveEvent event) {
// Log all bounty removals
getLogger().info(String.format(
"Bounty removed: %s removed $%.2f from %s (admin: %s)",
event.getPlayer().getName(),
event.getAmount(),
event.getTarget().getName(),
event.isAdmin()
));
}
public class BountyResetEvent extends Event implements Cancellable {
Player getPlayer(); // Player performing the reset
Player getTarget(); // Player being reset
double getPreviousAmount(); // Bounty amount before reset
boolean isAdmin(); // True if reset by admin
boolean isCancelled();
void setCancelled(boolean);
}
@EventHandler
public void onBountyReset(BountyResetEvent event) {
double lost = event.getPreviousAmount();
// Notify the target
if (event.getTarget().isOnline()) {
event.getTarget().sendMessage(
"Your bounty of $" + lost + " has been reset by " + event.getPlayer().getName()
);
}
}
public class BountyClaimEvent extends Event implements Cancellable {
Player getKiller(); // Player claiming the bounty (killer)
Player getVictim(); // Player whose bounty was claimed
double getAmount(); // Reward amount
void setAmount(double); // Modify the reward
boolean isCancelled();
void setCancelled(boolean);
}
@EventHandler
public void onBountyClaim(BountyClaimEvent event) {
Player killer = event.getKiller();
Player victim = event.getVictim();
double amount = event.getAmount();
// Prevent claiming bounties in certain regions (WorldGuard example)
if (isInSafeZone(victim.getLocation())) {
event.setCancelled(true);
killer.sendMessage("Bounties cannot be claimed in safe zones!");
return;
}
// Award bonus XP for bounty claims
killer.giveExp((int) (amount / 10));
// Announce big bounty claims
if (amount >= 10000) {
Bukkit.broadcastMessage(
killer.getName() + " just claimed a massive $" + amount + " bounty on " + victim.getName() + "!"
);
}
}
public class MyPlugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Register events
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onBountyAdd(BountyAddEvent event) {
// Handle event
}
@EventHandler(priority = EventPriority.HIGH)
public void onBountyClaim(BountyClaimEvent event) {
// Handle with high priority
}
}
@EventHandler(priority = EventPriority.LOWEST) // First to run
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.NORMAL) // Default
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.MONITOR) // Last, don't modify
package com.example.bountyextras;
import com.kammoun.api.events.*;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class BountyExtras extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Check if ZelBounty is installed
if (getServer().getPluginManager().getPlugin("ZelBounty") == null) {
getLogger().severe("ZelBounty not found! Disabling...");
getServer().getPluginManager().disablePlugin(this);
return;
}
// Register events
getServer().getPluginManager().registerEvents(this, this);
getLogger().info("BountyExtras enabled!");
}
@EventHandler(priority = EventPriority.NORMAL)
public void onBountyAdd(BountyAddEvent event) {
Player target = event.getTarget();
// VIP players get 50% bounty reduction
if (target.hasPermission("vip.bounty.reduction")) {
double reduced = event.getAmount() * 0.5;
event.setAmount(reduced);
event.getPlayer().sendMessage("VIP reduction applied: $" + reduced);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onBountyClaim(BountyClaimEvent event) {
Player killer = event.getKiller();
double amount = event.getAmount();
// Track kills in scoreboard
// ... your scoreboard logic
// Achievement for first bounty claim
// ... your achievement logic
// Log to file
getLogger().info(String.format(
"[CLAIM] %s claimed $%.2f from %s",
killer.getName(),
amount,
event.getVictim().getName()
));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBountyAddMonitor(BountyAddEvent event) {
// This runs last and only if event wasn't cancelled
// Good for logging final state
getLogger().info(String.format(
"[ADD] %s -> %s: $%.2f",
event.getPlayer().getName(),
event.getTarget().getName(),
event.getAmount()
));
}
}