- import java.awt.Color;
- import java.awt.Font;
- import java.awt.FontFormatException;
- import java.awt.Graphics;
- import java.awt.GraphicsEnvironment;
- import java.awt.font.FontRenderContext;
- import java.awt.geom.Rectangle2D;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import org.runedream.api.Script;
- import org.runedream.api.ScriptManifest;
- import org.runedream.api.methods.Environment;
- import org.runedream.api.methods.Game;
- import org.runedream.api.util.Log;
- @ScriptManifest(
- authors = { "TBT" },
- name = "Debugger",
- version = 1.0,
- description = "Debugs my shit",
- keywords = { ""},
- language = { true, true, true, true })
- public class Debugger extends Script {
- @Override
- public boolean onStart() {
- return true;
- }
- @Override
- public int loop() {
- Font font = null;
- try {
- font = Font.createFont(Font.TRUETYPE_FONT, new File(Environment.getStorageDirectoryPath() + "/chat.ttf"));
- } catch (FontFormatException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
- ge.registerFont(font);
- final Font chatFont = new Font(font.getName(), Font.PLAIN, 16);
- final FontRenderContext frc = new FontRenderContext(null, false, false);
- final Rectangle2D bounds = chatFont.getStringBounds("Hola", frc);
- int bw = (int)bounds.getWidth();
- int bh = (int)bounds.getHeight();
- haha: for(int x = 9; x < 490-bw; x++) {
- for(int y = 440; y < 490-bh; y++) {
- BufferedImage copy = Game.getImage();
- Graphics g = copy.getGraphics();
- g.setFont(chatFont);
- g.setColor(new Color(0, 0, 255));
- g.drawString("Hola", x, y);
- BufferedImage c1 = Game.getImage().getSubimage(x, y-bh, bw, bh);
- BufferedImage c2 = copy.getSubimage(x, y-bh, bw, bh);
- for(int i = 0; i < c1.getWidth(); i++) {
- for(int i2 = 0; i2 < c1.getHeight(); i2++) {
- if(c1.getRGB(i, i2) != c2.getRGB(i, i2))
- continue haha;
- }
- }
- g.setColor(new Color(255,0,0,100));
- g.fillRect(x, y-bh, bw, bh);
- try {
- ImageIO.write(copy, "png", new File("done.png"));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Log.log(x + ", " +y);
- break haha;
- }
- }
- return -1;
- }
- }