mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2025-01-03 13:38:21 +00:00
Updated to 1.1-R6
This commit is contained in:
parent
5a1377bf76
commit
1cfe757acc
13 changed files with 82 additions and 26 deletions
2
README
2
README
|
@ -1,4 +1,4 @@
|
||||||
Copyright (C) 2011 lishid. All rights reserved.
|
Copyright (C) 2011-2012 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 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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
|
||||||
|
@ -22,7 +22,6 @@ import lishid.openinv.commands.OpenInvPluginCommand;
|
||||||
import lishid.openinv.utils.SilentContainerChest;
|
import lishid.openinv.utils.SilentContainerChest;
|
||||||
import net.minecraft.server.Block;
|
import net.minecraft.server.Block;
|
||||||
import net.minecraft.server.EntityPlayer;
|
import net.minecraft.server.EntityPlayer;
|
||||||
import net.minecraft.server.ICrafting;
|
|
||||||
import net.minecraft.server.IInventory;
|
import net.minecraft.server.IInventory;
|
||||||
import net.minecraft.server.InventoryLargeChest;
|
import net.minecraft.server.InventoryLargeChest;
|
||||||
import net.minecraft.server.Packet100OpenWindow;
|
import net.minecraft.server.Packet100OpenWindow;
|
||||||
|
@ -139,27 +138,26 @@ public class OpenInvPlayerListener implements Listener{
|
||||||
|
|
||||||
if(!silentchest)
|
if(!silentchest)
|
||||||
{
|
{
|
||||||
player.a((IInventory)chest);
|
player.openContainer((IInventory)chest);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
Field windowID;
|
int id = 0;
|
||||||
try{
|
try{
|
||||||
windowID = player.getClass().getDeclaredField("cl");
|
Field windowID = player.getClass().getDeclaredField("containerCounter");
|
||||||
|
windowID.setAccessible(true);
|
||||||
|
id = windowID.getInt(player);
|
||||||
|
id = id % 100 + 1;
|
||||||
|
windowID.setInt(player, id);
|
||||||
}
|
}
|
||||||
catch(NoSuchFieldException e)
|
catch(NoSuchFieldException e)
|
||||||
{
|
{ }
|
||||||
windowID = player.getClass().getDeclaredField("ci");
|
|
||||||
}
|
|
||||||
windowID.setAccessible(true);
|
|
||||||
int id = windowID.getInt(player);
|
|
||||||
id = id % 100 + 1;
|
|
||||||
windowID.setInt(player, id);
|
|
||||||
player.netServerHandler.sendPacket(new Packet100OpenWindow(id, 0, ((IInventory)chest).getName(), ((IInventory)chest).getSize()));
|
player.netServerHandler.sendPacket(new Packet100OpenWindow(id, 0, ((IInventory)chest).getName(), ((IInventory)chest).getSize()));
|
||||||
player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory)chest));
|
player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory)chest));
|
||||||
player.activeContainer.windowId = id;
|
player.activeContainer.windowId = id;
|
||||||
player.activeContainer.a((ICrafting)player);
|
player.activeContainer.addSlotListener(player);
|
||||||
//event.getPlayer().sendMessage("You are opening a chest silently.");
|
//event.getPlayer().sendMessage("You are opening a chest silently.");
|
||||||
event.setUseInteractedBlock(Result.DENY);
|
event.setUseInteractedBlock(Result.DENY);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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
|
||||||
|
@ -181,7 +181,7 @@ public class OpenInvPluginCommand implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Open the inventory
|
//Open the inventory
|
||||||
entityplayer.a(inv);
|
entityplayer.openContainer(inv);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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,7 +16,13 @@
|
||||||
|
|
||||||
package lishid.openinv.utils;
|
package lishid.openinv.utils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
import lishid.openinv.commands.OpenInvPluginCommand;
|
import lishid.openinv.commands.OpenInvPluginCommand;
|
||||||
import net.minecraft.server.EntityHuman;
|
import net.minecraft.server.EntityHuman;
|
||||||
|
@ -133,6 +139,39 @@ public class PlayerInventoryChest implements IInventory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack splitWithoutUpdate(int i) {
|
||||||
|
ItemStack[] is = this.items;
|
||||||
|
|
||||||
|
if (i >= is.length)
|
||||||
|
{
|
||||||
|
i -= is.length;
|
||||||
|
is = this.armor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = getReversedItemSlotNum(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= is.length)
|
||||||
|
{
|
||||||
|
i -= is.length;
|
||||||
|
is = this.extra;
|
||||||
|
}
|
||||||
|
else if(is == this.armor)
|
||||||
|
{
|
||||||
|
i = getReversedArmorSlotNum(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is[i] != null) {
|
||||||
|
ItemStack itemstack = is[i];
|
||||||
|
|
||||||
|
is[i] = null;
|
||||||
|
return itemstack;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setItem(int i, ItemStack itemstack)
|
public void setItem(int i, ItemStack itemstack)
|
||||||
{
|
{
|
||||||
ItemStack[] is = this.items;
|
ItemStack[] is = this.items;
|
||||||
|
@ -224,4 +263,23 @@ public class PlayerInventoryChest implements IInventory
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
|
||||||
|
|
||||||
|
public void onOpen(CraftHumanEntity who) {
|
||||||
|
transaction.add(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClose(CraftHumanEntity who) {
|
||||||
|
transaction.remove(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HumanEntity> getViewers() {
|
||||||
|
return transaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InventoryHolder getOwner() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011 lishid. All rights reserved.
|
* Copyright (C) 2011-2012 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,6 +1,6 @@
|
||||||
name: OpenInv
|
name: OpenInv
|
||||||
main: lishid.openinv.OpenInv
|
main: lishid.openinv.OpenInv
|
||||||
version: 1.7.6
|
version: 1.8.1
|
||||||
author: lishid
|
author: lishid
|
||||||
website: http://forums.bukkit.org/threads/15379/
|
website: http://forums.bukkit.org/threads/15379/
|
||||||
description: >
|
description: >
|
||||||
|
|
Loading…
Reference in a new issue