Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Online Command

Iniciado por Swarlog, Ago 19, 2022, 12:43 AM

Tema anterior - Siguiente tema

Swarlog

### Eclipse Workspace Patch 1.0
#P L2J_DataPack_BETA
Index: dist/game/data/scripts/handlers/voicedcommandhandlers/OnlineStatus.java
===================================================================
--- dist/game/data/scripts/handlers/voicedcommandhandlers/OnlineStatus.java (revision 0)
+++ dist/game/data/scripts/handlers/voicedcommandhandlers/OnlineStatus.java (working copy)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2004-2014 L2J DataPack
+ *
+ * This file is part of L2J DataPack.
+ *
+ * L2J DataPack 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.
+ *
+ * L2J DataPack 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 handlers.voicedcommandhandlers;
+
+import java.util.Collection;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.cache.HtmCache;
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ * Command for show online players count.
+ * @author St3eT
+ */
+public class OnlineStatus implements IVoicedCommandHandler
+{
+ private static long LAST_UPDATE = 0;
+ private static int OFFLINE_COUNT = 0;
+ private static int ONLINE_COUNT = 0;
+
+ private static final String[] _voicedCommands =
+ {
+ "online"
+ };
+
+ @Override
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
+ {
+ if (command.equals("online"))
+ {
+ if (System.currentTimeMillis() > (LAST_UPDATE + (5 * 60 * 1000)))
+ {
+ LAST_UPDATE = System.currentTimeMillis();
+ ONLINE_COUNT = L2World.getInstance().getAllPlayersCount();
+ int offlineCount = 0;
+
+ final Collection<L2PcInstance> objs = L2World.getInstance().getPlayers();
+ for (L2PcInstance player : objs)
+ {
+ if ((player.getClient() == null) || player.getClient().isDetached())
+ {
+ offlineCount++;
+ }
+ }
+ OFFLINE_COUNT = offlineCount;
+ }
+
+ if (Config.L2JMOD_ONLINE_STATUS_HTML)
+ {
+ NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(5);
+ String htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), Config.L2JMOD_ONLINE_STATUS_SHOW_OFFLINE ? "data/html/mods/OnlineStatus-off.htm" : "data/html/mods/OnlineStatus.htm");
+ npcHtmlMessage.setHtml(htmContent);
+ npcHtmlMessage.replace("%OnlineCount%", String.valueOf(ONLINE_COUNT));
+ npcHtmlMessage.replace("%OfflineCount%", String.valueOf(OFFLINE_COUNT));
+ activeChar.sendPacket(npcHtmlMessage);
+ }
+ else
+ {
+ activeChar.sendMessage("===============");
+ activeChar.sendMessage("Total player count: " + ONLINE_COUNT);
+ if (Config.L2JMOD_ONLINE_STATUS_SHOW_OFFLINE)
+ {
+ activeChar.sendMessage("Offline shop count: " + OFFLINE_COUNT);
+ }
+ activeChar.sendMessage("===============");
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return _voicedCommands;
+ }
+}
\ No newline at end of file
Index: dist/game/data/scripts/handlers/MasterHandler.java
===================================================================
--- dist/game/data/scripts/handlers/MasterHandler.java (revision 10213)
+++ dist/game/data/scripts/handlers/MasterHandler.java (working copy)
@@ -268,6 +268,7 @@
 import handlers.voicedcommandhandlers.Debug;
 import handlers.voicedcommandhandlers.Hellbound;
 import handlers.voicedcommandhandlers.Lang;
+import handlers.voicedcommandhandlers.OnlineStatus;
 import handlers.voicedcommandhandlers.StatsVCmd;
 import handlers.voicedcommandhandlers.TvTVoicedInfo;
 import handlers.voicedcommandhandlers.Wedding;
@@ -522,6 +523,7 @@
  (Config.TVT_ALLOW_VOICED_COMMAND ? TvTVoicedInfo.class : null),
  (Config.L2JMOD_CHAT_ADMIN ? ChatAdmin.class : null),
  (Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW ? Lang.class : null),
+ (Config.L2JMOD_ENABLE_ONLINE_STATUS ? OnlineStatus.class : null),
  (Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null),
  (Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null),
  (Config.L2JMOD_HELLBOUND_STATUS ? Hellbound.class : null),
