Ir para conteúdo
  • Cadastre-se
  • 0

.online ajuda!


TeacherOfJava

Pergunta

Boa tarde primeiramente. adicionei código .online e fiz todo processo. mas na hora de dale o comando aparece nome do personagem em vez de quantidades em números de players. Alguém por favor.

Codigo Usado

### Eclipse Workspace Patch 1.0

#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (working copy)
@@ -0,0 +1,24 @@
+/*
+ * 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 mor
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+package net.sf.l2j.gameserver.handler;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+public interface IVoicedCommandHandler
+{
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params);
+
+ public String[] getVoicedCommandList();
+}
\ No newline at end of file

Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 1)
+++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
@@ -14,7 +14,11 @@
*/
package net.sf.l2j.gameserver.handler.chathandlers;

+import java.util.StringTokenizer;
+
import net.sf.l2j.gameserver.handler.IChatHandler;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
import net.sf.l2j.gameserver.model.BlockList;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
@@ -37,15 +41,43 @@

@Override
public void handleChat(int type, L2PcInstance activeChar, String params, String text)
{
- CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
+ boolean vcd_used = false;
+ if (text.startsWith("."))
+ {
+ StringTokenizer st = new StringTokenizer(text);
+ IVoicedCommandHandler vch;
+ String command = "";

- for (L2PcInstance player : activeChar.getKnownList().getKnownTypeInRadius(L2PcInstance.class, 1250))
+ if (st.countTokens() > 1)
+ {
+ command = st.nextToken().substring(1);
+ params = text.substring(command.length() + 2);
+ vch = VoicedCommandHandler.getInstance().getHandler(command);
+ }
+ else
+ {
+ command = text.substring(1);
+ vch = VoicedCommandHandler.getInstance().getHandler(command);
+ }
+
+ if (vch != null)
+ {
+ vch.useVoicedCommand(command, activeChar, params);
+ vcd_used = true;
+ }
+ }
+ if (!vcd_used)
{
- if (!BlockList.isBlocked(player, activeChar))
- player.sendPacket(cs);
- }
-
- activeChar.sendPacket(cs);
+ CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
+
+ for (L2PcInstance player : activeChar.getKnownList().getKnownTypeInRadius(L2PcInstance.class, 1250))
+ {
+ if (!BlockList.isBlocked(player, activeChar))
+ player.sendPacket(cs);
+ }
+
+ activeChar.sendPacket(cs);
+ }
}

/**

Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java (revision 1)
+++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
@@ -63,6 +63,7 @@
import net.sf.l2j.gameserver.handler.ItemHandler;
import net.sf.l2j.gameserver.handler.SkillHandler;
import net.sf.l2j.gameserver.handler.UserCommandHandler;
+import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.instancemanager.AuctionManager;
import net.sf.l2j.gameserver.instancemanager.BoatManager;

@@ -275,7 +276,8 @@
_log.config("ItemHandler: Loaded " + ItemHandler.getInstance().size() + " handlers.");
_log.config("SkillHandler: Loaded " + SkillHandler.getInstance().size() + " handlers.");
_log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
-
+ _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
+
if (Config.ALLOW_WEDDING)
CoupleManager.getInstance();

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 (working copy)
@@ -0,0 +1,42 @@
+/*
+ * 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 .
+ */
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+public class Online implements IVoicedCommandHandler
+{
+ private static final String[] _voicedCommands = {"online"};
+
+ @Override
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+ {
+ if (command.equals("online"))
+ {
+ activeChar.sendMessage("====[Online Players]====");
+ activeChar.sendMessage("Player(s): " + L2World.getInstance().getAllPlayersCount() + " Online.");
+ activeChar.sendMessage("======[L2jFanatic]======");
+ }
+ return true;
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return _voicedCommands;
+ }
+}

\ No newline at end of file
Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (working copy)
@@ -0,0 +1,64 @@
+/*
+ * 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 .
+ */
+package net.sf.l2j.gameserver.handler;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Online;
+
+public class VoicedCommandHandler
+{
+ private final Map _datatable = new HashMap<>();
+
+ public static VoicedCommandHandler getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ protected VoicedCommandHandler()
+ {
+ // coloque aqui os comandos
+ registerHandler(new Online());
+ }
+
+ public void registerHandler(IVoicedCommandHandler handler)
+ {
+ String[] ids = handler.getVoicedCommandList();
+
+ for (int i = 0; i < ids.length; i++)
+ _datatable.put(ids.hashCode(), handler);
+ }
+
+ public IVoicedCommandHandler getHandler(String voicedCommand)
+ {
+ String command = voicedCommand;
+
+ if (voicedCommand.indexOf(" ") != -1)
+ command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
+
+ return _datatable.get(command.hashCode());
+ }
+
+ public int size()
+ {
+ return _datatable.size();
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
+ }
+}

\ No newline at end of file

