use of net.citizensnpcs.npc.CitizensNPCRegistry in project Citizens2 by CitizensDev.
the class Citizens method onEnable.
@Override
public void onEnable() {
setupTranslator();
CitizensAPI.setImplementation(this);
config = new Settings(getDataFolder());
// Disable if the server is not using the compatible Minecraft version
String mcVersion = Util.getMinecraftRevision();
compatible = true;
try {
NMS.loadBridge(mcVersion);
} catch (Exception e) {
compatible = false;
if (Messaging.isDebugging()) {
e.printStackTrace();
}
Messaging.severeTr(Messages.CITIZENS_INCOMPATIBLE, getDescription().getVersion(), mcVersion);
getServer().getPluginManager().disablePlugin(this);
return;
}
registerScriptHelpers();
saves = createStorage(getDataFolder());
if (saves == null) {
Messaging.severeTr(Messages.FAILED_LOAD_SAVES);
getServer().getPluginManager().disablePlugin(this);
return;
}
npcRegistry = new CitizensNPCRegistry(saves);
traitFactory = new CitizensTraitFactory();
selector = new NPCSelector(this);
speechFactory = new CitizensSpeechFactory();
speechFactory.register(Chat.class, "chat");
getServer().getPluginManager().registerEvents(new EventListen(storedRegistries), this);
if (Setting.NPC_COST.asDouble() > 0) {
setupEconomy();
}
registerCommands();
enableSubPlugins();
NMS.load(commands);
// support and for NPCs to properly register external settings)
if (getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
saves.loadInto(npcRegistry);
Messaging.logTr(Messages.NUM_LOADED_NOTIFICATION, Iterables.size(npcRegistry), "?");
startMetrics();
scheduleSaveTask(Setting.SAVE_TASK_DELAY.asInt());
Bukkit.getPluginManager().callEvent(new CitizensEnableEvent());
if (!Util.getMinecraftRevision().equals("1_8_R3")) {
new PlayerUpdateTask().runTaskTimer(Citizens.this, 0, 1);
}
}
}, 1) == -1) {
Messaging.severeTr(Messages.LOAD_TASK_NOT_SCHEDULED);
getServer().getPluginManager().disablePlugin(this);
}
}
use of net.citizensnpcs.npc.CitizensNPCRegistry in project Citizens2 by CitizensDev.
the class Citizens method createNamedNPCRegistry.
@Override
public NPCRegistry createNamedNPCRegistry(String name, NPCDataStore store) {
NPCRegistry created = new CitizensNPCRegistry(store);
storedRegistries.put(name, created);
return created;
}
Aggregations