fix: 调整异常捕获

Signed-off-by: 502647092 <admin@yumc.pw>
merge/1/MERGE
502647092 2016-09-19 16:19:03 +08:00
parent 5cfd7a1b2a
commit b559c6f756
2 changed files with 36 additions and 38 deletions

View File

@ -52,9 +52,9 @@ public class C {
getHandle = typeCraftPlayer.getMethod("getHandle");
playerConnection = typeNMSPlayer.getField("playerConnection");
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet")));
} catch (final Throwable e) {
} catch (final Exception e) {
Log.warning(C.class.getSimpleName() + " 兼容性工具初始化失败 可能造成部分功能不可用!");
e.printStackTrace();
Log.debug(e);
}
}
@ -225,7 +225,7 @@ public class C {
}
}
// getOnlinePlayers end
} catch (NoSuchMethodException | SecurityException e) {
} catch (final Exception e) {
Log.warning(Player.class.getSimpleName() + "兼容性工具初始化失败 可能造成部分功能不可用!");
}
try {
@ -246,6 +246,7 @@ public class C {
craftOfflinePlayerConstructor.setAccessible(true);
// getOfflinePlayer end
} catch (final Exception e) {
Log.debug(e);
}
}
@ -261,7 +262,7 @@ public class C {
final Object gameProfile = gameProfileConstructor.newInstance(new Object[] { UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(Charsets.UTF_8)), playerName });
final Object offlinePlayer = craftOfflinePlayerConstructor.newInstance(new Object[] { Bukkit.getServer(), gameProfile });
return (OfflinePlayer) offlinePlayer;
} catch (final Throwable e) {
} catch (final Exception e) {
return Bukkit.getOfflinePlayer(playerName);
}
}
@ -274,7 +275,7 @@ public class C {
public static Collection<? extends org.bukkit.entity.Player> getOnlinePlayers() {
try {
return Arrays.asList((org.bukkit.entity.Player[]) getOnlinePlayers.invoke(null));
} catch (final Throwable e) {
} catch (final Exception e) {
return Bukkit.getOnlinePlayers();
}
}
@ -399,13 +400,13 @@ public class C {
Object serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, "{\"text\":\"" + ChatColor.translateAlternateColorCodes('&', title) + "\"}");
packet = packetTitle.getConstructor(packetActions, nmsIChatBaseComponent).newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet);
if (subtitle != "") {
if (!"".equals(subtitle)) {
// Send subtitle if present
serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, "{\"text\":\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\"}");
packet = packetTitle.getConstructor(packetActions, nmsIChatBaseComponent).newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
}
} catch (final Throwable e) {
} catch (final Exception e) {
e.printStackTrace();
}
}

View File

@ -130,11 +130,11 @@ public class Statistics {
* @param param
*
* @return
* @throws IOException
*/
public static String postData(final String url, final String param) {
public static String postData(final String url, final String param) throws IOException {
PrintWriter out = null;
String result = "";
try {
final URL realUrl = new URL(url);
// 打开和URL之间的连接
final URLConnection conn = realUrl.openConnection();
@ -159,12 +159,9 @@ public class Statistics {
result += response;
}
reader.close();
} catch (final Exception e) {
} finally {
if (out != null) {
out.close();
}
}
return result;
}