Merge pull request #47 from ShadowRanger/master

Update to 1.10
This commit is contained in:
ShadowRanger 2016-06-09 22:49:02 +10:00
commit 3152605bca
14 changed files with 108 additions and 82 deletions

View file

@ -4,7 +4,7 @@
<groupId>com.lishid</groupId>
<artifactId>openinv</artifactId>
<packaging>jar</packaging>
<version>2.3.8</version>
<version>2.3.9</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.9.4-R0.1-SNAPSHOT</version>
<version>1.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.9.4-R0.1-SNAPSHOT</version>
<version>1.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

View file

@ -10,7 +10,7 @@ import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import com.lishid.openinv.utils.UUIDUtil;
import com.lishid.openinv.utils.UUIDUtils;
public class ConfigUpdater {
@ -136,7 +136,7 @@ public class ConfigUpdater {
int converted = 0;
for (String playerName : keys) {
UUID uuid = UUIDUtil.getUUIDOf(playerName);
UUID uuid = UUIDUtils.getPlayerUUID(playerName);
if (uuid != null) {
boolean toggled = section.getBoolean(playerName + ".toggle", false);

View file

@ -129,6 +129,7 @@ public class OpenInv extends JavaPlugin {
*/
public SpecialPlayerInventory getPlayerInventory(Player player, boolean createIfNull) {
SpecialPlayerInventory inventory = inventories.get(player.getUniqueId());
if (inventory == null && createIfNull) {
inventory = new SpecialPlayerInventory(player, player.isOnline());
inventories.put(player.getUniqueId(), inventory);
@ -146,6 +147,7 @@ public class OpenInv extends JavaPlugin {
*/
public SpecialEnderChest getPlayerEnderChest(Player player, boolean createIfNull) {
SpecialEnderChest enderChest = enderChests.get(player.getUniqueId());
if (enderChest == null && createIfNull) {
enderChest = new SpecialEnderChest(player, player.isOnline());
enderChests.put(player.getUniqueId(), enderChest);
@ -206,33 +208,33 @@ public class OpenInv extends JavaPlugin {
}
/**
* Outputs OpenInv help information to a player.
* Outputs OpenInv help information to a CommandSender.
*
* @param player the player to show help to
* @param sender the CommandSender to show help to
*/
public static void showHelp(Player player) {
player.sendMessage(ChatColor.GREEN + "/openinv <player> - Opens a player's inventory.");
player.sendMessage(ChatColor.GREEN + " (aliases: oi, inv, open)");
public static void showHelp(CommandSender sender) {
sender.sendMessage(ChatColor.GREEN + "/openinv <player> - Opens a player's inventory.");
sender.sendMessage(ChatColor.GREEN + " (aliases: oi, inv, open)");
player.sendMessage(ChatColor.GREEN + "/openender <player> - Opens a player's ender chest.");
player.sendMessage(ChatColor.GREEN + " (aliases: oe)");
sender.sendMessage(ChatColor.GREEN + "/openender <player> - Opens a player's ender chest.");
sender.sendMessage(ChatColor.GREEN + " (aliases: oe)");
player.sendMessage(ChatColor.GREEN + "/searchinv <item> [minAmount] -");
player.sendMessage(ChatColor.GREEN + " Searches and lists players that have a specific item in their inventory.");
player.sendMessage(ChatColor.GREEN + " (aliases: si)");
sender.sendMessage(ChatColor.GREEN + "/searchinv <item> [minAmount] -");
sender.sendMessage(ChatColor.GREEN + " Searches and lists players that have a specific item in their inventory.");
sender.sendMessage(ChatColor.GREEN + " (aliases: si)");
player.sendMessage(ChatColor.GREEN + "/searchender <item> [minAmount] -");
player.sendMessage(ChatColor.GREEN + " Searches and lists players that have a specific item in their ender chest.");
player.sendMessage(ChatColor.GREEN + " (aliases: se)");
sender.sendMessage(ChatColor.GREEN + "/searchender <item> [minAmount] -");
sender.sendMessage(ChatColor.GREEN + " Searches and lists players that have a specific item in their ender chest.");
sender.sendMessage(ChatColor.GREEN + " (aliases: se)");
player.sendMessage(ChatColor.GREEN + "/toggleopeninv - Toggles the item openinv function.");
player.sendMessage(ChatColor.GREEN + " (aliases: toi, toggleoi, toggleinv)");
sender.sendMessage(ChatColor.GREEN + "/toggleopeninv - Toggles the item openinv function.");
sender.sendMessage(ChatColor.GREEN + " (aliases: toi, toggleoi, toggleinv)");
player.sendMessage(ChatColor.GREEN + "/anychest - Toggles the any chest function.");
player.sendMessage(ChatColor.GREEN + " (aliases: ac)");
sender.sendMessage(ChatColor.GREEN + "/anychest - Toggles the any chest function.");
sender.sendMessage(ChatColor.GREEN + " (aliases: ac)");
player.sendMessage(ChatColor.GREEN + "/silentchest - Toggles the silent chest function.");
player.sendMessage(ChatColor.GREEN + " (aliases: sc, silent)");
sender.sendMessage(ChatColor.GREEN + "/silentchest - Toggles the silent chest function.");
sender.sendMessage(ChatColor.GREEN + " (aliases: sc, silent)");
}
/**

View file

@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
import com.lishid.openinv.internal.SpecialEnderChest;
import com.lishid.openinv.utils.UUIDUtil;
import com.lishid.openinv.utils.UUIDUtils;
public class OpenEnderCommand implements CommandExecutor {
@ -55,7 +55,7 @@ public class OpenEnderCommand implements CommandExecutor {
}
if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
OpenInv.showHelp((Player) sender);
OpenInv.showHelp(sender);
return true;
}
@ -80,7 +80,7 @@ public class OpenEnderCommand implements CommandExecutor {
}
}
else {
uuid = UUIDUtil.getUUIDOf(args[0]);
uuid = UUIDUtils.getPlayerUUID(args[0]);
if (uuid == null) {
player.sendMessage(ChatColor.RED + "Player not found!");
return true;

View file

@ -25,12 +25,15 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
import com.lishid.openinv.internal.SpecialPlayerInventory;
import com.lishid.openinv.utils.UUIDUtil;
import com.lishid.openinv.utils.UUIDUtils;
public class OpenInvCommand implements CommandExecutor {
@ -55,7 +58,7 @@ public class OpenInvCommand implements CommandExecutor {
}
if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
OpenInv.showHelp((Player) sender);
OpenInv.showHelp(sender);
return true;
}
@ -73,9 +76,8 @@ public class OpenInvCommand implements CommandExecutor {
// Read from history if target is not named
if (args.length < 1) {
uuid = history;
}
else {
uuid = UUIDUtil.getUUIDOf(args[0]);
} else {
uuid = UUIDUtils.getPlayerUUID(args[0]);
if (uuid == null) {
player.sendMessage(ChatColor.RED + "Player not found!");
return true;

View file

@ -18,25 +18,25 @@ package com.lishid.openinv.internal;
import java.util.Iterator;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
import net.minecraft.server.v1_9_R2.AxisAlignedBB;
import net.minecraft.server.v1_9_R2.Block;
import net.minecraft.server.v1_9_R2.BlockChest;
import net.minecraft.server.v1_9_R2.BlockChest.Type;
import net.minecraft.server.v1_9_R2.BlockPosition;
import net.minecraft.server.v1_9_R2.Entity;
import net.minecraft.server.v1_9_R2.EntityOcelot;
import net.minecraft.server.v1_9_R2.EntityPlayer;
import net.minecraft.server.v1_9_R2.EnumDirection;
import net.minecraft.server.v1_9_R2.ITileInventory;
import net.minecraft.server.v1_9_R2.InventoryLargeChest;
import net.minecraft.server.v1_9_R2.TileEntity;
import net.minecraft.server.v1_9_R2.TileEntityChest;
import net.minecraft.server.v1_9_R2.World;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Block;
import net.minecraft.server.v1_10_R1.BlockChest;
import net.minecraft.server.v1_10_R1.BlockChest.Type;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityOcelot;
import net.minecraft.server.v1_10_R1.EntityPlayer;
import net.minecraft.server.v1_10_R1.EnumDirection;
import net.minecraft.server.v1_10_R1.ITileInventory;
import net.minecraft.server.v1_10_R1.InventoryLargeChest;
import net.minecraft.server.v1_10_R1.TileEntity;
import net.minecraft.server.v1_10_R1.TileEntityChest;
import net.minecraft.server.v1_10_R1.World;
public class AnySilentChest {
@ -78,6 +78,7 @@ public class AnySilentChest {
return this.blockOnTop(world, position) || this.ocelotOnTop(world, position);
}
@SuppressWarnings("deprecation")
private boolean blockOnTop(World world, BlockPosition position) {
Block block = world.getType(position.up()).getBlock();
return block.isOccluding(block.getBlockData());

View file

@ -4,8 +4,8 @@ import java.util.Iterator;
import com.google.common.collect.Iterators;
import net.minecraft.server.v1_9_R2.EnumDirection;
import net.minecraft.server.v1_9_R2.EnumDirection.EnumDirectionLimit;
import net.minecraft.server.v1_10_R1.EnumDirection;
import net.minecraft.server.v1_10_R1.EnumDirection.EnumDirectionLimit;
public enum EnumDirectionList implements Iterable<EnumDirection> {

View file

@ -18,14 +18,14 @@ package com.lishid.openinv.internal;
import java.lang.reflect.Field;
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftInventory;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftInventory;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.Inventory;
import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
import net.minecraft.server.v1_9_R2.IInventory;
import net.minecraft.server.v1_10_R1.IInventory;
public class InventoryAccess {

View file

@ -20,15 +20,15 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_9_R2.CraftServer;
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_9_R2.EntityPlayer;
import net.minecraft.server.v1_9_R2.MinecraftServer;
import net.minecraft.server.v1_9_R2.PlayerInteractManager;
import net.minecraft.server.v1_10_R1.EntityPlayer;
import net.minecraft.server.v1_10_R1.MinecraftServer;
import net.minecraft.server.v1_10_R1.PlayerInteractManager;
public class PlayerDataManager {

View file

@ -3,18 +3,18 @@ package com.lishid.openinv.internal;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.InventoryHolder;
import net.minecraft.server.v1_9_R2.ChestLock;
import net.minecraft.server.v1_9_R2.Container;
import net.minecraft.server.v1_9_R2.ContainerChest;
import net.minecraft.server.v1_9_R2.EntityHuman;
import net.minecraft.server.v1_9_R2.IChatBaseComponent;
import net.minecraft.server.v1_9_R2.ITileInventory;
import net.minecraft.server.v1_9_R2.ItemStack;
import net.minecraft.server.v1_9_R2.PlayerInventory;
import net.minecraft.server.v1_10_R1.ChestLock;
import net.minecraft.server.v1_10_R1.Container;
import net.minecraft.server.v1_10_R1.ContainerChest;
import net.minecraft.server.v1_10_R1.EntityHuman;
import net.minecraft.server.v1_10_R1.IChatBaseComponent;
import net.minecraft.server.v1_10_R1.ITileInventory;
import net.minecraft.server.v1_10_R1.ItemStack;
import net.minecraft.server.v1_10_R1.PlayerInventory;
public class SilentInventory implements ITileInventory {

View file

@ -16,15 +16,18 @@
package com.lishid.openinv.internal;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftInventory;
import java.lang.reflect.Field;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftInventory;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import net.minecraft.server.v1_9_R2.InventoryEnderChest;
import net.minecraft.server.v1_9_R2.InventorySubcontainer;
import net.minecraft.server.v1_10_R1.InventoryEnderChest;
import net.minecraft.server.v1_10_R1.InventorySubcontainer;
import net.minecraft.server.v1_10_R1.ItemStack;
public class SpecialEnderChest extends InventorySubcontainer {
@ -41,8 +44,8 @@ public class SpecialEnderChest extends InventorySubcontainer {
super(enderChest.getName(), enderChest.hasCustomName(), enderChest.getSize());
this.owner = (CraftPlayer) p;
this.enderChest = enderChest;
this.items = this.enderChest.getContents();
this.playerOnline = online;
reflectContents(getClass().getSuperclass(), this, this.enderChest.getContents());
}
private void saveOnExit() {
@ -51,8 +54,24 @@ public class SpecialEnderChest extends InventorySubcontainer {
}
}
private void reflectContents(Class clazz, InventorySubcontainer enderChest, ItemStack[] items) {
try {
Field itemsField = clazz.getDeclaredField("items");
itemsField.setAccessible(true);
itemsField.set(enderChest, items);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
private void linkInventory(InventoryEnderChest inventory) {
inventory.items = this.items;
reflectContents(inventory.getClass(), inventory, this.items);
}
public Inventory getBukkitInventory() {
@ -61,6 +80,7 @@ public class SpecialEnderChest extends InventorySubcontainer {
public boolean inventoryRemovalCheck(boolean save) {
boolean offline = transaction.isEmpty() && !playerOnline;
if (offline && save) {
owner.saveData();
}

View file

@ -18,16 +18,16 @@ package com.lishid.openinv.internal;
import java.lang.reflect.Field;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftInventory;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftInventory;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import net.minecraft.server.v1_9_R2.ContainerUtil;
import net.minecraft.server.v1_9_R2.EntityHuman;
import net.minecraft.server.v1_9_R2.ItemStack;
import net.minecraft.server.v1_9_R2.PlayerInventory;
import net.minecraft.server.v1_10_R1.ContainerUtil;
import net.minecraft.server.v1_10_R1.EntityHuman;
import net.minecraft.server.v1_10_R1.ItemStack;
import net.minecraft.server.v1_10_R1.PlayerInventory;
public class SpecialPlayerInventory extends PlayerInventory {
@ -80,6 +80,7 @@ public class SpecialPlayerInventory extends PlayerInventory {
public boolean inventoryRemovalCheck(boolean save) {
boolean offline = transaction.isEmpty() && !playerOnline;
if (offline && save) {
owner.saveData();
}

View file

@ -10,9 +10,9 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
public final class UUIDUtil {
public final class UUIDUtils {
private UUIDUtil() {}
private UUIDUtils() {}
private static Player getPlayer(String name) {
Validate.notNull(name, "Name cannot be null");
@ -50,7 +50,7 @@ public final class UUIDUtil {
* @param name the name of the player to get the UUID of
* @return the player's UUID or null
*/
public static UUID getUUIDOf(String name) {
public static UUID getPlayerUUID(String name) {
UUID uuid;
Player player = getPlayer(name);

View file

@ -1,6 +1,6 @@
name: OpenInv
main: com.lishid.openinv.OpenInv
version: 2.3.8
version: 2.3.9
author: lishid
authors: [ShadowRanger]
description: >