Jump to content
  • 0

Auto GoldBar RUSaCis 3.5


TikaLakaTika

Question

10 answers to this question

Recommended Posts

  • 0
2 horas atrás, TikaLakaTika disse:

Bom dia!

Alguém pode me ajudar com esse erro que estou tendo ao adaptar o código Auto Goldbar na RUSaCis 3.5?

image.png.48b3ec663ff65643fda27ab5e8505757.png


Grato!

package net.sf.l2j.gameserver.taskmanager.custom;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import net.sf.l2j.commons.pool.ThreadPool;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.Creature;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.network.serverpackets.ItemList;
import net.sf.l2j.gsregistering.L2JDev;

/**
 * @author BAN - {@link L2JDev}
 */
public class AutoGoldBar implements Runnable
{
	@Override
	public final void run()
	{
		if (_players.isEmpty())
			return;
		
		for (Map.Entry<Player, Long> entry : _players.entrySet())
		{
			final Player player = entry.getKey();
			
			if (player.getMemos().getLong("AutoGoldBar") < System.currentTimeMillis())
			{
				
				if (player.getInventory().getItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
				{
					player.getInventory().reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, player, null);
					player.getInventory().addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBARS, player, null);
					player.getInventory().updateDatabase();
					player.sendPacket(new ItemList(player, false));
					
				}
				remove(player);
			}
			if (player.getInventory().getItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
			{
				player.getInventory().reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, player, null);
				player.getInventory().addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBARS, player, null);
				player.getInventory().updateDatabase();
				player.sendPacket(new ItemList(player, false));
				
			}
		}
	}
	

	private final Map<Player, Long> _players = new ConcurrentHashMap<>();
	
	protected AutoGoldBar()
	{
		// Run task each 10 second.
		ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
	}
	
	public final void add(Player player)
	{
		_players.put(player, System.currentTimeMillis());
	}
	
	public final void remove(Creature player)
	{
		_players.remove(player);
	}
	
	public static final AutoGoldBar getInstance()
	{
		return SingletonHolder._instance;
	}
	
	private static class SingletonHolder
	{
		protected static final AutoGoldBar _instance = new AutoGoldBar();
	}
}

 

Screenshot_8.png
👑 WWW.L2JDEV.COM.BR 👑
Official L2JDev Discord Invite: https://discord.gg/9sNV96ZZD4

Link to comment
Share on other sites


  • 0
5 horas atrás, BAN - L2JDev disse:
package net.sf.l2j.gameserver.taskmanager.custom;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import net.sf.l2j.commons.pool.ThreadPool;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.Creature;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.network.serverpackets.ItemList;
import net.sf.l2j.gsregistering.L2JDev;

/**
 * @author BAN - {@link L2JDev}
 */
public class AutoGoldBar implements Runnable
{
	@Override
	public final void run()
	{
		if (_players.isEmpty())
			return;
		
		for (Map.Entry<Player, Long> entry : _players.entrySet())
		{
			final Player player = entry.getKey();
			
			if (player.getMemos().getLong("AutoGoldBar") < System.currentTimeMillis())
			{
				
				if (player.getInventory().getItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
				{
					player.getInventory().reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, player, null);
					player.getInventory().addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBARS, player, null);
					player.getInventory().updateDatabase();
					player.sendPacket(new ItemList(player, false));
					
				}
				remove(player);
			}
			if (player.getInventory().getItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
			{
				player.getInventory().reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, player, null);
				player.getInventory().addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBARS, player, null);
				player.getInventory().updateDatabase();
				player.sendPacket(new ItemList(player, false));
				
			}
		}
	}
	

	private final Map<Player, Long> _players = new ConcurrentHashMap<>();
	
	protected AutoGoldBar()
	{
		// Run task each 10 second.
		ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
	}
	
	public final void add(Player player)
	{
		_players.put(player, System.currentTimeMillis());
	}
	
	public final void remove(Creature player)
	{
		_players.remove(player);
	}
	
	public static final AutoGoldBar getInstance()
	{
		return SingletonHolder._instance;
	}
	
	private static class SingletonHolder
	{
		protected static final AutoGoldBar _instance = new AutoGoldBar();
	}
}

Ainda persiste o erro @BAN - L2JDev 😐

Segue as partes do código que adicionei:

