mirror of
https://github.com/NEZNAMY/TAB.git
synced 2026-11-26 10:29:49 -05:00
removed unnecessary code
This commit is contained in:
1 parent
bddda19192
commit
5012d41a57
5 files changed
+13
-47
No files matched your search
@@ -577,15 +577,4 @@ public class Main extends JavaPlugin implements Listener, MainClass{
|
||||
return new Player[0];
|
||||
}
|
||||
}
|
||||
public static int getOnlinePlayersCount() {
|
||||
try {
|
||||
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
||||
return onlinePlayersMethod.getReturnType().equals(Collection.class)
|
||||
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
|
||||
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||
} catch (Exception e) {
|
||||
Shared.error("Failed to get player count", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,10 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
@@ -23,6 +25,7 @@ import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
@@ -217,7 +220,15 @@ public class Metrics {
|
||||
*/
|
||||
private JSONObject getServerData() {
|
||||
// Minecraft specific data
|
||||
int playerAmount = Main.getOnlinePlayersCount();
|
||||
int playerAmount;
|
||||
try {
|
||||
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
||||
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
|
||||
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
|
||||
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||
} catch (Exception e) {
|
||||
playerAmount = 0;
|
||||
}
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
String bukkitVersion = Bukkit.getVersion();
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
package me.neznamy.tab.platforms.bukkit.packets;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
import me.neznamy.tab.platforms.bukkit.packets.method.MethodAPI;
|
||||
import me.neznamy.tab.shared.ProtocolVersion;
|
||||
|
||||
public class DataWatcherObject{
|
||||
|
||||
private int position;
|
||||
@@ -21,20 +15,4 @@ public class DataWatcherObject{
|
||||
public Object getClassType(){
|
||||
return classType;
|
||||
}
|
||||
public static DataWatcherObject fromNMS(Object nmsObject) throws Exception{
|
||||
int position = DataWatcherObject_POSITION.getInt(nmsObject);
|
||||
Object classType = DataWatcherObject_CLASSTYPE.get(nmsObject);
|
||||
return new DataWatcherObject(position, classType);
|
||||
}
|
||||
|
||||
private static Field DataWatcherObject_POSITION;
|
||||
private static Field DataWatcherObject_CLASSTYPE;
|
||||
|
||||
static {
|
||||
if (ProtocolVersion.SERVER_VERSION.getMinorVersion() >= 9) {
|
||||
Map<String, Field> fields = PacketPlayOut.getFields(MethodAPI.DataWatcherObject);
|
||||
DataWatcherObject_POSITION = fields.get("a");
|
||||
DataWatcherObject_CLASSTYPE = fields.get("b");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class DataWatcherSerializer {
|
||||
static {
|
||||
try {
|
||||
if (ProtocolVersion.SERVER_VERSION.getMinorVersion() >= 9) {
|
||||
Map<String, Field> fields = PacketPlayOut.getStaticFields(MethodAPI.DataWatcherRegistry);
|
||||
Map<String, Field> fields = PacketPlayOut.getFields(MethodAPI.DataWatcherRegistry);
|
||||
Byte = fields.get("a").get(null);
|
||||
Integer = fields.get("b").get(null);
|
||||
Float = fields.get("c").get(null);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package me.neznamy.tab.platforms.bukkit.packets;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -20,15 +19,4 @@ public abstract class PacketPlayOut{
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
public static Map<String, Field> getStaticFields(Class<?> clazz){
|
||||
Map<String, Field> fields = new HashMap<String, Field>();
|
||||
if (clazz == null) return fields;
|
||||
for (Field f : clazz.getDeclaredFields()) {
|
||||
if (Modifier.isStatic(f.getModifiers())) {
|
||||
f.setAccessible(true);
|
||||
fields.put(f.getName(), f);
|
||||
}
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user