Skip to content

Commit

Permalink
Added option to disable revertion on limit exceed.
Browse files Browse the repository at this point in the history
  • Loading branch information
przxmus committed Oct 9, 2022
1 parent a5e841f commit e18079a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
18 changes: 10 additions & 8 deletions src/main/java/eu/vibemc/lifesteal/events/PlayerJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ public void onPlayerJoin(PlayerJoinEvent e) throws IOException {
}
});
}
// get which value is bigger from Config.getInt("heartItem.addLimit") and Config.getInt("killHeartLimit")
int max = Config.getInt("heartItem.addLimit") > Config.getInt("killHeartLimit") ? Config.getInt("heartItem.addLimit") : Config.getInt("killHeartLimit");
// if player's max health is bigger than max, set max health to max
if (Config.getInt("killHeartLimit") > 0 && Config.getInt("heartItem.addLimit") > 0 && max > 0 && player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() > max) {
System.out.println(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() + " > " + max);
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(max);
player.sendMessage(Config.getMessage("abuseDetected"));
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, 100, 1);
if (Config.getBoolean("security.limits.auto-revert")) {
// get which value is bigger from Config.getInt("heartItem.addLimit") and Config.getInt("killHeartLimit")
int max = Config.getInt("heartItem.addLimit") > Config.getInt("killHeartLimit") ? Config.getInt("heartItem.addLimit") : Config.getInt("killHeartLimit");
// if player's max health is bigger than max, set max health to max
if (Config.getInt("killHeartLimit") > 0 && Config.getInt("heartItem.addLimit") > 0 && max > 0 && player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() > max) {
System.out.println(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() + " > " + max);
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(max);
player.sendMessage(Config.getMessage("abuseDetected"));
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, 100, 1);
}
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,5 @@ custom-commands:
security:
alt-farming:
ip-check: true
last-kill-check: false
limits:
auto-revert: true

0 comments on commit e18079a

Please sign in to comment.