File size: 1,820 Bytes
4c75d73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""

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}")