Skip to content

Commit

Permalink
1.0.27
Browse files Browse the repository at this point in the history
  • Loading branch information
ZombieStriker authored Feb 23, 2018
1 parent cd8a7d8 commit 93e827a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
16 changes: 14 additions & 2 deletions src/me/zombie_striker/pixelprinter/GithubUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class GithubUpdater {
* e.printStackTrace(); } }
*/

public static boolean autoUpdate(Plugin main, String author, String githubProject, String jarname) {
public static boolean autoUpdate(final Plugin main, String author, String githubProject, String jarname) {
try {
String version = main.getDescription().getVersion();
String parseVersion = version.replace(".", "");
Expand All @@ -62,7 +62,7 @@ public static boolean autoUpdate(Plugin main, String author, String githubProjec
+ tagname + "/" + jarname);

if (latestVersion > Integer.parseInt(parseVersion)) {
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Found a new version " + ChatColor.WHITE
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Found a new version of "+ChatColor.GOLD+main.getDescription().getName()+": " + ChatColor.WHITE
+ tagname + ChatColor.LIGHT_PURPLE + " downloading now!!");

new BukkitRunnable() {
Expand All @@ -72,6 +72,7 @@ public void run() {
try {

InputStream in = download.openStream();


File pluginFile = null;

Expand All @@ -87,12 +88,23 @@ public void run() {
// if (!temp.exists()) {
// temp.mkdir();
// }

File tempInCaseSomethingGoesWrong = new File(main.getName()+"-backup.jar");
copy(new FileInputStream(pluginFile),new FileOutputStream(tempInCaseSomethingGoesWrong));

// Path path = new File("plugins/update" + File.separator + "COD.jar").toPath();
pluginFile.setWritable(true, false);
pluginFile.delete();
//Files.copy(in, pluginFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
copy(in, new FileOutputStream(pluginFile));

if(pluginFile.length()<1000) {
//Plugin is too small. Keep old version in case new one is incomplete/nonexistant
copy(new FileInputStream(tempInCaseSomethingGoesWrong),new FileOutputStream(pluginFile));
}else {
//Plugin is valid, and we can delete the temp
tempInCaseSomethingGoesWrong.delete();
}

} catch (IOException e) {
e.printStackTrace();
Expand Down
12 changes: 9 additions & 3 deletions src/me/zombie_striker/pixelprinter/util/SkinCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SkinCreator {

public static BufferedImage[] getSkin(String uuid)
throws NullPointerException, IOException {
int linecode = 19;
try {
StringBuilder code = new StringBuilder();
InputStreamReader is = new InputStreamReader(new URL(
Expand All @@ -25,21 +26,26 @@ public static BufferedImage[] getSkin(String uuid)
while ((charI = is.read()) != -1) {
code.append(((char) charI));
}
linecode = 29;
String[] aaaa = code.toString().split("\"value\":\"");
if (aaaa.length == 1) {
System.out.println("The user does not exist- Error-Ln31.");
System.out.println("The user does not exist- AAAA does not contain value.");
throw new NullPointerException();
}
String decode = new String(
DatatypeConverter.parseBase64Binary(aaaa[1]
.split("\"}],\"legacy\"")[0]));
linecode =38;
System.out.println(decode);
String url = decode.split("url\":\"")[1].split("\"}")[0];
String url = decode.split("url\":\"")[1].split("\"}")[0].split("\",\"")[0];
linecode = 41;
System.out.println(url);
BufferedImage[] images = new BufferedImage[2];
images[0] = ImageIO.read(new URL(url));
linecode = 45;
if (decode.contains("CAPE")) {
String urlcape = decode.split("url\":\"")[2].split("\"}")[0];
linecode = 48;
images[1] = ImageIO.read(new URL(urlcape));
}
return images;
Expand All @@ -48,7 +54,7 @@ public static BufferedImage[] getSkin(String uuid)
.println("The Mojang servers denied the request. Wait a minute or so until you are allowed to get the texture again.");
throw new NullPointerException();
} catch (IOException e2) {
System.out.println("The user does not exist- Error-Ln46.");
System.out.println("The user does not exist- ErrorLineCode="+linecode+".");
throw new IOException();
}
}
Expand Down

0 comments on commit 93e827a

Please sign in to comment.