Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c0f513177a | ||
|
b3a3947b03 | ||
|
c7bab7d451 | ||
|
4058463f7f | ||
|
21cd1926ae |
@@ -17,12 +17,17 @@
|
|||||||
package com.lishid.openinv.commands;
|
package com.lishid.openinv.commands;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.Permissions;
|
import com.lishid.openinv.Permissions;
|
||||||
@@ -37,6 +42,7 @@ public class OpenEnderPluginCommand implements CommandExecutor {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
|
sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
|
||||||
@@ -53,8 +59,7 @@ public class OpenEnderPluginCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
boolean offline = false;
|
|
||||||
|
|
||||||
// History management
|
// History management
|
||||||
String history = openEnderHistory.get(player);
|
String history = openEnderHistory.get(player);
|
||||||
@@ -64,55 +69,78 @@ public class OpenEnderPluginCommand implements CommandExecutor {
|
|||||||
openEnderHistory.put(player, history);
|
openEnderHistory.put(player, history);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Target selecting
|
final String name;
|
||||||
Player target;
|
|
||||||
|
|
||||||
String name = "";
|
|
||||||
|
|
||||||
// Read from history if target is not named
|
// Read from history if target is not named
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
if (history != null && history != "") {
|
|
||||||
name = history;
|
name = history;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
sender.sendMessage(ChatColor.RED + "OpenEnder history is empty!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
name = args[0];
|
name = args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
target = this.plugin.getServer().getPlayer(name);
|
final UUID senderID = player.getUniqueId();
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
List<Player> matches = Bukkit.matchPlayer(name);
|
||||||
|
if (!matches.isEmpty()) {
|
||||||
|
openInventory(player, matches.get(0).getUniqueId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name);
|
||||||
|
if (Bukkit.getPlayer(senderID) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (offlinePlayer == null || !offlinePlayer.hasPlayedBefore()) {
|
||||||
|
player.sendMessage(ChatColor.RED + "Player not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (Bukkit.getPlayer(senderID) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
openInventory(player, offlinePlayer.getUniqueId());
|
||||||
|
}
|
||||||
|
}.runTask(plugin);
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(plugin);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openInventory(Player player, UUID uuid) {
|
||||||
|
|
||||||
|
Player target = this.plugin.getServer().getPlayer(uuid);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
// Try loading the player's data
|
// Try loading the player's data
|
||||||
target = OpenInv.playerLoader.loadPlayer(name);
|
target = OpenInv.playerLoader.loadPlayer(uuid);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
sender.sendMessage(ChatColor.RED + "Player " + name + " not found!");
|
player.sendMessage(ChatColor.RED + "Player not found!");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target != sender && !OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST_ALL)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "You do not have permission to access other player's enderchest");
|
if (target != player && !OpenInv.hasPermission(player, Permissions.PERM_ENDERCHEST_ALL)) {
|
||||||
return true;
|
player.sendMessage(ChatColor.RED + "You do not have permission to access other player's enderchest");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record the target
|
// Record the target
|
||||||
history = target.getName();
|
openEnderHistory.put(player, target.getName());
|
||||||
openEnderHistory.put(player, history);
|
|
||||||
|
|
||||||
// Create the inventory
|
// Create the inventory
|
||||||
ISpecialEnderChest chest = OpenInv.enderChests.get(target.getName().toLowerCase());
|
ISpecialEnderChest chest = OpenInv.enderChests.get(target.getName().toLowerCase());
|
||||||
if (chest == null) {
|
if (chest == null) {
|
||||||
chest = InternalAccessor.Instance.newSpecialEnderChest(target, !offline);
|
chest = InternalAccessor.Instance.newSpecialEnderChest(target, !target.isOnline());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the inventory
|
// Open the inventory
|
||||||
player.openInventory(chest.getBukkitInventory());
|
player.openInventory(chest.getBukkitInventory());
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,12 +17,17 @@
|
|||||||
package com.lishid.openinv.commands;
|
package com.lishid.openinv.commands;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.Permissions;
|
import com.lishid.openinv.Permissions;
|
||||||
@@ -37,6 +42,7 @@ public class OpenInvPluginCommand implements CommandExecutor {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
|
sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
|
||||||
@@ -52,8 +58,7 @@ public class OpenInvPluginCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
boolean offline = false;
|
|
||||||
|
|
||||||
// History management
|
// History management
|
||||||
String history = openInvHistory.get(player);
|
String history = openInvHistory.get(player);
|
||||||
@@ -63,10 +68,7 @@ public class OpenInvPluginCommand implements CommandExecutor {
|
|||||||
openInvHistory.put(player, history);
|
openInvHistory.put(player, history);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Target selecting
|
final String name;
|
||||||
Player target;
|
|
||||||
|
|
||||||
String name = "";
|
|
||||||
|
|
||||||
// Read from history if target is not named
|
// Read from history if target is not named
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
@@ -76,51 +78,80 @@ public class OpenInvPluginCommand implements CommandExecutor {
|
|||||||
name = args[0];
|
name = args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
target = this.plugin.getServer().getPlayer(name);
|
final UUID senderID = player.getUniqueId();
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
List<Player> matches = Bukkit.matchPlayer(name);
|
||||||
|
if (!matches.isEmpty()) {
|
||||||
|
openInventory(player, matches.get(0).getUniqueId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name);
|
||||||
|
if (Bukkit.getPlayer(senderID) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (offlinePlayer == null || !offlinePlayer.hasPlayedBefore()) {
|
||||||
|
player.sendMessage(ChatColor.RED + "Player not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (Bukkit.getPlayer(senderID) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
openInventory(player, offlinePlayer.getUniqueId());
|
||||||
|
}
|
||||||
|
}.runTask(plugin);
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(plugin);
|
||||||
|
|
||||||
if (target == null) {
|
|
||||||
if (target == null) {
|
|
||||||
// Try loading the player's data
|
|
||||||
target = OpenInv.playerLoader.loadPlayer(name);
|
|
||||||
|
|
||||||
if (target == null) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Player " + name + " not found!");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openInventory(Player player, UUID uuid) {
|
||||||
|
|
||||||
|
Player target = this.plugin.getServer().getPlayer(uuid);
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
|
// Try loading the player's data
|
||||||
|
target = OpenInv.playerLoader.loadPlayer(uuid);
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
|
player.sendMessage(ChatColor.RED + "Player not found!");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permissions checks
|
// Permissions checks
|
||||||
if (!OpenInv.hasPermission(player, Permissions.PERM_OVERRIDE) && OpenInv.hasPermission(target, Permissions.PERM_EXEMPT)) {
|
if (!OpenInv.hasPermission(player, Permissions.PERM_OVERRIDE) && OpenInv.hasPermission(target, Permissions.PERM_EXEMPT)) {
|
||||||
sender.sendMessage(ChatColor.RED + target.getDisplayName() + "'s inventory is protected!");
|
player.sendMessage(ChatColor.RED + target.getDisplayName() + "'s inventory is protected!");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crosswork check
|
// Crosswork check
|
||||||
if ((!OpenInv.hasPermission(player, Permissions.PERM_CROSSWORLD) && !OpenInv.hasPermission(player, Permissions.PERM_OVERRIDE)) && target.getWorld() != player.getWorld()) {
|
if ((!OpenInv.hasPermission(player, Permissions.PERM_CROSSWORLD) && !OpenInv.hasPermission(player, Permissions.PERM_OVERRIDE)) && target.getWorld() != player.getWorld()) {
|
||||||
sender.sendMessage(ChatColor.RED + target.getDisplayName() + " is not in your world!");
|
player.sendMessage(ChatColor.RED + target.getDisplayName() + " is not in your world!");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Self-open check
|
// Self-open check
|
||||||
if (!OpenInv.hasPermission(player, Permissions.PERM_OPENSELF) && target.equals(player)) {
|
if (!OpenInv.hasPermission(player, Permissions.PERM_OPENSELF) && target.equals(player)) {
|
||||||
sender.sendMessage(ChatColor.RED + "You're not allowed to openinv yourself.");
|
player.sendMessage(ChatColor.RED + "You're not allowed to openinv yourself.");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record the target
|
// Record the target
|
||||||
history = target.getName();
|
openInvHistory.put(player, target.getName());
|
||||||
openInvHistory.put(player, history);
|
|
||||||
|
|
||||||
// Create the inventory
|
// Create the inventory
|
||||||
ISpecialPlayerInventory inv = OpenInv.inventories.get(target.getName().toLowerCase());
|
ISpecialPlayerInventory inv = OpenInv.inventories.get(target.getName().toLowerCase());
|
||||||
if (inv == null) {
|
if (inv == null) {
|
||||||
inv = InternalAccessor.Instance.newSpecialPlayerInventory(target, !offline);
|
inv = InternalAccessor.Instance.newSpecialPlayerInventory(target, !target.isOnline());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the inventory
|
// Open the inventory
|
||||||
player.openInventory(inv.getBukkitInventory());
|
player.openInventory(inv.getBukkitInventory());
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
package com.lishid.openinv.internal;
|
package com.lishid.openinv.internal;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public interface IPlayerDataManager {
|
public interface IPlayerDataManager {
|
||||||
public Player loadPlayer(String name);
|
public Player loadPlayer(String name);
|
||||||
|
public Player loadPlayer(UUID uuid);
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_8_R1;
|
package com.lishid.openinv.internal.v1_8_R3;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -22,17 +22,21 @@ import org.bukkit.entity.Player;
|
|||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.internal.IAnySilentChest;
|
import com.lishid.openinv.internal.IAnySilentChest;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Volatile
|
//Volatile
|
||||||
import net.minecraft.server.v1_8_R1.*;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R1.entity.*;
|
import net.minecraft.server.v1_8_R3.Block;
|
||||||
|
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_8_R3.IInventory;
|
||||||
|
import net.minecraft.server.v1_8_R3.ITileInventory;
|
||||||
|
import net.minecraft.server.v1_8_R3.InventoryLargeChest;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
|
||||||
|
import net.minecraft.server.v1_8_R3.TileEntityChest;
|
||||||
|
import net.minecraft.server.v1_8_R3.World;
|
||||||
|
|
||||||
public class AnySilentChest implements IAnySilentChest {
|
public class AnySilentChest implements IAnySilentChest {
|
||||||
|
@Override
|
||||||
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
|
||||||
EntityPlayer player = ((CraftPlayer) p).getHandle();
|
EntityPlayer player = ((CraftPlayer) p).getHandle();
|
||||||
@@ -56,10 +60,11 @@ public class AnySilentChest implements IAnySilentChest {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
|
public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
|
||||||
EntityPlayer player = ((CraftPlayer) p).getHandle();
|
EntityPlayer player = ((CraftPlayer) p).getHandle();
|
||||||
World world = player.world;
|
World world = player.world;
|
||||||
Object chest = (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z));
|
Object chest = world.getTileEntity(new BlockPosition(x, y, z));
|
||||||
if (chest == null)
|
if (chest == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
@@ -14,7 +14,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_8_R1;
|
package com.lishid.openinv.internal.v1_8_R3;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
@@ -26,10 +26,12 @@ import com.lishid.openinv.Permissions;
|
|||||||
import com.lishid.openinv.internal.IInventoryAccess;
|
import com.lishid.openinv.internal.IInventoryAccess;
|
||||||
|
|
||||||
//Volatile
|
//Volatile
|
||||||
import net.minecraft.server.v1_8_R1.*;
|
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory;
|
||||||
import org.bukkit.craftbukkit.v1_8_R1.inventory.*;
|
|
||||||
|
import net.minecraft.server.v1_8_R3.IInventory;
|
||||||
|
|
||||||
public class InventoryAccess implements IInventoryAccess {
|
public class InventoryAccess implements IInventoryAccess {
|
||||||
|
@Override
|
||||||
public boolean check(Inventory inventory, HumanEntity player) {
|
public boolean check(Inventory inventory, HumanEntity player) {
|
||||||
IInventory inv = grabInventory(inventory);
|
IInventory inv = grabInventory(inventory);
|
||||||
|
|
@@ -14,7 +14,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_8_R1;
|
package com.lishid.openinv.internal.v1_8_R3;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -28,11 +28,14 @@ import com.lishid.openinv.internal.IPlayerDataManager;
|
|||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
//Volatile
|
//Volatile
|
||||||
import net.minecraft.server.v1_8_R1.*;
|
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R1.*;
|
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||||
|
import net.minecraft.server.v1_8_R3.PlayerInteractManager;
|
||||||
|
|
||||||
public class PlayerDataManager implements IPlayerDataManager {
|
public class PlayerDataManager implements IPlayerDataManager {
|
||||||
|
@Override
|
||||||
public Player loadPlayer(String name) {
|
public Player loadPlayer(String name) {
|
||||||
try {
|
try {
|
||||||
UUID uuid = matchUser(name);
|
UUID uuid = matchUser(name);
|
||||||
@@ -101,4 +104,29 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.lishid.openinv.internal.IPlayerDataManager#loadPlayer(java.util.UUID)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Player loadPlayer(UUID uuid) {
|
||||||
|
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
|
||||||
|
if (player == null || !player.hasPlayedBefore()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GameProfile profile = new GameProfile(uuid, player.getName());
|
||||||
|
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
|
// Create an entity to load the player data
|
||||||
|
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
|
||||||
|
|
||||||
|
// Get the bukkit entity
|
||||||
|
Player target = (entity == null) ? null : entity.getBukkitEntity();
|
||||||
|
if (target != null) {
|
||||||
|
// Load data
|
||||||
|
target.loadData();
|
||||||
|
// Return the entity
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -14,10 +14,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_8_R1;
|
package com.lishid.openinv.internal.v1_8_R3;
|
||||||
|
|
||||||
//Volatile
|
//Volatile
|
||||||
import net.minecraft.server.v1_8_R1.*;
|
import net.minecraft.server.v1_8_R3.ContainerChest;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||||
|
import net.minecraft.server.v1_8_R3.IInventory;
|
||||||
|
|
||||||
public class SilentContainerChest extends ContainerChest {
|
public class SilentContainerChest extends ContainerChest {
|
||||||
public IInventory inv;
|
public IInventory inv;
|
@@ -14,32 +14,38 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_8_R1;
|
package com.lishid.openinv.internal.v1_8_R3;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
|
||||||
import com.lishid.openinv.internal.ISpecialEnderChest;
|
|
||||||
|
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
|
import com.lishid.openinv.OpenInv;
|
||||||
|
import com.lishid.openinv.internal.ISpecialEnderChest;
|
||||||
|
|
||||||
//Volatile
|
//Volatile
|
||||||
import net.minecraft.server.v1_8_R1.*;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity;
|
||||||
import org.bukkit.craftbukkit.v1_8_R1.entity.*;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_8_R1.inventory.*;
|
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||||
|
import net.minecraft.server.v1_8_R3.IInventory;
|
||||||
|
import net.minecraft.server.v1_8_R3.InventoryEnderChest;
|
||||||
|
import net.minecraft.server.v1_8_R3.InventorySubcontainer;
|
||||||
|
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||||
|
|
||||||
public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
|
public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
|
||||||
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
|
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
|
||||||
public boolean playerOnline = false;
|
public boolean playerOnline = false;
|
||||||
private CraftPlayer owner;
|
private final CraftPlayer owner;
|
||||||
private InventoryEnderChest enderChest;
|
private final InventoryEnderChest enderChest;
|
||||||
private int maxStack = MAX_STACK;
|
private int maxStack = MAX_STACK;
|
||||||
private CraftInventory inventory = new CraftInventory(this);
|
private final CraftInventory inventory = new CraftInventory(this);
|
||||||
|
|
||||||
public SpecialEnderChest(Player p, Boolean online) {
|
public SpecialEnderChest(Player p, Boolean online) {
|
||||||
super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().hasCustomName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
|
super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().hasCustomName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
|
||||||
@@ -50,10 +56,12 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
|
|||||||
OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
|
OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Inventory getBukkitInventory() {
|
public Inventory getBukkitInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void InventoryRemovalCheck() {
|
public void InventoryRemovalCheck() {
|
||||||
owner.saveData();
|
owner.saveData();
|
||||||
if (transaction.isEmpty() && !playerOnline) {
|
if (transaction.isEmpty() && !playerOnline) {
|
||||||
@@ -61,6 +69,7 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void PlayerGoOnline(Player p) {
|
public void PlayerGoOnline(Player p) {
|
||||||
if (!playerOnline) {
|
if (!playerOnline) {
|
||||||
try {
|
try {
|
||||||
@@ -75,39 +84,48 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void PlayerGoOffline() {
|
public void PlayerGoOffline() {
|
||||||
playerOnline = false;
|
playerOnline = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack[] getContents() {
|
public ItemStack[] getContents() {
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onOpen(CraftHumanEntity who) {
|
public void onOpen(CraftHumanEntity who) {
|
||||||
transaction.add(who);
|
transaction.add(who);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onClose(CraftHumanEntity who) {
|
public void onClose(CraftHumanEntity who) {
|
||||||
transaction.remove(who);
|
transaction.remove(who);
|
||||||
this.InventoryRemovalCheck();
|
this.InventoryRemovalCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<HumanEntity> getViewers() {
|
public List<HumanEntity> getViewers() {
|
||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public InventoryHolder getOwner() {
|
public InventoryHolder getOwner() {
|
||||||
return this.owner;
|
return this.owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMaxStackSize(int size) {
|
public void setMaxStackSize(int size) {
|
||||||
maxStack = size;
|
maxStack = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getMaxStackSize() {
|
public int getMaxStackSize() {
|
||||||
return maxStack;
|
return maxStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean a(EntityHuman entityhuman) {
|
public boolean a(EntityHuman entityhuman) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -120,6 +138,7 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
enderChest.update();
|
enderChest.update();
|
||||||
}
|
}
|
@@ -14,7 +14,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_8_R1;
|
package com.lishid.openinv.internal.v1_8_R3;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@@ -23,15 +23,19 @@ import com.lishid.openinv.OpenInv;
|
|||||||
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
||||||
|
|
||||||
//Volatile
|
//Volatile
|
||||||
import net.minecraft.server.v1_8_R1.*;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity;
|
||||||
import org.bukkit.craftbukkit.v1_8_R1.entity.*;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_8_R1.inventory.*;
|
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||||
|
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||||
|
import net.minecraft.server.v1_8_R3.PlayerInventory;
|
||||||
|
|
||||||
public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
|
public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
|
||||||
CraftPlayer owner;
|
CraftPlayer owner;
|
||||||
public boolean playerOnline = false;
|
public boolean playerOnline = false;
|
||||||
private ItemStack[] extra = new ItemStack[5];
|
private final ItemStack[] extra = new ItemStack[5];
|
||||||
private CraftInventory inventory = new CraftInventory(this);
|
private final CraftInventory inventory = new CraftInventory(this);
|
||||||
|
|
||||||
public SpecialPlayerInventory(Player p, Boolean online) {
|
public SpecialPlayerInventory(Player p, Boolean online) {
|
||||||
super(((CraftPlayer) p).getHandle());
|
super(((CraftPlayer) p).getHandle());
|
||||||
@@ -82,7 +86,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
|
|||||||
public ItemStack[] getContents() {
|
public ItemStack[] getContents() {
|
||||||
ItemStack[] C = new ItemStack[getSize()];
|
ItemStack[] C = new ItemStack[getSize()];
|
||||||
System.arraycopy(items, 0, C, 0, items.length);
|
System.arraycopy(items, 0, C, 0, items.length);
|
||||||
System.arraycopy(items, 0, C, items.length, armor.length);
|
System.arraycopy(armor, 0, C, items.length, armor.length);
|
||||||
return C;
|
return C;
|
||||||
}
|
}
|
||||||
|
|
@@ -1,6 +1,6 @@
|
|||||||
name: OpenInv
|
name: OpenInv
|
||||||
main: com.lishid.openinv.OpenInv
|
main: com.lishid.openinv.OpenInv
|
||||||
version: 2.2.5
|
version: 2.2.8
|
||||||
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.
|
||||||
|
Reference in New Issue
Block a user