MCPcopy Create free account
hub / github.com/ZetaMap/MoreCommands / bansCommand

Method bansCommand

src/main/java/manager/BansManager.java:22–142  ·  view source on GitHub ↗
(String[] arg)

Source from the content-addressed store, hash-verified

20 private static Seq<String> bannedClients = Seq.with("VALVE", "tuttop", "CODEX", "IGGGAMES","IgruhaOrg", "FreeTP.Org");
21
22 public static void bansCommand(String[] arg) {
23 if (PVars.unbanConfirm && !arg[0].equals("reset")) {
24 Log.info("Confirmation canceled ...");
25 PVars.unbanConfirm = false;
26 return;
27 }
28
29 switch (arg[0]) {
30 case "list":
31 Seq<PlayerInfo> bans = netServer.admins.getBanned();
32 Seq<String> ipbans = netServer.admins.getBannedIPs();
33
34 if (bans.isEmpty()) Log.info("No ID-banned players have been found.");
35 else {
36 Log.info("Banned players [ID]: Total: " + bans.size);
37 bans.each(info -> Log.info("| @ - Last name: '@' - Reason: @", info.id, info.lastName, PVars.bansReason.get(info.id, "<unknown>")));
38 }
39
40 if (ipbans.isEmpty()) Log.info("No IP-banned players have been found.");
41 else {
42 Log.info("Banned players [IP]: Total: " + ipbans.size);
43 ipbans.each(ip -> {
44 Seq<PlayerInfo> infos = netServer.admins.findByIPs(ip);
45
46 if (infos.isEmpty()) Log.info("| + '@' (No name or info)", ip);
47 else {
48 Log.info("| + '@'", ip);
49 infos.each(info -> Log.info("| | Last name: '@' - ID: '@' - Reason: @", info.lastName, info.id, PVars.bansReason.get(info.id, "<unknown>")));
50 }
51 });
52 }
53 break;
54
55 case "add":
56 if (arg.length > 2) {
57 if (arg[1].equals("id")) {
58 netServer.admins.banPlayerID(arg[2]);
59 PVars.bansReason.put(arg[2], arg.length == 4 && !arg[3].isBlank() ? arg[3] : "<no_reason>");
60 Log.info("ID banned for the reason: @", PVars.bansReason.get(arg[2]));
61 ALog.write("Ban", "[Server] banned the id '@' for the reason: @", arg[2], PVars.bansReason.get(arg[2]));
62
63 } else if (arg[1].equals("ip")) {
64 netServer.admins.banPlayerIP(arg[2]);
65 netServer.admins.findByIPs(arg[2]).each(info -> PVars.bansReason.put(info.id, arg.length == 4 && !arg[3].isBlank() ? arg[3] : "<no_reason>"));
66 Log.info("IP banned for the reason: @", PVars.bansReason.get(arg[2]));
67 ALog.write("Ban", "[Server] banned the ip '@' for the reason: @", arg[2], PVars.bansReason.get(arg[2]));
68
69 } else {
70 Log.err("Invalid type.");
71 return;
72 }
73
74 TempData.each(d -> {
75 if (netServer.admins.isIDBanned(d.player.uuid())) {
76 Call.sendMessage("\n[gold]--------------------\n[scarlet]/!\\ " + d.nameColor + d.realName
77 + "[scarlet] has been banned of the server.\nReason: [white]" + PVars.bansReason.get(arg[2])
78 + "\n[gold]--------------------\n");
79 ALog.write("Ban", "[Server] banned @ [@] for the reason: @", d.stripedName, d.player.uuid(), PVars.bansReason.get(arg[2]));

Callers

nothing calls this directly

Calls 9

eachMethod · 0.95
writeMethod · 0.95
infoMethod · 0.80
isEmptyMethod · 0.80
errMethod · 0.80
warnMethod · 0.80
getMethod · 0.45
putMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected