mirror of
https://github.com/TotalFreedomMC/BukkitTelnet.git
synced 2024-06-27 16:31:03 +00:00
Added telnet.filter <full | chat | nonchat>
This commit is contained in:
parent
e34693f2f7
commit
7a5128fc4b
|
@ -17,6 +17,10 @@ import org.bukkit.plugin.Plugin;
|
|||
|
||||
public class BT_TelnetListener extends Handler implements CommandSender
|
||||
{
|
||||
private enum FilterMode
|
||||
{
|
||||
FULL, NONCHAT_ONLY, CHAT_ONLY
|
||||
}
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private boolean is_running = false;
|
||||
private boolean is_authenticated = false;
|
||||
|
@ -28,7 +32,7 @@ public class BT_TelnetListener extends Handler implements CommandSender
|
|||
private BufferedWriter outstream;
|
||||
private BukkitTelnet plugin;
|
||||
private String client_ip;
|
||||
private boolean show_full_log = true;
|
||||
private FilterMode filter_mode = FilterMode.FULL;
|
||||
private static final String COMMAND_REGEX = "[^\\x20-\\x7E]";
|
||||
private static final String LOGIN_REGEX = "[^a-zA-Z0-9\\-\\.\\_]";
|
||||
|
||||
|
@ -180,19 +184,42 @@ public class BT_TelnetListener extends Handler implements CommandSender
|
|||
{
|
||||
if (command.toLowerCase().startsWith("telnet"))
|
||||
{
|
||||
if (command.equalsIgnoreCase("telnet.log"))
|
||||
if (command.equalsIgnoreCase("telnet.log")) // for legacy use
|
||||
{
|
||||
show_full_log = !show_full_log;
|
||||
if (show_full_log)
|
||||
if (filter_mode == FilterMode.CHAT_ONLY)
|
||||
{
|
||||
filter_mode = FilterMode.FULL;
|
||||
writeOut("Showing full console log.\r\n:");
|
||||
}
|
||||
else
|
||||
{
|
||||
filter_mode = FilterMode.CHAT_ONLY;
|
||||
writeOut("Showing chat log only.\r\n:");
|
||||
}
|
||||
}
|
||||
if (command.equalsIgnoreCase("telnet.exit"))
|
||||
else if (command.toLowerCase().startsWith("telnet.filter"))
|
||||
{
|
||||
if (command.equalsIgnoreCase("telnet.filter full"))
|
||||
{
|
||||
filter_mode = FilterMode.FULL;
|
||||
writeOut("Showing full console log.\r\n:");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("telnet.filter chat"))
|
||||
{
|
||||
filter_mode = FilterMode.CHAT_ONLY;
|
||||
writeOut("Showing chat log only.\r\n:");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("telnet.filter nonchat"))
|
||||
{
|
||||
filter_mode = FilterMode.NONCHAT_ONLY;
|
||||
writeOut("Showing everything but chat.\r\n:");
|
||||
}
|
||||
else
|
||||
{
|
||||
writeOut("Usage: telnet.filter <full | chat | nonchat>.\r\n:");
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase("telnet.exit"))
|
||||
{
|
||||
shutdown();
|
||||
}
|
||||
|
@ -248,7 +275,6 @@ public class BT_TelnetListener extends Handler implements CommandSender
|
|||
// {
|
||||
// writeOut(("" + ((char) 255) + ((char) command) + ((char) option)));
|
||||
// }
|
||||
|
||||
private void writeOut(String message)
|
||||
{
|
||||
if (outstream != null)
|
||||
|
@ -283,11 +309,30 @@ public class BT_TelnetListener extends Handler implements CommandSender
|
|||
{
|
||||
String message = ChatColor.stripColor(record.getMessage());
|
||||
|
||||
if (show_full_log || message.startsWith("<") || message.startsWith("[Server:") || message.startsWith("[CONSOLE]<"))
|
||||
boolean is_chat = message.startsWith("<") || message.startsWith("[Server:") || message.startsWith("[CONSOLE]<");
|
||||
|
||||
switch (filter_mode)
|
||||
{
|
||||
case CHAT_ONLY:
|
||||
{
|
||||
if (!is_chat)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
case NONCHAT_ONLY:
|
||||
{
|
||||
if (is_chat)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
writeOut(message + "\r\n:");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush()
|
||||
|
|
Loading…
Reference in a new issue