mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Resolves FS-339 by aggressively rewriting /list and removing ancient unused code
This commit is contained in:
parent
ca990bc526
commit
c5f0886df6
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.banning;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.sql.ResultSet;
|
||||
@ -14,7 +13,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -30,8 +28,6 @@ public class BanManager extends FreedomService
|
||||
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
||||
private final Map<UUID, Ban> uuidBans = Maps.newHashMap();
|
||||
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||
private final List<String> unbannableUsernames = Lists.newArrayList();
|
||||
|
||||
//
|
||||
|
||||
@Override
|
||||
@ -70,11 +66,6 @@ public class BanManager extends FreedomService
|
||||
updateViews();
|
||||
|
||||
FLog.info("Loaded " + ipBans.size() + " IP bans and " + nameBans.size() + " username bans.");
|
||||
|
||||
// Load unbannable usernames
|
||||
unbannableUsernames.clear();
|
||||
unbannableUsernames.addAll(ConfigEntry.FAMOUS_PLAYERS.getStringList());
|
||||
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,9 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@ -12,63 +9,37 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-s | -f | -v]", aliases = "who,lsit")
|
||||
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a | -v]", aliases = "who,lsit")
|
||||
public class Command_list extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
if (args.length > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (FUtil.isFromHostConsole(sender.getName()))
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isVanished(player.getName()))
|
||||
{
|
||||
names.add(player.getName());
|
||||
}
|
||||
}
|
||||
msg("There are " + names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(names, ", "), ChatColor.WHITE);
|
||||
return true;
|
||||
}
|
||||
|
||||
ListFilter listFilter;
|
||||
if (args.length == 1)
|
||||
{
|
||||
String s = args[0];
|
||||
switch (s)
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
case "-s":
|
||||
case "-a":
|
||||
{
|
||||
listFilter = ListFilter.ADMINS;
|
||||
break;
|
||||
}
|
||||
case "-v":
|
||||
case "-s", "-a" -> listFilter = ListFilter.ADMINS;
|
||||
case "-v" ->
|
||||
{
|
||||
checkRank(Rank.ADMIN);
|
||||
listFilter = ListFilter.VANISHED_ADMINS;
|
||||
break;
|
||||
}
|
||||
case "-t":
|
||||
case "-t" ->
|
||||
{
|
||||
checkRank(Rank.ADMIN);
|
||||
listFilter = ListFilter.TELNET_SESSIONS;
|
||||
break;
|
||||
}
|
||||
case "-f":
|
||||
{
|
||||
listFilter = ListFilter.FAMOUS_PLAYERS;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
default ->
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -78,74 +49,42 @@ public class Command_list extends FreedomCommand
|
||||
{
|
||||
listFilter = ListFilter.PLAYERS;
|
||||
}
|
||||
StringBuilder onlineStats = new StringBuilder();
|
||||
StringBuilder onlineUsers = new StringBuilder();
|
||||
|
||||
List<String> n = new ArrayList<>();
|
||||
String onlineStats;
|
||||
List<String> players;
|
||||
|
||||
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender))
|
||||
{
|
||||
List<Admin> connectedAdmins = plugin.btb.getConnectedAdmins();
|
||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedAdmins.size())
|
||||
.append(ChatColor.BLUE)
|
||||
.append(" admins connected to telnet.");
|
||||
for (Admin admin : connectedAdmins)
|
||||
{
|
||||
n.add(admin.getName());
|
||||
}
|
||||
players = plugin.btb.getConnectedAdmins().stream().map(Admin::getName).toList();
|
||||
onlineStats = ChatColor.BLUE + "There are " + ChatColor.RED + players.size() + ChatColor.BLUE
|
||||
+ " admins connected to telnet.";
|
||||
}
|
||||
else
|
||||
{
|
||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(FUtil.getFakePlayerCount())
|
||||
.append(ChatColor.BLUE)
|
||||
.append(" out of a maximum ")
|
||||
.append(ChatColor.RED)
|
||||
.append(server.getMaxPlayers())
|
||||
.append(ChatColor.BLUE)
|
||||
.append(" players online.");
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (listFilter == ListFilter.ADMINS && !plugin.al.isAdmin(p))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.ADMINS && plugin.al.isVanished(p.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.VANISHED_ADMINS && !plugin.al.isVanished(p.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(p.getName().toLowerCase()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listFilter == ListFilter.PLAYERS && plugin.al.isVanished(p.getName()))
|
||||
{
|
||||
continue;
|
||||
onlineStats = ChatColor.BLUE + "There are " + ChatColor.RED + FUtil.getFakePlayerCount() + ChatColor.BLUE
|
||||
+ " out of a maximum " + ChatColor.RED + server.getMaxPlayers() + ChatColor.BLUE + " players online.";
|
||||
|
||||
players = server.getOnlinePlayers().stream().filter(pl ->
|
||||
(listFilter == ListFilter.ADMINS && plugin.al.isAdmin(pl) && !plugin.al.isVanished(pl.getName()))
|
||||
|| (listFilter == ListFilter.VANISHED_ADMINS && plugin.al.isVanished(pl.getName()))
|
||||
|| (listFilter == ListFilter.PLAYERS && !plugin.al.isVanished(pl.getName()))).map(player ->
|
||||
plugin.rm.getDisplay(player).getColoredTag() + player.getName()).toList();
|
||||
}
|
||||
|
||||
final Displayable display = plugin.rm.getDisplay(p);
|
||||
n.add(display.getColoredTag() + p.getName());
|
||||
}
|
||||
}
|
||||
String playerType = listFilter.toString().toLowerCase().replace('_', ' ');
|
||||
onlineUsers.append("Connected ")
|
||||
.append(playerType)
|
||||
.append(": ")
|
||||
.append(StringUtils.join(n, ChatColor.WHITE + ", "));
|
||||
String onlineUsers = "Connected " + listFilter.name().toLowerCase().replace('_', ' ') + ": " + ChatColor.WHITE +
|
||||
StringUtils.join(players, ChatColor.WHITE + ", " + ChatColor.WHITE);
|
||||
|
||||
if (senderIsConsole)
|
||||
{
|
||||
msg(ChatColor.stripColor(onlineStats.toString()));
|
||||
msg(ChatColor.stripColor(onlineUsers.toString()));
|
||||
msg(ChatColor.stripColor(onlineStats));
|
||||
msg(ChatColor.stripColor(onlineUsers));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(onlineStats.toString());
|
||||
msg(onlineUsers.toString());
|
||||
msg(onlineStats);
|
||||
msg(onlineUsers);
|
||||
}
|
||||
n.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -154,7 +93,6 @@ public class Command_list extends FreedomCommand
|
||||
PLAYERS,
|
||||
ADMINS,
|
||||
VANISHED_ADMINS,
|
||||
TELNET_SESSIONS,
|
||||
FAMOUS_PLAYERS
|
||||
TELNET_SESSIONS
|
||||
}
|
||||
}
|
@ -165,7 +165,6 @@ public enum ConfigEntry
|
||||
WILDCARD_BLOCKED_COMMANDS(List.class, "blocked_commands.wildcard"),
|
||||
FORBIDDEN_WORDS(List.class, "forbidden_words"),
|
||||
HOST_SENDER_NAMES(List.class, "host_sender_names"),
|
||||
FAMOUS_PLAYERS(List.class, "famous_players"),
|
||||
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
|
||||
ADMIN_INFO(List.class, "admininfo"),
|
||||
VOTING_INFO(List.class, "votinginfo"),
|
||||
|
@ -607,151 +607,6 @@ first_join_info:
|
||||
- "&eThe server's name doesn't mean we have no rules. Do &6/rules &efor a list of them."
|
||||
- "&aNeed help getting started? Do &2/help &aor a list of commands!"
|
||||
|
||||
# Famous players - cannot be banned by username
|
||||
famous_players:
|
||||
- honeydew
|
||||
- xephos
|
||||
- captainsparklez
|
||||
- truemu
|
||||
- kiershar
|
||||
- fvdisco
|
||||
- sethbling
|
||||
- gamechap
|
||||
- bertiechap
|
||||
- vechs
|
||||
- antvenom
|
||||
- chimneyswift
|
||||
- deadmau5
|
||||
- etho
|
||||
- ethoslab
|
||||
- skydoesminecraft
|
||||
- skythekidrs
|
||||
- tobyturner
|
||||
- xxslyfoxhoundxx
|
||||
- paulsoaresjr
|
||||
- sips_
|
||||
- deadlox
|
||||
- xxslyxx
|
||||
- jeromeasf
|
||||
- grum
|
||||
- evilseph
|
||||
- cavemanfilms
|
||||
- herobrine
|
||||
- whiteboy7thst
|
||||
- stampylonghead
|
||||
- stampylongnose
|
||||
- dantdm
|
||||
- gizzy14gazza
|
||||
- furiousdestroyer
|
||||
- pewdie
|
||||
- thecampingrusher
|
||||
- logdotzip
|
||||
- ssundee
|
||||
- mrcrainer
|
||||
- achileis
|
||||
- donibobes
|
||||
- itsjerry
|
||||
- itsharry
|
||||
- bebopvox
|
||||
- clankstar
|
||||
- jollyajax
|
||||
- b0xx3r
|
||||
- vareide
|
||||
- defek7
|
||||
- strutt20
|
||||
- appleg
|
||||
- sterling_
|
||||
- hypixel
|
||||
- huskymudkipz
|
||||
- setosorcerer
|
||||
- slamacow
|
||||
- mrcrayfish
|
||||
- zexyzek
|
||||
- synhd
|
||||
- syndicate
|
||||
- bajancanadian
|
||||
- actennisac
|
||||
- bodil40
|
||||
- trumu
|
||||
- huskymudkipz
|
||||
- dantdm
|
||||
- skeppy
|
||||
- badboyhalo
|
||||
# Mojang staff below this line
|
||||
- aeplh
|
||||
- amir343
|
||||
- angryem
|
||||
- ashrafi
|
||||
- binni
|
||||
- blurpi
|
||||
- bopogamel
|
||||
- boq
|
||||
- c418
|
||||
- carlmanneh
|
||||
- carnalizer
|
||||
- carramel
|
||||
- darngeek
|
||||
- dinnerbone
|
||||
- eldrone
|
||||
- elevenen
|
||||
- el_hefe_
|
||||
- engst
|
||||
- excitedze
|
||||
- frukthamster
|
||||
- fry_
|
||||
- grumm
|
||||
- hampus
|
||||
- helloiammarsh
|
||||
- hey
|
||||
- hoodad
|
||||
- ianna_na_na
|
||||
- jeb_
|
||||
- jonkagstrom
|
||||
- kappe
|
||||
- klumpig
|
||||
- krisjelbring
|
||||
- ladyagnes
|
||||
- lisa
|
||||
- mahuldur
|
||||
- mansolson
|
||||
- marc
|
||||
- marc_irl
|
||||
- masseffect
|
||||
- midnightenforcer
|
||||
- minecraftchick
|
||||
- modhelius
|
||||
- moesh
|
||||
- mojangjonas
|
||||
- mojangsta
|
||||
- mollstam
|
||||
- neonmaster
|
||||
- olle
|
||||
- olofcarlson
|
||||
- phreakholm
|
||||
- poipoichen
|
||||
- pretto
|
||||
- profmobius
|
||||
- razzleberryfox
|
||||
- searge
|
||||
- searge_dp
|
||||
- shoghicp
|
||||
- slicedlime
|
||||
- sockerpappan
|
||||
- themogminer
|
||||
- theopard
|
||||
- theputtman
|
||||
- tom__m
|
||||
- vaktis
|
||||
- volgar
|
||||
- vubui
|
||||
- xlson
|
||||
- xsson
|
||||
- yoloswag4lyfe
|
||||
- zeeraw
|
||||
- _alcatras
|
||||
- _tommo_
|
||||
- ____fox____
|
||||
|
||||
# Pet Protect - Prevent tamed pets from being killed.
|
||||
petprotect:
|
||||
enabled: true
|
||||
|
Loading…
Reference in New Issue
Block a user