11import abc
22
3- from commands import *
3+ import commands as c
44
55class InsnArg :
66
@@ -39,7 +39,7 @@ class EntityLocal(NativeType):
3939
4040 def __init__ (self , name ):
4141 self .name = name
42- self .obj_ref = ObjectiveRef (name )
42+ self .obj_ref = c . ObjectiveRef (name )
4343
4444class VirtualString (NativeType ):
4545
@@ -65,7 +65,7 @@ def __init__(self, name):
6565 self .player = name
6666
6767 def as_resolve (self ):
68- return NameRef (self .player )
68+ return c . NameRef (self .player )
6969
7070class SelectorType (InsnArg ):
7171
@@ -96,8 +96,7 @@ def _init_from_parser(cls, name):
9696SelectorType .NEAREST_PLAYER = SelectorType ('p' , 1 )
9797SelectorType .RANDOM_PLAYER = SelectorType ('r' , 1 )
9898
99- # Name conflict with commands.Selector
100- class SelectorTy (EntitySelection ):
99+ class Selector (EntitySelection ):
101100
102101 def __new__ (cls , type ):
103102 if type .max_limit == 1 :
@@ -114,24 +113,24 @@ def set(self, key, value):
114113 self .simple_args [key ] = value
115114
116115 def set_score_range (self , objective , min , max ):
117- self .other_args .append (SelRange (objective , min , max ))
116+ self .other_args .append (c . SelRange (objective , min , max ))
118117
119118 def set_nbt (self , path , value ):
120119 parts = path .split ('.' ) if path else []
121- self .other_args .append (SelNbt (parts , value ))
120+ self .other_args .append (c . SelNbt (parts , value ))
122121
123122 @property
124123 def is_only_one (self ):
125124 return 'limit' in self .simple_args and self .simple_args ['limit' ] == '1'
126125
127126 def as_resolve (self ):
128- args = SimpleSelectorArgs (self .simple_args )
127+ args = c . SimpleSelectorArgs (self .simple_args )
129128 for other in self .other_args :
130- args = ComboSelectorArgs .new (args , other )
131- return Selector (self .type .letter , args )
129+ args = c . ComboSelectorArgs .new (args , other )
130+ return c . Selector (self .type .letter , args )
132131
133132# Same as Selector but is also an EntityRef so can be used in more places
134- class SingleEntitySelector (SelectorTy , EntityRef ):
133+ class SingleEntitySelector (Selector , EntityRef ):
135134
136135 def __new__ (cls , type ):
137136 return object .__new__ (cls )
@@ -143,7 +142,7 @@ def is_only_one(self):
143142class PosUtilEntity (EntityRef ):
144143
145144 def as_resolve (self ):
146- return PosUtil
145+ return c . PosUtil
147146
148147class Position (NativeType ):
149148
@@ -158,30 +157,30 @@ def internal(val):
158157 self ._x , self ._y , self ._z = map (internal , (x , y , z ))
159158
160159 def as_blockpos (self ):
161- return WorldPos (self ._x , self ._y , self ._z , block_pos = True )
160+ return c . WorldPos (self ._x , self ._y , self ._z , block_pos = True )
162161
163162 def as_worldpos (self ):
164- return WorldPos (self ._x , self ._y , self ._z )
163+ return c . WorldPos (self ._x , self ._y , self ._z )
165164
166165class RelPosVal (NativeType ):
167166
168167 def __init__ (self , val ):
169168 self .val = val
170- self .as_coord = WorldRelCoord (val )
169+ self .as_coord = c . WorldRelCoord (val )
171170
172171class AncPosVal (NativeType ):
173172
174173 def __init__ (self , val ):
175174 self .val = val
176- self .as_coord = AnchorRelCoord (val )
175+ self .as_coord = c . AnchorRelCoord (val )
177176
178177class CmdFunction (NativeType , metaclass = abc .ABCMeta ):
179178
180179 @abc .abstractmethod
181180 def as_cmd (self ):
182181 pass
183182
184- class BlockType (Resolvable , NativeType ):
183+ class BlockType (c . Resolvable , NativeType ):
185184
186185 def __init__ (self , block_id ):
187186 self .block_id = block_id
@@ -200,7 +199,7 @@ def resolve(self, scope):
200199 nbt = self .nbt .resolve (scope ) if self .nbt is not None else ''
201200 return '%s%s%s' % (self .block_id , '[%s]' % props if props else '' , nbt )
202201
203- class ItemType (Resolvable , NativeType ):
202+ class ItemType (c . Resolvable , NativeType ):
204203
205204 def __init__ (self , item_id ):
206205 self .item_id = item_id
@@ -216,3 +215,79 @@ def resolve(self, scope):
216215 nbt = NBTCompound (self .nbt_props .items ())
217216 props = nbt .resolve (scope )
218217 return '%s%s' % (self .item_id , props )
218+
219+ class TeamRef (NativeType ):
220+
221+ def __init__ (self , name ):
222+ self .name = name
223+ self .ref = c .TeamName (name )
224+
225+ class TextColor (InsnArg ):
226+
227+ __lookup = {}
228+
229+ def __init__ (self , name ):
230+ self .name = name
231+ self .__lookup [name ] = self
232+
233+ @classmethod
234+ def _init_from_parser (cls , value ):
235+ return cls .__lookup [value ]
236+
237+ black = None
238+ dark_blue = None
239+ dark_green = None
240+ dark_aqua = None
241+ dark_red = None
242+ dark_purple = None
243+ gold = None
244+ gray = None
245+ dark_gray = None
246+ blue = None
247+ green = None
248+ aqua = None
249+ red = None
250+ light_purple = None
251+ yellow = None
252+ white = None
253+ reset = None
254+
255+ TextColor .black = TextColor ('black' )
256+ TextColor .dark_blue = TextColor ('dark_blue' )
257+ TextColor .dark_green = TextColor ('dark_green' )
258+ TextColor .dark_aqua = TextColor ('dark_aqua' )
259+ TextColor .dark_red = TextColor ('dark_red' )
260+ TextColor .dark_purple = TextColor ('dark_purple' )
261+ TextColor .gold = TextColor ('gold' )
262+ TextColor .gray = TextColor ('gray' )
263+ TextColor .dark_gray = TextColor ('dark_gray' )
264+ TextColor .blue = TextColor ('blue' )
265+ TextColor .green = TextColor ('green' )
266+ TextColor .aqua = TextColor ('aqua' )
267+ TextColor .red = TextColor ('red' )
268+ TextColor .light_purple = TextColor ('light_purple' )
269+ TextColor .yellow = TextColor ('yellow' )
270+ TextColor .white = TextColor ('white' )
271+ TextColor .reset = TextColor ('reset' )
272+
273+ class BossbarRef (NativeType ):
274+
275+ def __init__ (self , name ):
276+ self .name = name
277+ self .ref = c .Bossbar (name )
278+
279+ PosType = (int , float , RelPosVal , AncPosVal )
280+
281+ def Opt (optype ):
282+ return (type (None ), optype )
283+
284+ class EventRef (NativeType ):
285+
286+ def __init__ (self , name ):
287+ self .name = name
288+ self .conditions = {}
289+
290+ def add_condition (self , path , value ):
291+ self .conditions [path ] = value
292+
293+ RelPosType = (int , float , RelPosVal )
0 commit comments