Update to 1.7.10, update readme, organize imports
Dieser Commit ist enthalten in:
Ursprung
d8181b7bf3
Commit
cfb5944990
@ -1,11 +1,12 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<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.5.0-SNAPSHOT</version>
|
<version>3.5.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Provides read/write access to the Minecraft protocol.</description>
|
<description>Provides read/write access to the Minecraft protocol.</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>cp1252</project.build.sourceEncoding>
|
<project.build.sourceEncoding>cp1252</project.build.sourceEncoding>
|
||||||
<powermock.version>1.5</powermock.version>
|
<powermock.version>1.5</powermock.version>
|
||||||
@ -23,11 +24,11 @@
|
|||||||
<url>http://repo.comphenix.net/content/repositories/snapshots/</url>
|
<url>http://repo.comphenix.net/content/repositories/snapshots/</url>
|
||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>bukkit-rep</id>
|
<id>md_5-repo</id>
|
||||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
<url>http://repo.md-5.net/content/repositories/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>comphenix-releases</id>
|
<id>comphenix-releases</id>
|
||||||
@ -35,7 +36,7 @@
|
|||||||
<url>http://repo.comphenix.net/content/repositories/releases/</url>
|
<url>http://repo.comphenix.net/content/repositories/releases/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean install</defaultGoal>
|
<defaultGoal>clean install</defaultGoal>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
@ -49,7 +50,7 @@
|
|||||||
</excludes>
|
</excludes>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@ -71,7 +72,7 @@
|
|||||||
<shadedPattern>com.comphenix.net.sf</shadedPattern>
|
<shadedPattern>com.comphenix.net.sf</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
|
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>org.bukkit:craftbukkit</exclude>
|
<exclude>org.bukkit:craftbukkit</exclude>
|
||||||
@ -82,7 +83,7 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
@ -92,108 +93,108 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-failsafe-plugin</artifactId>
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
<version>2.12.4</version>
|
<version>2.12.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<workingDirectory>${basedir}/target/server/</workingDirectory>
|
<workingDirectory>${basedir}/target/server/</workingDirectory>
|
||||||
<argLine>-Xmx1024m -Xms1024M -Dnojline=true</argLine>
|
<argLine>-Xmx1024m -Xms1024M -Dnojline=true</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>integration-test</goal>
|
<goal>integration-test</goal>
|
||||||
<goal>verify</goal>
|
<goal>verify</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<reporting>
|
<reporting>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>findbugs-maven-plugin</artifactId>
|
<artifactId>findbugs-maven-plugin</artifactId>
|
||||||
<version>2.5.2</version>
|
<version>2.5.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<threshold>High</threshold>
|
<threshold>High</threshold>
|
||||||
<effort>Default</effort>
|
<effort>Default</effort>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</reporting>
|
</reporting>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>release-sign-artifacts</id>
|
<id>release-sign-artifacts</id>
|
||||||
<activation>
|
<activation>
|
||||||
<property>
|
<property>
|
||||||
<name>performRelease</name>
|
<name>performRelease</name>
|
||||||
<value>true</value>
|
<value>true</value>
|
||||||
</property>
|
</property>
|
||||||
</activation>
|
</activation>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>2.2</version>
|
<version>2.2</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>attach-sources</id>
|
<id>attach-sources</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>jar</goal>
|
<goal>jar</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>2.9</version>
|
<version>2.9</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>attach-javadocs</id>
|
<id>attach-javadocs</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>jar</goal>
|
<goal>jar</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.4</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>sign-artifacts</id>
|
<id>sign-artifacts</id>
|
||||||
<phase>verify</phase>
|
<phase>verify</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>sign</goal>
|
<goal>sign</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<url>http://dev.bukkit.org/server-mods/protocollib/</url>
|
<url>http://dev.bukkit.org/server-mods/protocollib/</url>
|
||||||
<name>ProtocolLib</name>
|
<name>ProtocolLib</name>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git://github.com/aadnk/ProtocolLib.git</connection>
|
<connection>scm:git:git://github.com/aadnk/ProtocolLib.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:aadnk/ProtocolLib.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:aadnk/ProtocolLib.git</developerConnection>
|
||||||
<url>https://github.com/aadnk/ProtocolLib</url>
|
<url>https://github.com/aadnk/ProtocolLib</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>GNU GENERAL PUBLIC LICENSE - Version 2, June 1991</name>
|
<name>GNU GENERAL PUBLIC LICENSE - Version 2, June 1991</name>
|
||||||
@ -201,63 +202,75 @@
|
|||||||
<distribution>repo</distribution>
|
<distribution>repo</distribution>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>dmulloy2</id>
|
||||||
|
<name>Dan Mulloy</name>
|
||||||
|
<url>http://shadowvolt.com/</url>
|
||||||
|
<roles>
|
||||||
|
<role>developer</role>
|
||||||
|
<role>maintainer</role>
|
||||||
|
</roles>
|
||||||
|
</developer>
|
||||||
<developer>
|
<developer>
|
||||||
<id>aadnk</id>
|
<id>aadnk</id>
|
||||||
<name>Kristian S. Stangeland</name>
|
<name>Kristian S. Stangeland</name>
|
||||||
<email>kr_stang@hotmail.com</email>
|
<email>kr_stang@hotmail.com</email>
|
||||||
<url>http://comphenix.net/</url>
|
<url>http://comphenix.net/</url>
|
||||||
<roles>
|
<roles>
|
||||||
<role>developer</role>
|
<role>former author</role>
|
||||||
<role>maintainer</role>
|
|
||||||
</roles>
|
</roles>
|
||||||
<timezone>1</timezone>
|
<timezone>1</timezone>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cglib</groupId>
|
<groupId>cglib</groupId>
|
||||||
<artifactId>cglib-nodep</artifactId>
|
<artifactId>cglib-nodep</artifactId>
|
||||||
<version>2.2.2</version>
|
<version>2.2.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.comphenix.executors</groupId>
|
<groupId>com.comphenix.executors</groupId>
|
||||||
<artifactId>BukkitExecutors</artifactId>
|
<artifactId>BukkitExecutors</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.7.8-R0.1-SNAPSHOT</version>
|
<version>1.7.10-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
<dependency>
|
<groupId>org.spigotmc</groupId>
|
||||||
<groupId>junit</groupId>
|
<artifactId>spigot</artifactId>
|
||||||
<artifactId>junit</artifactId>
|
<version>1.7.10-R0.1-SNAPSHOT</version>
|
||||||
<version>4.10</version>
|
</dependency>
|
||||||
<scope>test</scope>
|
<dependency>
|
||||||
</dependency>
|
<groupId>junit</groupId>
|
||||||
<dependency>
|
<artifactId>junit</artifactId>
|
||||||
<groupId>org.mockito</groupId>
|
<version>4.10</version>
|
||||||
<artifactId>mockito-all</artifactId>
|
<scope>test</scope>
|
||||||
<version>1.8.4</version>
|
</dependency>
|
||||||
<scope>test</scope>
|
<dependency>
|
||||||
</dependency>
|
<groupId>org.mockito</groupId>
|
||||||
<dependency>
|
<artifactId>mockito-all</artifactId>
|
||||||
<groupId>org.powermock</groupId>
|
<version>1.8.4</version>
|
||||||
<artifactId>powermock-module-junit4</artifactId>
|
<scope>test</scope>
|
||||||
<version>${powermock.version}</version>
|
</dependency>
|
||||||
<scope>test</scope>
|
<dependency>
|
||||||
</dependency>
|
<groupId>org.powermock</groupId>
|
||||||
<dependency>
|
<artifactId>powermock-module-junit4</artifactId>
|
||||||
<groupId>org.powermock</groupId>
|
<version>${powermock.version}</version>
|
||||||
<artifactId>powermock-api-mockito</artifactId>
|
<scope>test</scope>
|
||||||
<version>${powermock.version}</version>
|
</dependency>
|
||||||
<scope>test</scope>
|
<dependency>
|
||||||
</dependency>
|
<groupId>org.powermock</groupId>
|
||||||
|
<artifactId>powermock-api-mockito</artifactId>
|
||||||
|
<version>${powermock.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -19,6 +19,7 @@ package com.comphenix.protocol;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
@ -9,12 +9,12 @@ import java.util.concurrent.Callable;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import com.comphenix.protocol.events.ConnectionSide;
|
import com.comphenix.protocol.events.ConnectionSide;
|
||||||
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
||||||
import com.comphenix.protocol.reflect.ObjectEnum;
|
import com.comphenix.protocol.reflect.ObjectEnum;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.ComparisonChain;
|
import com.google.common.collect.ComparisonChain;
|
||||||
|
@ -8,10 +8,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import com.comphenix.protocol.utility.SafeCacheBuilder;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.utility.SafeCacheBuilder;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.RemovalListener;
|
import com.google.common.cache.RemovalListener;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.comphenix.protocol.error;
|
package com.comphenix.protocol.error;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.comphenix.protocol.error.Report.ReportBuilder;
|
import com.comphenix.protocol.error.Report.ReportBuilder;
|
||||||
|
@ -26,7 +26,6 @@ import java.util.Set;
|
|||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.injector.GamePhase;
|
import com.comphenix.protocol.injector.GamePhase;
|
||||||
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
@ -23,10 +23,6 @@ import java.util.logging.Logger;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.comphenix.protocol.Packets;
|
import com.comphenix.protocol.Packets;
|
||||||
import com.comphenix.protocol.events.ConnectionSide;
|
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
|
||||||
import com.comphenix.protocol.events.ListeningWhitelist;
|
|
||||||
import com.comphenix.protocol.events.PacketListener;
|
|
||||||
import com.comphenix.protocol.injector.GamePhase;
|
import com.comphenix.protocol.injector.GamePhase;
|
||||||
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
||||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||||
|
@ -12,6 +12,8 @@ import java.util.PriorityQueue;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.comphenix.protocol.utility.ByteBufferInputStream;
|
import com.comphenix.protocol.utility.ByteBufferInputStream;
|
||||||
|
@ -49,20 +49,19 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.PacketType.Protocol;
|
import com.comphenix.protocol.PacketType.Protocol;
|
||||||
import com.comphenix.protocol.PacketType.Sender;
|
|
||||||
import com.comphenix.protocol.injector.StructureCache;
|
import com.comphenix.protocol.injector.StructureCache;
|
||||||
import com.comphenix.protocol.reflect.EquivalentConverter;
|
import com.comphenix.protocol.reflect.EquivalentConverter;
|
||||||
import com.comphenix.protocol.reflect.FuzzyReflection;
|
import com.comphenix.protocol.reflect.FuzzyReflection;
|
||||||
import com.comphenix.protocol.reflect.ObjectWriter;
|
import com.comphenix.protocol.reflect.ObjectWriter;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
import com.comphenix.protocol.reflect.cloning.AggregateCloner;
|
import com.comphenix.protocol.reflect.cloning.AggregateCloner;
|
||||||
|
import com.comphenix.protocol.reflect.cloning.AggregateCloner.BuilderParameters;
|
||||||
import com.comphenix.protocol.reflect.cloning.BukkitCloner;
|
import com.comphenix.protocol.reflect.cloning.BukkitCloner;
|
||||||
import com.comphenix.protocol.reflect.cloning.Cloner;
|
import com.comphenix.protocol.reflect.cloning.Cloner;
|
||||||
import com.comphenix.protocol.reflect.cloning.CollectionCloner;
|
import com.comphenix.protocol.reflect.cloning.CollectionCloner;
|
||||||
import com.comphenix.protocol.reflect.cloning.FieldCloner;
|
import com.comphenix.protocol.reflect.cloning.FieldCloner;
|
||||||
import com.comphenix.protocol.reflect.cloning.ImmutableDetector;
|
import com.comphenix.protocol.reflect.cloning.ImmutableDetector;
|
||||||
import com.comphenix.protocol.reflect.cloning.SerializableCloner;
|
import com.comphenix.protocol.reflect.cloning.SerializableCloner;
|
||||||
import com.comphenix.protocol.reflect.cloning.AggregateCloner.BuilderParameters;
|
|
||||||
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
|
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
|
||||||
import com.comphenix.protocol.reflect.instances.DefaultInstances;
|
import com.comphenix.protocol.reflect.instances.DefaultInstances;
|
||||||
import com.comphenix.protocol.utility.MinecraftMethods;
|
import com.comphenix.protocol.utility.MinecraftMethods;
|
||||||
@ -72,7 +71,11 @@ import com.comphenix.protocol.wrappers.BukkitConverters;
|
|||||||
import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
|
import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
|
||||||
import com.comphenix.protocol.wrappers.ChunkPosition;
|
import com.comphenix.protocol.wrappers.ChunkPosition;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
|
import com.comphenix.protocol.wrappers.EnumWrappers.ChatVisibility;
|
||||||
|
import com.comphenix.protocol.wrappers.EnumWrappers.ClientCommand;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty;
|
import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty;
|
||||||
|
import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction;
|
||||||
|
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
||||||
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
@ -80,10 +83,6 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedServerPing;
|
import com.comphenix.protocol.wrappers.WrappedServerPing;
|
||||||
import com.comphenix.protocol.wrappers.WrappedStatistic;
|
import com.comphenix.protocol.wrappers.WrappedStatistic;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.ChatVisibility;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.ClientCommand;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
@ -5,9 +5,10 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketStream;
|
import com.comphenix.protocol.PacketStream;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.PacketType.Sender;
|
import com.comphenix.protocol.PacketType.Sender;
|
||||||
import com.google.common.base.Preconditions;import com.google.common.base.Objects;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a packet that is scheduled for transmission at a later stage.
|
* Represents a packet that is scheduled for transmission at a later stage.
|
||||||
|
@ -5,6 +5,7 @@ import java.util.Collections;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -16,8 +17,8 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
|
|
||||||
import com.comphenix.protocol.AsynchronousManager;
|
import com.comphenix.protocol.AsynchronousManager;
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
|
||||||
import com.comphenix.protocol.PacketType.Sender;
|
import com.comphenix.protocol.PacketType.Sender;
|
||||||
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.comphenix.protocol.error.ErrorReporter;
|
import com.comphenix.protocol.error.ErrorReporter;
|
||||||
import com.comphenix.protocol.error.Report;
|
import com.comphenix.protocol.error.Report;
|
||||||
import com.comphenix.protocol.error.ReportType;
|
import com.comphenix.protocol.error.ReportType;
|
||||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -25,8 +25,8 @@ import com.comphenix.protocol.events.ListenerPriority;
|
|||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.events.PacketListener;
|
import com.comphenix.protocol.events.PacketListener;
|
||||||
import com.comphenix.protocol.timing.TimedListenerManager;
|
import com.comphenix.protocol.timing.TimedListenerManager;
|
||||||
import com.comphenix.protocol.timing.TimedTracker;
|
|
||||||
import com.comphenix.protocol.timing.TimedListenerManager.ListenerType;
|
import com.comphenix.protocol.timing.TimedListenerManager.ListenerType;
|
||||||
|
import com.comphenix.protocol.timing.TimedTracker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registry of synchronous packet listeners.
|
* Registry of synchronous packet listeners.
|
||||||
|
@ -6,14 +6,13 @@ import java.util.List;
|
|||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.minecraft.util.io.netty.channel.Channel;
|
import net.minecraft.util.io.netty.channel.Channel;
|
||||||
|
|
||||||
// Hopefully, CB won't version these as well
|
// Hopefully, CB won't version these as well
|
||||||
import net.minecraft.util.io.netty.channel.ChannelFuture;
|
import net.minecraft.util.io.netty.channel.ChannelFuture;
|
||||||
import net.minecraft.util.io.netty.channel.ChannelHandler;
|
import net.minecraft.util.io.netty.channel.ChannelHandler;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
class BootstrapList implements List<Object> {
|
class BootstrapList implements List<Object> {
|
||||||
private List<Object> delegate;
|
private List<Object> delegate;
|
||||||
private ChannelHandler handler;
|
private ChannelHandler handler;
|
||||||
|
@ -35,7 +35,6 @@ import com.comphenix.protocol.PacketType.Protocol;
|
|||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.error.Report;
|
import com.comphenix.protocol.error.Report;
|
||||||
import com.comphenix.protocol.error.ReportType;
|
import com.comphenix.protocol.error.ReportType;
|
||||||
import com.comphenix.protocol.error.Report.ReportBuilder;
|
|
||||||
import com.comphenix.protocol.events.ConnectionSide;
|
import com.comphenix.protocol.events.ConnectionSide;
|
||||||
import com.comphenix.protocol.events.NetworkMarker;
|
import com.comphenix.protocol.events.NetworkMarker;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
@ -5,10 +5,6 @@ import java.net.SocketAddress;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import com.comphenix.protocol.reflect.accessors.Accessors;
|
|
||||||
import com.comphenix.protocol.reflect.accessors.FieldAccessor;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
|
|
||||||
import net.minecraft.util.io.netty.buffer.ByteBufAllocator;
|
import net.minecraft.util.io.netty.buffer.ByteBufAllocator;
|
||||||
import net.minecraft.util.io.netty.channel.Channel;
|
import net.minecraft.util.io.netty.channel.Channel;
|
||||||
import net.minecraft.util.io.netty.channel.ChannelConfig;
|
import net.minecraft.util.io.netty.channel.ChannelConfig;
|
||||||
@ -21,6 +17,10 @@ import net.minecraft.util.io.netty.channel.EventLoop;
|
|||||||
import net.minecraft.util.io.netty.util.Attribute;
|
import net.minecraft.util.io.netty.util.Attribute;
|
||||||
import net.minecraft.util.io.netty.util.AttributeKey;
|
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;
|
||||||
|
|
||||||
abstract class ChannelProxy implements Channel {
|
abstract class ChannelProxy implements Channel {
|
||||||
// Mark that a certain object does not contain a message field
|
// Mark that a certain object does not contain a message field
|
||||||
private static final FieldAccessor MARK_NO_MESSAGE = new FieldAccessor() {
|
private static final FieldAccessor MARK_NO_MESSAGE = new FieldAccessor() {
|
||||||
|
@ -3,7 +3,9 @@ package com.comphenix.protocol.injector.netty;
|
|||||||
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 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;
|
||||||
|
@ -7,8 +7,6 @@ import java.lang.reflect.Method;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import net.minecraft.util.io.netty.channel.Channel;
|
import net.minecraft.util.io.netty.channel.Channel;
|
||||||
import net.minecraft.util.io.netty.channel.ChannelFuture;
|
import net.minecraft.util.io.netty.channel.ChannelFuture;
|
||||||
@ -18,12 +16,19 @@ import net.minecraft.util.io.netty.channel.ChannelInboundHandler;
|
|||||||
import net.minecraft.util.io.netty.channel.ChannelInboundHandlerAdapter;
|
import net.minecraft.util.io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
import net.minecraft.util.io.netty.channel.ChannelInitializer;
|
import net.minecraft.util.io.netty.channel.ChannelInitializer;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.concurrency.PacketTypeSet;
|
import com.comphenix.protocol.concurrency.PacketTypeSet;
|
||||||
import com.comphenix.protocol.error.ErrorReporter;
|
import com.comphenix.protocol.error.ErrorReporter;
|
||||||
import com.comphenix.protocol.error.Report;
|
import com.comphenix.protocol.error.Report;
|
||||||
import com.comphenix.protocol.error.ReportType;
|
import com.comphenix.protocol.error.ReportType;
|
||||||
import com.comphenix.protocol.events.*;
|
import com.comphenix.protocol.events.ConnectionSide;
|
||||||
|
import com.comphenix.protocol.events.ListenerOptions;
|
||||||
|
import com.comphenix.protocol.events.NetworkMarker;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.injector.ListenerInvoker;
|
import com.comphenix.protocol.injector.ListenerInvoker;
|
||||||
import com.comphenix.protocol.injector.packet.PacketInjector;
|
import com.comphenix.protocol.injector.packet.PacketInjector;
|
||||||
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
||||||
|
@ -5,6 +5,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
|
@ -4,8 +4,8 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -19,7 +19,6 @@ import com.comphenix.protocol.reflect.fuzzy.FuzzyFieldContract;
|
|||||||
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
|
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
import com.comphenix.protocol.wrappers.TroveWrapper;
|
import com.comphenix.protocol.wrappers.TroveWrapper;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -24,14 +24,15 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.sf.cglib.proxy.Callback;
|
import net.sf.cglib.proxy.Callback;
|
||||||
|
import net.sf.cglib.proxy.CallbackFilter;
|
||||||
import net.sf.cglib.proxy.Enhancer;
|
import net.sf.cglib.proxy.Enhancer;
|
||||||
import net.sf.cglib.proxy.Factory;
|
import net.sf.cglib.proxy.Factory;
|
||||||
import net.sf.cglib.proxy.CallbackFilter;
|
|
||||||
import net.sf.cglib.proxy.NoOp;
|
import net.sf.cglib.proxy.NoOp;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.PacketType.Sender;
|
import com.comphenix.protocol.PacketType.Sender;
|
||||||
import com.comphenix.protocol.error.ErrorReporter;
|
import com.comphenix.protocol.error.ErrorReporter;
|
||||||
|
@ -23,6 +23,9 @@ import java.io.InputStream;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.sf.cglib.proxy.MethodInterceptor;
|
||||||
|
import net.sf.cglib.proxy.MethodProxy;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.PacketType.Sender;
|
import com.comphenix.protocol.PacketType.Sender;
|
||||||
import com.comphenix.protocol.error.ErrorReporter;
|
import com.comphenix.protocol.error.ErrorReporter;
|
||||||
@ -34,9 +37,6 @@ import com.comphenix.protocol.events.PacketEvent;
|
|||||||
import com.comphenix.protocol.injector.NetworkProcessor;
|
import com.comphenix.protocol.injector.NetworkProcessor;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
|
|
||||||
import net.sf.cglib.proxy.MethodInterceptor;
|
|
||||||
import net.sf.cglib.proxy.MethodProxy;
|
|
||||||
|
|
||||||
class ReadPacketModifier implements MethodInterceptor {
|
class ReadPacketModifier implements MethodInterceptor {
|
||||||
public static final ReportType REPORT_CANNOT_HANDLE_CLIENT_PACKET = new ReportType("Cannot handle client packet.");
|
public static final ReportType REPORT_CANNOT_HANDLE_CLIENT_PACKET = new ReportType("Cannot handle client packet.");
|
||||||
|
|
||||||
|
@ -22,20 +22,18 @@ import java.io.DataOutput;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.PriorityQueue;
|
|
||||||
|
import net.sf.cglib.proxy.MethodInterceptor;
|
||||||
|
import net.sf.cglib.proxy.MethodProxy;
|
||||||
|
|
||||||
import com.comphenix.protocol.error.ErrorReporter;
|
import com.comphenix.protocol.error.ErrorReporter;
|
||||||
import com.comphenix.protocol.error.Report;
|
import com.comphenix.protocol.error.Report;
|
||||||
import com.comphenix.protocol.error.ReportType;
|
import com.comphenix.protocol.error.ReportType;
|
||||||
import com.comphenix.protocol.events.NetworkMarker;
|
import com.comphenix.protocol.events.NetworkMarker;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.events.PacketOutputHandler;
|
|
||||||
import com.comphenix.protocol.injector.NetworkProcessor;
|
import com.comphenix.protocol.injector.NetworkProcessor;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
|
|
||||||
import net.sf.cglib.proxy.MethodInterceptor;
|
|
||||||
import net.sf.cglib.proxy.MethodProxy;
|
|
||||||
|
|
||||||
public class WritePacketModifier implements MethodInterceptor {
|
public class WritePacketModifier implements MethodInterceptor {
|
||||||
public static final ReportType REPORT_CANNOT_WRITE_SERVER_PACKET = new ReportType("Cannot write server packet.");
|
public static final ReportType REPORT_CANNOT_WRITE_SERVER_PACKET = new ReportType("Cannot write server packet.");
|
||||||
|
|
||||||
|
@ -23,6 +23,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
|
import net.sf.cglib.proxy.Callback;
|
||||||
|
import net.sf.cglib.proxy.Enhancer;
|
||||||
|
import net.sf.cglib.proxy.MethodInterceptor;
|
||||||
|
import net.sf.cglib.proxy.MethodProxy;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.error.Report;
|
import com.comphenix.protocol.error.Report;
|
||||||
@ -33,11 +38,6 @@ import com.comphenix.protocol.utility.EnhancerFactory;
|
|||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
|
|
||||||
import net.sf.cglib.proxy.Callback;
|
|
||||||
import net.sf.cglib.proxy.Enhancer;
|
|
||||||
import net.sf.cglib.proxy.MethodInterceptor;
|
|
||||||
import net.sf.cglib.proxy.MethodProxy;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The array list that notifies when packets are sent by the server.
|
* The array list that notifies when packets are sent by the server.
|
||||||
*
|
*
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package com.comphenix.protocol.injector.player;
|
package com.comphenix.protocol.injector.player;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import net.sf.cglib.proxy.Callback;
|
import net.sf.cglib.proxy.Callback;
|
||||||
import net.sf.cglib.proxy.CallbackFilter;
|
import net.sf.cglib.proxy.CallbackFilter;
|
||||||
@ -26,8 +27,6 @@ import net.sf.cglib.proxy.LazyLoader;
|
|||||||
import net.sf.cglib.proxy.MethodInterceptor;
|
import net.sf.cglib.proxy.MethodInterceptor;
|
||||||
import net.sf.cglib.proxy.MethodProxy;
|
import net.sf.cglib.proxy.MethodProxy;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -22,7 +22,13 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import net.sf.cglib.proxy.*;
|
import net.sf.cglib.proxy.Callback;
|
||||||
|
import net.sf.cglib.proxy.CallbackFilter;
|
||||||
|
import net.sf.cglib.proxy.Enhancer;
|
||||||
|
import net.sf.cglib.proxy.Factory;
|
||||||
|
import net.sf.cglib.proxy.MethodInterceptor;
|
||||||
|
import net.sf.cglib.proxy.MethodProxy;
|
||||||
|
import net.sf.cglib.proxy.NoOp;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.sf.cglib.proxy.Factory;
|
import net.sf.cglib.proxy.Factory;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -26,7 +26,6 @@ import java.net.Socket;
|
|||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -36,7 +35,6 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.PacketType.Sender;
|
import com.comphenix.protocol.PacketType.Sender;
|
||||||
import com.comphenix.protocol.Packets;
|
import com.comphenix.protocol.Packets;
|
||||||
import com.comphenix.protocol.concurrency.BlockingHashMap;
|
import com.comphenix.protocol.concurrency.BlockingHashMap;
|
||||||
@ -52,8 +50,8 @@ import com.comphenix.protocol.events.PacketEvent;
|
|||||||
import com.comphenix.protocol.events.PacketListener;
|
import com.comphenix.protocol.events.PacketListener;
|
||||||
import com.comphenix.protocol.injector.GamePhase;
|
import com.comphenix.protocol.injector.GamePhase;
|
||||||
import com.comphenix.protocol.injector.ListenerInvoker;
|
import com.comphenix.protocol.injector.ListenerInvoker;
|
||||||
import com.comphenix.protocol.injector.PlayerLoggedOutException;
|
|
||||||
import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks;
|
import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks;
|
||||||
|
import com.comphenix.protocol.injector.PlayerLoggedOutException;
|
||||||
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
||||||
import com.comphenix.protocol.injector.server.AbstractInputStreamLookup;
|
import com.comphenix.protocol.injector.server.AbstractInputStreamLookup;
|
||||||
import com.comphenix.protocol.injector.server.BukkitSocketInjector;
|
import com.comphenix.protocol.injector.server.BukkitSocketInjector;
|
||||||
|
@ -3,6 +3,7 @@ package com.comphenix.protocol.injector.server;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import java.net.InetSocketAddress;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.concurrency.PacketTypeSet;
|
import com.comphenix.protocol.concurrency.PacketTypeSet;
|
||||||
import com.comphenix.protocol.events.NetworkMarker;
|
import com.comphenix.protocol.events.NetworkMarker;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
@ -9,11 +9,6 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import net.sf.cglib.proxy.Callback;
|
import net.sf.cglib.proxy.Callback;
|
||||||
import net.sf.cglib.proxy.CallbackFilter;
|
import net.sf.cglib.proxy.CallbackFilter;
|
||||||
import net.sf.cglib.proxy.Enhancer;
|
import net.sf.cglib.proxy.Enhancer;
|
||||||
@ -22,9 +17,13 @@ import net.sf.cglib.proxy.MethodInterceptor;
|
|||||||
import net.sf.cglib.proxy.MethodProxy;
|
import net.sf.cglib.proxy.MethodProxy;
|
||||||
import net.sf.cglib.proxy.NoOp;
|
import net.sf.cglib.proxy.NoOp;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.PacketType.Sender;
|
import com.comphenix.protocol.PacketType.Sender;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.concurrency.PacketTypeSet;
|
import com.comphenix.protocol.concurrency.PacketTypeSet;
|
||||||
import com.comphenix.protocol.error.DelegatedErrorReporter;
|
import com.comphenix.protocol.error.DelegatedErrorReporter;
|
||||||
import com.comphenix.protocol.error.ErrorReporter;
|
import com.comphenix.protocol.error.ErrorReporter;
|
||||||
@ -35,7 +34,6 @@ import com.comphenix.protocol.events.NetworkMarker;
|
|||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.injector.ListenerInvoker;
|
import com.comphenix.protocol.injector.ListenerInvoker;
|
||||||
import com.comphenix.protocol.injector.PacketFilterBuilder;
|
|
||||||
import com.comphenix.protocol.injector.PacketFilterManager;
|
import com.comphenix.protocol.injector.PacketFilterManager;
|
||||||
import com.comphenix.protocol.injector.PlayerLoggedOutException;
|
import com.comphenix.protocol.injector.PlayerLoggedOutException;
|
||||||
import com.comphenix.protocol.injector.packet.LegacyNetworkMarker;
|
import com.comphenix.protocol.injector.packet.LegacyNetworkMarker;
|
||||||
@ -48,7 +46,6 @@ import com.comphenix.protocol.reflect.MethodInfo;
|
|||||||
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
|
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
|
||||||
import com.comphenix.protocol.utility.EnhancerFactory;
|
import com.comphenix.protocol.utility.EnhancerFactory;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
|
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
|
||||||
* Copyright (C) 2012 Kristian S. Stangeland
|
* Copyright (C) 2012 Kristian S. Stangeland
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
* 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
|
* GNU General Public License as published by the Free Software Foundation; either version 2 of
|
||||||
* the License, or (at your option) any later version.
|
* 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;
|
* 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.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* 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;
|
* 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
|
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
* 02111-1307 USA
|
* 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -45,14 +45,6 @@ package com.comphenix.protocol.metrics;
|
|||||||
* either expressed or implied, of anybody else.
|
* either expressed or implied, of anybody else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.utility.WrappedScheduler;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -71,6 +63,15 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.utility.BukkitUtil;
|
||||||
|
import com.comphenix.protocol.utility.WrappedScheduler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> The metrics class obtains data about a plugin and submits statistics about it to the metrics backend. </p> <p>
|
* <p> The metrics class obtains data about a plugin and submits statistics about it to the metrics backend. </p> <p>
|
||||||
* Public methods provided by this class: </p>
|
* Public methods provided by this class: </p>
|
||||||
@ -243,7 +244,8 @@ public class Metrics {
|
|||||||
|
|
||||||
private boolean firstPost = true;
|
private boolean firstPost = true;
|
||||||
|
|
||||||
public void run() {
|
@Override
|
||||||
|
public void run() {
|
||||||
try {
|
try {
|
||||||
// This has to be synchronized or it can collide with the disable method.
|
// This has to be synchronized or it can collide with the disable method.
|
||||||
synchronized (optOutLock) {
|
synchronized (optOutLock) {
|
||||||
@ -373,7 +375,7 @@ public class Metrics {
|
|||||||
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||||
String pluginVersion = description.getVersion();
|
String pluginVersion = description.getVersion();
|
||||||
String serverVersion = Bukkit.getVersion();
|
String serverVersion = Bukkit.getVersion();
|
||||||
int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
|
int playersOnline = BukkitUtil.getOnlinePlayers().size();
|
||||||
|
|
||||||
// END server software specific section -- all code below does not use any code outside of this class / Java
|
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||||
|
|
||||||
|
@ -7,7 +7,13 @@
|
|||||||
// Somewhat modified by aadnk.
|
// Somewhat modified by aadnk.
|
||||||
package com.comphenix.protocol.metrics;
|
package com.comphenix.protocol.metrics;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
@ -28,7 +34,6 @@ import com.comphenix.protocol.error.Report;
|
|||||||
import com.comphenix.protocol.error.ReportType;
|
import com.comphenix.protocol.error.ReportType;
|
||||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.io.Files;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check dev.bukkit.org to find updates for a given plugin, and download the updates if needed.
|
* Check dev.bukkit.org to find updates for a given plugin, and download the updates if needed.
|
||||||
|
@ -4,16 +4,16 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.comphenix.protocol.reflect.ClassAnalyser.AsmMethod.AsmOpcodes;
|
|
||||||
import com.comphenix.protocol.reflect.compiler.EmptyClassVisitor;
|
|
||||||
import com.comphenix.protocol.reflect.compiler.EmptyMethodVisitor;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
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;
|
||||||
import net.sf.cglib.asm.Type;
|
import net.sf.cglib.asm.Type;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.reflect.ClassAnalyser.AsmMethod.AsmOpcodes;
|
||||||
|
import com.comphenix.protocol.reflect.compiler.EmptyClassVisitor;
|
||||||
|
import com.comphenix.protocol.reflect.compiler.EmptyMethodVisitor;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public class ClassAnalyser {
|
public class ClassAnalyser {
|
||||||
/**
|
/**
|
||||||
* Represents a method in ASM.
|
* Represents a method in ASM.
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
package com.comphenix.protocol.reflect.compiler;
|
package com.comphenix.protocol.reflect.compiler;
|
||||||
|
|
||||||
import net.sf.cglib.asm.*;
|
import net.sf.cglib.asm.MethodVisitor;
|
||||||
|
import net.sf.cglib.asm.Opcodes;
|
||||||
|
import net.sf.cglib.asm.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by the compiler to automatically box and unbox values.
|
* Used by the compiler to automatically box and unbox values.
|
||||||
|
@ -25,6 +25,13 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import net.sf.cglib.asm.ClassWriter;
|
||||||
|
import net.sf.cglib.asm.FieldVisitor;
|
||||||
|
import net.sf.cglib.asm.Label;
|
||||||
|
import net.sf.cglib.asm.MethodVisitor;
|
||||||
|
import net.sf.cglib.asm.Opcodes;
|
||||||
|
import net.sf.cglib.asm.Type;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.error.Report;
|
import com.comphenix.protocol.error.Report;
|
||||||
import com.comphenix.protocol.error.ReportType;
|
import com.comphenix.protocol.error.ReportType;
|
||||||
@ -32,8 +39,6 @@ import com.comphenix.protocol.reflect.StructureModifier;
|
|||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.primitives.Primitives;
|
import com.google.common.primitives.Primitives;
|
||||||
|
|
||||||
import net.sf.cglib.asm.*;
|
|
||||||
|
|
||||||
// public class CompiledStructureModifierPacket20<TField> extends CompiledStructureModifier<TField> {
|
// public class CompiledStructureModifierPacket20<TField> extends CompiledStructureModifier<TField> {
|
||||||
//
|
//
|
||||||
// private Packet20NamedEntitySpawn typedTarget;
|
// private Packet20NamedEntitySpawn typedTarget;
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
package com.comphenix.protocol.reflect.instances;
|
package com.comphenix.protocol.reflect.instances;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import java.io.IOException;
|
|||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.timing.TimedListenerManager.ListenerType;
|
import com.comphenix.protocol.timing.TimedListenerManager.ListenerType;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.comphenix.protocol.utility;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility methods relating to Bukkit.
|
||||||
|
* @author dmulloy2
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class BukkitUtil {
|
||||||
|
|
||||||
|
private static Method getOnlinePlayers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of online {@link Player}s. This also provides backwards
|
||||||
|
* compatibility as Bukkit changed <code>getOnlinePlayers</code>.
|
||||||
|
*
|
||||||
|
* @return A list of online Players
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static List<Player> getOnlinePlayers() {
|
||||||
|
try {
|
||||||
|
if (getOnlinePlayers == null)
|
||||||
|
getOnlinePlayers = Bukkit.class.getMethod("getOnlinePlayers");
|
||||||
|
if (getOnlinePlayers.getReturnType() != Collection.class)
|
||||||
|
return Arrays.asList((Player[]) getOnlinePlayers.invoke(null));
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
}
|
||||||
|
return (List<Player>) Bukkit.getOnlinePlayers();
|
||||||
|
}
|
||||||
|
}
|
@ -12,15 +12,15 @@ 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;
|
import com.google.common.io.LimitInputStream;
|
||||||
|
|
||||||
import net.minecraft.util.io.netty.buffer.AbstractByteBuf;
|
|
||||||
import net.minecraft.util.io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.util.io.netty.buffer.ByteBufAllocator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a ByteBuf around an input stream and an output stream.
|
* Construct a ByteBuf around an input stream and an output stream.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -24,8 +24,8 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
|
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.ComparisonChain;
|
import com.google.common.collect.ComparisonChain;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
|
@ -22,6 +22,7 @@ package com.comphenix.protocol.utility;
|
|||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import com.comphenix.protocol.reflect.FieldUtils;
|
import com.comphenix.protocol.reflect.FieldUtils;
|
||||||
|
@ -7,6 +7,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -7,11 +7,8 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import javax.imageio.ImageIO;
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.util.io.netty.buffer.ByteBuf;
|
import net.minecraft.util.io.netty.buffer.ByteBuf;
|
||||||
@ -19,6 +16,10 @@ import net.minecraft.util.io.netty.buffer.Unpooled;
|
|||||||
import net.minecraft.util.io.netty.handler.codec.base64.Base64;
|
import net.minecraft.util.io.netty.handler.codec.base64.Base64;
|
||||||
import net.minecraft.util.io.netty.util.IllegalReferenceCountException;
|
import net.minecraft.util.io.netty.util.IllegalReferenceCountException;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
@ -28,6 +29,7 @@ import com.comphenix.protocol.reflect.accessors.Accessors;
|
|||||||
import com.comphenix.protocol.reflect.accessors.ConstructorAccessor;
|
import com.comphenix.protocol.reflect.accessors.ConstructorAccessor;
|
||||||
import com.comphenix.protocol.reflect.accessors.FieldAccessor;
|
import com.comphenix.protocol.reflect.accessors.FieldAccessor;
|
||||||
import com.comphenix.protocol.reflect.accessors.MethodAccessor;
|
import com.comphenix.protocol.reflect.accessors.MethodAccessor;
|
||||||
|
import com.comphenix.protocol.utility.BukkitUtil;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
@ -46,13 +48,13 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
/**
|
/**
|
||||||
* Lookup of Minecraft versions and ping version numbers.
|
* Lookup of Minecraft versions and ping version numbers.
|
||||||
*/
|
*/
|
||||||
private static ImmutableMap<MinecraftVersion, Integer> VERSION_NUMBERS =
|
private static ImmutableMap<MinecraftVersion, Integer> VERSION_NUMBERS =
|
||||||
ImmutableMap.<MinecraftVersion, Integer>builder().
|
ImmutableMap.<MinecraftVersion, Integer>builder().
|
||||||
put(MinecraftVersion.WORLD_UPDATE, 4).
|
put(MinecraftVersion.WORLD_UPDATE, 4).
|
||||||
put(MinecraftVersion.SKIN_UPDATE, 5).
|
put(MinecraftVersion.SKIN_UPDATE, 5).
|
||||||
build();
|
build();
|
||||||
private static MinecraftVersion LAST_VERSION = MinecraftVersion.SKIN_UPDATE;
|
private static MinecraftVersion LAST_VERSION = MinecraftVersion.SKIN_UPDATE;
|
||||||
|
|
||||||
// Server ping fields
|
// Server ping fields
|
||||||
private static Class<?> SERVER_PING = MinecraftReflection.getServerPingClass();
|
private static Class<?> SERVER_PING = MinecraftReflection.getServerPingClass();
|
||||||
private static ConstructorAccessor SERVER_PING_CONSTRUCTOR = Accessors.getConstructorAccessor(SERVER_PING);
|
private static ConstructorAccessor SERVER_PING_CONSTRUCTOR = Accessors.getConstructorAccessor(SERVER_PING);
|
||||||
@ -60,11 +62,11 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
private static FieldAccessor PLAYERS = Accessors.getFieldAccessor(SERVER_PING, MinecraftReflection.getServerPingPlayerSampleClass(), true);
|
private static FieldAccessor PLAYERS = Accessors.getFieldAccessor(SERVER_PING, MinecraftReflection.getServerPingPlayerSampleClass(), true);
|
||||||
private static FieldAccessor VERSION = Accessors.getFieldAccessor(SERVER_PING, MinecraftReflection.getServerPingServerDataClass(), true);
|
private static FieldAccessor VERSION = Accessors.getFieldAccessor(SERVER_PING, MinecraftReflection.getServerPingServerDataClass(), true);
|
||||||
private static FieldAccessor FAVICON = Accessors.getFieldAccessor(SERVER_PING, String.class, true);
|
private static FieldAccessor FAVICON = Accessors.getFieldAccessor(SERVER_PING, String.class, true);
|
||||||
|
|
||||||
// For converting to the underlying array
|
// For converting to the underlying array
|
||||||
private static EquivalentConverter<Iterable<? extends WrappedGameProfile>> PROFILE_CONVERT =
|
private static EquivalentConverter<Iterable<? extends WrappedGameProfile>> PROFILE_CONVERT =
|
||||||
BukkitConverters.getArrayConverter(GameProfile.class, BukkitConverters.getWrappedGameProfileConverter());
|
BukkitConverters.getArrayConverter(GameProfile.class, BukkitConverters.getWrappedGameProfileConverter());
|
||||||
|
|
||||||
// Server ping player sample fields
|
// Server ping player sample fields
|
||||||
private static Class<?> PLAYERS_CLASS = MinecraftReflection.getServerPingPlayerSampleClass();
|
private static Class<?> PLAYERS_CLASS = MinecraftReflection.getServerPingPlayerSampleClass();
|
||||||
private static ConstructorAccessor PLAYERS_CONSTRUCTOR = Accessors.getConstructorAccessor(PLAYERS_CLASS, int.class, int.class);
|
private static ConstructorAccessor PLAYERS_CONSTRUCTOR = Accessors.getConstructorAccessor(PLAYERS_CLASS, int.class, int.class);
|
||||||
@ -72,7 +74,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
private static FieldAccessor PLAYERS_PROFILES = Accessors.getFieldAccessor(PLAYERS_CLASS, GameProfile[].class, true);
|
private static FieldAccessor PLAYERS_PROFILES = Accessors.getFieldAccessor(PLAYERS_CLASS, GameProfile[].class, true);
|
||||||
private static FieldAccessor PLAYERS_MAXIMUM = PLAYERS_INTS[0];
|
private static FieldAccessor PLAYERS_MAXIMUM = PLAYERS_INTS[0];
|
||||||
private static FieldAccessor PLAYERS_ONLINE = PLAYERS_INTS[1];
|
private static FieldAccessor PLAYERS_ONLINE = PLAYERS_INTS[1];
|
||||||
|
|
||||||
// Server ping serialization
|
// Server ping serialization
|
||||||
private static Class<?> GSON_CLASS = MinecraftReflection.getMinecraftGsonClass();
|
private static Class<?> GSON_CLASS = MinecraftReflection.getMinecraftGsonClass();
|
||||||
private static MethodAccessor GSON_TO_JSON = Accessors.getMethodAccessor(GSON_CLASS, "toJson", Object.class);
|
private static MethodAccessor GSON_TO_JSON = Accessors.getMethodAccessor(GSON_CLASS, "toJson", Object.class);
|
||||||
@ -80,23 +82,23 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
private static FieldAccessor PING_GSON = Accessors.getCached(Accessors.getFieldAccessor(
|
private static FieldAccessor PING_GSON = Accessors.getCached(Accessors.getFieldAccessor(
|
||||||
PacketType.Status.Server.OUT_SERVER_INFO.getPacketClass(), GSON_CLASS, true
|
PacketType.Status.Server.OUT_SERVER_INFO.getPacketClass(), GSON_CLASS, true
|
||||||
));
|
));
|
||||||
|
|
||||||
// Server data fields
|
// Server data fields
|
||||||
private static Class<?> VERSION_CLASS = MinecraftReflection.getServerPingServerDataClass();
|
private static Class<?> VERSION_CLASS = MinecraftReflection.getServerPingServerDataClass();
|
||||||
private static ConstructorAccessor VERSION_CONSTRUCTOR = Accessors.getConstructorAccessor(VERSION_CLASS, String.class, int.class);
|
private static ConstructorAccessor VERSION_CONSTRUCTOR = Accessors.getConstructorAccessor(VERSION_CLASS, String.class, int.class);
|
||||||
private static FieldAccessor VERSION_NAME = Accessors.getFieldAccessor(VERSION_CLASS, String.class, true);
|
private static FieldAccessor VERSION_NAME = Accessors.getFieldAccessor(VERSION_CLASS, String.class, true);
|
||||||
private static FieldAccessor VERSION_PROTOCOL = Accessors.getFieldAccessor(VERSION_CLASS, int.class, true);
|
private static FieldAccessor VERSION_PROTOCOL = Accessors.getFieldAccessor(VERSION_CLASS, int.class, true);
|
||||||
|
|
||||||
// Get profile from player
|
// Get profile from player
|
||||||
private static FieldAccessor ENTITY_HUMAN_PROFILE = Accessors.getFieldAccessor(
|
private static FieldAccessor ENTITY_HUMAN_PROFILE = Accessors.getFieldAccessor(
|
||||||
MinecraftReflection.getEntityPlayerClass().getSuperclass(), GameProfile.class, true);
|
MinecraftReflection.getEntityPlayerClass().getSuperclass(), GameProfile.class, true);
|
||||||
|
|
||||||
// Inner class
|
// Inner class
|
||||||
private Object players; // may be NULL
|
private Object players; // may be NULL
|
||||||
private Object version;
|
private Object version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new server ping initialized with a zero player count, and zero maximum.
|
* Construct a new server ping initialized with a zero player count, and zero maximum.
|
||||||
* <p>
|
* <p>
|
||||||
* Note that the version string is set to 1.7.2.
|
* Note that the version string is set to 1.7.2.
|
||||||
*/
|
*/
|
||||||
@ -106,14 +108,14 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
resetPlayers();
|
resetPlayers();
|
||||||
resetVersion();
|
resetVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
private WrappedServerPing(Object handle) {
|
private WrappedServerPing(Object handle) {
|
||||||
super(MinecraftReflection.getServerPingClass());
|
super(MinecraftReflection.getServerPingClass());
|
||||||
setHandle(handle);
|
setHandle(handle);
|
||||||
this.players = PLAYERS.get(handle);
|
this.players = PLAYERS.get(handle);
|
||||||
this.version = VERSION.get(handle);
|
this.version = VERSION.get(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the player count and player maximum to the default values.
|
* Set the player count and player maximum to the default values.
|
||||||
*/
|
*/
|
||||||
@ -121,14 +123,14 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
players = PLAYERS_CONSTRUCTOR.invoke(0, 0);
|
players = PLAYERS_CONSTRUCTOR.invoke(0, 0);
|
||||||
PLAYERS.set(handle, players);
|
PLAYERS.set(handle, players);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the version string to the default state.
|
* Reset the version string to the default state.
|
||||||
*/
|
*/
|
||||||
protected void resetVersion() {
|
protected void resetVersion() {
|
||||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
||||||
MinecraftVersion minecraftVersion = LAST_VERSION;
|
MinecraftVersion minecraftVersion = LAST_VERSION;
|
||||||
|
|
||||||
// Fetch the latest known version
|
// Fetch the latest known version
|
||||||
if (manager != null) {
|
if (manager != null) {
|
||||||
minecraftVersion = manager.getMinecraftVersion();
|
minecraftVersion = manager.getMinecraftVersion();
|
||||||
@ -136,7 +138,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
version = VERSION_CONSTRUCTOR.invoke(minecraftVersion.toString(), VERSION_NUMBERS.get(minecraftVersion));
|
version = VERSION_CONSTRUCTOR.invoke(minecraftVersion.toString(), VERSION_NUMBERS.get(minecraftVersion));
|
||||||
VERSION.set(handle, version);
|
VERSION.set(handle, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a wrapped server ping from a native NMS object.
|
* Construct a wrapped server ping from a native NMS object.
|
||||||
* @param handle - the native object.
|
* @param handle - the native object.
|
||||||
@ -145,7 +147,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public static WrappedServerPing fromHandle(Object handle) {
|
public static WrappedServerPing fromHandle(Object handle) {
|
||||||
return new WrappedServerPing(handle);
|
return new WrappedServerPing(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a wrapper server ping from an encoded JSON string.
|
* Construct a wrapper server ping from an encoded JSON string.
|
||||||
* @param json - the JSON string.
|
* @param json - the JSON string.
|
||||||
@ -154,7 +156,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public static WrappedServerPing fromJson(String json) {
|
public static WrappedServerPing fromJson(String json) {
|
||||||
return fromHandle(GSON_FROM_JSON.invoke(PING_GSON.get(null), json, SERVER_PING));
|
return fromHandle(GSON_FROM_JSON.invoke(PING_GSON.get(null), json, SERVER_PING));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the message of the day.
|
* Retrieve the message of the day.
|
||||||
* @return The messge of the day.
|
* @return The messge of the day.
|
||||||
@ -162,7 +164,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public WrappedChatComponent getMotD() {
|
public WrappedChatComponent getMotD() {
|
||||||
return WrappedChatComponent.fromHandle(DESCRIPTION.get(handle));
|
return WrappedChatComponent.fromHandle(DESCRIPTION.get(handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the message of the day.
|
* Set the message of the day.
|
||||||
* @param description - message of the day.
|
* @param description - message of the day.
|
||||||
@ -178,7 +180,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public void setMotD(String message) {
|
public void setMotD(String message) {
|
||||||
setMotD(WrappedChatComponent.fromText(message));
|
setMotD(WrappedChatComponent.fromText(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the compressed PNG file that is being displayed as a favicon.
|
* Retrieve the compressed PNG file that is being displayed as a favicon.
|
||||||
* @return The favicon, or NULL if no favicon will be displayed.
|
* @return The favicon, or NULL if no favicon will be displayed.
|
||||||
@ -187,7 +189,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
String favicon = (String) FAVICON.get(handle);
|
String favicon = (String) FAVICON.get(handle);
|
||||||
return (favicon != null) ? CompressedImage.fromEncodedText(favicon) : null;
|
return (favicon != null) ? CompressedImage.fromEncodedText(favicon) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the compressed PNG file that is being displayed.
|
* Set the compressed PNG file that is being displayed.
|
||||||
* @param image - the new compressed image or NULL if no favicon should be displayed.
|
* @param image - the new compressed image or NULL if no favicon should be displayed.
|
||||||
@ -195,7 +197,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public void setFavicon(CompressedImage image) {
|
public void setFavicon(CompressedImage image) {
|
||||||
FAVICON.set(handle, (image != null) ? image.toEncodedText() : null);
|
FAVICON.set(handle, (image != null) ? image.toEncodedText() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the displayed number of online players.
|
* Retrieve the displayed number of online players.
|
||||||
* @see {@link #setPlayersOnline(int)} for more information.
|
* @see {@link #setPlayersOnline(int)} for more information.
|
||||||
@ -207,11 +209,11 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
throw new IllegalStateException("The player count has been hidden.");
|
throw new IllegalStateException("The player count has been hidden.");
|
||||||
return (Integer) PLAYERS_ONLINE.get(players);
|
return (Integer) PLAYERS_ONLINE.get(players);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the displayed number of online players.
|
* Set the displayed number of online players.
|
||||||
* <p>
|
* <p>
|
||||||
* As of 1.7.2, this is completely unrestricted, and can be both positive and
|
* As of 1.7.2, this is completely unrestricted, and can be both positive and
|
||||||
* negative, as well as higher than the player maximum.
|
* negative, as well as higher than the player maximum.
|
||||||
* @param online - online players.
|
* @param online - online players.
|
||||||
*/
|
*/
|
||||||
@ -220,7 +222,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
resetPlayers();
|
resetPlayers();
|
||||||
PLAYERS_ONLINE.set(players, online);
|
PLAYERS_ONLINE.set(players, online);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the displayed maximum number of players.
|
* Retrieve the displayed maximum number of players.
|
||||||
* @see {@link #setPlayersMaximum(int)} for more information.
|
* @see {@link #setPlayersMaximum(int)} for more information.
|
||||||
@ -232,7 +234,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
throw new IllegalStateException("The player maximum has been hidden.");
|
throw new IllegalStateException("The player maximum has been hidden.");
|
||||||
return (Integer) PLAYERS_MAXIMUM.get(players);
|
return (Integer) PLAYERS_MAXIMUM.get(players);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the displayed maximum number of players.
|
* Set the displayed maximum number of players.
|
||||||
* <p>
|
* <p>
|
||||||
@ -245,7 +247,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
resetPlayers();
|
resetPlayers();
|
||||||
PLAYERS_MAXIMUM.set(players, maximum);
|
PLAYERS_MAXIMUM.set(players, maximum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether or not the player count and player maximum is visible.
|
* Set whether or not the player count and player maximum is visible.
|
||||||
* <p>
|
* <p>
|
||||||
@ -258,13 +260,13 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
// Recreate the count and maximum
|
// Recreate the count and maximum
|
||||||
Server server = Bukkit.getServer();
|
Server server = Bukkit.getServer();
|
||||||
setPlayersMaximum(server.getMaxPlayers());
|
setPlayersMaximum(server.getMaxPlayers());
|
||||||
setPlayersOnline(server.getOnlinePlayers().length);
|
setPlayersOnline(BukkitUtil.getOnlinePlayers().size());
|
||||||
} else {
|
} else {
|
||||||
PLAYERS.set(handle, players = null);
|
PLAYERS.set(handle, players = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the player count and maximum is visible.
|
* Determine if the player count and maximum is visible.
|
||||||
* <p>
|
* <p>
|
||||||
@ -274,7 +276,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public boolean isPlayersVisible() {
|
public boolean isPlayersVisible() {
|
||||||
return players != null;
|
return players != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a copy of all the logged in players.
|
* Retrieve a copy of all the logged in players.
|
||||||
* @return Logged in players or an empty list if no player names will be displayed.
|
* @return Logged in players or an empty list if no player names will be displayed.
|
||||||
@ -287,7 +289,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
return ImmutableList.copyOf(PROFILE_CONVERT.getSpecific(playerProfiles));
|
return ImmutableList.copyOf(PROFILE_CONVERT.getSpecific(playerProfiles));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the displayed list of logged in players.
|
* Set the displayed list of logged in players.
|
||||||
* @param profile - every logged in player.
|
* @param profile - every logged in player.
|
||||||
@ -297,21 +299,21 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
resetPlayers();
|
resetPlayers();
|
||||||
PLAYERS_PROFILES.set(players, (profile != null) ? PROFILE_CONVERT.getGeneric(GameProfile[].class, profile) : null);
|
PLAYERS_PROFILES.set(players, (profile != null) ? PROFILE_CONVERT.getGeneric(GameProfile[].class, profile) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the displayed lst of logged in players.
|
* Set the displayed lst of logged in players.
|
||||||
* @param players - the players to display.
|
* @param players - the players to display.
|
||||||
*/
|
*/
|
||||||
public void setBukkitPlayers(Iterable<? extends Player> players) {
|
public void setBukkitPlayers(Iterable<? extends Player> players) {
|
||||||
List<WrappedGameProfile> profiles = Lists.newArrayList();
|
List<WrappedGameProfile> profiles = Lists.newArrayList();
|
||||||
|
|
||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
GameProfile profile = (GameProfile) ENTITY_HUMAN_PROFILE.get(BukkitUnwrapper.getInstance().unwrapItem(player));
|
GameProfile profile = (GameProfile) ENTITY_HUMAN_PROFILE.get(BukkitUnwrapper.getInstance().unwrapItem(player));
|
||||||
profiles.add(WrappedGameProfile.fromHandle(profile));
|
profiles.add(WrappedGameProfile.fromHandle(profile));
|
||||||
}
|
}
|
||||||
setPlayers(profiles);
|
setPlayers(profiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the version name of the current server.
|
* Retrieve the version name of the current server.
|
||||||
* @return The version name.
|
* @return The version name.
|
||||||
@ -319,7 +321,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public String getVersionName() {
|
public String getVersionName() {
|
||||||
return (String) VERSION_NAME.get(version);
|
return (String) VERSION_NAME.get(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the version name of the current server.
|
* Set the version name of the current server.
|
||||||
* @param name - the new version name.
|
* @param name - the new version name.
|
||||||
@ -327,7 +329,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public void setVersionName(String name) {
|
public void setVersionName(String name) {
|
||||||
VERSION_NAME.set(version, name);
|
VERSION_NAME.set(version, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the protocol number.
|
* Retrieve the protocol number.
|
||||||
* @return The protocol.
|
* @return The protocol.
|
||||||
@ -335,7 +337,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public int getVersionProtocol() {
|
public int getVersionProtocol() {
|
||||||
return (Integer) VERSION_PROTOCOL.get(version);
|
return (Integer) VERSION_PROTOCOL.get(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the version protocol
|
* Set the version protocol
|
||||||
* @param protocol - the protocol number.
|
* @param protocol - the protocol number.
|
||||||
@ -343,7 +345,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public void setVersionProtocol(int protocol) {
|
public void setVersionProtocol(int protocol) {
|
||||||
VERSION_PROTOCOL.set(version, protocol);
|
VERSION_PROTOCOL.set(version, protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a deep copy of the current wrapper object.
|
* Retrieve a deep copy of the current wrapper object.
|
||||||
* @return The current object.
|
* @return The current object.
|
||||||
@ -351,13 +353,13 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public WrappedServerPing deepClone() {
|
public WrappedServerPing deepClone() {
|
||||||
WrappedServerPing copy = new WrappedServerPing();
|
WrappedServerPing copy = new WrappedServerPing();
|
||||||
WrappedChatComponent motd = getMotD();
|
WrappedChatComponent motd = getMotD();
|
||||||
|
|
||||||
copy.setPlayers(getPlayers());
|
copy.setPlayers(getPlayers());
|
||||||
copy.setFavicon(getFavicon());
|
copy.setFavicon(getFavicon());
|
||||||
copy.setMotD(motd != null ? motd.deepClone() : null);
|
copy.setMotD(motd != null ? motd.deepClone() : null);
|
||||||
copy.setVersionName(getVersionName());
|
copy.setVersionName(getVersionName());
|
||||||
copy.setVersionProtocol(getVersionProtocol());
|
copy.setVersionProtocol(getVersionProtocol());
|
||||||
|
|
||||||
if (isPlayersVisible()) {
|
if (isPlayersVisible()) {
|
||||||
copy.setPlayersMaximum(getPlayersMaximum());
|
copy.setPlayersMaximum(getPlayersMaximum());
|
||||||
copy.setPlayersOnline(getPlayersOnline());
|
copy.setPlayersOnline(getPlayersOnline());
|
||||||
@ -366,7 +368,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
}
|
}
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the underlying JSON representation of this server ping.
|
* Retrieve the underlying JSON representation of this server ping.
|
||||||
* @return The JSON representation.
|
* @return The JSON representation.
|
||||||
@ -374,12 +376,12 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public String toJson() {
|
public String toJson() {
|
||||||
return (String) GSON_TO_JSON.invoke(PING_GSON.get(null), handle);
|
return (String) GSON_TO_JSON.invoke(PING_GSON.get(null), handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "WrappedServerPing< " + toJson() + ">";
|
return "WrappedServerPing< " + toJson() + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a compressed favicon.
|
* Represents a compressed favicon.
|
||||||
* @author Kristian
|
* @author Kristian
|
||||||
@ -389,14 +391,14 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
protected volatile String mime;
|
protected volatile String mime;
|
||||||
protected volatile byte[] data;
|
protected volatile byte[] data;
|
||||||
protected volatile String encoded;
|
protected volatile String encoded;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a compressed image with no content.
|
* Represents a compressed image with no content.
|
||||||
*/
|
*/
|
||||||
protected CompressedImage() {
|
protected CompressedImage() {
|
||||||
// Derived class should initialize some of the fields
|
// Derived class should initialize some of the fields
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new compressed image.
|
* Construct a new compressed image.
|
||||||
* @param mime - the mime type.
|
* @param mime - the mime type.
|
||||||
@ -416,7 +418,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public static CompressedImage fromPng(InputStream input) throws IOException {
|
public static CompressedImage fromPng(InputStream input) throws IOException {
|
||||||
return new CompressedImage("image/png", ByteStreams.toByteArray(input));
|
return new CompressedImage("image/png", ByteStreams.toByteArray(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a compressed image from a byte array of a PNG file.
|
* Retrieve a compressed image from a byte array of a PNG file.
|
||||||
* @param data - the file as a byte array.
|
* @param data - the file as a byte array.
|
||||||
@ -425,7 +427,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public static CompressedImage fromPng(byte[] data) {
|
public static CompressedImage fromPng(byte[] data) {
|
||||||
return new CompressedImage("image/png", data);
|
return new CompressedImage("image/png", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a compressed image from a base-64 encoded PNG file.
|
* Retrieve a compressed image from a base-64 encoded PNG file.
|
||||||
* @param base64 - the base 64-encoded PNG.
|
* @param base64 - the base 64-encoded PNG.
|
||||||
@ -439,7 +441,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
throw new IllegalReferenceCountException("Must be a pure base64 encoded string. Cannot be an encoded text.", e);
|
throw new IllegalReferenceCountException("Must be a pure base64 encoded string. Cannot be an encoded text.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a compressed image from an image.
|
* Retrieve a compressed image from an image.
|
||||||
* @param image - the image.
|
* @param image - the image.
|
||||||
@ -450,7 +452,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
ImageIO.write(image, "png", output);
|
ImageIO.write(image, "png", output);
|
||||||
return new CompressedImage("image/png", output.toByteArray());
|
return new CompressedImage("image/png", output.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a compressed image from an encoded text.
|
* Retrieve a compressed image from an encoded text.
|
||||||
* @param text - the encoded text.
|
* @param text - the encoded text.
|
||||||
@ -459,17 +461,17 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public static CompressedImage fromEncodedText(String text) {
|
public static CompressedImage fromEncodedText(String text) {
|
||||||
return new EncodedCompressedImage(text);
|
return new EncodedCompressedImage(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the MIME type of the image.
|
* Retrieve the MIME type of the image.
|
||||||
* <p>
|
* <p>
|
||||||
* This is image/png in vanilla Minecraft.
|
* This is image/png in vanilla Minecraft.
|
||||||
* @return The MIME type.
|
* @return The MIME type.
|
||||||
*/
|
*/
|
||||||
public String getMime() {
|
public String getMime() {
|
||||||
return mime;
|
return mime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a copy of the underlying data array.
|
* Retrieve a copy of the underlying data array.
|
||||||
* @return The underlying compressed image.
|
* @return The underlying compressed image.
|
||||||
@ -477,7 +479,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public byte[] getDataCopy() {
|
public byte[] getDataCopy() {
|
||||||
return getData().clone();
|
return getData().clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the underlying data, with no copying.
|
* Retrieve the underlying data, with no copying.
|
||||||
* @return The underlying data.
|
* @return The underlying data.
|
||||||
@ -485,7 +487,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
protected byte[] getData() {
|
protected byte[] getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uncompress and return the stored image.
|
* Uncompress and return the stored image.
|
||||||
* @return The image.
|
* @return The image.
|
||||||
@ -494,7 +496,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public BufferedImage getImage() throws IOException {
|
public BufferedImage getImage() throws IOException {
|
||||||
return ImageIO.read(new ByteArrayInputStream(getData()));
|
return ImageIO.read(new ByteArrayInputStream(getData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the compressed image to encoded text.
|
* Convert the compressed image to encoded text.
|
||||||
* @return The encoded text.
|
* @return The encoded text.
|
||||||
@ -502,15 +504,15 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public String toEncodedText() {
|
public String toEncodedText() {
|
||||||
if (encoded == null) {
|
if (encoded == null) {
|
||||||
final ByteBuf buffer = Unpooled.wrappedBuffer(getData());
|
final ByteBuf buffer = Unpooled.wrappedBuffer(getData());
|
||||||
String computed = "data:" + mime + ";base64," +
|
String computed = "data:" + mime + ";base64," +
|
||||||
Base64.encode(buffer).toString(Charsets.UTF_8);
|
Base64.encode(buffer).toString(Charsets.UTF_8);
|
||||||
|
|
||||||
encoded = computed;
|
encoded = computed;
|
||||||
}
|
}
|
||||||
return encoded;
|
return encoded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a compressed image that starts out as an encoded base 64 string.
|
* Represents a compressed image that starts out as an encoded base 64 string.
|
||||||
* @author Kristian
|
* @author Kristian
|
||||||
@ -519,7 +521,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
public EncodedCompressedImage(String encoded) {
|
public EncodedCompressedImage(String encoded) {
|
||||||
this.encoded = Preconditions.checkNotNull(encoded, "encoded favicon cannot be NULL");
|
this.encoded = Preconditions.checkNotNull(encoded, "encoded favicon cannot be NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure that we have decoded the content of the encoded text.
|
* Ensure that we have decoded the content of the encoded text.
|
||||||
*/
|
*/
|
||||||
@ -528,7 +530,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
decode();
|
decode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode the encoded text.
|
* Decode the encoded text.
|
||||||
*/
|
*/
|
||||||
@ -539,7 +541,7 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
} else if (segment.startsWith("base64,")) {
|
} else if (segment.startsWith("base64,")) {
|
||||||
byte[] encoded = segment.substring(7).getBytes(Charsets.UTF_8);
|
byte[] encoded = segment.substring(7).getBytes(Charsets.UTF_8);
|
||||||
ByteBuf decoded = Base64.decode(Unpooled.wrappedBuffer(encoded));
|
ByteBuf decoded = Base64.decode(Unpooled.wrappedBuffer(encoded));
|
||||||
|
|
||||||
// Read into a byte array
|
// Read into a byte array
|
||||||
byte[] data = new byte[decoded.readableBytes()];
|
byte[] data = new byte[decoded.readableBytes()];
|
||||||
decoded.readBytes(data);
|
decoded.readBytes(data);
|
||||||
@ -549,19 +551,19 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected byte[] getData() {
|
protected byte[] getData() {
|
||||||
initialize();
|
initialize();
|
||||||
return super.getData();
|
return super.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMime() {
|
public String getMime() {
|
||||||
initialize();
|
initialize();
|
||||||
return super.getMime();
|
return super.getMime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toEncodedText() {
|
public String toEncodedText() {
|
||||||
return encoded;
|
return encoded;
|
||||||
|
@ -3,6 +3,7 @@ package com.comphenix.protocol.wrappers;
|
|||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
|
|
||||||
import net.minecraft.util.com.mojang.authlib.properties.Property;
|
import net.minecraft.util.com.mojang.authlib.properties.Property;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
package com.comphenix.protocol.wrappers.nbt;
|
package com.comphenix.protocol.wrappers.nbt;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a generic container for an NBT element.
|
* Represents a generic container for an NBT element.
|
||||||
|
@ -4,8 +4,6 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R3.NBTTagCompound;
|
|
||||||
import net.minecraft.server.v1_7_R3.TileEntityChest;
|
|
||||||
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;
|
||||||
@ -34,24 +32,24 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
* Token indicating that the given block state doesn't contany any tile entities.
|
* Token indicating that the given block state doesn't contany any tile entities.
|
||||||
*/
|
*/
|
||||||
private static final TileEntityAccessor<BlockState> EMPTY_ACCESSOR = new TileEntityAccessor<BlockState>();
|
private static final TileEntityAccessor<BlockState> EMPTY_ACCESSOR = new TileEntityAccessor<BlockState>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached field accessors - {@link #EMPTY_ACCESSOR} represents no valid tile entity.
|
* Cached field accessors - {@link #EMPTY_ACCESSOR} represents no valid tile entity.
|
||||||
*/
|
*/
|
||||||
private static final ConcurrentMap<Class<?>, TileEntityAccessor<?>> cachedAccessors = Maps.newConcurrentMap();
|
private static final ConcurrentMap<Class<?>, TileEntityAccessor<?>> cachedAccessors = Maps.newConcurrentMap();
|
||||||
|
|
||||||
private FieldAccessor tileEntityField;
|
private FieldAccessor tileEntityField;
|
||||||
private MethodAccessor readCompound;
|
private MethodAccessor readCompound;
|
||||||
private MethodAccessor writeCompound;
|
private MethodAccessor writeCompound;
|
||||||
|
|
||||||
// For CGLib detection
|
// For CGLib detection
|
||||||
private boolean writeDetected;
|
private boolean writeDetected;
|
||||||
private boolean readDetected;
|
private boolean readDetected;
|
||||||
|
|
||||||
private TileEntityAccessor() {
|
private TileEntityAccessor() {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new tile entity accessor.
|
* Construct a new tile entity accessor.
|
||||||
* @param tileEntityField - the tile entity field.
|
* @param tileEntityField - the tile entity field.
|
||||||
@ -63,7 +61,7 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
if (tileEntityField != null) {
|
if (tileEntityField != null) {
|
||||||
this.tileEntityField = tileEntityField;
|
this.tileEntityField = tileEntityField;
|
||||||
Class<?> type = tileEntityField.getField().getType();
|
Class<?> type = tileEntityField.getField().getType();
|
||||||
|
|
||||||
// Possible read/write methods
|
// Possible read/write methods
|
||||||
try {
|
try {
|
||||||
findMethodsUsingASM(type);
|
findMethodsUsingASM(type);
|
||||||
@ -75,7 +73,7 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
throw new RuntimeException("Cannot find read/write methods in " + type, ex2);
|
throw new RuntimeException("Cannot find read/write methods in " + type, ex2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure we found them
|
// Ensure we found them
|
||||||
if (readCompound == null)
|
if (readCompound == null)
|
||||||
throw new RuntimeException("Unable to find read method in " + type);
|
throw new RuntimeException("Unable to find read method in " + type);
|
||||||
@ -93,36 +91,37 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
private void findMethodsUsingASM(final Class<?> tileEntityClass) throws IOException {
|
private void findMethodsUsingASM(final Class<?> tileEntityClass) throws IOException {
|
||||||
final Class<?> nbtCompoundClass = MinecraftReflection.getNBTCompoundClass();
|
final Class<?> nbtCompoundClass = MinecraftReflection.getNBTCompoundClass();
|
||||||
final ClassReader reader = new ClassReader(tileEntityClass.getCanonicalName());
|
final ClassReader reader = new ClassReader(tileEntityClass.getCanonicalName());
|
||||||
|
|
||||||
final String tagCompoundName = getJarName(MinecraftReflection.getNBTCompoundClass());
|
final String tagCompoundName = getJarName(MinecraftReflection.getNBTCompoundClass());
|
||||||
final String expectedDesc = "(L" + tagCompoundName + ";)V";
|
final String expectedDesc = "(L" + tagCompoundName + ";)V";
|
||||||
|
|
||||||
reader.accept(new EmptyClassVisitor() {
|
reader.accept(new EmptyClassVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||||
final String methodName = name;
|
final String methodName = name;
|
||||||
|
|
||||||
// Detect read/write calls to NBTTagCompound
|
// Detect read/write calls to NBTTagCompound
|
||||||
if (expectedDesc.equals(desc)) {
|
if (expectedDesc.equals(desc)) {
|
||||||
return new EmptyMethodVisitor() {
|
return new EmptyMethodVisitor() {
|
||||||
private int readMethods;
|
private int readMethods;
|
||||||
private int writeMethods;
|
private int writeMethods;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
|
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
|
||||||
// This must be a virtual call on NBTTagCompound that accepts a String
|
// This must be a virtual call on NBTTagCompound that accepts a String
|
||||||
if (opcode == Opcodes.INVOKEVIRTUAL &&
|
if (opcode == Opcodes.INVOKEVIRTUAL &&
|
||||||
tagCompoundName.equals(owner) &&
|
tagCompoundName.equals(owner) &&
|
||||||
desc.startsWith("(Ljava/lang/String")) {
|
desc.startsWith("(Ljava/lang/String")) {
|
||||||
|
|
||||||
// Is this a write call?
|
// Is this a write call?
|
||||||
if (desc.endsWith(")V")) {
|
if (desc.endsWith(")V")) {
|
||||||
writeMethods++;
|
writeMethods++;
|
||||||
} else {
|
} else {
|
||||||
readMethods++;
|
readMethods++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitEnd() {
|
public void visitEnd() {
|
||||||
if (readMethods > writeMethods) {
|
if (readMethods > writeMethods) {
|
||||||
@ -138,7 +137,7 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the read/write methods in TileEntity.
|
* Find the read/write methods in TileEntity.
|
||||||
* @param blockState - the block state.
|
* @param blockState - the block state.
|
||||||
@ -146,7 +145,7 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
*/
|
*/
|
||||||
private void findMethodUsingCGLib(T blockState) throws IOException {
|
private void findMethodUsingCGLib(T blockState) throws IOException {
|
||||||
final Class<?> nbtCompoundClass = MinecraftReflection.getNBTCompoundClass();
|
final Class<?> nbtCompoundClass = MinecraftReflection.getNBTCompoundClass();
|
||||||
|
|
||||||
// This is a much slower method, but it is necessary in MCPC
|
// This is a much slower method, but it is necessary in MCPC
|
||||||
Enhancer enhancer = EnhancerFactory.getInstance().createEnhancer();
|
Enhancer enhancer = EnhancerFactory.getInstance().createEnhancer();
|
||||||
enhancer.setSuperclass(nbtCompoundClass);
|
enhancer.setSuperclass(nbtCompoundClass);
|
||||||
@ -165,11 +164,11 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
});
|
});
|
||||||
Object compound = enhancer.create();
|
Object compound = enhancer.create();
|
||||||
Object tileEntity = tileEntityField.get(blockState);
|
Object tileEntity = tileEntityField.get(blockState);
|
||||||
|
|
||||||
// Look in every read/write like method
|
// Look in every read/write like method
|
||||||
for (Method method : FuzzyReflection.fromObject(tileEntity, true).
|
for (Method method : FuzzyReflection.fromObject(tileEntity, true).
|
||||||
getMethodListByParameters(Void.TYPE, new Class<?>[] { nbtCompoundClass })) {
|
getMethodListByParameters(Void.TYPE, new Class<?>[] { nbtCompoundClass })) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
readDetected = false;
|
readDetected = false;
|
||||||
writeDetected = false;
|
writeDetected = false;
|
||||||
@ -183,7 +182,7 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the JAR name (slash instead of dots) of the given clas.
|
* Retrieve the JAR name (slash instead of dots) of the given clas.
|
||||||
* @param clazz - the class.
|
* @param clazz - the class.
|
||||||
@ -192,7 +191,7 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
private static String getJarName(Class<?> clazz) {
|
private static String getJarName(Class<?> clazz) {
|
||||||
return clazz.getCanonicalName().replace('.', '/');
|
return clazz.getCanonicalName().replace('.', '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the NBT compound that represents a given tile entity.
|
* Read the NBT compound that represents a given tile entity.
|
||||||
* @param state - tile entity represented by a block state.
|
* @param state - tile entity represented by a block state.
|
||||||
@ -201,12 +200,12 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
public NbtCompound readBlockState(T state) {
|
public NbtCompound readBlockState(T state) {
|
||||||
NbtCompound output = NbtFactory.ofCompound("");
|
NbtCompound output = NbtFactory.ofCompound("");
|
||||||
Object tileEntity = tileEntityField.get(state);
|
Object tileEntity = tileEntityField.get(state);
|
||||||
|
|
||||||
// Write the block state to the output compound
|
// Write the block state to the output compound
|
||||||
writeCompound.invoke(tileEntity, NbtFactory.fromBase(output).getHandle());
|
writeCompound.invoke(tileEntity, NbtFactory.fromBase(output).getHandle());
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the NBT compound as a tile entity.
|
* Write the NBT compound as a tile entity.
|
||||||
* @param state - target block state.
|
* @param state - target block state.
|
||||||
@ -214,11 +213,11 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
*/
|
*/
|
||||||
public void writeBlockState(T state, NbtCompound compound) {
|
public void writeBlockState(T state, NbtCompound compound) {
|
||||||
Object tileEntity = tileEntityField.get(state);
|
Object tileEntity = tileEntityField.get(state);
|
||||||
|
|
||||||
// Ensure the block state is set to the compound
|
// Ensure the block state is set to the compound
|
||||||
readCompound.invoke(tileEntity, NbtFactory.fromBase(compound).getHandle());
|
readCompound.invoke(tileEntity, NbtFactory.fromBase(compound).getHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve an accessor for the tile entity at a specific location.
|
* Retrieve an accessor for the tile entity at a specific location.
|
||||||
* @param state - the block state.
|
* @param state - the block state.
|
||||||
@ -228,22 +227,22 @@ class TileEntityAccessor<T extends BlockState> {
|
|||||||
public static <T extends BlockState> TileEntityAccessor<T> getAccessor(T state) {
|
public static <T extends BlockState> TileEntityAccessor<T> getAccessor(T state) {
|
||||||
Class<?> craftBlockState = state.getClass();
|
Class<?> craftBlockState = state.getClass();
|
||||||
TileEntityAccessor<?> accessor = cachedAccessors.get(craftBlockState);
|
TileEntityAccessor<?> accessor = cachedAccessors.get(craftBlockState);
|
||||||
|
|
||||||
// Attempt to construct the accessor
|
// Attempt to construct the accessor
|
||||||
if (accessor == null ) {
|
if (accessor == null ) {
|
||||||
TileEntityAccessor<?> created = null;
|
TileEntityAccessor<?> created = null;
|
||||||
FieldAccessor field = null;
|
FieldAccessor field = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
field = Accessors.getFieldAccessor(craftBlockState, MinecraftReflection.getTileEntityClass(), true);
|
field = Accessors.getFieldAccessor(craftBlockState, MinecraftReflection.getTileEntityClass(), true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
created = EMPTY_ACCESSOR;
|
created = EMPTY_ACCESSOR;
|
||||||
}
|
}
|
||||||
if (field != null) {
|
if (field != null) {
|
||||||
created = new TileEntityAccessor<T>(field, state);
|
created = new TileEntityAccessor<T>(field, state);
|
||||||
}
|
}
|
||||||
accessor = cachedAccessors.putIfAbsent(craftBlockState, created);
|
accessor = cachedAccessors.putIfAbsent(craftBlockState, created);
|
||||||
|
|
||||||
// We won the race
|
// We won the race
|
||||||
if (accessor == null) {
|
if (accessor == null) {
|
||||||
accessor = created;
|
accessor = created;
|
||||||
|
@ -8,6 +8,7 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
|
@ -3,30 +3,29 @@ 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_7_R3.Block;
|
import net.minecraft.server.v1_7_R4.Item;
|
||||||
import net.minecraft.server.v1_7_R3.Item;
|
import net.minecraft.server.v1_7_R4.StatisticList;
|
||||||
import net.minecraft.server.v1_7_R3.StatisticList;
|
|
||||||
|
|
||||||
// Will have to be updated for every version though
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemFactory;
|
|
||||||
|
|
||||||
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.inventory.ItemFactory;
|
import org.bukkit.inventory.ItemFactory;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import com.comphenix.protocol.reflect.FieldUtils;
|
import com.comphenix.protocol.reflect.FieldUtils;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
|
// Will have to be updated for every version though
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to ensure that ProtocolLib and Bukkit is prepared to be tested.
|
* Used to ensure that ProtocolLib and Bukkit is prepared to be tested.
|
||||||
*
|
*
|
||||||
* @author Kristian
|
* @author Kristian
|
||||||
*/
|
*/
|
||||||
public class BukkitInitialization {
|
public class BukkitInitialization {
|
||||||
private static boolean initialized;
|
private static boolean initialized;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize Bukkit and ProtocolLib such that we can perfrom unit testing.
|
* Initialize Bukkit and ProtocolLib such that we can perfrom unit testing.
|
||||||
* @throws IllegalAccessException If we are unable to initialize Bukkit.
|
* @throws IllegalAccessException If we are unable to initialize Bukkit.
|
||||||
@ -35,9 +34,9 @@ public class BukkitInitialization {
|
|||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
// Denote that we're done
|
// Denote that we're done
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
initializePackage();
|
initializePackage();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Block.p();
|
Block.p();
|
||||||
Item.l();
|
Item.l();
|
||||||
@ -46,24 +45,24 @@ public class BukkitInitialization {
|
|||||||
// Swallow
|
// Swallow
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mock the server object
|
// Mock the server object
|
||||||
Server mockedServer = mock(Server.class);
|
Server mockedServer = mock(Server.class);
|
||||||
ItemFactory mockedFactory = mock(CraftItemFactory.class);
|
ItemFactory mockedFactory = mock(CraftItemFactory.class);
|
||||||
ItemMeta mockedMeta = mock(ItemMeta.class);
|
ItemMeta mockedMeta = mock(ItemMeta.class);
|
||||||
|
|
||||||
when(mockedServer.getItemFactory()).thenReturn(mockedFactory);
|
when(mockedServer.getItemFactory()).thenReturn(mockedFactory);
|
||||||
when(mockedServer.isPrimaryThread()).thenReturn(true);
|
when(mockedServer.isPrimaryThread()).thenReturn(true);
|
||||||
when(mockedFactory.getItemMeta(any(Material.class))).thenReturn(mockedMeta);
|
when(mockedFactory.getItemMeta(any(Material.class))).thenReturn(mockedMeta);
|
||||||
|
|
||||||
// Inject this fake server
|
// Inject this fake server
|
||||||
FieldUtils.writeStaticField(Bukkit.class, "server", mockedServer, true);
|
FieldUtils.writeStaticField(Bukkit.class, "server", mockedServer, true);
|
||||||
|
|
||||||
// And the fake item factory
|
// And the fake item factory
|
||||||
FieldUtils.writeStaticField(CraftItemFactory.class, "instance", mockedFactory, true);
|
FieldUtils.writeStaticField(CraftItemFactory.class, "instance", mockedFactory, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure that package names are correctly set up.
|
* Ensure that package names are correctly set up.
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
package com.comphenix.protocol;
|
package com.comphenix.protocol;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.comphenix.protocol;
|
package com.comphenix.protocol;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package com.comphenix.protocol.concurrency;
|
package com.comphenix.protocol.concurrency;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -2,39 +2,43 @@
|
|||||||
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
|
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
|
||||||
* Copyright (C) 2012 Kristian S. Stangeland
|
* Copyright (C) 2012 Kristian S. Stangeland
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
* 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
|
* GNU General Public License as published by the Free Software Foundation; either version 2 of
|
||||||
* the License, or (at your option) any later version.
|
* 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;
|
* 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.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* 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;
|
* 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
|
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
* 02111-1307 USA
|
* 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.comphenix.protocol.events;
|
package com.comphenix.protocol.events;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R3.AttributeModifier;
|
import net.minecraft.server.v1_7_R4.AttributeModifier;
|
||||||
import net.minecraft.server.v1_7_R3.AttributeSnapshot;
|
import net.minecraft.server.v1_7_R4.AttributeSnapshot;
|
||||||
import net.minecraft.server.v1_7_R3.PacketPlayOutUpdateAttributes;
|
import net.minecraft.server.v1_7_R4.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;
|
||||||
import org.apache.commons.lang.builder.ToStringStyle;
|
import org.apache.commons.lang.builder.ToStringStyle;
|
||||||
// Will have to be updated for every version though
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemFactory;
|
|
||||||
|
|
||||||
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.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;
|
||||||
@ -59,8 +63,8 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
// Will have to be updated for every version though
|
||||||
|
|
||||||
// Ensure that the CraftItemFactory is mockable
|
// Ensure that the CraftItemFactory is mockable
|
||||||
@RunWith(org.powermock.modules.junit4.PowerMockRunner.class)
|
@RunWith(org.powermock.modules.junit4.PowerMockRunner.class)
|
||||||
@ -70,12 +74,12 @@ public class PacketContainerTest {
|
|||||||
// Helper converters
|
// Helper converters
|
||||||
private EquivalentConverter<WrappedDataWatcher> watchConvert = BukkitConverters.getDataWatcherConverter();
|
private EquivalentConverter<WrappedDataWatcher> watchConvert = BukkitConverters.getDataWatcherConverter();
|
||||||
private EquivalentConverter<ItemStack> itemConvert = BukkitConverters.getItemStackConverter();
|
private EquivalentConverter<ItemStack> itemConvert = BukkitConverters.getItemStackConverter();
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initializeBukkit() throws IllegalAccessException {
|
public static void initializeBukkit() throws IllegalAccessException {
|
||||||
BukkitInitialization.initializeItemMeta();
|
BukkitInitialization.initializeItemMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void testPrimitive(StructureModifier<T> modifier, int index, T initialValue, T testValue) {
|
private <T> void testPrimitive(StructureModifier<T> modifier, int index, T initialValue, T testValue) {
|
||||||
// Check initial value
|
// Check initial value
|
||||||
assertEquals(initialValue, modifier.read(index));
|
assertEquals(initialValue, modifier.read(index));
|
||||||
@ -84,7 +88,7 @@ public class PacketContainerTest {
|
|||||||
modifier.write(index, testValue);
|
modifier.write(index, testValue);
|
||||||
assertEquals(testValue, modifier.read(0));
|
assertEquals(testValue, modifier.read(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void testObjectArray(StructureModifier<T[]> modifier, int index, T[] initialValue, T[] testValue) {
|
private <T> void testObjectArray(StructureModifier<T[]> modifier, int index, T[] initialValue, T[] testValue) {
|
||||||
// Check initial value
|
// Check initial value
|
||||||
assertNull(modifier.read(index));
|
assertNull(modifier.read(index));
|
||||||
@ -92,7 +96,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
// Test initial
|
// Test initial
|
||||||
assertArrayEquals(initialValue, modifier.read(index));
|
assertArrayEquals(initialValue, modifier.read(index));
|
||||||
|
|
||||||
// Test assignment
|
// Test assignment
|
||||||
modifier.write(index, testValue);
|
modifier.write(index, testValue);
|
||||||
assertArrayEquals(testValue, modifier.read(0));
|
assertArrayEquals(testValue, modifier.read(0));
|
||||||
@ -104,25 +108,25 @@ public class PacketContainerTest {
|
|||||||
PacketContainer customPayload = new PacketContainer(PacketType.Play.Server.CUSTOM_PAYLOAD);
|
PacketContainer customPayload = new PacketContainer(PacketType.Play.Server.CUSTOM_PAYLOAD);
|
||||||
StructureModifier<byte[]> bytes = customPayload.getByteArrays();
|
StructureModifier<byte[]> bytes = customPayload.getByteArrays();
|
||||||
byte[] testArray = new byte[] { 1, 2, 3 };
|
byte[] testArray = new byte[] { 1, 2, 3 };
|
||||||
|
|
||||||
// It's NULL at first
|
// It's NULL at first
|
||||||
assertArrayEquals(null, (byte[]) bytes.read(0));
|
assertArrayEquals(null, bytes.read(0));
|
||||||
customPayload.getModifier().writeDefaults();
|
customPayload.getModifier().writeDefaults();
|
||||||
|
|
||||||
// Then it should create an empty array
|
// Then it should create an empty array
|
||||||
assertArrayEquals(new byte[0], (byte[]) bytes.read(0));
|
assertArrayEquals(new byte[0], bytes.read(0));
|
||||||
|
|
||||||
// Check and see if we can write to it
|
// Check and see if we can write to it
|
||||||
bytes.write(0, testArray);
|
bytes.write(0, testArray);
|
||||||
assertArrayEquals(testArray, (byte[]) bytes.read(0));
|
assertArrayEquals(testArray, bytes.read(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBytes() {
|
public void testGetBytes() {
|
||||||
PacketContainer spawnMob = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
|
PacketContainer spawnMob = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
|
||||||
testPrimitive(spawnMob.getBytes(), 0, (byte)0, (byte)1);
|
testPrimitive(spawnMob.getBytes(), 0, (byte)0, (byte)1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetShorts() {
|
public void testGetShorts() {
|
||||||
PacketContainer itemData = new PacketContainer(PacketType.Play.Server.TRANSACTION);
|
PacketContainer itemData = new PacketContainer(PacketType.Play.Server.TRANSACTION);
|
||||||
@ -132,7 +136,7 @@ public class PacketContainerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetIntegers() {
|
public void testGetIntegers() {
|
||||||
PacketContainer updateSign = new PacketContainer(PacketType.Play.Server.UPDATE_SIGN);
|
PacketContainer updateSign = new PacketContainer(PacketType.Play.Server.UPDATE_SIGN);
|
||||||
testPrimitive(updateSign.getIntegers(), 0, (int)0, (int)1);
|
testPrimitive(updateSign.getIntegers(), 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -150,7 +154,7 @@ public class PacketContainerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetDoubles() {
|
public void testGetDoubles() {
|
||||||
PacketContainer explosion = new PacketContainer(PacketType.Play.Server.EXPLOSION);
|
PacketContainer explosion = new PacketContainer(PacketType.Play.Server.EXPLOSION);
|
||||||
testPrimitive(explosion.getDoubles(), 0, (double)0, (double)0.8);
|
testPrimitive(explosion.getDoubles(), 0, (double)0, 0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -171,57 +175,57 @@ public class PacketContainerTest {
|
|||||||
PacketContainer mapChunkBulk = new PacketContainer(PacketType.Play.Server.MAP_CHUNK_BULK);
|
PacketContainer mapChunkBulk = new PacketContainer(PacketType.Play.Server.MAP_CHUNK_BULK);
|
||||||
StructureModifier<int[]> integers = mapChunkBulk.getIntegerArrays();
|
StructureModifier<int[]> integers = mapChunkBulk.getIntegerArrays();
|
||||||
int[] testArray = new int[] { 1, 2, 3 };
|
int[] testArray = new int[] { 1, 2, 3 };
|
||||||
|
|
||||||
// Pre and post conditions
|
// Pre and post conditions
|
||||||
assertArrayEquals(null, (int[]) integers.read(0));
|
assertArrayEquals(null, integers.read(0));
|
||||||
mapChunkBulk.getModifier().writeDefaults();
|
mapChunkBulk.getModifier().writeDefaults();
|
||||||
assertArrayEquals(new int[0], (int[]) integers.read(0));
|
assertArrayEquals(new int[0], integers.read(0));
|
||||||
|
|
||||||
integers.write(0, testArray);
|
integers.write(0, testArray);
|
||||||
assertArrayEquals(testArray, (int[]) integers.read(0));
|
assertArrayEquals(testArray, integers.read(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetItemModifier() {
|
public void testGetItemModifier() {
|
||||||
PacketContainer windowClick = new PacketContainer(PacketType.Play.Client.WINDOW_CLICK);
|
PacketContainer windowClick = new PacketContainer(PacketType.Play.Client.WINDOW_CLICK);
|
||||||
|
|
||||||
StructureModifier<ItemStack> items = windowClick.getItemModifier();
|
StructureModifier<ItemStack> items = windowClick.getItemModifier();
|
||||||
ItemStack goldAxe = new ItemStack(Material.GOLD_AXE);
|
ItemStack goldAxe = new ItemStack(Material.GOLD_AXE);
|
||||||
|
|
||||||
assertNotNull(goldAxe.getType());
|
assertNotNull(goldAxe.getType());
|
||||||
assertNull(items.read(0));
|
assertNull(items.read(0));
|
||||||
|
|
||||||
// Insert the goldaxe and check if it's there
|
// Insert the goldaxe and check if it's there
|
||||||
items.write(0, goldAxe);
|
items.write(0, goldAxe);
|
||||||
assertTrue("Item " + goldAxe + " != " + items.read(0), equivalentItem(goldAxe, items.read(0)));
|
assertTrue("Item " + goldAxe + " != " + items.read(0), equivalentItem(goldAxe, items.read(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetItemArrayModifier() {
|
public void testGetItemArrayModifier() {
|
||||||
PacketContainer windowItems = new PacketContainer(PacketType.Play.Server.WINDOW_ITEMS);
|
PacketContainer windowItems = new PacketContainer(PacketType.Play.Server.WINDOW_ITEMS);
|
||||||
StructureModifier<ItemStack[]> itemAccess = windowItems.getItemArrayModifier();
|
StructureModifier<ItemStack[]> itemAccess = windowItems.getItemArrayModifier();
|
||||||
|
|
||||||
ItemStack[] itemArray = new ItemStack[] {
|
ItemStack[] itemArray = new ItemStack[] {
|
||||||
new ItemStack(Material.GOLD_AXE),
|
new ItemStack(Material.GOLD_AXE),
|
||||||
new ItemStack(Material.DIAMOND_AXE)
|
new ItemStack(Material.DIAMOND_AXE)
|
||||||
};
|
};
|
||||||
|
|
||||||
assertNull(itemAccess.read(0));
|
assertNull(itemAccess.read(0));
|
||||||
|
|
||||||
// Insert and check that it was succesful
|
// Insert and check that it was succesful
|
||||||
itemAccess.write(0, itemArray);
|
itemAccess.write(0, itemArray);
|
||||||
|
|
||||||
// Read back array
|
// Read back array
|
||||||
ItemStack[] comparision = itemAccess.read(0);
|
ItemStack[] comparision = itemAccess.read(0);
|
||||||
assertEquals(itemArray.length, comparision.length);
|
assertEquals(itemArray.length, comparision.length);
|
||||||
|
|
||||||
// Check that it is equivalent
|
// Check that it is equivalent
|
||||||
for (int i = 0; i < itemArray.length; i++) {
|
for (int i = 0; i < itemArray.length; i++) {
|
||||||
assertTrue(String.format("Array element %s is not the same: %s != %s",
|
assertTrue(String.format("Array element %s is not the same: %s != %s",
|
||||||
i, itemArray[i], comparision[i]), equivalentItem(itemArray[i], comparision[i]));
|
i, itemArray[i], comparision[i]), equivalentItem(itemArray[i], comparision[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean equivalentItem(ItemStack first, ItemStack second) {
|
private boolean equivalentItem(ItemStack first, ItemStack second) {
|
||||||
if (first == null) {
|
if (first == null) {
|
||||||
return second == null;
|
return second == null;
|
||||||
@ -231,20 +235,20 @@ public class PacketContainerTest {
|
|||||||
return first.getType().equals(second.getType());
|
return first.getType().equals(second.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWorldTypeModifier() {
|
public void testGetWorldTypeModifier() {
|
||||||
// Not used in Netty
|
// Not used in Netty
|
||||||
if (MinecraftReflection.isUsingNetty())
|
if (MinecraftReflection.isUsingNetty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PacketContainer loginPacket = new PacketContainer(PacketType.Play.Server.LOGIN);
|
PacketContainer loginPacket = new PacketContainer(PacketType.Play.Server.LOGIN);
|
||||||
StructureModifier<WorldType> worldAccess = loginPacket.getWorldTypeModifier();
|
StructureModifier<WorldType> worldAccess = loginPacket.getWorldTypeModifier();
|
||||||
|
|
||||||
WorldType testValue = WorldType.LARGE_BIOMES;
|
WorldType testValue = WorldType.LARGE_BIOMES;
|
||||||
|
|
||||||
assertNull(worldAccess.read(0));
|
assertNull(worldAccess.read(0));
|
||||||
|
|
||||||
// Insert and read back
|
// Insert and read back
|
||||||
worldAccess.write(0, testValue);
|
worldAccess.write(0, testValue);
|
||||||
assertEquals(testValue, worldAccess.read(0));
|
assertEquals(testValue, worldAccess.read(0));
|
||||||
@ -253,30 +257,30 @@ public class PacketContainerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetNbtModifier() {
|
public void testGetNbtModifier() {
|
||||||
PacketContainer updateTileEntity = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA);
|
PacketContainer updateTileEntity = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA);
|
||||||
|
|
||||||
NbtCompound compound = NbtFactory.ofCompound("test");
|
NbtCompound compound = NbtFactory.ofCompound("test");
|
||||||
compound.put("test", "name");
|
compound.put("test", "name");
|
||||||
compound.put(NbtFactory.ofList("ages", 1, 2, 3));
|
compound.put(NbtFactory.ofList("ages", 1, 2, 3));
|
||||||
|
|
||||||
updateTileEntity.getNbtModifier().write(0, compound);
|
updateTileEntity.getNbtModifier().write(0, compound);
|
||||||
|
|
||||||
NbtCompound result = (NbtCompound) updateTileEntity.getNbtModifier().read(0);
|
NbtCompound result = (NbtCompound) updateTileEntity.getNbtModifier().read(0);
|
||||||
|
|
||||||
assertEquals(compound.getString("test"), result.getString("test"));
|
assertEquals(compound.getString("test"), result.getString("test"));
|
||||||
assertEquals(compound.getList("ages"), result.getList("ages"));
|
assertEquals(compound.getList("ages"), result.getList("ages"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDataWatcherModifier() {
|
public void testGetDataWatcherModifier() {
|
||||||
PacketContainer mobSpawnPacket = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
|
PacketContainer mobSpawnPacket = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
|
||||||
StructureModifier<WrappedDataWatcher> watcherAccessor = mobSpawnPacket.getDataWatcherModifier();
|
StructureModifier<WrappedDataWatcher> watcherAccessor = mobSpawnPacket.getDataWatcherModifier();
|
||||||
|
|
||||||
WrappedDataWatcher dataWatcher = new WrappedDataWatcher();
|
WrappedDataWatcher dataWatcher = new WrappedDataWatcher();
|
||||||
dataWatcher.setObject(1, 100);
|
dataWatcher.setObject(1, 100);
|
||||||
dataWatcher.setObject(2, 125);
|
dataWatcher.setObject(2, 125);
|
||||||
|
|
||||||
assertNull(watcherAccessor.read(0));
|
assertNull(watcherAccessor.read(0));
|
||||||
|
|
||||||
// Insert and read back
|
// Insert and read back
|
||||||
watcherAccessor.write(0, dataWatcher);
|
watcherAccessor.write(0, dataWatcher);
|
||||||
assertEquals(dataWatcher, watcherAccessor.read(0));
|
assertEquals(dataWatcher, watcherAccessor.read(0));
|
||||||
@ -285,7 +289,7 @@ public class PacketContainerTest {
|
|||||||
// Unfortunately, it might be too difficult to mock this one
|
// Unfortunately, it might be too difficult to mock this one
|
||||||
//
|
//
|
||||||
// @Test
|
// @Test
|
||||||
// public void testGetEntityModifier() { }
|
// public void testGetEntityModifier() { }
|
||||||
|
|
||||||
// No packet expose this type directly.
|
// No packet expose this type directly.
|
||||||
//
|
//
|
||||||
@ -296,94 +300,94 @@ public class PacketContainerTest {
|
|||||||
public void testGetPositionCollectionModifier() {
|
public void testGetPositionCollectionModifier() {
|
||||||
PacketContainer explosionPacket = new PacketContainer(PacketType.Play.Server.EXPLOSION);
|
PacketContainer explosionPacket = new PacketContainer(PacketType.Play.Server.EXPLOSION);
|
||||||
StructureModifier<List<ChunkPosition>> positionAccessor = explosionPacket.getPositionCollectionModifier();
|
StructureModifier<List<ChunkPosition>> positionAccessor = explosionPacket.getPositionCollectionModifier();
|
||||||
|
|
||||||
assertNull(positionAccessor.read(0));
|
assertNull(positionAccessor.read(0));
|
||||||
|
|
||||||
List<ChunkPosition> positions = Lists.newArrayList();
|
List<ChunkPosition> positions = Lists.newArrayList();
|
||||||
positions.add(new ChunkPosition(1, 2, 3));
|
positions.add(new ChunkPosition(1, 2, 3));
|
||||||
positions.add(new ChunkPosition(3, 4, 5));
|
positions.add(new ChunkPosition(3, 4, 5));
|
||||||
|
|
||||||
// Insert and read back
|
// Insert and read back
|
||||||
positionAccessor.write(0, positions);
|
positionAccessor.write(0, positions);
|
||||||
List<ChunkPosition> cloned = positionAccessor.read(0);
|
List<ChunkPosition> cloned = positionAccessor.read(0);
|
||||||
|
|
||||||
assertEquals(positions, cloned);
|
assertEquals(positions, cloned);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWatchableCollectionModifier() {
|
public void testGetWatchableCollectionModifier() {
|
||||||
PacketContainer entityMetadata = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
PacketContainer entityMetadata = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
StructureModifier<List<WrappedWatchableObject>> watchableAccessor =
|
StructureModifier<List<WrappedWatchableObject>> watchableAccessor =
|
||||||
entityMetadata.getWatchableCollectionModifier();
|
entityMetadata.getWatchableCollectionModifier();
|
||||||
|
|
||||||
assertNull(watchableAccessor.read(0));
|
assertNull(watchableAccessor.read(0));
|
||||||
|
|
||||||
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
||||||
watcher.setObject(1, 10);
|
watcher.setObject(1, 10);
|
||||||
watcher.setObject(8, 10);
|
watcher.setObject(8, 10);
|
||||||
|
|
||||||
List<WrappedWatchableObject> list = watcher.getWatchableObjects();
|
List<WrappedWatchableObject> list = watcher.getWatchableObjects();
|
||||||
|
|
||||||
// Insert and read back
|
// Insert and read back
|
||||||
watchableAccessor.write(0, list);
|
watchableAccessor.write(0, list);
|
||||||
assertEquals(list, watchableAccessor.read(0));
|
assertEquals(list, watchableAccessor.read(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGameProfiles() {
|
public void testGameProfiles() {
|
||||||
PacketContainer spawnEntity = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
PacketContainer spawnEntity = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
||||||
WrappedGameProfile profile = new WrappedGameProfile("d7047a08-3150-4aa8-a2f2-7c1e2b17e298", "name");
|
WrappedGameProfile profile = new WrappedGameProfile("d7047a08-3150-4aa8-a2f2-7c1e2b17e298", "name");
|
||||||
spawnEntity.getGameProfiles().write(0, profile);
|
spawnEntity.getGameProfiles().write(0, profile);
|
||||||
|
|
||||||
assertEquals(profile, spawnEntity.getGameProfiles().read(0));
|
assertEquals(profile, spawnEntity.getGameProfiles().read(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChatComponents() {
|
public void testChatComponents() {
|
||||||
PacketContainer chatPacket = new PacketContainer(PacketType.Play.Server.CHAT);
|
PacketContainer chatPacket = new PacketContainer(PacketType.Play.Server.CHAT);
|
||||||
chatPacket.getChatComponents().write(0,
|
chatPacket.getChatComponents().write(0,
|
||||||
WrappedChatComponent.fromChatMessage("You shall not " + ChatColor.ITALIC + "pass!")[0]);
|
WrappedChatComponent.fromChatMessage("You shall not " + ChatColor.ITALIC + "pass!")[0]);
|
||||||
|
|
||||||
assertEquals("{\"extra\":[\"You shall not \",{\"italic\":true,\"text\":\"pass!\"}],\"text\":\"\"}",
|
assertEquals("{\"extra\":[\"You shall not \",{\"italic\":true,\"text\":\"pass!\"}],\"text\":\"\"}",
|
||||||
chatPacket.getChatComponents().read(0).getJson());
|
chatPacket.getChatComponents().read(0).getJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerialization() {
|
public void testSerialization() {
|
||||||
PacketContainer chat = new PacketContainer(PacketType.Play.Client.CHAT);
|
PacketContainer chat = new PacketContainer(PacketType.Play.Client.CHAT);
|
||||||
chat.getStrings().write(0, "Test");
|
chat.getStrings().write(0, "Test");
|
||||||
|
|
||||||
PacketContainer copy = (PacketContainer) SerializationUtils.clone(chat);
|
PacketContainer copy = (PacketContainer) SerializationUtils.clone(chat);
|
||||||
|
|
||||||
assertEquals(PacketType.Play.Client.CHAT, copy.getType());
|
assertEquals(PacketType.Play.Client.CHAT, copy.getType());
|
||||||
assertEquals("Test", copy.getStrings().read(0));
|
assertEquals("Test", copy.getStrings().read(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAttributeList() {
|
public void testAttributeList() {
|
||||||
PacketContainer attribute = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
PacketContainer attribute = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
||||||
attribute.getIntegers().write(0, 123); // Entity ID
|
attribute.getIntegers().write(0, 123); // Entity ID
|
||||||
|
|
||||||
// Initialize some test data
|
// Initialize some test data
|
||||||
List<AttributeModifier> modifiers = Lists.newArrayList(
|
List<AttributeModifier> modifiers = Lists.newArrayList(
|
||||||
new AttributeModifier(UUID.randomUUID(), "Unknown synced attribute modifier", 10, 0));
|
new AttributeModifier(UUID.randomUUID(), "Unknown synced attribute modifier", 10, 0));
|
||||||
AttributeSnapshot snapshot = new AttributeSnapshot(
|
AttributeSnapshot snapshot = new AttributeSnapshot(
|
||||||
(PacketPlayOutUpdateAttributes) attribute.getHandle(), "generic.Maxhealth", 20.0, modifiers);
|
(PacketPlayOutUpdateAttributes) attribute.getHandle(), "generic.Maxhealth", 20.0, modifiers);
|
||||||
|
|
||||||
attribute.getSpecificModifier(List.class).write(0, Lists.newArrayList(snapshot));
|
attribute.getSpecificModifier(List.class).write(0, Lists.newArrayList(snapshot));
|
||||||
PacketContainer cloned = attribute.deepClone();
|
PacketContainer cloned = attribute.deepClone();
|
||||||
AttributeSnapshot clonedSnapshot = (AttributeSnapshot) cloned.getSpecificModifier(List.class).read(0).get(0);
|
AttributeSnapshot clonedSnapshot = (AttributeSnapshot) cloned.getSpecificModifier(List.class).read(0).get(0);
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
ToStringBuilder.reflectionToString(snapshot, ToStringStyle.SHORT_PREFIX_STYLE),
|
ToStringBuilder.reflectionToString(snapshot, ToStringStyle.SHORT_PREFIX_STYLE),
|
||||||
ToStringBuilder.reflectionToString(clonedSnapshot, ToStringStyle.SHORT_PREFIX_STYLE));
|
ToStringBuilder.reflectionToString(clonedSnapshot, ToStringStyle.SHORT_PREFIX_STYLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBlocks() {
|
public void testBlocks() {
|
||||||
PacketContainer blockAction = new PacketContainer(PacketType.Play.Server.BLOCK_ACTION);
|
PacketContainer blockAction = new PacketContainer(PacketType.Play.Server.BLOCK_ACTION);
|
||||||
blockAction.getBlocks().write(0, Material.STONE);
|
blockAction.getBlocks().write(0, Material.STONE);
|
||||||
|
|
||||||
assertEquals(Material.STONE, blockAction.getBlocks().read(0));
|
assertEquals(Material.STONE, blockAction.getBlocks().read(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,38 +395,38 @@ public class PacketContainerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testPotionEffect() {
|
public void testPotionEffect() {
|
||||||
PotionEffect effect = new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 20 * 60, 1);
|
PotionEffect effect = new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 20 * 60, 1);
|
||||||
|
|
||||||
// The constructor we want to call
|
// The constructor we want to call
|
||||||
PacketConstructor creator = PacketConstructor.DEFAULT.withPacket(
|
PacketConstructor creator = PacketConstructor.DEFAULT.withPacket(
|
||||||
PacketType.Play.Server.ENTITY_EFFECT, new Class<?>[] { int.class, PotionEffect.class });
|
PacketType.Play.Server.ENTITY_EFFECT, new Class<?>[] { int.class, PotionEffect.class });
|
||||||
PacketContainer packet = creator.createPacket(1, effect);
|
PacketContainer packet = creator.createPacket(1, effect);
|
||||||
|
|
||||||
assertEquals(1, (int) packet.getIntegers().read(0));
|
assertEquals(1, (int) packet.getIntegers().read(0));
|
||||||
assertEquals(effect.getType().getId(), (byte) packet.getBytes().read(0));
|
assertEquals(effect.getType().getId(), (byte) packet.getBytes().read(0));
|
||||||
assertEquals(effect.getAmplifier(), (byte) packet.getBytes().read(1));
|
assertEquals(effect.getAmplifier(), (byte) packet.getBytes().read(1));
|
||||||
assertEquals(effect.getDuration(), (short) packet.getShorts().read(0));
|
assertEquals(effect.getDuration(), (short) packet.getShorts().read(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeepClone() {
|
public void testDeepClone() {
|
||||||
// Try constructing all the packets
|
// Try constructing all the packets
|
||||||
for (PacketType type : PacketType.values()) {
|
for (PacketType type : PacketType.values()) {
|
||||||
// Whether or not this packet has been registered
|
// Whether or not this packet has been registered
|
||||||
boolean registered = type.isSupported();
|
boolean registered = type.isSupported();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PacketContainer constructed = new PacketContainer(type);
|
PacketContainer constructed = new PacketContainer(type);
|
||||||
|
|
||||||
if (!registered) {
|
if (!registered) {
|
||||||
fail("Expected IllegalArgumentException(Packet " + type + " not registered");
|
fail("Expected IllegalArgumentException(Packet " + type + " not registered");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize default values
|
// Initialize default values
|
||||||
constructed.getModifier().writeDefaults();
|
constructed.getModifier().writeDefaults();
|
||||||
|
|
||||||
// Clone the packet
|
// Clone the packet
|
||||||
PacketContainer cloned = constructed.deepClone();
|
PacketContainer cloned = constructed.deepClone();
|
||||||
|
|
||||||
// Make sure they're equivalent
|
// Make sure they're equivalent
|
||||||
StructureModifier<Object> firstMod = constructed.getModifier(), secondMod = cloned.getModifier();
|
StructureModifier<Object> firstMod = constructed.getModifier(), secondMod = cloned.getModifier();
|
||||||
assertEquals(firstMod.size(), secondMod.size());
|
assertEquals(firstMod.size(), secondMod.size());
|
||||||
@ -439,7 +443,7 @@ public class PacketContainerTest {
|
|||||||
testEquality(firstMod.read(i), secondMod.read(i));
|
testEquality(firstMod.read(i), secondMod.read(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
if (!registered) {
|
if (!registered) {
|
||||||
// Check the same
|
// Check the same
|
||||||
@ -451,12 +455,12 @@ public class PacketContainerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPacketType() {
|
public void testPacketType() {
|
||||||
assertEquals(PacketType.Legacy.Server.SET_CREATIVE_SLOT, PacketType.findLegacy(107, Sender.SERVER));
|
assertEquals(PacketType.Legacy.Server.SET_CREATIVE_SLOT, PacketType.findLegacy(107, Sender.SERVER));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to objects that support equals()
|
// Convert to objects that support equals()
|
||||||
private void testEquality(Object a, Object b) {
|
private void testEquality(Object a, Object b) {
|
||||||
if (a != null && b != null) {
|
if (a != null && b != null) {
|
||||||
@ -468,10 +472,10 @@ public class PacketContainerTest {
|
|||||||
b = itemConvert.getSpecific(b);
|
b = itemConvert.getSpecific(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(a, b);
|
assertEquals(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the underlying array as an object array.
|
* Get the underlying array as an object array.
|
||||||
* @param val - array wrapped as an Object.
|
* @param val - array wrapped as an Object.
|
||||||
@ -485,7 +489,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
int arrlength = Array.getLength(val);
|
int arrlength = Array.getLength(val);
|
||||||
Object[] outputArray = new Object[arrlength];
|
Object[] outputArray = new Object[arrlength];
|
||||||
|
|
||||||
for (int i = 0; i < arrlength; ++i)
|
for (int i = 0; i < arrlength; ++i)
|
||||||
outputArray[i] = Array.get(val, i);
|
outputArray[i] = Array.get(val, i);
|
||||||
return outputArray;
|
return outputArray;
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
package com.comphenix.protocol.injector;
|
package com.comphenix.protocol.injector;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.Matchers.anyString;
|
||||||
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 java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.PluginLoadOrder;
|
import org.bukkit.plugin.PluginLoadOrder;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
|
|
||||||
import com.comphenix.protocol.injector.PluginVerifier.VerificationResult;
|
import com.comphenix.protocol.injector.PluginVerifier.VerificationResult;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
package com.comphenix.protocol.injector;
|
package com.comphenix.protocol.injector;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.comphenix.protocol.reflect.accessors;
|
package com.comphenix.protocol.reflect.accessors;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.comphenix.protocol.reflect.cloning;
|
package com.comphenix.protocol.reflect.cloning;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package com.comphenix.protocol.utility;
|
package com.comphenix.protocol.utility;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
import net.minecraft.server.v1_7_R3.ChatComponentText;
|
import static org.mockito.Mockito.verify;
|
||||||
import net.minecraft.server.v1_7_R3.ChatSerializer;
|
import net.minecraft.server.v1_7_R4.ChatComponentText;
|
||||||
import net.minecraft.server.v1_7_R3.ChunkCoordIntPair;
|
import net.minecraft.server.v1_7_R4.ChatSerializer;
|
||||||
import net.minecraft.server.v1_7_R3.IChatBaseComponent;
|
import net.minecraft.server.v1_7_R4.ChunkCoordIntPair;
|
||||||
import net.minecraft.server.v1_7_R3.NBTCompressedStreamTools;
|
import net.minecraft.server.v1_7_R4.IChatBaseComponent;
|
||||||
import net.minecraft.server.v1_7_R3.ServerPing;
|
import net.minecraft.server.v1_7_R4.NBTCompressedStreamTools;
|
||||||
import net.minecraft.server.v1_7_R3.ServerPingPlayerSample;
|
import net.minecraft.server.v1_7_R4.ServerPing;
|
||||||
import net.minecraft.server.v1_7_R3.ServerPingServerData;
|
import net.minecraft.server.v1_7_R4.ServerPingPlayerSample;
|
||||||
import net.minecraft.server.v1_7_R3.WatchableObject;
|
import net.minecraft.server.v1_7_R4.ServerPingServerData;
|
||||||
|
import net.minecraft.server.v1_7_R4.WatchableObject;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -27,40 +28,40 @@ public class MinecraftReflectionTest {
|
|||||||
private interface FakeEntity {
|
private interface FakeEntity {
|
||||||
public Entity getBukkitEntity();
|
public Entity getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface FakeBlock {
|
private interface FakeBlock {
|
||||||
public Block getBukkitEntity();
|
public Block getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initializeReflection() throws IllegalAccessException {
|
public static void initializeReflection() throws IllegalAccessException {
|
||||||
BukkitInitialization.initializePackage();
|
BukkitInitialization.initializePackage();
|
||||||
|
|
||||||
// Set up a package with no class loader knowledge
|
// Set up a package with no class loader knowledge
|
||||||
MinecraftReflection.minecraftPackage = new CachedPackage(
|
MinecraftReflection.minecraftPackage = new CachedPackage(
|
||||||
MinecraftReflection.getMinecraftPackage(),
|
MinecraftReflection.getMinecraftPackage(),
|
||||||
ClassSource.fromMap(Maps.<String, Class<?>>newHashMap())
|
ClassSource.fromMap(Maps.<String, Class<?>>newHashMap())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void undoMocking() {
|
public static void undoMocking() {
|
||||||
// NOP
|
// NOP
|
||||||
MinecraftReflection.minecraftPackage = null;
|
MinecraftReflection.minecraftPackage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBukkitMethod() {
|
public void testBukkitMethod() {
|
||||||
FakeEntity entity = mock(FakeEntity.class);
|
FakeEntity entity = mock(FakeEntity.class);
|
||||||
FakeBlock block = mock(FakeBlock.class);
|
FakeBlock block = mock(FakeBlock.class);
|
||||||
|
|
||||||
MinecraftReflection.getBukkitEntity(entity);
|
MinecraftReflection.getBukkitEntity(entity);
|
||||||
MinecraftReflection.getBukkitEntity(block);
|
MinecraftReflection.getBukkitEntity(block);
|
||||||
|
|
||||||
verify(entity, times(1)).getBukkitEntity();
|
verify(entity, times(1)).getBukkitEntity();
|
||||||
verify(block, times(1)).getBukkitEntity();
|
verify(block, times(1)).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void testIllegalClass() {
|
public void testIllegalClass() {
|
||||||
MinecraftReflection.getBukkitEntity("Hello");
|
MinecraftReflection.getBukkitEntity("Hello");
|
||||||
@ -70,42 +71,42 @@ public class MinecraftReflectionTest {
|
|||||||
public void testNbtStreamTools() {
|
public void testNbtStreamTools() {
|
||||||
assertEquals(NBTCompressedStreamTools.class, MinecraftReflection.getNbtCompressedStreamToolsClass());
|
assertEquals(NBTCompressedStreamTools.class, MinecraftReflection.getNbtCompressedStreamToolsClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChatComponent() {
|
public void testChatComponent() {
|
||||||
assertEquals(IChatBaseComponent.class, MinecraftReflection.getIChatBaseComponentClass());
|
assertEquals(IChatBaseComponent.class, MinecraftReflection.getIChatBaseComponentClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChatComponentText() {
|
public void testChatComponentText() {
|
||||||
assertEquals(ChatComponentText.class, MinecraftReflection.getChatComponentTextClass());
|
assertEquals(ChatComponentText.class, MinecraftReflection.getChatComponentTextClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChatSerializer() {
|
public void testChatSerializer() {
|
||||||
assertEquals(ChatSerializer.class, MinecraftReflection.getChatSerializerClass());
|
assertEquals(ChatSerializer.class, MinecraftReflection.getChatSerializerClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServerPing() {
|
public void testServerPing() {
|
||||||
assertEquals(ServerPing.class, MinecraftReflection.getServerPingClass());
|
assertEquals(ServerPing.class, MinecraftReflection.getServerPingClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServerPingPlayerSample() {
|
public void testServerPingPlayerSample() {
|
||||||
assertEquals(ServerPingPlayerSample.class, MinecraftReflection.getServerPingPlayerSampleClass());
|
assertEquals(ServerPingPlayerSample.class, MinecraftReflection.getServerPingPlayerSampleClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServerPingServerData() {
|
public void testServerPingServerData() {
|
||||||
assertEquals(ServerPingServerData.class, MinecraftReflection.getServerPingServerDataClass());
|
assertEquals(ServerPingServerData.class, MinecraftReflection.getServerPingServerDataClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChunkCoordIntPair() {
|
public void testChunkCoordIntPair() {
|
||||||
assertEquals(ChunkCoordIntPair.class, MinecraftReflection.getChunkCoordIntPair());
|
assertEquals(ChunkCoordIntPair.class, MinecraftReflection.getChunkCoordIntPair());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWatchableObject() {
|
public void testWatchableObject() {
|
||||||
assertEquals(WatchableObject.class, MinecraftReflection.getWatchableObjectClass());
|
assertEquals(WatchableObject.class, MinecraftReflection.getWatchableObjectClass());
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.comphenix.protocol.utility;
|
package com.comphenix.protocol.utility;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.comphenix.protocol.utility;
|
package com.comphenix.protocol.utility;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -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_R3.IntHashMap;
|
import net.minecraft.server.v1_7_R4.IntHashMap;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemFactory;
|
import org.bukkit.craftbukkit.v1_7_R4.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;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -15,16 +15,16 @@ public class ChunkCoordIntPairTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
net.minecraft.server.v1_7_R3.ChunkCoordIntPair pair = new net.minecraft.server.v1_7_R3.ChunkCoordIntPair(1, 2);
|
net.minecraft.server.v1_7_R4.ChunkCoordIntPair pair = new net.minecraft.server.v1_7_R4.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_R3.ChunkCoordIntPair roundtrip =
|
net.minecraft.server.v1_7_R4.ChunkCoordIntPair roundtrip =
|
||||||
(net.minecraft.server.v1_7_R3.ChunkCoordIntPair) ChunkCoordIntPair.getConverter().
|
(net.minecraft.server.v1_7_R4.ChunkCoordIntPair) ChunkCoordIntPair.getConverter().
|
||||||
getGeneric(net.minecraft.server.v1_7_R3.ChunkCoordIntPair.class, specific);
|
getGeneric(net.minecraft.server.v1_7_R4.ChunkCoordIntPair.class, specific);
|
||||||
|
|
||||||
assertEquals(1, roundtrip.x);
|
assertEquals(1, roundtrip.x);
|
||||||
assertEquals(2, roundtrip.z);
|
assertEquals(2, roundtrip.z);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.BukkitInitialization;
|
import com.comphenix.protocol.BukkitInitialization;
|
||||||
import com.comphenix.protocol.reflect.cloning.AggregateCloner;
|
import com.comphenix.protocol.reflect.cloning.AggregateCloner;
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import net.minecraft.server.v1_7_R4.EnumChatVisibility;
|
||||||
import net.minecraft.server.v1_7_R3.EnumChatVisibility;
|
import net.minecraft.server.v1_7_R4.EnumClientCommand;
|
||||||
import net.minecraft.server.v1_7_R3.EnumClientCommand;
|
import net.minecraft.server.v1_7_R4.EnumDifficulty;
|
||||||
import net.minecraft.server.v1_7_R3.EnumDifficulty;
|
import net.minecraft.server.v1_7_R4.EnumEntityUseAction;
|
||||||
import net.minecraft.server.v1_7_R3.EnumEntityUseAction;
|
import net.minecraft.server.v1_7_R4.EnumGamemode;
|
||||||
import net.minecraft.server.v1_7_R3.EnumGamemode;
|
import net.minecraft.server.v1_7_R4.EnumProtocol;
|
||||||
import net.minecraft.server.v1_7_R3.EnumProtocol;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotSame;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R3.AttributeModifier;
|
import net.minecraft.server.v1_7_R4.AttributeModifier;
|
||||||
import net.minecraft.server.v1_7_R3.AttributeSnapshot;
|
import net.minecraft.server.v1_7_R4.AttributeSnapshot;
|
||||||
import net.minecraft.server.v1_7_R3.PacketPlayOutUpdateAttributes;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutUpdateAttributes;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemFactory;
|
import org.bukkit.craftbukkit.v1_7_R4.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;
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
|
|
||||||
package com.comphenix.protocol.wrappers.nbt;
|
package com.comphenix.protocol.wrappers.nbt;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.comphenix.protocol.BukkitInitialization;
|
import com.comphenix.protocol.BukkitInitialization;
|
||||||
|
|
||||||
public class NbtCompoundTest {
|
public class NbtCompoundTest {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package com.comphenix.protocol.wrappers.nbt;
|
package com.comphenix.protocol.wrappers.nbt;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -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_R3.inventory.CraftItemFactory;
|
import org.bukkit.craftbukkit.v1_7_R4.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;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.comphenix.protocol.wrappers.nbt.io;
|
package com.comphenix.protocol.wrappers.nbt.io;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -11,6 +11,8 @@ Critically, different plugins that use this approach may _hook_ into the same cl
|
|||||||
with unpredictable outcomes. More than often this causes plugins to crash, but it may also
|
with unpredictable outcomes. More than often this causes plugins to crash, but it may also
|
||||||
lead to more subtle bugs.
|
lead to more subtle bugs.
|
||||||
|
|
||||||
|
Currently maintained by dmulloy2 on behalf of [SpigotMC](http://www.spigotmc.org/)
|
||||||
|
|
||||||
|
|
||||||
### Resources
|
### Resources
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren