Sign in to follow this  
0samita

[ Share ] .menu + VoiceCommandHandler adapted to Rev. 385

Recommended Posts

 

Well I made this adaptation for my server and I share them, it works perfectly, but if anyone has any correction or improvement for the code it is welcome.

 

Rev 385 L2j aCis

 

I think the image speaks for itself of what this modification does.

 

 

image.png.f4ed91d6eb27dceacb231d896690f3f9.png

 

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
diff --git java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
new file mode 100644
index 0000000..6bd2063
--- /dev/null
+++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
@@ -0,0 +1,10 @@
+package net.sf.l2j.gameserver.handler;
+
+import net.sf.l2j.gameserver.model.actor.Player;
+
+public interface IVoicedCommandHandler
+{
+    public boolean useVoicedCommand(String command, Player activeChar);
+    
+    public String[] getVoicedCommandList();
+}
\ No newline at end of file
diff --git java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
new file mode 100644
index 0000000..59f60a4
--- /dev/null
+++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
@@ -0,0 +1,54 @@
+package net.sf.l2j.gameserver.handler;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sf.l2j.commons.logging.CLogger;
+
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Menu;
+
+public class VoicedCommandHandler
+{
+    CLogger LOGGER = new CLogger(VoicedCommandHandler.class.getName());
+    private final Map<Integer, IVoicedCommandHandler> VOICED_COMMANDS;
+    
+    public static VoicedCommandHandler getInstance()
+    {
+        return SingletonHolder._instance;
+    }
+    
+    protected VoicedCommandHandler()
+    {
+        VOICED_COMMANDS = new HashMap<>();
+        // example how to register you handler:
+        registerVoicedCommandHandler(new Menu());
+        // registerVoicedCommandHandler(new YourHandler());
+        LOGGER.info("Loaded {} voiced command handlers.", size());
+    }
+    
+    public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
+    {
+        for (String id : handler.getVoicedCommandList())
+            VOICED_COMMANDS.put(id.hashCode(), handler);
+    }
+    
+    public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
+    {
+        String command = voicedCommand;
+        
+        if (voicedCommand.indexOf(" ") != -1)
+            command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
+        
+        return VOICED_COMMANDS.get(command.hashCode());
+    }
+    
+    public int size()
+    {
+        return VOICED_COMMANDS.size();
+    }
+    
+    private static class SingletonHolder
+    {
+        protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
+    }
+}
\ No newline at end of file
diff --git java/net/sf/l2j/gameserver/handler/skillhandlers/Continuous.java java/net/sf/l2j/gameserver/handler/skillhandlers/Continuous.java
index 5e746e6..a7d3a2d 100644
--- java/net/sf/l2j/gameserver/handler/skillhandlers/Continuous.java
+++ java/net/sf/l2j/gameserver/handler/skillhandlers/Continuous.java
@@ -75,6 +75,15 @@
 					if (target.getFirstEffect(L2EffectType.BLOCK_BUFF) != null)
 						continue;
 					
+					// Anti-Buff Protection prevents you from getting buffs by other players
+                      if (activeChar instanceof Player && target != activeChar && target.isBuffProtected() && !skill.isHeroSkill()
+                        && (skill.getSkillType() == L2SkillType.BUFF                        
+                        || skill.getSkillType() == L2SkillType.HEAL_PERCENT
+                        || skill.getSkillType() == L2SkillType.MANAHEAL_PERCENT
+                        || skill.getSkillType() == L2SkillType.COMBATPOINTHEAL
+                        || skill.getSkillType() == L2SkillType.REFLECT))
+                    continue;
+					
 					// Player holding a cursed weapon can't be buffed and can't buff
 					if (!(activeChar instanceof ClanHallManagerNpc) && target != activeChar)
 					{
diff --git java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Menu.java java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Menu.java
new file mode 100644
index 0000000..0e9910a
--- /dev/null
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Menu.java
@@ -0,0 +1,80 @@
+/*
+ * 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.voicedcommandhandlers;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.World;
+import net.sf.l2j.gameserver.model.actor.Player;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ * @author Bluur
+ * @version 1.0
+ */
+
+public class Menu implements IVoicedCommandHandler
+{
+	@Override
+	public String[] getVoicedCommandList()
+	{
+		return new String[]
+		{
+			"menu",
+			"setPartyRefuse",
+			"setTradeRefuse",
+			"setbuffsRefuse",
+			"setMessageRefuse",
+		};
+	}
+	
+	private static final String ACTIVED = "<font color=00FF00>ON</font>";
+	private static final String DESATIVED = "<font color=FF0000>OFF</font>";
+	
+	@Override
+	public boolean useVoicedCommand(String command, Player activeChar)
+	{
+		if (command.equals("setPartyRefuse"))
+		{
+			activeChar.setIsPartyInRefuse(!activeChar.isPartyInRefuse());
+		}
+		else if (command.equals("setTradeRefuse"))
+		{
+			activeChar.setTradeRefusal(!activeChar.getTradeRefusal());
+		}
+		else if (command.equals("setMessageRefuse"))
+		{
+			activeChar.setInRefusalMode(!activeChar.isInRefusalMode());
+		}
+		else if (command.equals("setbuffsRefuse"))
+		{
+			activeChar.setIsBuffProtected(!activeChar.isBuffProtected());
+		}
+		
+		showHtml(activeChar);
+		return true;
+	}
+	
+	private static void showHtml(Player activeChar)
+	{
+		NpcHtmlMessage html = new NpcHtmlMessage(0);
+		html.setFile("data/html/mods/menu.htm");
+		html.replace("%online%", World.getInstance().getPlayers().size());
+		html.replace("%partyRefusal%", activeChar.isPartyInRefuse() ? ACTIVED : DESATIVED);
+		html.replace("%tradeRefusal%", activeChar.getTradeRefusal() ? ACTIVED : DESATIVED);
+		html.replace("%buffsRefusal%", activeChar.isBuffProtected() ? ACTIVED : DESATIVED);
+		html.replace("%messageRefusal%", activeChar.isInRefusalMode() ? ACTIVED : DESATIVED);
+		activeChar.sendPacket(html);
+	}
+}
\ No newline at end of file
diff --git java/net/sf/l2j/gameserver/model/actor/Creature.java java/net/sf/l2j/gameserver/model/actor/Creature.java
index 5846b08..ff4547e 100644
--- java/net/sf/l2j/gameserver/model/actor/Creature.java
+++ java/net/sf/l2j/gameserver/model/actor/Creature.java
@@ -1564,6 +1564,19 @@
 		return false;
 	}
 	
+    // protect From Debuffs
+    private boolean _isBuffProtected = false;
+    public void setIsBuffProtected(boolean value)
+    {
+        _isBuffProtected = value;
+    }
+           
+    public boolean isBuffProtected()
+    {
+        return _isBuffProtected;    
+    }
+
+	
 	/**
 	 * @return true if this object is either a raid minion or a raid boss.
 	 */
diff --git java/net/sf/l2j/gameserver/model/actor/Player.java java/net/sf/l2j/gameserver/model/actor/Player.java
index 6311d3f..294a397 100644
--- java/net/sf/l2j/gameserver/model/actor/Player.java
+++ java/net/sf/l2j/gameserver/model/actor/Player.java
@@ -432,6 +432,7 @@
 	private boolean _messageRefusal; // message refusal mode
 	private boolean _tradeRefusal; // Trade refusal
 	private boolean _exchangeRefusal; // Exchange refusal
+	private boolean _isPartyInRefuse = false; // Party Refusal Mode
 	
 	private Party _party;
 	private LootRule _lootRule;
@@ -7131,6 +7132,16 @@
 		_race[i] = val;
 	}
 	
+	public boolean isPartyInRefuse()
+    {
+        return _isPartyInRefuse;
+    }
+
+    public void setIsPartyInRefuse(boolean value)
+    {
+        _isPartyInRefuse = value;
+    }
+	
 	public boolean isInRefusalMode()
 	{
 		return _messageRefusal;
diff --git java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
index cfd76fa..6ae0ef5 100644
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
@@ -9,6 +9,8 @@
 import net.sf.l2j.gameserver.data.xml.AdminData;
 import net.sf.l2j.gameserver.handler.AdminCommandHandler;
 import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
 import net.sf.l2j.gameserver.model.World;
 import net.sf.l2j.gameserver.model.WorldObject;
 import net.sf.l2j.gameserver.model.actor.Npc;
@@ -99,6 +101,23 @@
 			html.disableValidation();
 			player.sendPacket(html);
 		}
