/*
* 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 org.jriver.core.MudDriver;
import org.jriver.lib.Player;
import org.jriver.lib.interfaces.Talkable.MessageLevel;
import org.jriver.lib.std.Command;
public class snoop implements Command
{
private MudDriver driver = MudDriver.getMudDriver();
public void execute(String[] args, Player thisPlayer) {
if(args.length != 1)
{
thisPlayer.catchTell("Syntax: snoop <playerName>", MessageLevel.INFO, thisPlayer);
return;
}
Player target = driver.findPlayer(args[0]);
if(target == null)
{
thisPlayer.catchTell("No such player to snoop!", MessageLevel.WARNING, thisPlayer);
return;
}
if(target.querySnoopers().contains(thisPlayer))
{
target.removeSnooper(thisPlayer);
thisPlayer.catchTell("Done snooping "+ target.queryName(), MessageLevel.INFO, thisPlayer);
return ;
}
target.addSnooper(thisPlayer);
thisPlayer.catchTell("Snooping "+ target.queryName(), MessageLevel.INFO, thisPlayer);
}
}