mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-10 21:02:36 +01:00
New metrics for total goals
This commit is contained in:
parent
28e3d5c4fb
commit
1f4b8ce43f
@ -2,7 +2,6 @@ package net.citizensnpcs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
@ -55,8 +54,6 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.InputSupplier;
|
||||
|
||||
public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
private final CommandManager commands = new CommandManager();
|
||||
@ -84,23 +81,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void test() {
|
||||
getDataFolder().mkdirs();
|
||||
final InputStream dllResource = getResource("path/to/dll");
|
||||
try {
|
||||
Files.copy(new InputSupplier<InputStream>() {
|
||||
@Override
|
||||
public InputStream getInput() throws IOException {
|
||||
return dllResource;
|
||||
}
|
||||
}, new File(getDataFolder(), "name.dll"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// code here
|
||||
new File(getDataFolder(), "name.dll").delete();
|
||||
}
|
||||
|
||||
private void enableSubPlugins() {
|
||||
File root = new File(getDataFolder(), Setting.SUBPLUGIN_FOLDER.asString());
|
||||
if (!root.exists() || !root.isDirectory())
|
||||
@ -120,8 +100,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
Messaging.logTr(Messages.LOADING_SUB_PLUGIN, plugin.getDescription().getFullName());
|
||||
plugin.onLoad();
|
||||
} catch (Throwable ex) {
|
||||
Messaging.severeTr(Messages.ERROR_INITALISING_SUB_PLUGIN, ex.getMessage(), plugin
|
||||
.getDescription().getFullName());
|
||||
Messaging.severeTr(Messages.ERROR_INITALISING_SUB_PLUGIN, ex.getMessage(), plugin.getDescription()
|
||||
.getFullName());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -156,9 +136,9 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpeechFactory getSpeechFactory() {
|
||||
return speechFactory;
|
||||
}
|
||||
public SpeechFactory getSpeechFactory() {
|
||||
return speechFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String cmdName, String[] args) {
|
||||
@ -299,8 +279,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
|
||||
private void setupEconomy() {
|
||||
try {
|
||||
RegisteredServiceProvider<Economy> provider = Bukkit.getServicesManager().getRegistration(
|
||||
Economy.class);
|
||||
RegisteredServiceProvider<Economy> provider = Bukkit.getServicesManager().getRegistration(Economy.class);
|
||||
if (provider != null && provider.getProvider() != null) {
|
||||
Economy economy = provider.getProvider();
|
||||
Bukkit.getPluginManager().registerEvents(new PaymentListener(economy), this);
|
||||
@ -323,6 +302,18 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
return Iterables.size(npcRegistry);
|
||||
}
|
||||
});
|
||||
metrics.addCustomData(new Metrics.Plotter("Total goals") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
if (npcRegistry == null)
|
||||
return 0;
|
||||
int goalCount = 0;
|
||||
for (NPC npc : npcRegistry) {
|
||||
goalCount += Iterables.size(npc.getDefaultGoalController());
|
||||
}
|
||||
return goalCount;
|
||||
}
|
||||
});
|
||||
|
||||
traitFactory.addPlotters(metrics.createGraph("traits"));
|
||||
saves.addPlotters(metrics.createGraph("Storage type"));
|
||||
|
Loading…
Reference in New Issue
Block a user