Cross world disabled

This commit is contained in:
lishd
2011-07-11 16:53:59 -04:00
parent 8908cc918a
commit 70c75996c0
4 changed files with 59 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ import lishid.openinv.utils.PlayerInventoryChest;
import net.minecraft.server.ContainerPlayer;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.ICrafting;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.event.Event;
@@ -24,6 +25,7 @@ import org.bukkit.plugin.Plugin;
public class OpenInv extends JavaPlugin {
private final OpenInvPlayerListener playerListener = new OpenInvPlayerListener(this);
private final OpenInvEntityListener entityListener = new OpenInvEntityListener(this);
//private final OpenInvInventoryListener inventoryListener = new OpenInvInventoryListener(this);
public static PermissionHandler permissionHandler;
public void onDisable() {
}
@@ -47,10 +49,11 @@ public class OpenInv extends JavaPlugin {
//pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Event.Priority.Normal, this);
//pm.registerEvent(Event.Type.INVENTORY_CLOSE, inventoryListener, Event.Priority.Normal, this);
setupPermissions();
// EXAMPLE: Custom code, here we just output some info so we can check all is well
PluginDescriptionFile pdfFile = this.getDescription();
System.out.println("[" + pdfFile.getName() + "] version " + pdfFile.getVersion() + " is enabled!" );
System.out.println("[" + pdfFile.getName() + "] version " + pdfFile.getVersion() + " enabled!" );
getCommand("openinv").setExecutor(new OpenInvPluginCommand(this));
getCommand("searchinv").setExecutor(new SearchInvPluginCommand(this));
@@ -59,11 +62,19 @@ public class OpenInv extends JavaPlugin {
public static void ReplaceInv(CraftPlayer player)
{
EntityPlayer entityplayer = player.getHandle();
entityplayer.inventory = new PlayerInventoryChest(entityplayer.inventory);
entityplayer.defaultContainer = new ContainerPlayer(entityplayer.inventory, !entityplayer.world.isStatic);
entityplayer.activeContainer = entityplayer.defaultContainer;
player.setHandle(entityplayer);
try{
EntityPlayer entityplayer = player.getHandle();
entityplayer.inventory = new PlayerInventoryChest(entityplayer.inventory);
entityplayer.defaultContainer = new ContainerPlayer(entityplayer.inventory, !entityplayer.world.isStatic);
entityplayer.activeContainer = entityplayer.defaultContainer;
//sync
((ICrafting)entityplayer).a(entityplayer.activeContainer, entityplayer.activeContainer.b());
entityplayer.activeContainer.a();
player.setHandle(entityplayer);
}
catch(Exception e)
{}
}