Skip to content

Commit

Permalink
Fixed metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jan 18, 2015
1 parent fff8235 commit 70f8d17
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/com/wasteofplastic/askyblock/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;

import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitTask;

import com.google.common.collect.Lists;

public class Metrics {
private static String encode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
Expand Down Expand Up @@ -130,7 +136,7 @@ private void postPlugin(final boolean isPing) throws IOException {
final boolean onlineMode = Bukkit.getServer().getOnlineMode();
final String pluginVersion = description.getVersion();
final String serverVersion = Bukkit.getVersion();
final int playersOnline = Bukkit.getServer().getOnlinePlayers().size();
final int playersOnline = getOnlinePlayers().size();

final StringBuilder data = new StringBuilder();

Expand Down Expand Up @@ -185,7 +191,15 @@ private void postPlugin(final boolean isPing) throws IOException {
throw new IOException(response);
}
}


public static List<Player> getOnlinePlayers() {
List<Player> list = Lists.newArrayList();
for (World world : Bukkit.getWorlds()) {
list.addAll(world.getPlayers());
}
return Collections.unmodifiableList(list);
}

public boolean start() {
synchronized (optOutLock) {
if (isOptOut()) {
Expand Down

0 comments on commit 70f8d17

Please sign in to comment.