Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Commit

Permalink
multi-thread support
Browse files Browse the repository at this point in the history
  • Loading branch information
kafuuchino-desu authored Nov 25, 2018
1 parent 153c612 commit f643ba8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ def tick(self):
server.say('error initalizing plugins,check console for detailed information')
errlog('error initalizing plugins,printing traceback.', traceback.format_exc())
for singleplugin in plugins.plugins:
try:
singleplugin.onServerInfo(self, result)
except:
errlog('error processing plugin: ' + str(singleplugin), traceback.format_exc())
t =threading.Thread(target=self.callplugin,args=(result, singleplugin))
t.setDaemon(True)
t.start()
time.sleep(1)
except (KeyboardInterrupt, SystemExit):
self.stop()
Expand Down Expand Up @@ -105,6 +104,12 @@ def say(self, data):
def tell(self, player, data):
self.execute('tellraw '+ player + ' {"text":"' + data + '"}')
def callplugin(self, result, plugin):
try:
plugin.onServerInfo(self, result)
except:
errlog('error processing plugin: ' + str(singleplugin), traceback.format_exc())
if __name__ == "__main__":
notice()
Expand Down

0 comments on commit f643ba8

Please sign in to comment.