feat: take a configurable percent of money from killed players

This commit is contained in:
HerozDotExe 2026-02-09 18:15:13 +01:00
parent 8d8585c85d
commit 30700e9609
4 changed files with 21 additions and 1 deletions

View file

@ -12,6 +12,9 @@ repositories {
name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/"
}
maven {
url = 'https://repo.rosewooddev.io/repository/public/'
}
}
dependencies {
@ -19,6 +22,7 @@ dependencies {
implementation("com.google.code.gson:gson:2.13.2")
implementation("net.kyori:adventure-api:4.26.1")
implementation("net.kyori:adventure-text-minimessage:4.26.1")
compileOnly("org.black_ixx:playerpoints:3.3.3")
}
tasks {

View file

@ -5,6 +5,8 @@ import dev.hrz0.smp4.States.States;
import dev.hrz0.smp4.Utilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.black_ixx.playerpoints.PlayerPoints;
import org.black_ixx.playerpoints.PlayerPointsAPI;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.EntityType;
@ -24,6 +26,7 @@ public class DeathListener implements Listener {
private final States states;
private final Logger logger;
private final FileConfiguration config;
private PlayerPointsAPI pointsAPI;
public DeathListener(States states, Logger logger, FileConfiguration config) {
this.states = states;
@ -70,6 +73,16 @@ public class DeathListener implements Listener {
toFill.put("<killer>", killer.getName());
toFill.put("<killed>", killed.getName());
Utilities.runCommands(commands, toFill);
if (Bukkit.getPluginManager().isPluginEnabled("PlayerPoints")) {
this.pointsAPI = PlayerPoints.getInstance().getAPI();
if (this.pointsAPI != null) {
double money = pointsAPI.look(killed.getUniqueId());
money = money * ((double) (100 - config.getInt("percentOfMoneyToTakeOnKills")) / 100);
pointsAPI.set(killed.getUniqueId(), (int) money);
}
}
}
}
}

View file

@ -82,7 +82,7 @@ public final class Smp4 extends JavaPlugin {
Map<String, String> toFill = new HashMap<String, String>();
toFill.put("<owner>", eggOwner.getName());
Utilities.runCommands(commands, toFill);
//Utilities.runCommands(commands, toFill);
}
}
}.runTaskTimer(this, 0L, config.getInt("eggOwnerCommandInterval") * 20L);

View file

@ -5,6 +5,9 @@ killCommands:
- msg <killer> You killed <killed> !
- msg <killed> You got killed by <killer>
# Percent of killed's money to take
percentOfMoneyToTakeOnKills: 25
# List of commands to run every eggOwnerCommandInterval s
# <owner> will be replaced by the current egg owner's name
eggOwnerCommandInterval: 5