Caminho > AutoGoldBar
+package net.sf.l2j.gameserver.taskmanager;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import net.sf.l2j.commons.pool.ThreadPool;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.model.actor.Creature;
+import net.sf.l2j.gameserver.model.actor.Player;
+import net.sf.l2j.gameserver.network.serverpackets.ItemList;
+
+public class AutoGoldBar implements Runnable
+{
+	@Override
+	public final void run()
+	{
+		if (_players.isEmpty())
+			return;
+		
+		for (Map.Entry<Player, Long> entry : _players.entrySet())
+		{
+			final Player player = entry.getKey();
+			
+			if (player.getMemos().getLong("AutoGoldBar") < System.currentTimeMillis())
+			{
+				
+				if (player.getInventory().getItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
+				{
+					player.getInventory().reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, player, null);
+					player.getInventory().addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBAR, player, null);
+					player.getInventory().updateDatabase();
+					player.sendPacket(new ItemList(player, false));
+				}
+				remove(player);
+			}
+			if (player.getInventory().getItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
+			{
+				player.getInventory().reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, player, null);
+				player.getInventory().addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBAR, player, null);
+				player.getInventory().updateDatabase();
+				player.sendPacket(new ItemList(player, false));
+			}
+		}
+	}
+	
+	private final Map<Player, Long> _players = new ConcurrentHashMap<>();
+	
+	protected AutoGoldBar()
+	{
+		// Run task each 10 second.
+		ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
+	}
+	
+	public final void add(Player player)
+	{
+		_players.put(player, System.currentTimeMillis());
+	}
+	
+	public final void remove(Creature player)
+	{
+		_players.remove(player);
+	}
+	
+	public static final AutoGoldBar getInstance()
+	{
+		return SingletonHolder._instance;
+	}
+	
+	private static class SingletonHolder
+	{
+		protected static final AutoGoldBar _instance = new AutoGoldBar();
+	}
+}


Caminho > Player.java
+private final CachedDataValueBoolean _gbforadena = _cachedData.newBoolean("gbforadena");

+public void setAutoGb(boolean value)
+	{
+		_gbforadena.set(value);
+	}
+	
+	public boolean isAutoGb()
+	{
+		return _gbforadena.get();
+	}


Class > AutoBanking.java
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.actor.Player;
+import net.sf.l2j.gameserver.taskmanager.AutoGoldBar;
+
+public class AutoBanking implements IVoicedCommandHandler
+{
+	private static final String[] _voicedCommands =
+	{
+		"gbstart",
+		"gbstop",
+	};
+	
+	@Override
+	public boolean useVoicedCommand(final String command, final Player player, final String target)
+	{
+		if (command.equalsIgnoreCase("gbstart"))
+		{
+			if (player.isAutoGb())
+			{
+				player.setAutoGb(false);
+				AutoGoldBar.getInstance().remove(player);
+			}
+			else
+			{
+				player.setAutoGb(true);
+				AutoGoldBar.getInstance().add(player);
+			}
+			Menu.showHtml(player);
+		}
+		return true;
+	}
+	
+	@Override
+	public String[] getVoicedCommandList()
+	{
+		return _voicedCommands;
+	}
+}


Class > AutoBanking.java
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.AutoBanking;

+registerHandler(new AutoBanking());


Class > Menu.java
+htm.replace("%autogb%", player.isAutoGb() ? ENABLED : DISABLED);


Datapack > gameserver/data/html/mods/menu.htm
+<tr>
+  <td width=100>Auto GoldBar</td>
+  <td width=100>%autogb%</td>
+  <td width=50>
+    <button width=35 height=15 back="sek.cbui94" fore="sek.cbui94" action="bypass voiced_gbstart" value="Alter">
+  </td>
+</tr>


 Tá faltando alguma coisa no meu código ou adicionar parte em alguma Class que esqueci?

- Tudo posso NAQUELE que me fortalece! :boxing:

Link to comment
Share on other sites

  • 0

mano que codigo doido e esse que tu ta fazendo voce tento decompilar meu projeto pra pegar o codigo usando DJ-Gui ? mais mais coisas ta faltando os getmemos todas as checagem para tudo fluir 

Screenshot_8.png
👑 WWW.L2JDEV.COM.BR 👑
Official L2JDev Discord Invite: https://discord.gg/9sNV96ZZD4

Link to comment
Share on other sites

  • 0

Não mano, não decompilei nada, só usando como base mesmo outros projetos pra tentar fazer do zero. Não tenho tanta experiência assim em Java como você. Mas tô me esforçando. Agradeço se puder ajudar a completar o código.

- Tudo posso NAQUELE que me fortalece! :boxing:

Link to comment
Share on other sites

  • 0

Você pode simplesmente apagar/comentar essa parte do código. Ela é a que está causando erro e não parece ser usada pelo que foi implementado.
 

			if (player.getMemos().getLong("AutoGoldBar") < System.currentTimeMillis())
			{
				
				if (player.getInventory().getItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
				{
					player.getInventory().reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, player, null);
					player.getInventory().addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBARS, player, null);
					player.getInventory().updateDatabase();
					player.sendPacket(new ItemList(player, false));
					
				}
				remove(player);
			}

AutoGoldBar sempre vai ser null porque aparentemente não está sendo setada em lugar algum.

Link to comment
Share on other sites

  • 0
18 horas atrás, coldplay disse:

testou o que eu propus? eu apliquei o patch que vc mandou e deu certo com essa modificação

Valeu @coldplay deu certo eu fazendo da forma que você propos. Vou postar o código pra galera 🙂

