blob: 3e9ee9e49abf7a9b2fb975d167afa1a257553f98 (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
package com.earth2me.essentials.metrics;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.metrics.Metrics.Graph;
import com.earth2me.essentials.metrics.Metrics.Plotter;
import com.earth2me.essentials.register.payment.Method;
import com.earth2me.essentials.register.payment.methods.VaultEco;
import java.util.Locale;
import java.util.logging.Level;
import org.bukkit.configuration.ConfigurationSection;
public class MetricsStarter implements Runnable
{
private final IEssentials ess;
private transient Boolean start;
private enum Modules
{
Essentials,
EssentialsAntiBuild,
EssentialsAntiCheat,
EssentialsChat,
EssentialsSpawn,
EssentialsProtect,
EssentialsGeoIP,
EssentialsXMPP
};
public MetricsStarter(final IEssentials plugin)
{
ess = plugin;
try
{
final Metrics metrics = new Metrics(ess);
ess.setMetrics(metrics);
if (!metrics.isOptOut())
{
if (ess.getSettings().isMetricsEnabled())
{
start = true;
}
else
{
ess.getLogger().info("This plugin collects minimal statistic data and sends it to http://metrics.essentials3.net.");
ess.getLogger().info("You can opt out by running /essentials opt-out");
ess.getLogger().info("This will start 5 minutes after the first admin/op joins.");
start = false;
}
return;
}
}
catch (Exception ex)
{
metricsError(ex);
}
}
@Override
public void run()
{
try
{
final Metrics metrics = ess.getMetrics();
final Graph moduleGraph = metrics.createGraph("Modules Used");
for (Modules module : Modules.values())
{
final String moduleName = module.toString();
if (ess.getServer().getPluginManager().isPluginEnabled(moduleName))
{
moduleGraph.addPlotter(new SimplePlotter(moduleName));
}
}
final Graph localeGraph = metrics.createGraph("Locale");
localeGraph.addPlotter(new SimplePlotter(ess.getI18n().getCurrentLocale().getDisplayLanguage(Locale.ENGLISH)));
final Graph featureGraph = metrics.createGraph("Features");
featureGraph.addPlotter(new Plotter("Unique Accounts")
{
@Override
public int getValue()
{
return ess.getUserMap().getUniqueUsers();
}
});
featureGraph.addPlotter(new Plotter("Jails")
{
@Override
public int getValue()
{
return ess.getJails().getCount();
}
});
featureGraph.addPlotter(new Plotter("Kits")
{
@Override
public int getValue()
{
ConfigurationSection kits = ess.getSettings().getKits();
if (kits == null) { return 0; }
return kits.getKeys(false).size();
}
});
featureGraph.addPlotter(new Plotter("Warps")
{
@Override
public int getValue()
{
return ess.getWarps().getWarpNames().size();
}
});
final Graph enabledGraph = metrics.createGraph("EnabledFeatures");
enabledGraph.addPlotter(new SimplePlotter("Total"));
final String BKcommand = ess.getSettings().getBackupCommand();
if (BKcommand != null && !"".equals(BKcommand))
{
enabledGraph.addPlotter(new SimplePlotter("Backup"));
}
if (ess.getJails().getCount() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("Jails"));
}
if (ess.getSettings().getKits() != null && ess.getSettings().getKits().getKeys(false).size() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("Kits"));
}
if (ess.getWarps().getWarpNames().size() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("Warps"));
}
if (ess.getSettings().getTeleportCooldown() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("TeleportCooldown"));
}
if (ess.getSettings().getTeleportDelay() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("TeleportDelay"));
}
if (!ess.getSettings().areSignsDisabled())
{
enabledGraph.addPlotter(new SimplePlotter("Signs"));
}
if (ess.getSettings().getAutoAfk() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("AutoAFK"));
}
if (ess.getSettings().changePlayerListName())
{
enabledGraph.addPlotter(new SimplePlotter("PlayerListName"));
}
if (ess.getSettings().getOperatorColor() != null)
{
enabledGraph.addPlotter(new SimplePlotter("OpColour"));
}
if (ess.getSettings().changeDisplayName())
{
enabledGraph.addPlotter(new SimplePlotter("DisplayName"));
}
if (ess.getSettings().getChatRadius() >= 1)
{
enabledGraph.addPlotter(new SimplePlotter("LocalChat"));
}
final Graph depGraph = metrics.createGraph("Dependencies");
final Method method = ess.getPaymentMethod().getMethod();
if (method != null)
{
String version;
if (method instanceof VaultEco)
{
version = ((VaultEco)method).getEconomy();
}
else
{
version = method.getVersion();
final int dashPosition = version.indexOf('-');
if (dashPosition > 0)
{
version = version.substring(0, dashPosition);
}
}
depGraph.addPlotter(new SimplePlotter(method.getName() + " " + version));
}
depGraph.addPlotter(new SimplePlotter(ess.getPermissionsHandler().getName()));
metrics.start();
}
catch (Exception ex)
{
metricsError(ex);
}
}
public void metricsError(final Exception ex)
{
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage(), ex);
}
else
{
ess.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
}
}
public Boolean getStart()
{
return start;
}
private class SimplePlotter extends Plotter
{
public SimplePlotter(final String name)
{
super(name);
}
@Override
public int getValue()
{
return 1;
}
}
}
|