Skip to content

Commit 8620e43

Browse files
committed
First commit
0 parents  commit 8620e43

File tree

4 files changed

+288
-0
lines changed

4 files changed

+288
-0
lines changed

ReadMe.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# MinecraftUnblocker
2+
3+
## Description
4+
5+
Copies a select Minecraft version and removes the blocking server implementation.
6+
7+
An alternative to downloading the forge client
8+
9+
## Images
10+
11+
![Unblocked client](http://i.imgur.com/Ld7tCZU.png)

pom.xml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.github.games647</groupId>
6+
<artifactId>minecraftunblocker</artifactId>
7+
<packaging>jar</packaging>
8+
9+
<name>MinecraftUnblocker</name>
10+
<version>1.0</version>
11+
<inceptionYear>2016</inceptionYear>
12+
13+
<url>https://github.com/games647/MinecraftUnblocker/</url>
14+
<description>
15+
Lets you connect to blocked servers again
16+
</description>
17+
18+
<properties>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
</properties>
21+
22+
<issueManagement>
23+
<system>GitHub</system>
24+
<url>https://github.com/games647/MinecraftUnblocker/issues</url>
25+
</issueManagement>
26+
27+
<scm>
28+
<url>https://github.com/games647/MinecraftUnblocker</url>
29+
<connection>scm:git:git://github.com/games647/MinecraftUnblocker.git</connection>
30+
<developerConnection>scm:git:ssh://git@github.com:games647/MinecraftUnblocker.git</developerConnection>
31+
</scm>
32+
33+
<build>
34+
<plugins>
35+
<plugin>
36+
<groupId>org.apache.maven.plugins</groupId>
37+
<artifactId>maven-compiler-plugin</artifactId>
38+
<version>3.5.1</version>
39+
<configuration>
40+
<source>1.8</source>
41+
<target>1.8</target>
42+
<showWarnings>true</showWarnings>
43+
<showDeprecation>true</showDeprecation>
44+
</configuration>
45+
</plugin>
46+
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-shade-plugin</artifactId>
50+
<version>2.4.3</version>
51+
<configuration>
52+
<artifactSet>
53+
<includes>
54+
<include>com.googlecode.json-simple:json-simple</include>
55+
</includes>
56+
</artifactSet>
57+
</configuration>
58+
<executions>
59+
<execution>
60+
<phase>package</phase>
61+
<goals>
62+
<goal>shade</goal>
63+
</goals>
64+
</execution>
65+
</executions>
66+
</plugin>
67+
68+
<plugin>
69+
<groupId>org.apache.maven.plugins</groupId>
70+
<artifactId>maven-jar-plugin</artifactId>
71+
<version>2.6</version>
72+
<configuration>
73+
<archive>
74+
<manifest>
75+
<mainClass>com.github.games647.minecraftunblocker.MinecraftUnblocker</mainClass>
76+
</manifest>
77+
</archive>
78+
</configuration>
79+
</plugin>
80+
</plugins>
81+
</build>
82+
83+
<licenses>
84+
<license>
85+
<name>The MIT License</name>
86+
<url>http://opensource.org/licenses/MIT</url>
87+
<distribution>repo</distribution>
88+
</license>
89+
</licenses>
90+
91+
<dependencies>
92+
<dependency>
93+
<groupId>com.googlecode.json-simple</groupId>
94+
<artifactId>json-simple</artifactId>
95+
<version>1.1.1</version>
96+
</dependency>
97+
</dependencies>
98+
</project>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
package com.github.games647.minecraftunblocker;
2+
3+
import java.awt.FlowLayout;
4+
import java.awt.event.ActionEvent;
5+
import java.awt.event.ActionListener;
6+
import java.io.File;
7+
import java.io.FileReader;
8+
import java.io.IOException;
9+
import java.nio.charset.StandardCharsets;
10+
import java.nio.file.Files;
11+
import java.nio.file.Path;
12+
import java.util.ArrayList;
13+
import java.util.Arrays;
14+
import java.util.List;
15+
import java.util.logging.Level;
16+
import java.util.logging.Logger;
17+
import java.util.stream.Stream;
18+
19+
import javax.swing.JButton;
20+
import javax.swing.JComboBox;
21+
import javax.swing.JFrame;
22+
import javax.swing.JLabel;
23+
import javax.swing.JOptionPane;
24+
25+
import org.json.simple.JSONArray;
26+
import org.json.simple.JSONObject;
27+
import org.json.simple.JSONValue;
28+
import org.json.simple.parser.ParseException;
29+
30+
public class MinecraftUnblocker {
31+
32+
public static void main(String[] args) {
33+
File minecraftFolder = getWorkingDirectory();
34+
final File versionsFolder = new File(minecraftFolder, "versions/");
35+
36+
List<String> selectItems = new ArrayList<>();
37+
selectItems.add("SELECT");
38+
Stream.of(versionsFolder.list()).forEach((fileName) -> selectItems.add(fileName));
39+
versionsFolder.listFiles();
40+
41+
JFrame frame = new JFrame();
42+
FlowLayout experimentLayout = new FlowLayout();
43+
frame.setLayout(experimentLayout);
44+
45+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
46+
frame.add(new JLabel("Select the version you want to unblock"));
47+
final JComboBox<String> list = new JComboBox(selectItems.toArray());
48+
frame.add(list);
49+
50+
JButton button = new JButton("Unblock");
51+
frame.add(button);
52+
53+
frame.pack();
54+
frame.setVisible(true);
55+
button.addActionListener(new ActionListener() {
56+
@Override
57+
public void actionPerformed(ActionEvent actionEvent) {
58+
String selectedVersion = (String) list.getSelectedItem();
59+
File sourceFolder = new File(versionsFolder, selectedVersion);
60+
if (!sourceFolder.exists() || !sourceFolder.isDirectory()) {
61+
JOptionPane.showMessageDialog(frame, "Folder not found");
62+
} else {
63+
File destinationDir = new File(versionsFolder, selectedVersion + "-Unblock");
64+
destinationDir.mkdir();
65+
66+
Path sourceJsonFile = new File(sourceFolder, selectedVersion + ".json").toPath();
67+
Path targetJsonFile = new File(destinationDir, selectedVersion + "-Unblock" + ".json").toPath();
68+
69+
Path sourceJarFile = new File(sourceFolder, selectedVersion + ".jar").toPath();
70+
Path targetJarFile = new File(destinationDir, selectedVersion + "-Unblock" + ".jar").toPath();
71+
try {
72+
Files.copy(sourceJarFile, targetJarFile);
73+
Files.copy(sourceJsonFile, targetJsonFile);
74+
75+
JSONObject json = (JSONObject) JSONValue
76+
.parseWithException(new FileReader(targetJsonFile.toFile()));
77+
json.put("id", selectedVersion + "-Unblock");
78+
JSONArray libraries = (JSONArray) json.get("libraries");
79+
for (Object libraryObj : libraries) {
80+
JSONObject library = (JSONObject) libraryObj;
81+
String name = (String) library.get("name");
82+
if (name.startsWith("com.mojang:netty")) {
83+
libraries.remove(libraryObj);
84+
break;
85+
}
86+
}
87+
88+
Files.write(targetJsonFile, Arrays.asList(json.toJSONString()), StandardCharsets.UTF_8);
89+
JOptionPane.showMessageDialog(frame, "Sucessfully created an unblocked version. \n"
90+
+ "Now restart your launcher and select the version with the suffix -Unblock");
91+
} catch (IOException | ParseException ex) {
92+
Logger.getLogger(MinecraftUnblocker.class.getName()).log(Level.SEVERE, null, ex);
93+
JOptionPane.showMessageDialog(frame, "Error " + ex.getMessage());
94+
}
95+
}
96+
}
97+
});
98+
}
99+
100+
public static File getWorkingDirectory() {
101+
String userHome = System.getProperty("user.home", ".");
102+
File workingDirectory;
103+
switch (OS.getPlatform()){
104+
case LINUX:
105+
case SOLARIS:
106+
workingDirectory = new File(userHome, ".minecraft/");
107+
break;
108+
case WINDOWS:
109+
String applicationData = System.getenv("APPDATA");
110+
String folder = applicationData != null ? applicationData : userHome;
111+
112+
workingDirectory = new File(folder, ".minecraft/");
113+
break;
114+
case MACOS:
115+
workingDirectory = new File(userHome, "Library/Application Support/minecraft");
116+
break;
117+
default:
118+
workingDirectory = new File(userHome, "minecraft/");
119+
}
120+
121+
return workingDirectory;
122+
}
123+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* The MIT License
3+
*
4+
* Copyright 2016 Win7Home.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
package com.github.games647.minecraftunblocker;
25+
26+
public enum OS {
27+
WINDOWS,
28+
MACOS,
29+
SOLARIS,
30+
LINUX,
31+
UNKNOWN;
32+
33+
private OS() {
34+
}
35+
36+
public static OS getPlatform() {
37+
String osName = System.getProperty("os.name").toLowerCase();
38+
if (osName.contains("win")) {
39+
return OS.WINDOWS;
40+
}
41+
42+
if (osName.contains("mac")) {
43+
return OS.MACOS;
44+
}
45+
46+
if (osName.contains("linux")) {
47+
return OS.LINUX;
48+
}
49+
50+
if (osName.contains("unix")) {
51+
return OS.LINUX;
52+
}
53+
54+
return OS.UNKNOWN;
55+
}
56+
}

0 commit comments

Comments
 (0)