Skip to content

Commit

Permalink
Enable Sponge Implementation, re-enable Metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
jb-aero committed Mar 16, 2016
1 parent 6a0175b commit c240d59
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 35 deletions.
15 changes: 7 additions & 8 deletions pom.xml
Expand Up @@ -144,11 +144,10 @@
<url>http://files.zachsthings.com/repo/</url>
</repository-->

<!-- mcstats repo (this appears to no longer be working)
<repository>
<id>Plugin Metrics</id>
<url>http://repo.mcstats.org/content/repositories/public</url>
</repository>-->
</repository>

<!-- Java Mail -->
<repository>
Expand Down Expand Up @@ -342,12 +341,12 @@
</exclusion>
</exclusions>
</dependency>
<!-- MCStats (this appears to no longer be working)
<dependency>
<groupId>org.mcstats</groupId>
<groupId>org.mcstats.bukkit</groupId>
<artifactId>metrics</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency> -->
<version>R8-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
Expand Down Expand Up @@ -501,7 +500,7 @@
<include>com.jcraft:jsch:jar:*</include>
<include>org.apache.commons:commons-io:jar:*</include>
<include>org.xerial:sqlite-jdbc:jar:*</include>
<include>org.mcstats:metrics:jar:*</include>
<include>org.mcstats.bukkit:metrics:jar:*</include>
<include>net.sourceforge.jchardet:jchardet:jar:*</include>
<include>redis.clients:jedis:jar:*</include>
<include>mysql:mysql-connector-java:jar:*</include>
Expand Down Expand Up @@ -641,7 +640,7 @@
</includes>
</filter>
<filter>
<artifact>org.mcstats:metrics:jar:*</artifact>
<artifact>org.mcstats.bukkit:metrics:jar:*</artifact>
<includes>
<include>**</include>
</includes>
Expand Down
Expand Up @@ -156,7 +156,8 @@ public static enum Type {

TEST("test-backend"),
BUKKIT("CommandHelper"),
SHELL("MethodScript");
SHELL("MethodScript"),
SPONGE("CommandHelper");
//GLOWSTONE,
//SINGLE_PLAYER
private final String branding;
Expand Down
Expand Up @@ -37,6 +37,7 @@
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;

import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -129,13 +130,11 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {

@EventHandler(priority= EventPriority.NORMAL)
public void onPlayerJoin(PlayerJoinEvent event) {
Static.HostnameCache(new BukkitMCPlayer(event.getPlayer()));
Static.HostnameCache(event.getPlayer().getName(), event.getPlayer().getAddress().getHostName());
}

@EventHandler(priority= EventPriority.NORMAL)
public void onPlayerLogin(PlayerLoginEvent event){
Static.SetPlayerHost(new BukkitMCPlayer(event.getPlayer()), event.getHostname());
Static.SetPlayerHost(event.getPlayer().getName(), event.getHostname());
}


}
Expand Up @@ -75,7 +75,7 @@
import org.bukkit.plugin.RegisteredListener;
import org.bukkit.plugin.TimedRegisteredListener;
import org.bukkit.plugin.java.JavaPlugin;
//import org.mcstats.Metrics;
import org.mcstats.Metrics;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -324,20 +324,21 @@ public void onEnable() {
BukkitMCSound.build();

//Metrics
// MCStats no longer appears to be supported. If it comes back, this code can be re-added
// try {
// org.mcstats.Metrics m = new Metrics(this);
// m.addCustomData(new Metrics.Plotter("Player count") {
//
// @Override
// public int getValue() {
// return Static.getServer().getOnlinePlayers().size();
// }
// });
// m.start();
// } catch (IOException e) {
// // Failed to submit the stats :-(
// }
try {
Metrics m = new Metrics(this);
Metrics.Graph graph = m.createGraph("Player count");
graph.addPlotter(new Metrics.Plotter("Player count") {

@Override
public int getValue() {
return Static.getServer().getOnlinePlayers().size();
}
});
m.addGraph(graph);
m.start();
} catch (IOException e) {
// Failed to submit the stats :-(
}

try {
//This may seem redundant, but on a /reload, we want to refresh these
Expand Down Expand Up @@ -377,11 +378,11 @@ public Thread newThread(Runnable r) {
return new Thread(r, "CommandHelperHostnameLookup-" + (++hostnameThreadPoolID));
}
});
for (MCPlayer p : Static.getServer().getOnlinePlayers()) {
for (Player p : getServer().getOnlinePlayers()) {
//Repopulate our cache for currently online players.
//New players that join later will get a lookup done
//on them at that time.
Static.HostnameCache(p);
Static.HostnameCache(p.getName(), p.getAddress().getHostName());
}

BukkitDirtyRegisteredListener.PlayDirty();
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/laytonsmith/core/Static.java
Expand Up @@ -1218,18 +1218,17 @@ public static MCCommandSender UninjectPlayer(MCCommandSender player) {
return injectedPlayers.remove(name);
}

public static void HostnameCache(final MCPlayer p) {
public static void HostnameCache(final String name, final String hostname) {
CommandHelperPlugin.hostnameLookupThreadPool.submit(new Runnable() {
@Override
public void run() {
CommandHelperPlugin.hostnameLookupCache.put(p.getName(),
p.getAddress().getHostName());
CommandHelperPlugin.hostnameLookupCache.put(name, hostname);
}
});
}

public static void SetPlayerHost(MCPlayer p, String host) {
hostCache.put(p.getName(), host);
public static void SetPlayerHost(String playerName, String host) {
hostCache.put(playerName, host);
}

public static String GetHost(MCPlayer p) {
Expand Down

0 comments on commit c240d59

Please sign in to comment.