Skip to content

Commit

Permalink
Removed the proxy and added the MineOnline protocol.
Browse files Browse the repository at this point in the history
  • Loading branch information
craftycodie committed Jul 9, 2021
1 parent 7acc9c0 commit fa109c4
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 641 deletions.
429 changes: 154 additions & 275 deletions .idea/workspace.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions res/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: OnlineModeFix
version: 1.0.0
description: Fixes online-mode authentication
version: 1.1.0
description: Fixes online-mode authentication.
author: craftycodie
authors: [Codie]
website: https://twitter.com/craftycodie
Expand Down
51 changes: 7 additions & 44 deletions src/OnlineModeFix.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@

import gg.codie.mineonline.plugin.ProxyThread;
import gg.codie.mineonline.protocol.MineOnlineURLStreamHandlerFactory;

import java.io.*;
import java.net.ServerSocket;
import java.net.URL;
import java.util.Properties;
import java.util.logging.Logger;

public class OnlineModeFix extends Plugin {
private static String NAME = "OnlineModeFix";
Logger log;
ProxyThread proxyThread;
boolean initialized;

public void launchProxy() throws IOException {
ServerSocket serverSocket = new ServerSocket(0);
proxyThread = new ProxyThread(serverSocket);
proxyThread.start();

System.out.println("Enabling online-mode fix.");
public void enableOnlineMode() {
this.log = Logger.getLogger("Minecraft");

System.setProperty("http.proxyHost", serverSocket.getInetAddress().getHostAddress());
System.setProperty("http.proxyPort", "" + serverSocket.getLocalPort());
System.setProperty("http.nonProxyHosts", "localhost|127.0.0.1");
}
log.info("Enabling online-mode fix.");

public void stopProxy() {
if (proxyThread != null) {
proxyThread.stop();
proxyThread = null;
}
URL.setURLStreamHandlerFactory(new MineOnlineURLStreamHandlerFactory());
}

public void enable() {
Expand All @@ -38,23 +24,7 @@ public void enable() {
}

public void initialize() {
if (initialized)
return;

this.log = Logger.getLogger("Minecraft");

Properties propertiesFile = new Properties();

try {
propertiesFile.load(new FileInputStream(new File("server.properties")));
boolean onlineMode = propertiesFile.getProperty("online-mode", "true").equals("true");

if (onlineMode)
launchProxy();
} catch (Exception ex) {
log.warning("Failed to enable online-mode fix. Authentication may fail.");
}
initialized = true;
enableOnlineMode();
}

private void register(PluginLoader.Hook hook, PluginListener.Priority priority) {
Expand All @@ -70,13 +40,6 @@ private void register(PluginLoader.Hook hook) {
}

public void disable() {
if (!initialized)
return;

unregister();

stopProxy();

initialized = false;
}
}
271 changes: 0 additions & 271 deletions src/gg/codie/mineonline/plugin/ProxyThread.java

This file was deleted.

Loading

0 comments on commit fa109c4

Please sign in to comment.