Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>org.retromc</groupId>
<artifactId>Authme-Expanded</artifactId>
<version>3.6.3</version>
<version>3.6.4</version>
<description>A fork of AuthMe utilized by RetroMC</description>

<properties>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/uk/org/whoami/authme/AuthMe.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public void onEnable() {
Priority.Lowest, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener,
Priority.Lowest, this);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener,
Priority.Lowest, this);
pm.registerEvent(Event.Type.PLAYER_KICK, playerListener,
Priority.Lowest, this);
pm.registerEvent(Event.Type.PLAYER_PICKUP_ITEM, playerListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public Location getLoc() {
return loc;
}

public void setLoc(Location loc) {
this.loc = loc;
}

public ItemStack[] getArmour() {
return armour;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
Expand Down Expand Up @@ -316,6 +317,15 @@ public void onPlayerJoin(PlayerJoinEvent event) {
}

LimboCache.getInstance().addLimboPlayer(player);
//If the player reconnected while dead (still on the respawn screen), the
//location captured above is the spot where they died. Leaving it in the
//limbo cache would let /login teleport them back there after they respawn
//(respawn-at-death exploit). A dead player has no valid location to
//return to, so fall back to the world spawn. onPlayerRespawn refines this
//to their actual respawn point (e.g. bed) once they respawn.
if (player.isDead() || player.getHealth() <= 0) {
LimboCache.getInstance().getLimboPlayer(name).setLoc(player.getWorld().getSpawnLocation());
}
player.getInventory().setArmorContents(new ItemStack[0]);
player.getInventory().setContents(new ItemStack[36]);
if (settings.isTeleportToSpawnEnabled()) {
Expand Down Expand Up @@ -381,6 +391,28 @@ public void onPlayerKick(PlayerKickEvent event) {
PlayerCache.getInstance().removePlayer(name);
}

@Override
public void onPlayerRespawn(PlayerRespawnEvent event) {
if (event.getPlayer() == null) {
return;
}

Player player = event.getPlayer();
String name = player.getName().toLowerCase();

if (CitizensCommunicator.isNPC(player)) {
return;
}

if (PlayerCache.getInstance().isAuthenticated(name)) {
return;
}

if (LimboCache.getInstance().hasLimboPlayer(name)) {
LimboCache.getInstance().getLimboPlayer(name).setLoc(event.getRespawnLocation());
}
}

@Override
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (event.isCancelled() || event.getPlayer() == null) {
Expand Down
Loading