Skip to content

Commit

Permalink
fix bed trap
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 8, 2024
1 parent a2dc7fd commit 4dc0185
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,20 @@ private void onRespawn(PlayerPostRespawnEvent event) {

if (nearBedDeaths == null) {
playerDeathNearBedCount.put(playerUniqueId, 1);
} else {
nearBedDeaths++;
if (nearBedDeaths > maxDeathsPerTime) {
player.getScheduler().run(AnarchyExploitFixes.getInstance(), resetBed -> {
player.setBedSpawnLocation(null, true);
if (logIsEnabled) LogUtil.moduleLog(Level.INFO, name(),
"Reset bed respawn of potentially bed-trapped player '" + player.getName() + "'");
}, null);
}
return;
}

nearBedDeaths++;

if (nearBedDeaths > maxDeathsPerTime) {
player.getScheduler().run(AnarchyExploitFixes.getInstance(), resetBed -> {
player.setBedSpawnLocation(null, true);
if (logIsEnabled) LogUtil.moduleLog(Level.INFO, name(),
"Reset bed respawn of potentially bed-trapped player '" + player.getName() + "'");
}, null);
return;
}

playerDeathNearBedCount.put(playerUniqueId, nearBedDeaths);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,19 @@ private void onDeath(PlayerDeathEvent event) {

if (nearBedDeaths == null) {
playerDeathNearBedCount.put(playerUniqueId, 1);
} else {
nearBedDeaths++;
if (nearBedDeaths > maxDeathsPerTime) {
player.setBedSpawnLocation(null, true);
if (logIsEnabled) LogUtil.moduleLog(Level.INFO, name(),
"Reset bed respawn of potentially bed-trapped player '" + player.getName() + "'");
}
return;
}

nearBedDeaths++;

if (nearBedDeaths > maxDeathsPerTime) {
player.setBedSpawnLocation(null, true);
if (logIsEnabled) LogUtil.moduleLog(Level.INFO, name(),
"Reset bed respawn of potentially bed-trapped player '" + player.getName() + "'");
return;
}

playerDeathNearBedCount.put(playerUniqueId, nearBedDeaths);
}

private boolean isNearBedSpawn(Player player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "me.moomoo.anarchyexploitfixes"
version = "2.6.0"
version = "2.6.1"
description = "Prevent many exploits that affect anarchy servers."
var url: String? = "github.com/moom0o/AnarchyExploitFixes"

Expand Down

0 comments on commit 4dc0185

Please sign in to comment.