Compare commits

..

3 Commits

Author SHA1 Message Date
Colbster937
e7343b557d Merge pull request #17 from Cirsius/main
fix NullPointerException when geyser dispatches ProxyPingEvent with a null virtual host
2026-02-11 07:34:52 -06:00
cirsius
47d451362b fix NullPointerException when geyser dispatches ProxyPingEvent with a null virtual host 2026-02-11 05:33:20 -06:00
Colbster937
f4261e0d6c update 2026-02-05 17:36:05 -06:00
3 changed files with 16 additions and 11 deletions

View File

@@ -326,7 +326,7 @@ public final class OriginBlacklistConfig {
addJSONObj(uObj, "enabled", Json5Primitive.fromBoolean(true), null);
addJSONObj(uObj, "allow_snapshots", Json5Primitive.fromBoolean(false), null);
addJSONObj(uObj, "check_timer", Json5Primitive.fromNumber(3600), null);
addJSONObj(uObj, "auto_update", Json5Primitive.fromBoolean(true), null);
addJSONObj(uObj, "auto_update", Json5Primitive.fromBoolean(false), null);
addJSONObj(obj, "update_checker", uObj, null);
addJSONObj(obj, "blacklist_http_api", Json5Primitive.fromBoolean(false), null);
addJSONObj(obj, "blacklist_to_whitelist", Json5Primitive.fromBoolean(false), null);

View File

@@ -94,8 +94,9 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
final PendingConnection conn = event.getPlayer().getPendingConnection();
final InetSocketAddress vhost = conn.getVirtualHost();
final ProxiedPlayer aPlayer = event.getPlayer();
final String origin = vhost != null ? vhost.getHostString() + vhost.getPort() : OriginBlacklist.UNKNOWN_STR;
final OPlayer bPlayer = new OPlayer(null, aPlayer.getName(), aPlayer.getUniqueId(),
aPlayer.getAddress().toString(), aPlayer.getClientBrand(), vhost.getHostString() + vhost.getPort(),
aPlayer.getAddress().toString(), aPlayer.getClientBrand(), origin,
conn.getVersion());
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, bPlayer));
}
@@ -104,8 +105,9 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
public final void onJavaHandshake(final PreLoginEvent event) {
final PendingConnection conn = event.getConnection();
final InetSocketAddress vhost = conn.getVirtualHost();
final String origin = vhost != null ? vhost.getHostString() + vhost.getPort() : OriginBlacklist.UNKNOWN_STR;
final OPlayer player = new OPlayer(null, null, null, conn.getAddress().toString(), OriginBlacklist.UNKNOWN_STR,
vhost.getHostString() + vhost.getPort(), conn.getVersion());
origin, conn.getVersion());
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, player));
}
@@ -113,8 +115,9 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
public final void onJavaMOTD(final ProxyPingEvent event) {
final PendingConnection conn = event.getConnection();
final InetSocketAddress vhost = conn.getVirtualHost();
final String origin = vhost != null ? vhost.getHostString() + vhost.getPort() : OriginBlacklist.UNKNOWN_STR;
final OPlayer player = new OPlayer(null, null, null, conn.getAddress().toString(), null,
vhost.getHostString() + vhost.getPort(), -1);
origin, -1);
this.blacklist.handleMOTD(new OriginBlacklistMOTDEvent(null, event, EnumConnectionType.JAVA, player));
}

View File

@@ -108,19 +108,21 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
@Subscribe(order = PostOrder.FIRST)
public final void onJavaLogin(final PreLoginEvent event) {
final InboundConnection conn = event.getConnection();
final InetSocketAddress vhost = conn.getVirtualHost().orElseThrow();
final InetSocketAddress vhost = conn.getVirtualHost().orElse(null);
final String origin = vhost != null ? vhost.getHostString() + vhost.getPort() : OriginBlacklist.UNKNOWN_STR;
final OPlayer player = new OPlayer(null, event.getUsername(), event.getUniqueId(),
conn.getRemoteAddress().toString(), OriginBlacklist.UNKNOWN_STR, vhost.getHostString() + vhost.getPort(),
conn.getRemoteAddress().toString(), OriginBlacklist.UNKNOWN_STR, origin,
conn.getProtocolVersion().getProtocol());
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, player));
}
@Subscribe(order = PostOrder.FIRST)
public final void onJavaHandshake(final PlayerClientBrandEvent event) {
final InetSocketAddress vhost = event.getPlayer().getVirtualHost().orElseThrow();
final InetSocketAddress vhost = event.getPlayer().getVirtualHost().orElse(null);
final String origin = vhost != null ? vhost.getHostString() + vhost.getPort() : OriginBlacklist.UNKNOWN_STR;
final Player aPlayer = event.getPlayer();
final OPlayer bPlayer = new OPlayer(null, aPlayer.getUsername(), aPlayer.getUniqueId(),
aPlayer.getRemoteAddress().getAddress().toString(), event.getBrand(), vhost.getHostString() + vhost.getPort(),
aPlayer.getRemoteAddress().getAddress().toString(), event.getBrand(), origin,
event.getPlayer().getProtocolVersion().getProtocol());
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, bPlayer));
}
@@ -128,10 +130,10 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
@Subscribe(order = PostOrder.LAST)
public final void onJavaMOTD(final ProxyPingEvent event) {
final InboundConnection conn = event.getConnection();
final InetSocketAddress vhost = conn.getVirtualHost().orElseThrow();
final InetSocketAddress vhost = conn.getVirtualHost().orElse(null);
final String origin = vhost != null ? vhost.getHostString() + vhost.getPort() : OriginBlacklist.UNKNOWN_STR;
final OPlayer player = new OPlayer(null, null, null, conn.getRemoteAddress().getHostString(),
vhost.getHostString() + vhost.getPort(),
null, -1);
null, origin, -1);
this.blacklist.handleMOTD(new OriginBlacklistMOTDEvent(null, event, EnumConnectionType.JAVA, player));
}