Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.src;
- import java.awt.image.BufferedImage;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.OutputStreamWriter;
- import java.io.PrintStream;
- import java.net.MalformedURLException;
- import java.net.Socket;
- import java.net.URL;
- import java.net.UnknownHostException;
- import java.util.HashMap;
- import java.util.Map;
- import javax.imageio.ImageIO;
- import net.minecraft.client.Minecraft;
- import org.jibble.pircbot.*;
- public class teaminfo extends PircBot implements Runnable
- {
- static String channel;
- public String username;
- public String nick;
- public String tempusr;
- private static BufferedWriter bw;
- private boolean isRunning;
- boolean recievingnames;
- public static Map online = new HashMap();
- public static Map players = new HashMap();
- public static Map showgui = new HashMap();
- public static Map playershealth = new HashMap();
- public static Map playersprevhealth = new HashMap();
- public static Map playershunger = new HashMap();
- public static Map playersarmour = new HashMap();
- public static Map playerpoison = new HashMap();
- public static Map playerfireresist = new HashMap();
- public static Map playerweakness = new HashMap();
- public static Map playerswift = new HashMap();
- public static Map playerslow = new HashMap();
- public static Map playerregen = new HashMap();
- public static Map playerhungerdrain = new HashMap();
- public static Map playeronfire = new HashMap();
- public static Map playerposX = new HashMap();
- public static Map playerposY = new HashMap();
- public static Map playerposZ = new HashMap();
- public static Map playerskin = new HashMap();
- public static Map toplefti = new HashMap();
- public static Map topleftj = new HashMap();
- public static Map dragable = new HashMap();
- public static BufferedImage spowney;
- public static BufferedImage jay92;
- public static String[] usernames;
- public String[] junkyarray;
- public GuiScreen hello;
- public GuiAddtoTeam add = new GuiAddtoTeam(hello);
- int x = 0;
- public teaminfo(String s)
- {
- this.nick = s;
- this.isRunning = true;
- this.recievingnames = false;
- this.setName(nick);
- this.usernames = new String[100];
- this.junkyarray = new String[2];
- }
- //TODO: I need to add the ADDME thingy to the correct channel, using the PircBot classes
- public void onMessage(String channel, String sender, String login, String hostname, String message) {
- if(message.equalsIgnoreCase("hello")) {
- sendMessage(channel, sender + "Hello");
- }
- if(message.equalsIgnoreCase("PING")) {
- sendMessage(channel, "PONG");
- }
- if(message.contains((" ADDME ")) && (message.contains(nick))) {
- sendMessage(channel, "PRIVMSG " + add.getServerTextField() + " :" + "ADDME " + "HP" + powney.mc.thePlayer.health + "HUNGER" + powney.mc.thePlayer.foodStats.getFoodLevel() + "ARMOUR" + powney.mc.thePlayer.getTotalArmorValue() + "POISON" + powney.mc.thePlayer.isPotionActive(Potion.poison) + "FIRERESIST" + powney.mc.thePlayer.isPotionActive(Potion.fireResistance) + "WEAKNESS" + powney.mc.thePlayer.isPotionActive(Potion.weakness) + "SWIFT" + powney.mc.thePlayer.isPotionActive(Potion.digSpeed) + "SLOW" + powney.mc.thePlayer.isPotionActive(Potion.moveSlowdown) + "REGEN" + powney.mc.thePlayer.isPotionActive(Potion.regeneration) + "HUNGERDRAIN" + powney.mc.thePlayer.isPotionActive(Potion.hunger) + "ONFIRE" + powney.mc.thePlayer.isBurning() + "POSX" + (int)powney.mc.thePlayer.posX + "POSY" + (int)powney.mc.thePlayer.posY + "POSZ" + (int)powney.mc.thePlayer.posZ + "\n");
- }
- if(message.contains(("USN"))) {
- junkyarray = message.split("=");
- usernames[x++] = junkyarray[1];
- }
- }
- public void onJoin(String channel, String sender, String login, String hostname)
- {
- sendMessage(channel, "USN =" + nick);
- }
- public static void print(String s, String to)
- {
- try
- {
- // sendMessage(channel, "PRIVMSG " + to + " :" + s + "\n");
- }
- catch (Exception exception)
- {
- }
- }
- public static void requestadd(String to) {
- try {
- // sendMessage(channel, "PRIVMSG " + to + " :" + "ADDME " + "HP" + powney.mc.thePlayer.health + "HUNGER" + powney.mc.thePlayer.foodStats.getFoodLevel() + "ARMOUR" + powney.mc.thePlayer.getTotalArmorValue() + "POISON" + powney.mc.thePlayer.isPotionActive(Potion.poison) + "FIRERESIST" + powney.mc.thePlayer.isPotionActive(Potion.fireResistance) + "WEAKNESS" + powney.mc.thePlayer.isPotionActive(Potion.weakness) + "SWIFT" + powney.mc.thePlayer.isPotionActive(Potion.digSpeed) + "SLOW" + powney.mc.thePlayer.isPotionActive(Potion.moveSlowdown) + "REGEN" + powney.mc.thePlayer.isPotionActive(Potion.regeneration) + "HUNGERDRAIN" + powney.mc.thePlayer.isPotionActive(Potion.hunger) + "ONFIRE" + powney.mc.thePlayer.isBurning() + "POSX" + (int)powney.mc.thePlayer.posX + "POSY" + (int)powney.mc.thePlayer.posY + "POSZ" + (int)powney.mc.thePlayer.posZ + "\n");
- }
- catch (Exception exception)
- {
- }
- }
- public void acceptadd(String to) {
- try {
- int i=0;
- while(usernames[i]!=null) {
- if(usernames[i]==to) break;
- }
- if(usernames[i]!=null) {
- sendMessage(channel, "PRIVMSG " + usernames[i] + " :" + " ADDME " + "HP" + powney.mc.thePlayer.health + "HUNGER" + powney.mc.thePlayer.foodStats.getFoodLevel() + "ARMOUR" + powney.mc.thePlayer.getTotalArmorValue() + "POISON" + powney.mc.thePlayer.isPotionActive(Potion.poison) + "FIRERESIST" + powney.mc.thePlayer.isPotionActive(Potion.fireResistance) + "WEAKNESS" + powney.mc.thePlayer.isPotionActive(Potion.weakness) + "SWIFT" + powney.mc.thePlayer.isPotionActive(Potion.digSpeed) + "SLOW" + powney.mc.thePlayer.isPotionActive(Potion.moveSlowdown) + "REGEN" + powney.mc.thePlayer.isPotionActive(Potion.regeneration) + "HUNGERDRAIN" + powney.mc.thePlayer.isPotionActive(Potion.hunger) + "ONFIRE" + powney.mc.thePlayer.isBurning() + "POSX" + (int)powney.mc.thePlayer.posX + "POSY" + (int)powney.mc.thePlayer.posY + "POSZ" + (int)powney.mc.thePlayer.posZ + "\n");
- }
- }
- catch (Exception exception) {
- }
- add(to);
- }
- public static void rejectadd(String to)
- {
- try
- {
- // sendMessage(channel, "PRIVMSG " + to + " :" + " REJECT" + "\n");
- }
- catch (Exception exception)
- {
- }
- }
- public static void sendUpdate(String to) {
- try {
- // sendMessage(channel, "PRIVMSG " + to + " :" + " ADDME " + "HP" + powney.mc.thePlayer.health + "HUNGER" + powney.mc.thePlayer.foodStats.getFoodLevel() + "ARMOUR" + powney.mc.thePlayer.getTotalArmorValue() + "POISON" + powney.mc.thePlayer.isPotionActive(Potion.poison) + "FIRERESIST" + powney.mc.thePlayer.isPotionActive(Potion.fireResistance) + "WEAKNESS" + powney.mc.thePlayer.isPotionActive(Potion.weakness) + "SWIFT" + powney.mc.thePlayer.isPotionActive(Potion.digSpeed) + "SLOW" + powney.mc.thePlayer.isPotionActive(Potion.moveSlowdown) + "REGEN" + powney.mc.thePlayer.isPotionActive(Potion.regeneration) + "HUNGERDRAIN" + powney.mc.thePlayer.isPotionActive(Potion.hunger) + "ONFIRE" + powney.mc.thePlayer.isBurning() + "POSX" + (int)powney.mc.thePlayer.posX + "POSY" + (int)powney.mc.thePlayer.posY + "POSZ" + (int)powney.mc.thePlayer.posZ + "\n");
- }
- catch (Exception exception) {
- }
- }
- public static void interpretUpdate(String update) {
- String name = update.substring(1, update.indexOf("!"));
- String health = update.substring(update.indexOf("HP") + 2, update.indexOf("HUNGER"));
- String hunger = update.substring(update.indexOf("HUNGER") + 6, update.indexOf("ARMOUR"));
- String armour = update.substring(update.indexOf("ARMOUR") + 6, update.indexOf("POISON"));
- String poison = update.substring(update.indexOf("POISON") + 6, update.indexOf("FIRERESIST"));
- String fireresist = update.substring(update.indexOf("FIRERESIST") + 10, update.indexOf("WEAKNESS"));
- String weakness = update.substring(update.indexOf("WEAKNESS") + 8, update.indexOf("SWIFT"));
- String swift = update.substring(update.indexOf("SWIFT") + 5, update.indexOf("SLOW"));
- String slow = update.substring(update.indexOf("SLOW") + 4, update.indexOf("REGEN"));
- String regen = update.substring(update.indexOf("REGEN") + 5, update.indexOf("HUNGERDRAIN"));
- String hungerdrain = update.substring(update.indexOf("HUNGERDRAIN") + 11, update.indexOf("ONFIRE"));
- String onfire = update.substring(update.indexOf("ONFIRE") + 6, update.indexOf("POSX"));
- String posX = update.substring(update.indexOf("POSX") + 4, update.indexOf("POSY"));
- String posY = update.substring(update.indexOf("POSY") + 4, update.indexOf("POSZ"));
- String posZ = update.substring(update.indexOf("POSZ") + 4);
- if (playershealth.containsKey(name))
- {
- playersprevhealth.put(name, playershealth.get(name));
- }
- playershealth.put(name, Integer.valueOf(Integer.parseInt(health)));
- playershunger.put(name, Integer.valueOf(Integer.parseInt(hunger)));
- playersarmour.put(name, Integer.valueOf(Integer.parseInt(armour)));
- playerpoison.put(name, Boolean.valueOf(Boolean.parseBoolean(poison)));
- playerfireresist.put(name, Boolean.valueOf(Boolean.parseBoolean(fireresist)));
- playerweakness.put(name, Boolean.valueOf(Boolean.parseBoolean(weakness)));
- playerswift.put(name, Boolean.valueOf(Boolean.parseBoolean(swift)));
- playerslow.put(name, Boolean.valueOf(Boolean.parseBoolean(slow)));
- playerregen.put(name, Boolean.valueOf(Boolean.parseBoolean(regen)));
- playerhungerdrain.put(name, Boolean.valueOf(Boolean.parseBoolean(hungerdrain)));
- playeronfire.put(name, Boolean.valueOf(Boolean.parseBoolean(onfire)));
- playerposX.put(name, Integer.valueOf(Integer.parseInt(posX)));
- playerposY.put(name, Integer.valueOf(Integer.parseInt(posY)));
- playerposZ.put(name, Integer.valueOf(Integer.parseInt(posZ)));
- }
- public static void add(String s)
- {
- players.put(s, Boolean.valueOf(true));
- showgui.put(s, Boolean.valueOf(true));
- ScaledResolution scaledresolution = new ScaledResolution(powney.mc.gameSettings, powney.mc.displayWidth, powney.mc.displayHeight);
- int k = scaledresolution.getScaledWidth();
- toplefti.put(s, Integer.valueOf(k - 110));
- topleftj.put(s, Integer.valueOf(players.size() * 35));
- URL skinUrl = null;
- try {
- skinUrl = new URL("http://s3.amazonaws.com/MinecraftSkins/" + s + ".png");
- }
- catch (MalformedURLException e) {
- e.printStackTrace();
- }
- BufferedImage bi = null;
- try {
- bi = ImageIO.read(skinUrl);
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- playerskin.put(s, bi);
- }
- public static void remove(String s)
- {
- players.remove(s);
- powney.mc.thePlayer.addChatMessage("§c" + s + "§f was removed from your team info.");
- try
- {
- bw.write("PRIVMSG " + s + " :" + " REMOVE " + "\n");
- bw.flush();
- }
- catch (Exception exception) {
- }
- }
- public static void forceremove(String s) {
- players.remove(s);
- powney.mc.thePlayer.addChatMessage("§c" + s + "§f requested that you stop sharing info.");
- }
- public void run()
- {
- URL skinUrl = null;
- try {
- skinUrl = new URL("http://s3.amazonaws.com/MinecraftSkins/" + "spowney" + ".png");
- }
- catch (MalformedURLException e) {
- e.printStackTrace();
- }
- try {
- spowney = ImageIO.read(skinUrl);
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- try {
- skinUrl = new URL("http://s3.amazonaws.com/MinecraftSkins/" + "Jay_92" + ".png");
- }
- catch (MalformedURLException e) {
- e.printStackTrace();
- }
- try {
- jay92 = ImageIO.read(skinUrl);
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- String s = "irc.esper.net";
- String s1 = this.nick;
- channel = "#teaminfomod";
- System.out.println("PRIVMSG " + "rainfur" + " :" + " ADDME ");
- int c = 6667;
- try
- {
- Socket socket = new Socket(s, c);
- bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
- BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
- //the logging in
- //bw = irc.esper.net
- bw.write("NICK " + this.nick + "\n");
- bw.write("USER " + s1 + " Team Info :Team Info Mod\n");
- bw.flush();
- //this is the RECIEVE code, not the send
- while (this.isRunning)
- {
- String s2 = null;
- while ((s2 = bufferedreader.readLine()) != null)
- {
- if (s2.contains("PING"))
- {
- bw.write("PONG " + s2.substring(s2.indexOf(":")) + "\n");
- bw.flush();
- continue;
- }
- if ((s2.contains(" ADDME ")) && (s2.contains(nick)))
- {
- String s4 = s2.substring(1, s2.indexOf("!"));
- powney.mc.displayGuiScreen(new GuiAddReject(powney.mc.currentScreen, s4, s2));
- continue;
- }if ((s2.contains("REMOVE")) && (s2.contains(nick)))
- {
- String s4 = s2.substring(1, s2.indexOf("!"));
- forceremove(s4);
- continue;
- }if ((s2.contains("REJECT")) && (s2.contains(nick)))
- {
- String s4 = s2.substring(1, s2.indexOf("!"));
- powney.mc.thePlayer.addChatMessage("Your request was rejected by §c" + s4 + "§f");
- continue;
- }if ((s2.contains(" PRIVMSG ")) && (s2.contains(nick)) && (s2.contains("UPDATE")))
- {
- String s3 = s2.substring(s2.indexOf(":", s2.indexOf("PRIVMSG")) + 1);
- String s4 = s2.substring(1, s2.indexOf("!"));
- interpretUpdate(s2);
- continue;
- }if ((s2.contains(" PRIVMSG ")) && (s2.contains(nick)) && (s2.contains("ADDED")))
- {
- String s3 = s2.substring(s2.indexOf(":", s2.indexOf("PRIVMSG")) + 1);
- String s4 = s2.substring(1, s2.indexOf("!"));
- powney.mc.thePlayer.addChatMessage("Your request was accepted by §c" + s4 + "§f");
- add(s4);
- interpretUpdate(s2);
- continue;
- }if ((s2.contains(" MODE ")) && (s2.contains(nick)))
- {
- try
- {
- bw.write("JOIN " + channel + "\n");
- bw.flush(); } catch (Exception exception) {
- }
- continue;
- }
- if ((s2.contains(" PART ")) || (s2.contains(" QUIT ")))
- {
- String s4 = s2.substring(1, s2.indexOf("!"));
- online.remove(s4);
- players.remove(s4);
- if (players.containsKey(s4))
- {
- players.remove(s4);
- }
- continue;
- }
- if ((s2.contains(" JOIN ")) && (!s2.contains(nick)))
- {
- String s4 = s2.substring(1, s2.indexOf("!"));
- online.put(s4, Boolean.valueOf(false));
- continue;
- }
- if (!s2.contains(" " + nick + " = " + channel + " :"))
- continue;
- String s4 = s2.substring(s2.indexOf(" :"));
- String[] names = s4.split(" ");
- for (int i = 0; i < names.length; i++)
- {
- if (names[i].startsWith("@"))
- {
- names[i] = names[i].substring(names[i].indexOf("@") + 1);
- }
- online.put(names[i], Boolean.valueOf(false));
- }
- }
- }
- }
- catch (UnknownHostException unknownhostexception)
- {
- System.err.println("No such host");
- }
- catch (IOException ioexception)
- {
- System.err.println("There was an error connecting to the host");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement