Skip to content

Commit 93e827a

Browse files
1.0.27
1 parent cd8a7d8 commit 93e827a

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/me/zombie_striker/pixelprinter/GithubUpdater.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class GithubUpdater {
4040
* e.printStackTrace(); } }
4141
*/
4242

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

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

6868
new BukkitRunnable() {
@@ -72,6 +72,7 @@ public void run() {
7272
try {
7373

7474
InputStream in = download.openStream();
75+
7576

7677
File pluginFile = null;
7778

@@ -87,12 +88,23 @@ public void run() {
8788
// if (!temp.exists()) {
8889
// temp.mkdir();
8990
// }
91+
92+
File tempInCaseSomethingGoesWrong = new File(main.getName()+"-backup.jar");
93+
copy(new FileInputStream(pluginFile),new FileOutputStream(tempInCaseSomethingGoesWrong));
9094

9195
// Path path = new File("plugins/update" + File.separator + "COD.jar").toPath();
9296
pluginFile.setWritable(true, false);
9397
pluginFile.delete();
9498
//Files.copy(in, pluginFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
9599
copy(in, new FileOutputStream(pluginFile));
100+
101+
if(pluginFile.length()<1000) {
102+
//Plugin is too small. Keep old version in case new one is incomplete/nonexistant
103+
copy(new FileInputStream(tempInCaseSomethingGoesWrong),new FileOutputStream(pluginFile));
104+
}else {
105+
//Plugin is valid, and we can delete the temp
106+
tempInCaseSomethingGoesWrong.delete();
107+
}
96108

97109
} catch (IOException e) {
98110
e.printStackTrace();

src/me/zombie_striker/pixelprinter/util/SkinCreator.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class SkinCreator {
1616

1717
public static BufferedImage[] getSkin(String uuid)
1818
throws NullPointerException, IOException {
19+
int linecode = 19;
1920
try {
2021
StringBuilder code = new StringBuilder();
2122
InputStreamReader is = new InputStreamReader(new URL(
@@ -25,21 +26,26 @@ public static BufferedImage[] getSkin(String uuid)
2526
while ((charI = is.read()) != -1) {
2627
code.append(((char) charI));
2728
}
29+
linecode = 29;
2830
String[] aaaa = code.toString().split("\"value\":\"");
2931
if (aaaa.length == 1) {
30-
System.out.println("The user does not exist- Error-Ln31.");
32+
System.out.println("The user does not exist- AAAA does not contain value.");
3133
throw new NullPointerException();
3234
}
3335
String decode = new String(
3436
DatatypeConverter.parseBase64Binary(aaaa[1]
3537
.split("\"}],\"legacy\"")[0]));
38+
linecode =38;
3639
System.out.println(decode);
37-
String url = decode.split("url\":\"")[1].split("\"}")[0];
40+
String url = decode.split("url\":\"")[1].split("\"}")[0].split("\",\"")[0];
41+
linecode = 41;
3842
System.out.println(url);
3943
BufferedImage[] images = new BufferedImage[2];
4044
images[0] = ImageIO.read(new URL(url));
45+
linecode = 45;
4146
if (decode.contains("CAPE")) {
4247
String urlcape = decode.split("url\":\"")[2].split("\"}")[0];
48+
linecode = 48;
4349
images[1] = ImageIO.read(new URL(urlcape));
4450
}
4551
return images;
@@ -48,7 +54,7 @@ public static BufferedImage[] getSkin(String uuid)
4854
.println("The Mojang servers denied the request. Wait a minute or so until you are allowed to get the texture again.");
4955
throw new NullPointerException();
5056
} catch (IOException e2) {
51-
System.out.println("The user does not exist- Error-Ln46.");
57+
System.out.println("The user does not exist- ErrorLineCode="+linecode+".");
5258
throw new IOException();
5359
}
5460
}

0 commit comments

Comments
 (0)