Updated to CraftBukkit 1.9

This commit is contained in:
ShadowRanger 2016-03-02 13:44:16 +11:00
parent 8dbbe80dbf
commit 346036b7e7
12 changed files with 54 additions and 37 deletions

View file

@ -4,7 +4,7 @@
<groupId>com.lishid</groupId>
<artifactId>openinv</artifactId>
<packaging>jar</packaging>
<version>2.3.4</version>
<version>2.3.5</version>
<name>OpenInv</name>
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>
@ -23,14 +23,14 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<version>1.9-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<version>1.9-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

View file

@ -23,9 +23,10 @@ import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
// Volatile
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_9_R1.*;
import net.minecraft.server.v1_9_R1.BlockChest.Type;
import org.bukkit.craftbukkit.v1_8_R3.entity.*;
import org.bukkit.craftbukkit.v1_9_R1.entity.*;
public class AnySilentChest {
public boolean isAnyChestNeeded(Player p, int x, int y, int z) {
@ -33,7 +34,7 @@ public class AnySilentChest {
BlockPosition position = new BlockPosition(x, y, z);
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
BlockChest chest = (BlockChest) (((BlockChest) world.getType(position).getBlock()).b == 1 ?
BlockChest chest = (BlockChest) (((BlockChest) world.getType(position).getBlock()).g == Type.TRAP ?
Block.getByName("trapped_chest") : Block.getByName("chest"));
// If block on top
@ -59,7 +60,11 @@ public class AnySilentChest {
}
private boolean blockOnTop(World world, BlockPosition position) {
return world.getType(position.up()).getBlock().isOccluding();
// return world.getType(position.up()).getBlock().isOccluding();
// TODO: Does this work?
Block block = world.getType(position.up()).getBlock();
return block.isOccluding(block.getBlockData());
}
private boolean ocelotOnTop(World world, BlockPosition position) {
@ -89,7 +94,7 @@ public class AnySilentChest {
return true;
}
BlockChest chest = (BlockChest) (((BlockChest) world.getType(position).getBlock()).b == 1 ?
BlockChest chest = (BlockChest) (((BlockChest) world.getType(position).getBlock()).g == Type.TRAP ?
Block.getByName("trapped_chest") : Block.getByName("chest"));
TileEntity tileEntity = world.getTileEntity(position);

View file

@ -4,16 +4,16 @@ import java.util.Iterator;
import com.google.common.collect.Iterators;
import net.minecraft.server.v1_8_R3.EnumDirection;
import net.minecraft.server.v1_8_R3.EnumDirection.EnumDirectionLimit;
import net.minecraft.server.v1_9_R1.EnumDirection;
import net.minecraft.server.v1_9_R1.EnumDirection.EnumDirectionLimit;
public enum EnumDirectionList implements Iterable<EnumDirection> {
HORIZONTAL(EnumDirectionLimit.HORIZONTAL),
VERTICAL(EnumDirectionLimit.VERTICAL);
private final EnumDirectionLimit list;
private final EnumDirection.EnumDirectionLimit list;
private EnumDirectionList(EnumDirectionLimit list) {
EnumDirectionList(EnumDirection.EnumDirectionLimit list) {
this.list = list;
}

View file

@ -25,9 +25,9 @@ import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
// Volatile
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_9_R1.*;
import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
import org.bukkit.craftbukkit.v1_9_R1.inventory.*;
public class InventoryAccess {
public boolean check(Inventory inventory, HumanEntity player) {
@ -49,16 +49,17 @@ public class InventoryAccess {
}
private IInventory grabInventory(Inventory inventory) {
if(inventory instanceof CraftInventory) {
if (inventory instanceof CraftInventory) {
return ((CraftInventory) inventory).getInventory();
}
// Use reflection to find the inventory
Class<? extends Inventory> clazz = inventory.getClass();
IInventory result = null;
for(Field f : clazz.getDeclaredFields()) {
for (Field f : clazz.getDeclaredFields()) {
f.setAccessible(true);
if(IInventory.class.isAssignableFrom(f.getDeclaringClass())) {
if (IInventory.class.isAssignableFrom(f.getDeclaringClass())) {
try {
result = (IInventory) f.get(inventory);
}

View file

@ -26,9 +26,9 @@ import com.lishid.openinv.OpenInv;
import com.mojang.authlib.GameProfile;
// Volatile
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_9_R1.*;
import org.bukkit.craftbukkit.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_9_R1.*;
public class PlayerDataManager {
public Player loadPlayer(UUID uuid) {

View file

@ -17,7 +17,7 @@
package com.lishid.openinv.internal;
// Volatile
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_9_R1.*;
public class SilentContainerChest extends ContainerChest {
public IInventory inv;

View file

@ -2,12 +2,13 @@ package com.lishid.openinv.internal;
import java.util.List;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.InventoryHolder;
// Volatile
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_9_R1.*;
public class SilentInventory implements ITileInventory {
public ITileInventory inv;
@ -17,8 +18,8 @@ public class SilentInventory implements ITileInventory {
}
@Override
public boolean r_() {
return inv.r_();
public boolean x_() {
return inv.x_();
}
@Override
@ -27,8 +28,8 @@ public class SilentInventory implements ITileInventory {
}
@Override
public ChestLock i() {
return inv.i();
public ChestLock y_() {
return inv.y_();
}
@Override
@ -92,8 +93,8 @@ public class SilentInventory implements ITileInventory {
}
@Override
public void b(int i, int i1) {
inv.b(i, i1);
public void setProperty(int i, int i1) {
inv.setProperty(i, i1);
}
@Override
@ -136,6 +137,11 @@ public class SilentInventory implements ITileInventory {
inv.setMaxStackSize(i);
}
@Override
public Location getLocation() {
return inv.getLocation();
}
@Override
public String getName() {
return inv.getName();

View file

@ -23,10 +23,10 @@ import org.bukkit.inventory.InventoryHolder;
import com.lishid.openinv.OpenInv;
// Volatile
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_9_R1.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.*;
import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
import org.bukkit.craftbukkit.v1_9_R1.entity.*;
import org.bukkit.craftbukkit.v1_9_R1.inventory.*;
public class SpecialEnderChest extends InventorySubcontainer {
private final CraftInventory inventory = new CraftInventory(this);

View file

@ -22,11 +22,16 @@ import org.bukkit.inventory.Inventory;
import com.lishid.openinv.OpenInv;
// Volatile
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_9_R1.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.*;
import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
import org.bukkit.craftbukkit.v1_9_R1.entity.*;
import org.bukkit.craftbukkit.v1_9_R1.inventory.*;
/*
* -----------------------------------------------
* This class still needs to be updated for 1.9.
* -----------------------------------------------
*/
public class SpecialPlayerInventory extends PlayerInventory {
private final CraftInventory inventory = new CraftInventory(this);
private final ItemStack[] extra = new ItemStack[5];

View file

@ -38,7 +38,7 @@ public class OpenInvEntityListener implements Listener {
Player player = (Player) attacker;
if (player.getItemInHand().getType() == OpenInv.getOpenInvItem()) {
if (player.getInventory().getItemInMainHand().getType() == OpenInv.getOpenInvItem()) {
if (!OpenInv.getPlayerItemOpenInvStatus(player) || !OpenInv.hasPermission(player, Permissions.PERM_OPENINV)) {
return;
}

View file

@ -143,7 +143,7 @@ public class OpenInvPlayerListener implements Listener {
}
case RIGHT_CLICK_AIR:
// OpenInv item
if (player.getItemInHand().getType() == OpenInv.getOpenInvItem() && OpenInv.getPlayerItemOpenInvStatus(player) && OpenInv.hasPermission(player, Permissions.PERM_OPENINV)) {
if (player.getInventory().getItemInMainHand().getType() == OpenInv.getOpenInvItem() && OpenInv.getPlayerItemOpenInvStatus(player) && OpenInv.hasPermission(player, Permissions.PERM_OPENINV)) {
player.performCommand("openinv");
}
}

View file

@ -1,6 +1,6 @@
name: OpenInv
main: com.lishid.openinv.OpenInv
version: 2.3.4
version: 2.3.5
author: lishid
description: >
This plugin allows you to open a player's inventory as a chest and interact with it in real time.