Archiviert
13
0

Initial update to 1.8 - "It compiles"

Dieser Commit ist enthalten in:
Dan Mulloy 2014-11-28 11:22:10 -05:00
Ursprung d7e46215b8
Commit 077ea6ea08
31 geänderte Dateien mit 324 neuen und 208 gelöschten Zeilen

Datei anzeigen

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId> <artifactId>ProtocolLib</artifactId>
<version>3.6.0-SNAPSHOT</version> <version>3.6.1-SNAPSHOT</version>
<name>ProtocolLib</name> <name>ProtocolLib</name>
<description>Provides read/write access to the Minecraft protocol.</description> <description>Provides read/write access to the Minecraft protocol.</description>
@ -231,12 +231,16 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version> <version>1.8-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}/lib/SpigotAPI.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version> <version>1.8-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Spigot.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>

Datei anzeigen

@ -9,14 +9,14 @@ import java.util.Set;
import com.comphenix.protocol.PacketType.Protocol; import com.comphenix.protocol.PacketType.Protocol;
import com.comphenix.protocol.PacketType.Sender; import com.comphenix.protocol.PacketType.Sender;
import com.comphenix.protocol.events.ConnectionSide; import com.comphenix.protocol.events.ConnectionSide;
import com.google.common.collect.DiscreteDomains; import com.google.common.collect.ContiguousSet;
import com.google.common.collect.DiscreteDomain;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import com.google.common.collect.Ranges;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
class PacketTypeParser { class PacketTypeParser {
public final static Range<Integer> DEFAULT_MAX_RANGE = Ranges.closed(0, 255); public final static Range<Integer> DEFAULT_MAX_RANGE = Range.closed(0, 255);
private Sender side = null; private Sender side = null;
private Protocol protocol = null; private Protocol protocol = null;
@ -72,7 +72,7 @@ class PacketTypeParser {
} }
for (Range<Integer> range : ranges) { for (Range<Integer> range : ranges) {
for (Integer id : range.asSet(DiscreteDomains.integers())) { for (Integer id : ContiguousSet.create(range, DiscreteDomain.integers())) {
// Deprecated packets // Deprecated packets
if (protocol == null) { if (protocol == null) {
if (PacketType.hasLegacy(id)) { if (PacketType.hasLegacy(id)) {

Datei anzeigen

@ -23,9 +23,9 @@ import java.util.Arrays;
import java.util.Deque; import java.util.Deque;
import java.util.List; import java.util.List;
import com.google.common.collect.DiscreteDomains; import com.google.common.collect.ContiguousSet;
import com.google.common.collect.DiscreteDomain;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import com.google.common.collect.Ranges;
/** /**
* Used to parse ranges in CommandPacket. * Used to parse ranges in CommandPacket.
@ -68,7 +68,7 @@ class RangeParser {
throw new IllegalArgumentException("Cannot form a range without a upper limit."); throw new IllegalArgumentException("Cannot form a range without a upper limit.");
// This is a proper range // This is a proper range
range = Ranges.closed(Integer.parseInt(current), Integer.parseInt(tokens.get(i + 2))); range = Range.closed(Integer.parseInt(current), Integer.parseInt(tokens.get(i + 2)));
ranges.add(range); ranges.add(range);
// Skip the two next tokens // Skip the two next tokens
@ -76,7 +76,7 @@ class RangeParser {
} else { } else {
// Just a single number // Just a single number
range = Ranges.singleton(Integer.parseInt(current)); range = Range.singleton(Integer.parseInt(current));
ranges.add(range); ranges.add(range);
} }
@ -102,7 +102,7 @@ class RangeParser {
// Set every ID // Set every ID
for (Range<Integer> range : ranges) { for (Range<Integer> range : ranges) {
for (int id : range.asSet(DiscreteDomains.integers())) { for (int id : ContiguousSet.create(range, DiscreteDomain.integers())) {
set[id] = true; set[id] = true;
} }
} }
@ -115,7 +115,7 @@ class RangeParser {
} }
} else { } else {
if (start >= 0) { if (start >= 0) {
result.add(Ranges.closed(start, i - 1)); result.add(Range.closed(start, i - 1));
start = -1; start = -1;
} }
} }

Datei anzeigen

@ -25,7 +25,6 @@ import java.util.TreeMap;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import com.google.common.collect.Ranges;
/** /**
* Represents a generic store of intervals and associated values. No two intervals * Represents a generic store of intervals and associated values. No two intervals
@ -68,7 +67,7 @@ public abstract class AbstractIntervalTree<TKey extends Comparable<TKey>, TValue
@Override @Override
public Range<TKey> getKey() { public Range<TKey> getKey() {
return Ranges.closed(left.key, right.key); return Range.closed(left.key, right.key);
} }
@Override @Override

Datei anzeigen

@ -17,6 +17,9 @@
package com.comphenix.protocol.events; package com.comphenix.protocol.events;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import java.io.DataInput; import java.io.DataInput;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutput; import java.io.DataOutput;
@ -37,10 +40,6 @@ import java.util.concurrent.ConcurrentMap;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.io.netty.buffer.ByteBuf;
import net.minecraft.util.io.netty.buffer.UnpooledByteBufAllocator;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldType; import org.bukkit.WorldType;
@ -88,6 +87,7 @@ import com.google.common.base.Function;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.mojang.authlib.GameProfile;
/** /**
* Represents a Minecraft packet indirectly. * Represents a Minecraft packet indirectly.

Datei anzeigen

@ -1,17 +1,17 @@
package com.comphenix.protocol.injector.netty; package com.comphenix.protocol.injector.netty;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import net.minecraft.util.io.netty.channel.Channel;
// Hopefully, CB won't version these as well
import net.minecraft.util.io.netty.channel.ChannelFuture;
import net.minecraft.util.io.netty.channel.ChannelHandler;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
// Hopefully, CB won't version these as well
class BootstrapList implements List<Object> { class BootstrapList implements List<Object> {
private List<Object> delegate; private List<Object> delegate;
@ -116,82 +116,102 @@ class BootstrapList implements List<Object> {
} }
// Boiler plate // Boiler plate
@Override
public synchronized int size() { public synchronized int size() {
return delegate.size(); return delegate.size();
} }
@Override
public synchronized boolean isEmpty() { public synchronized boolean isEmpty() {
return delegate.isEmpty(); return delegate.isEmpty();
} }
@Override
public boolean contains(Object o) { public boolean contains(Object o) {
return delegate.contains(o); return delegate.contains(o);
} }
@Override
public synchronized Iterator<Object> iterator() { public synchronized Iterator<Object> iterator() {
return delegate.iterator(); return delegate.iterator();
} }
@Override
public synchronized Object[] toArray() { public synchronized Object[] toArray() {
return delegate.toArray(); return delegate.toArray();
} }
@Override
public synchronized <T> T[] toArray(T[] a) { public synchronized <T> T[] toArray(T[] a) {
return delegate.toArray(a); return delegate.toArray(a);
} }
@Override
public synchronized boolean remove(Object o) { public synchronized boolean remove(Object o) {
return delegate.remove(o); return delegate.remove(o);
} }
@Override
public synchronized boolean containsAll(Collection<?> c) { public synchronized boolean containsAll(Collection<?> c) {
return delegate.containsAll(c); return delegate.containsAll(c);
} }
@Override
public synchronized boolean addAll(int index, Collection<? extends Object> c) { public synchronized boolean addAll(int index, Collection<? extends Object> c) {
return delegate.addAll(index, c); return delegate.addAll(index, c);
} }
@Override
public synchronized boolean removeAll(Collection<?> c) { public synchronized boolean removeAll(Collection<?> c) {
return delegate.removeAll(c); return delegate.removeAll(c);
} }
@Override
public synchronized boolean retainAll(Collection<?> c) { public synchronized boolean retainAll(Collection<?> c) {
return delegate.retainAll(c); return delegate.retainAll(c);
} }
@Override
public synchronized void clear() { public synchronized void clear() {
delegate.clear(); delegate.clear();
} }
@Override
public synchronized Object get(int index) { public synchronized Object get(int index) {
return delegate.get(index); return delegate.get(index);
} }
@Override
public synchronized void add(int index, Object element) { public synchronized void add(int index, Object element) {
delegate.add(index, element); delegate.add(index, element);
} }
@Override
public synchronized Object remove(int index) { public synchronized Object remove(int index) {
return delegate.remove(index); return delegate.remove(index);
} }
@Override
public synchronized int indexOf(Object o) { public synchronized int indexOf(Object o) {
return delegate.indexOf(o); return delegate.indexOf(o);
} }
@Override
public synchronized int lastIndexOf(Object o) { public synchronized int lastIndexOf(Object o) {
return delegate.lastIndexOf(o); return delegate.lastIndexOf(o);
} }
@Override
public synchronized ListIterator<Object> listIterator() { public synchronized ListIterator<Object> listIterator() {
return delegate.listIterator(); return delegate.listIterator();
} }
@Override
public synchronized ListIterator<Object> listIterator(int index) { public synchronized ListIterator<Object> listIterator(int index) {
return delegate.listIterator(index); return delegate.listIterator(index);
} }
@Override
public synchronized List<Object> subList(int fromIndex, int toIndex) { public synchronized List<Object> subList(int fromIndex, int toIndex) {
return delegate.subList(fromIndex, toIndex); return delegate.subList(fromIndex, toIndex);
} }

Datei anzeigen

@ -1,5 +1,19 @@
package com.comphenix.protocol.injector.netty; package com.comphenix.protocol.injector.netty;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.concurrent.GenericFutureListener;
import io.netty.util.internal.TypeParameterMatcher;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.Socket; import java.net.Socket;
import java.net.SocketAddress; import java.net.SocketAddress;
@ -12,20 +26,6 @@ import java.util.NoSuchElementException;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.io.netty.buffer.ByteBuf;
import net.minecraft.util.io.netty.channel.Channel;
import net.minecraft.util.io.netty.channel.ChannelHandler;
import net.minecraft.util.io.netty.channel.ChannelHandlerContext;
import net.minecraft.util.io.netty.channel.ChannelInboundHandler;
import net.minecraft.util.io.netty.channel.ChannelInboundHandlerAdapter;
import net.minecraft.util.io.netty.channel.ChannelPipeline;
import net.minecraft.util.io.netty.channel.ChannelPromise;
import net.minecraft.util.io.netty.channel.socket.SocketChannel;
import net.minecraft.util.io.netty.handler.codec.ByteToMessageDecoder;
import net.minecraft.util.io.netty.handler.codec.MessageToByteEncoder;
import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.util.io.netty.util.internal.TypeParameterMatcher;
import net.sf.cglib.proxy.Factory; import net.sf.cglib.proxy.Factory;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -53,6 +53,7 @@ import com.comphenix.protocol.utility.MinecraftProtocolVersion;
import com.comphenix.protocol.utility.MinecraftReflection; import com.comphenix.protocol.utility.MinecraftReflection;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.MapMaker; import com.google.common.collect.MapMaker;
import com.mojang.authlib.GameProfile;
/** /**
* Represents a channel injector. * Represents a channel injector.

Datei anzeigen

@ -1,22 +1,22 @@
package com.comphenix.protocol.injector.netty; package com.comphenix.protocol.injector.netty;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.Channel;
import io.netty.channel.ChannelConfig;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelMetadata;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelProgressivePromise;
import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoop;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import net.minecraft.util.io.netty.buffer.ByteBufAllocator;
import net.minecraft.util.io.netty.channel.Channel;
import net.minecraft.util.io.netty.channel.ChannelConfig;
import net.minecraft.util.io.netty.channel.ChannelFuture;
import net.minecraft.util.io.netty.channel.ChannelMetadata;
import net.minecraft.util.io.netty.channel.ChannelPipeline;
import net.minecraft.util.io.netty.channel.ChannelProgressivePromise;
import net.minecraft.util.io.netty.channel.ChannelPromise;
import net.minecraft.util.io.netty.channel.EventLoop;
import net.minecraft.util.io.netty.util.Attribute;
import net.minecraft.util.io.netty.util.AttributeKey;
import com.comphenix.protocol.reflect.accessors.Accessors; import com.comphenix.protocol.reflect.accessors.Accessors;
import com.comphenix.protocol.reflect.accessors.FieldAccessor; import com.comphenix.protocol.reflect.accessors.FieldAccessor;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;

Datei anzeigen

@ -1,5 +1,15 @@
package com.comphenix.protocol.injector.netty; package com.comphenix.protocol.injector.netty;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.util.concurrent.EventExecutor;
import io.netty.util.concurrent.ProgressivePromise;
import io.netty.util.concurrent.Promise;
import io.netty.util.concurrent.ScheduledFuture;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -9,27 +19,19 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import net.minecraft.util.io.netty.channel.Channel;
import net.minecraft.util.io.netty.channel.ChannelFuture;
import net.minecraft.util.io.netty.channel.ChannelPromise;
import net.minecraft.util.io.netty.channel.EventLoop;
import net.minecraft.util.io.netty.channel.EventLoopGroup;
import net.minecraft.util.io.netty.util.concurrent.EventExecutor;
import net.minecraft.util.io.netty.util.concurrent.ProgressivePromise;
import net.minecraft.util.io.netty.util.concurrent.Promise;
import net.minecraft.util.io.netty.util.concurrent.ScheduledFuture;
/** /**
* An event loop proxy. * An event loop proxy.
* @author Kristian. * @author Kristian.
*/ */
abstract class EventLoopProxy implements EventLoop { abstract class EventLoopProxy implements EventLoop {
private static final Runnable EMPTY_RUNNABLE = new Runnable() { private static final Runnable EMPTY_RUNNABLE = new Runnable() {
@Override
public void run() { public void run() {
// Do nothing // Do nothing
} }
}; };
private static final Callable<?> EMPTY_CALLABLE = new Callable<Object>() { private static final Callable<?> EMPTY_CALLABLE = new Callable<Object>() {
@Override
public Object call() throws Exception { public Object call() throws Exception {
return null; return null;
}; };
@ -72,88 +74,108 @@ abstract class EventLoopProxy implements EventLoop {
*/ */
protected abstract <T> Callable<T> schedulingCallable(Callable<T> callable); protected abstract <T> Callable<T> schedulingCallable(Callable<T> callable);
@Override
public void execute(Runnable command) { public void execute(Runnable command) {
getDelegate().execute(schedulingRunnable(command)); getDelegate().execute(schedulingRunnable(command));
} }
public <T> net.minecraft.util.io.netty.util.concurrent.Future<T> submit(Callable<T> action) { @Override
public <T> io.netty.util.concurrent.Future<T> submit(Callable<T> action) {
return getDelegate().submit(schedulingCallable(action)); return getDelegate().submit(schedulingCallable(action));
} }
public <T> net.minecraft.util.io.netty.util.concurrent.Future<T> submit(Runnable action, T arg1) { @Override
public <T> io.netty.util.concurrent.Future<T> submit(Runnable action, T arg1) {
return getDelegate().submit(schedulingRunnable(action), arg1); return getDelegate().submit(schedulingRunnable(action), arg1);
} }
public net.minecraft.util.io.netty.util.concurrent.Future<?> submit(Runnable action) { @Override
public io.netty.util.concurrent.Future<?> submit(Runnable action) {
return getDelegate().submit(schedulingRunnable(action)); return getDelegate().submit(schedulingRunnable(action));
} }
@Override
public <V> ScheduledFuture<V> schedule(Callable<V> action, long arg1, TimeUnit arg2) { public <V> ScheduledFuture<V> schedule(Callable<V> action, long arg1, TimeUnit arg2) {
return getDelegate().schedule(schedulingCallable(action), arg1, arg2); return getDelegate().schedule(schedulingCallable(action), arg1, arg2);
} }
@Override
public ScheduledFuture<?> schedule(Runnable action, long arg1, TimeUnit arg2) { public ScheduledFuture<?> schedule(Runnable action, long arg1, TimeUnit arg2) {
return getDelegate().schedule(schedulingRunnable(action), arg1, arg2); return getDelegate().schedule(schedulingRunnable(action), arg1, arg2);
} }
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable action, long arg1, long arg2, TimeUnit arg3) { public ScheduledFuture<?> scheduleAtFixedRate(Runnable action, long arg1, long arg2, TimeUnit arg3) {
return getDelegate().scheduleAtFixedRate(schedulingRunnable(action), arg1, arg2, arg3); return getDelegate().scheduleAtFixedRate(schedulingRunnable(action), arg1, arg2, arg3);
} }
@Override
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable action, long arg1, long arg2, TimeUnit arg3) { public ScheduledFuture<?> scheduleWithFixedDelay(Runnable action, long arg1, long arg2, TimeUnit arg3) {
return getDelegate().scheduleWithFixedDelay(schedulingRunnable(action), arg1, arg2, arg3); return getDelegate().scheduleWithFixedDelay(schedulingRunnable(action), arg1, arg2, arg3);
} }
// Boiler plate: // Boiler plate:
@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
return getDelegate().awaitTermination(timeout, unit); return getDelegate().awaitTermination(timeout, unit);
} }
@Override
public boolean inEventLoop() { public boolean inEventLoop() {
return getDelegate().inEventLoop(); return getDelegate().inEventLoop();
} }
@Override
public boolean inEventLoop(Thread arg0) { public boolean inEventLoop(Thread arg0) {
return getDelegate().inEventLoop(arg0); return getDelegate().inEventLoop(arg0);
} }
@Override
public boolean isShutdown() { public boolean isShutdown() {
return getDelegate().isShutdown(); return getDelegate().isShutdown();
} }
@Override
public boolean isTerminated() { public boolean isTerminated() {
return getDelegate().isTerminated(); return getDelegate().isTerminated();
} }
@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
throws InterruptedException { throws InterruptedException {
return getDelegate().invokeAll(tasks); return getDelegate().invokeAll(tasks);
} }
@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout,
TimeUnit unit) throws InterruptedException { TimeUnit unit) throws InterruptedException {
return getDelegate().invokeAll(tasks, timeout, unit); return getDelegate().invokeAll(tasks, timeout, unit);
} }
@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException,
ExecutionException { ExecutionException {
return getDelegate().invokeAny(tasks); return getDelegate().invokeAny(tasks);
} }
@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
return getDelegate().invokeAny(tasks, timeout, unit); return getDelegate().invokeAny(tasks, timeout, unit);
} }
@Override
public boolean isShuttingDown() { public boolean isShuttingDown() {
return getDelegate().isShuttingDown(); return getDelegate().isShuttingDown();
} }
@Override
public Iterator<EventExecutor> iterator() { public Iterator<EventExecutor> iterator() {
return getDelegate().iterator(); return getDelegate().iterator();
} }
public <V> net.minecraft.util.io.netty.util.concurrent.Future<V> newFailedFuture(Throwable arg0) { @Override
public <V> io.netty.util.concurrent.Future<V> newFailedFuture(Throwable arg0) {
return getDelegate().newFailedFuture(arg0); return getDelegate().newFailedFuture(arg0);
} }
@ -162,47 +184,58 @@ abstract class EventLoopProxy implements EventLoop {
return getDelegate().next(); return getDelegate().next();
} }
@Override
public <V> ProgressivePromise<V> newProgressivePromise() { public <V> ProgressivePromise<V> newProgressivePromise() {
return getDelegate().newProgressivePromise(); return getDelegate().newProgressivePromise();
} }
@Override
public <V> Promise<V> newPromise() { public <V> Promise<V> newPromise() {
return getDelegate().newPromise(); return getDelegate().newPromise();
} }
public <V> net.minecraft.util.io.netty.util.concurrent.Future<V> newSucceededFuture(V arg0) { @Override
public <V> io.netty.util.concurrent.Future<V> newSucceededFuture(V arg0) {
return getDelegate().newSucceededFuture(arg0); return getDelegate().newSucceededFuture(arg0);
} }
@Override
public EventLoopGroup parent() { public EventLoopGroup parent() {
return getDelegate().parent(); return getDelegate().parent();
} }
@Override
public ChannelFuture register(Channel arg0, ChannelPromise arg1) { public ChannelFuture register(Channel arg0, ChannelPromise arg1) {
return getDelegate().register(arg0, arg1); return getDelegate().register(arg0, arg1);
} }
@Override
public ChannelFuture register(Channel arg0) { public ChannelFuture register(Channel arg0) {
return getDelegate().register(arg0); return getDelegate().register(arg0);
} }
public net.minecraft.util.io.netty.util.concurrent.Future<?> shutdownGracefully() { @Override
public io.netty.util.concurrent.Future<?> shutdownGracefully() {
return getDelegate().shutdownGracefully(); return getDelegate().shutdownGracefully();
} }
public net.minecraft.util.io.netty.util.concurrent.Future<?> shutdownGracefully(long arg0, long arg1, TimeUnit arg2) { @Override
public io.netty.util.concurrent.Future<?> shutdownGracefully(long arg0, long arg1, TimeUnit arg2) {
return getDelegate().shutdownGracefully(arg0, arg1, arg2); return getDelegate().shutdownGracefully(arg0, arg1, arg2);
} }
public net.minecraft.util.io.netty.util.concurrent.Future<?> terminationFuture() { @Override
public io.netty.util.concurrent.Future<?> terminationFuture() {
return getDelegate().terminationFuture(); return getDelegate().terminationFuture();
} }
@Override
@Deprecated @Deprecated
public void shutdown() { public void shutdown() {
getDelegate().shutdown(); getDelegate().shutdown();
} }
@Override
@Deprecated @Deprecated
public List<Runnable> shutdownNow() { public List<Runnable> shutdownNow() {
return getDelegate().shutdownNow(); return getDelegate().shutdownNow();

Datei anzeigen

@ -1,11 +1,11 @@
package com.comphenix.protocol.injector.netty; package com.comphenix.protocol.injector.netty;
import io.netty.channel.Channel;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import net.minecraft.util.io.netty.channel.Channel;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;

Datei anzeigen

@ -1,5 +1,13 @@
package com.comphenix.protocol.injector.netty; package com.comphenix.protocol.injector.netty;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -8,14 +16,6 @@ import java.net.InetSocketAddress;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import net.minecraft.util.io.netty.channel.Channel;
import net.minecraft.util.io.netty.channel.ChannelFuture;
import net.minecraft.util.io.netty.channel.ChannelHandler;
import net.minecraft.util.io.netty.channel.ChannelHandlerContext;
import net.minecraft.util.io.netty.channel.ChannelInboundHandler;
import net.minecraft.util.io.netty.channel.ChannelInboundHandlerAdapter;
import net.minecraft.util.io.netty.channel.ChannelInitializer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;

Datei anzeigen

@ -1,5 +1,9 @@
package com.comphenix.protocol.injector.netty; package com.comphenix.protocol.injector.netty;
import io.netty.channel.Channel;
import io.netty.channel.ChannelOption;
import io.netty.channel.socket.SocketChannel;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -8,9 +12,6 @@ import java.net.Socket;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.net.SocketException; import java.net.SocketException;
import net.minecraft.util.io.netty.channel.ChannelOption;
import net.minecraft.util.io.netty.channel.socket.SocketChannel;
/** /**
* This class wraps a Netty {@link Channel} in a {@link Socket}. It overrides * This class wraps a Netty {@link Channel} in a {@link Socket}. It overrides
* all methods in {@link Socket} to ensure that calls are not mistakingly made * all methods in {@link Socket} to ensure that calls are not mistakingly made

Datei anzeigen

@ -1,19 +1,19 @@
package com.comphenix.protocol.injector.netty; package com.comphenix.protocol.injector.netty;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.util.concurrent.EventExecutorGroup;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import net.minecraft.util.io.netty.channel.Channel;
import net.minecraft.util.io.netty.channel.ChannelFuture;
import net.minecraft.util.io.netty.channel.ChannelHandler;
import net.minecraft.util.io.netty.channel.ChannelHandlerContext;
import net.minecraft.util.io.netty.channel.ChannelPipeline;
import net.minecraft.util.io.netty.channel.ChannelPromise;
import net.minecraft.util.io.netty.util.concurrent.EventExecutorGroup;
/** /**
* A pipeline proxy. * A pipeline proxy.
* @author Kristian * @author Kristian

Datei anzeigen

@ -12,7 +12,7 @@ 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.Closeables; 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,13 +29,14 @@ 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 = Files.newWriter(destination, Charsets.UTF_8); writer = closer.register(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));
@ -60,13 +61,8 @@ public class TimingReportGenerator {
// Next plugin // Next plugin
writer.write(NEWLINE); writer.write(NEWLINE);
} }
} finally { } finally {
if (writer != null) { closer.close();
// Don't suppress exceptions
writer.flush();
Closeables.closeQuietly(writer);
}
} }
} }

Datei anzeigen

@ -1,5 +1,9 @@
package com.comphenix.protocol.utility; package com.comphenix.protocol.utility;
import io.netty.buffer.AbstractByteBuf;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
@ -12,14 +16,9 @@ import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel; import java.nio.channels.ScatteringByteChannel;
import java.nio.channels.WritableByteChannel; import java.nio.channels.WritableByteChannel;
import net.minecraft.util.io.netty.buffer.AbstractByteBuf;
import net.minecraft.util.io.netty.buffer.ByteBuf;
import net.minecraft.util.io.netty.buffer.ByteBufAllocator;
import com.comphenix.protocol.reflect.accessors.Accessors; import com.comphenix.protocol.reflect.accessors.Accessors;
import com.comphenix.protocol.reflect.accessors.FieldAccessor; import com.comphenix.protocol.reflect.accessors.FieldAccessor;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.google.common.io.LimitInputStream;
/** /**
* Construct a ByteBuf around an input stream and an output stream. * Construct a ByteBuf around an input stream and an output stream.
@ -250,13 +249,13 @@ class ByteBufAdapter extends AbstractByteBuf {
@Override @Override
public ByteBuf getBytes(int index, OutputStream dst, int length) throws IOException { public ByteBuf getBytes(int index, OutputStream dst, int length) throws IOException {
ByteStreams.copy(new LimitInputStream(input, length), dst); ByteStreams.copy(ByteStreams.limit(input, length), dst);
return this; return this;
} }
@Override @Override
public int getBytes(int index, GatheringByteChannel out, int length) throws IOException { public int getBytes(int index, GatheringByteChannel out, int length) throws IOException {
byte[] data = ByteStreams.toByteArray(new LimitInputStream(input, length)); byte[] data = ByteStreams.toByteArray(ByteStreams.limit(input, length));
out.write(ByteBuffer.wrap(data)); out.write(ByteBuffer.wrap(data));
return data.length; return data.length;
@ -299,7 +298,7 @@ class ByteBufAdapter extends AbstractByteBuf {
@Override @Override
public int setBytes(int index, InputStream in, int length) throws IOException { public int setBytes(int index, InputStream in, int length) throws IOException {
LimitInputStream limit = new LimitInputStream(in, length); InputStream limit = ByteStreams.limit(in, length);
ByteStreams.copy(limit, output); ByteStreams.copy(limit, output);
return length - limit.available(); return length - limit.available();
} }

Datei anzeigen

@ -1,14 +1,15 @@
package com.comphenix.protocol.utility; package com.comphenix.protocol.utility;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.concurrent.GenericFutureListener;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.minecraft.util.io.netty.buffer.ByteBuf;
import net.minecraft.util.io.netty.buffer.UnpooledByteBufAllocator;
import net.minecraft.util.io.netty.channel.ChannelHandlerContext;
import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener;
import net.sf.cglib.proxy.Enhancer; import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor; import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy; import net.sf.cglib.proxy.MethodProxy;

Datei anzeigen

@ -17,6 +17,8 @@
package com.comphenix.protocol.utility; package com.comphenix.protocol.utility;
import io.netty.buffer.ByteBuf;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
@ -37,8 +39,6 @@ import java.util.regex.Pattern;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.io.netty.buffer.ByteBuf;
import net.sf.cglib.asm.ClassReader; import net.sf.cglib.asm.ClassReader;
import net.sf.cglib.asm.MethodVisitor; import net.sf.cglib.asm.MethodVisitor;
import net.sf.cglib.asm.Opcodes; import net.sf.cglib.asm.Opcodes;
@ -73,6 +73,7 @@ import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import com.comphenix.protocol.wrappers.nbt.NbtType; import com.comphenix.protocol.wrappers.nbt.NbtType;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
/** /**
* Methods and constants specifically used in conjuction with reflecting Minecraft object. * Methods and constants specifically used in conjuction with reflecting Minecraft object.

Datei anzeigen

@ -23,65 +23,79 @@ class GuavaWrappers {
* @return The Bukkit multimap. * @return The Bukkit multimap.
*/ */
public static <TKey, TValue> Multimap<TKey, TValue> getBukkitMultimap( public static <TKey, TValue> Multimap<TKey, TValue> getBukkitMultimap(
final net.minecraft.util.com.google.common.collect.Multimap<TKey, TValue> multimap) { final com.google.common.collect.Multimap<TKey, TValue> multimap) {
if (USE_REFLECTION_FALLBACK) { if (USE_REFLECTION_FALLBACK) {
return GuavaReflection.getBukkitMultimap(multimap); return GuavaReflection.getBukkitMultimap(multimap);
} }
Multimap<TKey, TValue> result = new Multimap<TKey, TValue>() { Multimap<TKey, TValue> result = new Multimap<TKey, TValue>() {
@Override
public Map<TKey, Collection<TValue>> asMap() { public Map<TKey, Collection<TValue>> asMap() {
return multimap.asMap(); return multimap.asMap();
} }
@Override
public void clear() { public void clear() {
multimap.clear(); multimap.clear();
} }
@Override
public boolean containsEntry(Object arg0, Object arg1) { public boolean containsEntry(Object arg0, Object arg1) {
return multimap.containsEntry(arg0, arg1); return multimap.containsEntry(arg0, arg1);
} }
@Override
public boolean containsKey(Object arg0) { public boolean containsKey(Object arg0) {
return multimap.containsKey(arg0); return multimap.containsKey(arg0);
} }
@Override
public boolean containsValue(Object arg0) { public boolean containsValue(Object arg0) {
return multimap.containsValue(arg0); return multimap.containsValue(arg0);
} }
@Override
public Collection<Entry<TKey, TValue>> entries() { public Collection<Entry<TKey, TValue>> entries() {
return multimap.entries(); return multimap.entries();
} }
@Override
public boolean equals(Object arg0) { public boolean equals(Object arg0) {
return multimap.equals(arg0); return multimap.equals(arg0);
} }
@Override
public Collection<TValue> get(TKey arg0) { public Collection<TValue> get(TKey arg0) {
return multimap.get(arg0); return multimap.get(arg0);
} }
@Override
public int hashCode() { public int hashCode() {
return multimap.hashCode(); return multimap.hashCode();
} }
@Override
public boolean isEmpty() { public boolean isEmpty() {
return multimap.isEmpty(); return multimap.isEmpty();
} }
@Override
public Set<TKey> keySet() { public Set<TKey> keySet() {
return multimap.keySet(); return multimap.keySet();
} }
@Override
public Multiset<TKey> keys() { public Multiset<TKey> keys() {
return getBukkitMultiset(multimap.keys()); return getBukkitMultiset(multimap.keys());
} }
@Override
public boolean put(TKey arg0, TValue arg1) { public boolean put(TKey arg0, TValue arg1) {
return multimap.put(arg0, arg1); return multimap.put(arg0, arg1);
} }
@Override
public boolean putAll(com.google.common.collect.Multimap<? extends TKey, ? extends TValue> arg0) { public boolean putAll(com.google.common.collect.Multimap<? extends TKey, ? extends TValue> arg0) {
boolean result = false; boolean result = false;
@ -92,26 +106,32 @@ class GuavaWrappers {
return result; return result;
} }
@Override
public boolean putAll(TKey arg0, Iterable<? extends TValue> arg1) { public boolean putAll(TKey arg0, Iterable<? extends TValue> arg1) {
return multimap.putAll(arg0, arg1); return multimap.putAll(arg0, arg1);
} }
@Override
public boolean remove(Object arg0, Object arg1) { public boolean remove(Object arg0, Object arg1) {
return multimap.remove(arg0, arg1); return multimap.remove(arg0, arg1);
} }
@Override
public Collection<TValue> removeAll(Object arg0) { public Collection<TValue> removeAll(Object arg0) {
return multimap.removeAll(arg0); return multimap.removeAll(arg0);
} }
@Override
public Collection<TValue> replaceValues(TKey arg0, Iterable<? extends TValue> arg1) { public Collection<TValue> replaceValues(TKey arg0, Iterable<? extends TValue> arg1) {
return multimap.replaceValues(arg0, arg1); return multimap.replaceValues(arg0, arg1);
} }
@Override
public int size() { public int size() {
return multimap.size(); return multimap.size();
} }
@Override
public Collection<TValue> values() { public Collection<TValue> values() {
return multimap.values(); return multimap.values();
} }
@ -127,116 +147,139 @@ class GuavaWrappers {
} }
} }
public static <TValue> Multiset<TValue> getBukkitMultiset(final net.minecraft.util.com.google.common.collect.Multiset<TValue> multiset) { public static <TValue> Multiset<TValue> getBukkitMultiset(final com.google.common.collect.Multiset<TValue> multiset) {
if (USE_REFLECTION_FALLBACK) { if (USE_REFLECTION_FALLBACK) {
return GuavaReflection.getBukkitMultiset(multiset); return GuavaReflection.getBukkitMultiset(multiset);
} }
Multiset<TValue> result = new Multiset<TValue>() { Multiset<TValue> result = new Multiset<TValue>() {
@Override
public int add(TValue arg0, int arg1) { public int add(TValue arg0, int arg1) {
return multiset.add(arg0, arg1); return multiset.add(arg0, arg1);
} }
@Override
public boolean add(TValue arg0) { public boolean add(TValue arg0) {
return multiset.add(arg0); return multiset.add(arg0);
} }
@Override
public boolean addAll(Collection<? extends TValue> c) { public boolean addAll(Collection<? extends TValue> c) {
return multiset.addAll(c); return multiset.addAll(c);
} }
@Override
public void clear() { public void clear() {
multiset.clear(); multiset.clear();
} }
@Override
public boolean contains(Object arg0) { public boolean contains(Object arg0) {
return multiset.contains(arg0); return multiset.contains(arg0);
} }
@Override
public boolean containsAll(Collection<?> arg0) { public boolean containsAll(Collection<?> arg0) {
return multiset.containsAll(arg0); return multiset.containsAll(arg0);
} }
@Override
public int count(Object arg0) { public int count(Object arg0) {
return multiset.count(arg0); return multiset.count(arg0);
} }
@Override
public Set<TValue> elementSet() { public Set<TValue> elementSet() {
return multiset.elementSet(); return multiset.elementSet();
} }
@Override
public Set<Multiset.Entry<TValue>> entrySet() { public Set<Multiset.Entry<TValue>> entrySet() {
return new ConvertedSet< return new ConvertedSet<
net.minecraft.util.com.google.common.collect.Multiset.Entry<TValue>, com.google.common.collect.Multiset.Entry<TValue>,
Multiset.Entry<TValue>> Multiset.Entry<TValue>>
(multiset.entrySet()) { (multiset.entrySet()) {
@Override @Override
protected com.google.common.collect.Multiset.Entry<TValue> toOuter( protected com.google.common.collect.Multiset.Entry<TValue> toOuter(
net.minecraft.util.com.google.common.collect.Multiset.Entry<TValue> inner) { com.google.common.collect.Multiset.Entry<TValue> inner) {
return getBukkitEntry(inner); return getBukkitEntry(inner);
} }
@Override @Override
protected net.minecraft.util.com.google.common.collect.Multiset.Entry<TValue> toInner( protected com.google.common.collect.Multiset.Entry<TValue> toInner(
com.google.common.collect.Multiset.Entry<TValue> outer) { com.google.common.collect.Multiset.Entry<TValue> outer) {
throw new UnsupportedOperationException("Cannot convert " + outer); throw new UnsupportedOperationException("Cannot convert " + outer);
} }
}; };
} }
@Override
public boolean equals(Object arg0) { public boolean equals(Object arg0) {
return multiset.equals(arg0); return multiset.equals(arg0);
} }
@Override
public int hashCode() { public int hashCode() {
return multiset.hashCode(); return multiset.hashCode();
} }
@Override
public boolean isEmpty() { public boolean isEmpty() {
return multiset.isEmpty(); return multiset.isEmpty();
} }
@Override
public Iterator<TValue> iterator() { public Iterator<TValue> iterator() {
return multiset.iterator(); return multiset.iterator();
} }
@Override
public int remove(Object arg0, int arg1) { public int remove(Object arg0, int arg1) {
return multiset.remove(arg0, arg1); return multiset.remove(arg0, arg1);
} }
@Override
public boolean remove(Object arg0) { public boolean remove(Object arg0) {
return multiset.remove(arg0); return multiset.remove(arg0);
} }
@Override
public boolean removeAll(Collection<?> arg0) { public boolean removeAll(Collection<?> arg0) {
return multiset.removeAll(arg0); return multiset.removeAll(arg0);
} }
@Override
public boolean retainAll(Collection<?> arg0) { public boolean retainAll(Collection<?> arg0) {
return multiset.retainAll(arg0); return multiset.retainAll(arg0);
} }
@Override
public boolean setCount(TValue arg0, int arg1, int arg2) { public boolean setCount(TValue arg0, int arg1, int arg2) {
return multiset.setCount(arg0, arg1, arg2); return multiset.setCount(arg0, arg1, arg2);
} }
@Override
public int setCount(TValue arg0, int arg1) { public int setCount(TValue arg0, int arg1) {
return multiset.setCount(arg0, arg1); return multiset.setCount(arg0, arg1);
} }
@Override
public int size() { public int size() {
return multiset.size(); return multiset.size();
} }
@Override
public Object[] toArray() { public Object[] toArray() {
return multiset.toArray(); return multiset.toArray();
} }
@Override
public <T> T[] toArray(T[] a) { public <T> T[] toArray(T[] a) {
return multiset.toArray(a); return multiset.toArray(a);
} }
@Override
public String toString() { public String toString() {
return multiset.toString(); return multiset.toString();
} }
@ -251,24 +294,29 @@ class GuavaWrappers {
} }
} }
private static <TValue> Multiset.Entry<TValue> getBukkitEntry(final net.minecraft.util.com.google.common.collect.Multiset.Entry<TValue> entry) { private static <TValue> Multiset.Entry<TValue> getBukkitEntry(final com.google.common.collect.Multiset.Entry<TValue> entry) {
return new Multiset.Entry<TValue>() { return new Multiset.Entry<TValue>() {
@Override
public boolean equals(Object arg0) { public boolean equals(Object arg0) {
return entry.equals(arg0); return entry.equals(arg0);
} }
@Override
public int getCount() { public int getCount() {
return entry.getCount(); return entry.getCount();
} }
@Override
public TValue getElement() { public TValue getElement() {
return entry.getElement(); return entry.getElement();
} }
@Override
public int hashCode() { public int hashCode() {
return entry.hashCode(); return entry.hashCode();
} }
@Override
public String toString() { public String toString() {
return entry.toString(); return entry.toString();
} }

Datei anzeigen

@ -3,9 +3,6 @@ package com.comphenix.protocol.wrappers;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.com.mojang.authlib.properties.Property;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -22,6 +19,8 @@ import com.comphenix.protocol.wrappers.collection.ConvertedMultimap;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
/** /**
* Represents a wrapper for a game profile. * Represents a wrapper for a game profile.

Datei anzeigen

@ -1,5 +1,10 @@
package com.comphenix.protocol.wrappers; package com.comphenix.protocol.wrappers;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.base64.Base64;
import io.netty.util.IllegalReferenceCountException;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage; import java.awt.image.RenderedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -10,12 +15,6 @@ import java.util.List;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.io.netty.buffer.ByteBuf;
import net.minecraft.util.io.netty.buffer.Unpooled;
import net.minecraft.util.io.netty.handler.codec.base64.Base64;
import net.minecraft.util.io.netty.util.IllegalReferenceCountException;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -39,6 +38,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.mojang.authlib.GameProfile;
/** /**
* Represents a server ping packet data. * Represents a server ping packet data.

Datei anzeigen

@ -2,9 +2,8 @@ package com.comphenix.protocol.wrappers;
import java.security.PublicKey; import java.security.PublicKey;
import net.minecraft.util.com.mojang.authlib.properties.Property;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.mojang.authlib.properties.Property;
/** /**
* Represents a wrapper over a signed property. * Represents a wrapper over a signed property.

Datei anzeigen

@ -125,7 +125,7 @@ public class SimpleCraftBukkitITCase {
// Copy the ProtocolLib plugin to the server // Copy the ProtocolLib plugin to the server
if (pluginDirectory.exists()) { if (pluginDirectory.exists()) {
Files.deleteDirectoryContents(pluginDirectory); deleteFolder(pluginDirectory);
} }
pluginDirectory.mkdirs(); pluginDirectory.mkdirs();
@ -134,6 +134,21 @@ public class SimpleCraftBukkitITCase {
Files.copy(bestFile, destination); Files.copy(bestFile, destination);
} }
private static void deleteFolder(File folder) {
if (folder.exists()) {
File[] files = folder.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
deleteFolder(file);
} else {
file.delete();
}
}
}
}
}
/** /**
* Load a specific fake plugin. * Load a specific fake plugin.
* @param plugin - the plugin to load. * @param plugin - the plugin to load.

Datei anzeigen

@ -3,14 +3,14 @@ package com.comphenix.protocol;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import net.minecraft.server.v1_7_R4.Block; import net.minecraft.server.v1_8_R1.Block;
import net.minecraft.server.v1_7_R4.Item; import net.minecraft.server.v1_8_R1.Item;
import net.minecraft.server.v1_7_R4.StatisticList; import net.minecraft.server.v1_8_R1.StatisticList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemFactory; import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemFactory;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -38,9 +38,9 @@ public class BukkitInitialization {
initializePackage(); initializePackage();
try { try {
Block.p(); Block.R(); // Block.register();
Item.l(); Item.t(); // Item.register();
StatisticList.a(); StatisticList.a(); // StatisticList.register();
} catch (Exception e) { } catch (Exception e) {
// Swallow // Swallow
e.printStackTrace(); e.printStackTrace();

Datei anzeigen

@ -26,9 +26,9 @@ import static org.junit.Assert.assertTrue;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import net.minecraft.server.v1_7_R4.AttributeModifier; import net.minecraft.server.v1_8_R1.AttributeModifier;
import net.minecraft.server.v1_7_R4.AttributeSnapshot; import net.minecraft.server.v1_8_R1.AttributeSnapshot;
import net.minecraft.server.v1_7_R4.PacketPlayOutUpdateAttributes; import net.minecraft.server.v1_8_R1.PacketPlayOutUpdateAttributes;
import org.apache.commons.lang.SerializationUtils; import org.apache.commons.lang.SerializationUtils;
import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringBuilder;
@ -36,7 +36,7 @@ import org.apache.commons.lang.builder.ToStringStyle;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.WorldType; import org.bukkit.WorldType;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemFactory; import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;

Datei anzeigen

@ -4,12 +4,12 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import net.minecraft.server.v1_7_R4.ChatComponentText; import net.minecraft.server.v1_8_R1.ChatComponentText;
import net.minecraft.server.v1_7_R4.ChatSerializer; import net.minecraft.server.v1_8_R1.ChatSerializer;
import net.minecraft.server.v1_7_R4.IChatBaseComponent; import net.minecraft.server.v1_8_R1.IChatBaseComponent;
import net.minecraft.server.v1_7_R4.ServerPing; import net.minecraft.server.v1_8_R1.ServerPing;
import net.minecraft.server.v1_7_R4.ServerPingPlayerSample; import net.minecraft.server.v1_8_R1.ServerPingPlayerSample;
import net.minecraft.server.v1_7_R4.ServerPingServerData; import net.minecraft.server.v1_8_R1.ServerPingServerData;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;

Datei anzeigen

@ -8,10 +8,10 @@ import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import net.minecraft.server.v1_7_R4.IntHashMap; import net.minecraft.server.v1_8_R1.IntHashMap;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemFactory; import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;

Datei anzeigen

@ -15,15 +15,15 @@ public class ChunkCoordIntPairTest {
@Test @Test
public void test() { public void test() {
net.minecraft.server.v1_7_R4.ChunkCoordIntPair pair = new net.minecraft.server.v1_7_R4.ChunkCoordIntPair(1, 2); net.minecraft.server.v1_8_R1.ChunkCoordIntPair pair = new net.minecraft.server.v1_8_R1.ChunkCoordIntPair(1, 2);
ChunkCoordIntPair specific = ChunkCoordIntPair.getConverter().getSpecific(pair); ChunkCoordIntPair specific = ChunkCoordIntPair.getConverter().getSpecific(pair);
assertEquals(1, specific.getChunkX()); assertEquals(1, specific.getChunkX());
assertEquals(2, specific.getChunkZ()); assertEquals(2, specific.getChunkZ());
net.minecraft.server.v1_7_R4.ChunkCoordIntPair roundtrip = net.minecraft.server.v1_8_R1.ChunkCoordIntPair roundtrip =
(net.minecraft.server.v1_7_R4.ChunkCoordIntPair) ChunkCoordIntPair.getConverter(). (net.minecraft.server.v1_8_R1.ChunkCoordIntPair) ChunkCoordIntPair.getConverter().
getGeneric(net.minecraft.server.v1_7_R4.ChunkCoordIntPair.class, specific); getGeneric(net.minecraft.server.v1_8_R1.ChunkCoordIntPair.class, specific);
assertEquals(1, roundtrip.x); assertEquals(1, roundtrip.x);
assertEquals(2, roundtrip.z); assertEquals(2, roundtrip.z);

Datei anzeigen

@ -1,12 +1,12 @@
package com.comphenix.protocol.wrappers; package com.comphenix.protocol.wrappers;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import net.minecraft.server.v1_7_R4.EnumChatVisibility; import net.minecraft.server.v1_8_R1.EnumChatVisibility;
import net.minecraft.server.v1_7_R4.EnumClientCommand; import net.minecraft.server.v1_8_R1.EnumClientCommand;
import net.minecraft.server.v1_7_R4.EnumDifficulty; import net.minecraft.server.v1_8_R1.EnumDifficulty;
import net.minecraft.server.v1_7_R4.EnumEntityUseAction; import net.minecraft.server.v1_8_R1.EnumEntityUseAction;
import net.minecraft.server.v1_7_R4.EnumGamemode; import net.minecraft.server.v1_8_R1.EnumGamemode;
import net.minecraft.server.v1_7_R4.EnumProtocol; import net.minecraft.server.v1_8_R1.EnumProtocol;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;

Datei anzeigen

@ -6,9 +6,9 @@ import static org.junit.Assert.assertTrue;
import java.util.List; import java.util.List;
import net.minecraft.server.v1_7_R4.AttributeModifier; import net.minecraft.server.v1_8_R1.AttributeModifier;
import net.minecraft.server.v1_7_R4.AttributeSnapshot; import net.minecraft.server.v1_8_R1.AttributeSnapshot;
import net.minecraft.server.v1_7_R4.PacketPlayOutUpdateAttributes; import net.minecraft.server.v1_8_R1.PacketPlayOutUpdateAttributes;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;

Datei anzeigen

@ -3,7 +3,7 @@ package com.comphenix.protocol.wrappers;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemFactory; import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;

Datei anzeigen

@ -27,7 +27,7 @@ import java.io.DataOutput;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemFactory; import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;