Replace IPs of admins that are higher or equal to you in rank with their fuzzied IPs, and make /saconfig info always return the admin's fuzzied IPs. Also, if you're not a senior admin, you are unable to view full IPs. Closes #44.

This commit is contained in:
Business Goose 2022-03-29 23:01:21 +01:00
parent 659867dfce
commit 0b293b7a0d
No known key found for this signature in database
GPG key ID: 77DCA801362E9645
5 changed files with 53 additions and 2 deletions

View file

@ -7,9 +7,11 @@ import me.StevenLawson.TotalFreedomMod.ban.BanManager;
import me.StevenLawson.TotalFreedomMod.ban.PermbanList;
import me.StevenLawson.TotalFreedomMod.bridge.EssentialsBridge;
import me.StevenLawson.TotalFreedomMod.config.ConfigurationEntry;
import me.StevenLawson.TotalFreedomMod.discord.bridge.DiscordBridge;
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
import me.StevenLawson.TotalFreedomMod.util.SynchronousUtil;
import me.StevenLawson.TotalFreedomMod.util.Utilities;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.PropertyManager;
@ -80,6 +82,18 @@ public class Server
{
final String ip = event.getAddress().getHostAddress().trim();
final boolean isAdmin = AdminList.isSuperAdminSafe(null, ip);
TextComponent textComponent = new TextComponent(String.format("%s is attempting to join with IP %s.", event.getName(), Utilities.getFuzzyIp(ip)));
textComponent.setColor(ChatColor.GRAY.asBungee());
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers())
{
if (AdminList.isSuperAdmin(player))
{
player.spigot().sendMessage(textComponent);
}
}
DiscordBridge.transmitAdminMessage(textComponent.getText());
// Check if the player is already online
for (Player onlinePlayer : TotalFreedomMod.server.getOnlinePlayers())

View file

@ -55,10 +55,16 @@ public class Admin
public String toString()
{
final StringBuilder output = new StringBuilder();
final ArrayList<String> fuzziedIps = new ArrayList<>();
for (String ip : ips)
{
fuzziedIps.add(Utilities.getFuzzyIp(ip));
}
output.append("UUID: ").append(uuid.toString()).append("\n");
output.append("- Last Login Name: ").append(lastLoginName).append("\n");
output.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n");
output.append("- IPs: ").append(StringUtils.join(fuzziedIps, ", ")).append("\n");
output.append("- Last Login: ").append(Utilities.dateToString(lastLogin)).append("\n");
output.append("- Custom Login Message: ").append(loginMessage).append("\n");
output.append("- Is Senior Admin: ").append(isSeniorAdmin).append("\n");

View file

@ -1,11 +1,14 @@
package me.StevenLawson.TotalFreedomMod.commands;
import me.StevenLawson.TotalFreedomMod.player.PlayerList;
import me.StevenLawson.TotalFreedomMod.player.PlayerRank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
public class Command_findip extends FreedomCommand {
@Override
@ -22,7 +25,17 @@ public class Command_findip extends FreedomCommand {
return true;
}
playerMsg(sender, "Player IPs: " + StringUtils.join(PlayerList.getEntry(player).getIps(), ", "));
PlayerRank rank = PlayerRank.fromSender(sender);
PlayerRank targetRank = PlayerRank.fromSender(player);
ArrayList<String> ipsToShow = (ArrayList<String>) PlayerList.getEntry(player).getIps();
if(rank.getOrdinal() < PlayerRank.SENIOR.getOrdinal() || targetRank.getOrdinal() >= rank.getOrdinal()) {
ipsToShow = (ArrayList<String>) PlayerList.getEntry(player).getFuzziedIps();
}
playerMsg(sender, "Player IPs: " + StringUtils.join(ipsToShow, ", "));
return true;
}

View file

@ -19,6 +19,7 @@ import me.StevenLawson.TotalFreedomMod.util.Utilities;
import me.StevenLawson.TotalFreedomMod.world.AdminWorld;
import me.StevenLawson.TotalFreedomMod.world.RollbackManager;
import me.StevenLawson.TotalFreedomMod.world.RollbackManager.RollbackEntry;
import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.*;
import org.bukkit.block.Block;
@ -33,8 +34,11 @@ import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import org.javacord.api.entity.message.component.Component;
import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;
import java.util.regex.Pattern;

View file

@ -1,10 +1,13 @@
package me.StevenLawson.TotalFreedomMod.player;
import java.sql.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import com.google.common.collect.ImmutableList;
import me.StevenLawson.TotalFreedomMod.util.Utilities;
import org.bukkit.configuration.ConfigurationSection;
public class Player
@ -59,6 +62,17 @@ public class Player
return uuid;
}
public List<String> getFuzziedIps() {
final ArrayList<String> fuzziedIps = new ArrayList<>();
for (String ip : ips)
{
fuzziedIps.add(Utilities.getFuzzyIp(ip));
}
return ImmutableList.copyOf(fuzziedIps);
}
public List<String> getIps()
{
return Collections.unmodifiableList(ips);