Download plugins/sample_plugin.py from Agents-MCP-Hackathon/MMORPG_AI_NPC_MCP_CLIENT_SERVER: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/spaces/Agents-MCP-Hackathon/MMORPG_AI_NPC_MCP_CLIENT_SERVER/resolve/main/plugins/sample_plugin.py
- Command line
-
hf download hf://spaces/Agents-MCP-Hackathon/MMORPG_AI_NPC_MCP_CLIENT_SERVER/plugins/sample_plugin.py
-
curl -L -o sample_plugin.py https://huggingface.co/spaces/Agents-MCP-Hackathon/MMORPG_AI_NPC_MCP_CLIENT_SERVER/resolve/main/plugins/sample_plugin.py
1.82 kB
| """ | |
| 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.""" | |
| 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}") | |