diff --git a/bukkit/src/main/java/ch/andre601/advancedserverlist/bukkit/objects/PAPIPlaceholders.java b/bukkit/src/main/java/ch/andre601/advancedserverlist/bukkit/objects/PAPIPlaceholders.java index d14642de..e6468dd2 100644 --- a/bukkit/src/main/java/ch/andre601/advancedserverlist/bukkit/objects/PAPIPlaceholders.java +++ b/bukkit/src/main/java/ch/andre601/advancedserverlist/bukkit/objects/PAPIPlaceholders.java @@ -76,7 +76,7 @@ public PAPIPlaceholders(PluginCore plugin){ public String onPlaceholderRequest(Player pl, @NotNull String identifier){ InetSocketAddress address = pl.getAddress(); - String host = address == null ? null : ProtocolLibEvents.getHostAddresses().get(address.getHostString()); + String host = resolveVirtualHost(pl, address); CachedPlayer cached = plugin.getCore().getPlayerHandler().getCachedPlayer(pl.getUniqueId()); int protocol = resolveProtocol(pl); @@ -129,4 +129,17 @@ private int resolveProtocol(Player player){ // getProtocolVersion is only in Paper, so this is only called when return Bukkit.getUnsafe().getProtocolVersion(); } + + private String resolveVirtualHost(Player player, InetSocketAddress address){ + try { + // Server is a Paper Server with Player#getVirtualHost() + Class.forName("com.destroystokyo.paper.network.NetworkClient"); + return player.getVirtualHost() == null ? null : player.getVirtualHost().getHostString(); + }catch(ClassNotFoundException ignored){} + + if(address == null) + return null; + + return ProtocolLibEvents.getHostAddresses().get(address.getHostString()); + } } diff --git a/bukkit/src/main/java/ch/andre601/advancedserverlist/paper/PaperCore.java b/bukkit/src/main/java/ch/andre601/advancedserverlist/paper/PaperCore.java index fe642eab..31d2afd3 100644 --- a/bukkit/src/main/java/ch/andre601/advancedserverlist/paper/PaperCore.java +++ b/bukkit/src/main/java/ch/andre601/advancedserverlist/paper/PaperCore.java @@ -35,6 +35,8 @@ import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore; import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler; import ch.andre601.advancedserverlist.paper.events.PaperPingEvent; +import org.bstats.bukkit.Metrics; +import org.bstats.charts.SimplePie; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.CachedServerIcon; @@ -77,7 +79,9 @@ public void loadEvents(){ @Override public void loadMetrics(){ - + new Metrics(this, 15584).addCustomChart(new SimplePie("profiles", + () -> String.valueOf(core.getFileHandler().getProfiles().size()) + )); } @Override diff --git a/bukkit/src/main/java/ch/andre601/advancedserverlist/spigot/SpigotCore.java b/bukkit/src/main/java/ch/andre601/advancedserverlist/spigot/SpigotCore.java index 1758feed..3340b1c7 100644 --- a/bukkit/src/main/java/ch/andre601/advancedserverlist/spigot/SpigotCore.java +++ b/bukkit/src/main/java/ch/andre601/advancedserverlist/spigot/SpigotCore.java @@ -34,10 +34,8 @@ import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler; import ch.andre601.advancedserverlist.spigot.events.LoadEvent; import com.comphenix.protocol.wrappers.WrappedServerPing; -import net.kyori.adventure.platform.bukkit.BukkitAudiences; import org.bstats.bukkit.Metrics; import org.bstats.charts.SimplePie; -import org.bukkit.command.PluginCommand; import org.bukkit.plugin.java.JavaPlugin; import java.nio.file.Path;