Skip to content

Commit

Permalink
Fix BC listener
Browse files Browse the repository at this point in the history
  • Loading branch information
andylizi committed Mar 12, 2022
1 parent bca43a7 commit 61c6617
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
25 changes: 12 additions & 13 deletions src/main/java/net/andylizi/haproxydetector/bukkit/BukkitMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,26 @@ public void onEnable() {
}

try {
class TrackingStatsListener implements Listener {
@EventHandler
public void onLogin(PlayerLoginEvent event) {
ConnectionStats.trackLogin(event.getPlayer().getAddress());
}

@EventHandler
public void onDisconnect(PlayerQuitEvent event) {
ConnectionStats.trackDisconnect(event.getPlayer().getAddress());
}
}

getServer().getPluginManager().registerEvents(new TrackingStatsListener(), this);

Metrics metrics = new Metrics(this, 12604);
ConnectionStats.createCharts().forEach(metrics::addCustomChart);
} catch (Throwable t) {
logger.log(Level.WARNING, "Failed to start metrics", t);
}
}

public static class TrackingStatsListener implements Listener {
@EventHandler
public void onLogin(PlayerLoginEvent event) {
ConnectionStats.trackLogin(event.getPlayer().getAddress());
}

@EventHandler
public void onDisconnect(PlayerQuitEvent event) {
ConnectionStats.trackDisconnect(event.getPlayer().getAddress());
}
}

@Override
public void onDisable() {
if (injectorFactoryField != null && injector != null && oldFactory != null) {
Expand Down
27 changes: 13 additions & 14 deletions src/main/java/net/andylizi/haproxydetector/bungee/BungeeMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void onLoad() {
}

@Override
@SuppressWarnings({ "unchecked", "deprecation" })
@SuppressWarnings("unchecked")
public void onEnable() {
try {
Path path = this.getDataFolder().toPath().resolve("whitelist.conf");
Expand Down Expand Up @@ -121,27 +121,26 @@ public void onEnable() {
}

try {
class TrackingStatsListener implements Listener {
@EventHandler
public void onLogin(PostLoginEvent event) {
ConnectionStats.trackLogin(event.getPlayer().getSocketAddress());
}

@EventHandler
public void onDisconnect(PlayerDisconnectEvent event) {
ConnectionStats.trackDisconnect(event.getPlayer().getSocketAddress());
}
}

ProxyServer.getInstance().getPluginManager().registerListener(this, new TrackingStatsListener());

Metrics metrics = new Metrics(this, 12605);
ConnectionStats.createCharts().forEach(metrics::addCustomChart);
} catch (Throwable t) {
logger.log(Level.WARNING, "Failed to start metrics", t);
}
}

public static class TrackingStatsListener implements Listener {
@EventHandler
public void onLogin(PostLoginEvent event) {
ConnectionStats.trackLogin(event.getPlayer().getSocketAddress());
}

@EventHandler
public void onDisconnect(PlayerDisconnectEvent event) {
ConnectionStats.trackDisconnect(event.getPlayer().getSocketAddress());
}
}

@Override
public void onDisable() {
if (serverChildField != null && originalChildInitializer != null) {
Expand Down

0 comments on commit 61c6617

Please sign in to comment.