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/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(); + } +}
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.
GOSTARIA DOS ICONES DAS TATTOS , TODOS ICONES , COM ESSE LV , ATÉ O LVL 6 POR FAVOR , PARA INTERLUDE , ESSES DO PRINT NAO SAO INTERLUDE E NAO TENHO ! OBRIGADO!
Olá, seu tópico se encontra com um ou mais links offline. Caso ainda possua o conteúdo, favor postar aqui mesmo no tópico ou mandar MP para algum staff que estaremos normalizando o tópico.
Grato pela atenção!
Voce usar a conta de admin q vc tem no server, vai em accounts e define o acess_level la. e vc entra auto.
Eu tenho uma versão desse votesystem q tentei atualizar e com tutorial so acessar o link na minha assinatura em baixo.
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.
Pergunta
TeacherOfJava
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
,

Editado por powergamesLink para o comentário
Compartilhar em outros sites
11 respostass a esta questão
Posts recomendados
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.