use of mc.dragons.core.gameobject.GameObject in project DragonsOnline by UniverseCraft.
the class NPCClassLoader method loadObject.
@Override
public NPCClass loadObject(StorageAccess storageAccess) {
lazyLoadAll();
LOGGER.trace("Loading NPC class " + storageAccess.getIdentifier());
for (GameObject gameObject : masterRegistry.getRegisteredObjects(GameObjectType.NPC_CLASS)) {
NPCClass npcClass = (NPCClass) gameObject;
if (npcClass.getIdentifier().equals(storageAccess.getIdentifier())) {
return npcClass;
}
}
NPCClass npcClass = new NPCClass(storageManager, storageAccess);
masterRegistry.getRegisteredObjects().add(npcClass);
cachedNPCClasses.put(npcClass.getClassName(), npcClass);
return npcClass;
}
use of mc.dragons.core.gameobject.GameObject in project DragonsOnline by UniverseCraft.
the class NPCLoader method loadObject.
public NPC loadObject(UUID uuid, UUID cid) {
if (uuidToNpc.containsKey(uuid)) {
LOGGER.debug("Prevented spawn of duplicate NPC " + uuid);
return uuidToNpc.get(uuid);
}
LOGGER.verbose(cid, "loading NPC with uuid " + uuid);
for (GameObject gameObject : masterRegistry.getRegisteredObjects(new GameObjectType[] { GameObjectType.NPC })) {
NPC npc = (NPC) gameObject;
if (npc.getUUID().equals(uuid)) {
LOGGER.verbose("found in local cache (" + npc + "), returning");
return npc;
}
}
StorageAccess storageAccess = storageManager.getStorageAccess(GameObjectType.NPC, uuid);
if (storageAccess == null) {
LOGGER.warning(cid, "could not load NPC from database: returned null storage access");
return null;
}
LOGGER.verbose(cid, "loaded storage access (" + storageAccess + "), constructing downstream");
return loadObject(storageAccess);
}
use of mc.dragons.core.gameobject.GameObject in project DragonsOnline by UniverseCraft.
the class ItemClassLoader method loadObject.
@Override
public ItemClass loadObject(StorageAccess storageAccess) {
LOGGER.trace("Loading item class " + storageAccess.getIdentifier());
for (GameObject gameObject : masterRegistry.getRegisteredObjects(GameObjectType.ITEM_CLASS)) {
ItemClass itemClass = (ItemClass) gameObject;
if (itemClass.getIdentifier().equals(storageAccess.getIdentifier())) {
return itemClass;
}
}
ItemClass itemClass = new ItemClass(storageManager, storageAccess);
masterRegistry.getRegisteredObjects().add(itemClass);
return itemClass;
}
use of mc.dragons.core.gameobject.GameObject in project DragonsOnline by UniverseCraft.
the class ObjectMetadataCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!requirePermission(sender, PermissionLevel.GM))
return true;
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/objmeta <gameobject type> <gameobject uuid>");
return true;
}
GameObjectType type = StringUtil.parseEnum(sender, GameObjectType.class, args[0]);
UUID uuid = parseUUID(sender, args[1]);
if (type == null || uuid == null)
return true;
GameObject gameObject = type.getLoader().loadObject(dragons.getPersistentStorageManager().getStorageAccess(type, uuid));
if (gameObject == null) {
sender.sendMessage(ChatColor.RED + "No game object was found matching these criteria!");
return true;
}
// MetadataConstants.displayMetadata(sender, gameObject);
List<AuditLogEntry> entries = AUDIT_LOG.getEntries(gameObject.getIdentifier());
int count = entries.size();
if (count == 0) {
sender.sendMessage(ChatColor.RED + "There is no metadata for this game object!");
return true;
}
AuditLogEntry first = entries.get(0);
AuditLogEntry last = entries.get(entries.size() - 1);
AuditLogEntry lastPush = AUDIT_LOG.getLastPush(gameObject.getIdentifier());
if (first != null && first.getLine().equals("Created")) {
sender.sendMessage(ChatColor.GRAY + "Created By: " + ChatColor.GREEN + ObjectUtil.get(first.getBy(), () -> first.getBy().getName(), UNKNOWN));
sender.sendMessage(ChatColor.GRAY + "Created On: " + ChatColor.GREEN + ObjectUtil.get(first.getDate(), () -> StringUtil.DATE_FORMAT.format(first.getDate()), UNKNOWN));
}
sender.sendMessage(ChatColor.GRAY + "Revision Count: " + ChatColor.GREEN + count);
if (last != null) {
sender.sendMessage(ChatColor.GRAY + "Last Revised By: " + ChatColor.GREEN + ObjectUtil.get(last.getBy(), () -> last.getBy().getName(), UNKNOWN));
sender.sendMessage(ChatColor.GRAY + "Last Revised On: " + ChatColor.GREEN + ObjectUtil.get(last.getDate(), () -> StringUtil.DATE_FORMAT.format(last.getDate()), UNKNOWN));
}
if (lastPush != null) {
sender.sendMessage(ChatColor.GRAY + "Last Pushed On: " + ChatColor.GREEN + StringUtil.DATE_FORMAT.format(lastPush.getDate()));
}
if (last == null || lastPush == null) {
sender.sendMessage(ChatColor.GRAY + "Sync Status: " + UNKNOWN);
} else if (last.getId() == lastPush.getId()) {
sender.sendMessage(ChatColor.GRAY + "Sync Status: " + ChatColor.GREEN + "Matched in production");
} else if (last.getId() > lastPush.getId()) {
sender.sendMessage(ChatColor.GRAY + "Sync Status: " + ChatColor.YELLOW + "Changes made since last push");
} else {
sender.sendMessage(ChatColor.GRAY + "Sync Status: " + ChatColor.RED + "Behind production (SYNC ERROR)");
}
return true;
}
use of mc.dragons.core.gameobject.GameObject in project DragonsOnline by UniverseCraft.
the class ItemCommand method listClasses.
private void listClasses(CommandSender sender, String[] args) {
String startingWith = "";
if (args.length > 1) {
startingWith = args[1];
}
sender.sendMessage(ChatColor.GREEN + "Listing all item classes" + (startingWith.length() > 0 ? (" starting with \"" + startingWith + "\"") : "") + ":");
for (GameObject gameObject : registry.getRegisteredObjects(GameObjectType.ITEM_CLASS)) {
ItemClass itemClass = (ItemClass) gameObject;
if (!itemClass.getClassName().startsWith(startingWith))
continue;
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "- " + itemClass.getClassName() + " [Lv Min " + itemClass.getLevelMin() + "]", "/item give " + itemClass.getClassName(), true, "Click to receive this item"));
}
}
Aggregations