mirror of
				https://e.coding.net/circlecloud/YumCore.git
				synced 2025-11-03 23:06:02 +00:00 
			
		
		
		
	@@ -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,40 +130,37 @@ 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();
 | 
					        // 设置通用的请求属性
 | 
				
			||||||
            // 设置通用的请求属性
 | 
					        conn.setRequestProperty("Accept", "*/*");
 | 
				
			||||||
            conn.setRequestProperty("Accept", "*/*");
 | 
					        conn.setRequestProperty("Connection", "Keep-Alive");
 | 
				
			||||||
            conn.setRequestProperty("Connection", "Keep-Alive");
 | 
					        conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36");
 | 
				
			||||||
            conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36");
 | 
					        // 设置超时时间 10秒
 | 
				
			||||||
            // 设置超时时间 10秒
 | 
					        conn.setReadTimeout(10000);
 | 
				
			||||||
            conn.setReadTimeout(10000);
 | 
					        // 发送POST请求必须设置如下两行
 | 
				
			||||||
            // 发送POST请求必须设置如下两行
 | 
					        conn.setDoOutput(true);
 | 
				
			||||||
            conn.setDoOutput(true);
 | 
					        conn.setDoInput(true);
 | 
				
			||||||
            conn.setDoInput(true);
 | 
					        // 获取URLConnection对象对应的输出流
 | 
				
			||||||
            // 获取URLConnection对象对应的输出流
 | 
					        out = new PrintWriter(conn.getOutputStream());
 | 
				
			||||||
            out = new PrintWriter(conn.getOutputStream());
 | 
					        // 发送请求参数
 | 
				
			||||||
            // 发送请求参数
 | 
					        out.write(param);
 | 
				
			||||||
            out.write(param);
 | 
					        // flush输出流的缓冲
 | 
				
			||||||
            // flush输出流的缓冲
 | 
					        out.flush();
 | 
				
			||||||
            out.flush();
 | 
					        String response = "";
 | 
				
			||||||
            String response = "";
 | 
					        final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), UTF_8));
 | 
				
			||||||
            final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), UTF_8));
 | 
					        while ((response = reader.readLine()) != null) {
 | 
				
			||||||
            while ((response = reader.readLine()) != null) {
 | 
					            result += response;
 | 
				
			||||||
                result += response;
 | 
					        }
 | 
				
			||||||
            }
 | 
					        reader.close();
 | 
				
			||||||
            reader.close();
 | 
					        if (out != null) {
 | 
				
			||||||
        } catch (final Exception e) {
 | 
					            out.close();
 | 
				
			||||||
        } finally {
 | 
					 | 
				
			||||||
            if (out != null) {
 | 
					 | 
				
			||||||
                out.close();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return result;
 | 
					        return result;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user