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.net.Socket;
- import java.util.logging.Logger;
- class ClientWorker
- implements Runnable
- {
- private Socket client;
- protected static final Logger log = Logger.getLogger("Minecraft");
- ClientWorker(Socket client) {
- this.client = client;
- }
- public void exec_meow(String line) {
- PropertiesFile options = new PropertiesFile("mcban.properties");
- for (Player pi : etc.getServer().getPlayerList())
- if (pi.isAdmin()) {
- log.info(line);
- Boolean enable_mcbansay = Boolean.valueOf(options.getBoolean("chat_enable"));
- if (enable_mcbansay.booleanValue())
- pi.sendMessage("§4[MCBans Chat] §f" + line);
- }
- }
- public void run()
- {
- BufferedReader in = null;
- try {
- in = new BufferedReader(new InputStreamReader(
- this.client.getInputStream()));
- } catch (Exception e) {
- log.severe("[MCBANS] MCBans Chat Error, could not read message (pre).");
- }
- while (true)
- try
- {
- String line = in.readLine();
- if ((line == null) || (line.isEmpty())) break;
- exec_meow(line); continue;
- }
- catch (Exception e)
- {
- log.severe("[MCBANS] MCBans Chat Error, could not read message (post).");
- try {
- this.client.close();
- } catch (IOException i) {
- log.severe("[MCBANS] MCBans Chat Error, could not close client socket.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment