Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.82 KB | None | 0 0
  1. package scripts.lib.tone;
  2.  
  3. import javax.sound.sampled.AudioFormat;
  4. import javax.sound.sampled.AudioSystem;
  5. import javax.sound.sampled.LineUnavailableException;
  6. import javax.sound.sampled.SourceDataLine;
  7.  
  8. public class Tone {
  9. public static float SAMPLE_RATE = 8000f;
  10.  
  11. public static void tone(int hz, int msecs, double vol) {
  12. try {
  13. byte[] buf = new byte[1];
  14. AudioFormat af =
  15. new AudioFormat(SAMPLE_RATE, 8, 1, true, false);
  16. SourceDataLine sdl;
  17.  
  18. sdl = AudioSystem.getSourceDataLine(af);
  19. sdl.open(af);
  20. sdl.start();
  21. for (int i = 0; i < msecs * 8; i++) {
  22. double angle = i / (SAMPLE_RATE / hz) * 2.0 * Math.PI;
  23. buf[0] = (byte) (Math.sin(angle) * 127.0 * vol);
  24. sdl.write(buf, 0, 1);
  25. }
  26. sdl.drain();
  27. sdl.stop();
  28. sdl.close();
  29. } catch (LineUnavailableException e) {
  30. e.printStackTrace();
  31. }
  32. }
  33. }
  34.  
  35. -----------------------------------------
  36. package scripts.scripts.chickenKiller.util;
  37.  
  38. public class Ids {
  39.  
  40. }
  41.  
  42. -----------------------------------------
  43. package scripts.scripts.chickenKiller.util;
  44.  
  45. import org.tribot.api2007.types.RSArea;
  46. import org.tribot.api2007.types.RSTile;
  47.  
  48. public class Areas {
  49. public static RSArea chickenCoup = new RSArea(new RSTile[]{new RSTile(3234, 3301, 0), new RSTile(3235, 3301, 0), new RSTile(3236, 3300, 0), new RSTile(3237, 3299, 0),
  50. new RSTile(3237, 3298, 0), new RSTile(3236, 3297, 0), new RSTile(3236, 3293, 0), new RSTile(3237, 3292, 0),
  51. new RSTile(3237, 3291, 0), new RSTile(3236, 3290, 0), new RSTile(3236, 3288, 0), new RSTile(3235, 3287, 0),
  52. new RSTile(3232, 3287, 0), new RSTile(3231, 3287, 0), new RSTile(3231, 3295, 0), new RSTile(3227, 3295, 0),
  53. new RSTile(3226, 3296, 0), new RSTile(3225, 3296, 0), new RSTile(3225, 3300, 0), new RSTile(3226, 3301, 0)});
  54. }
  55.  
  56. -----------------------------------------
  57. package scripts.lib.timer;
  58.  
  59. import org.tribot.api.General;
  60.  
  61. public class Timer {
  62. private long startTime;
  63. private long duration;
  64.  
  65. /**
  66. * Creates a new Timer with the duration l.
  67. *
  68. * @param l duration of the timer
  69. */
  70. public Timer(long l) {
  71. this(l, -1);
  72. }
  73.  
  74. public Timer(long l, int type) {
  75. switch (type) {
  76. case 1:
  77. this.startTime = System.currentTimeMillis();
  78. this.duration = General.random(0, (int) l) + General.random(0, (int) l) + l;
  79. break;
  80. default:
  81. this.startTime = System.currentTimeMillis();
  82. this.duration = l;
  83. break;
  84. }
  85. }
  86.  
  87. /**
  88. * Compares start time, duration, and current time to return weather or not the timer is still running.
  89. *
  90. * @return true if timer is still running otherwise false.
  91. */
  92. public boolean isRunning() {
  93. if (startTime + duration > System.currentTimeMillis())
  94. return true;
  95. return false;
  96. }
  97.  
  98. public int timeRunning() {
  99. if (!isRunning())
  100. return (int) duration;
  101. int timeRunning = (int) (System.currentTimeMillis() - startTime);
  102. return timeRunning > 0 ? timeRunning : 0;
  103. }
  104. }
  105. -----------------------------------------
  106. package scripts.node;
  107.  
  108. import scripts.lib.script.Script;
  109.  
  110. public abstract class Node {
  111. public Script s;
  112. public Object o;
  113.  
  114. public Node(Object s) {
  115. this.s = (Script) s;
  116. this.o = s;
  117. }
  118.  
  119. public abstract boolean activate();
  120.  
  121. public abstract void execute();
  122.  
  123. public abstract String status();
  124. }
  125.  
  126. -----------------------------------------
  127. package scripts.lib.runtime;
  128.  
  129. public class RunTime {
  130. private long startTime;
  131.  
  132. public RunTime() {
  133. this.startTime = System.currentTimeMillis();
  134. }
  135.  
  136. public int getSeconds() {
  137. return (int) ((System.currentTimeMillis() - startTime) / 1000);
  138. }
  139.  
  140. public int getMins() {
  141. return getSeconds() / 60;
  142. }
  143.  
  144. public int getHours() {
  145. return getMins() / 60;
  146. }
  147.  
  148. public String getRunTime() {
  149. if (getHours() > 3) {
  150. return getHours() + "h";
  151. } else if (getMins() > 5) {
  152. return getMins() + "m";
  153. } else {
  154. return getSeconds() + "s";
  155. }
  156. }
  157.  
  158. }
  159.  
  160. -----------------------------------------
  161. package scripts.lib.generic;
  162.  
  163. import java.nio.charset.Charset;
  164. import java.security.MessageDigest;
  165. import java.security.NoSuchAlgorithmException;
  166. import java.util.Map;
  167. import java.util.TreeMap;
  168.  
  169. public class StringFunctions {
  170. public static int stringToInt(String name, int base, int mult, int max) {
  171. name = name.toLowerCase().trim();
  172. int hash = base;
  173. for (int i = 0; i < name.length(); i++)
  174. hash = hash * mult + name.charAt(i);
  175. return (int) (Math.floor(((max / 2) * Math.sin(hash) + (max / 2))));
  176. }
  177.  
  178. public static Map<String, String> string2Map(String str, Charset encoding, String delimeter) {
  179. String[] atributes = str.split(delimeter);
  180. Map<String, String> s = new TreeMap<String, String>();
  181. for (String i : atributes) {
  182. s.put(i.substring(0, i.indexOf("=")), i.substring(i.indexOf("=") + 1).trim());
  183. }
  184. return s;
  185. }
  186.  
  187. public static String normalize(String text) {
  188. text = text.toLowerCase().trim();
  189. final StringBuilder sb = new StringBuilder(text.length());
  190. final char[] chars = text.toCharArray();
  191. for (final char c : chars) {
  192. if (Character.isLetterOrDigit(c)) {
  193. sb.append(c);
  194. } else if (c == '-' || c == '_') {
  195. sb.append('_');
  196. } else {
  197. sb.append('_');
  198. }
  199. }
  200. return sb.toString();
  201. }
  202.  
  203. public static String cryptWithMD5(String pass) {
  204. try {
  205. MessageDigest md = MessageDigest.getInstance("MD5");
  206. byte[] passBytes = pass.getBytes();
  207. md.reset();
  208. byte[] digested = md.digest(passBytes);
  209. StringBuffer sb = new StringBuffer();
  210. for (int i = 0; i < digested.length; i++) {
  211. sb.append(Integer.toHexString(0xff & digested[i]));
  212. }
  213. return sb.toString();
  214. } catch (NoSuchAlgorithmException e) {
  215. e.printStackTrace();
  216. }
  217. return null;
  218. }
  219. public static String formatName(String name){
  220. String out = "";
  221. char lastChar = ' ';
  222. for(char c:name.toCharArray()) {
  223. if(lastChar == ' ')
  224. c = Character.toUpperCase(c);
  225. out = out+c;
  226. }
  227. return out.trim();
  228. }
  229. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement