Add v1_8R2 to support 1.8.3 users not on the latest 1.8.3 build

This commit is contained in:
vemacs 2015-06-18 13:43:39 -04:00
parent 0331fafa77
commit 16c7bf2eb3
8 changed files with 99 additions and 2 deletions

View File

@ -117,6 +117,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>1_8_R2Provider</artifactId>
<version>2.0.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>LegacyProvider</artifactId>

View File

@ -5,6 +5,7 @@ import net.ess3.nms.SpawnerProvider;
import net.ess3.nms.blockmeta.BlockMetaSpawnerProvider;
import net.ess3.nms.legacy.LegacySpawnerProvider;
import net.ess3.nms.v1_8_R1.v1_8_R1SpawnerProvider;
import net.ess3.nms.v1_8_R2.v1_8_R2SpawnerProvider;
import java.util.Arrays;
import java.util.List;
@ -20,6 +21,7 @@ public class SpawnerProviderFactory {
List<Class<? extends SpawnerProvider>> availableProviders = Arrays.asList(
BlockMetaSpawnerProvider.class,
v1_8_R1SpawnerProvider.class,
v1_8_R2SpawnerProvider.class,
LegacySpawnerProvider.class
);
SpawnerProvider finalProvider = null;

View File

@ -2,11 +2,9 @@ package net.ess3.nms.v1_8_R1;
import net.ess3.nms.SpawnerProvider;
import net.minecraft.server.v1_8_R1.NBTTagCompound;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class v1_8_R1SpawnerProvider extends SpawnerProvider {
@Override

1
nms/1_8_R2Provider/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
craftbukkit-*.jar

View File

@ -0,0 +1 @@
Put a 1.8.3 Spigot/CraftBukkit JAR with filename `craftbukkit-1.8.3-R0.1-SNAPSHOT.jar` in `lib/org/bukkit/craftbukkit/1.8.3-R0.1-SNAPSHOT`.

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>EssentialsParent</artifactId>
<groupId>net.ess3</groupId>
<version>2.0.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>1_8_R2Provider</artifactId>
<repositories>
<repository>
<id>project.local</id>
<name>local repo</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.8.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>NMSProvider</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,46 @@
package net.ess3.nms.v1_8_R2;
import net.ess3.nms.SpawnerProvider;
import net.minecraft.server.v1_8_R2.NBTTagCompound;
import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
public class v1_8_R2SpawnerProvider extends SpawnerProvider {
@Override
public ItemStack setEntityType(ItemStack is, EntityType type) {
net.minecraft.server.v1_8_R2.ItemStack itemStack;
CraftItemStack craftStack = CraftItemStack.asCraftCopy(is);
itemStack = CraftItemStack.asNMSCopy(craftStack);
NBTTagCompound tag = itemStack.getTag();
if (tag == null) {
tag = new NBTTagCompound();
itemStack.setTag(tag);
}
if (!tag.hasKey("BlockEntityTag")) {
tag.set("BlockEntityTag", new NBTTagCompound());
}
tag = itemStack.getTag().getCompound("BlockEntityTag");
tag.setString("EntityId", type.getName());
ItemStack bukkitItemStack = CraftItemStack.asCraftMirror(itemStack).clone();
return setDisplayName(bukkitItemStack, type);
}
@Override
public EntityType getEntityType(ItemStack is) {
net.minecraft.server.v1_8_R2.ItemStack itemStack;
CraftItemStack craftStack = CraftItemStack.asCraftCopy(is);
itemStack = CraftItemStack.asNMSCopy(craftStack);
NBTTagCompound tag = itemStack.getTag();
if (tag == null || !tag.hasKey("BlockEntityTag")) {
throw new IllegalArgumentException();
}
String name = tag.getCompound("BlockEntityTag").getString("EntityId");
return EntityType.fromName(name);
}
@Override
public String getHumanName() {
return "CraftBukkit 1.8 NMS-based provider";
}
}

View File

@ -44,6 +44,7 @@
<module>nms/NMSProvider</module>
<module>nms/BlockMetaProvider</module>
<module>nms/1_8_R1Provider</module>
<module>nms/1_8_R2Provider</module>
<module>nms/LegacyProvider</module>
</modules>