use of mc.dragons.core.storage.mongo.MongoConfig in project DragonsOnline by UniverseCraft.
the class DragonsResidences method onEnable.
public void onEnable() {
enableDebugLogging();
dragons = Dragons.getInstance();
resetResWorld();
MongoConfig mongoConfig = dragons.getMongoConfig();
ResLoader resLoader = new ResLoader(mongoConfig);
ResPointLoader resPointLoader = new ResPointLoader(mongoConfig);
LightweightLoaderRegistry registry = dragons.getLightweightLoaderRegistry();
registry.register(resLoader);
registry.register(resPointLoader);
dragons.getUserHookRegistry().registerHook(new ResUserHook(dragons));
resPointLoader.loadAllResPoints();
getServer().getPluginManager().registerEvents(new ResEvents(dragons), this);
ResCommands resCommands = new ResCommands(dragons);
getCommand("res").setExecutor(resCommands);
getCommand("resadmin").setExecutor(resCommands);
getCommand("restest").setExecutor(resCommands);
getCommand("testschematic").setExecutor(resCommands);
getCommand("testcontextualholograms").setExecutor(resCommands);
getLogger().info("Loading holograms for res points...");
for (ResPoint resPoint : resPointLoader.getAllResPoints()) {
resPointLoader.createResPointHologram(resPoint);
}
}
use of mc.dragons.core.storage.mongo.MongoConfig in project DragonsOnline by UniverseCraft.
the class ServerOptionsCommands method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!requirePermission(sender, PermissionLevel.DEVELOPER))
return true;
if (label.equalsIgnoreCase("getservername")) {
sender.sendMessage(ChatColor.GREEN + "Server Name: " + ChatColor.GRAY + dragons.getServerName());
} else if (label.equalsIgnoreCase("spoofserver")) {
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/spoofserver <servername>");
return true;
}
user(sender).getStorageAccess().set("currentServer", args[0]);
sender.sendMessage(ChatColor.GREEN + "Spoofed your connected server.");
} else if (label.equalsIgnoreCase("ignoreremoterestarts")) {
RemoteAdminMessageHandler handler = dragons.getRemoteAdminHandler();
handler.setIgnoresRemoteRestarts(!handler.ignoresRemoteRestarts());
sender.sendMessage(ChatColor.GREEN + "Server will " + (handler.ignoresRemoteRestarts() ? "now" : "no longer") + " ignore remote restart commands.");
} else if (label.equalsIgnoreCase("getlogtoken")) {
UUID logToken = dragons.getCustomLoggingProvider().getCustomLogFilter().getLogEntryUUID();
TextComponent token = new TextComponent(ChatColor.GREEN + "Log Token: " + ChatColor.GRAY + logToken);
token.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Click for copy-able text")));
token.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, logToken.toString()));
sender.spigot().sendMessage(token);
} else if (label.equalsIgnoreCase("vgir") || label.equalsIgnoreCase("vrgit")) {
Bukkit.dispatchCommand(sender, "verifygameintegrity -resolve");
} else if (label.equalsIgnoreCase("getnetworkstate")) {
MongoConfig mongoConfig = dragons.getMongoConfig();
sender.sendMessage(ChatColor.GREEN + "Server: " + ChatColor.GRAY + dragons.getServerName() + " - " + (Bukkit.getIp().equals("") ? "localhost" : Bukkit.getIp()) + ":" + Bukkit.getPort());
sender.sendMessage(ChatColor.GREEN + "Database: " + ChatColor.GRAY + mongoConfig.getHost() + ":" + mongoConfig.getPort() + " (" + mongoConfig.getUser() + ")");
if (!Bukkit.getOnlineMode()) {
sender.sendMessage(ChatColor.RED + "This server is in offline mode! This should not happen in production.");
}
} else if (label.equalsIgnoreCase("serveroptions")) {
serverOptionsCommand(sender, args);
}
return true;
}
use of mc.dragons.core.storage.mongo.MongoConfig in project DragonsOnline by UniverseCraft.
the class MongoCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!requirePermission(sender, SystemProfileFlag.DEVELOPMENT))
return true;
MongoConfig config = dragons.getMongoConfig();
MongoDatabase db = config.getDatabase();
if (db == null) {
sender.sendMessage(ChatColor.RED + "No MongoDB instance connected!");
return true;
}
sender.sendMessage(ChatColor.DARK_GREEN + "Connected to MongoDB");
sender.sendMessage(ChatColor.GREEN + "IP: " + ChatColor.GRAY + config.getHost() + ":" + config.getPort());
sender.sendMessage(ChatColor.GREEN + "Database name: " + ChatColor.GRAY + db.getName());
sender.sendMessage(ChatColor.GREEN + "Collections: " + ChatColor.GRAY + db.listCollectionNames().into(new ArrayList<>()).stream().map(coll -> coll + " (" + db.getCollection(coll).estimatedDocumentCount() + "D, " + db.runCommand(new Document("collStats", coll).append("scale", 1024)).getInteger("storageSize") + "KB)").reduce((a, b) -> a + "; " + b).get());
return true;
}
use of mc.dragons.core.storage.mongo.MongoConfig in project DragonsOnline by UniverseCraft.
the class Dragons method onLoad.
@Override
public synchronized void onLoad() {
FIXED_ENTITY_KEY = new NamespacedKey(this, "fixed");
started = System.currentTimeMillis();
getLogger().info("Searching for compatible version...");
switch(BUKKIT_API_VERSION) {
case "1_16_R3":
bridge = new BridgeSpigot116R3();
break;
default:
getLogger().severe("Incompatible server version (" + BUKKIT_API_VERSION + ")");
getLogger().severe("Cannot run DragonsOnline.");
getServer().getPluginManager().disablePlugin(this);
return;
}
joinable = false;
getLogger().info("Disabled player joins until Dragons startup completes");
serverName = getConfig().getString("serverName");
getLogger().info("Server instance name is " + serverName);
getLogger().info("Initializing storage and registries...");
saveDefaultConfig();
mongoConfig = new MongoConfig(this);
persistentStorageManager = new MongoStorageManager(this);
localStorageManager = new LocalStorageManager();
gameObjectRegistry = new GameObjectRegistry(this, persistentStorageManager);
addonRegistry = new AddonRegistry(this);
userHookRegistry = new UserHookRegistry();
lightweightLoaderRegistry = new LightweightLoaderRegistry();
sidebarManager = new SidebarManager(this);
chatMessageRegistry = new ChatMessageRegistry();
messageDispatcher = new MessageDispatcher(this);
setCustomLoggingProvider(new CustomLoggingProvider(this));
autoSaveRunnable = new AutoSaveTask(this);
spawnEntityRunnable = new SpawnEntityTask(this);
verifyGameIntegrityRunnable = new VerifyGameIntegrityTask(this);
lagMeter = new LagMeter();
lagMonitorTask = new LagMonitorTask();
updateScoreboardTask = new UpdateScoreboardTask(this);
serverOptions = new ServerOptions(this);
serverOptions.setLogLevel(Level.parse(getConfig().getString("loglevel")));
debug = getConfig().getBoolean("debug");
if (debug) {
if (serverOptions.getLogLevel().intValue() > Level.CONFIG.intValue()) {
serverOptions.setLogLevel(Level.CONFIG);
}
serverOptions.setVerifyIntegrityEnabled(false);
getLogger().warning("==========================================================");
getLogger().warning("THIS SERVER IS IN DEVELOPMENT MODE.");
getLogger().warning("GAME INTEGRITY WILL NOT BE VERIFIED AFTER INITIAL LOAD.");
getLogger().warning("==========================================================");
}
customLoggingProvider.enableCustomLogging();
enableDebugLogging();
getLogger().info("Log token is " + customLoggingProvider.getCustomLogFilter().getLogEntryUUID());
}
use of mc.dragons.core.storage.mongo.MongoConfig in project DragonsOnline by UniverseCraft.
the class Dragons method onEnable.
@Override
public void onEnable() {
BukkitUtil.initRollingSync();
playerNPCRegistry = new PlayerNPCRegistry(this);
// Game objects must be loaded from database in a particular sequence, to ensure
// all dependencies are ready.
// For example, items cannot be loaded before their item classes have been loaded,
// and regions cannot be loaded before their associated floors have been loaded.
getLogger().info("Loading game objects...");
GameObjectType.getLoader(FloorLoader.class).lazyLoadAll();
GameObjectType.getLoader(RegionLoader.class).lazyLoadAll();
GameObjectType.getLoader(ItemClassLoader.class).lazyLoadAll();
GameObjectType.getLoader(NPCClassLoader.class).lazyLoadAll();
GameObjectType.getLoader(QuestLoader.class).lazyLoadAll();
// If the server did not shut down gracefully (and sometimes if it did) there may be
// entities remaining from the previous instance which are no longer linked to a
// live game object. These entities need to be purged as they will not be responsive
// to new game events.
getLogger().info("Removing stale entities...");
boolean hasFixed = false;
for (Entity e : getEntities()) {
if (e.getPersistentDataContainer().has(FIXED_ENTITY_KEY, PersistentDataType.SHORT)) {
getLogger().verbose("-Skipping fixed entity #" + e.getEntityId());
hasFixed = true;
continue;
}
if (e instanceof ItemFrame) {
getLogger().verbose("-Skipping item frame #" + e.getEntityId());
continue;
}
e.remove();
}
if (hasFixed) {
getLogger().notice("The use of fixed entities is not automatically synced across servers the same way that persistent NPCs are.\n" + "Instead, the appropriate world files must be copied.");
}
new BukkitRunnable() {
@Override
public void run() {
GameObjectType.getLoader(NPCLoader.class).lazyLoadAllPermanent();
getLogger().info("Flushing invalid game objects from initial load...");
new BukkitRunnable() {
int i = 1;
@Override
public void run() {
verifyGameIntegrityRunnable.run(true);
i++;
if (i >= 5) {
cancel();
getLogger().info("... flush complete. Entity count: " + getEntities().size());
joinable = true;
getLogger().info("Server is now joinable");
}
}
}.runTaskTimer(Dragons.this, 20L, 20L);
}
}.runTaskLater(this, 20L);
getLogger().info("Registering lightweight object loaders...");
lightweightLoaderRegistry.register(new ChangeLogLoader(mongoConfig));
lightweightLoaderRegistry.register(new FeedbackLoader(mongoConfig));
lightweightLoaderRegistry.register(new WarpLoader(mongoConfig));
lightweightLoaderRegistry.register(new CorrelationLogger(mongoConfig));
lightweightLoaderRegistry.register(new SystemProfileLoader(this));
lightweightLoaderRegistry.register(new GlobalVarLoader(mongoConfig));
lightweightLoaderRegistry.register(new StateLoader(mongoConfig));
UserLoader.lazyLoadGlobalVarLoader();
getLogger().info("Registering events...");
PluginManager pluginManager = getServer().getPluginManager();
pluginManager.registerEvents(new EntityDeathListener(this), this);
pluginManager.registerEvents(new EntityDamageListener(this), this);
pluginManager.registerEvents(new WorldEventListeners(this), this);
pluginManager.registerEvents(new EntityTargetEventListener(this), this);
pluginManager.registerEvents(new InventoryEventListeners(), this);
pluginManager.registerEvents(new PlayerEventListeners(this), this);
pluginManager.registerEvents(new EntityCombustListener(), this);
pluginManager.registerEvents(new SlimeSplitEventListener(this), this);
getLogger().info("Registering packet listeners...");
if (verifyProtocolLib()) {
ProtocolLibrary.getProtocolManager().addPacketListener(new EntityMoveListener(this));
entityHider = new EntityHider(this, EntityHider.Policy.BLACKLIST);
}
getLogger().info("Registering commands...");
getCommand("dragons").setExecutor(new DragonsCommand());
getCommand("rank").setExecutor(new RankCommand());
getCommand("autorank").setExecutor(new AutoRankCommand());
getCommand("syslogon").setExecutor(new SystemLogonCommand());
getCommand("respawn").setExecutor(new RespawnCommand());
getCommand("heal").setExecutor(new HealCommand());
getCommand("feedback").setExecutor(new FeedbackCommand());
getCommand("myquests").setExecutor(new MyQuestsCommand());
getCommand("help").setExecutor(new HelpCommand());
getCommand("stuckquest").setExecutor(new StuckQuestCommand());
getCommand("restartinstance").setExecutor(new RestartInstanceCommand());
getCommand("logout").setExecutor(new LogoutCommand());
CommandExecutor stateCommands = new StateCommands();
getCommand("getstate").setExecutor(stateCommands);
getCommand("setstate").setExecutor(stateCommands);
QuestDialogueCommands questDialogueCommands = new QuestDialogueCommands();
getCommand("fastforwarddialogue").setExecutor(questDialogueCommands);
getCommand("questchoice").setExecutor(questDialogueCommands);
ChangeLogCommands changeLogCommandsExecutor = new ChangeLogCommands();
getCommand("news").setExecutor(changeLogCommandsExecutor);
getCommand("newsmanager").setExecutor(changeLogCommandsExecutor);
CommandExecutor chatCommands = new ChatOptionsCommand();
getCommand("chatoptions").setExecutor(chatCommands);
getCommand("chatreply").setExecutor(chatCommands);
getLogger().info("Scheduling tasks...");
autoSaveRunnable.runTaskTimer(this, 0L, serverOptions.getAutoSavePeriodTicks());
spawnEntityRunnable.runTaskTimer(this, 0L, serverOptions.getCustomSpawnRate());
verifyGameIntegrityRunnable.runTaskTimer(this, 0L, serverOptions.getVerifyIntegritySweepRate());
lagMeter.runTaskTimer(this, 100L, 1L);
lagMonitorTask.runTaskAsynchronously(this);
updateScoreboardTask.runTaskTimer(this, 100L, 20L);
BukkitUtil.syncPeriodic(() -> Bukkit.getOnlinePlayers().stream().map(p -> UserLoader.fromPlayer(p)).forEach(u -> u.updateTablistHeaders()), 20 * 10, 20 * 5);
getLogger().info("Registering message handlers...");
internalMessageHandler = new InternalMessageHandler(this);
remoteAdminHandler = new RemoteAdminMessageHandler(this);
staffAlertHandler = new StaffAlertMessageHandler(this);
getLogger().info("Enabling addons...");
addonRegistry.enableAll();
}
Aggregations