#630 Disable collisions for unlogged players

This commit is contained in:
Gabriele C
2016-04-01 18:21:05 +02:00
parent 997c31a03e
commit de89244e0e
5 changed files with 33 additions and 2 deletions
@@ -27,10 +27,14 @@ import fr.xephi.authme.util.Utils.GroupType;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitTask;
import com.comphenix.protocol.reflect.MethodUtils;
/**
*/
public class AsynchronousJoin implements Process {
@@ -42,6 +46,9 @@ public class AsynchronousJoin implements Process {
private final ProcessService service;
private final PlayerCache playerCache;
private final boolean disableCollisions = MethodUtils
.getAccessibleMethod(LivingEntity.class, "setCollidable", new Class[]{}) != null;
public AsynchronousJoin(Player player, AuthMe plugin, DataSource database, PlayerCache playerCache,
ProcessService service) {
this.player = player;
@@ -89,6 +96,10 @@ public class AsynchronousJoin implements Process {
});
return;
}
// Prevent player collisions in 1.9
if (disableCollisions) {
((LivingEntity) player).setCollidable(false);
}
final Location spawnLoc = service.getSpawnLoader().getSpawnLocation(player);
final boolean isAuthAvailable = database.isAuthAvailable(name);
if (isAuthAvailable) {
@@ -4,12 +4,15 @@ import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.potion.PotionEffectType;
import com.comphenix.protocol.reflect.MethodUtils;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
@@ -29,6 +32,7 @@ import fr.xephi.authme.util.Utils;
import fr.xephi.authme.util.Utils.GroupType;
import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN;
import static fr.xephi.authme.settings.properties.PluginSettings.KEEP_COLLISIONS_DISABLED;
public class ProcessSyncPlayerLogin implements Runnable {
@@ -42,6 +46,9 @@ public class ProcessSyncPlayerLogin implements Runnable {
private final JsonCache playerCache;
private final NewSetting settings;
private final boolean restoreCollisions = MethodUtils
.getAccessibleMethod(LivingEntity.class, "setCollidable", new Class[]{}) != null;
/**
* Constructor for ProcessSyncPlayerLogin.
*
@@ -148,6 +155,10 @@ public class ProcessSyncPlayerLogin implements Runnable {
}
}
if (restoreCollisions && !settings.getProperty(KEEP_COLLISIONS_DISABLED)) {
player.setCollidable(true);
}
if (settings.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
restoreInventory();
}