Remove unused code, revert some unnecessary changes
Dieser Commit ist enthalten in:
Ursprung
5e5eff5e5f
Commit
3dda5c6a0a
@ -59,14 +59,14 @@ class CommandProtocol extends CommandBase {
|
|||||||
else if (subCommand.equalsIgnoreCase("timings"))
|
else if (subCommand.equalsIgnoreCase("timings"))
|
||||||
toggleTimings(sender, args);
|
toggleTimings(sender, args);
|
||||||
else if (subCommand.equalsIgnoreCase("listeners"))
|
else if (subCommand.equalsIgnoreCase("listeners"))
|
||||||
printListeners(sender, args);
|
printListeners(sender);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display every listener on the server
|
// Display every listener on the server
|
||||||
private void printListeners(final CommandSender sender, String[] args) {
|
private void printListeners(final CommandSender sender) {
|
||||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
||||||
|
|
||||||
for (PacketListener listener : manager.getPacketListeners()) {
|
for (PacketListener listener : manager.getPacketListeners()) {
|
||||||
|
@ -77,10 +77,6 @@ public class ProtocolConfig {
|
|||||||
private int modCount;
|
private int modCount;
|
||||||
|
|
||||||
public ProtocolConfig(Plugin plugin) {
|
public ProtocolConfig(Plugin plugin) {
|
||||||
this(plugin, plugin.getConfig());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProtocolConfig(Plugin plugin, Configuration config) {
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ public class AsyncFilterManager implements AsynchronousManager {
|
|||||||
* @return Asynchronous marker.
|
* @return Asynchronous marker.
|
||||||
*/
|
*/
|
||||||
public AsyncMarker createAsyncMarker() {
|
public AsyncMarker createAsyncMarker() {
|
||||||
return createAsyncMarker(AsyncMarker.DEFAULT_SENDING_DELTA, AsyncMarker.DEFAULT_TIMEOUT_DELTA);
|
return createAsyncMarker(AsyncMarker.DEFAULT_TIMEOUT_DELTA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -371,14 +371,13 @@ public class AsyncFilterManager implements AsynchronousManager {
|
|||||||
* @param timeoutDelta - how long (in ms) until the packet expire.
|
* @param timeoutDelta - how long (in ms) until the packet expire.
|
||||||
* @return An async marker.
|
* @return An async marker.
|
||||||
*/
|
*/
|
||||||
public AsyncMarker createAsyncMarker(long sendingDelta, long timeoutDelta) {
|
public AsyncMarker createAsyncMarker(long timeoutDelta) {
|
||||||
return createAsyncMarker(sendingDelta, timeoutDelta,
|
return createAsyncMarker(timeoutDelta, currentSendingIndex.incrementAndGet());
|
||||||
currentSendingIndex.incrementAndGet(), System.currentTimeMillis());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper method
|
// Helper method
|
||||||
private AsyncMarker createAsyncMarker(long sendingDelta, long timeoutDelta, long sendingIndex, long currentTime) {
|
private AsyncMarker createAsyncMarker(long timeoutDelta, long sendingIndex) {
|
||||||
return new AsyncMarker(manager, sendingIndex, sendingDelta, System.currentTimeMillis(), timeoutDelta);
|
return new AsyncMarker(manager, sendingIndex, System.currentTimeMillis(), timeoutDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,7 +110,7 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
|
|||||||
* Create a container for asyncronous packets.
|
* Create a container for asyncronous packets.
|
||||||
* @param initialTime - the current time in milliseconds since 01.01.1970 00:00.
|
* @param initialTime - the current time in milliseconds since 01.01.1970 00:00.
|
||||||
*/
|
*/
|
||||||
AsyncMarker(PacketStream packetStream, long sendingIndex, long sendingDelta, long initialTime, long timeoutDelta) {
|
AsyncMarker(PacketStream packetStream, long sendingIndex, long initialTime, long timeoutDelta) {
|
||||||
if (packetStream == null)
|
if (packetStream == null)
|
||||||
throw new IllegalArgumentException("packetStream cannot be NULL");
|
throw new IllegalArgumentException("packetStream cannot be NULL");
|
||||||
|
|
||||||
|
@ -152,8 +152,6 @@ class EntityUtilities {
|
|||||||
|
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new FieldAccessException("Security limitation prevented access to the list of tracked players.", e);
|
throw new FieldAccessException("Security limitation prevented access to the list of tracked players.", e);
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
throw new FieldAccessException("Exception occurred in Minecraft.", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +162,7 @@ class EntityUtilities {
|
|||||||
* @return The entity tracker entry.
|
* @return The entity tracker entry.
|
||||||
* @throws FieldAccessException
|
* @throws FieldAccessException
|
||||||
*/
|
*/
|
||||||
private static Object getEntityTrackerEntry(World world, int entityID) throws FieldAccessException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
private static Object getEntityTrackerEntry(World world, int entityID) throws FieldAccessException, IllegalArgumentException {
|
||||||
BukkitUnwrapper unwrapper = new BukkitUnwrapper();
|
BukkitUnwrapper unwrapper = new BukkitUnwrapper();
|
||||||
Object worldServer = unwrapper.unwrapItem(world);
|
Object worldServer = unwrapper.unwrapItem(world);
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
|
|||||||
playerInjection.checkListener(listener);
|
playerInjection.checkListener(listener);
|
||||||
}
|
}
|
||||||
if (hasSending)
|
if (hasSending)
|
||||||
incrementPhases(processPhase(sending, ConnectionSide.SERVER_SIDE));
|
incrementPhases(processPhase(sending));
|
||||||
|
|
||||||
// Handle receivers after senders
|
// Handle receivers after senders
|
||||||
if (hasReceiving) {
|
if (hasReceiving) {
|
||||||
@ -450,7 +450,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
|
|||||||
enablePacketFilters(listener, receiving.getTypes());
|
enablePacketFilters(listener, receiving.getTypes());
|
||||||
}
|
}
|
||||||
if (hasReceiving)
|
if (hasReceiving)
|
||||||
incrementPhases(processPhase(receiving, ConnectionSide.CLIENT_SIDE));
|
incrementPhases(processPhase(receiving));
|
||||||
|
|
||||||
// Inform our injected hooks
|
// Inform our injected hooks
|
||||||
packetListeners.add(listener);
|
packetListeners.add(listener);
|
||||||
@ -458,7 +458,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GamePhase processPhase(ListeningWhitelist whitelist, ConnectionSide side) {
|
private GamePhase processPhase(ListeningWhitelist whitelist) {
|
||||||
// Determine if this is a login packet, ensuring that gamephase detection is enabled
|
// Determine if this is a login packet, ensuring that gamephase detection is enabled
|
||||||
if (!whitelist.getGamePhase().hasLogin() &&
|
if (!whitelist.getGamePhase().hasLogin() &&
|
||||||
!whitelist.getOptions().contains(ListenerOptions.DISABLE_GAMEPHASE_DETECTION)) {
|
!whitelist.getOptions().contains(ListenerOptions.DISABLE_GAMEPHASE_DETECTION)) {
|
||||||
@ -571,11 +571,11 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
|
|||||||
// Remove listeners and phases
|
// Remove listeners and phases
|
||||||
if (sending != null && sending.isEnabled()) {
|
if (sending != null && sending.isEnabled()) {
|
||||||
sendingRemoved = sendingListeners.removeListener(listener, sending);
|
sendingRemoved = sendingListeners.removeListener(listener, sending);
|
||||||
decrementPhases(processPhase(sending, ConnectionSide.SERVER_SIDE));
|
decrementPhases(processPhase(sending));
|
||||||
}
|
}
|
||||||
if (receiving != null && receiving.isEnabled()) {
|
if (receiving != null && receiving.isEnabled()) {
|
||||||
receivingRemoved = recievedListeners.removeListener(listener, receiving);
|
receivingRemoved = recievedListeners.removeListener(listener, receiving);
|
||||||
decrementPhases(processPhase(receiving, ConnectionSide.CLIENT_SIDE));
|
decrementPhases(processPhase(receiving));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove hooks, if needed
|
// Remove hooks, if needed
|
||||||
|
@ -225,7 +225,7 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
|
|||||||
protected void encode(ChannelHandlerContext ctx, Object packet, ByteBuf output) throws Exception {
|
protected void encode(ChannelHandlerContext ctx, Object packet, ByteBuf output) throws Exception {
|
||||||
if (packet instanceof WirePacket) {
|
if (packet instanceof WirePacket) {
|
||||||
// Special case for wire format
|
// Special case for wire format
|
||||||
ChannelInjector.this.encodeWirePacket(ctx, (WirePacket) packet, output);
|
ChannelInjector.this.encodeWirePacket((WirePacket) packet, output);
|
||||||
} else {
|
} else {
|
||||||
ChannelInjector.this.encode(ctx, packet, output);
|
ChannelInjector.this.encode(ctx, packet, output);
|
||||||
}
|
}
|
||||||
@ -356,7 +356,7 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
|
|||||||
*/
|
*/
|
||||||
private boolean guessCompression(ChannelHandler handler) {
|
private boolean guessCompression(ChannelHandler handler) {
|
||||||
String className = handler != null ? handler.getClass().getCanonicalName() : null;
|
String className = handler != null ? handler.getClass().getCanonicalName() : null;
|
||||||
return className.contains("PacketCompressor") || className.contains("PacketDecompressor");
|
return className.contains("Compressor") || className.contains("Decompressor");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -386,7 +386,7 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
|
|||||||
super.exceptionCaught(ctx, cause);
|
super.exceptionCaught(ctx, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void encodeWirePacket(ChannelHandlerContext ctx, WirePacket packet, ByteBuf output) throws Exception {
|
protected void encodeWirePacket(WirePacket packet, ByteBuf output) throws Exception {
|
||||||
packet.writeId(output);
|
packet.writeId(output);
|
||||||
packet.writeBytes(output);
|
packet.writeBytes(output);
|
||||||
}
|
}
|
||||||
|
@ -160,19 +160,16 @@ public class PipelineProxy implements ChannelPipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We have to call the depreciated methods to properly implement the proxy
|
// We have to call the depreciated methods to properly implement the proxy
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture deregister() {
|
public ChannelFuture deregister() {
|
||||||
return pipeline.deregister();
|
return pipeline.deregister();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture deregister(ChannelPromise arg0) {
|
public ChannelFuture deregister(ChannelPromise arg0) {
|
||||||
return pipeline.deregister(arg0);
|
return pipeline.deregister(arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelPipeline fireChannelUnregistered() {
|
public ChannelPipeline fireChannelUnregistered() {
|
||||||
pipeline.fireChannelUnregistered();
|
pipeline.fireChannelUnregistered();
|
||||||
|
@ -53,6 +53,7 @@ public class InterceptWritePacket {
|
|||||||
this.modifierRest = new WritePacketModifier(reporter, false);
|
this.modifierRest = new WritePacketModifier(reporter, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: PacketId should probably do something...
|
||||||
private Class<?> createProxyClass(int packetId) {
|
private Class<?> createProxyClass(int packetId) {
|
||||||
// Construct the proxy object
|
// Construct the proxy object
|
||||||
Enhancer ex = EnhancerFactory.getInstance().createEnhancer();
|
Enhancer ex = EnhancerFactory.getInstance().createEnhancer();
|
||||||
|
@ -11,8 +11,7 @@ import javax.annotation.Nonnull;
|
|||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.ConnectionSide;
|
import com.comphenix.protocol.events.ConnectionSide;
|
||||||
import com.comphenix.protocol.events.NetworkMarker;
|
import com.comphenix.protocol.events.NetworkMarker;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteSource;
|
||||||
import com.google.common.io.InputSupplier;
|
|
||||||
import com.google.common.primitives.Bytes;
|
import com.google.common.primitives.Bytes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,27 +38,26 @@ public class LegacyNetworkMarker extends NetworkMarker {
|
|||||||
return ByteBuffer.wrap(Bytes.concat(new byte[] { (byte) type.getLegacyId() }, buffer.array()));
|
return ByteBuffer.wrap(Bytes.concat(new byte[] { (byte) type.getLegacyId() }, buffer.array()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
|
||||||
@Override
|
@Override
|
||||||
protected DataInputStream addHeader(final DataInputStream input, final PacketType type) {
|
protected DataInputStream addHeader(final DataInputStream input, final PacketType type) {
|
||||||
InputSupplier<InputStream> header = new InputSupplier<InputStream>() {
|
ByteSource header = new ByteSource() {
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInput() throws IOException {
|
public InputStream openStream() throws IOException {
|
||||||
byte[] data = new byte[] { (byte) type.getLegacyId() };
|
byte[] data = new byte[] { (byte) type.getLegacyId() };
|
||||||
return new ByteArrayInputStream(data);
|
return new ByteArrayInputStream(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
InputSupplier<InputStream> data = new InputSupplier<InputStream>() {
|
ByteSource data = new ByteSource() {
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInput() throws IOException {
|
public InputStream openStream() throws IOException {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Combine them into a single stream
|
// Combine them into a single stream
|
||||||
try {
|
try {
|
||||||
return new DataInputStream(ByteStreams.join((InputSupplier) header, (InputSupplier) data).getInput());
|
return new DataInputStream(ByteSource.concat(header, data).openStream());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Cannot add header.", e);
|
throw new RuntimeException("Cannot add header.", e);
|
||||||
}
|
}
|
||||||
|
@ -77,9 +77,7 @@ class NetworkFieldInjector extends PlayerInjector {
|
|||||||
// Determine if we're listening
|
// Determine if we're listening
|
||||||
private IntegerSet sendingFilters;
|
private IntegerSet sendingFilters;
|
||||||
|
|
||||||
public NetworkFieldInjector(ErrorReporter reporter, Player player,
|
public NetworkFieldInjector(ErrorReporter reporter, Player player, ListenerInvoker manager, IntegerSet sendingFilters) {
|
||||||
ListenerInvoker manager, IntegerSet sendingFilters) throws IllegalAccessException {
|
|
||||||
|
|
||||||
super(reporter, player, manager);
|
super(reporter, player, manager);
|
||||||
this.sendingFilters = sendingFilters;
|
this.sendingFilters = sendingFilters;
|
||||||
}
|
}
|
||||||
@ -178,6 +176,7 @@ class NetworkFieldInjector extends PlayerInjector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected void cleanHook() {
|
protected void cleanHook() {
|
||||||
// Clean up
|
// Clean up
|
||||||
|
@ -81,8 +81,7 @@ class NetworkServerInjector extends PlayerInjector {
|
|||||||
public NetworkServerInjector(
|
public NetworkServerInjector(
|
||||||
ErrorReporter reporter, Player player,
|
ErrorReporter reporter, Player player,
|
||||||
ListenerInvoker invoker, IntegerSet sendingFilters,
|
ListenerInvoker invoker, IntegerSet sendingFilters,
|
||||||
InjectedServerConnection serverInjection) throws IllegalAccessException {
|
InjectedServerConnection serverInjection) {
|
||||||
|
|
||||||
super(reporter, player, invoker);
|
super(reporter, player, invoker);
|
||||||
this.sendingFilters = sendingFilters;
|
this.sendingFilters = sendingFilters;
|
||||||
this.serverInjection = serverInjection;
|
this.serverInjection = serverInjection;
|
||||||
|
@ -137,7 +137,7 @@ public abstract class PlayerInjector implements SocketInjector {
|
|||||||
boolean updateOnLogin;
|
boolean updateOnLogin;
|
||||||
volatile Player updatedPlayer;
|
volatile Player updatedPlayer;
|
||||||
|
|
||||||
public PlayerInjector(ErrorReporter reporter, Player player, ListenerInvoker invoker) throws IllegalAccessException {
|
public PlayerInjector(ErrorReporter reporter, Player player, ListenerInvoker invoker) {
|
||||||
this.reporter = reporter;
|
this.reporter = reporter;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.invoker = invoker;
|
this.invoker = invoker;
|
||||||
@ -176,7 +176,7 @@ public abstract class PlayerInjector implements SocketInjector {
|
|||||||
* @param player - the player to hook.
|
* @param player - the player to hook.
|
||||||
*/
|
*/
|
||||||
public void initializePlayer(Player player) {
|
public void initializePlayer(Player player) {
|
||||||
Object notchEntity = getEntityPlayer((Player) player);
|
Object notchEntity = getEntityPlayer(player);
|
||||||
|
|
||||||
// Save the player too
|
// Save the player too
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
@ -124,7 +124,7 @@ public class PrettyPrinter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private static void printIterables(StringBuilder output, Iterable iterable, Class<?> current, Class<?> stop,
|
private static void printIterables(StringBuilder output, Iterable iterable, Class<?> stop,
|
||||||
Set<Object> previous, int hierachyIndex, ObjectPrinter printer) throws IllegalAccessException {
|
Set<Object> previous, int hierachyIndex, ObjectPrinter printer) throws IllegalAccessException {
|
||||||
|
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
@ -270,7 +270,7 @@ public class PrettyPrinter {
|
|||||||
} else if (type.isArray()) {
|
} else if (type.isArray()) {
|
||||||
printArray(output, value, type, stop, previous, hierachyIndex, printer);
|
printArray(output, value, type, stop, previous, hierachyIndex, printer);
|
||||||
} else if (Iterable.class.isAssignableFrom(type)) {
|
} else if (Iterable.class.isAssignableFrom(type)) {
|
||||||
printIterables(output, (Iterable) value, type, stop, previous, hierachyIndex, printer);
|
printIterables(output, (Iterable) value, stop, previous, hierachyIndex, printer);
|
||||||
} else if (Map.class.isAssignableFrom(type)) {
|
} else if (Map.class.isAssignableFrom(type)) {
|
||||||
printMap(output, (Map<Object, Object>) value, type, stop, previous, hierachyIndex, printer);
|
printMap(output, (Map<Object, Object>) value, type, stop, previous, hierachyIndex, printer);
|
||||||
} else if (ClassLoader.class.isAssignableFrom(type) || previous.contains(value)) {
|
} else if (ClassLoader.class.isAssignableFrom(type) || previous.contains(value)) {
|
||||||
|
@ -12,7 +12,6 @@ import com.comphenix.protocol.timing.TimedListenerManager.ListenerType;
|
|||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.io.Closer;
|
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
|
|
||||||
public class TimingReportGenerator {
|
public class TimingReportGenerator {
|
||||||
@ -29,14 +28,13 @@ public class TimingReportGenerator {
|
|||||||
private static final String SUM_MAIN_THREAD = " => Time on main thread: %.6f ms" + NEWLINE;
|
private static final String SUM_MAIN_THREAD = " => Time on main thread: %.6f ms" + NEWLINE;
|
||||||
|
|
||||||
public void saveTo(File destination, TimedListenerManager manager) throws IOException {
|
public void saveTo(File destination, TimedListenerManager manager) throws IOException {
|
||||||
Closer closer = Closer.create();
|
|
||||||
BufferedWriter writer = null;
|
BufferedWriter writer = null;
|
||||||
Date started = manager.getStarted();
|
Date started = manager.getStarted();
|
||||||
Date stopped = manager.getStopped();
|
Date stopped = manager.getStopped();
|
||||||
long seconds = Math.abs((stopped.getTime() - started.getTime()) / 1000);
|
long seconds = Math.abs((stopped.getTime() - started.getTime()) / 1000);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
writer = closer.register(Files.newWriter(destination, Charsets.UTF_8));
|
writer = Files.newWriter(destination, Charsets.UTF_8);
|
||||||
|
|
||||||
// Write some timing information
|
// Write some timing information
|
||||||
writer.write(String.format(META_STARTED, started));
|
writer.write(String.format(META_STARTED, started));
|
||||||
@ -62,7 +60,9 @@ public class TimingReportGenerator {
|
|||||||
writer.write(NEWLINE);
|
writer.write(NEWLINE);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
closer.close();
|
if (writer != null) {
|
||||||
|
writer.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,12 +104,12 @@ public class StreamSerializer {
|
|||||||
if (READ_ITEM_METHOD == null) {
|
if (READ_ITEM_METHOD == null) {
|
||||||
READ_ITEM_METHOD = Accessors.getMethodAccessor(
|
READ_ITEM_METHOD = Accessors.getMethodAccessor(
|
||||||
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
||||||
getMethodByParameters("i", /* readItemStack */
|
getMethodByParameters("readItemStack", /* i */
|
||||||
MinecraftReflection.getItemStackClass(), new Class<?>[0])
|
MinecraftReflection.getItemStackClass(), new Class<?>[0])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
nmsItem = READ_ITEM_METHOD.invoke(ByteBufAdapter.packetReader(input));
|
|
||||||
|
|
||||||
|
nmsItem = READ_ITEM_METHOD.invoke(ByteBufAdapter.packetReader(input));
|
||||||
} else {
|
} else {
|
||||||
if (READ_ITEM_METHOD == null) {
|
if (READ_ITEM_METHOD == null) {
|
||||||
READ_ITEM_METHOD = Accessors.getMethodAccessor(
|
READ_ITEM_METHOD = Accessors.getMethodAccessor(
|
||||||
@ -121,6 +121,7 @@ public class StreamSerializer {
|
|||||||
build())
|
build())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
nmsItem = READ_ITEM_METHOD.invoke(null, input);
|
nmsItem = READ_ITEM_METHOD.invoke(null, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,12 +148,12 @@ public class StreamSerializer {
|
|||||||
if (READ_NBT_METHOD == null) {
|
if (READ_NBT_METHOD == null) {
|
||||||
READ_NBT_METHOD = Accessors.getMethodAccessor(
|
READ_NBT_METHOD = Accessors.getMethodAccessor(
|
||||||
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
||||||
getMethodByParameters("h", /* readNbtCompound */
|
getMethodByParameters("readNbtCompound", /* h */
|
||||||
MinecraftReflection.getNBTCompoundClass(), new Class<?>[0])
|
MinecraftReflection.getNBTCompoundClass(), new Class<?>[0])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
nmsCompound = READ_NBT_METHOD.invoke(ByteBufAdapter.packetReader(input));
|
|
||||||
|
|
||||||
|
nmsCompound = READ_NBT_METHOD.invoke(ByteBufAdapter.packetReader(input));
|
||||||
} else {
|
} else {
|
||||||
if (READ_NBT_METHOD == null) {
|
if (READ_NBT_METHOD == null) {
|
||||||
READ_NBT_METHOD = Accessors.getMethodAccessor(
|
READ_NBT_METHOD = Accessors.getMethodAccessor(
|
||||||
@ -200,12 +201,12 @@ public class StreamSerializer {
|
|||||||
if (READ_STRING_METHOD == null) {
|
if (READ_STRING_METHOD == null) {
|
||||||
READ_STRING_METHOD = Accessors.getMethodAccessor(
|
READ_STRING_METHOD = Accessors.getMethodAccessor(
|
||||||
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
||||||
getMethodByParameters("c", /* readString */
|
getMethodByParameters("readString", /* c */
|
||||||
String.class, new Class<?>[] { int.class })
|
String.class, new Class<?>[] { int.class })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (String) READ_STRING_METHOD.invoke(ByteBufAdapter.packetReader(input), maximumLength);
|
|
||||||
|
|
||||||
|
return (String) READ_STRING_METHOD.invoke(ByteBufAdapter.packetReader(input), maximumLength);
|
||||||
} else {
|
} else {
|
||||||
if (READ_STRING_METHOD == null) {
|
if (READ_STRING_METHOD == null) {
|
||||||
READ_STRING_METHOD = Accessors.getMethodAccessor(
|
READ_STRING_METHOD = Accessors.getMethodAccessor(
|
||||||
@ -218,6 +219,7 @@ public class StreamSerializer {
|
|||||||
build())
|
build())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (String) READ_STRING_METHOD.invoke(null, input, maximumLength);
|
return (String) READ_STRING_METHOD.invoke(null, input, maximumLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,12 +261,12 @@ public class StreamSerializer {
|
|||||||
if (WRITE_ITEM_METHOD == null) {
|
if (WRITE_ITEM_METHOD == null) {
|
||||||
WRITE_ITEM_METHOD = Accessors.getMethodAccessor(
|
WRITE_ITEM_METHOD = Accessors.getMethodAccessor(
|
||||||
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
||||||
getMethodByParameters("a", /* writeStack */
|
getMethodByParameters("writeStack", /* a */
|
||||||
MinecraftReflection.getItemStackClass())
|
MinecraftReflection.getItemStackClass())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
WRITE_ITEM_METHOD.invoke(ByteBufAdapter.packetWriter(output), nmsItem);
|
|
||||||
|
|
||||||
|
WRITE_ITEM_METHOD.invoke(ByteBufAdapter.packetWriter(output), nmsItem);
|
||||||
} else {
|
} else {
|
||||||
if (WRITE_ITEM_METHOD == null)
|
if (WRITE_ITEM_METHOD == null)
|
||||||
WRITE_ITEM_METHOD = Accessors.getMethodAccessor(
|
WRITE_ITEM_METHOD = Accessors.getMethodAccessor(
|
||||||
@ -275,6 +277,7 @@ public class StreamSerializer {
|
|||||||
parameterDerivedOf(DataOutput.class, 1).
|
parameterDerivedOf(DataOutput.class, 1).
|
||||||
build())
|
build())
|
||||||
);
|
);
|
||||||
|
|
||||||
WRITE_ITEM_METHOD.invoke(null, nmsItem, output);
|
WRITE_ITEM_METHOD.invoke(null, nmsItem, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,12 +302,12 @@ public class StreamSerializer {
|
|||||||
if (WRITE_NBT_METHOD == null) {
|
if (WRITE_NBT_METHOD == null) {
|
||||||
WRITE_NBT_METHOD = Accessors.getMethodAccessor(
|
WRITE_NBT_METHOD = Accessors.getMethodAccessor(
|
||||||
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
||||||
getMethodByParameters("a", /* writeNbtCompound */
|
getMethodByParameters("writeNbtCompound", /* a */
|
||||||
MinecraftReflection.getNBTCompoundClass())
|
MinecraftReflection.getNBTCompoundClass())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
WRITE_NBT_METHOD.invoke(ByteBufAdapter.packetWriter(output), handle);
|
|
||||||
|
|
||||||
|
WRITE_NBT_METHOD.invoke(ByteBufAdapter.packetWriter(output), handle);
|
||||||
} else {
|
} else {
|
||||||
if (WRITE_NBT_METHOD == null) {
|
if (WRITE_NBT_METHOD == null) {
|
||||||
WRITE_NBT_METHOD = Accessors.getMethodAccessor(
|
WRITE_NBT_METHOD = Accessors.getMethodAccessor(
|
||||||
@ -317,6 +320,7 @@ public class StreamSerializer {
|
|||||||
build())
|
build())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
WRITE_NBT_METHOD.invoke(null, handle, output);
|
WRITE_NBT_METHOD.invoke(null, handle, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,12 +343,12 @@ public class StreamSerializer {
|
|||||||
if (WRITE_STRING_METHOD == null) {
|
if (WRITE_STRING_METHOD == null) {
|
||||||
WRITE_STRING_METHOD = Accessors.getMethodAccessor(
|
WRITE_STRING_METHOD = Accessors.getMethodAccessor(
|
||||||
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
FuzzyReflection.fromClass(MinecraftReflection.getPacketDataSerializerClass(), true).
|
||||||
getMethodByParameters("a", /* writeString */
|
getMethodByParameters("writeString", /* a */
|
||||||
String.class)
|
String.class)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
WRITE_STRING_METHOD.invoke(ByteBufAdapter.packetWriter(output), text);
|
|
||||||
|
|
||||||
|
WRITE_STRING_METHOD.invoke(ByteBufAdapter.packetWriter(output), text);
|
||||||
} else {
|
} else {
|
||||||
if (WRITE_STRING_METHOD == null) {
|
if (WRITE_STRING_METHOD == null) {
|
||||||
WRITE_STRING_METHOD = Accessors.getMethodAccessor(
|
WRITE_STRING_METHOD = Accessors.getMethodAccessor(
|
||||||
@ -357,6 +361,7 @@ public class StreamSerializer {
|
|||||||
build())
|
build())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
WRITE_STRING_METHOD.invoke(null, text, output);
|
WRITE_STRING_METHOD.invoke(null, text, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -371,12 +376,12 @@ public class StreamSerializer {
|
|||||||
* @throws IOException If the operation fails due to reflection problems.
|
* @throws IOException If the operation fails due to reflection problems.
|
||||||
*/
|
*/
|
||||||
public String serializeItemStack(ItemStack stack) throws IOException {
|
public String serializeItemStack(ItemStack stack) throws IOException {
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
DataOutputStream dataOutput = new DataOutputStream(outputStream);
|
DataOutputStream dataOutput = new DataOutputStream(outputStream);
|
||||||
|
|
||||||
serializeItemStack(dataOutput, stack);
|
serializeItemStack(dataOutput, stack);
|
||||||
|
|
||||||
// Serialize that array
|
// Serialize that array
|
||||||
return Base64Coder.encodeLines(outputStream.toByteArray());
|
return Base64Coder.encodeLines(outputStream.toByteArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ public class WrappedChatComponent extends AbstractWrapper {
|
|||||||
FuzzyReflection fuzzy = FuzzyReflection.fromClass(SERIALIZER);
|
FuzzyReflection fuzzy = FuzzyReflection.fromClass(SERIALIZER);
|
||||||
|
|
||||||
// Retrieve the correct methods
|
// Retrieve the correct methods
|
||||||
SERIALIZE_COMPONENT = Accessors.getMethodAccessor(fuzzy.getMethodByParameters("a", /* serialize */
|
SERIALIZE_COMPONENT = Accessors.getMethodAccessor(fuzzy.getMethodByParameters("serialize", /* a */
|
||||||
String.class, new Class<?>[] { COMPONENT }));
|
String.class, new Class<?>[] { COMPONENT }));
|
||||||
DESERIALIZE_COMPONENT = Accessors.getMethodAccessor(fuzzy.getMethodByParameters("a", /* serialize */
|
DESERIALIZE_COMPONENT = Accessors.getMethodAccessor(fuzzy.getMethodByParameters("deserialize", /* a */
|
||||||
COMPONENT, new Class<?>[] { String.class }));
|
COMPONENT, new Class<?>[] { String.class }));
|
||||||
|
|
||||||
// Get a component from a standard Minecraft message
|
// Get a component from a standard Minecraft message
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren