summaryrefslogtreecommitdiffstats
path: root/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/ActiveCheckPrinter.java
blob: 295acb9ef3ad6ebd183791bd90b45a22664cf34f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.earth2me.essentials.anticheat.debug;

import com.earth2me.essentials.anticheat.EventManager;
import com.earth2me.essentials.anticheat.NoCheat;
import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore;
import java.util.List;
import org.bukkit.World;


/**
 * Prints the list of active checks per world on startup, if requested
 *
 */
public class ActiveCheckPrinter
{
	public static void printActiveChecks(NoCheat plugin, List<EventManager> eventManagers)
	{

		boolean introPrinted = false;

		// Print active checks for NoCheat, if needed.
		for (World world : plugin.getServer().getWorlds())
		{

			StringBuilder line = new StringBuilder("  ").append(world.getName()).append(": ");

			int length = line.length();

			ConfigurationCacheStore cc = plugin.getConfig(world);

			if (!cc.logging.showactivechecks)
			{
				continue;
			}

			for (EventManager em : eventManagers)
			{
				if (em.getActiveChecks(cc).isEmpty())
				{
					continue;
				}

				for (String active : em.getActiveChecks(cc))
				{
					line.append(active).append(' ');
				}

				if (!introPrinted)
				{
					plugin.getLogger().info("Active Checks: ");
					introPrinted = true;
				}

				plugin.getServer().getLogger().info(line.toString());

				line = new StringBuilder(length);

				for (int i = 0; i < length; i++)
				{
					line.append(' ');
				}
			}

		}
	}
}