Secret Experience

Secret Experience (https://secretexperience.net/)
-   [Lineage] Java Mods (https://secretexperience.net/lineage-java-mods/)
-   -   [L2JServer] Comando .online (https://secretexperience.net/lineage-java-mods/10342-comando-online.html)

KaL 03-07-2009 12:05 AM

Comando .online
 
Este Mod mostra quantos players estão conectados através do comando .online no momento. Funciona em todas as plataformas.

Código:

Index: /java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Online.java
===================================================================
--- /java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Online.java  (revision 0)
+++ /java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Online.java  (revision 0)
@@ -0,0 +1,59 @@
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
+
+
+import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.network.SystemMessageId;
+import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+
+/**
+*
+* @author Ombladon
+*
+* this class...
+* shows the amount of online players to any1 who calls it.
+*/
+public class Online implements IVoicedCommandHandler
+{
+
+
+private static final String[] VOICED_COMMANDS = {"online"};
+
+public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+{
+if (command.startsWith("online"))
+{
+showPlayers(activeChar, target);
+}
+
+return true;
+
+}
+
+
+
+public String[] getVoicedCommandList()
+{
+return VOICED_COMMANDS;
+}
+
+
+public void showPlayers (L2PcInstance player, String target)
+
+{
+SystemMessage sm = new SystemMessage(SystemMessageId.S1);
+sm = new SystemMessage(SystemMessageId.S1);
+sm.addString("======<Online Players>======");
+player.sendPacket(sm);
+sm = new SystemMessage(SystemMessageId.S1);
+sm.addString("There are "+L2World.getInstance().getAllPlayers().size()+" players on.");
+player.sendPacket(sm);
+
+sm = new SystemMessage(SystemMessageId.S1);
+sm.addString("=======================");
+player.sendPacket(sm);
+}
+
+
+}

Vá no arquivo gameserver/handler/VoicedCommandHandler.java
Código:

                registerVoicedCommandHandler(new Hellbound());
                registerVoicedCommandHandler(new Banking());
                registerVoicedCommandHandler(new VersionInfo());
+                registerVoicedCommandHandler(new Online());

Creditos : Mafia_007

lemile 12-07-2009 12:16 AM

Poderia explicar direito?
 
explica direito pq coloquei asim crieii essa pasta {handler} depois coloqueii um bloco de notas com essas seguintes formas
Código:

Index: /java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Online.java
===================================================================
--- /java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Online.java  (revision 0)
+++ /java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Online.java  (revision 0)
@@ -0,0 +1,59 @@
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
+
+
+import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.network.SystemMessageId;
+import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+
+/**
+*
+* @author Ombladon
+*
+* this class...
+* shows the amount of online players to any1 who calls it.
+*/
+public class Online implements IVoicedCommandHandler
+{
+
+
+private static final String[] VOICED_COMMANDS = {"online"};
+
+public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+{
+if (command.startsWith("online"))
+{
+showPlayers(activeChar, target);
+}
+
+return true;
+
+}
+
+
+
+public String[] getVoicedCommandList()
+{
+return VOICED_COMMANDS;
+}
+
+
+public void showPlayers (L2PcInstance player, String target)
+
+{
+SystemMessage sm = new SystemMessage(SystemMessageId.S1);
+sm = new SystemMessage(SystemMessageId.S1);
+sm.addString("======<Online Players>======");
+player.sendPacket(sm);
+sm = new SystemMessage(SystemMessageId.S1);
+sm.addString("There are "+L2World.getInstance().getAllPlayers().size()+" players on.");
+player.sendPacket(sm);
+
+sm = new SystemMessage(SystemMessageId.S1);
+sm.addString("=======================");
+player.sendPacket(sm);
+}
+
+
+}

falta oq? poderia explicar ou postar pra min porfavo'?

l2nemesis 17-07-2009 01:56 PM

voce tem que retirar os "+" sinal de mais(+) se nao vai ficar incorreto o código... pois ai esta o Diff

trovao 31-07-2009 04:38 AM

Vixe ta dificil aqui, o meu nao tem essa segunda parte Vá no arquivo gameserver/handler/VoicedCommandHandler.java, tipo tem esse arquivo mais nao consigo add nada nele, porque nao tem nem linhas semelhantes ^^.
Alguem sabe o que devo fazer, no meu VoicedCommandHandler.java, esta assim :
Código:

/*
 * 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 the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program 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 net.sf.l2j.gameserver.handler;

import java.util.Map;
import java.util.logging.Logger;

import javolution.util.FastMap;
import net.sf.l2j.Config;

/**
 * This class ...
 *
 * @version $Revision: 1.1.4.5 $ $Date: 2005/03/27 15:30:09 $
 */
public class VoicedCommandHandler
{
        private static Logger _log = Logger.getLogger(ItemHandler.class.getName());
       
        private Map<String, IVoicedCommandHandler> _datatable;
       
        public static VoicedCommandHandler getInstance()
        {
                return SingletonHolder._instance;
        }
       
        private VoicedCommandHandler()
        {
                _datatable = new FastMap<String, IVoicedCommandHandler>();
        }
       
        public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
        {
                String[] ids = handler.getVoicedCommandList();
                for (int i = 0; i < ids.length; i++)
                {
                        if (Config.DEBUG)
                                _log.fine("Adding handler for command " + ids[i]);
                        _datatable.put(ids[i], handler);
                }
        }

        public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
        {
                String command = voicedCommand;
                if (voicedCommand.indexOf(" ") != -1)
                {
                        command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
                }
                if (Config.DEBUG)
                        _log.fine("getting handler for command: " + command + " -> " + (_datatable.get(command) != null));
                return _datatable.get(command);
        }
       
        /**
        * @return
        */
        public int size()
        {
                return _datatable.size();
        }
       
        @SuppressWarnings("synthetic-access")
        private static class SingletonHolder
        {
                protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
        }
}

Encerra o codigo aqui, como add no voiced o comando do online ? Obrigado.

KaL 31-07-2009 01:14 PM

Nem todos os packs estão seguindo a mesma orientação na criação dos comandos, por isso essa diferença na hora de registá-los. Procure nos arquivos da pasta handler algum lugar onde tenham estas linhas de registro, similares...caso não encontre, basta adicionar o arquivo do comando, sem registrá-lo, pois será automatico o seu registro.

trovao 31-07-2009 04:06 PM

Ok obrigado pela resposta.

deserts2 17-12-2009 10:10 PM

como q fasso pra add essa opcao na config do server ?

ManoeL-ADM 18-12-2009 07:34 PM

cara quando voce coloca no SERVIDOR via JAVA automaticamente quando compila ele ja adiciona

----------

gente so lembrando issu se adiciona via JAVA .... não em outros lugares ....



se ajudei agradeça

deserts2 18-12-2009 07:59 PM

entao tipow c eu colokar ali no java eu nao preciso add nada nas config do server ?
qnd eu copilar ja vai tar la a opcao pra false ou true ?

Trinix 23-12-2009 12:41 PM

isso é um java patch vejam este tutorial para add ele:
[Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
e tbm... a config si vc quizer add uma config pra isso sugiro que veja o tutorial do Anthony - Java Core Modificacoes é ótimo pra quem esta iniciando no Java tem aqui na area de Java Mods ta aki o link : [Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]


Horários baseados na GMT -3. Agora são 07:39 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0