-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcdplugin.py
37 lines (33 loc) · 1.15 KB
/
mcdplugin.py
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
#!/bin/bash
# -*- coding: utf-8 -*-
#this file includes basic plugin features
import os
import sys
import traceback
from imp import load_source
from mcdlog import *
class mcdplugin(object):
def __init__(self):
self.initPlugins()
def initPlugins(self): #find plugins and init
self.pluginList = []
self.plugins = []
self.startupPlugins = []
self.onPlayerJoinPlugins = []
self.onPlayerLeavePlugins = []
path = 'plugins'
filelist = os.listdir(path)
for singleFile in filelist:
filepath = path + '/' + singleFile
if os.path.isfile(filepath):
if singleFile.endswith('.py'):
self.pluginList.append(singleFile[:-3])
singlePlugin = load_source(singleFile[:-3], filepath)
if hasattr(singlePlugin, 'onServerInfo'):
self.plugins.append(singlePlugin)
if hasattr(singlePlugin, 'onServerStartup'):
self.startupPlugins.append(singlePlugin)
if hasattr(singlePlugin, 'onPlayerJoin'):
self.onPlayerJoinPlugins.append(singlePlugin)
if hasattr(singlePlugin, 'onPlayerLeave'):
self.onPlayerLeavePlugins.append(singlePlugin)