mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
add ssh support
This commit is contained in:
parent
746ccdfd44
commit
7c6c407f78
6
pom.xml
6
pom.xml
@ -168,6 +168,12 @@
|
||||
<version>6.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.TFPatches</groupId>
|
||||
<artifactId>BukkitSSH</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -16,6 +16,7 @@ import me.totalfreedom.totalfreedommod.blocking.PVPBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.SignBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
||||
import me.totalfreedom.totalfreedommod.bridge.BukkitSSHBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
||||
@ -126,6 +127,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
// Bridges
|
||||
public ServiceManager<TotalFreedomMod> bridges;
|
||||
public BukkitTelnetBridge btb;
|
||||
public BukkitSSHBridge bsb;
|
||||
public EssentialsBridge esb;
|
||||
public LibsDisguisesBridge ldb;
|
||||
public CoreProtectBridge cpb;
|
||||
@ -243,6 +245,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
// Start bridges
|
||||
bridges = new ServiceManager<>(plugin);
|
||||
btb = bridges.registerService(BukkitTelnetBridge.class);
|
||||
bsb = bridges.registerService(BukkitSSHBridge.class);
|
||||
cpb = bridges.registerService(CoreProtectBridge.class);
|
||||
esb = bridges.registerService(EssentialsBridge.class);
|
||||
ldb = bridges.registerService(LibsDisguisesBridge.class);
|
||||
|
@ -15,6 +15,7 @@ import net.pravian.aero.base.Validatable;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -0,0 +1,94 @@
|
||||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import com.ryanmichela.bukkitssh.BukkitSSH;
|
||||
import com.ryanmichela.bukkitssh.SshTerminal;
|
||||
import me.totalfreedom.bukkitssh.SSHCommandEvent;
|
||||
import me.totalfreedom.bukkitssh.SSHPreLoginEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BukkitSSHBridge extends FreedomService
|
||||
{
|
||||
|
||||
private BukkitSSH BukkitSSHPlugin = null;
|
||||
|
||||
public BukkitSSHBridge(TotalFreedomMod plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onTelnetPreLogin(SSHPreLoginEvent event)
|
||||
{
|
||||
|
||||
final String ip = event.getIp();
|
||||
if (ip == null || ip.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
|
||||
|
||||
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setBypassPassword(true);
|
||||
event.setName(admin.getName());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onTelnetCommand(SSHCommandEvent event)
|
||||
{
|
||||
if (plugin.cb.isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
public BukkitSSH getBukkitSSHPlugin()
|
||||
{
|
||||
if (BukkitSSHPlugin == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Plugin BukkitSSH = server.getPluginManager().getPlugin("BukkitSSH");
|
||||
if (BukkitSSH != null)
|
||||
{
|
||||
if (BukkitSSH instanceof BukkitSSH)
|
||||
{
|
||||
BukkitSSHPlugin = (BukkitSSH)BukkitSSH;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return BukkitSSHPlugin;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user