Archiviert
13
0

Added server list ping event.

Dieser Commit ist enthalten in:
sk89q 2011-09-26 15:32:05 -07:00
Ursprung 87494d46f8
Commit afd95b7e30
2 geänderte Dateien mit 21 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -5,6 +5,11 @@ import java.util.Iterator;
import java.util.Random; import java.util.Random;
import java.util.logging.Logger; import java.util.logging.Logger;
// CraftBukkit start
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.server.ServerListPingEvent;
// CraftBukkit end
public class NetLoginHandler extends NetHandler { public class NetLoginHandler extends NetHandler {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
@ -139,7 +144,10 @@ public class NetLoginHandler extends NetHandler {
public void a(Packet254GetInfo packet254getinfo) { public void a(Packet254GetInfo packet254getinfo) {
if (this.networkManager.f() == null) return; // CraftBukkit - fix NPE when a client queries a server that is unable to handle it. if (this.networkManager.f() == null) return; // CraftBukkit - fix NPE when a client queries a server that is unable to handle it.
try { try {
String s = this.server.p + "\u00A7" + this.server.serverConfigurationManager.g() + "\u00A7" + this.server.serverConfigurationManager.h(); // CraftBukkit start
ServerListPingEvent pingEvent = CraftEventFactory.callServerListPingEvent(this.server.server, getSocket().getInetAddress(), this.server.p, this.server.serverConfigurationManager.g(), this.server.serverConfigurationManager.h());
String s = pingEvent.getMotd() + "\u00A7" + this.server.serverConfigurationManager.g() + "\u00A7" + pingEvent.getMaxPlayers();
// CraftBukkit end
this.networkManager.queue(new Packet255KickDisconnect(s)); this.networkManager.queue(new Packet255KickDisconnect(s));
this.networkManager.d(); this.networkManager.d();

Datei anzeigen

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.event; package org.bukkit.craftbukkit.event;
import java.net.InetAddress;
import java.util.List; import java.util.List;
import net.minecraft.server.ChunkCoordinates; import net.minecraft.server.ChunkCoordinates;
import net.minecraft.server.EntityCaveSpider; import net.minecraft.server.EntityCaveSpider;
@ -29,6 +30,7 @@ import net.minecraft.server.ItemStack;
import net.minecraft.server.World; import net.minecraft.server.World;
import net.minecraft.server.WorldServer; import net.minecraft.server.WorldServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -48,6 +50,7 @@ import org.bukkit.event.block.*;
import org.bukkit.event.entity.*; import org.bukkit.event.entity.*;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.event.server.ServerListPingEvent;
public class CraftEventFactory { public class CraftEventFactory {
private static boolean canBuild(CraftWorld world, Player player, int x, int z) { private static boolean canBuild(CraftWorld world, Player player, int x, int z) {
@ -308,4 +311,13 @@ public class CraftEventFactory {
return event; return event;
} }
/**
* Server methods
*/
public static ServerListPingEvent callServerListPingEvent(Server craftServer, InetAddress address, String motd, int numPlayers, int maxPlayers) {
ServerListPingEvent event = new ServerListPingEvent(address, motd, numPlayers, maxPlayers);
craftServer.getPluginManager().callEvent(event);
return event;
}
} }