Format code [skip actions]

This commit is contained in:
github-actions 2023-05-17 05:02:10 +00:00
parent cc94a21ca9
commit 69fadff479
3 changed files with 30 additions and 33 deletions

View File

@ -1,5 +1,8 @@
package emu.grasscutter.auth;
import static emu.grasscutter.config.Configuration.ACCOUNT;
import static emu.grasscutter.utils.Language.translate;
import at.favre.lib.crypto.bcrypt.BCrypt;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.Grasscutter.ServerRunMode;
@ -14,17 +17,13 @@ import emu.grasscutter.utils.DispatchUtils;
import emu.grasscutter.utils.FileUtils;
import emu.grasscutter.utils.Utils;
import io.javalin.http.ContentType;
import javax.crypto.Cipher;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.interfaces.RSAPrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import static emu.grasscutter.config.Configuration.ACCOUNT;
import static emu.grasscutter.utils.Language.translate;
import javax.crypto.Cipher;
/** A class containing default authenticators. */
public final class DefaultAuthenticators {
@ -396,18 +395,17 @@ public final class DefaultAuthenticators {
// Check to see if an IP authentication can be performed.
if (Grasscutter.getRunMode() == ServerRunMode.HYBRID) {
var player = Grasscutter.getGameServer()
.getPlayerByIpAddress(ctx.ip());
var player = Grasscutter.getGameServer().getPlayerByIpAddress(ctx.ip());
if (player != null) {
// Get the player's session token.
var sessionKey = player.getAccount().getSessionKey();
// Respond with the handbook auth page.
ctx.status(200).result(
this.authPage
.replace("{{VALUE}}", "true")
.replace("{{SESSION_TOKEN}}", sessionKey)
.replace("{{PLAYER_ID}}", String.valueOf(player.getUid()))
);
ctx.status(200)
.result(
this.authPage
.replace("{{VALUE}}", "true")
.replace("{{SESSION_TOKEN}}", sessionKey)
.replace("{{PLAYER_ID}}", String.valueOf(player.getUid())));
return;
}
}

View File

@ -41,15 +41,14 @@ import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.KahnsSort;
import emu.grasscutter.utils.Position;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.Getter;
import lombok.Setter;
import lombok.val;
import javax.annotation.Nullable;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.Getter;
import lombok.Setter;
import lombok.val;
public final class Scene {
@Getter private final World world;

View File

@ -1,5 +1,9 @@
package emu.grasscutter.server.game;
import static emu.grasscutter.config.Configuration.DISPATCH_INFO;
import static emu.grasscutter.config.Configuration.GAME_INFO;
import static emu.grasscutter.utils.Language.translate;
import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.Grasscutter.ServerRunMode;
@ -37,22 +41,17 @@ import emu.grasscutter.server.event.internal.ServerStopEvent;
import emu.grasscutter.server.event.types.ServerEvent;
import emu.grasscutter.server.scheduler.ServerTaskScheduler;
import emu.grasscutter.task.TaskMap;
import kcp.highway.ChannelConfig;
import kcp.highway.KcpServer;
import lombok.Getter;
import lombok.Setter;
import lombok.SneakyThrows;
import java.net.InetSocketAddress;
import java.net.URI;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import static emu.grasscutter.config.Configuration.DISPATCH_INFO;
import static emu.grasscutter.config.Configuration.GAME_INFO;
import static emu.grasscutter.utils.Language.translate;
import kcp.highway.ChannelConfig;
import kcp.highway.KcpServer;
import lombok.Getter;
import lombok.Setter;
import lombok.SneakyThrows;
@Getter
public final class GameServer extends KcpServer {
@ -255,11 +254,12 @@ public final class GameServer extends KcpServer {
*/
public Player getPlayerByIpAddress(String ipAddress) {
return this.getPlayers().values().stream()
.map(Player::getSession)
.filter(session -> session != null &&
session.getAddress().getHostString().equals(ipAddress))
.map(GameSession::getPlayer)
.findFirst().orElse(null);
.map(Player::getSession)
.filter(
session -> session != null && session.getAddress().getHostString().equals(ipAddress))
.map(GameSession::getPlayer)
.findFirst()
.orElse(null);
}
public SocialDetail.Builder getSocialDetailByUid(int id) {