mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-23 00:15:08 +00:00
Updated to CraftBukkit 1.9
This commit is contained in:
parent
8dbbe80dbf
commit
346036b7e7
12 changed files with 54 additions and 37 deletions
6
pom.xml
6
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
<groupId>com.lishid</groupId>
|
<groupId>com.lishid</groupId>
|
||||||
<artifactId>openinv</artifactId>
|
<artifactId>openinv</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>2.3.4</version>
|
<version>2.3.5</version>
|
||||||
<name>OpenInv</name>
|
<name>OpenInv</name>
|
||||||
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>
|
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>
|
||||||
|
|
||||||
|
@ -23,14 +23,14 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
<version>1.9-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
<version>1.9-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -23,9 +23,10 @@ import org.bukkit.entity.Player;
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
|
|
||||||
// Volatile
|
// 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 class AnySilentChest {
|
||||||
public boolean isAnyChestNeeded(Player p, int x, int y, int z) {
|
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);
|
BlockPosition position = new BlockPosition(x, y, z);
|
||||||
EntityPlayer player = ((CraftPlayer) p).getHandle();
|
EntityPlayer player = ((CraftPlayer) p).getHandle();
|
||||||
World world = player.world;
|
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"));
|
Block.getByName("trapped_chest") : Block.getByName("chest"));
|
||||||
|
|
||||||
// If block on top
|
// If block on top
|
||||||
|
@ -59,7 +60,11 @@ public class AnySilentChest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean blockOnTop(World world, BlockPosition position) {
|
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) {
|
private boolean ocelotOnTop(World world, BlockPosition position) {
|
||||||
|
@ -89,7 +94,7 @@ public class AnySilentChest {
|
||||||
return true;
|
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"));
|
Block.getByName("trapped_chest") : Block.getByName("chest"));
|
||||||
|
|
||||||
TileEntity tileEntity = world.getTileEntity(position);
|
TileEntity tileEntity = world.getTileEntity(position);
|
||||||
|
|
|
@ -4,16 +4,16 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import com.google.common.collect.Iterators;
|
import com.google.common.collect.Iterators;
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R3.EnumDirection;
|
import net.minecraft.server.v1_9_R1.EnumDirection;
|
||||||
import net.minecraft.server.v1_8_R3.EnumDirection.EnumDirectionLimit;
|
import net.minecraft.server.v1_9_R1.EnumDirection.EnumDirectionLimit;
|
||||||
|
|
||||||
public enum EnumDirectionList implements Iterable<EnumDirection> {
|
public enum EnumDirectionList implements Iterable<EnumDirection> {
|
||||||
HORIZONTAL(EnumDirectionLimit.HORIZONTAL),
|
HORIZONTAL(EnumDirectionLimit.HORIZONTAL),
|
||||||
VERTICAL(EnumDirectionLimit.VERTICAL);
|
VERTICAL(EnumDirectionLimit.VERTICAL);
|
||||||
|
|
||||||
private final EnumDirectionLimit list;
|
private final EnumDirection.EnumDirectionLimit list;
|
||||||
|
|
||||||
private EnumDirectionList(EnumDirectionLimit list) {
|
EnumDirectionList(EnumDirection.EnumDirectionLimit list) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.Permissions;
|
import com.lishid.openinv.Permissions;
|
||||||
|
|
||||||
// Volatile
|
// 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 class InventoryAccess {
|
||||||
public boolean check(Inventory inventory, HumanEntity player) {
|
public boolean check(Inventory inventory, HumanEntity player) {
|
||||||
|
@ -49,16 +49,17 @@ public class InventoryAccess {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IInventory grabInventory(Inventory inventory) {
|
private IInventory grabInventory(Inventory inventory) {
|
||||||
if(inventory instanceof CraftInventory) {
|
if (inventory instanceof CraftInventory) {
|
||||||
return ((CraftInventory) inventory).getInventory();
|
return ((CraftInventory) inventory).getInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use reflection to find the inventory
|
// Use reflection to find the inventory
|
||||||
Class<? extends Inventory> clazz = inventory.getClass();
|
Class<? extends Inventory> clazz = inventory.getClass();
|
||||||
IInventory result = null;
|
IInventory result = null;
|
||||||
for(Field f : clazz.getDeclaredFields()) {
|
for (Field f : clazz.getDeclaredFields()) {
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
if(IInventory.class.isAssignableFrom(f.getDeclaringClass())) {
|
|
||||||
|
if (IInventory.class.isAssignableFrom(f.getDeclaringClass())) {
|
||||||
try {
|
try {
|
||||||
result = (IInventory) f.get(inventory);
|
result = (IInventory) f.get(inventory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,9 @@ import com.lishid.openinv.OpenInv;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
// Volatile
|
// 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 class PlayerDataManager {
|
||||||
public Player loadPlayer(UUID uuid) {
|
public Player loadPlayer(UUID uuid) {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package com.lishid.openinv.internal;
|
package com.lishid.openinv.internal;
|
||||||
|
|
||||||
// Volatile
|
// Volatile
|
||||||
import net.minecraft.server.v1_8_R3.*;
|
import net.minecraft.server.v1_9_R1.*;
|
||||||
|
|
||||||
public class SilentContainerChest extends ContainerChest {
|
public class SilentContainerChest extends ContainerChest {
|
||||||
public IInventory inv;
|
public IInventory inv;
|
||||||
|
|
|
@ -2,12 +2,13 @@ package com.lishid.openinv.internal;
|
||||||
|
|
||||||
import java.util.List;
|
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.entity.HumanEntity;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
// Volatile
|
// Volatile
|
||||||
import net.minecraft.server.v1_8_R3.*;
|
import net.minecraft.server.v1_9_R1.*;
|
||||||
|
|
||||||
public class SilentInventory implements ITileInventory {
|
public class SilentInventory implements ITileInventory {
|
||||||
public ITileInventory inv;
|
public ITileInventory inv;
|
||||||
|
@ -17,8 +18,8 @@ public class SilentInventory implements ITileInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean r_() {
|
public boolean x_() {
|
||||||
return inv.r_();
|
return inv.x_();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,8 +28,8 @@ public class SilentInventory implements ITileInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChestLock i() {
|
public ChestLock y_() {
|
||||||
return inv.i();
|
return inv.y_();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,8 +93,8 @@ public class SilentInventory implements ITileInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(int i, int i1) {
|
public void setProperty(int i, int i1) {
|
||||||
inv.b(i, i1);
|
inv.setProperty(i, i1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,6 +137,11 @@ public class SilentInventory implements ITileInventory {
|
||||||
inv.setMaxStackSize(i);
|
inv.setMaxStackSize(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return inv.getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return inv.getName();
|
return inv.getName();
|
||||||
|
|
|
@ -23,10 +23,10 @@ import org.bukkit.inventory.InventoryHolder;
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
|
|
||||||
// Volatile
|
// 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_9_R1.entity.*;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
|
import org.bukkit.craftbukkit.v1_9_R1.inventory.*;
|
||||||
|
|
||||||
public class SpecialEnderChest extends InventorySubcontainer {
|
public class SpecialEnderChest extends InventorySubcontainer {
|
||||||
private final CraftInventory inventory = new CraftInventory(this);
|
private final CraftInventory inventory = new CraftInventory(this);
|
||||||
|
|
|
@ -22,11 +22,16 @@ import org.bukkit.inventory.Inventory;
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
|
|
||||||
// Volatile
|
// 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_9_R1.entity.*;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
|
import org.bukkit.craftbukkit.v1_9_R1.inventory.*;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -----------------------------------------------
|
||||||
|
* This class still needs to be updated for 1.9.
|
||||||
|
* -----------------------------------------------
|
||||||
|
*/
|
||||||
public class SpecialPlayerInventory extends PlayerInventory {
|
public class SpecialPlayerInventory extends PlayerInventory {
|
||||||
private final CraftInventory inventory = new CraftInventory(this);
|
private final CraftInventory inventory = new CraftInventory(this);
|
||||||
private final ItemStack[] extra = new ItemStack[5];
|
private final ItemStack[] extra = new ItemStack[5];
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class OpenInvEntityListener implements Listener {
|
||||||
|
|
||||||
Player player = (Player) attacker;
|
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)) {
|
if (!OpenInv.getPlayerItemOpenInvStatus(player) || !OpenInv.hasPermission(player, Permissions.PERM_OPENINV)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ public class OpenInvPlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
// OpenInv item
|
// 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");
|
player.performCommand("openinv");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: OpenInv
|
name: OpenInv
|
||||||
main: com.lishid.openinv.OpenInv
|
main: com.lishid.openinv.OpenInv
|
||||||
version: 2.3.4
|
version: 2.3.5
|
||||||
author: lishid
|
author: lishid
|
||||||
description: >
|
description: >
|
||||||
This plugin allows you to open a player's inventory as a chest and interact with it in real time.
|
This plugin allows you to open a player's inventory as a chest and interact with it in real time.
|
||||||
|
|
Loading…
Reference in a new issue