Skip to content

Commit

Permalink
- fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzybol committed Jul 7, 2024
1 parent 3970967 commit 0490db1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>betterbox.mine.game</groupId>
<artifactId>BetterElo</artifactId>
<version>4.4.12-SNAPSHOT</version>
<version>4.4.15-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BetterElo</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package betterbox.mine.game.betterelo;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/betterbox/mine/game/betterelo/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,14 @@ private Player getLastAttacker(Player victim) {

@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
Player victim = event.getEntity();
if (victim.hasMetadata("handledDeath")) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onEntityDamageByEntity event already handled!");
return;
}
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
Player victim = event.getEntity();

Player killer = victim.getKiller();
if (!cheaters.getCheatersList().contains(victim.getName()) && !cheaters.getCheatersList().contains(killer.getName())) {
pluginLogger.log(PluginLogger.LogLevel.KILL_EVENT, "Event: onPlayerDeath: victim: " + victim + " killer: " + killer);
Expand Down Expand Up @@ -276,6 +281,13 @@ public void onPlayerDeath(PlayerDeathEvent event) {
killer.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo] " + ChatColor.DARK_RED + "Your Elo difference in the Event ranking is too big! No reward for this one.");
}
}
victim.setMetadata("handledDamage", new FixedMetadataValue(plugin, true));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
victim.removeMetadata("handledDamage", plugin);
}
}, 1L);


} else {
Expand Down

0 comments on commit 0490db1

Please sign in to comment.