Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.PrintWriter;
- import java.net.Socket;
- import java.net.UnknownHostException;
- public class Bridge {
- static Socket s;
- static PrintWriter w;
- static String myname = null;
- public static void connect(String myname, String ip){
- Bridge.myname = myname;
- try {
- s = new Socket(ip, 9843);
- } catch (UnknownHostException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- w = new PrintWriter(s.getOutputStream());
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- final BufferedReader read = new BufferedReader(new InputStreamReader(s.getInputStream()));
- new Thread(){
- public void run(){
- String raw;
- try {
- while((raw=read.readLine())!=null){
- //The Bungee the message is coming from
- String sourceBungee = raw.split("~")[0];
- //The command
- String cmd = raw.split("~")[1];
- //****************************************************
- //Handle your stuff here
- //****************************************************
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }.start();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public static void send(String cmd){
- w.println(myname+"~"+cmd);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement