mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-01 05:57:09 +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;
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@ -14,7 +13,6 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.entity.Player;
|
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<String, Ban> nameBans = Maps.newHashMap();
|
||||||
private final Map<UUID, Ban> uuidBans = Maps.newHashMap();
|
private final Map<UUID, Ban> uuidBans = Maps.newHashMap();
|
||||||
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||||
private final List<String> unbannableUsernames = Lists.newArrayList();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,11 +66,6 @@ public class BanManager extends FreedomService
|
|||||||
updateViews();
|
updateViews();
|
||||||
|
|
||||||
FLog.info("Loaded " + ipBans.size() + " IP bans and " + nameBans.size() + " username bans.");
|
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
|
@Override
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
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.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@ -12,63 +9,37 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
@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
|
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)
|
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)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
return false;
|
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;
|
ListFilter listFilter;
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
String s = args[0];
|
switch (args[0].toLowerCase())
|
||||||
switch (s)
|
|
||||||
{
|
{
|
||||||
case "-s":
|
case "-s", "-a" -> listFilter = ListFilter.ADMINS;
|
||||||
case "-a":
|
case "-v" ->
|
||||||
{
|
|
||||||
listFilter = ListFilter.ADMINS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "-v":
|
|
||||||
{
|
{
|
||||||
checkRank(Rank.ADMIN);
|
checkRank(Rank.ADMIN);
|
||||||
listFilter = ListFilter.VANISHED_ADMINS;
|
listFilter = ListFilter.VANISHED_ADMINS;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "-t":
|
case "-t" ->
|
||||||
{
|
{
|
||||||
checkRank(Rank.ADMIN);
|
checkRank(Rank.ADMIN);
|
||||||
listFilter = ListFilter.TELNET_SESSIONS;
|
listFilter = ListFilter.TELNET_SESSIONS;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "-f":
|
default ->
|
||||||
{
|
|
||||||
listFilter = ListFilter.FAMOUS_PLAYERS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -78,74 +49,42 @@ public class Command_list extends FreedomCommand
|
|||||||
{
|
{
|
||||||
listFilter = ListFilter.PLAYERS;
|
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))
|
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
List<Admin> connectedAdmins = plugin.btb.getConnectedAdmins();
|
players = plugin.btb.getConnectedAdmins().stream().map(Admin::getName).toList();
|
||||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedAdmins.size())
|
onlineStats = ChatColor.BLUE + "There are " + ChatColor.RED + players.size() + ChatColor.BLUE
|
||||||
.append(ChatColor.BLUE)
|
+ " admins connected to telnet.";
|
||||||
.append(" admins connected to telnet.");
|
|
||||||
for (Admin admin : connectedAdmins)
|
|
||||||
{
|
|
||||||
n.add(admin.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(FUtil.getFakePlayerCount())
|
onlineStats = ChatColor.BLUE + "There are " + ChatColor.RED + FUtil.getFakePlayerCount() + ChatColor.BLUE
|
||||||
.append(ChatColor.BLUE)
|
+ " out of a maximum " + ChatColor.RED + server.getMaxPlayers() + ChatColor.BLUE + " players online.";
|
||||||
.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Displayable display = plugin.rm.getDisplay(p);
|
players = server.getOnlinePlayers().stream().filter(pl ->
|
||||||
n.add(display.getColoredTag() + p.getName());
|
(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();
|
||||||
}
|
}
|
||||||
String playerType = listFilter.toString().toLowerCase().replace('_', ' ');
|
|
||||||
onlineUsers.append("Connected ")
|
String onlineUsers = "Connected " + listFilter.name().toLowerCase().replace('_', ' ') + ": " + ChatColor.WHITE +
|
||||||
.append(playerType)
|
StringUtils.join(players, ChatColor.WHITE + ", " + ChatColor.WHITE);
|
||||||
.append(": ")
|
|
||||||
.append(StringUtils.join(n, ChatColor.WHITE + ", "));
|
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
msg(ChatColor.stripColor(onlineStats.toString()));
|
msg(ChatColor.stripColor(onlineStats));
|
||||||
msg(ChatColor.stripColor(onlineUsers.toString()));
|
msg(ChatColor.stripColor(onlineUsers));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg(onlineStats.toString());
|
msg(onlineStats);
|
||||||
msg(onlineUsers.toString());
|
msg(onlineUsers);
|
||||||
}
|
}
|
||||||
n.clear();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +93,6 @@ public class Command_list extends FreedomCommand
|
|||||||
PLAYERS,
|
PLAYERS,
|
||||||
ADMINS,
|
ADMINS,
|
||||||
VANISHED_ADMINS,
|
VANISHED_ADMINS,
|
||||||
TELNET_SESSIONS,
|
TELNET_SESSIONS
|
||||||
FAMOUS_PLAYERS
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -165,7 +165,6 @@ public enum ConfigEntry
|
|||||||
WILDCARD_BLOCKED_COMMANDS(List.class, "blocked_commands.wildcard"),
|
WILDCARD_BLOCKED_COMMANDS(List.class, "blocked_commands.wildcard"),
|
||||||
FORBIDDEN_WORDS(List.class, "forbidden_words"),
|
FORBIDDEN_WORDS(List.class, "forbidden_words"),
|
||||||
HOST_SENDER_NAMES(List.class, "host_sender_names"),
|
HOST_SENDER_NAMES(List.class, "host_sender_names"),
|
||||||
FAMOUS_PLAYERS(List.class, "famous_players"),
|
|
||||||
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
|
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
|
||||||
ADMIN_INFO(List.class, "admininfo"),
|
ADMIN_INFO(List.class, "admininfo"),
|
||||||
VOTING_INFO(List.class, "votinginfo"),
|
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."
|
- "&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!"
|
- "&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.
|
# Pet Protect - Prevent tamed pets from being killed.
|
||||||
petprotect:
|
petprotect:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
Loading…
Reference in New Issue
Block a user