Skip to content

Commit

Permalink
(feat): 1.20.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakShearman committed Mar 1, 2024
1 parent 76536d4 commit 6cce60e
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 20 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ repositories {

dependencies {
// Minestom
api("dev.hollowcube:minestom-ce:30699ec3fd")
api("net.kyori:adventure-text-minimessage:4.14.0")
api("net.minestom:minestom-snapshots:60fc9ebd28")
api("net.kyori:adventure-text-minimessage:4.15.0")
implementation("io.pyroscope:agent:0.12.2")

// Logger
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/emortal/minestom/core/EntrypointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minestom.server.entity.GameMode;
import net.minestom.server.entity.Player;
import net.minestom.server.event.GlobalEventHandler;
import net.minestom.server.event.player.PlayerLoginEvent;
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
import net.minestom.server.event.player.PlayerSpawnEvent;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.block.Block;
Expand All @@ -32,7 +32,7 @@ public static void main(String[] args) {
instance.setGenerator(unit -> unit.modifier().fillHeight(-20, 0, Block.GRASS_BLOCK));

GlobalEventHandler eventHandler = MinecraftServer.getGlobalEventHandler();
eventHandler.addListener(PlayerLoginEvent.class, event -> {
eventHandler.addListener(AsyncPlayerConfigurationEvent.class, event -> {
event.setSpawningInstance(instance);
event.getPlayer().setRespawnPoint(new Pos(0, 0, 0));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,16 @@ private void loadAgones() {

for (AgonesSDKProto.KeyValue label : this.additionalLabels) {
this.sdk.setLabel(label, new IgnoredStreamObserver<>());
LOGGER.info("Set Agones label {} to {}", label.getKey(), label.getValue());
LOGGER.info("Set Agones label agones.dev/sdk-{}={}", label.getKey(), label.getValue());
}

LOGGER.info("Setting agones label: agones.dev/sdk-emc-protocol-version={}", MinecraftServer.PROTOCOL_VERSION);
AgonesSDKProto.KeyValue protocolVersion = AgonesSDKProto.KeyValue.newBuilder()
.setKey("emc-protocol-version")
.setValue(String.valueOf(MinecraftServer.PROTOCOL_VERSION))
.build();

LOGGER.info("Setting agones label: agones.dev/sdk-emc-version-name={}", MinecraftServer.VERSION_NAME);
AgonesSDKProto.KeyValue versionName = AgonesSDKProto.KeyValue.newBuilder()
.setKey("emc-version-name")
.setValue(MinecraftServer.VERSION_NAME)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.emortal.minestom.core.module.kubernetes.command.agones;

import org.jetbrains.annotations.NotNull;

//public class AgonesMetrics {
//
// public AgonesMetrics(@NotNull )
//}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.event.EventNode;
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
import net.minestom.server.event.player.PlayerDisconnectEvent;
import net.minestom.server.event.player.PlayerLoginEvent;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -54,7 +54,7 @@ public MatchmakingSessionManager(@NotNull EventNode<Event> eventNode, @NotNull M
this.sessionCreator = sessionCreator;
this.gameModes = gameModes;

eventNode.addListener(PlayerLoginEvent.class, this::handlePlayerLogin);
eventNode.addListener(AsyncPlayerConfigurationEvent.class, this::handlePlayerLogin);

eventNode.addListener(PlayerDisconnectEvent.class, event -> {
UUID playerId = event.getPlayer().getUuid();
Expand Down Expand Up @@ -100,7 +100,7 @@ private void onTicketCreate(@NotNull Ticket ticket) {
for (String playerId : ticket.getPlayerIdsList()) {
UUID uuid = UUID.fromString(playerId);

Player player = MinecraftServer.getConnectionManager().getPlayer(uuid);
Player player = MinecraftServer.getConnectionManager().getOnlinePlayerByUuid(uuid);
if (player == null) continue;

GameModeConfig gameMode = this.gameModes.getConfig(ticket.getGameModeId());
Expand Down Expand Up @@ -143,7 +143,7 @@ private void onTicketUpdated(@NotNull Ticket newTicket) {
}

UUID uuid = UUID.fromString(playerId);
Player player = MinecraftServer.getConnectionManager().getPlayer(uuid);
Player player = MinecraftServer.getConnectionManager().getOnlinePlayerByUuid(uuid);
if (player == null) continue;

session = this.sessionCreator.create(player, gameMode, newTicket);
Expand Down Expand Up @@ -181,7 +181,7 @@ private void deleteSession(@NotNull String stringId, @NotNull MatchmakingSession
UUID id = UUID.fromString(stringId);

if (playerMustBeOnline) {
Player player = MinecraftServer.getConnectionManager().getPlayer(id);
Player player = MinecraftServer.getConnectionManager().getOnlinePlayerByUuid(id);
if (player == null) return;
}

Expand All @@ -197,7 +197,7 @@ private void destroySession(@NotNull MatchmakingSession session) {
session.destroy();
}

private void handlePlayerLogin(@NotNull PlayerLoginEvent event) {
private void handlePlayerLogin(@NotNull AsyncPlayerConfigurationEvent event) {
Player player = event.getPlayer();
UUID playerId = player.getUuid();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.event.EventNode;
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
import net.minestom.server.event.player.PlayerDisconnectEvent;
import net.minestom.server.event.player.PlayerLoginEvent;
import net.minestom.server.permission.Permission;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
Expand Down Expand Up @@ -40,7 +40,7 @@ public PermissionCache(@NotNull PermissionService permissionService, @NotNull Ev
this.permissionService = permissionService;

eventNode.addListener(PlayerDisconnectEvent.class, this::onDisconnect);
eventNode.addListener(PlayerLoginEvent.class, this::onLogin);
eventNode.addListener(AsyncPlayerConfigurationEvent.class, this::onLogin);

this.loadRoles();
}
Expand Down Expand Up @@ -90,7 +90,7 @@ private void loadUser(@NotNull Player player) {
}

private void updateUserPermissions(@NotNull User user) {
Player player = MinecraftServer.getConnectionManager().getPlayer(user.id());
Player player = MinecraftServer.getConnectionManager().getOnlinePlayerByUuid(user.id());
if (player == null) {
LOGGER.error("Couldn't find player with id {}", user.id());
return;
Expand Down Expand Up @@ -173,7 +173,7 @@ void removeRoleFromUser(@NotNull UUID userId, @NotNull String roleId) {
}

private void refreshCommands(@NotNull UUID playerId) {
Player player = MinecraftServer.getConnectionManager().getPlayer(playerId);
Player player = MinecraftServer.getConnectionManager().getOnlinePlayerByUuid(playerId);
if (player == null) {
LOGGER.error("Couldn't find player with id {}", playerId);
return;
Expand All @@ -186,7 +186,7 @@ private void onDisconnect(@NotNull PlayerDisconnectEvent event) {
this.userCache.remove(event.getPlayer().getUuid());
}

private void onLogin(@NotNull PlayerLoginEvent event) {
private void onLogin(@NotNull AsyncPlayerConfigurationEvent event) {
this.loadUser(event.getPlayer());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import dev.emortal.minestom.core.Environment;
import dev.emortal.minestom.core.module.MinestomModule;
import dev.emortal.minestom.core.module.messaging.MessagingModule;
import net.minestom.server.event.player.PlayerLoginEvent;
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
import net.minestom.server.permission.Permission;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -34,7 +34,7 @@ public boolean onLoad() {
if (!ENABLED) {
if (GRANT_ALL_PERMISSIONS) {
LOGGER.warn("Permission service is not available, granting all permissions");
this.eventNode.addListener(PlayerLoginEvent.class, event -> event.getPlayer().addPermission(new Permission("*")));
this.eventNode.addListener(AsyncPlayerConfigurationEvent.class, event -> event.getPlayer().addPermission(new Permission("*")));
} else {
LOGGER.warn("Permission service is not available, denying all permissions");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public PlayerResolver(@Nullable McPlayerService playerService, @NotNull Connecti

@Blocking
public @Nullable LocalMcPlayer getPlayer(@NotNull UUID uuid) throws StatusException {
Player player = this.connectionManager.getPlayer(uuid);
Player player = this.connectionManager.getOnlinePlayerByUuid(uuid);
if (player != null) return this.convertPlayer(player);

return this.requestPlayer(uuid);
Expand All @@ -35,7 +35,7 @@ public PlayerResolver(@Nullable McPlayerService playerService, @NotNull Connecti
public @Nullable LocalMcPlayer getPlayer(@NotNull String username) throws StatusException {
String usernameLowercase = username.toLowerCase(Locale.ROOT);

Player player = this.connectionManager.getPlayer(usernameLowercase);
Player player = this.connectionManager.getOnlinePlayerByUsername(usernameLowercase);
if (player != null) return this.convertPlayer(player);

return this.requestPlayer(usernameLowercase);
Expand Down

0 comments on commit 6cce60e

Please sign in to comment.