1313import com .velocitypowered .api .plugin .Plugin ;
1414import com .velocitypowered .api .plugin .annotation .DataDirectory ;
1515import com .velocitypowered .api .proxy .ProxyServer ;
16- import com .velocitypowered .api .proxy .server .RegisteredServer ;
1716import com .velocitypowered .api .proxy .server .ServerPing ;
1817import io .netty .bootstrap .ServerBootstrap ;
1918import io .netty .channel .ChannelFuture ;
3130import java .util .concurrent .CompletableFuture ;
3231import java .util .concurrent .TimeUnit ;
3332
34- @ Plugin (id = "denizen-velocity" , name = "denizen-velocity" , version = "1.1 " , authors = {"isnsest" })
33+ @ Plugin (id = "denizen-velocity" , name = "denizen-velocity" , version = "1.2 " , authors = {"isnsest" })
3534public class DenizenVelocity {
3635
3736 public static DenizenVelocity instance ;
@@ -41,8 +40,6 @@ public class DenizenVelocity {
4140 public static YamlConfig config ;
4241
4342 private static int DEPENIZEN_PORT = 0 ;
44- // public static boolean proxyCommandNoDup = false;
45- // public static long proxyCommandId = 1;
4643
4744 public HashMap <Integer , PacketIn > packets = new HashMap <>();
4845 private final List <DenizenConnection > connections = new ArrayList <>();
@@ -140,32 +137,8 @@ private void startServer() {
140137 @ Override
141138 public void initChannel (SocketChannel ch ) {
142139 InetSocketAddress remoteAddress = ch .remoteAddress ();
143- String remoteIp = remoteAddress .getAddress ().getHostAddress ();
144-
145- RegisteredServer matchedServer = null ;
146- for (RegisteredServer rs : server .getAllServers ()) {
147- String serverIp = rs .getServerInfo ().getAddress ().getAddress ().getHostAddress ();
148- if (serverIp .equals (remoteIp )) {
149- matchedServer = rs ;
150- break ;
151- }
152- if ((remoteIp .equals ("127.0.0.1" ) || remoteIp .equals ("0:0:0:0:0:0:0:1" ))
153- && (rs .getServerInfo ().getAddress ().getAddress ().isLoopbackAddress ())) {
154- matchedServer = rs ;
155- break ;
156- }
157- }
158-
159- if (matchedServer == null ) {
160- logger .warn ("BLOCKED connection from " + remoteIp );
161- ch .close ();
162- return ;
163- }
164-
165- logger .info ("Accepted connection from " + remoteIp + " as server: " + matchedServer .getServerInfo ().getName ());
166140
167141 DenizenConnection depenConnection = new DenizenConnection ();
168- depenConnection .thisServer = matchedServer ;
169142 depenConnection .build (ch , remoteAddress .getAddress ());
170143 }
171144 });
@@ -241,7 +214,6 @@ public void onProxyPing(ProxyPingEvent event) {
241214 finalPing .version (finalVersion );
242215
243216 event .setPing (finalPing .build ());
244-
245217 } catch (Exception e ) {
246218 connection .proxyPingWaiters .remove (id );
247219 }
@@ -253,7 +225,9 @@ public void onProxyPing(ProxyPingEvent event) {
253225
254226 public void broadcastPacket (PacketOut packet ) {
255227 for (DenizenConnection connection : getConnections ()) {
256- connection .sendPacket (packet );
228+ if (connection .thisServer != null ) {
229+ connection .sendPacket (packet );
230+ }
257231 }
258232 }
259233}
0 commit comments