mirror of
https://github.com/solero/houdini.git
synced 2024-11-22 05:27:23 +00:00
Move server load crumbs code out of Houdini class
Make use of the new `handlers.boot` event handler to load the server crumbs in from each respective handler module.
This commit is contained in:
parent
9a4acade3f
commit
de4946771c
@ -1,10 +1,11 @@
|
|||||||
from houdini import handlers
|
from houdini import handlers
|
||||||
from houdini.handlers import XTPacket
|
from houdini.handlers import XMLPacket, XTPacket
|
||||||
from houdini.handlers.play.navigation import handle_join_room, handle_join_server
|
from houdini.handlers.play.navigation import handle_join_room
|
||||||
|
from houdini.handlers import Priority
|
||||||
|
|
||||||
from houdini.data.penguin import Penguin
|
from houdini.data.penguin import Penguin
|
||||||
from houdini.data.buddy import BuddyList, BuddyRequest, BuddyListCollection, \
|
from houdini.data.buddy import BuddyList, BuddyRequest, BuddyListCollection, \
|
||||||
BuddyRequestCollection, CharacterBuddyCollection
|
BuddyRequestCollection, CharacterBuddyCollection, CharacterCollection
|
||||||
from houdini.constants import ClientType
|
from houdini.constants import ClientType
|
||||||
|
|
||||||
|
|
||||||
@ -26,8 +27,13 @@ async def update_player_presence(p):
|
|||||||
await penguin.send_xt('caon', p.character, p.server.config.id, p.room.id)
|
await penguin.send_xt('caon', p.character, p.server.config.id, p.room.id)
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('j', 'js'), after=handle_join_server)
|
@handlers.boot
|
||||||
@handlers.player_attribute(joined_world=True)
|
async def characters_load(server):
|
||||||
|
server.characters = await CharacterCollection.get_collection()
|
||||||
|
server.logger.info(f'Loaded {len(server.characters)} characters')
|
||||||
|
|
||||||
|
|
||||||
|
@handlers.handler(XMLPacket('login'), priority=Priority.Low)
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
async def load_buddy_inventory(p):
|
async def load_buddy_inventory(p):
|
||||||
p.buddies = await BuddyListCollection.get_collection(p.id)
|
p.buddies = await BuddyListCollection.get_collection(p.id)
|
||||||
|
@ -4,7 +4,7 @@ import time
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from houdini import handlers
|
from houdini import handlers
|
||||||
from houdini.handlers import XTPacket
|
from houdini.handlers import XMLPacket, XTPacket, Priority
|
||||||
from houdini.converters import SeparatorConverter
|
from houdini.converters import SeparatorConverter
|
||||||
from houdini.constants import ClientType, StatusField
|
from houdini.constants import ClientType, StatusField
|
||||||
from houdini.handlers.play.navigation import handle_join_server
|
from houdini.handlers.play.navigation import handle_join_server
|
||||||
@ -13,6 +13,8 @@ from houdini.data import db
|
|||||||
from houdini.data.penguin import Penguin
|
from houdini.data.penguin import Penguin
|
||||||
from houdini.data.room import PenguinIglooRoom
|
from houdini.data.room import PenguinIglooRoom
|
||||||
from houdini.data.igloo import IglooFurniture, IglooLike, Igloo, Furniture, Flooring, Location, \
|
from houdini.data.igloo import IglooFurniture, IglooLike, Igloo, Furniture, Flooring, Location, \
|
||||||
|
IglooCollection, FurnitureCollection, \
|
||||||
|
FlooringCollection, LocationCollection,\
|
||||||
PenguinIglooCollection, PenguinFurnitureCollection, \
|
PenguinIglooCollection, PenguinFurnitureCollection, \
|
||||||
PenguinFlooringCollection, PenguinLocationCollection
|
PenguinFlooringCollection, PenguinLocationCollection
|
||||||
from houdini.data.room import PenguinIglooRoomCollection
|
from houdini.data.room import PenguinIglooRoomCollection
|
||||||
@ -141,8 +143,18 @@ async def save_igloo_furniture(p, furniture_list=None):
|
|||||||
await IglooFurniture.insert().values(furniture).gino.status()
|
await IglooFurniture.insert().values(furniture).gino.status()
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('j', 'js'), after=handle_join_server)
|
@handlers.boot
|
||||||
@handlers.player_attribute(joined_world=True)
|
async def igloos_load(server):
|
||||||
|
server.igloos = await IglooCollection.get_collection()
|
||||||
|
server.furniture = await FurnitureCollection.get_collection()
|
||||||
|
server.locations = await LocationCollection.get_collection()
|
||||||
|
server.flooring = await FlooringCollection.get_collection()
|
||||||
|
|
||||||
|
server.logger.info(f'Loaded {len(server.igloos)} igloos')
|
||||||
|
server.logger.info(f'Loaded {len(server.furniture)} furniture items')
|
||||||
|
server.logger.info(f'Loaded {len(server.locations)} igloo locations')
|
||||||
|
server.logger.info(f'Loaded {len(server.flooring)} igloo flooring')
|
||||||
|
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
async def load_igloo_inventory(p):
|
async def load_igloo_inventory(p):
|
||||||
p.igloos = await PenguinIglooCollection.get_collection(p.id)
|
p.igloos = await PenguinIglooCollection.get_collection(p.id)
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
from houdini import handlers
|
from houdini import handlers
|
||||||
from houdini.handlers import XTPacket
|
from houdini.handlers import XMLPacket, XTPacket, Priority
|
||||||
from houdini.handlers.play.navigation import handle_join_server
|
|
||||||
|
|
||||||
from houdini.data.penguin import Penguin
|
from houdini.data.penguin import Penguin
|
||||||
from houdini.data.buddy import IgnoreList, IgnoreListCollection
|
from houdini.data.buddy import IgnoreList, IgnoreListCollection
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('j', 'js'), after=handle_join_server)
|
@handlers.handler(XMLPacket('login'), priority=Priority.Low)
|
||||||
@handlers.player_attribute(joined_world=True)
|
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
async def load_ignore_inventory(p):
|
async def load_ignore_inventory(p):
|
||||||
p.ignore = await IgnoreListCollection.get_collection(p.id)
|
p.ignore = await IgnoreListCollection.get_collection(p.id)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from houdini import handlers
|
from houdini import handlers
|
||||||
from houdini.handlers import XTPacket
|
from houdini.handlers import XMLPacket, XTPacket, Priority
|
||||||
from houdini.handlers.play.navigation import handle_join_server
|
from houdini.data.item import Item, ItemCollection, PenguinItemCollection
|
||||||
from houdini.data.item import Item, PenguinItemCollection
|
|
||||||
from houdini.data.permission import PenguinPermissionCollection
|
from houdini.data.permission import PenguinPermissionCollection
|
||||||
|
|
||||||
import time
|
import time
|
||||||
@ -45,8 +44,11 @@ async def get_awards_string(p, player_id):
|
|||||||
return '%'.join(awards)
|
return '%'.join(awards)
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('j', 'js'), after=handle_join_server)
|
@handlers.boot
|
||||||
@handlers.player_attribute(joined_world=True)
|
async def items_load(server):
|
||||||
|
server.items = await ItemCollection.get_collection()
|
||||||
|
server.logger.info(f'Loaded {len(server.items)} clothing items')
|
||||||
|
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
async def load_inventory(p):
|
async def load_inventory(p):
|
||||||
p.inventory = await PenguinItemCollection.get_collection(p.id)
|
p.inventory = await PenguinItemCollection.get_collection(p.id)
|
||||||
|
@ -4,11 +4,17 @@ from houdini.handlers import XTPacket
|
|||||||
from houdini.data import db
|
from houdini.data import db
|
||||||
from houdini.data.penguin import Penguin
|
from houdini.data.penguin import Penguin
|
||||||
from houdini.data.buddy import IgnoreList
|
from houdini.data.buddy import IgnoreList
|
||||||
from houdini.data.mail import PenguinPostcard
|
from houdini.data.mail import PenguinPostcard, PostcardCollection
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
@handlers.boot
|
||||||
|
async def postcards_load(server):
|
||||||
|
server.postcards = await PostcardCollection.get_collection()
|
||||||
|
server.logger.info(f'Loaded {len(server.postcards)} postcards')
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('l', 'mst'))
|
@handlers.handler(XTPacket('l', 'mst'))
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
async def handle_start_mail_engine(p):
|
async def handle_start_mail_engine(p):
|
||||||
|
@ -2,6 +2,14 @@ from houdini import handlers
|
|||||||
from houdini.handlers import XTPacket
|
from houdini.handlers import XTPacket
|
||||||
from houdini.commands import invoke_command_string, has_command_prefix
|
from houdini.commands import invoke_command_string, has_command_prefix
|
||||||
|
|
||||||
|
from houdini.data.moderator import ChatFilterRuleCollection
|
||||||
|
|
||||||
|
|
||||||
|
@handlers.boot
|
||||||
|
async def filter_load(server):
|
||||||
|
server.chat_filter_words = await ChatFilterRuleCollection.get_collection()
|
||||||
|
server.logger.info(f'Loaded {len(server.chat_filter_words)} filter words')
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('m', 'sm'))
|
@handlers.handler(XTPacket('m', 'sm'))
|
||||||
@handlers.cooldown(.5)
|
@handlers.cooldown(.5)
|
||||||
|
@ -2,14 +2,20 @@ from houdini import handlers
|
|||||||
from houdini.handlers import XTPacket
|
from houdini.handlers import XTPacket
|
||||||
from houdini.data.room import Room
|
from houdini.data.room import Room
|
||||||
from houdini.data.penguin import Login
|
from houdini.data.penguin import Login
|
||||||
from houdini.data.penguin import Penguin
|
from houdini.data.room import PenguinIglooRoom, PenguinBackyardRoom, RoomCollection
|
||||||
from houdini.data.room import PenguinIglooRoom, PenguinBackyardRoom
|
|
||||||
from houdini.constants import ClientType, StatusField
|
from houdini.constants import ClientType, StatusField
|
||||||
|
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@handlers.boot
|
||||||
|
async def rooms_load(server):
|
||||||
|
server.rooms = await RoomCollection.get_collection()
|
||||||
|
await server.rooms.setup_tables()
|
||||||
|
await server.rooms.setup_waddles()
|
||||||
|
server.logger.info(f'Loaded {len(server.rooms)} rooms ({len(server.rooms.spawn_rooms)} spawn)')
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('j', 'js'), pre_login=True)
|
@handlers.handler(XTPacket('j', 'js'), pre_login=True)
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
from houdini import handlers
|
from houdini import handlers
|
||||||
from houdini.handlers import XTPacket
|
from houdini.handlers import XMLPacket, XTPacket, Priority
|
||||||
from houdini.handlers.play.navigation import handle_join_server
|
from houdini.data.ninja import PenguinCardCollection, CardCollection
|
||||||
from houdini.data.ninja import PenguinCardCollection
|
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('j', 'js'), after=handle_join_server)
|
@handlers.boot
|
||||||
@handlers.player_attribute(joined_world=True)
|
async def cards_load(server):
|
||||||
|
server.cards = await CardCollection.get_collection()
|
||||||
|
server.logger.info(f'Loaded {len(server.cards)} ninja cards')
|
||||||
|
|
||||||
|
|
||||||
|
@handlers.handler(XMLPacket('login'), priority=Priority.Low)
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
async def load_ninja_inventory(p):
|
async def load_ninja_inventory(p):
|
||||||
p.cards = await PenguinCardCollection.get_collection(p.id)
|
p.cards = await PenguinCardCollection.get_collection(p.id)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
from houdini import handlers
|
from houdini import handlers
|
||||||
from houdini.handlers import XTPacket
|
from houdini.handlers import XMLPacket, XTPacket, Priority
|
||||||
from houdini.handlers.play.navigation import handle_join_server
|
|
||||||
from houdini.constants import ClientType, StatusField
|
from houdini.constants import ClientType, StatusField
|
||||||
|
|
||||||
from houdini.data.pet import PenguinPuffleCollection, PenguinPuffleItemCollection, PenguinPuffle
|
from houdini.data.pet import PenguinPuffleCollection, PenguinPuffleItemCollection, PenguinPuffle, \
|
||||||
|
PuffleCollection, PuffleItemCollection, \
|
||||||
|
PuffleTreasureFurniture, PuffleTreasureItem, \
|
||||||
|
PuffleTreasurePuffleItem
|
||||||
from houdini.data.room import PenguinBackyardRoom, PenguinIglooRoom
|
from houdini.data.room import PenguinBackyardRoom, PenguinIglooRoom
|
||||||
from houdini.data.mail import PenguinPostcard
|
from houdini.data.mail import PenguinPostcard
|
||||||
|
|
||||||
@ -223,7 +225,19 @@ def check_name(p, puffle_name):
|
|||||||
return characters_ok and length_ok and clean
|
return characters_ok and length_ok and clean
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('j', 'js'), before=handle_join_server, pre_login=True)
|
@handlers.boot
|
||||||
|
async def puffles_load(server):
|
||||||
|
server.puffles = await PuffleCollection.get_collection()
|
||||||
|
server.puffle_items = await PuffleItemCollection.get_collection()
|
||||||
|
server.logger.info(f'Loaded {len(server.puffle_items)} puffle care items')
|
||||||
|
server.logger.info(f'Loaded {len(server.puffles)} puffles')
|
||||||
|
|
||||||
|
server.puffle_food_treasure = await PuffleTreasurePuffleItem.query.gino.all()
|
||||||
|
server.puffle_furniture_treasure = await PuffleTreasureFurniture.query.gino.all()
|
||||||
|
server.puffle_clothing_treasure = await PuffleTreasureItem.query.gino.all()
|
||||||
|
|
||||||
|
|
||||||
|
@handlers.handler(XMLPacket('login'), priority=Priority.Low)
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
async def load_pet_inventory(p):
|
async def load_pet_inventory(p):
|
||||||
p.puffles = await PenguinPuffleCollection.get_collection(p.id)
|
p.puffles = await PenguinPuffleCollection.get_collection(p.id)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from houdini import handlers
|
from houdini import handlers
|
||||||
from houdini.handlers import XTPacket
|
from houdini.handlers import XMLPacket, XTPacket, Priority
|
||||||
from houdini.handlers.play.navigation import handle_join_server, handle_join_room
|
from houdini.handlers.play.navigation import handle_join_server, handle_join_room
|
||||||
from houdini.data.stamp import Stamp, CoverStamp, CoverItem, PenguinStampCollection
|
from houdini.data.stamp import Stamp, CoverStamp, CoverItem, PenguinStampCollection, StampCollection
|
||||||
from houdini.data.penguin import Penguin
|
from houdini.data.penguin import Penguin
|
||||||
|
|
||||||
from aiocache import cached
|
from aiocache import cached
|
||||||
@ -47,8 +47,13 @@ async def get_player_stamps_string(p, player_id):
|
|||||||
return '|'.join(map(str, stamp_inventory.keys()))
|
return '|'.join(map(str, stamp_inventory.keys()))
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('j', 'js'), after=handle_join_server)
|
@handlers.boot
|
||||||
@handlers.player_attribute(joined_world=True)
|
async def stamps_load(server):
|
||||||
|
server.stamps = await StampCollection.get_collection()
|
||||||
|
server.logger.info(f'Loaded {len(server.stamps)} stamps')
|
||||||
|
|
||||||
|
|
||||||
|
@handlers.handler(XMLPacket('login'), priority=Priority.Low)
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
async def load_stamp_inventory(p):
|
async def load_stamp_inventory(p):
|
||||||
p.stamps = await PenguinStampCollection.get_collection(p.id)
|
p.stamps = await PenguinStampCollection.get_collection(p.id)
|
||||||
|
@ -181,48 +181,7 @@ class Houdini:
|
|||||||
await self.dummy_event_listeners.setup(houdini.handlers)
|
await self.dummy_event_listeners.setup(houdini.handlers)
|
||||||
await self.dummy_event_listeners.fire('boot', self)
|
await self.dummy_event_listeners.fire('boot', self)
|
||||||
|
|
||||||
self.igloos = await IglooCollection.get_collection()
|
|
||||||
self.logger.info(f'Loaded {len(self.igloos)} igloos')
|
|
||||||
|
|
||||||
self.furniture = await FurnitureCollection.get_collection()
|
|
||||||
self.logger.info(f'Loaded {len(self.furniture)} furniture items')
|
|
||||||
|
|
||||||
self.locations = await LocationCollection.get_collection()
|
|
||||||
self.logger.info(f'Loaded {len(self.locations)} igloo locations')
|
|
||||||
|
|
||||||
self.flooring = await FlooringCollection.get_collection()
|
|
||||||
self.logger.info(f'Loaded {len(self.flooring)} igloo flooring')
|
|
||||||
|
|
||||||
self.rooms = await RoomCollection.get_collection()
|
|
||||||
self.spawn_rooms = self.rooms.spawn_rooms
|
|
||||||
await self.rooms.setup_tables()
|
|
||||||
await self.rooms.setup_waddles()
|
|
||||||
self.logger.info(f'Loaded {len(self.rooms)} rooms ({len(self.spawn_rooms)} spawn)')
|
|
||||||
|
|
||||||
self.postcards = await PostcardCollection.get_collection()
|
|
||||||
self.logger.info(f'Loaded {len(self.postcards)} postcards')
|
|
||||||
|
|
||||||
self.stamps = await StampCollection.get_collection()
|
|
||||||
self.logger.info(f'Loaded {len(self.stamps)} stamps')
|
|
||||||
|
|
||||||
self.cards = await CardCollection.get_collection()
|
|
||||||
self.logger.info(f'Loaded {len(self.cards)} ninja cards')
|
|
||||||
|
|
||||||
self.puffles = await PuffleCollection.get_collection()
|
|
||||||
self.logger.info(f'Loaded {len(self.puffles)} puffles')
|
|
||||||
|
|
||||||
self.puffle_items = await PuffleItemCollection.get_collection()
|
|
||||||
self.logger.info(f'Loaded {len(self.puffle_items)} puffle care items')
|
|
||||||
|
|
||||||
self.puffle_food_treasure = await PuffleTreasurePuffleItem.query.gino.all()
|
|
||||||
self.puffle_furniture_treasure = await PuffleTreasureFurniture.query.gino.all()
|
|
||||||
self.puffle_clothing_treasure = await PuffleTreasureItem.query.gino.all()
|
|
||||||
|
|
||||||
self.characters = await CharacterCollection.get_collection()
|
|
||||||
self.logger.info(f'Loaded {len(self.characters)} characters')
|
|
||||||
|
|
||||||
self.permissions = await PermissionCollection.get_collection()
|
self.permissions = await PermissionCollection.get_collection()
|
||||||
self.chat_filter_words = await ChatFilterRuleCollection.get_collection()
|
|
||||||
|
|
||||||
self.logger.info(f'Multi-client support is '
|
self.logger.info(f'Multi-client support is '
|
||||||
f'{"enabled" if not self.config.single_client_mode else "disabled"}')
|
f'{"enabled" if not self.config.single_client_mode else "disabled"}')
|
||||||
|
Loading…
Reference in New Issue
Block a user