Code improvements.
This commit is contained in:
parent
5fd543cb35
commit
a15a75dc29
|
@ -319,7 +319,7 @@ public class AuthMe extends JavaPlugin {
|
|||
// Wait for tasks and close data source
|
||||
new TaskCloser(this, database).run();
|
||||
|
||||
spectateLoginService.removeArmorstands();
|
||||
injector.createIfHasDependencies(SpectateLoginService.class).removeArmorstands();
|
||||
|
||||
// Disabled correctly
|
||||
Consumer<String> infoLogMethod = logger == null ? getLogger()::info : logger::info;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package fr.xephi.authme.data.limbo;
|
||||
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
|
@ -22,18 +23,20 @@ public class LimboPlayer {
|
|||
private final Location loc;
|
||||
private final float walkSpeed;
|
||||
private final float flySpeed;
|
||||
private final GameMode gameMode;
|
||||
private BukkitTask timeoutTask = null;
|
||||
private MessageTask messageTask = null;
|
||||
private LimboPlayerState state = LimboPlayerState.PASSWORD_REQUIRED;
|
||||
|
||||
public LimboPlayer(Location loc, boolean operator, Collection<UserGroup> groups, boolean fly, float walkSpeed,
|
||||
float flySpeed) {
|
||||
float flySpeed, GameMode gameMode) {
|
||||
this.loc = loc;
|
||||
this.operator = operator;
|
||||
this.groups = new ArrayList<>(groups); // prevent bug #2413
|
||||
this.canFly = fly;
|
||||
this.walkSpeed = walkSpeed;
|
||||
this.flySpeed = flySpeed;
|
||||
this.gameMode = gameMode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,6 +48,13 @@ public class LimboPlayer {
|
|||
return loc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the player's original gamemode.
|
||||
*
|
||||
* @return The player's gamemode
|
||||
*/
|
||||
public GameMode getGameMode() {return gameMode;}
|
||||
|
||||
/**
|
||||
* Return whether the player is an operator or not (i.e. whether he is an OP).
|
||||
*
|
||||
|
|
|
@ -119,6 +119,7 @@ public class LimboService {
|
|||
logger.debug("No LimboPlayer found for `{0}` - cannot restore", lowerName);
|
||||
} else {
|
||||
player.setOp(limbo.isOperator());
|
||||
player.setGameMode(limbo.getGameMode());
|
||||
settings.getProperty(RESTORE_ALLOW_FLIGHT).restoreAllowFlight(player, limbo);
|
||||
settings.getProperty(RESTORE_FLY_SPEED).restoreFlySpeed(player, limbo);
|
||||
settings.getProperty(RESTORE_WALK_SPEED).restoreWalkSpeed(player, limbo);
|
||||
|
|
|
@ -6,6 +6,7 @@ import fr.xephi.authme.permission.PermissionsManager;
|
|||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.LimboSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -44,6 +45,7 @@ class LimboServiceHelper {
|
|||
boolean flyEnabled = player.getAllowFlight();
|
||||
float walkSpeed = player.getWalkSpeed();
|
||||
float flySpeed = player.getFlySpeed();
|
||||
GameMode gameMode = player.getGameMode();
|
||||
Collection<UserGroup> playerGroups = permissionsManager.hasGroupSupport()
|
||||
? permissionsManager.getGroups(player) : Collections.emptyList();
|
||||
|
||||
|
@ -52,7 +54,7 @@ class LimboServiceHelper {
|
|||
.collect(toList());
|
||||
|
||||
logger.debug("Player `{0}` has groups `{1}`", player.getName(), String.join(", ", groupNames));
|
||||
return new LimboPlayer(location, isOperator, playerGroups, flyEnabled, walkSpeed, flySpeed);
|
||||
return new LimboPlayer(location, isOperator, playerGroups, flyEnabled, walkSpeed, flySpeed, gameMode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,10 +99,11 @@ class LimboServiceHelper {
|
|||
boolean canFly = newLimbo.isCanFly() || oldLimbo.isCanFly();
|
||||
float flySpeed = Math.max(newLimbo.getFlySpeed(), oldLimbo.getFlySpeed());
|
||||
float walkSpeed = Math.max(newLimbo.getWalkSpeed(), oldLimbo.getWalkSpeed());
|
||||
GameMode gameMode = oldLimbo.getGameMode();
|
||||
Collection<UserGroup> groups = getLimboGroups(oldLimbo.getGroups(), newLimbo.getGroups());
|
||||
Location location = firstNotNull(oldLimbo.getLocation(), newLimbo.getLocation());
|
||||
|
||||
return new LimboPlayer(location, isOperator, groups, canFly, walkSpeed, flySpeed);
|
||||
return new LimboPlayer(location, isOperator, groups, canFly, walkSpeed, flySpeed, gameMode);
|
||||
}
|
||||
|
||||
private static Location firstNotNull(Location first, Location second) {
|
||||
|
|
|
@ -383,10 +383,7 @@ public class PlayerListener implements Listener {
|
|||
event.setRespawnLocation(spawn);
|
||||
}
|
||||
|
||||
if (settings.getProperty(RestrictionSettings.SPECTATE_STAND_LOGIN)
|
||||
|| spectateLoginService.hasStand(event.getPlayer())) {
|
||||
// If a player is dead, no stand will be created for him
|
||||
// therefore we can be sure that there will not be two stands
|
||||
if (settings.getProperty(RestrictionSettings.SPECTATE_STAND_LOGIN)) {
|
||||
bukkitService.runTaskLater(() -> spectateLoginService.createStand(event.getPlayer()), 1L);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,11 +201,11 @@ public final class RestrictionSettings implements SettingsHolder {
|
|||
public static final Property<Boolean> SPECTATE_STAND_LOGIN =
|
||||
newProperty("settings.restrictions.spectateStandLogin.enabled", false);
|
||||
|
||||
@Comment("Head Yaw position for 'spectateStandLogin'.")
|
||||
@Comment("Head Yaw position (rotation of X head) for 'spectateStandLogin'.")
|
||||
public static final Property<Double> HEAD_YAW =
|
||||
newProperty("settings.restrictions.spectateStandLogin.headYaw", 0.0f);
|
||||
|
||||
@Comment("Head Pitch position for 'spectateStandLogin'.")
|
||||
@Comment("Head Pitch position (rotation of Y head) for 'spectateStandLogin'.")
|
||||
public static final Property<Double> HEAD_PITCH =
|
||||
newProperty("settings.restrictions.spectateStandLogin.headPitch", 0.0f);
|
||||
|
||||
|
|
Loading…
Reference in New Issue