/*
* Copyright 2007 Kevin Roe, Daniel Mccarney
* This file is part of Jriver.
*
* Jriver is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Jriver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jriver.lib.bin;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.swing.tree.*;
import org.jriver.lib.std.Command;
import org.jriver.lib.Player;
import org.jriver.core.*;
public class inventory implements Command {
private PrintWriter out;
public void execute(String[] arg, Player player)
{
try {
out = new PrintWriter(player.getSocket().getOutputStream(),true);
} catch(IOException e) {
e.printStackTrace();
}
Enumeration e = ((MudObject) player.getRootNode().getUserObject()).inventory();
if(e.hasMoreElements()) out.println("You are carrying:");
else out.println("You have nothing");
while(e.hasMoreElements()) {
DefaultMutableTreeNode n = (DefaultMutableTreeNode) e.nextElement();
MudObject thisObj = (MudObject) n.getUserObject();
out.println(thisObj.queryName());
}
}
}