Chris4K's picture
Upload 195 files
4c75d73 verified
"""
Sample plugin demonstrating the plugin system.
"""
from src.interfaces.plugin_interfaces import IPlugin, PluginMetadata, PluginType
from typing import Dict, Any
class SamplePlugin(IPlugin):
"""Sample plugin implementation."""
@property
def metadata(self) -> PluginMetadata:
return PluginMetadata(
id="sample_plugin",
name="Sample Plugin",
version="1.0.0",
description="A sample plugin demonstrating the plugin system",
author="MMORPG System",
plugin_type=PluginType.EVENT,
dependencies=[],
config={}
)
def initialize(self, context: Dict[str, Any]) -> bool:
"""Initialize the plugin."""
self.context = context
print("[SamplePlugin] Plugin initialized!")
return True
def shutdown(self) -> bool:
"""Shutdown the plugin."""
print("[SamplePlugin] Plugin shutdown!")
return True
def get_status(self) -> Dict[str, Any]:
"""Get plugin status."""
return {
"status": "active",
"message": "Sample plugin is running normally"
}
def on_player_join(self, player_id: str) -> None:
"""Called when a player joins."""
print(f"[SamplePlugin] Player {player_id} joined!")
def on_player_leave(self, player_id: str) -> None:
"""Called when a player leaves."""
print(f"[SamplePlugin] Player {player_id} left!")
def on_chat_message(self, sender_id: str, message: str, message_type: str) -> None:
"""Called when a chat message is sent."""
if "hello plugin" in message.lower():
print(f"[SamplePlugin] Detected greeting from {sender_id}")