/* * 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 org.apache.log4j.Logger; */ import org.jriver.lib.interfaces.Talkable; import org.jriver.lib.std.Command; import org.jriver.core.MudDriver; import org.jriver.lib.Player; /** * A basic shout command that echoes the input provided to all * connected users. * @author Enigma * integrated into new system by Zanz */ public class shout implements Command { /* private Logger m_log = Logger.getLogger(this.getClass().toString()); */ MudDriver driver; /* (non-Javadoc) * The entry point of the shout command, execute accepts the required arguments * and passes them to our connection pool's shout method. * @see org.jriver.lib.std.Command#execute(java.lang.String[], java.io.InputStream, java.io.OutputStream) */ public void execute(String[] args, Player player) { try { InputStream in = player.getSocket().getInputStream(); OutputStream out = player.getSocket().getOutputStream(); } catch(IOException e) { e.printStackTrace(); } StringBuffer buff = new StringBuffer(); for(String s : args) { buff.append(s); buff.append(" "); } shout(player, buff.toString()); } public void shout(Player source, String message) { Player user; driver = MudDriver.getMudDriver(); Iterator<Player> e = driver.getUsers().iterator(); while (e.hasNext()) { user = e.next(); if (message.equals("DISCONNECT")) message = source.queryName() + " has left.\r"; else if (message.equals("CONNECT")) message = source.queryName() + " arrives.\r"; else { user.catchTell( "[shout] "+ source.queryName() +": "+message+"\r", Talkable.MessageLevel.GENERAL, source); } } return; } }