Skip to content

Instantly share code, notes, and snippets.

@Williams0ff
Last active January 16, 2023 17:43
Show Gist options
  • Save Williams0ff/a214f6ba8fa0bf323b21036d08befb37 to your computer and use it in GitHub Desktop.
Save Williams0ff/a214f6ba8fa0bf323b21036d08befb37 to your computer and use it in GitHub Desktop.
AutoGb L2jOne
diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/voicecommandhandlers/AutoBanking.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/voicecommandhandlers/AutoBanking.java
new file mode 100644
index 0000000..92cd85f
--- /dev/null
+++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/voicecommandhandlers/AutoBanking.java
@@ -0,0 +1,59 @@
+package net.sf.l2j.gameserver.handler.voicecommandhandlers;
+
+import java.util.concurrent.ScheduledFuture;
+
+import net.sf.l2j.commons.pool.ThreadPool;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.actor.Player;
+import net.sf.l2j.gameserver.network.serverpackets.ItemList;
+
+public class AutoBanking implements IVoicedCommandHandler
+{
+ private ScheduledFuture<?> _feeTask;
+
+ private static final String[] COMMANDS =
+ {
+ "autogb"
+ };
+
+ @Override
+ public void useVoicedCommand(final String command, final Player player, final String target)
+ {
+ if (command.equalsIgnoreCase("autogb"))
+ {
+ if (player.getMemos().containsKey("autoGB"))
+ {
+ if (_feeTask != null)
+ {
+ _feeTask.cancel(false);
+ _feeTask = null;
+ }
+
+ player.getMemos().unset("autoGB");
+ }
+ else
+ {
+ player.getMemos().set("autoGB", true);
+ _feeTask = ThreadPool.scheduleAtFixedRate(() -> autoGoldBar(player), 1000, 1000);
+ }
+ }
+ }
+
+ public void autoGoldBar(Player player)
+ {
+ if (player.getInventory().getItemCount(57, 0) >= 1000000)
+ {
+ player.getInventory().reduceAdena("Goldbar", 1000000, player, null);
+ player.getInventory().addItem("Goldbar", 3470, 1, player, null);
+ player.getInventory().updateDatabase();
+ player.sendPacket(new ItemList(player, false));
+ }
+ }
+
+ @Override
+ public String[] getVoicedCommands()
+ {
+ return COMMANDS;
+ }
+}
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment