mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2024-11-03 22:48:56 +00:00
fix: 调整异常捕获
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
5cfd7a1b2a
commit
b559c6f756
@ -52,9 +52,9 @@ public class C {
|
|||||||
getHandle = typeCraftPlayer.getMethod("getHandle");
|
getHandle = typeCraftPlayer.getMethod("getHandle");
|
||||||
playerConnection = typeNMSPlayer.getField("playerConnection");
|
playerConnection = typeNMSPlayer.getField("playerConnection");
|
||||||
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet")));
|
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet")));
|
||||||
} catch (final Throwable e) {
|
} catch (final Exception e) {
|
||||||
Log.warning(C.class.getSimpleName() + " 兼容性工具初始化失败 可能造成部分功能不可用!");
|
Log.warning(C.class.getSimpleName() + " 兼容性工具初始化失败 可能造成部分功能不可用!");
|
||||||
e.printStackTrace();
|
Log.debug(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ public class C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// getOnlinePlayers end
|
// getOnlinePlayers end
|
||||||
} catch (NoSuchMethodException | SecurityException e) {
|
} catch (final Exception e) {
|
||||||
Log.warning(Player.class.getSimpleName() + "兼容性工具初始化失败 可能造成部分功能不可用!");
|
Log.warning(Player.class.getSimpleName() + "兼容性工具初始化失败 可能造成部分功能不可用!");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -246,6 +246,7 @@ public class C {
|
|||||||
craftOfflinePlayerConstructor.setAccessible(true);
|
craftOfflinePlayerConstructor.setAccessible(true);
|
||||||
// getOfflinePlayer end
|
// getOfflinePlayer end
|
||||||
} catch (final Exception e) {
|
} 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 gameProfile = gameProfileConstructor.newInstance(new Object[] { UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(Charsets.UTF_8)), playerName });
|
||||||
final Object offlinePlayer = craftOfflinePlayerConstructor.newInstance(new Object[] { Bukkit.getServer(), gameProfile });
|
final Object offlinePlayer = craftOfflinePlayerConstructor.newInstance(new Object[] { Bukkit.getServer(), gameProfile });
|
||||||
return (OfflinePlayer) offlinePlayer;
|
return (OfflinePlayer) offlinePlayer;
|
||||||
} catch (final Throwable e) {
|
} catch (final Exception e) {
|
||||||
return Bukkit.getOfflinePlayer(playerName);
|
return Bukkit.getOfflinePlayer(playerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,7 +275,7 @@ public class C {
|
|||||||
public static Collection<? extends org.bukkit.entity.Player> getOnlinePlayers() {
|
public static Collection<? extends org.bukkit.entity.Player> getOnlinePlayers() {
|
||||||
try {
|
try {
|
||||||
return Arrays.asList((org.bukkit.entity.Player[]) getOnlinePlayers.invoke(null));
|
return Arrays.asList((org.bukkit.entity.Player[]) getOnlinePlayers.invoke(null));
|
||||||
} catch (final Throwable e) {
|
} catch (final Exception e) {
|
||||||
return Bukkit.getOnlinePlayers();
|
return Bukkit.getOnlinePlayers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,13 +400,13 @@ public class C {
|
|||||||
Object serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, "{\"text\":\"" + ChatColor.translateAlternateColorCodes('&', title) + "\"}");
|
Object serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, "{\"text\":\"" + ChatColor.translateAlternateColorCodes('&', title) + "\"}");
|
||||||
packet = packetTitle.getConstructor(packetActions, nmsIChatBaseComponent).newInstance(actions[0], serialized);
|
packet = packetTitle.getConstructor(packetActions, nmsIChatBaseComponent).newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
if (subtitle != "") {
|
if (!"".equals(subtitle)) {
|
||||||
// Send subtitle if present
|
// Send subtitle if present
|
||||||
serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, "{\"text\":\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\"}");
|
serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, "{\"text\":\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\"}");
|
||||||
packet = packetTitle.getConstructor(packetActions, nmsIChatBaseComponent).newInstance(actions[1], serialized);
|
packet = packetTitle.getConstructor(packetActions, nmsIChatBaseComponent).newInstance(actions[1], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
} catch (final Throwable e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,11 +130,11 @@ public class Statistics {
|
|||||||
* @param param
|
* @param param
|
||||||
* 请求参数
|
* 请求参数
|
||||||
* @return 所代表远程资源的响应结果
|
* @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;
|
PrintWriter out = null;
|
||||||
String result = "";
|
String result = "";
|
||||||
try {
|
|
||||||
final URL realUrl = new URL(url);
|
final URL realUrl = new URL(url);
|
||||||
// 打开和URL之间的连接
|
// 打开和URL之间的连接
|
||||||
final URLConnection conn = realUrl.openConnection();
|
final URLConnection conn = realUrl.openConnection();
|
||||||
@ -159,12 +159,9 @@ public class Statistics {
|
|||||||
result += response;
|
result += response;
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (final Exception e) {
|
|
||||||
} finally {
|
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user