<s> import logging <EOL> from collections import deque <EOL> from spockbot . plugins . base import pl_announce , PluginBase <EOL> from spockbot . vector import Vector3 <EOL> from bat . command import register_command <EOL> logger = logging . getLogger ( '<STR_LIT>' ) <EOL> @ pl_announce ( '<STR_LIT>' ) <EOL> class MovementCommandsPlugin ( PluginBase ) : <EOL> requires = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __init__ ( self , ploader , settings ) : <EOL> super ( MovementCommandsPlugin , self ) . __init__ ( ploader , settings ) <EOL> self . commands . register_handlers ( self ) <EOL> ploader . provides ( '<STR_LIT>' , self ) <EOL> self . path_queue = deque ( ) <EOL> self . follow_eid = None <EOL> def on_entity_move ( self , evt , packet ) : <EOL> eid = packet . data [ '<STR_LIT>' ] <EOL> if self . follow_eid and eid == self . follow_eid : <EOL> self . teleport ( Vector3 ( self . entities . entities [ eid ] ) ) <EOL> @ register_command ( '<STR_LIT>' , '<STR_LIT:3>' ) <EOL> def tp_block ( self , coords ) : <EOL> self . teleport ( Vector3 ( * coords ) . ifloor ( ) . iadd ( <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> ) ) <EOL> @ register_command ( '<STR_LIT>' , '<STR_LIT:3>' ) <EOL> def tp_delta ( self , deltas ) : <EOL> self . teleport ( Vector3 ( * deltas ) . iadd ( self . clientinfo . position ) ) <EOL> @ register_command ( '<STR_LIT>' , '<STR_LIT:3>' ) <EOL> def teleport ( self , coords ) : <EOL> self . clientinfo . position . init ( * coords ) <EOL> @ register_command ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def tp_to_player ( self , player = None ) : <EOL> if player is None : <EOL> logger . warn ( '<STR_LIT>' ) <EOL> else : <EOL> self . teleport ( Vector3 ( player ) ) <EOL> @ register_command ( '<STR_LIT>' , '<STR_LIT:e>' ) <EOL> def follow_player ( self , player ) : <EOL> self . follow_eid = player . eid <EOL> @ register_command ( '<STR_LIT>' ) <EOL> def unfollow_player ( self ) : <EOL> self . follow_eid = None <EOL> @ register_command ( '<STR_LIT>' ) <EOL> def path_reset ( self ) : <EOL> self . path_queue = deque ( ) <EOL> @ register_command ( '<STR_LIT>' ) <EOL> def path_go ( self ) : <EOL> if len ( self . path_queue ) > <NUM_LIT:0> : <EOL> self . tp_block ( self . path_queue . popleft ( ) ) <EOL> self . timers . reg_event_timer ( <NUM_LIT:1> , self . path_go , runs = <NUM_LIT:1> ) <EOL> @ register_command ( '<STR_LIT>' , '<STR_LIT:3>' ) <EOL> def path_add ( self , coords ) : <EOL> self . path_queue . append ( coords ) <EOL> @ register_command ( '<STR_LIT>' , '<STR_LIT:3>' ) <EOL> def path_add_delta ( self , delta ) : <EOL> if len ( self . path_queue ) > <NUM_LIT:0> : <EOL> pos = Vector3 ( self . path_queue [ - <NUM_LIT:1> ] ) <EOL> else : <EOL> pos = self . clientinfo . position <EOL> self . path_queue . append ( pos + delta ) </s>
