Skip to content

Commit

Permalink
Update to Spigot 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
rutgerkok committed Jun 9, 2016
1 parent dd45c97 commit b1cc6fd
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 39 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>nl.rutgerkok.betterenderchest</groupId>
<artifactId>BetterEnderChest</artifactId>
<version>2.4.3</version>
<version>2.4.4</version>
<name>BetterEnderChest</name>
<description>CraftBukkit plugin that adds functionality for both players and admins to the Ender Chest.</description>
<url>https://github.com/rutgerkok/BetterEnderChest</url>
Expand Down Expand Up @@ -54,13 +54,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.9.4-R0.1-SNAPSHOT</version>
<version>1.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.9.4-R0.1-SNAPSHOT</version>
<version>1.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -108,7 +108,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,32 @@

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;

import com.google.common.collect.ImmutableMap;

import net.minecraft.server.v1_9_R2.BlockPosition;
import net.minecraft.server.v1_9_R2.Blocks;
import net.minecraft.server.v1_9_R2.NBTBase;
import net.minecraft.server.v1_9_R2.NBTBase.NBTNumber;
import net.minecraft.server.v1_9_R2.NBTCompressedStreamTools;
import net.minecraft.server.v1_9_R2.NBTTagByteArray;
import net.minecraft.server.v1_9_R2.NBTTagCompound;
import net.minecraft.server.v1_9_R2.NBTTagDouble;
import net.minecraft.server.v1_9_R2.NBTTagInt;
import net.minecraft.server.v1_9_R2.NBTTagIntArray;
import net.minecraft.server.v1_9_R2.NBTTagList;
import net.minecraft.server.v1_9_R2.NBTTagLong;
import net.minecraft.server.v1_9_R2.NBTTagString;
import net.minecraft.server.v1_9_R2.TileEntity;
import net.minecraft.server.v1_9_R2.TileEntityEnderChest;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Blocks;
import net.minecraft.server.v1_10_R1.NBTBase;
import net.minecraft.server.v1_10_R1.NBTCompressedStreamTools;
import net.minecraft.server.v1_10_R1.NBTTagByte;
import net.minecraft.server.v1_10_R1.NBTTagByteArray;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.NBTTagDouble;
import net.minecraft.server.v1_10_R1.NBTTagFloat;
import net.minecraft.server.v1_10_R1.NBTTagInt;
import net.minecraft.server.v1_10_R1.NBTTagIntArray;
import net.minecraft.server.v1_10_R1.NBTTagList;
import net.minecraft.server.v1_10_R1.NBTTagLong;
import net.minecraft.server.v1_10_R1.NBTTagShort;
import net.minecraft.server.v1_10_R1.NBTTagString;
import net.minecraft.server.v1_10_R1.TileEntity;
import net.minecraft.server.v1_10_R1.TileEntityEnderChest;

public class SimpleNMSHandler extends NMSHandler {
static class JSONSimpleTypes {
Expand Down Expand Up @@ -173,26 +175,32 @@ private static final Object nbtTagToJavaType(NBTBase tag) throws IOException {
objects.add(tagInNBTListToJavaType(listTag, i));
}
return objects;
} else if (tag instanceof NBTNumber) {
// Check for whole or fractional number (we don't care about
// the difference between int/long or double/float, in JSON
// they look the same)
NBTNumber nbtNumber = (NBTNumber) tag;
if (nbtNumber instanceof NBTTagInt || nbtNumber instanceof NBTTagLong) {
// Whole number
return nbtNumber.c();
} else {
// Fractional number
return nbtNumber.g();
}
} else if (tag instanceof NBTTagByte) {
byte value = ((NBTTagByte) tag).g();
return value;
} else if (tag instanceof NBTTagDouble) {
double value = ((NBTTagDouble) tag).h();
return value;
} else if (tag instanceof NBTTagFloat) {
float value = ((NBTTagFloat) tag).i();
return value;
} else if (tag instanceof NBTTagInt) {
int value = ((NBTTagInt) tag).e();
return value;
} else if (tag instanceof NBTTagLong) {
long value = ((NBTTagLong) tag).d();
return value;
} else if (tag instanceof NBTTagShort) {
short value = ((NBTTagShort) tag).f();
return value;
} else if (tag instanceof NBTTagString) {
String value = ((NBTTagString) tag).a_();
String value = ((NBTTagString) tag).c_();
return value;
} else if (tag instanceof NBTTagByteArray) {
// Byte arrays are placed in a map, see comment for BYTE_ARRAY
return ImmutableMap.of(BYTE_ARRAY, boxBytes(((NBTTagByteArray) tag).c()));
} else if (tag instanceof NBTTagIntArray) {
return boxIntegers(((NBTTagIntArray) tag).c());
return boxIntegers(((NBTTagIntArray) tag).d());
}

throw new IOException("Unknown tag: " + tag);
Expand All @@ -211,7 +219,7 @@ private static final Object nbtTagToJavaType(NBTBase tag) throws IOException {
* If the tag type is unknown.
*/
private static final Object tagInNBTListToJavaType(NBTTagList tagList, int position) throws IOException {
switch (tagList.d()) {
switch (tagList.g()) {
case TagType.COMPOUND:
NBTTagCompound compoundValue = tagList.get(position);
return nbtTagToJavaType(compoundValue);
Expand Down Expand Up @@ -418,7 +426,7 @@ private Inventory loadNBTInventoryFromTag(NBTTagCompound baseTag, ChestOwner che
NBTTagCompound item = inventoryTag.get(i);
int slot = item.getByte("Slot") & 255;
inventory.setItem(slot,
CraftItemStack.asCraftMirror(net.minecraft.server.v1_9_R2.ItemStack.createStack(item)));
CraftItemStack.asCraftMirror(net.minecraft.server.v1_10_R1.ItemStack.createStack(item)));
}

// Return the inventory
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/nl/rutgerkok/betterenderchest/nms/TestJSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import net.minecraft.server.v1_9_R2.NBTTagCompound;
import net.minecraft.server.v1_10_R1.NBTTagCompound;

@RunWith(JUnit4.class)
public class TestJSON {
Expand All @@ -30,7 +30,7 @@ public class TestJSON {
* JSON to decode and encode.
* @return The JSON after it has been decoded and encoded.
* @throws IOException
* When a decoding error occurs.
* When an error occurs.
*/
private String reserialize(String json) throws IOException {
NBTTagCompound compoundTag = JSONSimpleTypes.toTag(json);
Expand Down

0 comments on commit b1cc6fd

Please sign in to comment.