feat: add rewards when holding the egg and tell player about their rewards/losses when killing someone

This commit is contained in:
HerozDotExe 2026-02-09 19:37:09 +01:00
parent 7d98ca067b
commit c930f30c74
3 changed files with 29 additions and 9 deletions

View file

@ -78,13 +78,17 @@ public class DeathListener implements Listener {
if (this.pointsAPI != null) {
// Take money
double money = pointsAPI.look(killed.getUniqueId());
money = money * ((double) (100 - config.getInt("percentOfMoneyToTakeOnKills")) / 100);
pointsAPI.set(killed.getUniqueId(), (int) money);
double newMoney = money * ((double) (100 - config.getInt("percentOfMoneyToTakeOnKills")) / 100);
pointsAPI.set(killed.getUniqueId(), (int) newMoney);
killed.sendRichMessage(String.format("[SMP4] <dark_purple>You lost %s points by getting killed by %s (%s->%s).</dark_purple>", money - newMoney, killed.getName(), money, newMoney));
// Give money
int eloGain = newRankings[1] - killerRanking;
int moneyGain = newRankings[1] - killerRanking;
int multiplier = config.getInt("moneyMultiplier");
pointsAPI.give(killer.getUniqueId(), eloGain*multiplier);
pointsAPI.give(killer.getUniqueId(), moneyGain*multiplier);
killer.sendRichMessage(String.format("[SMP4] <dark_purple>You received %s points for killing %s.</dark_purple>", moneyGain*multiplier, killed.getName()));
}
}

View file

@ -6,6 +6,8 @@ import dev.hrz0.smp4.Listeners.VaultChangeStateListener;
import dev.hrz0.smp4.Listeners.WorldSaveListener;
import dev.hrz0.smp4.States.States;
import dev.hrz0.smp4.States.StatesParser;
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.Player;
@ -82,7 +84,20 @@ 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);
int eloGain = config.getInt("eloGainWhenHoldingEgg");
int currentElo = states.rankings.getPlayerRanking(eggOwner);
states.rankings.setPlayerRanking(eggOwner, currentElo + eloGain);
PlayerPointsAPI pointsAPI = PlayerPoints.getInstance().getAPI();
if (pointsAPI != null) {
int moneyGain = config.getInt("moneyGainWhenHoldingEgg");
pointsAPI.give(eggOwner.getUniqueId(), moneyGain);
eggOwner.sendRichMessage(String.format("[SMP4] <dark_purple>You received %s ELO and %s points for holding the egg.</dark_purple>", eloGain, moneyGain));
}
}
}
}.runTaskTimer(this, 0L, config.getInt("eggOwnerCommandInterval") * 20L);

View file

@ -2,18 +2,19 @@
# <killer> and <killed> are replaced by players' name.
# Don't put / before commands.
killCommands:
- msg <killer> You killed <killed> !
- msg <killed> You got killed by <killer>
# Percent of killed's money to take
percentOfMoneyToTakeOnKills: 25
# Constant used to multiply eloGain with, the result being the amount of money given to the killer
moneyMultiplier: 20
# List of commands to run every eggOwnerCommandInterval s
# List of commands to run every eggOwnerCommandInterval (in seconds)
# <owner> will be replaced by the current egg owner's name
eggOwnerCommandInterval: 5
eggOwnerCommands:
- msg <owner> You have the egg!
# How much elo should be given to players holding the dragon egg every eggOwnerCommandInterval
eloGainWhenHoldingEgg: 10
# How much money should be given to players holding the dragon egg every eggOwnerCommandInterval
moneyGainWhenHoldingEgg: 100
disableVaultLoot: true