- Tudo posso NAQUELE que me fortalece! :boxing:

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   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.

Loading...
  • Join now

    Be part of the largest and oldest communities about Lineage2 in Latin America.





  • Patrocinadores

  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Interessante esse projeto, parabéns @BAN - L2JDev
    • Boa noite alguém pode me manda os arquivos da coroa hero preta??
    • @Kelvin, mesmo efetuando o download do plugin acima, ou trazendo ele junto com a importação do kit, não trouxe os cabeçalhos e rodapés. O que poderia ser?
    • ta dando esse erro ao tentar donatar, alguem sabe como resolver? Edit: o Pagseguro e Paypal estão da mesma forma  O sistema de doação não esta funcionando.  
    • Hola, lo tienen para acis 382, esa version me anda para probar
    • BAN NÃO TOU CONSGUINDO TER ACESSO... TOU SEM O PATCH PODERIA DISPONIBILIZAR ?
    • Hola, ¿tienes un comando de voz para este código?      package net.sf.l2j.gameserver.taskmanager;   import java.util.logging.Logger; import net.sf.l2j.Config; import net.sf.l2j.commons.util.ArraysUtil; import net.sf.l2j.gameserver.enums.ZoneId; import net.sf.l2j.gameserver.model.actor.Creature; import net.sf.l2j.gameserver.model.actor.Player; import net.sf.l2j.gameserver.model.holder.IntIntHolder; import net.sf.l2j.gameserver.skills.L2Skill; import net.sf.l2j.gameserver.skills.effects.EffectTemplate; public class AutoPotionTask implements Runnable  {     protected static final Logger _log = Logger.getLogger(AutoPotionTask.class.getName());     private int itemId;     private Player player;     private static final int[] HP_POTION_SKILL_IDS = new int[]{2031, 2032, 2037};     public AutoPotionTask(int itemId, Player player)      {         this.itemId = itemId;         this.player = player;     }     @Override     public void run()      {         if (player.isInOlympiadMode())          {             player.sendMessage("You cannot that in olympiad mode.");             player.stopAutoPotion(itemId);             return;         }                  if (player.isInJail() || player.isInsideZone(ZoneId.JAIL))          {             player.sendMessage("You cannot that in Jail mode.");             return;         }         if (Config.AUTO_POTIONS_LIMITS.containsKey(itemId))          {             String type = ((String[])Config.AUTO_POTIONS_LIMITS.get(itemId))[0];             int val = Integer.parseInt(((String[])Config.AUTO_POTIONS_LIMITS.get(itemId))[1]);             switch (type)              {                 case "CP":                 {                     if (!(player.getStatus().getCp() / (double)player.getStatus().getMaxCp() * 100.0 > (double)val)) break;                     return;                 }                 case "HP":                  {                     if (!(player.getStatus().getHp() / (double)player.getStatus().getMaxHp() * 100.0 > (double)val)) break;                     return;                 }                 case "MP":                  {                     if (!(player.getStatus().getMp() / (double)player.getStatus().getMaxMp() * 100.0 > (double)val)) break;                     return;                 }             }         }         if (!player.destroyItemByItemId("auto potion use", itemId, 1, null, true))          {             player.stopAutoPotion(itemId);             player.sendMessage("Incorrect item count.");             return;         }         if (player.getInventory().getItemByItemId(itemId) == null)          {             player.stopAutoPotion(itemId);             return;         }         IntIntHolder[] skills = player.getInventory().getItemByItemId(itemId).getEtcItem().getSkills();         if (skills == null)          {             _log.info("{} doesn't have any registered skill for handler." + player.getInventory().getItemByItemId(itemId).getName());             return;         }         for (IntIntHolder skillInfo : skills)          {             EffectTemplate template;             L2Skill itemSkill;             if (skillInfo == null || (itemSkill = skillInfo.getSkill()) == null) continue;             if (!itemSkill.checkCondition((Creature)player, (Creature)player, false))              {                 return;             }             if (player.isSkillDisabled(itemSkill))             {                 return;             }             if (itemSkill.isPotion() || itemSkill.isSimultaneousCast())              {                 player.getAI().tryToCast((Creature)player, itemSkill, false, false, itemId);             }              else              {                 player.getAI().tryToCast((Creature)player, itemSkill, false, false, itemId);             }             int skillId = skillInfo.getId();             if (!ArraysUtil.contains((int[])HP_POTION_SKILL_IDS, (int)skillId) || skillId < player.getShortBuffTaskSkillId() || (template = (EffectTemplate)itemSkill.getEffectTemplates().get(0)) == null) continue;             player.shortBuffStatusUpdate(skillId, skillInfo.getValue(), template.getCounter() * template.getPeriod());         }     }     public int getItemId()      {         return itemId;     } }  
    • @Ivan Pires como está as entregas automáticas desse painel?
×
×
  • Create New...

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.