Skip to content

Commit

Permalink
fix: отключено отключения сокет сервера в случае ошибки
Browse files Browse the repository at this point in the history
- Добавлен аргумент -snowfall_everywhere
- Убран NativeNetworking.NetworkLoopHandler.CLIENT_HANDLER
- Добавлена поддержка ников в глобальном бане
  • Loading branch information
Reider745 committed Jan 5, 2024
1 parent e5a3bff commit 57fa627
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
6 changes: 5 additions & 1 deletion src/main/java/com/reider745/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public static void main(String[] args) throws Throwable {
loader.registerHooksInitializationForClass(LevelHooks.class);
loader.registerHooksInitializationForClass(ItemUtils.class);
loader.registerHooksInitializationForClass(AndroidHooks.class);
// loader.registerHooksInitializationForClass(SnowfallEverywhere.class);

for(String arg : args)
if(arg.equals("-snowfall_everywhere"))
loader.registerHooksInitializationForClass(SnowfallEverywhere.class);

// loader.registerHooksInitializationForClass(BiomesHooks.class);
loader.registerHooksInitializationForClass(GlobalBanList.class);

Expand Down
13 changes: 4 additions & 9 deletions src/main/java/com/reider745/hooks/GlobalBanList.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public class GlobalBanList implements HookClass {

list = new JSONArray(result);
}
} catch (Exception ignored) {
ignored.printStackTrace();
}
} catch (Exception ignored) {}

final String[] banListGit = new String[list.length()];
for(int i = 0;i < banListGit.length;i++)
Expand All @@ -55,12 +53,9 @@ public class GlobalBanList implements HookClass {

@Inject
public static boolean isBanned(BanList self, String name){
final String file = ReflectHelper.getField(self, "file");

if(file != null && file.endsWith("banned-ips.json"))
for(final String ip : banList)
if(ip.equals(name))
return true;
for(final String ip : banList)
if(ip.equals(name))
return true;

if (!self.isEnable() || name == null)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void startLanServer(int port) {
//shutdown();

NativeNetworking.NetworkLoopHandler handler = new NativeNetworking.NetworkLoopHandler(
NativeNetworking.NetworkLoopHandler.GLOBAL_HANDLER | NativeNetworking.NetworkLoopHandler.SERVER_HANDLER | NativeNetworking.NetworkLoopHandler.CLIENT_HANDLER
NativeNetworking.NetworkLoopHandler.GLOBAL_HANDLER | NativeNetworking.NetworkLoopHandler.SERVER_HANDLER
).start();

startServer(port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public void start(int port) throws IOException {
continue;
}

Logger.debug("New socket connection "+socket.getInetAddress());

try {
int protocol = socket.getInputStream().read();
DataChannel channel = DataChannelFactory.newDataChannelViaSupportedProtocol(socket, protocol);
Expand All @@ -53,8 +55,7 @@ public void start(int port) throws IOException {
} catch (IOException e) {
e.printStackTrace();
}
isRunning = false;
return;
continue;
}

boolean isChannelManaged = false;
Expand All @@ -70,7 +71,6 @@ public void start(int port) throws IOException {
} catch (IOException e) {
e.printStackTrace();
}
isRunning = false;
}
}
}).start();
Expand Down

0 comments on commit 57fa627

Please sign in to comment.