Initial update to 1.8 - "It compiles"

This commit is contained in:
Dan Mulloy 2014-11-28 11:22:10 -05:00
parent d7e46215b8
commit 077ea6ea08
31 changed files with 324 additions and 208 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>3.6.0-SNAPSHOT</version>
<version>3.6.1-SNAPSHOT</version>
<name>ProtocolLib</name>
<description>Provides read/write access to the Minecraft protocol.</description>
@ -231,12 +231,16 @@
<dependency>
<groupId>org.spigotmc</groupId>
<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>
<groupId>org.spigotmc</groupId>
<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>
<groupId>junit</groupId>

View File

@ -9,14 +9,14 @@ import java.util.Set;
import com.comphenix.protocol.PacketType.Protocol;
import com.comphenix.protocol.PacketType.Sender;
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.Range;
import com.google.common.collect.Ranges;
import com.google.common.collect.Sets;
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 Protocol protocol = null;
@ -72,7 +72,7 @@ class PacketTypeParser {
}
for (Range<Integer> range : ranges) {
for (Integer id : range.asSet(DiscreteDomains.integers())) {
for (Integer id : ContiguousSet.create(range, DiscreteDomain.integers())) {
// Deprecated packets
if (protocol == null) {
if (PacketType.hasLegacy(id)) {
@ -143,5 +143,5 @@ class PacketTypeParser {
return Protocol.STATUS;
else
return null;
}
}
}

View File

@ -2,16 +2,16 @@
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
* Copyright (C) 2012 Kristian S. Stangeland
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*/
@ -23,9 +23,9 @@ import java.util.Arrays;
import java.util.Deque;
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.Ranges;
/**
* Used to parse ranges in CommandPacket.
@ -68,7 +68,7 @@ class RangeParser {
throw new IllegalArgumentException("Cannot form a range without a upper limit.");
// 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);
// Skip the two next tokens
@ -76,7 +76,7 @@ class RangeParser {
} else {
// Just a single number
range = Ranges.singleton(Integer.parseInt(current));
range = Range.singleton(Integer.parseInt(current));
ranges.add(range);
}
@ -102,7 +102,7 @@ class RangeParser {
// Set every ID
for (Range<Integer> range : ranges) {
for (int id : range.asSet(DiscreteDomains.integers())) {
for (int id : ContiguousSet.create(range, DiscreteDomain.integers())) {
set[id] = true;
}
}
@ -115,7 +115,7 @@ class RangeParser {
}
} else {
if (start >= 0) {
result.add(Ranges.closed(start, i - 1));
result.add(Range.closed(start, i - 1));
start = -1;
}
}

View File

@ -2,16 +2,16 @@
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
* Copyright (C) 2012 Kristian S. Stangeland
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*/
@ -25,7 +25,6 @@ import java.util.TreeMap;
import com.google.common.base.Objects;
import com.google.common.collect.Range;
import com.google.common.collect.Ranges;
/**
* 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
public Range<TKey> getKey() {
return Ranges.closed(left.key, right.key);
return Range.closed(left.key, right.key);
}
@Override
@ -130,7 +129,7 @@ public abstract class AbstractIntervalTree<TKey extends Comparable<TKey>, TValue
this.state = state;
this.key = key;
this.value = value;
}
}
}
// To quickly look up ranges we'll index them by endpoints
@ -155,7 +154,7 @@ public abstract class AbstractIntervalTree<TKey extends Comparable<TKey>, TValue
checkBounds(lowerBound, upperBound);
NavigableMap<TKey, EndPoint> range = bounds.subMap(lowerBound, true, upperBound, true);
EndPoint first = getNextEndPoint(lowerBound, true);
EndPoint first = getNextEndPoint(lowerBound, true);
EndPoint last = getPreviousEndPoint(upperBound, true);
// Used while resizing intervals
@ -181,7 +180,7 @@ public abstract class AbstractIntervalTree<TKey extends Comparable<TKey>, TValue
if (next != null) {
removed.add(getEntry(last, next));
}
}
}
// Now remove both ranges
@ -253,7 +252,7 @@ public abstract class AbstractIntervalTree<TKey extends Comparable<TKey>, TValue
/**
* Associates a given interval of keys with a certain value. Any previous
* association will be overwritten in the given interval.
* association will be overwritten in the given interval.
* <p>
* Overlapping intervals are not permitted. A key can only be associated with a single value.
*
@ -262,7 +261,7 @@ public abstract class AbstractIntervalTree<TKey extends Comparable<TKey>, TValue
* @param value - the value, or NULL to reset this range.
*/
public void put(TKey lowerBound, TKey upperBound, TValue value) {
// While we don't permit overlapping intervals, we'll still allow overwriting existing intervals.
// While we don't permit overlapping intervals, we'll still allow overwriting existing intervals.
remove(lowerBound, upperBound, true);
invokeEntryAdded(putUnsafe(lowerBound, upperBound, value));
}
@ -423,7 +422,7 @@ public abstract class AbstractIntervalTree<TKey extends Comparable<TKey>, TValue
if (point != null) {
Map.Entry<TKey, EndPoint> previous = bounds.floorEntry(inclusive ? point : decrementKey(point));
if (previous != null)
if (previous != null)
return previous.getValue();
}
return null;
@ -439,7 +438,7 @@ public abstract class AbstractIntervalTree<TKey extends Comparable<TKey>, TValue
if (point != null) {
Map.Entry<TKey, EndPoint> next = bounds.ceilingEntry(inclusive ? point : incrementKey(point));
if (next != null)
if (next != null)
return next.getValue();
}
return null;

View File

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

View File

@ -1,17 +1,17 @@
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.Iterator;
import java.util.List;
import java.util.ListIterator;
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;
// Hopefully, CB won't version these as well
class BootstrapList implements List<Object> {
private List<Object> delegate;
@ -116,82 +116,102 @@ class BootstrapList implements List<Object> {
}
// Boiler plate
@Override
public synchronized int size() {
return delegate.size();
}
@Override
public synchronized boolean isEmpty() {
return delegate.isEmpty();
}
@Override
public boolean contains(Object o) {
return delegate.contains(o);
}
@Override
public synchronized Iterator<Object> iterator() {
return delegate.iterator();
}
@Override
public synchronized Object[] toArray() {
return delegate.toArray();
}
@Override
public synchronized <T> T[] toArray(T[] a) {
return delegate.toArray(a);
}
@Override
public synchronized boolean remove(Object o) {
return delegate.remove(o);
}
@Override
public synchronized boolean containsAll(Collection<?> c) {
return delegate.containsAll(c);
}
@Override
public synchronized boolean addAll(int index, Collection<? extends Object> c) {
return delegate.addAll(index, c);
}
@Override
public synchronized boolean removeAll(Collection<?> c) {
return delegate.removeAll(c);
}
@Override
public synchronized boolean retainAll(Collection<?> c) {
return delegate.retainAll(c);
}
@Override
public synchronized void clear() {
delegate.clear();
}
@Override
public synchronized Object get(int index) {
return delegate.get(index);
}
@Override
public synchronized void add(int index, Object element) {
delegate.add(index, element);
}
@Override
public synchronized Object remove(int index) {
return delegate.remove(index);
}
@Override
public synchronized int indexOf(Object o) {
return delegate.indexOf(o);
}
@Override
public synchronized int lastIndexOf(Object o) {
return delegate.lastIndexOf(o);
}
@Override
public synchronized ListIterator<Object> listIterator() {
return delegate.listIterator();
}
@Override
public synchronized ListIterator<Object> listIterator(int index) {
return delegate.listIterator(index);
}
@Override
public synchronized List<Object> subList(int fromIndex, int toIndex) {
return delegate.subList(fromIndex, toIndex);
}

View File

@ -1,5 +1,19 @@
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.net.Socket;
import java.net.SocketAddress;
@ -12,20 +26,6 @@ import java.util.NoSuchElementException;
import java.util.concurrent.Callable;
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 org.bukkit.Bukkit;
@ -53,6 +53,7 @@ import com.comphenix.protocol.utility.MinecraftProtocolVersion;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.google.common.base.Preconditions;
import com.google.common.collect.MapMaker;
import com.mojang.authlib.GameProfile;
/**
* Represents a channel injector.

View File

@ -1,22 +1,22 @@
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.net.SocketAddress;
import java.util.Map;
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.FieldAccessor;
import com.google.common.collect.Maps;

View File

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

View File

@ -1,11 +1,11 @@
package com.comphenix.protocol.injector.netty;
import io.netty.channel.Channel;
import java.util.concurrent.ConcurrentMap;
import javax.annotation.Nonnull;
import net.minecraft.util.io.netty.channel.Channel;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -119,11 +119,11 @@ class InjectionFactory {
* @return The channel injector, or a closed injector.
*/
@Nonnull
public Injector fromChannel(Channel channel, ChannelListener listener, TemporaryPlayerFactory playerFactory) {
public Injector fromChannel(Channel channel, ChannelListener listener, TemporaryPlayerFactory playerFactory) {
if (closed)
return new ClosedInjector(null);
Object networkManager = findNetworkManager(channel);
Object networkManager = findNetworkManager(channel);
Player temporaryPlayer = playerFactory.createTemporaryPlayer(Bukkit.getServer());
ChannelInjector injector = new ChannelInjector(temporaryPlayer, networkManager, channel, listener, this);

View File

@ -1,5 +1,13 @@
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.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@ -8,14 +16,6 @@ import java.net.InetSocketAddress;
import java.util.List;
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.plugin.Plugin;
@ -42,7 +42,7 @@ import com.comphenix.protocol.utility.MinecraftReflection;
import com.google.common.collect.Lists;
public class NettyProtocolInjector implements ChannelListener {
public class NettyProtocolInjector implements ChannelListener {
public static final ReportType REPORT_CANNOT_INJECT_INCOMING_CHANNEL = new ReportType("Unable to inject incoming channel %s.");
private volatile boolean injected;
@ -234,7 +234,7 @@ public class NettyProtocolInjector implements ChannelListener {
for (VolatileField field : bootstrapFields) {
Object value = field.getValue();
// Undo the processed channels, if any
// Undo the processed channels, if any
if (value instanceof BootstrapList) {
((BootstrapList) value).close();
}

View File

@ -1,5 +1,9 @@
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.InputStream;
import java.io.OutputStream;
@ -8,9 +12,6 @@ import java.net.Socket;
import java.net.SocketAddress;
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
* all methods in {@link Socket} to ensure that calls are not mistakingly made

View File

@ -1,19 +1,19 @@
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.util.Iterator;
import java.util.List;
import java.util.Map;
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.
* @author Kristian

View File

@ -12,7 +12,7 @@ import com.comphenix.protocol.timing.TimedListenerManager.ListenerType;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
import com.google.common.io.Closeables;
import com.google.common.io.Closer;
import com.google.common.io.Files;
public class TimingReportGenerator {
@ -22,20 +22,21 @@ public class TimingReportGenerator {
private static final String PLUGIN_HEADER = "=== PLUGIN %s ===" + NEWLINE;
private static final String LISTENER_HEADER = " TYPE: %s " + NEWLINE;
private static final String SEPERATION_LINE = " " + Strings.repeat("-", 139) + NEWLINE;
private static final String STATISTICS_HEADER =
private static final String STATISTICS_HEADER =
" Protocol: Name: ID: Count: Min (ms): " +
"Max (ms): Mean (ms): Std (ms): " + NEWLINE;
private static final String STATISTICS_ROW = " %-15s %-29s %-19s %-12d %-15.6f %-15.6f %-15.6f %.6f " + NEWLINE;
private static final String SUM_MAIN_THREAD = " => Time on main thread: %.6f ms" + NEWLINE;
public void saveTo(File destination, TimedListenerManager manager) throws IOException {
Closer closer = Closer.create();
BufferedWriter writer = null;
Date started = manager.getStarted();
Date stopped = manager.getStopped();
long seconds = Math.abs((stopped.getTime() - started.getTime()) / 1000);
try {
writer = Files.newWriter(destination, Charsets.UTF_8);
writer = closer.register(Files.newWriter(destination, Charsets.UTF_8));
// Write some timing information
writer.write(String.format(META_STARTED, started));
@ -60,13 +61,8 @@ public class TimingReportGenerator {
// Next plugin
writer.write(NEWLINE);
}
} finally {
if (writer != null) {
// Don't suppress exceptions
writer.flush();
Closeables.closeQuietly(writer);
}
closer.close();
}
}
@ -97,21 +93,21 @@ public class TimingReportGenerator {
}
// These are executed on the main thread
if (type == ListenerType.SYNC_SERVER_SIDE) {
destination.write(String.format(SUM_MAIN_THREAD,
destination.write(String.format(SUM_MAIN_THREAD,
toMilli(sum.getCount() * sum.getMean())
));
}
}
private void printStatistic(Writer destination, PacketType key, final StatisticsStream stream) throws IOException {
destination.write(String.format(STATISTICS_ROW,
key != null ? key.getProtocol() : "SUM",
key != null ? key.name() : "-",
destination.write(String.format(STATISTICS_ROW,
key != null ? key.getProtocol() : "SUM",
key != null ? key.name() : "-",
key != null ? getPacketId(key) : "-",
stream.getCount(),
toMilli(stream.getMinimum()),
toMilli(stream.getMaximum()),
toMilli(stream.getMean()),
stream.getCount(),
toMilli(stream.getMinimum()),
toMilli(stream.getMaximum()),
toMilli(stream.getMean()),
toMilli(stream.getStandardDeviation())
));
}

View File

@ -1,5 +1,9 @@
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.DataOutputStream;
import java.io.IOException;
@ -12,19 +16,14 @@ import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel;
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.FieldAccessor;
import com.google.common.io.ByteStreams;
import com.google.common.io.LimitInputStream;
/**
* Construct a ByteBuf around an input stream and an output stream.
* <p>
* Note that as streams usually don't support seeking, this implementation will ignore
* Note that as streams usually don't support seeking, this implementation will ignore
* all indexing in the byte buffer.
* @author Kristian
*/
@ -250,13 +249,13 @@ class ByteBufAdapter extends AbstractByteBuf {
@Override
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;
}
@Override
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));
return data.length;
@ -299,7 +298,7 @@ class ByteBufAdapter extends AbstractByteBuf {
@Override
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);
return length - limit.available();
}

View File

@ -1,14 +1,15 @@
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.Method;
import java.util.List;
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.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

View File

@ -17,6 +17,8 @@
package com.comphenix.protocol.utility;
import io.netty.buffer.ByteBuf;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.IOException;
@ -37,8 +39,6 @@ import java.util.regex.Pattern;
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.MethodVisitor;
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.google.common.base.Joiner;
import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
/**
* Methods and constants specifically used in conjuction with reflecting Minecraft object.

View File

@ -23,65 +23,79 @@ class GuavaWrappers {
* @return The Bukkit multimap.
*/
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) {
return GuavaReflection.getBukkitMultimap(multimap);
}
Multimap<TKey, TValue> result = new Multimap<TKey, TValue>() {
@Override
public Map<TKey, Collection<TValue>> asMap() {
return multimap.asMap();
}
@Override
public void clear() {
multimap.clear();
}
@Override
public boolean containsEntry(Object arg0, Object arg1) {
return multimap.containsEntry(arg0, arg1);
}
@Override
public boolean containsKey(Object arg0) {
return multimap.containsKey(arg0);
}
@Override
public boolean containsValue(Object arg0) {
return multimap.containsValue(arg0);
}
@Override
public Collection<Entry<TKey, TValue>> entries() {
return multimap.entries();
}
@Override
public boolean equals(Object arg0) {
return multimap.equals(arg0);
}
@Override
public Collection<TValue> get(TKey arg0) {
return multimap.get(arg0);
}
@Override
public int hashCode() {
return multimap.hashCode();
}
@Override
public boolean isEmpty() {
return multimap.isEmpty();
}
@Override
public Set<TKey> keySet() {
return multimap.keySet();
}
@Override
public Multiset<TKey> keys() {
return getBukkitMultiset(multimap.keys());
}
@Override
public boolean put(TKey arg0, TValue arg1) {
return multimap.put(arg0, arg1);
}
@Override
public boolean putAll(com.google.common.collect.Multimap<? extends TKey, ? extends TValue> arg0) {
boolean result = false;
@ -92,33 +106,39 @@ class GuavaWrappers {
return result;
}
@Override
public boolean putAll(TKey arg0, Iterable<? extends TValue> arg1) {
return multimap.putAll(arg0, arg1);
}
@Override
public boolean remove(Object arg0, Object arg1) {
return multimap.remove(arg0, arg1);
}
@Override
public Collection<TValue> removeAll(Object arg0) {
return multimap.removeAll(arg0);
}
@Override
public Collection<TValue> replaceValues(TKey arg0, Iterable<? extends TValue> arg1) {
return multimap.replaceValues(arg0, arg1);
}
@Override
public int size() {
return multimap.size();
}
@Override
public Collection<TValue> values() {
return multimap.values();
}
}
};
try {
result.size(); // Test
result.size(); // Test
return result;
} catch (LinkageError e) {
// Occurs on Cauldron 1.7.10
@ -127,123 +147,146 @@ 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) {
return GuavaReflection.getBukkitMultiset(multiset);
}
Multiset<TValue> result = new Multiset<TValue>() {
@Override
public int add(TValue arg0, int arg1) {
return multiset.add(arg0, arg1);
}
@Override
public boolean add(TValue arg0) {
return multiset.add(arg0);
}
@Override
public boolean addAll(Collection<? extends TValue> c) {
return multiset.addAll(c);
}
@Override
public void clear() {
multiset.clear();
}
@Override
public boolean contains(Object arg0) {
return multiset.contains(arg0);
}
@Override
public boolean containsAll(Collection<?> arg0) {
return multiset.containsAll(arg0);
}
@Override
public int count(Object arg0) {
return multiset.count(arg0);
}
@Override
public Set<TValue> elementSet() {
return multiset.elementSet();
}
@Override
public Set<Multiset.Entry<TValue>> entrySet() {
return new ConvertedSet<
net.minecraft.util.com.google.common.collect.Multiset.Entry<TValue>,
com.google.common.collect.Multiset.Entry<TValue>,
Multiset.Entry<TValue>>
(multiset.entrySet()) {
@Override
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);
}
@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) {
throw new UnsupportedOperationException("Cannot convert " + outer);
}
};
}
@Override
public boolean equals(Object arg0) {
return multiset.equals(arg0);
}
@Override
public int hashCode() {
return multiset.hashCode();
}
@Override
public boolean isEmpty() {
return multiset.isEmpty();
}
@Override
public Iterator<TValue> iterator() {
return multiset.iterator();
}
@Override
public int remove(Object arg0, int arg1) {
return multiset.remove(arg0, arg1);
}
@Override
public boolean remove(Object arg0) {
return multiset.remove(arg0);
}
@Override
public boolean removeAll(Collection<?> arg0) {
return multiset.removeAll(arg0);
}
@Override
public boolean retainAll(Collection<?> arg0) {
return multiset.retainAll(arg0);
}
@Override
public boolean setCount(TValue arg0, int arg1, int arg2) {
return multiset.setCount(arg0, arg1, arg2);
}
@Override
public int setCount(TValue arg0, int arg1) {
return multiset.setCount(arg0, arg1);
}
@Override
public int size() {
return multiset.size();
}
@Override
public Object[] toArray() {
return multiset.toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return multiset.toArray(a);
}
@Override
public String toString() {
return multiset.toString();
}
};
try {
result.size(); // Test
result.size(); // Test
return result;
} catch (LinkageError e) {
USE_REFLECTION_FALLBACK = true;
@ -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>() {
@Override
public boolean equals(Object arg0) {
return entry.equals(arg0);
}
@Override
public int getCount() {
return entry.getCount();
}
@Override
public TValue getElement() {
return entry.getElement();
}
@Override
public int hashCode() {
return entry.hashCode();
}
@Override
public String toString() {
return entry.toString();
}

View File

@ -3,9 +3,6 @@ package com.comphenix.protocol.wrappers;
import java.util.UUID;
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.entity.Player;
@ -22,6 +19,8 @@ import com.comphenix.protocol.wrappers.collection.ConvertedMultimap;
import com.google.common.base.Charsets;
import com.google.common.base.Objects;
import com.google.common.collect.Multimap;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
/**
* Represents a wrapper for a game profile.
@ -88,7 +87,7 @@ public class WrappedGameProfile extends AbstractWrapper {
/**
* Construct a new game profile with the given properties.
* <p>
* Note that this constructor is very lenient when parsing UUIDs for backwards compatibility reasons.
* Note that this constructor is very lenient when parsing UUIDs for backwards compatibility reasons.
* IDs that cannot be parsed as an UUID will be hashed and form a version 3 UUID instead.
* <p>
* This method is deprecated for Minecraft 1.7.8 and above.
@ -128,7 +127,7 @@ public class WrappedGameProfile extends AbstractWrapper {
* @param profile - the underlying profile, or NULL.
*/
public static WrappedGameProfile fromHandle(Object handle) {
if (handle == null)
if (handle == null)
return null;
return new WrappedGameProfile(handle);
}
@ -145,7 +144,7 @@ public class WrappedGameProfile extends AbstractWrapper {
} catch (IllegalArgumentException e) {
// Warn once every hour (per plugin)
ProtocolLibrary.getErrorReporter().reportWarning(
WrappedGameProfile.class,
WrappedGameProfile.class,
Report.newBuilder(REPORT_INVALID_UUID).
rateLimit(1, TimeUnit.HOURS).
messageParam(PluginContext.getPluginCaller(new Exception()), id)

View File

@ -1,5 +1,10 @@
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.RenderedImage;
import java.io.ByteArrayInputStream;
@ -10,12 +15,6 @@ import java.util.List;
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.Server;
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.Lists;
import com.google.common.io.ByteStreams;
import com.mojang.authlib.GameProfile;
/**
* Represents a server ping packet data.

View File

@ -2,9 +2,8 @@ package com.comphenix.protocol.wrappers;
import java.security.PublicKey;
import net.minecraft.util.com.mojang.authlib.properties.Property;
import com.google.common.base.Objects;
import com.mojang.authlib.properties.Property;
/**
* Represents a wrapper over a signed property.
@ -68,7 +67,7 @@ public class WrappedSignedProperty extends AbstractWrapper {
}
/**
* Retrieve the signature of the property (base64) as returned by the session server's /hasJoined.
* Retrieve the signature of the property (base64) as returned by the session server's /hasJoined.
* @return The signature of the property.
*/
public String getSignature() {
@ -76,7 +75,7 @@ public class WrappedSignedProperty extends AbstractWrapper {
}
/**
* Retrieve the value of the property (base64) as return by the session server's /hasJoined
* Retrieve the value of the property (base64) as return by the session server's /hasJoined
* @return The value of the property.
*/
public String getValue() {
@ -108,7 +107,7 @@ public class WrappedSignedProperty extends AbstractWrapper {
@Override
public boolean equals(Object object){
if (object instanceof WrappedSignedProperty) {
if (!super.equals(object))
if (!super.equals(object))
return false;
WrappedSignedProperty that = (WrappedSignedProperty) object;
return Objects.equal(this.getName(), that.getName())

View File

@ -34,14 +34,14 @@ import com.google.common.io.Files;
@RunWith(org.powermock.modules.junit4.PowerMockRunner.class)
@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" })
@PrepareForTest(PluginDescriptionFile.class)
public class SimpleCraftBukkitITCase {
public class SimpleCraftBukkitITCase {
// The fake plugin
private static volatile Plugin FAKE_PLUGIN = null;
/**
* The maximum amount of time to wait before a server has started.
* <p>
* We have to give it the ample time of 60 seconds, as a server may have to
* We have to give it the ample time of 60 seconds, as a server may have to
* generate the spawn area in three worlds.
*/
private static final int TIMEOUT_MS = 60000;
@ -125,7 +125,7 @@ public class SimpleCraftBukkitITCase {
// Copy the ProtocolLib plugin to the server
if (pluginDirectory.exists()) {
Files.deleteDirectoryContents(pluginDirectory);
deleteFolder(pluginDirectory);
}
pluginDirectory.mkdirs();
@ -133,6 +133,21 @@ public class SimpleCraftBukkitITCase {
File destination = new File(pluginDirectory, bestFile.getName()).getAbsoluteFile();
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.

View File

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

View File

@ -26,9 +26,9 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.UUID;
import net.minecraft.server.v1_7_R4.AttributeModifier;
import net.minecraft.server.v1_7_R4.AttributeSnapshot;
import net.minecraft.server.v1_7_R4.PacketPlayOutUpdateAttributes;
import net.minecraft.server.v1_8_R1.AttributeModifier;
import net.minecraft.server.v1_8_R1.AttributeSnapshot;
import net.minecraft.server.v1_8_R1.PacketPlayOutUpdateAttributes;
import org.apache.commons.lang.SerializationUtils;
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.Material;
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.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

View File

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

View File

@ -8,10 +8,10 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
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.craftbukkit.v1_7_R4.inventory.CraftItemFactory;
import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemFactory;
import org.bukkit.inventory.ItemStack;
import org.junit.BeforeClass;
import org.junit.Test;

View File

@ -15,15 +15,15 @@ public class ChunkCoordIntPairTest {
@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);
assertEquals(1, specific.getChunkX());
assertEquals(2, specific.getChunkZ());
net.minecraft.server.v1_7_R4.ChunkCoordIntPair roundtrip =
(net.minecraft.server.v1_7_R4.ChunkCoordIntPair) ChunkCoordIntPair.getConverter().
getGeneric(net.minecraft.server.v1_7_R4.ChunkCoordIntPair.class, specific);
net.minecraft.server.v1_8_R1.ChunkCoordIntPair roundtrip =
(net.minecraft.server.v1_8_R1.ChunkCoordIntPair) ChunkCoordIntPair.getConverter().
getGeneric(net.minecraft.server.v1_8_R1.ChunkCoordIntPair.class, specific);
assertEquals(1, roundtrip.x);
assertEquals(2, roundtrip.z);

View File

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

View File

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

View File

@ -3,7 +3,7 @@ package com.comphenix.protocol.wrappers;
import static org.junit.Assert.assertEquals;
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.junit.BeforeClass;
import org.junit.Test;

View File

@ -27,7 +27,7 @@ import java.io.DataOutput;
import java.io.DataOutputStream;
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.junit.BeforeClass;
import org.junit.Test;