Index: dist/game/data/html/mods/OnlineStatus-off.htm
===================================================================
--- dist/game/data/html/mods/OnlineStatus-off.htm (revision 0)
+++ dist/game/data/html/mods/OnlineStatus-off.htm (working copy)
@@ -0,0 +1,20 @@
+<html><body>
+<center>
+<img src="L2UI_CH3.herotower_deco" width=258 height=32>
+<table cellspacing=-1>
+<tr>
+<td><img src="L2UI.SquareBlank" width=40 height=20></td>
+</tr>
+</table>
+<img src="L2UI.SquareWhite" width=200 height=1>
+<table bgcolor=333333 width=204>
+<tr>
+<td><center><font color="FFFF00">Online Status</font></center></td>
+</tr>
+</table>
+<img src="L2UI.SquareWhite" width=200 height=1><br><br><br>
+Total player count: %OnlineCount%<br1>
+Offline shop count: %OfflineCount%<br><br><br>
+<img src="L2UI_CH3.herotower_deco" width=256 height=32>
+</center>
+</body></html>
\ No newline at end of file
Index: dist/game/data/html/mods/OnlineStatus.htm
===================================================================
--- dist/game/data/html/mods/OnlineStatus.htm (revision 0)
+++ dist/game/data/html/mods/OnlineStatus.htm (working copy)
@@ -0,0 +1,19 @@
+<html><body>
+<center>
+<img src="L2UI_CH3.herotower_deco" width=258 height=32>
+<table cellspacing=-1>
+<tr>
+<td><img src="L2UI.SquareBlank" width=40 height=20></td>
+</tr>
+</table>
+<img src="L2UI.SquareWhite" width=200 height=1>
+<table bgcolor=333333 width=204>
+<tr>
+<td><center><font color="FFFF00">Online Status</font></center></td>
+</tr>
+</table>
+<img src="L2UI.SquareWhite" width=200 height=1><br><br><br>
+Total player count: %OnlineCount%<br><br><br>
+<img src="L2UI_CH3.herotower_deco" width=256 height=32>
+</center>
+</body></html>
\ No newline at end of file
#P L2J_Server_BETA
Index: dist/game/config/L2JMods.properties
===================================================================
--- dist/game/config/L2JMods.properties (revision 6438)
+++ dist/game/config/L2JMods.properties (working copy)
@@ -429,6 +429,26 @@
 
 
 # ---------------------------------------------------------------------------
+# Online players status Voice Command
+# ---------------------------------------------------------------------------
+
+# This option will enable using of the voice commands .online
+# for information about online players.
+# Default: False
+EnableOnlineStatus = False
+
+# This option enable counter for Offline Traders.
+# Default: False
+EnableOfflineTraders = False
+
+# This option setup if status use HTML or message.
+# True = Status in HTML
+# False = Status in chat
+# Default: False
+EnableAdvancedStatus = False
+
+
+# ---------------------------------------------------------------------------
 # Walker/Bot protection
 # ---------------------------------------------------------------------------
 
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java (revision 6438)
+++ java/com/l2jserver/Config.java (working copy)
@@ -779,6 +779,9 @@
  public static List<String> L2JMOD_MULTILANG_SM_ALLOWED = new ArrayList<>();
  public static boolean L2JMOD_MULTILANG_NS_ENABLE;
  public static List<String> L2JMOD_MULTILANG_NS_ALLOWED = new ArrayList<>();
+ public static boolean L2JMOD_ENABLE_ONLINE_STATUS;
+ public static boolean L2JMOD_ONLINE_STATUS_HTML;
+ public static boolean L2JMOD_ONLINE_STATUS_SHOW_OFFLINE;
  public static boolean L2WALKER_PROTECTION;
  public static boolean L2JMOD_DEBUG_VOICE_COMMAND;
  public static int L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP;
@@ -2568,6 +2571,10 @@
  }
  }
 
+ L2JMOD_ENABLE_ONLINE_STATUS = L2JModSettings.getBoolean("EnableOnlineStatus", false);
+ L2JMOD_ONLINE_STATUS_HTML = L2JModSettings.getBoolean("EnableAdvancedStatus", false);
+ L2JMOD_ONLINE_STATUS_SHOW_OFFLINE = L2JModSettings.getBoolean("EnableOfflineTraders", false);
+
  L2WALKER_PROTECTION = L2JModSettings.getBoolean("L2WalkerProtection", false);
  L2JMOD_DEBUG_VOICE_COMMAND = L2JModSettings.getBoolean("DebugVoiceCommand", false);