,

21950115_479484622407242_233033649144524

Editado por powergames
Link para o comentário
Compartilhar em outros sites

11 respostass a esta questão

Posts recomendados

  • 0

Essa parte aqui:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

Você adicionou exatamente dessa forma?

No arquivo L2World.java você chegou a modificar alguma parte do código? Ou exatamente a parte do método "getAllPlayersCount()"?
Link para o comentário
Compartilhar em outros sites


  • 0

 

Essa parte aqui:

O conteúdo está oculto, favor efetuar login ou se cadastrar!
Você adicionou exatamente dessa forma?

 

No arquivo L2World.java você chegou a modificar alguma parte do código? Ou exatamente a parte do método "getAllPlayersCount()"?

 

mudei. coloquei L2World.getInstance().getPlayers().size();

Link para o comentário
Compartilhar em outros sites

  • 0

To dizendo que coloquei esse World.getInstance().getPlayers().size(); e ficou mesma coisa.

Tem algo de errado. Baixei a revisão 364 da aCis aqui no fórum mesmo, testei o método getPLayers() chamando o .size() e funcionou corretamente. Faça o seguinte teste:

 

Vá no arquivo: EnterWorld.java que fica em aCis_gameserver\java\net\sf\l2j\gameserver\network\clientpackets\

 

Abaixo dessas linhas:

 

O conteúdo está oculto, favor efetuar login ou se cadastrar!
Adicione:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

Ficando assim:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

Entre com a quantidade de personagens que desejar e veja que vai ser chamado corretamente a quantidade de players online. Veja a print:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

Link para o comentário
Compartilhar em outros sites

  • 0

 

Tem algo de errado. Baixei a revisão 364 da aCis aqui no fórum mesmo, testei o método getPLayers() chamando o .size() e funcionou corretamente. Faça o seguinte teste:

 

Vá no arquivo: EnterWorld.java que fica em aCis_gameserver\java\net\sf\l2j\gameserver\network\clientpackets\

 

Abaixo dessas linhas:

O conteúdo está oculto, favor efetuar login ou se cadastrar!
Adicione:

O conteúdo está oculto, favor efetuar login ou se cadastrar!
Ficando assim:

O conteúdo está oculto, favor efetuar login ou se cadastrar!
Entre com a quantidade de personagens que desejar e veja que vai ser chamado corretamente a quantidade de players online. Veja a print:
O conteúdo está oculto, favor efetuar login ou se cadastrar!

 

Fiz que vc falou amigo. Agora aparece quantos online, mas ai não percisa do comando .online, ele ta automático. eu queria q fosse pelo comando.

 

21768282_479781039044267_897124065595995

Link para o comentário
Compartilhar em outros sites

  • 0

Fiz que vc falou amigo. Agora aparece quantos online, mas ai não percisa do comando .online, ele ta automático. eu queria q fosse pelo comando.

 

O que fiz foi apenas um teste em relação ao método getPlayers(). Assim que eu tiver um tempo livre ainda hoje, testo o mod que você postou no tópico. Caso alguém não lhe ajude antes, claro.

Link para o comentário
Compartilhar em outros sites

  • 0

Obrigado aguardo então.

Baixe essa revisão, compile, e veja que está funcionando corretamente o .online:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

 

Se possível, faça a diff desse mod, parecida com a que você postou no tópico, mas no caso, com o código sendo retirado dessa revisão que lhe passei. Após fazer a diff, upe ela no Pastebin e posta aqui, para ficar mais fácil para o pessoal. Lembrando que nessa revisão o arquivo EnterWorld.java está editado, apenas ignore, é que esqueci de deixá-lo sem edições, padrão.

Link para o comentário
Compartilhar em outros sites

  • 0

Baixe essa revisão, compile, e veja que está funcionando corretamente o .online:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

 

Se possível, faça a diff desse mod, parecida com a que você postou no tópico, mas no caso, com o código sendo retirado dessa revisão que lhe passei. Após fazer a diff, upe ela no Pastebin e posta aqui, para ficar mais fácil para o pessoal. Lembrando que nessa revisão o arquivo EnterWorld.java está editado, apenas ignore, é que esqueci de deixá-lo sem edições, padrão.

mesma revisão minha n muda absolutamente em nada amigo.

Link para o comentário
Compartilhar em outros sites

  • 0

mesma revisão minha n muda absolutamente em nada amigo.

Então você está fazendo algo de errado, porque só de baixar e compilar, já funciona, por conta que essa revisão que postei já está com o mod adicionado e funcionando perfeitamente.

 

Prints:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

O conteúdo está oculto, favor efetuar login ou se cadastrar!

Link para o comentário
Compartilhar em outros sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Processando...
  • Registre-se

    Faça parte da maior e  mais antigas comunidades sobre Lineage2 da América Latina.





×
×
  • Criar Novo...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.