Jump to content

Aces_

Members
  • Posts

    6
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

Recent Profile Visitors

1001 profile views

Aces_'s Achievements

Newbie

Newbie (1/10)

3

Reputation

  1. It is outside the Script file so I've left it like this
  2. Presenting you easy generic SAVE/LOAD implementation, feel free to use : (some of the Load and Save class implementations are copypasted from help section) Save Class: import java.io.*; import java.util.Base64; public class Save { private PrintWriter pw; String localDir = System.getProperty("user.home") + File.separator + "OSBot" + File.separator + "data" + File.separator; public Save(String localName) { try { pw = new PrintWriter(localDir + localName + ".ini"); System.out.println(pw.toString() + "\n" + localDir); } catch (FileNotFoundException e) { e.printStackTrace(); } } public boolean writeString(String s) { pw.println(s); pw.close(); return true; } public boolean writeObject(Serializable o) throws IOException { writeString(toString(o)); System.out.println(toString(o)); return true; } private static String toString(Serializable o) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(o); oos.close(); return Base64.getEncoder().encodeToString(baos.toByteArray()); } } Load class: import java.io.*; import java.nio.charset.Charset; import java.util.Base64; public class Load { private BufferedReader br; private InputStream fis; private InputStreamReader isr; private boolean finished = false; String localDir = System.getProperty("user.home") + File.separator + "OSBot" + File.separator + "data" + File.separator; public Load(String localName) { try { fis = new FileInputStream(localDir + localName + ".ini"); isr = new InputStreamReader(fis, Charset.forName("UTF-8")); br = new BufferedReader(isr); } catch (FileNotFoundException e) { e.printStackTrace(); } } public String readLine() throws IOException { String line = null; if (!finished) { line = br.readLine(); if (line == null) finished = true; } else { if (br != null) { br.close(); fis.close(); isr.close(); br = null; } } return line; } public Object readObject() throws IOException, ClassNotFoundException { return fromString(readLine()); } private static Object fromString( String s ) throws IOException , ClassNotFoundException { byte [] data = Base64.getDecoder().decode( s ); ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream( data ) ); Object o = ois.readObject(); ois.close(); return o; } } How it works? FOR SAVING All you have to do is create a Save class that you are going to use: Save save = new Save("Filename"); And saving class that contains information about your bot: //make sure that your Properties class implements "Serializable" Properties propertiesofBot = new Properties("My properties class"); save.writeObject(propertiesofBot); FOR LOADING: //Make sure you create Load class with same name as the Save class Load load = new Load("Filename"); And all you need to do is load and save the class to the variable Properties properties = (Properties) load.readObject(); Saving or loading classes that differ is not supported. Hope this helps!
  3. Daamn, thought it was somewhere in the API
  4. Hi, how do I get the data for Webwalker? Is there any graph that represents walkable tiles that can be walked and that cannot? I need information about portals, ladders and that stuff too. I want to implement my own webwalker and release it to public.
  5. Is there any way to update the bot by its source without actually exporting the project as Jar file? for Example after ctrl + S using eclipse?
  6. Thanks, but how about underground paths?
×
×
  • Create New...