2016-03-05 21:03:06 +00:00
|
|
|
package me.totalfreedom.bukkittelnet.session;
|
2014-03-20 16:57:22 +00:00
|
|
|
|
2016-03-05 21:03:06 +00:00
|
|
|
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
|
|
|
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
2014-03-20 16:57:22 +00:00
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.OutputStreamWriter;
|
|
|
|
import java.net.Socket;
|
2016-06-18 15:25:57 +00:00
|
|
|
import java.net.SocketException;
|
2014-03-20 16:57:22 +00:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.regex.Pattern;
|
2016-03-05 21:03:06 +00:00
|
|
|
import me.totalfreedom.bukkittelnet.TelnetLogger;
|
|
|
|
import me.totalfreedom.bukkittelnet.TelnetServer;
|
|
|
|
import me.totalfreedom.bukkittelnet.Util;
|
2014-03-20 16:57:22 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Server;
|
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
|
|
|
|
public final class ClientSession extends Thread
|
|
|
|
{
|
2016-03-05 21:03:06 +00:00
|
|
|
|
2014-03-20 16:57:22 +00:00
|
|
|
public static final Pattern NONASCII_FILTER = Pattern.compile("[^\\x20-\\x7E]");
|
2016-06-18 15:38:33 +00:00
|
|
|
public static final Pattern AUTH_INPUT_FILTER = Pattern.compile("[^_a-zA-Z0-9]");
|
|
|
|
public static final Pattern COMMAND_INPUT_FILTER = Pattern.compile("^[^_a-zA-Z0-9/\\?!\\.]+");
|
2014-03-20 16:57:22 +00:00
|
|
|
//
|
2016-03-05 21:03:06 +00:00
|
|
|
private final TelnetServer telnet;
|
2014-03-20 16:57:22 +00:00
|
|
|
private final Socket clientSocket;
|
|
|
|
private final String clientAddress;
|
|
|
|
private final SessionCommandSender commandSender;
|
2016-03-05 21:03:06 +00:00
|
|
|
//
|
2016-06-18 15:38:33 +00:00
|
|
|
private FilterMode filterMode = FilterMode.NONE;
|
2014-03-20 16:57:22 +00:00
|
|
|
//
|
|
|
|
private BufferedWriter writer;
|
|
|
|
private BufferedReader reader;
|
2016-06-18 15:38:33 +00:00
|
|
|
private String username = "";
|
|
|
|
private volatile boolean terminated = false;
|
|
|
|
private volatile boolean authenticated = false;
|
2020-03-30 06:05:25 +00:00
|
|
|
private boolean enhancedMode = false;
|
|
|
|
private boolean enhancedPlusMode = false;
|
2014-03-20 16:57:22 +00:00
|
|
|
|
2016-03-05 21:03:06 +00:00
|
|
|
public ClientSession(TelnetServer telnet, Socket clientSocket)
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
2016-03-05 21:03:06 +00:00
|
|
|
this.telnet = telnet;
|
2014-03-20 16:57:22 +00:00
|
|
|
this.clientSocket = clientSocket;
|
|
|
|
this.clientAddress = clientSocket.getInetAddress().getHostAddress();
|
|
|
|
this.commandSender = new SessionCommandSender(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
synchronized (clientSocket)
|
|
|
|
{
|
|
|
|
reader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
|
|
|
|
writer = new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
|
|
|
TelnetLogger.severe(ex);
|
|
|
|
syncTerminateSession();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Session Started.");
|
2014-03-20 16:57:22 +00:00
|
|
|
|
|
|
|
if (!authenticate())
|
|
|
|
{
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Authentication failed.");
|
2014-03-20 16:57:22 +00:00
|
|
|
syncTerminateSession();
|
|
|
|
}
|
|
|
|
|
2016-06-18 15:25:57 +00:00
|
|
|
writeLine("Logged in as " + username + ".");
|
|
|
|
TelnetLogger.info(clientAddress + " logged in as \"" + username + "\".");
|
|
|
|
|
|
|
|
// Start feeding data to the client.
|
|
|
|
telnet.getPlugin().appender.addSession(this);
|
|
|
|
|
2014-03-20 16:57:22 +00:00
|
|
|
mainLoop();
|
2016-06-18 15:25:57 +00:00
|
|
|
|
2014-03-20 16:57:22 +00:00
|
|
|
syncTerminateSession();
|
2020-03-30 06:05:25 +00:00
|
|
|
|
|
|
|
telnet.getPlugin().listener.triggerUsageUpdates();
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|
|
|
|
|
2016-06-18 15:38:33 +00:00
|
|
|
public boolean syncIsAuthenticated()
|
|
|
|
{
|
|
|
|
return authenticated;
|
|
|
|
}
|
|
|
|
|
2014-03-20 16:57:22 +00:00
|
|
|
public boolean syncIsConnected()
|
|
|
|
{
|
|
|
|
synchronized (clientSocket)
|
|
|
|
{
|
|
|
|
return !clientSocket.isClosed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void syncTerminateSession()
|
|
|
|
{
|
2016-06-18 15:38:33 +00:00
|
|
|
if (terminated)
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-18 15:38:33 +00:00
|
|
|
terminated = true;
|
|
|
|
|
|
|
|
if (authenticated)
|
|
|
|
{
|
|
|
|
TelnetLogger.info("Closing connection: " + clientAddress + (username.isEmpty() ? "" : " (" + username + ")"));
|
|
|
|
}
|
2014-03-20 16:57:22 +00:00
|
|
|
|
2016-06-18 15:38:33 +00:00
|
|
|
// Stop feeding the client with data
|
2016-03-05 21:03:06 +00:00
|
|
|
telnet.getPlugin().appender.removeSession(this);
|
2014-03-20 16:57:22 +00:00
|
|
|
|
|
|
|
synchronized (clientSocket)
|
|
|
|
{
|
|
|
|
if (clientSocket == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Closing connection...");
|
2014-03-20 16:57:22 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
clientSocket.close();
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getUserName()
|
|
|
|
{
|
|
|
|
return username;
|
|
|
|
}
|
|
|
|
|
|
|
|
public SessionCommandSender getCommandSender()
|
|
|
|
{
|
|
|
|
return commandSender;
|
|
|
|
}
|
|
|
|
|
|
|
|
public FilterMode getFilterMode()
|
|
|
|
{
|
|
|
|
return filterMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFilterMode(FilterMode filterMode)
|
|
|
|
{
|
|
|
|
this.filterMode = filterMode;
|
|
|
|
}
|
|
|
|
|
2016-03-05 21:03:06 +00:00
|
|
|
public void writeLine(String message)
|
|
|
|
{
|
|
|
|
writeRawLine("[" + (username.isEmpty() ? "" : username + "@") + "BukkitTelnet]$ " + message);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void writeRawLine(String message)
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
|
|
|
if (writer == null || !syncIsConnected())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-08-18 00:52:57 +00:00
|
|
|
writer.write(":" + ChatColor.stripColor(message) + "\r\n");
|
2014-03-20 16:57:22 +00:00
|
|
|
writer.flush();
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void flush()
|
|
|
|
{
|
|
|
|
if (writer == null || !syncIsConnected())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
writer.flush();
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void syncExecuteCommand(final String command)
|
|
|
|
{
|
|
|
|
new BukkitRunnable()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
final Server server = Bukkit.getServer();
|
|
|
|
|
|
|
|
final TelnetCommandEvent event = new TelnetCommandEvent(commandSender, command);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
2016-03-05 21:03:06 +00:00
|
|
|
if (event.isCancelled() || event.getCommand().isEmpty())
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
server.dispatchCommand(event.getSender(), event.getCommand());
|
|
|
|
}
|
2016-03-05 21:03:06 +00:00
|
|
|
}.runTask(telnet.getPlugin());
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private boolean authenticate()
|
|
|
|
{
|
2016-06-18 15:38:33 +00:00
|
|
|
if (terminated)
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-21 10:34:01 +00:00
|
|
|
boolean passAuth = false;
|
2014-03-20 16:57:22 +00:00
|
|
|
|
|
|
|
// Pre-authenticate IP addresses
|
|
|
|
if (clientAddress != null)
|
|
|
|
{
|
2016-03-05 21:03:06 +00:00
|
|
|
final Map<String, List<String>> admins = telnet.getConfig().getAdmins();
|
2014-03-20 16:57:22 +00:00
|
|
|
|
|
|
|
// For every admin
|
|
|
|
for (String name : admins.keySet())
|
|
|
|
{
|
|
|
|
|
|
|
|
// For every IP of each admin
|
|
|
|
for (String ip : admins.get(name))
|
|
|
|
{
|
|
|
|
if (Util.fuzzyIpMatch(ip, clientAddress, 3))
|
|
|
|
{
|
2014-03-21 10:34:01 +00:00
|
|
|
passAuth = true;
|
2014-03-20 16:57:22 +00:00
|
|
|
this.username = name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-21 10:34:01 +00:00
|
|
|
// TelnetPreLoginEvent authentication
|
|
|
|
final TelnetPreLoginEvent event = new TelnetPreLoginEvent(clientAddress, username, passAuth);
|
2014-03-20 16:57:22 +00:00
|
|
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.canBypassPassword())
|
|
|
|
{
|
2014-03-21 10:34:01 +00:00
|
|
|
if (!event.getName().isEmpty()) // If the name hasn't been set, we'll ask for it.
|
|
|
|
{
|
|
|
|
this.username = event.getName();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
passAuth = true;
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|
|
|
|
|
2014-03-21 10:34:01 +00:00
|
|
|
// Username
|
2014-03-20 16:57:22 +00:00
|
|
|
boolean validUsername = false;
|
|
|
|
|
|
|
|
int tries = 0;
|
|
|
|
while (tries++ < 3)
|
|
|
|
{
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Username: ");
|
2014-03-20 16:57:22 +00:00
|
|
|
|
|
|
|
String input;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
input = reader.readLine();
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
2014-09-07 15:22:13 +00:00
|
|
|
break;
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|
|
|
|
|
2014-09-07 15:22:13 +00:00
|
|
|
if (input == null)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2016-06-18 15:38:33 +00:00
|
|
|
|
2014-09-07 15:22:13 +00:00
|
|
|
if (input.isEmpty())
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
input = AUTH_INPUT_FILTER.matcher(input).replaceAll("").trim();
|
|
|
|
|
2016-06-18 15:38:33 +00:00
|
|
|
if (input.isEmpty() || input.length() > 20)
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Invalid username.");
|
2014-03-20 16:57:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.username = input;
|
|
|
|
validUsername = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!validUsername)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-21 10:34:01 +00:00
|
|
|
// If the TelnetPreLoginEvent authenticates the password,
|
|
|
|
// don't ask for it.
|
|
|
|
if (passAuth)
|
|
|
|
{
|
2016-06-18 15:38:33 +00:00
|
|
|
authenticated = true;
|
2014-03-21 10:34:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Password
|
2014-03-20 16:57:22 +00:00
|
|
|
tries = 0;
|
|
|
|
while (tries++ < 3)
|
|
|
|
{
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Password: ");
|
2014-03-20 16:57:22 +00:00
|
|
|
|
|
|
|
String input;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
input = reader.readLine();
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
2016-06-18 15:38:33 +00:00
|
|
|
return false;
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|
|
|
|
|
2014-09-07 15:22:13 +00:00
|
|
|
if (input == null)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (input.isEmpty())
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
input = AUTH_INPUT_FILTER.matcher(input).replaceAll("").trim();
|
|
|
|
|
2016-03-05 21:03:06 +00:00
|
|
|
if (telnet.getConfig().getPassword().equals(input))
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
2016-06-18 15:38:33 +00:00
|
|
|
authenticated = true;
|
2014-03-20 16:57:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Invalid password.");
|
2014-03-20 16:57:22 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Thread.sleep(2000);
|
|
|
|
}
|
|
|
|
catch (InterruptedException ex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void mainLoop()
|
|
|
|
{
|
2016-06-18 15:38:33 +00:00
|
|
|
if (terminated)
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-21 10:34:01 +00:00
|
|
|
// Process commands
|
2014-03-20 16:57:22 +00:00
|
|
|
while (syncIsConnected())
|
|
|
|
{
|
|
|
|
// Read a command
|
|
|
|
String command;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
command = reader.readLine();
|
|
|
|
}
|
2016-06-18 15:25:57 +00:00
|
|
|
catch (SocketException ex)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2014-03-20 16:57:22 +00:00
|
|
|
catch (IOException ex)
|
|
|
|
{
|
2016-03-05 21:03:06 +00:00
|
|
|
TelnetLogger.severe(ex);
|
2014-09-07 15:22:13 +00:00
|
|
|
break;
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|
|
|
|
|
2014-08-18 00:52:57 +00:00
|
|
|
if (command == null)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (command.isEmpty())
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
command = COMMAND_INPUT_FILTER.matcher(NONASCII_FILTER.matcher(command).replaceAll("")).replaceFirst("").trim();
|
|
|
|
if (command.isEmpty())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command.toLowerCase().startsWith("telnet"))
|
|
|
|
{
|
|
|
|
executeTelnetCommand(command);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
syncExecuteCommand(command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-17 00:33:55 +00:00
|
|
|
private void executeTelnetCommand(final String command)
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
2014-08-17 00:33:55 +00:00
|
|
|
if ("telnet.help".equalsIgnoreCase(command))
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("--- Telnet commands ---");
|
|
|
|
writeLine("telnet.help - See all of the telnet commands.");
|
|
|
|
writeLine("telnet.stop - Shut the server down.");
|
|
|
|
writeLine("telnet.log - Change your logging settings.");
|
|
|
|
writeLine("telnet.exit - Quit the telnet session.");
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|
2014-08-17 00:33:55 +00:00
|
|
|
else if ("telnet.stop".equalsIgnoreCase(command))
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Shutting down the server...");
|
2014-03-20 16:57:22 +00:00
|
|
|
TelnetLogger.warning(username + ": Shutting down the server...");
|
2016-03-05 21:03:06 +00:00
|
|
|
Bukkit.shutdown();
|
2014-03-20 16:57:22 +00:00
|
|
|
System.exit(0);
|
|
|
|
}
|
2014-08-17 00:33:55 +00:00
|
|
|
else if ("telnet.log".equalsIgnoreCase(command))
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
2014-08-17 00:33:55 +00:00
|
|
|
switch (filterMode)
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
2016-06-18 15:38:33 +00:00
|
|
|
case NONE:
|
2014-08-17 00:33:55 +00:00
|
|
|
{
|
|
|
|
filterMode = FilterMode.CHAT_ONLY;
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Showing only chat logs.");
|
2014-08-17 00:33:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CHAT_ONLY:
|
|
|
|
{
|
|
|
|
filterMode = FilterMode.NONCHAT_ONLY;
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Showing only non-chat logs.");
|
2014-08-17 00:33:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NONCHAT_ONLY:
|
|
|
|
{
|
2016-06-18 15:38:33 +00:00
|
|
|
filterMode = FilterMode.NONE;
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Showing all logs.");
|
2014-08-17 00:33:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|
2014-08-17 00:33:55 +00:00
|
|
|
}
|
|
|
|
else if ("telnet.exit".equalsIgnoreCase(command))
|
|
|
|
{
|
2016-03-05 21:03:06 +00:00
|
|
|
writeLine("Goodbye. <3");
|
2014-08-17 00:33:55 +00:00
|
|
|
syncTerminateSession();
|
|
|
|
}
|
|
|
|
else if ("telnet.enhanced".equalsIgnoreCase(command))
|
|
|
|
{
|
|
|
|
enhancedMode = !enhancedMode;
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine((enhancedMode ? "A" : "Dea") + "ctivated enhanced mode.");
|
2014-08-17 03:10:52 +00:00
|
|
|
if (enhancedMode)
|
|
|
|
{
|
2016-03-05 21:03:06 +00:00
|
|
|
telnet.getPlugin().listener.triggerPlayerListUpdates();
|
2014-08-17 03:10:52 +00:00
|
|
|
}
|
2014-08-17 00:33:55 +00:00
|
|
|
}
|
2020-03-30 06:05:25 +00:00
|
|
|
else if ("telnet.enhancedplus".equalsIgnoreCase(command))
|
|
|
|
{
|
|
|
|
enhancedPlusMode = !enhancedPlusMode;
|
|
|
|
writeLine((enhancedPlusMode ? "A" : "Dea") + "ctivated enhanced+ mode.");
|
|
|
|
}
|
2014-08-17 00:33:55 +00:00
|
|
|
else
|
|
|
|
{
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("Invalid telnet command, use \"telnet.help\" to view help.");
|
2014-08-17 00:33:55 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-20 16:57:22 +00:00
|
|
|
|
2014-08-17 00:33:55 +00:00
|
|
|
public void syncTriggerPlayerListUpdate(String playerListData)
|
|
|
|
{
|
|
|
|
if (!enhancedMode)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-03-20 16:57:22 +00:00
|
|
|
|
2014-08-17 00:33:55 +00:00
|
|
|
synchronized (clientSocket)
|
|
|
|
{
|
|
|
|
if (clientSocket.isClosed())
|
2014-03-20 16:57:22 +00:00
|
|
|
{
|
2014-03-21 10:34:01 +00:00
|
|
|
return;
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|
|
|
|
|
2014-08-18 00:52:57 +00:00
|
|
|
writeLine("playerList~" + playerListData);
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-30 06:05:25 +00:00
|
|
|
|
|
|
|
public void syncUsageUpdate(String usageData)
|
|
|
|
{
|
|
|
|
if (!enhancedPlusMode)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
synchronized (clientSocket)
|
|
|
|
{
|
|
|
|
if (clientSocket.isClosed())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
writeLine("usage~" + usageData);
|
|
|
|
}
|
|
|
|
}
|
2014-03-20 16:57:22 +00:00
|
|
|
}
|