mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2025-01-03 13:38:21 +00:00
Merge pull request #37 from ShadowRanger/master
Update to CraftBukkit 1.9
This commit is contained in:
commit
7b16140ee1
23 changed files with 256 additions and 182 deletions
2
README
2
README
|
@ -1,4 +1,4 @@
|
||||||
Copyright (C) 2011-2014 lishid. All rights reserved.
|
Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
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>
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import com.lishid.openinv.utils.UUIDUtil;
|
import com.lishid.openinv.utils.UUIDUtil;
|
||||||
|
|
||||||
public class ConfigUpdater {
|
public class ConfigUpdater {
|
||||||
|
|
||||||
private final OpenInv plugin;
|
private final OpenInv plugin;
|
||||||
|
|
||||||
private static final int CONFIG_VERSION = 2;
|
private static final int CONFIG_VERSION = 2;
|
||||||
|
@ -33,8 +34,7 @@ public class ConfigUpdater {
|
||||||
if (isConfigOutdated()) {
|
if (isConfigOutdated()) {
|
||||||
plugin.getLogger().info("[Config] Update found! Performing update...");
|
plugin.getLogger().info("[Config] Update found! Performing update...");
|
||||||
performUpdate();
|
performUpdate();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
plugin.getLogger().info("[Config] Update not required.");
|
plugin.getLogger().info("[Config] Update not required.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,7 @@ public class ConfigUpdater {
|
||||||
|
|
||||||
for (String playerName : keys) {
|
for (String playerName : keys) {
|
||||||
UUID uuid = UUIDUtil.getUUIDOf(playerName);
|
UUID uuid = UUIDUtil.getUUIDOf(playerName);
|
||||||
|
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
boolean toggled = section.getBoolean(playerName + ".toggle", false);
|
boolean toggled = section.getBoolean(playerName + ".toggle", false);
|
||||||
toggles.put(uuid, toggled);
|
toggles.put(uuid, toggled);
|
||||||
|
@ -152,9 +153,11 @@ public class ConfigUpdater {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private Material getMaterialById(int id) {
|
private Material getMaterialById(int id) {
|
||||||
Material material = Material.getMaterial(id);
|
Material material = Material.getMaterial(id);
|
||||||
|
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
material = Material.STICK;
|
material = Material.STICK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -20,6 +20,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -44,12 +45,8 @@ import com.lishid.openinv.listeners.OpenInvEntityListener;
|
||||||
import com.lishid.openinv.listeners.OpenInvInventoryListener;
|
import com.lishid.openinv.listeners.OpenInvInventoryListener;
|
||||||
import com.lishid.openinv.listeners.OpenInvPlayerListener;
|
import com.lishid.openinv.listeners.OpenInvPlayerListener;
|
||||||
|
|
||||||
/**
|
|
||||||
* Open other player's inventory
|
|
||||||
*
|
|
||||||
* @author lishid
|
|
||||||
*/
|
|
||||||
public class OpenInv extends JavaPlugin {
|
public class OpenInv extends JavaPlugin {
|
||||||
|
|
||||||
public static final Map<UUID, SpecialPlayerInventory> inventories = new HashMap<UUID, SpecialPlayerInventory>();
|
public static final Map<UUID, SpecialPlayerInventory> inventories = new HashMap<UUID, SpecialPlayerInventory>();
|
||||||
public static final Map<UUID, SpecialEnderChest> enderChests = new HashMap<UUID, SpecialEnderChest>();
|
public static final Map<UUID, SpecialEnderChest> enderChests = new HashMap<UUID, SpecialEnderChest>();
|
||||||
|
|
||||||
|
@ -113,11 +110,11 @@ public class OpenInv extends JavaPlugin {
|
||||||
|
|
||||||
public static Object getFromConfig(String path, Object defaultValue) {
|
public static Object getFromConfig(String path, Object defaultValue) {
|
||||||
Object val = mainPlugin.getConfig().get(path);
|
Object val = mainPlugin.getConfig().get(path);
|
||||||
|
|
||||||
if (val == null) {
|
if (val == null) {
|
||||||
mainPlugin.getConfig().set(path, defaultValue);
|
mainPlugin.getConfig().set(path, defaultValue);
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,12 +212,15 @@ public class OpenInv extends JavaPlugin {
|
||||||
public static boolean hasPermission(Permissible player, String permission) {
|
public static boolean hasPermission(Permissible player, String permission) {
|
||||||
String[] parts = permission.split("\\.");
|
String[] parts = permission.split("\\.");
|
||||||
String perm = "";
|
String perm = "";
|
||||||
|
|
||||||
for (int i = 0; i < parts.length; i++) {
|
for (int i = 0; i < parts.length; i++) {
|
||||||
if (player.hasPermission(perm + "*")) {
|
if (player.hasPermission(perm + "*")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
perm += parts[i] + ".";
|
perm += parts[i] + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
return player.hasPermission(permission);
|
return player.hasPermission(permission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,6 +26,7 @@ import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.Permissions;
|
import com.lishid.openinv.Permissions;
|
||||||
|
|
||||||
public class AnyChestCommand implements CommandExecutor {
|
public class AnyChestCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (command.getName().equalsIgnoreCase("anychest")) {
|
if (command.getName().equalsIgnoreCase("anychest")) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -33,6 +33,7 @@ import com.lishid.openinv.internal.SpecialEnderChest;
|
||||||
import com.lishid.openinv.utils.UUIDUtil;
|
import com.lishid.openinv.utils.UUIDUtil;
|
||||||
|
|
||||||
public class OpenEnderCommand implements CommandExecutor {
|
public class OpenEnderCommand implements CommandExecutor {
|
||||||
|
|
||||||
private final OpenInv plugin;
|
private final OpenInv plugin;
|
||||||
private final Map<UUID, UUID> openEnderHistory = new ConcurrentHashMap<UUID, UUID>();
|
private final Map<UUID, UUID> openEnderHistory = new ConcurrentHashMap<UUID, UUID>();
|
||||||
|
|
||||||
|
@ -73,8 +74,7 @@ public class OpenEnderCommand implements CommandExecutor {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
if (history != null) {
|
if (history != null) {
|
||||||
uuid = history;
|
uuid = history;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sender.sendMessage(ChatColor.RED + "OpenEnder history is empty!");
|
sender.sendMessage(ChatColor.RED + "OpenEnder history is empty!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ public class OpenEnderCommand implements CommandExecutor {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
openInventory(player, target);
|
openInventory(player, target);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -33,6 +33,7 @@ import com.lishid.openinv.internal.SpecialPlayerInventory;
|
||||||
import com.lishid.openinv.utils.UUIDUtil;
|
import com.lishid.openinv.utils.UUIDUtil;
|
||||||
|
|
||||||
public class OpenInvCommand implements CommandExecutor {
|
public class OpenInvCommand implements CommandExecutor {
|
||||||
|
|
||||||
private final OpenInv plugin;
|
private final OpenInv plugin;
|
||||||
private final Map<UUID, UUID> openInvHistory = new ConcurrentHashMap<UUID, UUID>();
|
private final Map<UUID, UUID> openInvHistory = new ConcurrentHashMap<UUID, UUID>();
|
||||||
|
|
||||||
|
@ -147,10 +148,14 @@ public class OpenInvCommand implements CommandExecutor {
|
||||||
openInvHistory.put(player.getUniqueId(), target.getUniqueId());
|
openInvHistory.put(player.getUniqueId(), target.getUniqueId());
|
||||||
|
|
||||||
// Create the inventory
|
// Create the inventory
|
||||||
|
/*
|
||||||
SpecialPlayerInventory inv = OpenInv.inventories.get(target.getUniqueId());
|
SpecialPlayerInventory inv = OpenInv.inventories.get(target.getUniqueId());
|
||||||
if (inv == null) {
|
if (inv == null) {
|
||||||
inv = new SpecialPlayerInventory(target, target.isOnline());
|
inv = new SpecialPlayerInventory(target, target.isOnline());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
SpecialPlayerInventory inv = new SpecialPlayerInventory(target, target.isOnline());
|
||||||
|
|
||||||
// Open the inventory
|
// Open the inventory
|
||||||
player.openInventory(inv.getBukkitInventory());
|
player.openInventory(inv.getBukkitInventory());
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.Permissions;
|
import com.lishid.openinv.Permissions;
|
||||||
|
|
||||||
public class SearchEnderCommand implements CommandExecutor {
|
public class SearchEnderCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (command.getName().equalsIgnoreCase("searchender")) {
|
if (command.getName().equalsIgnoreCase("searchender")) {
|
||||||
|
@ -30,11 +31,11 @@ public class SearchEnderCommand implements CommandExecutor {
|
||||||
gData = args[0].split(":");
|
gData = args[0].split(":");
|
||||||
material = Material.matchMaterial(gData[0]);
|
material = Material.matchMaterial(gData[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
try {
|
try {
|
||||||
count = Integer.parseInt(args[1]);
|
count = Integer.parseInt(args[1]);
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch (NumberFormatException ex) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number!");
|
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -28,6 +28,7 @@ import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.Permissions;
|
import com.lishid.openinv.Permissions;
|
||||||
|
|
||||||
public class SearchInvCommand implements CommandExecutor {
|
public class SearchInvCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (command.getName().equalsIgnoreCase("searchinv")) {
|
if (command.getName().equalsIgnoreCase("searchinv")) {
|
||||||
|
@ -46,11 +47,11 @@ public class SearchInvCommand implements CommandExecutor {
|
||||||
gData = args[0].split(":");
|
gData = args[0].split(":");
|
||||||
material = Material.matchMaterial(gData[0]);
|
material = Material.matchMaterial(gData[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
try {
|
try {
|
||||||
count = Integer.parseInt(args[1]);
|
count = Integer.parseInt(args[1]);
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch (NumberFormatException ex) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number!");
|
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,6 +26,7 @@ import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.Permissions;
|
import com.lishid.openinv.Permissions;
|
||||||
|
|
||||||
public class SilentChestCommand implements CommandExecutor {
|
public class SilentChestCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (command.getName().equalsIgnoreCase("silentchest")) {
|
if (command.getName().equalsIgnoreCase("silentchest")) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,6 +26,7 @@ import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.Permissions;
|
import com.lishid.openinv.Permissions;
|
||||||
|
|
||||||
public class ToggleOpenInvCommand implements CommandExecutor {
|
public class ToggleOpenInvCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (command.getName().equalsIgnoreCase("toggleopeninv")) {
|
if (command.getName().equalsIgnoreCase("toggleopeninv")) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,29 +23,32 @@ 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) {
|
||||||
// FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
|
// FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
|
||||||
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 a block is on top
|
||||||
if (topBlocking(world, position)) {
|
if (topBlocking(world, position)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If block next to chest is chest and has a block on top
|
// If the block next to the chest is chest and has a block on top
|
||||||
for (EnumDirection direction : EnumDirectionList.HORIZONTAL) {
|
for (EnumDirection direction : EnumDirectionList.HORIZONTAL) {
|
||||||
BlockPosition sidePosition = position.shift(direction);
|
BlockPosition sidePosition = position.shift(direction);
|
||||||
Block var8 = world.getType(sidePosition).getBlock();
|
Block block = world.getType(sidePosition).getBlock();
|
||||||
if (var8 == chest) {
|
|
||||||
|
if (block == chest) {
|
||||||
if (this.topBlocking(world, sidePosition)) {
|
if (this.topBlocking(world, sidePosition)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -54,29 +57,33 @@ public class AnySilentChest {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean topBlocking(World world, BlockPosition position) {
|
private boolean topBlocking(World world, BlockPosition position) {
|
||||||
return this.blockOnTop(world, position) || this.ocelotOnTop(world, position);
|
return this.blockOnTop(world, position) || this.ocelotOnTop(world, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean blockOnTop(World world, BlockPosition position) {
|
private boolean blockOnTop(World world, BlockPosition position) {
|
||||||
return world.getType(position.up()).getBlock().isOccluding();
|
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) {
|
||||||
Iterator var3 = world.a(EntityOcelot.class,
|
Iterator iterator = world.a(EntityOcelot.class,
|
||||||
new AxisAlignedBB((double) position.getX(), (double) (position.getY() + 1),
|
new AxisAlignedBB((double) position.getX(), (double) (position.getY() + 1),
|
||||||
(double) position.getZ(), (double) (position.getX() + 1),
|
(double) position.getZ(), (double) (position.getX() + 1),
|
||||||
(double) (position.getY() + 2), (double) (position.getZ() + 1))).iterator();
|
(double) (position.getY() + 2), (double) (position.getZ() + 1))).iterator();
|
||||||
|
|
||||||
EntityOcelot var5;
|
EntityOcelot entityOcelot;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!var3.hasNext()) {
|
if (!iterator.hasNext()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity var4 = (Entity) var3.next();
|
Entity entity = (Entity) iterator.next();
|
||||||
var5 = (EntityOcelot) var4;
|
|
||||||
} while (!var5.isSitting());
|
entityOcelot = (EntityOcelot) entity;
|
||||||
|
} while (!entityOcelot.isSitting());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +96,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);
|
||||||
|
@ -105,12 +112,14 @@ public class AnySilentChest {
|
||||||
for (EnumDirection direction : EnumDirectionList.HORIZONTAL) {
|
for (EnumDirection direction : EnumDirectionList.HORIZONTAL) {
|
||||||
BlockPosition side = position.shift(direction);
|
BlockPosition side = position.shift(direction);
|
||||||
Block block = world.getType(side).getBlock();
|
Block block = world.getType(side).getBlock();
|
||||||
|
|
||||||
if (block == chest) {
|
if (block == chest) {
|
||||||
if (!anyChest && this.topBlocking(world, side)) {
|
if (!anyChest && this.topBlocking(world, side)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity sideTileEntity = world.getTileEntity(side);
|
TileEntity sideTileEntity = world.getTileEntity(side);
|
||||||
|
|
||||||
if (sideTileEntity instanceof TileEntityChest) {
|
if (sideTileEntity instanceof TileEntityChest) {
|
||||||
if (direction != EnumDirection.WEST && direction != EnumDirection.NORTH) {
|
if (direction != EnumDirection.WEST && direction != EnumDirection.NORTH) {
|
||||||
tileInventory = new InventoryLargeChest("container.chestDouble", tileInventory, (TileEntityChest) sideTileEntity);
|
tileInventory = new InventoryLargeChest("container.chestDouble", tileInventory, (TileEntityChest) sideTileEntity);
|
||||||
|
@ -122,11 +131,14 @@ public class AnySilentChest {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean returnValue = true;
|
boolean returnValue = true;
|
||||||
|
|
||||||
if (silentChest) {
|
if (silentChest) {
|
||||||
tileInventory = new SilentInventory(tileInventory);
|
tileInventory = new SilentInventory(tileInventory);
|
||||||
|
|
||||||
if (OpenInv.notifySilentChest()) {
|
if (OpenInv.notifySilentChest()) {
|
||||||
OpenInv.sendMessage(p, "You are opening a chest silently.");
|
OpenInv.sendMessage(p, "You are opening a chest silently.");
|
||||||
}
|
}
|
||||||
|
|
||||||
returnValue = false;
|
returnValue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,17 @@ 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 EnumDirectionLimit list;
|
||||||
|
|
||||||
private EnumDirectionList(EnumDirectionLimit list) {
|
EnumDirectionList(EnumDirectionLimit list) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -25,11 +25,12 @@ 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) {
|
||||||
IInventory inv = grabInventory(inventory);
|
IInventory inv = grabInventory(inventory);
|
||||||
|
|
||||||
|
@ -49,24 +50,25 @@ 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);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
OpenInv.log(e);
|
OpenInv.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,17 +26,19 @@ 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) {
|
||||||
try {
|
try {
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
|
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
|
||||||
if (player == null || !player.hasPlayedBefore()) {
|
if (player == null || !player.hasPlayedBefore()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameProfile profile = new GameProfile(uuid, player.getName());
|
GameProfile profile = new GameProfile(uuid, player.getName());
|
||||||
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
// Create an entity to load the player data
|
// Create an entity to load the player data
|
||||||
|
@ -44,14 +46,15 @@ public class PlayerDataManager {
|
||||||
|
|
||||||
// Get the bukkit entity
|
// Get the bukkit entity
|
||||||
Player target = entity.getBukkitEntity();
|
Player target = entity.getBukkitEntity();
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
// Load data
|
// Load data
|
||||||
target.loadData();
|
target.loadData();
|
||||||
|
|
||||||
// Return the entity
|
// Return the entity
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
OpenInv.log(e);
|
OpenInv.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,9 +17,10 @@
|
||||||
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;
|
||||||
|
|
||||||
public SilentContainerChest(IInventory i1, IInventory i2, EntityHuman human) {
|
public SilentContainerChest(IInventory i1, IInventory i2, EntityHuman human) {
|
||||||
|
|
|
@ -2,14 +2,16 @@ 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;
|
||||||
|
|
||||||
public SilentInventory(ITileInventory inv) {
|
public SilentInventory(ITileInventory inv) {
|
||||||
|
@ -17,8 +19,8 @@ public class SilentInventory implements ITileInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean r_() {
|
public boolean x_() {
|
||||||
return inv.r_();
|
return inv.x_();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,8 +29,8 @@ public class SilentInventory implements ITileInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChestLock i() {
|
public ChestLock y_() {
|
||||||
return inv.i();
|
return inv.y_();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,8 +94,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 +138,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();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,12 +23,13 @@ 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);
|
||||||
private final InventoryEnderChest enderChest;
|
private final InventoryEnderChest enderChest;
|
||||||
private final CraftPlayer owner;
|
private final CraftPlayer owner;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,32 +16,68 @@
|
||||||
|
|
||||||
package com.lishid.openinv.internal;
|
package com.lishid.openinv.internal;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
// Volatile
|
||||||
|
import net.minecraft.server.v1_9_R1.*;
|
||||||
|
|
||||||
|
import org.bukkit.craftbukkit.v1_9_R1.entity.*;
|
||||||
|
import org.bukkit.craftbukkit.v1_9_R1.inventory.*;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
|
|
||||||
// Volatile
|
|
||||||
import net.minecraft.server.v1_8_R3.*;
|
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.*;
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
|
|
||||||
|
|
||||||
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];
|
||||||
|
private final ItemStack[][] arrays;
|
||||||
private final CraftPlayer owner;
|
private final CraftPlayer owner;
|
||||||
private boolean playerOnline;
|
private boolean playerOnline;
|
||||||
|
|
||||||
public SpecialPlayerInventory(Player p, boolean online) {
|
public SpecialPlayerInventory(Player p, boolean online) {
|
||||||
super(((CraftPlayer) p).getHandle());
|
super(((CraftPlayer) p).getHandle());
|
||||||
this.owner = (CraftPlayer) p;
|
this.owner = (CraftPlayer) p;
|
||||||
this.items = player.inventory.items;
|
reflectContents(getClass().getSuperclass(), player.inventory, this);
|
||||||
this.armor = player.inventory.armor;
|
this.arrays = new ItemStack[][] { this.items, this.armor, this.extra };
|
||||||
this.playerOnline = online;
|
this.playerOnline = online;
|
||||||
OpenInv.inventories.put(owner.getUniqueId(), this);
|
OpenInv.inventories.put(owner.getUniqueId(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reflectContents(Class clazz, PlayerInventory src, PlayerInventory dest) {
|
||||||
|
// Items
|
||||||
|
try {
|
||||||
|
Field itemsField = clazz.getDeclaredField("items");
|
||||||
|
itemsField.setAccessible(true);
|
||||||
|
itemsField.set(dest, src.items);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Armor
|
||||||
|
try {
|
||||||
|
Field armorField = clazz.getDeclaredField("armor");
|
||||||
|
armorField.setAccessible(true);
|
||||||
|
armorField.set(dest, src.armor);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Inventory getBukkitInventory() {
|
public Inventory getBukkitInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
@ -54,8 +90,7 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkInventory(PlayerInventory inventory) {
|
private void linkInventory(PlayerInventory inventory) {
|
||||||
inventory.items = this.items;
|
reflectContents(inventory.getClass(), inventory, this);
|
||||||
inventory.armor = this.armor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playerOnline(Player player) {
|
public void playerOnline(Player player) {
|
||||||
|
@ -82,99 +117,102 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack[] getContents() {
|
public ItemStack[] getContents() {
|
||||||
ItemStack[] C = new ItemStack[getSize()];
|
ItemStack[] contents = new ItemStack[getSize()];
|
||||||
System.arraycopy(items, 0, C, 0, items.length);
|
System.arraycopy(this.items, 0, contents, 0, this.items.length);
|
||||||
System.arraycopy(armor, 0, C, items.length, armor.length);
|
System.arraycopy(this.armor, 0, contents, this.items.length, this.armor.length);
|
||||||
return C;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return super.getSize() + 5;
|
return super.getSize() - this.extraSlots.length + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(int i) {
|
public ItemStack getItem(int i) {
|
||||||
ItemStack[] is = this.items;
|
ItemStack[] is = null;
|
||||||
|
ItemStack[][] contents = this.arrays;
|
||||||
|
int j = contents.length;
|
||||||
|
|
||||||
if (i >= is.length) {
|
for (int k = 0; k < j; ++k) {
|
||||||
i -= is.length;
|
ItemStack[] is2 = contents[k];
|
||||||
is = this.armor;
|
|
||||||
} else {
|
if (i < is2.length) {
|
||||||
i = getReversedItemSlotNum(i);
|
is = is2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
i -= is2.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= is.length) {
|
if (is == this.items) {
|
||||||
i -= is.length;
|
i = getReversedItemSlotNum(i);
|
||||||
is = this.extra;
|
|
||||||
} else if (is == this.armor) {
|
} else if (is == this.armor) {
|
||||||
i = getReversedArmorSlotNum(i);
|
i = getReversedArmorSlotNum(i);
|
||||||
|
} else if (is == this.extra) {
|
||||||
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
return is[i];
|
return is == null ? null : is[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack splitStack(int i, int j) {
|
public ItemStack splitStack(int i, int j) {
|
||||||
ItemStack[] is = this.items;
|
ItemStack[] is = null;
|
||||||
|
ItemStack[][] contents = this.arrays;
|
||||||
|
int k = contents.length;
|
||||||
|
|
||||||
if (i >= is.length) {
|
for (int l = 0; l < k; ++l) {
|
||||||
i -= is.length;
|
ItemStack[] is2 = contents[l];
|
||||||
is = this.armor;
|
|
||||||
} else {
|
if (i < is2.length) {
|
||||||
i = getReversedItemSlotNum(i);
|
is = is2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
i -= is2.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= is.length) {
|
if (is == this.items) {
|
||||||
i -= is.length;
|
i = getReversedItemSlotNum(i);
|
||||||
is = this.extra;
|
|
||||||
} else if (is == this.armor) {
|
} else if (is == this.armor) {
|
||||||
i = getReversedArmorSlotNum(i);
|
i = getReversedArmorSlotNum(i);
|
||||||
|
} else if (is == this.extra) {
|
||||||
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is[i] != null) {
|
return is != null && is[i] != null ? ContainerUtil.a(is, i, j) : null;
|
||||||
ItemStack itemstack;
|
|
||||||
|
|
||||||
if (is[i].count <= j) {
|
|
||||||
itemstack = is[i];
|
|
||||||
is[i] = null;
|
|
||||||
return itemstack;
|
|
||||||
} else {
|
|
||||||
itemstack = is[i].cloneAndSubtract(j);
|
|
||||||
if (is[i].count == 0) {
|
|
||||||
is[i] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemstack;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack splitWithoutUpdate(int i) {
|
public ItemStack splitWithoutUpdate(int i) {
|
||||||
ItemStack[] is = this.items;
|
ItemStack[] is = null;
|
||||||
|
ItemStack[][] contents = this.arrays;
|
||||||
|
int j = contents.length;
|
||||||
|
|
||||||
if (i >= is.length) {
|
for (int object = 0; object < j; ++object) {
|
||||||
i -= is.length;
|
ItemStack[] is2 = contents[object];
|
||||||
is = this.armor;
|
|
||||||
} else {
|
if (i < is2.length) {
|
||||||
i = getReversedItemSlotNum(i);
|
is = is2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
i -= is2.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= is.length) {
|
if (is != null && is[i] != null) {
|
||||||
i -= is.length;
|
if (is == this.items) {
|
||||||
is = this.extra;
|
i = getReversedItemSlotNum(i);
|
||||||
} else if (is == this.armor) {
|
} else if (is == this.armor) {
|
||||||
i = getReversedArmorSlotNum(i);
|
i = getReversedArmorSlotNum(i);
|
||||||
}
|
} else if (is == this.extra) {
|
||||||
|
// Do nothing
|
||||||
if (is[i] != null) {
|
}
|
||||||
ItemStack itemstack = is[i];
|
|
||||||
|
|
||||||
|
Object object = is[i];
|
||||||
is[i] = null;
|
is[i] = null;
|
||||||
return itemstack;
|
return (ItemStack) object;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -182,51 +220,46 @@ public class SpecialPlayerInventory extends PlayerInventory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItem(int i, ItemStack itemStack) {
|
public void setItem(int i, ItemStack itemStack) {
|
||||||
ItemStack[] is = this.items;
|
ItemStack[] is = null;
|
||||||
|
ItemStack[][] contents = this.arrays;
|
||||||
|
int j = contents.length;
|
||||||
|
|
||||||
if (i >= is.length) {
|
for (int k = 0; k < j; ++k) {
|
||||||
i -= is.length;
|
ItemStack[] is2 = contents[k];
|
||||||
is = this.armor;
|
|
||||||
} else {
|
if (i < is2.length) {
|
||||||
i = getReversedItemSlotNum(i);
|
is = is2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
i -= is2.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= is.length) {
|
if (is != null) {
|
||||||
i -= is.length;
|
if (is == this.items) {
|
||||||
is = this.extra;
|
i = getReversedItemSlotNum(i);
|
||||||
} else if (is == this.armor) {
|
} else if (is == this.armor) {
|
||||||
i = getReversedArmorSlotNum(i);
|
i = getReversedArmorSlotNum(i);
|
||||||
|
} else if (is == this.extra) {
|
||||||
|
owner.getHandle().drop(itemStack, true);
|
||||||
|
itemStack = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
is[i] = itemStack;
|
||||||
|
|
||||||
|
owner.getHandle().defaultContainer.b();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Effects
|
|
||||||
if (is == this.extra) {
|
|
||||||
owner.getHandle().drop(itemStack, true);
|
|
||||||
itemStack = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
is[i] = itemStack;
|
|
||||||
|
|
||||||
owner.getHandle().defaultContainer.b();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getReversedItemSlotNum(int i) {
|
private int getReversedItemSlotNum(int i) {
|
||||||
if (i >= 27)
|
return (i >= 27) ? (i - 27) : (i + 9);
|
||||||
return i - 27;
|
|
||||||
else
|
|
||||||
return i + 9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getReversedArmorSlotNum(int i) {
|
private int getReversedArmorSlotNum(int i) {
|
||||||
if (i == 0)
|
if (i == 0) return 3;
|
||||||
return 3;
|
if (i == 1) return 2;
|
||||||
if (i == 1)
|
if (i == 2) return 1;
|
||||||
return 2;
|
return (i == 3) ? 0 : i;
|
||||||
if (i == 2)
|
|
||||||
return 1;
|
|
||||||
if (i == 3)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
* Copyright (C) 2011-2016 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -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