Logviewer registration overhaul.

This commit is contained in:
Steven Lawson
2017-08-01 15:59:24 -04:00
parent 3bc8adfb98
commit b55ca70056
5 changed files with 175 additions and 59 deletions

View File

@ -5,6 +5,8 @@ import java.util.Date;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.base.ConfigLoadable;
@ -25,7 +27,6 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
@Setter
private String name;
@Getter
@Setter
private boolean active = true;
@Getter
@Setter
@ -138,6 +139,26 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
ips.clear();
}
public void setActive(boolean active)
{
this.active = active;
final TotalFreedomMod plugin = TotalFreedomMod.plugin();
if (!active)
{
if (getRank().isAtLeast(Rank.TELNET_ADMIN))
{
if (plugin.btb != null)
{
plugin.btb.killTelnetSessions(getName());
}
}
plugin.lv.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE);
}
}
@Override
public boolean isValid()
{

View File

@ -10,7 +10,6 @@ import java.util.concurrent.TimeUnit;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.Command_logs;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
@ -272,6 +271,14 @@ public class AdminList extends FreedomService
public boolean removeAdmin(Admin admin)
{
if (admin.getRank().isAtLeast(Rank.TELNET_ADMIN))
{
if (plugin.btb != null)
{
plugin.btb.killTelnetSessions(admin.getName());
}
}
// Remove admin, update views
if (allAdmins.remove(admin.getConfigKey()) == null)
{
@ -345,7 +352,6 @@ public class AdminList extends FreedomService
}
admin.setActive(false);
plugin.lv.deactivateSuperadmin(admin);
}
save();