API
zNetSell fires one event, dev.netsell.SellEvent, right before every sale: after the items and amounts are known
(and any daily limit has been applied), before the items are taken and the money is paid. Listen to it to block a
sale, change its multiplier, or log it.
Add zNetSell to your plugin
There’s no Maven repository yet. Put zNetSell.jar in a libs/ folder of your project and compile against it:
dependencies {
compileOnly(files("libs/zNetSell.jar"))
}softdepend: [zNetSell] # or depend: [zNetSell] if your plugin can't run without itSellEvent
| Method | What it gives |
|---|---|
getPlayer() | The player selling. |
getSource() | How they’re selling: HAND, ALL, GUI (the sell menu) or WAND (a sellwand on a container). |
getItems() | Item type → amount about to be sold. Read-only. |
getMultiplier() / setMultiplier(BigDecimal) | The multiplier this sale pays: rank, booster and sellwand already combined. Set it to change what the sale pays; 0 or more. Kept to 4 decimals, rounded down. |
isCancelled() / setCancelled(boolean) | Cancel to stop the sale: nothing is taken, nothing is paid, and any daily-limit quota goes back. |
Each line of a sale pays price × amount × multiplier, rounded down to the cent.
Examples
Block selling in one world:
@EventHandler(ignoreCancelled = true)
public void onSell(SellEvent event) {
if (event.getPlayer().getWorld().getName().equals("event_world")) {
event.setCancelled(true);
event.getPlayer().sendMessage("You can't sell here.");
}
}Pay 10% more on weekends:
@EventHandler(ignoreCancelled = true)
public void onSell(SellEvent event) {
DayOfWeek day = LocalDate.now().getDayOfWeek();
if (day == DayOfWeek.SATURDAY || day == DayOfWeek.SUNDAY) {
event.setMultiplier(event.getMultiplier().multiply(new BigDecimal("1.1")));
}
}Log sales of diamonds:
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSell(SellEvent event) {
Integer diamonds = event.getItems().get(Material.DIAMOND);
if (diamonds != null) getLogger().info(event.getPlayer().getName() + " is selling " + diamonds + " diamonds");
}At MONITOR the sale can still fail afterwards, if the economy plugin refuses the deposit; the items then go back
to the player.
Threads
The event is called on the thread that owns the player: the main thread on Paper, the player’s region thread on Folia. You may read and change the player there. Don’t block it with database or web calls; hand those to an async task.