Remove unused variable
Dieser Commit ist enthalten in:
Ursprung
eebcdf3ea1
Commit
4043f67610
@ -11,8 +11,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.PacketType.Protocol;
|
|
||||||
import com.comphenix.protocol.PacketType.Sender;
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
@ -20,16 +18,16 @@ import com.comphenix.protocol.events.PacketEvent;
|
|||||||
public class TestPingPacket {
|
public class TestPingPacket {
|
||||||
// Current versions
|
// Current versions
|
||||||
private static final int PROTOCOL_VERSION = 4;
|
private static final int PROTOCOL_VERSION = 4;
|
||||||
|
|
||||||
// Timeout
|
// Timeout
|
||||||
private static final int TIMEOUT_PING_MS = 10000;
|
private static final int TIMEOUT_PING_MS = 10000;
|
||||||
|
|
||||||
private volatile String source;
|
private volatile String source;
|
||||||
|
|
||||||
private TestPingPacket() {
|
private TestPingPacket() {
|
||||||
// Prevent external constructors
|
// Prevent external constructors
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new test ping packet test.
|
* Create a new test ping packet test.
|
||||||
* @return The new test.
|
* @return The new test.
|
||||||
@ -37,7 +35,7 @@ public class TestPingPacket {
|
|||||||
public static TestPingPacket newTest() {
|
public static TestPingPacket newTest() {
|
||||||
return new TestPingPacket();
|
return new TestPingPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked when the test should be started.
|
* Invoked when the test should be started.
|
||||||
* @param plugin - the current plugin.
|
* @param plugin - the current plugin.
|
||||||
@ -47,7 +45,7 @@ public class TestPingPacket {
|
|||||||
try {
|
try {
|
||||||
String transmitted = testInterception(plugin).
|
String transmitted = testInterception(plugin).
|
||||||
get(TIMEOUT_PING_MS, TimeUnit.MILLISECONDS);
|
get(TIMEOUT_PING_MS, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
// Make sure it's the same
|
// Make sure it's the same
|
||||||
System.out.println("Server string: " + transmitted);
|
System.out.println("Server string: " + transmitted);
|
||||||
assertEquals(source, transmitted);
|
assertEquals(source, transmitted);
|
||||||
@ -55,10 +53,8 @@ public class TestPingPacket {
|
|||||||
throw e.getCause();
|
throw e.getCause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Future<String> testInterception(Plugin test) {
|
private Future<String> testInterception(Plugin test) {
|
||||||
PacketType customPacket = PacketType.fromCurrent(Protocol.STATUS, Sender.CLIENT, 3, -1);
|
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(
|
ProtocolLibrary.getProtocolManager().addPacketListener(
|
||||||
new PacketAdapter(test, PacketType.Status.Server.OUT_SERVER_INFO) {
|
new PacketAdapter(test, PacketType.Status.Server.OUT_SERVER_INFO) {
|
||||||
@Override
|
@Override
|
||||||
@ -66,7 +62,7 @@ public class TestPingPacket {
|
|||||||
source = event.getPacket().getServerPings().read(0).toJson();
|
source = event.getPacket().getServerPings().read(0).toJson();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Invoke the client on a separate thread
|
// Invoke the client on a separate thread
|
||||||
return Executors.newSingleThreadExecutor().submit(new Callable<String>() {
|
return Executors.newSingleThreadExecutor().submit(new Callable<String>() {
|
||||||
@Override
|
@Override
|
||||||
@ -75,7 +71,7 @@ public class TestPingPacket {
|
|||||||
String information = client.queryLocalPing();
|
String information = client.queryLocalPing();
|
||||||
|
|
||||||
// Wait for the listener to catch up
|
// Wait for the listener to catch up
|
||||||
for (int i = 0; i < 1000 && (source == null); i++)
|
for (int i = 0; i < 1000 && (source == null); i++)
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
|
|
||||||
return information;
|
return information;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren