mirror of
https://github.com/TotalFreedomMC/BukkitTelnet.git
synced 2025-08-05 12:02:55 +00:00
mc 1.5 update
This commit is contained in:
parent
3ca030eb13
commit
db6f0ad30a
4 changed files with 60 additions and 17 deletions
|
@ -26,7 +26,7 @@ dist.jar=${dist.dir}/MCTelnet.jar
|
||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
excludes=
|
||||||
file.reference.craftbukkit.jar=jars/440/craftbukkit.jar
|
file.reference.craftbukkit.jar=C:\\Users\\Administrator\\Documents\\NetBeansProjects\\CBJars\\craftbukkit.jar
|
||||||
includes=**
|
includes=**
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -37,6 +38,7 @@ public class MCTelnet extends JavaPlugin {
|
||||||
private Thread listenerThread;
|
private Thread listenerThread;
|
||||||
private boolean run = false;
|
private boolean run = false;
|
||||||
int port = 8765;
|
int port = 8765;
|
||||||
|
InetAddress listenAddress;
|
||||||
|
|
||||||
public MCTelnet()
|
public MCTelnet()
|
||||||
{
|
{
|
||||||
|
@ -53,11 +55,20 @@ public class MCTelnet extends JavaPlugin {
|
||||||
if(listenerSocket != null)
|
if(listenerSocket != null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
synchronized (listenerSocket)
|
||||||
|
{
|
||||||
|
if(listenerSocket!=null)
|
||||||
listenerSocket.close();
|
listenerSocket.close();
|
||||||
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
Logger.getLogger(MCTelnet.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
@ -69,8 +80,25 @@ public class MCTelnet extends JavaPlugin {
|
||||||
if(this.getConfiguration().getBoolean("encryptPasswords", false))
|
if(this.getConfiguration().getBoolean("encryptPasswords", false))
|
||||||
encryptPasswords();
|
encryptPasswords();
|
||||||
port = this.getConfiguration().getInt("telnetPort", port);
|
port = this.getConfiguration().getInt("telnetPort", port);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String address = this.getConfiguration().getString("listenAddress",null);
|
||||||
|
if(address!=null)
|
||||||
|
listenAddress = InetAddress.getByName(address);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.out.println("[MCTelnet] Exception when trying to binding to custom address:" + ex.getMessage());
|
||||||
|
}
|
||||||
|
if(listenAddress != null)
|
||||||
|
{
|
||||||
|
listenerSocket = new java.net.ServerSocket(port, 10, listenAddress);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
listenerSocket = new java.net.ServerSocket(port,10);
|
||||||
|
}
|
||||||
clientHolder = new ArrayList<TelnetListener>();
|
clientHolder = new ArrayList<TelnetListener>();
|
||||||
listenerSocket = new java.net.ServerSocket(port);
|
|
||||||
listenerThread = new Thread(new Runnable() {
|
listenerThread = new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
acceptConnections();
|
acceptConnections();
|
||||||
|
@ -80,8 +108,7 @@ public class MCTelnet extends JavaPlugin {
|
||||||
Field cfield = CraftServer.class.getDeclaredField("console");
|
Field cfield = CraftServer.class.getDeclaredField("console");
|
||||||
cfield.setAccessible(true);
|
cfield.setAccessible(true);
|
||||||
mcserv = (MinecraftServer) cfield.get((CraftServer)getServer());
|
mcserv = (MinecraftServer) cfield.get((CraftServer)getServer());
|
||||||
|
Logger.getLogger("Minecraft").log(Level.INFO,"[MCTelnet] - Listening on: " + listenerSocket.getInetAddress().getHostAddress() + ":" + port);
|
||||||
Logger.getLogger("Minecraft").log(Level.INFO,"[MCTelnet] - Listening on port: " + port + "!");
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger("Minecraft").log(Level.SEVERE, "[MCTelnet] - Unable to Enable! Error: " + ex.getMessage());
|
Logger.getLogger("Minecraft").log(Level.SEVERE, "[MCTelnet] - Unable to Enable! Error: " + ex.getMessage());
|
||||||
this.setEnabled(false);
|
this.setEnabled(false);
|
||||||
|
@ -174,6 +201,11 @@ public class MCTelnet extends JavaPlugin {
|
||||||
this.getConfiguration().setProperty("telnetPort", 8765);
|
this.getConfiguration().setProperty("telnetPort", 8765);
|
||||||
this.getConfiguration().save();
|
this.getConfiguration().save();
|
||||||
}
|
}
|
||||||
|
testConfig = this.getConfiguration().getString("listenAddress");
|
||||||
|
if (testConfig == null || testConfig.equals("")) {
|
||||||
|
this.getConfiguration().setProperty("listenAddress", "0.0.0.0");
|
||||||
|
this.getConfiguration().save();
|
||||||
|
}
|
||||||
testConfig = this.getConfiguration().getString("rootPass");
|
testConfig = this.getConfiguration().getString("rootPass");
|
||||||
if (testConfig == null || testConfig.equals("")) {
|
if (testConfig == null || testConfig.equals("")) {
|
||||||
this.getConfiguration().setProperty("rootPass", "abcd");
|
this.getConfiguration().setProperty("rootPass", "abcd");
|
||||||
|
@ -190,6 +222,7 @@ public class MCTelnet extends JavaPlugin {
|
||||||
this.getConfiguration().setProperty("encryptPasswords", true);
|
this.getConfiguration().setProperty("encryptPasswords", true);
|
||||||
this.getConfiguration().save();
|
this.getConfiguration().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,21 +15,17 @@ import java.util.logging.Handler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import net.minecraft.server.ICommandListener;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.command.PluginCommand;
|
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.config.ConfigurationNode;
|
import org.bukkit.util.config.ConfigurationNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class TelnetListener extends Handler implements CommandSender {
|
public class TelnetListener extends Handler implements CommandSender, ICommandListener {
|
||||||
|
|
||||||
private boolean run;
|
private boolean run;
|
||||||
private boolean isAuth;
|
private boolean isAuth;
|
||||||
|
@ -43,8 +39,8 @@ public class TelnetListener extends Handler implements CommandSender {
|
||||||
BufferedWriter outstream;
|
BufferedWriter outstream;
|
||||||
MCTelnet parent;
|
MCTelnet parent;
|
||||||
String ip;
|
String ip;
|
||||||
String passRegex = "[^a-zA-Z0-9\\-]";
|
String passRegex = "[^a-zA-Z0-9\\-\\.\\_]";
|
||||||
String commandRegex = "[^a-zA-Z0-9 \\-]";
|
String commandRegex = "[^a-zA-Z0-9 \\-\\.\\_]";
|
||||||
|
|
||||||
public TelnetListener(Socket inSock, MinecraftServer imcserv, MCTelnet iparent)
|
public TelnetListener(Socket inSock, MinecraftServer imcserv, MCTelnet iparent)
|
||||||
{
|
{
|
||||||
|
@ -80,7 +76,16 @@ public class TelnetListener extends Handler implements CommandSender {
|
||||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||||
run = false;
|
run = false;
|
||||||
}
|
}
|
||||||
|
if(!clientSocket.getInetAddress().isLoopbackAddress() || !parent.getConfiguration().getBoolean("allowAuthlessLocalhost", false))
|
||||||
|
{
|
||||||
authenticateLoop();
|
authenticateLoop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isAuth = true;
|
||||||
|
isRoot = true;
|
||||||
|
authUser = parent.getConfiguration().getString("rootUser");
|
||||||
|
}
|
||||||
commandLoop();
|
commandLoop();
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
|
@ -230,8 +235,9 @@ public class TelnetListener extends Handler implements CommandSender {
|
||||||
if (!clientSocket.isClosed()) {
|
if (!clientSocket.isClosed()) {
|
||||||
if (isRoot || allowCommand) {
|
if (isRoot || allowCommand) {
|
||||||
//((CraftServer)getServer()).dispatchCommand(new ConsoleCommandSender(getServer()), command);
|
//((CraftServer)getServer()).dispatchCommand(new ConsoleCommandSender(getServer()), command);
|
||||||
mcserv.a(command, mcserv);
|
mcserv.issueCommand(command, this);
|
||||||
//parent.getServer().getPlayer(authUser).performCommand(command);
|
System.out.println("[MCTelnet] "+authUser+" issued command: " + command);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(!command.equals(""))
|
if(!command.equals(""))
|
||||||
{
|
{
|
||||||
|
@ -345,4 +351,8 @@ public class TelnetListener extends Handler implements CommandSender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return authUser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: MCTelnet
|
name: MCTelnet
|
||||||
main: com.bekvon.bukkit.mctelnet.MCTelnet
|
main: com.bekvon.bukkit.mctelnet.MCTelnet
|
||||||
version: 1.2.1
|
version: 1.2.5
|
||||||
description: Telnet console access plugin.
|
description: Telnet console access plugin.
|
||||||
author: bekvon
|
author: bekvon
|
||||||
commands:
|
commands:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue