-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvenience_plugin.py
37 lines (31 loc) · 1.69 KB
/
convenience_plugin.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
from base_plugin import SimpleCommandPlugin
from plugins.core.player_manager import permissions, UserLevels
from packets import warp_command_write, Packets, warp_command
from utility_functions import build_packet, extract_name
class Convenience(SimpleCommandPlugin):
"""
Plugin that allows players to warp to their ship and home planet.
"""
name = "convenience_plugin"
depends = ['command_dispatcher', 'player_manager']
commands = ["ship", "home"]
auto_activate = True
def activate(self):
super(Convenience, self).activate()
self.player_manager = self.plugins['player_manager'].player_manager
@permissions(UserLevels.REGISTERED)
def ship(self, arg):
"""Warps you to your ship.\nSyntax: /ship"""
player = self.player_manager.get_logged_in_by_name(self.protocol.player.name)
from_protocol = self.factory.protocols[player.protocol]
warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_UP'))
from_protocol.client_protocol.transport.write(warp_packet)
self.protocol.send_chat_message("^yellow;%s^green; warped to their ship." % self.protocol.player.name)
@permissions(UserLevels.REGISTERED)
def home(self, arg):
"""Warps you to your home planet.\nSyntax: /home"""
player = self.player_manager.get_logged_in_by_name(self.protocol.player.name)
from_protocol = self.factory.protocols[player.protocol]
warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_HOME'))
from_protocol.client_protocol.transport.write(warp_packet)
self.protocol.send_chat_message("^yellow;%s^green; warped to their home planet." % self.protocol.player.name)