Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.lib.tone;
- import javax.sound.sampled.AudioFormat;
- import javax.sound.sampled.AudioSystem;
- import javax.sound.sampled.LineUnavailableException;
- import javax.sound.sampled.SourceDataLine;
- public class Tone {
- public static float SAMPLE_RATE = 8000f;
- public static void tone(int hz, int msecs, double vol) {
- try {
- byte[] buf = new byte[1];
- AudioFormat af =
- new AudioFormat(SAMPLE_RATE, 8, 1, true, false);
- SourceDataLine sdl;
- sdl = AudioSystem.getSourceDataLine(af);
- sdl.open(af);
- sdl.start();
- for (int i = 0; i < msecs * 8; i++) {
- double angle = i / (SAMPLE_RATE / hz) * 2.0 * Math.PI;
- buf[0] = (byte) (Math.sin(angle) * 127.0 * vol);
- sdl.write(buf, 0, 1);
- }
- sdl.drain();
- sdl.stop();
- sdl.close();
- } catch (LineUnavailableException e) {
- e.printStackTrace();
- }
- }
- }
- -----------------------------------------
- package scripts.scripts.chickenKiller.util;
- public class Ids {
- }
- -----------------------------------------
- package scripts.scripts.chickenKiller.util;
- import org.tribot.api2007.types.RSArea;
- import org.tribot.api2007.types.RSTile;
- public class Areas {
- 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),
- new RSTile(3237, 3298, 0), new RSTile(3236, 3297, 0), new RSTile(3236, 3293, 0), new RSTile(3237, 3292, 0),
- new RSTile(3237, 3291, 0), new RSTile(3236, 3290, 0), new RSTile(3236, 3288, 0), new RSTile(3235, 3287, 0),
- new RSTile(3232, 3287, 0), new RSTile(3231, 3287, 0), new RSTile(3231, 3295, 0), new RSTile(3227, 3295, 0),
- new RSTile(3226, 3296, 0), new RSTile(3225, 3296, 0), new RSTile(3225, 3300, 0), new RSTile(3226, 3301, 0)});
- }
- -----------------------------------------
- package scripts.lib.timer;
- import org.tribot.api.General;
- public class Timer {
- private long startTime;
- private long duration;
- /**
- * Creates a new Timer with the duration l.
- *
- * @param l duration of the timer
- */
- public Timer(long l) {
- this(l, -1);
- }
- public Timer(long l, int type) {
- switch (type) {
- case 1:
- this.startTime = System.currentTimeMillis();
- this.duration = General.random(0, (int) l) + General.random(0, (int) l) + l;
- break;
- default:
- this.startTime = System.currentTimeMillis();
- this.duration = l;
- break;
- }
- }
- /**
- * Compares start time, duration, and current time to return weather or not the timer is still running.
- *
- * @return true if timer is still running otherwise false.
- */
- public boolean isRunning() {
- if (startTime + duration > System.currentTimeMillis())
- return true;
- return false;
- }
- public int timeRunning() {
- if (!isRunning())
- return (int) duration;
- int timeRunning = (int) (System.currentTimeMillis() - startTime);
- return timeRunning > 0 ? timeRunning : 0;
- }
- }
- -----------------------------------------
- package scripts.node;
- import scripts.lib.script.Script;
- public abstract class Node {
- public Script s;
- public Object o;
- public Node(Object s) {
- this.s = (Script) s;
- this.o = s;
- }
- public abstract boolean activate();
- public abstract void execute();
- public abstract String status();
- }
- -----------------------------------------
- package scripts.lib.runtime;
- public class RunTime {
- private long startTime;
- public RunTime() {
- this.startTime = System.currentTimeMillis();
- }
- public int getSeconds() {
- return (int) ((System.currentTimeMillis() - startTime) / 1000);
- }
- public int getMins() {
- return getSeconds() / 60;
- }
- public int getHours() {
- return getMins() / 60;
- }
- public String getRunTime() {
- if (getHours() > 3) {
- return getHours() + "h";
- } else if (getMins() > 5) {
- return getMins() + "m";
- } else {
- return getSeconds() + "s";
- }
- }
- }
- -----------------------------------------
- package scripts.lib.generic;
- import java.nio.charset.Charset;
- import java.security.MessageDigest;
- import java.security.NoSuchAlgorithmException;
- import java.util.Map;
- import java.util.TreeMap;
- public class StringFunctions {
- public static int stringToInt(String name, int base, int mult, int max) {
- name = name.toLowerCase().trim();
- int hash = base;
- for (int i = 0; i < name.length(); i++)
- hash = hash * mult + name.charAt(i);
- return (int) (Math.floor(((max / 2) * Math.sin(hash) + (max / 2))));
- }
- public static Map<String, String> string2Map(String str, Charset encoding, String delimeter) {
- String[] atributes = str.split(delimeter);
- Map<String, String> s = new TreeMap<String, String>();
- for (String i : atributes) {
- s.put(i.substring(0, i.indexOf("=")), i.substring(i.indexOf("=") + 1).trim());
- }
- return s;
- }
- public static String normalize(String text) {
- text = text.toLowerCase().trim();
- final StringBuilder sb = new StringBuilder(text.length());
- final char[] chars = text.toCharArray();
- for (final char c : chars) {
- if (Character.isLetterOrDigit(c)) {
- sb.append(c);
- } else if (c == '-' || c == '_') {
- sb.append('_');
- } else {
- sb.append('_');
- }
- }
- return sb.toString();
- }
- public static String cryptWithMD5(String pass) {
- try {
- MessageDigest md = MessageDigest.getInstance("MD5");
- byte[] passBytes = pass.getBytes();
- md.reset();
- byte[] digested = md.digest(passBytes);
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < digested.length; i++) {
- sb.append(Integer.toHexString(0xff & digested[i]));
- }
- return sb.toString();
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- }
- return null;
- }
- public static String formatName(String name){
- String out = "";
- char lastChar = ' ';
- for(char c:name.toCharArray()) {
- if(lastChar == ' ')
- c = Character.toUpperCase(c);
- out = out+c;
- }
- return out.trim();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement