Some late X-mas gift for everyone

Forum for game modifications and custom clients.

Some late X-mas gift for everyone

Postby Taipion » Mon Jan 01, 2018 9:55 pm

Hello fellow Salemites! :-)

I feel not only due to the time of the year, that it's time for me to give something back.

In this post you will find 2 things that some may find interesting, or even useful.

First:

A public release of my ClickAllPlugin.
It is the most simple and still one of the most useful plugins that I made so far,
and for the good health of everyone's hands/fingers and some extended mouse-lifetime,
I'd say it's a good thing in general to have a bit less click spamming in Salem. ^^

This plugin is simple:
1. Take any item into your hand (cursor)
2. Activate plugin (HotKey "u")
3. The plugin will now drop the item in hand into your inventory,
and then proceed to right-click all items in your inventory with that name.
You can chose default flower menu actions in latikais, and in combination with the plugin
you can, for instance, slice/split/study/... all of one kind of item easily.
4.(optional) with pressing (recommend holding for a second) the hotkey "u" again, it can be interrupted any time.

Link to a compiled jar

Here comes all relevant java code, look into the latikais-plugin-thread for how to put that into a plugin:

Code: Select all
package haven.plugins;

import haven.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class ClickAllPlugin extends Plugin {

   public boolean isRunning = false;
   public boolean signalToStop = false;

   public void load(UI ui) {
      Glob glob = ui.sess.glob;
      Collection<Glob.Pagina> p = glob.paginae;
      p.add(glob.paginafor(Resource.load("paginae/add/clickall")));
      XTendedPaginae.registerPlugin("clickall", this);
   }

   public void execute(final UI ui) {

      if (isRunning) {
         signalToStop = true;
      } else {
         isRunning = true;

         new Thread(new Runnable() {
            @Override
            public void run() {

               // String for the name of the item in hand (cursor)
               String itemResName = "";

               if (!ui.gui.hand.isEmpty()) {

                  Iterator<GItem> handContent = ui.gui.hand.iterator();
                  while (handContent.hasNext()) {
                     GItem item = handContent.next();
                     itemResName = item.resname();
                     ui.message("[ClickAllPlugin] Hand contains: " + itemResName, GameUI.MsgType.INFO);
                  }

                  if (ui.gui.maininv.getSameName("", true).size() > 1023) {
                     ui.message("[ClickAllPlugin] Your inventory is full, please free up at least one space!", GameUI.MsgType.INFO);
                     isRunning = false;
                     signalToStop = false;
                     return;
                  }

                  ui.message("[ClickAllPlugin] Dropping item in hand to inventory and clicking all items with the same name, please wait...", GameUI.MsgType.INFO);


                  // next is finding an empty inventory slot...
                  boolean[][] grid = new boolean[32][32];
                  int x = 0;
                  int y = 0;

                  boolean dontDrop = false;
                  List<WItem> items = ui.gui.maininv.getSameName("", true);
                  for (int i = items.size() - 1; i < items.size() && i >= 0; i--) {

                     WItem subject = items.get(i);

                     x = subject.server_c.x;
                     y = subject.server_c.y;

                     if (y < 32 && x < 32) {
                        grid[x][y] = true;
                     } else {
                        dontDrop = true;
                     }

                  }

                  // ...and droping the item in hand to the first free spot in the inventory
                  outerLoop: for (int i = 0; i < 32 && !dontDrop; i++) {
                     for (int j = 0; j < 32; j++) {
                        if (!grid[j][i]) {

                           ui.wdgmsg(ui.instance.gui.maininv, "drop", new Coord(j, i));
                           try {
                              Thread.sleep(300);
                           } catch (InterruptedException ex) {
                           }
                           break outerLoop;
                        }
                     }
                  }

                  // get all items in the inventory
                  items = ui.gui.maininv.getSameName("", true);
                  
                  // right-click each one that matches the name of the item previously in our hand
                  for (int i = items.size() - 1; i < items.size() && i >= 0; i--) {

                     WItem subject = items.get(i);

                     if (subject.item.resname().equals(itemResName)) {
                        subject.mousedown(Coord.z, 3);
                        try {
                           Thread.sleep(350);
                        } catch (InterruptedException ex) {
                        }

                     }

                     if (signalToStop) {
                        break;
                     }
                  }

               } else {
                  ui.message("[ClickAllPlugin] Your hand (cursor) is empty, take an Item into your hand and try again.", GameUI.MsgType.INFO);
               }

               ui.message("[ClickAllPlugin] Done with clicking!", GameUI.MsgType.INFO);
               if (signalToStop) {
                  ui.message("[ClickAllPlugin] Exiting...", GameUI.MsgType.INFO);
                  try {
                     Thread.sleep(2000);
                  } catch (InterruptedException ex) {
                  }
               }
               ui.message("[ClickAllPlugin] Stopped.", GameUI.MsgType.INFO);
               isRunning = false;
               signalToStop = false;
            } // END of run
         }, "Click all").start(); // END of thread
      }
   }
}

Note:
This plugin is ofc approved by the devs.
If you intend to do ANY plugin yourself, you MUST pm them first and ask if the intended functionality is allowed or not.


Second:

As I know some people still prefer enders,
and some fellow player wearing the name of a German quantum-physics-scientist asked me to do it, ^^
here I present to you all:

A salem.jar for enders client, with cravings! :D

(both the original cravings code and the little update JC pushed for the mason lodge thingy)

You can download the jar here

Instructions:
1. download the jar
2. replace the jar in your salem folder with it (in windows under "...Users/YourUserName/Salem/bin")
3. make new file write-protected so it won't get replaced with the default jar by the launcher

Simply delete the jar in case you want to use the original again, like, in case ender starts pushing updates again, the launcher will automatically get you a new one.
Need something? Here is my Shop (Including some useful info for new/returning players at the bottom of the first post)
Taipion
 
Posts: 2659
Joined: Fri Mar 08, 2013 4:12 pm

Return to Artifice & Arcana

Who is online

Users browsing this forum: No registered users and 10 guests

cron