+		
+		if (_command.startsWith("voiced_"))
+            {
+                String command = _command.split(" ")[0];
+
+                IVoicedCommandHandler ach = VoicedCommandHandler.getInstance().getVoicedCommandHandler(_command.substring(7));
+
+                if (ach == null)
+                {
+                    player.sendMessage("The command " + command.substring(7) + " does not exist!");
+                    LOGGER.warn("No handler registered for command '" + _command + "'");
+                    return;
+                }
+
+                ach.useVoicedCommand(_command.substring(7), player);
+            } 
+		
 		else if (_command.startsWith("npc_"))
 		{
 			if (!player.validateBypass(_command))
diff --git java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
index aaa69a0..0755a16 100644
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
@@ -47,6 +47,12 @@
 			return;
 		}
 		
+		if (target.isPartyInRefuse())
+        {
+            requestor.sendMessage("[Party Refuse]: Player in refusal party.");
+            return;
+        }
+		
 		if (target.isInParty())
 		{
 			requestor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_IS_ALREADY_IN_PARTY).addCharName(target));

 

/data/html/mods/menu.htm

 

<html><body><title>Menu L2 Theon</title>
<br>
<center>
<table width=224>
    <tr>
        <td width=32><img src=Icon.etc_alphabet_l_i00 height=32 width=32></td>
        <td width=32><img src=Icon.etc_alphabet_ii_i00 height=32 width=32></td>
        <td width=32><img src=Icon.etc_alphabet_t_i00 height=32 width=32></td>
        <td width=32><img src=Icon.etc_alphabet_h_i00 height=32 width=32></td>
        <td width=32><img src=Icon.etc_alphabet_e_i00 height=32 width=32></td>
        <td width=32><img src=Icon.etc_alphabet_o_i00 height=32 width=32></td>
        <td width=32><img src=Icon.etc_alphabet_n_i00 height=32 width=32></td>
    </tr>
</table>
<br>
<br>
Player(s) online: <font color="00FF00">%online%</font></center>
<br>
<center><font color="LEVEL">Configura tus opciones.</font></center>
<br>
<center><font color="LEVEL">Configure yours options.</font></center>
<img src="L2UI.SquareGray" width=270 height=1>
<table bgcolor="000000">
<tr>
<td width=5></td>
<td width=105>Funcion / type</td>
<td width=100>Estado / Status</td>
<td width=50>Action</td>
</tr>
</table>
<img src="L2UI.SquareGray" width=270 height=1>
<br>
<table bgcolor="000000">
<tr>
<td width=5></td>
<td width=100>Party Refuse</td>
<td width=100>%partyRefusal%</td>
<td width=50><button width=35 height=15 back="sek.cbui94" fore="sek.cbui94" action="bypass -h voiced_setPartyRefuse" value="Alter"></td>
</tr>
<tr>
<td width=5></td>
<td width=100>Trade Refusal</td>
<td width=100>%tradeRefusal%</td>
<td width=50><button width=35 height=15 back="sek.cbui94" fore="sek.cbui94" action="bypass -h voiced_setTradeRefuse" value="Alter"></td>
</tr>
<tr>
<td width=5></td>
<td width=100>Buffs Refusal</td>
<td width=100>%buffsRefusal%</td>
<td width=50><button width=35 height=15 back="sek.cbui94" fore="sek.cbui94" action="bypass -h voiced_setbuffsRefuse" value="Alter"></td>
</tr>
<tr>
<td width=5></td>
<td width=100>Message Refusal</td>
<td width=100>%messageRefusal%</td>
<td width=50><button width=35 height=15 back="sek.cbui94" fore="sek.cbui94" action="bypass -h voiced_setMessageRefuse" value="Alter"></td>
</tr>
</table>
<br>
<center>
<img src="L2UI.SquareGray" width=160 height=1><br>
<font color="LEVEL">L2 Theon - 0samita</font></center>
</body></html>

 

Edited by 0samita

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.