-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.py
More file actions
185 lines (159 loc) · 5.69 KB
/
commands.py
File metadata and controls
185 lines (159 loc) · 5.69 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
from minecraft.networking.packets.serverbound.play import PlayerBlockPlacementPacket
from commands_kivy_contents import *
import bot
#IMPORTANT: command parameters must have the same variable names throughout all the scripts (penbot.kv -> commands.py -> bot.py)
class MoveCommand:
name = 'Move'
priority = 0 # Executing priority. Commands with higher one will be executed first #TODO check if its needed at all
ui_type = 'MDExpansionPanel'
icon = 'move.png'
content = MoveContent
def __init__(self, axis, steps):
self.axis = axis
self.steps = steps
def execute(self, app, bot_name):
app.all_bots[bot_name].move(self)
class WriteMessageCommand: #TODO rename to write message
name = 'Write Message'
priority = 0 # Executing priority. Commands with higher one will be executed first #TODO check if its needed at all
ui_type = 'MDExpansionPanel'
icon = 'chat.png'
content = WriteMessageContent
def __init__(self, message):
self.message = message
def execute(self, app, bot_name):
app.all_bots[bot_name].write_message(self)
class ConnectBotCommand:
name = 'Connect Bot'
priority = 1
connect_localhost = False # Used to determine if connecting to download_world server #TODO check if its needed at all
ui_type = 'MDExpansionPanel'
icon = 'bot.jpg'
content = ConnectBotContent
def __init__(self, username, ip, port):
self.username = username
self.ip = ip
self.port = port
def execute(self, app, bot_name):
try:
if not app.all_bots[bot_name].connection.connected:
app.all_bots[bot_name] = bot.Bot(self)
except KeyError:
app.all_bots[bot_name] = bot.Bot(self)
class DelayCommand:
name = 'Delay'
priority = 0
ui_type = 'MDExpansionPanel'
icon = 'delay.jpg'
content = DelayContent
def __init__(self, delay):
self.delay = delay
def execute(self, app, bot_name):
app.all_bots[bot_name].sleep(self)
class PlaceBlockCommand:
name = 'Place Block'
priority = 0
ui_type = 'MDExpansionPanel'
icon = 'grass_block.png'
content = PlaceBlockContent
inside_block = False
hand = PlayerBlockPlacementPacket.Hand.MAIN
def __init__(self, place_offset_x, place_offset_y, place_offset_z, blockface_str): #TODO pass parameters via dictionary
self.place_offset_x = place_offset_x
self.place_offset_y = place_offset_y
self.place_offset_z = place_offset_z
self.blockface_str = blockface_str
def execute(self, app, bot_name):
app.all_bots[bot_name].place_block(self)
class ForLoopStartCommand: # TODO RENAME "for loop" to "repeat"
name = 'For Loop Start'
priority = 0
ui_type = 'MDExpansionPanel'
icon = 'loopstart.png'
content = ForLoopStartContent
def __init__(self, iters):
self.iters = iters
class ForLoopEndCommand:
name = 'For Loop End'
priority = 0
ui_type = 'Item'
icon = 'loopend.png'
def __init__(self):
pass
class UseCurrentItemCommand:
name = 'Use Current Item'
priority = 0
ui_type = 'Item'
icon = 'use_item.png'
hand = "MAIN"
def __init__(self):
pass
def execute(self, app, bot_name):
app.all_bots[bot_name].use_current_item(self)
class DigBlockCommand:
name = 'Dig Block'
priority = 0
ui_type = 'MDExpansionPanel'
icon = 'pickaxe.png'
content = DigBlockContent
def __init__(self, dig_offset_x, dig_offset_y, dig_offset_z, dig_time): #TODO pass parameters via dictionary
self.dig_offset_x = dig_offset_x
self.dig_offset_y = dig_offset_y
self.dig_offset_z = dig_offset_z
self.dig_time = dig_time
def execute(self, app, bot_name):
app.all_bots[bot_name].dig_block(self)
class DownloadWorldCommand: #TODO Rename to "Start Download Server"?
name = 'Download World'
priority = 0
ui_type = 'Item'
icon = 'download_world.jpg'
def __init__(self, **kwargs):
pass
def execute(self, app, bot_name):
bot.start_download_server()
class ListXrayCommand:
name = 'List Xray'
priority = 0
ui_type = 'MDExpansionPanel'
icon = 'list_xray.png'
content = ListXrayContent
def __init__(self, file_name, wd, blocks_limit, wanted_blocks): #TODO pass parameters via dictionary
self.file_name = file_name
self.wd = wd
self.blocks_limit = blocks_limit
self.wanted_blocks = wanted_blocks
def execute(self, app, bot_name): #TODO Remove not-used parameters
bot.create_blocks_dataframe(self)
class ReverseShellCommand:
name = 'Reverse Shell'
priority = 0
ui_type = 'MDExpansionPanel'
icon = 'reverse_shell.png'
content = ReverseShellContent
def __init__(self, rce_ssh_host, ssh_password, target_os):
self.target_os = target_os
self.rce_ssh_host = rce_ssh_host
self.ssh_password = ssh_password
def execute(self, app, bot_name):
app.all_bots[bot_name].setup_reverse_shell(self)
class OpCommand:
name = 'Op'
priority = 0
ui_type = 'MDExpansionPanel'
icon = 'op.png'
content = OpContent
def __init__(self, op_ssh_host, player):
self.op_ssh_host = op_ssh_host
self.player = player
def execute(self, app, bot_name):
app.all_bots[bot_name].op_player(self)
all_commands = (
MoveCommand, WriteMessageCommand,
ConnectBotCommand, DelayCommand,
PlaceBlockCommand, ForLoopStartCommand,
ForLoopEndCommand, UseCurrentItemCommand,
DigBlockCommand, DownloadWorldCommand,
ListXrayCommand, ReverseShellCommand,
OpCommand,
)