#630 Disable collisions for unlogged players
This commit is contained in:
parent
997c31a03e
commit
de89244e0e
@ -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();
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ public final class Settings {
|
||||
checkVeryGames, removeJoinMessage, removeLeaveMessage, delayJoinMessage,
|
||||
noTeleport, hideTablistBeforeLogin, denyTabcompleteBeforeLogin,
|
||||
kickPlayersBeforeStopping, allowAllCommandsIfRegIsOptional,
|
||||
customAttributes, isRemoveSpeedEnabled, preventOtherCase;
|
||||
customAttributes, isRemoveSpeedEnabled, preventOtherCase, keepCollisionsDisabled;
|
||||
public static String getNickRegex, getUnloggedinGroup,
|
||||
unRegisteredGroup,
|
||||
backupWindowsPath, getRegisteredGroup,
|
||||
@ -195,7 +195,7 @@ public final class Settings {
|
||||
preventOtherCase = configFile.getBoolean("settings.preventOtherCase", false);
|
||||
kickPlayersBeforeStopping = configFile.getBoolean("Security.stop.kickPlayersBeforeStopping", true);
|
||||
sendPlayerTo = configFile.getString("Hooks.sendPlayerTo", "");
|
||||
|
||||
keepCollisionsDisabled = configFile.getBoolean("settings.keepCollisionsDisabled");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -53,6 +53,12 @@ public class PluginSettings implements SettingsClass {
|
||||
public static final Property<Boolean> ENABLE_PERMISSION_CHECK =
|
||||
newProperty("permission.EnablePermissionCheck", false);
|
||||
|
||||
@Comment({
|
||||
"Keeps collisions disabled for logged players",
|
||||
"Works only with MC 1.9"
|
||||
})
|
||||
public static final Property<Boolean> KEEP_COLLISIONS_DISABLED =
|
||||
newProperty("settings.KeepCollisionsDisabled", false);
|
||||
|
||||
private PluginSettings() {
|
||||
}
|
||||
|
||||
@ -159,6 +159,9 @@ settings:
|
||||
noTeleport: false
|
||||
# Regex syntax for allowed Chars in passwords.
|
||||
allowedPasswordCharacters: '[\x21-\x7E]*'
|
||||
# Keeps collisions disabled for logged players
|
||||
# Works only with MC 1.9
|
||||
keepCollisionsDisabled: false
|
||||
GameMode:
|
||||
# ForceSurvivalMode to player when join ?
|
||||
ForceSurvivalMode: false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user