no invulnerability on join plugin code example
Example: no invulnerability on join plugin
@EventHandler(priority = EventPriority.MONITOR)
private void onPlayerJoin(PlayerJoinEvent event) {
try {
Field underlyingEntityField = CraftEntity.class.getDeclaredField("entity");
underlyingEntityField.setAccessible(true);
Object underlyingPlayerObj = underlyingEntityField.get(event.getPlayer());
if (underlyingPlayerObj instanceof EntityPlayer) {
EntityPlayer underlyingPlayer = (EntityPlayer) underlyingPlayerObj;
underlyingPlayer.invulnerableTicks = 1;
}
} catch (Exception e) {
log.info("LoginInvulnerabilityFix exception: " + e.getMessage());
e.printStackTrace();
}
}