Search in sources :

Example 1 with LocalStorageAccess

use of mc.dragons.core.storage.local.LocalStorageAccess in project DragonsOnline by UniverseCraft.

the class FloorCommand method listFloors.

private void listFloors(CommandSender sender) {
    sender.sendMessage(ChatColor.GREEN + "Listing all floors:");
    for (GameObject gameObject : registry.getRegisteredObjects(GameObjectType.FLOOR)) {
        Floor floor = (Floor) gameObject;
        sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "- " + floor.getFloorName() + " [" + floor.getFloorStatus() + "] [Lv " + floor.getLevelMin() + "]" + (floor.getStorageAccess() instanceof LocalStorageAccess ? LOCAL_FLOOR_WARNING : ""), "/floor goto " + floor.getFloorName(), "Click to go to floor " + floor.getFloorName()));
    }
}
Also used : LocalStorageAccess(mc.dragons.core.storage.local.LocalStorageAccess) Floor(mc.dragons.core.gameobject.floor.Floor) GameObject(mc.dragons.core.gameobject.GameObject)

Example 2 with LocalStorageAccess

use of mc.dragons.core.storage.local.LocalStorageAccess in project DragonsOnline by UniverseCraft.

the class NPCLoader method registerNew.

public NPC registerNew(Location location, EntityType entType, String className, String name, double maxHealth, int level, NPC.NPCType npcType, boolean ai, boolean immortal) {
    LOGGER.trace("Registering new NPC of class " + className);
    lazyLoadAllPermanent();
    Document data = new Document("_id", UUID.randomUUID()).append("className", className).append("name", name).append("entityType", entType.toString()).append("maxHealth", Double.valueOf(maxHealth)).append("lastLocation", StorageUtil.locToDoc(location)).append("level", Integer.valueOf(level)).append("npcType", npcType.toString()).append("ai", Boolean.valueOf(ai)).append("immortal", Boolean.valueOf(immortal)).append("lootTable", new Document());
    npcClassLoader.getNPCClassByClassName(className).getAddons().forEach(a -> a.onCreateStorageAccess(data));
    StorageAccess storageAccess = npcType.isPersistent() ? storageManager.getNewStorageAccess(GameObjectType.NPC, data) : localStorageManager.getNewStorageAccess(GameObjectType.NPC, data);
    NPC npc = new NPC(location, liveSpawner, npcType.isPersistent() ? storageManager : localStorageManager, storageAccess);
    liveSpawner.forEach(r -> r.run());
    liveSpawner.clear();
    if (storageAccess instanceof LocalStorageAccess) {
        LOGGER.verbose("- Using local storage access for NPC of type " + npcType + " (" + storageAccess + ")");
    }
    if (storageAccess == null) {
        LOGGER.warning("- Could not construct storage access for NPC of type " + npcType + " and class " + className);
    }
    npc.setMaxHealth(maxHealth);
    npc.setHealth(maxHealth);
    if (npc.getEntity() != null) {
        npc.getEntity().setMetadata("handle", new FixedMetadataValue(plugin, npc));
    }
    masterRegistry.getRegisteredObjects().add(npc);
    return npc;
}
Also used : LocalStorageAccess(mc.dragons.core.storage.local.LocalStorageAccess) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) Document(org.bson.Document) LocalStorageAccess(mc.dragons.core.storage.local.LocalStorageAccess) StorageAccess(mc.dragons.core.storage.StorageAccess)

Aggregations

LocalStorageAccess (mc.dragons.core.storage.local.LocalStorageAccess)2 GameObject (mc.dragons.core.gameobject.GameObject)1 Floor (mc.dragons.core.gameobject.floor.Floor)1 StorageAccess (mc.dragons.core.storage.StorageAccess)1 Document (org.bson.Document)1 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)1