diff --git a/ansible/files/zorweth-config/plugins/KiraBukkitGateway/config.yml b/ansible/files/zorweth-config/plugins/KiraBukkitGateway/config.yml index d98b13c07..234d22509 100644 --- a/ansible/files/zorweth-config/plugins/KiraBukkitGateway/config.yml +++ b/ansible/files/zorweth-config/plugins/KiraBukkitGateway/config.yml @@ -34,4 +34,4 @@ console: key: ip regex: '.*is brand new!.*' -server-name: "main" +server-name: "zorweth" diff --git a/containers/provisioning/mariadb/docker-entrypoint-initdb.d/0100_create_databases.sql b/containers/provisioning/mariadb/docker-entrypoint-initdb.d/0100_create_databases.sql index 0538b3fbf..721a3f8c7 100755 --- a/containers/provisioning/mariadb/docker-entrypoint-initdb.d/0100_create_databases.sql +++ b/containers/provisioning/mariadb/docker-entrypoint-initdb.d/0100_create_databases.sql @@ -51,7 +51,6 @@ CREATE DATABASE zorweth_essenceglue; CREATE DATABASE zorweth_jukealert; CREATE DATABASE zorweth_realisticbiomes; CREATE DATABASE zorweth_exilepearl; -CREATE DATABASE zorweth_castlegates; GRANT ALL PRIVILEGES ON `zorweth_bastion`.* TO 'mariadb'@'%'; GRANT ALL PRIVILEGES ON `zorweth_castlegates`.* TO 'mariadb'@'%'; @@ -64,7 +63,6 @@ GRANT ALL PRIVILEGES ON `zorweth_essenceglue`.* TO 'mariadb'@'%'; GRANT ALL PRIVILEGES ON `zorweth_jukealert`.* TO 'mariadb'@'%'; GRANT ALL PRIVILEGES ON `zorweth_realisticbiomes`.* TO 'mariadb'@'%'; GRANT ALL PRIVILEGES ON `zorweth_exilepearl`.* TO 'mariadb'@'%'; -GRANT ALL PRIVILEGES ON `zorweth_castlegates`.* TO 'mariadb'@'%'; CREATE DATABASE zorweth; GRANT ALL PRIVILEGES ON `zorweth`.* TO 'mariadb'@'%'; diff --git a/plugins/civproxy-velocity/src/main/java/net/civmc/civproxy/CivProxyPlugin.java b/plugins/civproxy-velocity/src/main/java/net/civmc/civproxy/CivProxyPlugin.java index 62c277cf8..3aded66a1 100644 --- a/plugins/civproxy-velocity/src/main/java/net/civmc/civproxy/CivProxyPlugin.java +++ b/plugins/civproxy-velocity/src/main/java/net/civmc/civproxy/CivProxyPlugin.java @@ -9,14 +9,14 @@ import com.velocitypowered.api.plugin.PluginContainer; import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.velocitypowered.api.proxy.ProxyServer; import com.zaxxer.hikari.HikariConfig; -import java.util.Optional; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; -import javax.sql.DataSource; +import java.util.Optional; import com.zaxxer.hikari.HikariDataSource; import net.civmc.civproxy.renamer.PlayerRenamer; +import net.civmc.nameapi.NameAPI; import net.civmc.zorweth.velocity.ZorwethVelocityPlugin; import org.slf4j.Logger; import org.spongepowered.configurate.CommentedConfigurationNode; @@ -30,7 +30,7 @@ public class CivProxyPlugin { private CommentedConfigurationNode config; - private DataSource source; + private NameAPI nameAPI; @Inject public CivProxyPlugin(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) { this.server = server; @@ -47,16 +47,17 @@ public class CivProxyPlugin { public void onProxyInitialization(ProxyInitializeEvent event) { loadNameApiConfig(); new PlayerCount(this, server).start(); - new PlayerRenamer(this, server, source).start(); - if (server.getPluginManager().isLoaded("ajqueue")) { - final Optional zorweth = server.getPluginManager().getPlugin("zorweth") - .flatMap(PluginContainer::getInstance) - .map(ZorwethVelocityPlugin.class::cast); - if (zorweth.isPresent()) { + new PlayerRenamer(this, server, this.nameAPI).start(); + final Optional zorweth = server.getPluginManager().getPlugin("zorweth") + .flatMap(PluginContainer::getInstance) + .map(ZorwethVelocityPlugin.class::cast); + if (zorweth.isPresent()) { + zorweth.get().setOfflinePlayerResolver(this.nameAPI::getUUID); + if (server.getPluginManager().isLoaded("ajqueue")) { new QueueListener(this, server, zorweth.get()).start(); - } else { - this.logger.error("Zorweth is required for queue routing, but its plugin instance was not available"); } + } else { + this.logger.error("Zorweth is required for route management, but its plugin instance was not available"); } } @@ -81,7 +82,7 @@ public class CivProxyPlugin { if (password != null && !password.isBlank()) { config.setPassword(password); } - this.source = new HikariDataSource(config); + this.nameAPI = new NameAPI(this.logger, new HikariDataSource(config)); } /** diff --git a/plugins/civproxy-velocity/src/main/java/net/civmc/civproxy/renamer/PlayerRenamer.java b/plugins/civproxy-velocity/src/main/java/net/civmc/civproxy/renamer/PlayerRenamer.java index b565c5658..9066fdd10 100644 --- a/plugins/civproxy-velocity/src/main/java/net/civmc/civproxy/renamer/PlayerRenamer.java +++ b/plugins/civproxy-velocity/src/main/java/net/civmc/civproxy/renamer/PlayerRenamer.java @@ -4,7 +4,6 @@ import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.player.GameProfileRequestEvent; import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.util.GameProfile; -import javax.sql.DataSource; import net.civmc.civproxy.CivProxyPlugin; import net.civmc.nameapi.NameAPI; @@ -15,10 +14,10 @@ public class PlayerRenamer { private final NameAPI nameAPI; - public PlayerRenamer(CivProxyPlugin plugin, ProxyServer server, DataSource source) { + public PlayerRenamer(CivProxyPlugin plugin, ProxyServer server, NameAPI nameAPI) { this.plugin = plugin; this.server = server; - this.nameAPI = new NameAPI(plugin.getLogger(), source); + this.nameAPI = nameAPI; } @Subscribe diff --git a/plugins/simpleadminhacks-paper/src/main/java/com/programmerdan/minecraft/simpleadminhacks/hacks/OneTimeTeleport.java b/plugins/simpleadminhacks-paper/src/main/java/com/programmerdan/minecraft/simpleadminhacks/hacks/OneTimeTeleport.java index a6f20e763..7addf4ffc 100644 --- a/plugins/simpleadminhacks-paper/src/main/java/com/programmerdan/minecraft/simpleadminhacks/hacks/OneTimeTeleport.java +++ b/plugins/simpleadminhacks-paper/src/main/java/com/programmerdan/minecraft/simpleadminhacks/hacks/OneTimeTeleport.java @@ -572,7 +572,7 @@ public final class OneTimeTeleport extends SimpleHack imp private boolean isEligibleForCrossServerOtt(Player player) { if (Bukkit.getPluginManager().isPluginEnabled("Zorweth")) { - return player.getPersistentDataContainer().has(RocketTransferKeys.NO_OTT); + return !player.getPersistentDataContainer().has(RocketTransferKeys.NO_OTT); } return true; } diff --git a/plugins/zorweth-velocity/src/main/java/net/civmc/zorweth/velocity/ZorwethVelocityPlugin.java b/plugins/zorweth-velocity/src/main/java/net/civmc/zorweth/velocity/ZorwethVelocityPlugin.java index fb3919a61..9860c6379 100644 --- a/plugins/zorweth-velocity/src/main/java/net/civmc/zorweth/velocity/ZorwethVelocityPlugin.java +++ b/plugins/zorweth-velocity/src/main/java/net/civmc/zorweth/velocity/ZorwethVelocityPlugin.java @@ -24,9 +24,11 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Objects; import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.function.Function; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.slf4j.Logger; @@ -42,6 +44,7 @@ public final class ZorwethVelocityPlugin { private CommentedConfigurationNode config; private HikariDataSource dataSource; private RocketTransferRouter router; + private Function offlinePlayerResolver = ignored -> null; @Inject public ZorwethVelocityPlugin(final ProxyServer server, final Logger logger, @@ -59,6 +62,10 @@ public final class ZorwethVelocityPlugin { registerCommands(); } + public void setOfflinePlayerResolver(final Function offlinePlayerResolver) { + this.offlinePlayerResolver = Objects.requireNonNull(offlinePlayerResolver); + } + @Subscribe public void onProxyShutdown(final ProxyShutdownEvent event) { if (this.dataSource != null) { @@ -75,8 +82,7 @@ public final class ZorwethVelocityPlugin { final RegisteredServer target = event.getResult().getServer().orElse(event.getOriginalServer()); final String targetName = target.getServerInfo().getName(); - final String originalName = event.getOriginalServer().getServerInfo().getName(); - if (!isProtectedServer(targetName) && !isProtectedServer(originalName)) { + if (!isProtectedServer(targetName)) { return; } @@ -161,7 +167,7 @@ public final class ZorwethVelocityPlugin { commandManager.register(routeMeta, new RouteCommand()); } - private UUID parsePlayerId(final String input) throws SQLException { + private UUID parsePlayerId(final String input) { try { return UUID.fromString(input); } catch (final IllegalArgumentException ignored) { @@ -169,7 +175,7 @@ public final class ZorwethVelocityPlugin { if (onlinePlayer.isPresent()) { return onlinePlayer.get().getUniqueId(); } - return this.router.getPlayerId(input); + return this.offlinePlayerResolver.apply(input); } } @@ -244,15 +250,7 @@ public final class ZorwethVelocityPlugin { } CompletableFuture.runAsync(() -> { - final UUID playerId; - try { - playerId = parsePlayerId(args[0]); - } catch (final SQLException exception) { - source.sendMessage(Component.text("Failed to look up player.", NamedTextColor.RED)); - logger.error("Failed to look up player for Zorweth route override", exception); - return; - } - + final UUID playerId = parsePlayerId(args[0]); if (playerId == null) { source.sendMessage(Component.text("Unknown player. Use a UUID for offline players not in NameAPI.", NamedTextColor.RED)); return; @@ -300,24 +298,6 @@ public final class ZorwethVelocityPlugin { } } - private UUID getPlayerId(final String playerName) throws SQLException { - try (Connection connection = this.dataSource.getConnection(); - PreparedStatement statement = connection.prepareStatement(""" - SELECT uuid - FROM Name_player - WHERE player = ? - LIMIT 1 - """)) { - statement.setString(1, playerName); - try (ResultSet resultSet = statement.executeQuery()) { - if (!resultSet.next()) { - return null; - } - return UUID.fromString(resultSet.getString("uuid")); - } - } - } - private void setPlayerRoute(final UUID playerUuid, final String expectedServer) throws SQLException { try (Connection connection = this.dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement("""