Created
January 2, 2013 23:30
-
-
Save zack6849/4439365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package multithread; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.net.Socket; | |
import java.util.logging.Handler; | |
import java.util.logging.LogManager; | |
import org.bukkit.Bukkit; | |
public class CommandExecutor implements Runnable{ | |
public static BufferedReader in; | |
public static Socket s; | |
public static PrintWriter out; | |
public CommandExecutor(Socket s, BufferedReader in, PrintWriter out){ | |
this.in = in; | |
this.s = s; | |
this.out = out; | |
} | |
public void run(){ | |
Bukkit.getLogger().addHandler(new LoggerHandler(out)); | |
while(true){ | |
try { | |
String line = in.readLine(); | |
if(line != null){ | |
if(line.startsWith("/")){ | |
BukkitPlugin.log.info("[" + Clienthandler.user + "] executed command " + line); | |
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), line.replaceFirst("/", "")); | |
}else{ | |
Bukkit.broadcastMessage("[" + Clienthandler.user + "] " + line); | |
} | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
public static void close(){ | |
try{ | |
Clienthandler.close(); | |
Server.close(); | |
}catch(Exception e){ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment