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
|
||||
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
|
||||
* 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
|
||||
* 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
|
||||
* 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 net.minecraft.server.Block;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.ICrafting;
|
||||
import net.minecraft.server.IInventory;
|
||||
import net.minecraft.server.InventoryLargeChest;
|
||||
import net.minecraft.server.Packet100OpenWindow;
|
||||
|
@ -139,27 +138,26 @@ public class OpenInvPlayerListener implements Listener{
|
|||
|
||||
if(!silentchest)
|
||||
{
|
||||
player.a((IInventory)chest);
|
||||
player.openContainer((IInventory)chest);
|
||||
}
|
||||
else
|
||||
{
|
||||
try{
|
||||
Field windowID;
|
||||
int id = 0;
|
||||
try{
|
||||
windowID = player.getClass().getDeclaredField("cl");
|
||||
}
|
||||
catch(NoSuchFieldException e)
|
||||
{
|
||||
windowID = player.getClass().getDeclaredField("ci");
|
||||
}
|
||||
Field windowID = player.getClass().getDeclaredField("containerCounter");
|
||||
windowID.setAccessible(true);
|
||||
int id = windowID.getInt(player);
|
||||
id = windowID.getInt(player);
|
||||
id = id % 100 + 1;
|
||||
windowID.setInt(player, id);
|
||||
}
|
||||
catch(NoSuchFieldException e)
|
||||
{ }
|
||||
|
||||
player.netServerHandler.sendPacket(new Packet100OpenWindow(id, 0, ((IInventory)chest).getName(), ((IInventory)chest).getSize()));
|
||||
player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory)chest));
|
||||
player.activeContainer.windowId = id;
|
||||
player.activeContainer.a((ICrafting)player);
|
||||
player.activeContainer.addSlotListener(player);
|
||||
//event.getPlayer().sendMessage("You are opening a chest silently.");
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
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
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
entityplayer.a(inv);
|
||||
entityplayer.openContainer(inv);
|
||||
|
||||
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
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,7 +16,13 @@
|
|||
|
||||
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.inventory.InventoryHolder;
|
||||
|
||||
import lishid.openinv.commands.OpenInvPluginCommand;
|
||||
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)
|
||||
{
|
||||
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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: OpenInv
|
||||
main: lishid.openinv.OpenInv
|
||||
version: 1.7.6
|
||||
version: 1.8.1
|
||||
author: lishid
|
||||
website: http://forums.bukkit.org/threads/15379/
|
||||
description: >
|
||||
|
|
Loading…
Reference in a new issue