Jump to content

Recommended Posts

Posted

Its been a long time since i shared something, so i decide to share something simple but with good idia.

So the main feature of this command is to remove karma when player is stack with it.

Command is .clean

It cannot be used in combat & doesn't need compile to insert it.

Tested on Freya!

 

package handlers.voicedcommandhandlers;
import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;


/**
* @author Stewie
*/

public class clean implements IVoicedCommandHandler
{
public static final String[] VOICED_COMMANDS = { "clean" };
    
public boolean useVoicedCommand(String command, L2PcInstance player, String params)
{

	if (command.startsWith("clean"))
	{
    {
	if(player.getKarma() == 0)
	{
	player.sendMessage("You don't have any karma!");
	}
	else if (!player.isInCombat())
        {		
			player.sendMessage("Done you are clean now!");
			player.setKarma(0);
         }
else 
					player.sendMessage("You can't clean karma while in combat!"); 
	}
}
	return false;
}

public String[] getVoicedCommandList()
{
	return VOICED_COMMANDS;
}}

 

In MasterHandler.java

import handlers.voicedcommandhandlers.clean;

VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new clean());

 

Command: .clean

Credits: Mine

Have fun!

Posted

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/handler/customcommandhandlers/KarmaClean.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/customcommandhandlers/KarmaClean.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/customcommandhandlers/KarmaClean.java	(working copy)
@@ -0,0 +1,55 @@
+/*
+ * 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.customcommandhandlers;
+
+import net.sf.l2j.gameserver.handler.ICustomCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Devlin
+ *
+ */
+public class KarmaClean implements ICustomCommandHandler
+{
+	private static String[] VOICED_COMMANDS = { "karmaclean" };
+	
+	@Override
+	public boolean useCustomCommand(String command, L2PcInstance activeChar)
+	{
+		if (command.equals("karmaclean"))
+		{
+			if (activeChar.getKarma() == 0)
+			{
+				activeChar.sendMessage("You don't have any karma.");
+			}
+			
+			if (activeChar.isInCombat())
+			{
+				activeChar.sendMessage("You cannot use this command while you are in combat.");
+			}
+			
+			activeChar.setKarma(0);
+			activeChar.broadcastKarma();
+			activeChar.sendMessage("Your karma has been cleaned.");
+		}
+		return true;
+	}
+
+	@Override
+	public String[] getCustomCommandList()
+	{
+		return VOICED_COMMANDS;
+	}
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/handler/CustomCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/CustomCommandHandler.java	(revision 21)
+++ java/net/sf/l2j/gameserver/handler/CustomCommandHandler.java	(working copy)
@@ -20,6 +20,7 @@

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.handler.customcommandhandlers.HappyHour;
+import net.sf.l2j.gameserver.handler.customcommandhandlers.KarmaClean;
import net.sf.l2j.gameserver.handler.customcommandhandlers.Topstats;

public class CustomCommandHandler
@@ -40,6 +41,8 @@

		if (Config.ALLOW_TOPSTATS_COMMAND)
			registerCustomCommandHandler(new Topstats());
+		
+		registerCustomCommandHandler(new KarmaClean());
	}

	public void registerCustomCommandHandler(ICustomCommandHandler handler)

 

It looks better, what's your opinion?

 

Nice try tho, btw you forgot broadcast method and use diff patches.

Posted

Devlin, your code is wrong.

 

The way you wrote the player even if he has no karma or even if he is in combat is going to have his karma set to 0 anyway.

 

After the sendMessage you should call return in order to prevent the exexution of the rest script.

 

Or the karma set part in else bracket.

Posted

Devlin, your code is wrong.

 

The way you wrote the player even if he has no karma or even if he is in combat is going to have his karma set to 0 anyway.

 

After the sendMessage you should call return in order to prevent the exexution of the rest script.

 

Or the karma set part in else bracket.

It is aCis. In aCis you write first the exceptions in brackets and you write the last lines alone. Dunno, maybe you are right. Thanks for your suggestion.
Posted

It is aCis. In aCis you write first the exceptions in brackets and you write the last lines alone. Dunno, maybe you are right. Thanks for your suggestion.

 

Your mistake is not related to the pack. 

 

It is, let's say, a logic mistake and it would have the same results everywhere.

Posted

anyway.. its already shared.. "old share" but stills here and its working.. iam too lazy to search it now.

 

I am sorry if already exist i made it yestarday... so i decide to share ...

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.

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.



  • Posts

    • So Goldbar thinks that deleted his side of the conversation makes it easier to claim he didn’t scam me. But I sent him $51 USDT to his ERC-20 account it was verified, he acted like it was fine but then deleted his messages and blocked me. Seriously do not trust this guy. 
    • Hi everyone, let me introduce myself—I'm Martin, a junior developer. I'm diving into the world of L2 servers, and honestly, I'm super overwhelmed about where to start learning the right way to set up, configure, and run a server. There are so many datapacks—free, private—but it's so much that my head feels like it's going to explode. I'm currently looking for someone or an active project willing to take me on as an intern. I'm not looking to make money—I'm just here to learn and grow out of pure passion for L2. I've already been working with L2jMobius H5. I managed to edit the Community Board, add a buffer, GM Shop, and teleports. I've also created custom NPCs for the GM Shop, and imported new custom weapons and armors—complete with original glow effects, like the Valakas and Antharas weapons. But there's still a lot I don't know, and it can get overwhelming. That’s why I’m looking for someone—or an active non-profit project—willing to take me on as an intern. I’m not looking to make money; I just want to learn, contribute, and grow out of pure passion for L2. If you’re working on a project and could use a motivated learner who’s eager to help, I’d love to connect!
    • Our next easy-botting project, Kain, is right around the corner! Launching tomorrow, Saturday, April 26th at 9:00 ET (UTC -4)! If you haven’t, check out the features and join our Discord to catch up on the latest drama. See you very soon! Read more about L2Toggle and Kain on our site and forum!  
    • 🤣 You were talking about security — I want you to prove that it's actually insecure, try to hack it or something. You're just talking without any evidence, and that's not right. Without the personal key that's generated for each site, you can't do anything. And by the way, boberKurwa isn't even used — it's a joke, and you totally fell for it. You're being very unconstructive. I appreciate criticism based on facts, and here's a fact: Sphere 2 has been running publicly since October, and there haven't been any successful hacking attempts. If you doubt that, go ahead and prove me wrong.  
  • Topics

×
×
  • Create New...