rustplus 5.6.17__tar.gz → 6.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rustplus-6.0.0/MANIFEST.in +3 -0
- {rustplus-5.6.17/rustplus.egg-info → rustplus-6.0.0}/PKG-INFO +2 -2
- rustplus-6.0.0/requirements.txt +9 -0
- rustplus-6.0.0/rustplus/__init__.py +16 -0
- rustplus-6.0.0/rustplus/annotations/__init__.py +5 -0
- rustplus-6.0.0/rustplus/annotations/chat_event.py +21 -0
- rustplus-6.0.0/rustplus/annotations/command.py +23 -0
- rustplus-6.0.0/rustplus/annotations/entity_event.py +19 -0
- rustplus-6.0.0/rustplus/annotations/protobuf_event.py +19 -0
- rustplus-6.0.0/rustplus/annotations/team_event.py +19 -0
- rustplus-6.0.0/rustplus/commands/__init__.py +3 -0
- rustplus-6.0.0/rustplus/commands/chat_command.py +33 -0
- rustplus-5.6.17/rustplus/commands/command_data.py → rustplus-6.0.0/rustplus/commands/chat_command_data.py +7 -6
- rustplus-6.0.0/rustplus/commands/command_options.py +9 -0
- rustplus-6.0.0/rustplus/events/__init__.py +4 -0
- rustplus-6.0.0/rustplus/events/chat_event.py +13 -0
- rustplus-6.0.0/rustplus/events/entity_event.py +60 -0
- rustplus-6.0.0/rustplus/events/protobuf_event.py +12 -0
- rustplus-6.0.0/rustplus/events/team_event.py +18 -0
- rustplus-6.0.0/rustplus/identification/__init__.py +2 -0
- rustplus-6.0.0/rustplus/identification/handler_list.py +76 -0
- {rustplus-5.6.17/rustplus/api/remote/events → rustplus-6.0.0/rustplus/identification}/registered_listener.py +4 -10
- rustplus-6.0.0/rustplus/identification/server_details.py +39 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/remote/camera/camera_manager.py +21 -13
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/remote/camera/camera_parser.py +9 -6
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/remote/camera/structures.py +7 -7
- rustplus-6.0.0/rustplus/remote/fcm/__init__.py +1 -0
- rustplus-6.0.0/rustplus/remote/proxy/__init__.py +1 -0
- rustplus-6.0.0/rustplus/remote/proxy/proxy_value_grabber.py +32 -0
- rustplus-5.6.17/rustplus/api/remote/ratelimiter.py → rustplus-6.0.0/rustplus/remote/ratelimiter/__init__.py +27 -30
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/remote/rustplus_proto/rustplus.py +2 -1
- rustplus-6.0.0/rustplus/remote/websocket/__init__.py +1 -0
- rustplus-6.0.0/rustplus/remote/websocket/ws.py +348 -0
- rustplus-6.0.0/rustplus/rust_api.py +524 -0
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/rust_chat_message.py +1 -1
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/rust_entity_info.py +1 -1
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/rust_marker.py +1 -0
- rustplus-6.0.0/rustplus/utils/__init__.py +13 -0
- rustplus-6.0.0/rustplus/utils/emojis.py +31 -0
- rustplus-6.0.0/rustplus/utils/fonts/__init__.py +0 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/rustplus/utils/grab_items.py +46 -1
- rustplus-5.6.17/rustplus/utils/rust_utils.py → rustplus-6.0.0/rustplus/utils/utils.py +129 -167
- {rustplus-5.6.17 → rustplus-6.0.0}/rustplus/utils/yielding_event.py +10 -8
- {rustplus-5.6.17 → rustplus-6.0.0/rustplus.egg-info}/PKG-INFO +2 -2
- rustplus-6.0.0/rustplus.egg-info/SOURCES.txt +111 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/rustplus.egg-info/requires.txt +1 -1
- rustplus-5.6.17/MANIFEST.in +0 -2
- rustplus-5.6.17/rustplus/__init__.py +0 -26
- rustplus-5.6.17/rustplus/api/__init__.py +0 -1
- rustplus-5.6.17/rustplus/api/base_rust_api.py +0 -637
- rustplus-5.6.17/rustplus/api/remote/__init__.py +0 -8
- rustplus-5.6.17/rustplus/api/remote/events/__init__.py +0 -4
- rustplus-5.6.17/rustplus/api/remote/events/event_handler.py +0 -44
- rustplus-5.6.17/rustplus/api/remote/events/event_loop_manager.py +0 -25
- rustplus-5.6.17/rustplus/api/remote/events/events.py +0 -126
- rustplus-5.6.17/rustplus/api/remote/events/handler_list.py +0 -63
- rustplus-5.6.17/rustplus/api/remote/events/map_event_listener.py +0 -104
- rustplus-5.6.17/rustplus/api/remote/heartbeat.py +0 -32
- rustplus-5.6.17/rustplus/api/remote/rplus_version_handler.py +0 -19
- rustplus-5.6.17/rustplus/api/remote/rust_remote_interface.py +0 -256
- rustplus-5.6.17/rustplus/api/remote/rustws.py +0 -394
- rustplus-5.6.17/rustplus/api/remote/server_checker.py +0 -26
- rustplus-5.6.17/rustplus/api/rust_api.py +0 -404
- rustplus-5.6.17/rustplus/commands/__init__.py +0 -3
- rustplus-5.6.17/rustplus/commands/command.py +0 -23
- rustplus-5.6.17/rustplus/commands/command_handler.py +0 -68
- rustplus-5.6.17/rustplus/commands/command_options.py +0 -17
- rustplus-5.6.17/rustplus/conversation/__init__.py +0 -3
- rustplus-5.6.17/rustplus/conversation/conversation.py +0 -62
- rustplus-5.6.17/rustplus/conversation/conversation_factory.py +0 -50
- rustplus-5.6.17/rustplus/conversation/conversation_prompt.py +0 -12
- rustplus-5.6.17/rustplus/utils/__init__.py +0 -6
- rustplus-5.6.17/rustplus/utils/emojis.py +0 -31
- rustplus-5.6.17/rustplus/utils/server_id.py +0 -26
- rustplus-5.6.17/rustplus.egg-info/SOURCES.txt +0 -110
- {rustplus-5.6.17 → rustplus-6.0.0}/LICENSE +0 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/README.md +0 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/rustplus/exceptions/__init__.py +0 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/rustplus/exceptions/exceptions.py +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/__init__.py +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/airfield.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/arctic_base.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/bandit.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/barn.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/cargo.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/chinook.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/chinook_blades.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/crate.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/desert_base.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/dome.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/excavator.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/explosion.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/ferryterminal.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/fishing.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/harbour.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/icon.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/junkyard.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/large_oil_rig.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/launchsite.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/lighthouse.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/military_tunnels.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/mining_outpost.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/mining_quarry_hqm.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/mining_quarry_stone.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/mining_quarry_sulfur.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/missile_silo.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/outpost.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/oxums.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/patrol.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/power_plant.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/satellite.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/sewer.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/small_oil_rig.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/stables.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/supermarket.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/swamp.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/train.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/train_yard.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/underwater_lab.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/vending_machine.png +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/icons/water_treatment.png +0 -0
- {rustplus-5.6.17/rustplus/utils/fonts → rustplus-6.0.0/rustplus/remote}/__init__.py +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/remote/camera/__init__.py +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/remote/camera/camera_constants.py +0 -0
- {rustplus-5.6.17/rustplus/api/remote → rustplus-6.0.0/rustplus/remote/fcm}/fcm_listener.py +0 -0
- {rustplus-5.6.17/rustplus/api → rustplus-6.0.0/rustplus}/remote/rustplus_proto/__init__.py +0 -0
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/__init__.py +0 -0
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/rust_contents.py +0 -0
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/rust_info.py +0 -0
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/rust_item.py +0 -0
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/rust_map.py +0 -0
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/rust_team_info.py +0 -0
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/rust_time.py +0 -0
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/serialization.py +0 -0
- {rustplus-5.6.17/rustplus/api/structures → rustplus-6.0.0/rustplus/structs}/util.py +0 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/rustplus/utils/deprecated.py +0 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/rustplus/utils/fonts/PermanentMarker.ttf +0 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/rustplus.egg-info/dependency_links.txt +0 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/rustplus.egg-info/top_level.txt +0 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/setup.cfg +0 -0
- {rustplus-5.6.17 → rustplus-6.0.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rustplus
|
|
3
|
-
Version:
|
|
3
|
+
Version: 6.0.0
|
|
4
4
|
Summary: A python wrapper for the Rust Plus API
|
|
5
5
|
Home-page: https://github.com/olijeffers0n/rustplus
|
|
6
6
|
Author: olijeffers0n
|
|
@@ -12,7 +12,7 @@ License-File: LICENSE
|
|
|
12
12
|
Requires-Dist: websockets
|
|
13
13
|
Requires-Dist: Pillow
|
|
14
14
|
Requires-Dist: asyncio
|
|
15
|
-
Requires-Dist: rustPlusPushReceiver==0.
|
|
15
|
+
Requires-Dist: rustPlusPushReceiver==0.6.0
|
|
16
16
|
Requires-Dist: http-ece
|
|
17
17
|
Requires-Dist: requests
|
|
18
18
|
Requires-Dist: numpy
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
r"""
|
|
2
|
+
RustPlus, An API wrapper for interfacing with the Rust+ App API
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .rust_api import RustSocket
|
|
6
|
+
from .identification import ServerDetails
|
|
7
|
+
from .annotations import Command, ChatEvent, ProtobufEvent, TeamEvent, EntityEvent
|
|
8
|
+
from .remote.fcm import FCMListener
|
|
9
|
+
from .commands import CommandOptions, ChatCommand
|
|
10
|
+
from .events import ChatEventPayload, TeamEventPayload, EntityEventPayload
|
|
11
|
+
from .utils import convert_event_type_to_name, Emoji
|
|
12
|
+
|
|
13
|
+
__name__ = "rustplus"
|
|
14
|
+
__author__ = "olijeffers0n"
|
|
15
|
+
__version__ = "6.0.0"
|
|
16
|
+
__support__ = "Discord: https://discord.gg/nQqJe8qvP8"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
from .. import ServerDetails
|
|
4
|
+
from ..identification import RegisteredListener
|
|
5
|
+
from ..events import ChatEventPayload as ChatEventManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def ChatEvent(server_details: ServerDetails) -> Callable:
|
|
9
|
+
|
|
10
|
+
def wrapper(func) -> RegisteredListener:
|
|
11
|
+
|
|
12
|
+
if isinstance(func, RegisteredListener):
|
|
13
|
+
func = func.get_coro()
|
|
14
|
+
|
|
15
|
+
listener = RegisteredListener(func.__name__, func)
|
|
16
|
+
|
|
17
|
+
ChatEventManager.HANDLER_LIST.register(listener, server_details)
|
|
18
|
+
|
|
19
|
+
return listener
|
|
20
|
+
|
|
21
|
+
return wrapper
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
from ..identification import RegisteredListener, ServerDetails
|
|
4
|
+
from ..commands import ChatCommand, ChatCommandData
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def Command(
|
|
8
|
+
server_details: ServerDetails, aliases: list = None, alias_func: Callable = None
|
|
9
|
+
) -> Callable:
|
|
10
|
+
|
|
11
|
+
def wrapper(func):
|
|
12
|
+
|
|
13
|
+
if isinstance(func, RegisteredListener):
|
|
14
|
+
func = func.get_coro()
|
|
15
|
+
|
|
16
|
+
command_data = ChatCommandData(
|
|
17
|
+
coroutine=func, aliases=aliases, callable_func=alias_func
|
|
18
|
+
)
|
|
19
|
+
ChatCommand.REGISTERED_COMMANDS[server_details][func.__name__] = command_data
|
|
20
|
+
|
|
21
|
+
return RegisteredListener(func.__name__, func)
|
|
22
|
+
|
|
23
|
+
return wrapper
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
from .. import ServerDetails
|
|
4
|
+
from ..identification import RegisteredListener
|
|
5
|
+
from ..events import EntityEventPayload as EntityEventManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def EntityEvent(server_details: ServerDetails, eid: int) -> Callable:
|
|
9
|
+
def wrapper(func) -> RegisteredListener:
|
|
10
|
+
if isinstance(func, RegisteredListener):
|
|
11
|
+
func = func.get_coro()
|
|
12
|
+
|
|
13
|
+
listener = RegisteredListener(str(eid), func)
|
|
14
|
+
|
|
15
|
+
EntityEventManager.HANDLER_LIST.register(listener, server_details)
|
|
16
|
+
|
|
17
|
+
return listener
|
|
18
|
+
|
|
19
|
+
return wrapper
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
from .. import ServerDetails
|
|
4
|
+
from ..identification import RegisteredListener
|
|
5
|
+
from ..events import ProtobufEventPayload as ProtobufEventManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def ProtobufEvent(server_details: ServerDetails) -> Callable:
|
|
9
|
+
def wrapper(func) -> RegisteredListener:
|
|
10
|
+
if isinstance(func, RegisteredListener):
|
|
11
|
+
func = func.get_coro()
|
|
12
|
+
|
|
13
|
+
listener = RegisteredListener(func.__name__, func)
|
|
14
|
+
|
|
15
|
+
ProtobufEventManager.HANDLER_LIST.register(listener, server_details)
|
|
16
|
+
|
|
17
|
+
return listener
|
|
18
|
+
|
|
19
|
+
return wrapper
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
from .. import ServerDetails
|
|
4
|
+
from ..identification import RegisteredListener
|
|
5
|
+
from ..events import TeamEventPayload as TeamEventManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def TeamEvent(server_details: ServerDetails) -> Callable:
|
|
9
|
+
def wrapper(func) -> RegisteredListener:
|
|
10
|
+
if isinstance(func, RegisteredListener):
|
|
11
|
+
func = func.get_coro()
|
|
12
|
+
|
|
13
|
+
listener = RegisteredListener(func.__name__, func)
|
|
14
|
+
|
|
15
|
+
TeamEventManager.HANDLER_LIST.register(listener, server_details)
|
|
16
|
+
|
|
17
|
+
return listener
|
|
18
|
+
|
|
19
|
+
return wrapper
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import dataclasses
|
|
2
|
+
from collections import defaultdict
|
|
3
|
+
from typing import Dict, List
|
|
4
|
+
|
|
5
|
+
from .chat_command_data import ChatCommandData
|
|
6
|
+
from ..identification import ServerDetails
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclasses.dataclass
|
|
10
|
+
class ChatCommandTime:
|
|
11
|
+
formatted_time: str
|
|
12
|
+
raw_time: int
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ChatCommand:
|
|
16
|
+
|
|
17
|
+
REGISTERED_COMMANDS: Dict[ServerDetails, Dict[str, ChatCommandData]] = defaultdict(
|
|
18
|
+
dict
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
sender_name: str,
|
|
24
|
+
sender_steam_id: int,
|
|
25
|
+
time: ChatCommandTime,
|
|
26
|
+
command: str,
|
|
27
|
+
args: List[str],
|
|
28
|
+
) -> None:
|
|
29
|
+
self.sender_name = sender_name
|
|
30
|
+
self.sender_steam_id = sender_steam_id
|
|
31
|
+
self.time = time
|
|
32
|
+
self.command = command
|
|
33
|
+
self.args = args
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
from typing import Callable
|
|
1
|
+
from typing import Callable
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
class
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
class ChatCommandData:
|
|
5
|
+
|
|
6
|
+
def __init__(self, coroutine: Callable, aliases=None, callable_func=None) -> None:
|
|
7
|
+
self.coroutine = coroutine
|
|
7
8
|
self._aliases = aliases
|
|
8
9
|
self._callable_func = callable_func
|
|
9
10
|
|
|
10
11
|
@property
|
|
11
|
-
def aliases(self)
|
|
12
|
+
def aliases(self):
|
|
12
13
|
if self._aliases is None:
|
|
13
14
|
return []
|
|
14
15
|
|
|
15
16
|
return self._aliases
|
|
16
17
|
|
|
17
18
|
@property
|
|
18
|
-
def callable_func(self)
|
|
19
|
+
def callable_func(self):
|
|
19
20
|
if self._callable_func is None:
|
|
20
21
|
return lambda x: False
|
|
21
22
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from rustplus.identification.handler_list import HandlerList
|
|
2
|
+
from ..structs import RustChatMessage
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ChatEventPayload:
|
|
6
|
+
HANDLER_LIST = HandlerList()
|
|
7
|
+
|
|
8
|
+
def __init__(self, message: RustChatMessage) -> None:
|
|
9
|
+
self._message = message
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
def message(self) -> RustChatMessage:
|
|
13
|
+
return self._message
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from rustplus.identification.handler_list import EntityHandlerList
|
|
4
|
+
from ..remote.rustplus_proto import AppEntityPayloadItem, AppEntityChanged
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Item:
|
|
8
|
+
def __init__(self, app_message: AppEntityPayloadItem) -> None:
|
|
9
|
+
self._item_id: int = app_message.item_id
|
|
10
|
+
self._quantity: int = app_message.quantity
|
|
11
|
+
self._item_is_blueprint: bool = app_message.item_is_blueprint
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def item_id(self) -> int:
|
|
15
|
+
return self._item_id
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def quantity(self) -> int:
|
|
19
|
+
return self._quantity
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def item_is_blueprint(self) -> bool:
|
|
23
|
+
return self._item_is_blueprint
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class EntityEventPayload:
|
|
27
|
+
HANDLER_LIST = EntityHandlerList()
|
|
28
|
+
|
|
29
|
+
def __init__(self, entity_changed: AppEntityChanged) -> None:
|
|
30
|
+
self._entity_id: int = entity_changed.entity_id
|
|
31
|
+
self._value: bool = entity_changed.payload.value
|
|
32
|
+
self._capacity: int = entity_changed.payload.capacity
|
|
33
|
+
self._has_protection: bool = entity_changed.payload.has_protection
|
|
34
|
+
self._protection_expiry: int = entity_changed.payload.protection_expiry
|
|
35
|
+
|
|
36
|
+
self._items: List[Item] = [Item(item) for item in entity_changed.payload.items]
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def entity_id(self) -> int:
|
|
40
|
+
return self._entity_id
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def value(self) -> bool:
|
|
44
|
+
return self._value
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def capacity(self) -> int:
|
|
48
|
+
return self._capacity
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def has_protection(self) -> bool:
|
|
52
|
+
return self._has_protection
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def protection_expiry(self) -> int:
|
|
56
|
+
return self._protection_expiry
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def items(self) -> List[Item]:
|
|
60
|
+
return self._items
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from rustplus.identification.handler_list import HandlerList
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ProtobufEventPayload:
|
|
5
|
+
HANDLER_LIST = HandlerList()
|
|
6
|
+
|
|
7
|
+
def __init__(self, message: bytes) -> None:
|
|
8
|
+
self._message = message
|
|
9
|
+
|
|
10
|
+
@property
|
|
11
|
+
def message(self) -> bytes:
|
|
12
|
+
return self._message
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from rustplus.identification.handler_list import HandlerList
|
|
2
|
+
from ..structs import RustTeamInfo
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TeamEventPayload:
|
|
6
|
+
HANDLER_LIST = HandlerList()
|
|
7
|
+
|
|
8
|
+
def __init__(self, player_id: int, team_info: RustTeamInfo) -> None:
|
|
9
|
+
self._player_id = player_id
|
|
10
|
+
self._team_info = team_info
|
|
11
|
+
|
|
12
|
+
@property
|
|
13
|
+
def player_id(self) -> int:
|
|
14
|
+
return self._player_id
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def team_info(self) -> RustTeamInfo:
|
|
18
|
+
return self._team_info
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from collections import defaultdict
|
|
2
|
+
from typing import Set, Dict
|
|
3
|
+
from rustplus.identification import (
|
|
4
|
+
RegisteredListener,
|
|
5
|
+
ServerDetails,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class HandlerList:
|
|
10
|
+
def __init__(self) -> None:
|
|
11
|
+
self._handlers: Dict[ServerDetails, Set[RegisteredListener]] = defaultdict(set)
|
|
12
|
+
|
|
13
|
+
def unregister(
|
|
14
|
+
self, listener: RegisteredListener, server_details: ServerDetails
|
|
15
|
+
) -> None:
|
|
16
|
+
self._handlers[server_details].remove(listener)
|
|
17
|
+
|
|
18
|
+
def register(
|
|
19
|
+
self, listener: RegisteredListener, server_details: ServerDetails
|
|
20
|
+
) -> None:
|
|
21
|
+
self._handlers[server_details].add(listener)
|
|
22
|
+
|
|
23
|
+
def has(self, listener: RegisteredListener, server_details: ServerDetails) -> bool:
|
|
24
|
+
return listener in self._handlers[server_details]
|
|
25
|
+
|
|
26
|
+
def unregister_all(self) -> None:
|
|
27
|
+
self._handlers.clear()
|
|
28
|
+
|
|
29
|
+
def get_handlers(self, server_details: ServerDetails) -> Set[RegisteredListener]:
|
|
30
|
+
return self._handlers.get(server_details, set())
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class EntityHandlerList(HandlerList):
|
|
34
|
+
def __init__(self) -> None:
|
|
35
|
+
super().__init__()
|
|
36
|
+
self._handlers: Dict[ServerDetails, Dict[str, Set[RegisteredListener]]] = (
|
|
37
|
+
defaultdict(dict)
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def unregister(
|
|
41
|
+
self, listener: RegisteredListener, server_details: ServerDetails
|
|
42
|
+
) -> None:
|
|
43
|
+
if listener.listener_id in self._handlers.get(server_details):
|
|
44
|
+
self._handlers.get(server_details).get(listener.listener_id).remove(
|
|
45
|
+
listener
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def register(
|
|
49
|
+
self, listener: RegisteredListener, server_details: ServerDetails
|
|
50
|
+
) -> None:
|
|
51
|
+
if server_details not in self._handlers:
|
|
52
|
+
self._handlers[server_details] = defaultdict(set)
|
|
53
|
+
|
|
54
|
+
if listener.listener_id not in self._handlers.get(server_details):
|
|
55
|
+
self._handlers.get(server_details)[listener.listener_id] = set()
|
|
56
|
+
|
|
57
|
+
self._handlers.get(server_details).get(listener.listener_id).add(listener)
|
|
58
|
+
|
|
59
|
+
def has(self, listener: RegisteredListener, server_details: ServerDetails) -> bool:
|
|
60
|
+
if (
|
|
61
|
+
server_details in self._handlers
|
|
62
|
+
and listener.listener_id in self._handlers.get(server_details)
|
|
63
|
+
):
|
|
64
|
+
return listener in self._handlers.get(server_details).get(
|
|
65
|
+
listener.listener_id
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
return False
|
|
69
|
+
|
|
70
|
+
def unregister_all(self) -> None:
|
|
71
|
+
self._handlers.clear()
|
|
72
|
+
|
|
73
|
+
def get_handlers(
|
|
74
|
+
self, server_details: ServerDetails
|
|
75
|
+
) -> Dict[str, Set[RegisteredListener]]:
|
|
76
|
+
return self._handlers.get(server_details, dict())
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Coroutine
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class RegisteredListener:
|
|
5
5
|
def __init__(
|
|
6
6
|
self,
|
|
7
|
-
listener_id:
|
|
7
|
+
listener_id: str,
|
|
8
8
|
coroutine: Coroutine,
|
|
9
|
-
entity_type: int = None,
|
|
10
9
|
) -> None:
|
|
11
|
-
self.listener_id =
|
|
10
|
+
self.listener_id = listener_id
|
|
12
11
|
self._coroutine = coroutine
|
|
13
|
-
self._entity_type = entity_type
|
|
14
12
|
|
|
15
13
|
def get_coro(self):
|
|
16
14
|
return self._coroutine
|
|
17
15
|
|
|
18
|
-
def get_entity_type(self):
|
|
19
|
-
return self._entity_type
|
|
20
|
-
|
|
21
16
|
def __eq__(self, other) -> bool:
|
|
22
17
|
if not isinstance(other, RegisteredListener):
|
|
23
18
|
return False
|
|
@@ -25,8 +20,7 @@ class RegisteredListener:
|
|
|
25
20
|
return (
|
|
26
21
|
self.listener_id == other.listener_id
|
|
27
22
|
and self._coroutine == other.get_coro()
|
|
28
|
-
and self._entity_type == other.get_entity_type()
|
|
29
23
|
)
|
|
30
24
|
|
|
31
25
|
def __hash__(self):
|
|
32
|
-
return hash((self.listener_id, self._coroutine
|
|
26
|
+
return hash((self.listener_id, self._coroutine))
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ServerDetails:
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
ip: str,
|
|
8
|
+
port: Union[str, int, None],
|
|
9
|
+
player_id: int,
|
|
10
|
+
player_token: int,
|
|
11
|
+
secure: bool = False,
|
|
12
|
+
) -> None:
|
|
13
|
+
self.ip = str(ip)
|
|
14
|
+
self.port = str(port)
|
|
15
|
+
self.player_id = int(player_id)
|
|
16
|
+
self.player_token = int(player_token)
|
|
17
|
+
self.secure = secure
|
|
18
|
+
|
|
19
|
+
def get_server_string(self) -> str:
|
|
20
|
+
if self.port is None:
|
|
21
|
+
return f"{self.ip}"
|
|
22
|
+
return f"{self.ip}:{self.port}"
|
|
23
|
+
|
|
24
|
+
def __str__(self) -> str:
|
|
25
|
+
return f"{self.ip}:{self.port} {self.player_id} {self.player_token}"
|
|
26
|
+
|
|
27
|
+
def __hash__(self):
|
|
28
|
+
return hash(self.__str__())
|
|
29
|
+
|
|
30
|
+
def __eq__(self, o: object) -> bool:
|
|
31
|
+
if not isinstance(o, ServerDetails):
|
|
32
|
+
return False
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
self.ip == o.ip
|
|
36
|
+
and self.port == o.port
|
|
37
|
+
and self.player_id == o.player_id
|
|
38
|
+
and self.player_token == o.player_token
|
|
39
|
+
)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import time
|
|
2
2
|
from typing import Iterable, Union, List, Coroutine, Set, Callable
|
|
3
|
-
|
|
4
3
|
from PIL import Image
|
|
5
4
|
|
|
6
5
|
from .camera_parser import Parser
|
|
@@ -10,12 +9,17 @@ from ..rustplus_proto import (
|
|
|
10
9
|
AppEmpty,
|
|
11
10
|
AppRequest,
|
|
12
11
|
AppCameraInfo,
|
|
12
|
+
AppCameraRays,
|
|
13
|
+
AppCameraSubscribe,
|
|
13
14
|
)
|
|
14
|
-
from ...
|
|
15
|
+
from ...structs import Vector
|
|
15
16
|
from .structures import CameraInfo, Entity, LimitedQueue
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
class CameraManager:
|
|
20
|
+
|
|
21
|
+
ACTIVE_INSTANCE: Union["CameraManager", None] = None
|
|
22
|
+
|
|
19
23
|
def __init__(
|
|
20
24
|
self, rust_socket, cam_id: str, cam_info_message: AppCameraInfo
|
|
21
25
|
) -> None:
|
|
@@ -29,8 +33,9 @@ class CameraManager:
|
|
|
29
33
|
)
|
|
30
34
|
self.time_since_last_subscribe: float = time.time()
|
|
31
35
|
self.frame_callbacks: Set[Callable[[Image.Image], Coroutine]] = set()
|
|
36
|
+
CameraManager.ACTIVE_INSTANCE = self
|
|
32
37
|
|
|
33
|
-
async def add_packet(self, packet) -> None:
|
|
38
|
+
async def add_packet(self, packet: AppCameraRays) -> None:
|
|
34
39
|
self._last_packets.add(packet)
|
|
35
40
|
|
|
36
41
|
if len(self.frame_callbacks) == 0:
|
|
@@ -122,8 +127,7 @@ class CameraManager:
|
|
|
122
127
|
for movement in movements:
|
|
123
128
|
value = value | movement
|
|
124
129
|
|
|
125
|
-
await self.rust_socket.
|
|
126
|
-
app_request: AppRequest = self.rust_socket._generate_protobuf()
|
|
130
|
+
app_request: AppRequest = await self.rust_socket._generate_request(0.01)
|
|
127
131
|
cam_input = AppCameraInput()
|
|
128
132
|
|
|
129
133
|
cam_input.buttons = value
|
|
@@ -133,25 +137,29 @@ class CameraManager:
|
|
|
133
137
|
cam_input.mouse_delta = vector
|
|
134
138
|
app_request.camera_input = cam_input
|
|
135
139
|
|
|
136
|
-
await self.rust_socket.
|
|
137
|
-
await self.rust_socket.remote.add_ignored_response(app_request.seq)
|
|
140
|
+
await self.rust_socket.ws.send_message(app_request, True)
|
|
138
141
|
|
|
139
142
|
async def exit_camera(self) -> None:
|
|
140
|
-
await self.rust_socket.
|
|
141
|
-
app_request: AppRequest = self.rust_socket._generate_protobuf()
|
|
143
|
+
app_request: AppRequest = await self.rust_socket._generate_request()
|
|
142
144
|
app_request.camera_unsubscribe = AppEmpty()
|
|
143
145
|
|
|
144
|
-
await self.rust_socket.
|
|
145
|
-
await self.rust_socket.remote.add_ignored_response(app_request.seq)
|
|
146
|
+
await self.rust_socket.ws.send_message(app_request, True)
|
|
146
147
|
|
|
147
148
|
self._open = False
|
|
148
149
|
self._last_packets.clear()
|
|
149
150
|
|
|
150
151
|
async def resubscribe(self) -> None:
|
|
151
|
-
|
|
152
|
+
|
|
153
|
+
packet = await self.rust_socket._generate_request()
|
|
154
|
+
subscribe = AppCameraSubscribe()
|
|
155
|
+
subscribe.camera_id = self._cam_id
|
|
156
|
+
packet.camera_subscribe = subscribe
|
|
157
|
+
|
|
158
|
+
self.rust_socket.ws.send_message(packet, True)
|
|
159
|
+
|
|
152
160
|
self.time_since_last_subscribe = time.time()
|
|
153
161
|
self._open = True
|
|
154
|
-
self.
|
|
162
|
+
self.ACTIVE_INSTANCE = self
|
|
155
163
|
|
|
156
164
|
async def get_entities_in_frame(self) -> List[Entity]:
|
|
157
165
|
if self._last_packets is None:
|
|
@@ -318,9 +318,9 @@ class Parser:
|
|
|
318
318
|
entity_size = np.array([entity.size.x, entity.size.y, entity.size.z, 0])
|
|
319
319
|
|
|
320
320
|
vertices = (
|
|
321
|
-
MathUtils.get_player_vertices(entity.size)
|
|
321
|
+
MathUtils.get_player_vertices(Vector3(vector3=entity.size))
|
|
322
322
|
if entity.type == 2
|
|
323
|
-
else MathUtils.get_tree_vertices(entity.size)
|
|
323
|
+
else MathUtils.get_tree_vertices(Vector3(vector3=entity.size))
|
|
324
324
|
)
|
|
325
325
|
# Add the position for the name tag to the vertices
|
|
326
326
|
vertices = np.append(vertices, [np.array([0, 1.3, 0, 1])], axis=0)
|
|
@@ -367,7 +367,9 @@ class Parser:
|
|
|
367
367
|
colour = (
|
|
368
368
|
(PLAYER_COLOUR if not entity.name.isdigit() else SCIENTIST_COLOUR)
|
|
369
369
|
if entity.type == 2
|
|
370
|
-
else MathUtils.get_slightly_random_colour(
|
|
370
|
+
else MathUtils.get_slightly_random_colour(
|
|
371
|
+
TREE_COLOUR, Vector3(vector3=entity.position)
|
|
372
|
+
)
|
|
371
373
|
)
|
|
372
374
|
|
|
373
375
|
MathUtils.set_polygon_with_depth(
|
|
@@ -393,11 +395,12 @@ class Parser:
|
|
|
393
395
|
# The font size should be proportional to the size of the entity as it gets further away
|
|
394
396
|
with resources.path(FONT_PATH, "PermanentMarker.ttf") as path:
|
|
395
397
|
font = ImageFont.truetype(str(path), font_size)
|
|
396
|
-
|
|
398
|
+
width = image_draw.textlength(entity.name, font=font)
|
|
399
|
+
height = font_size
|
|
397
400
|
|
|
398
401
|
name_place1 = (
|
|
399
|
-
name_place[0] -
|
|
400
|
-
name_place[1] -
|
|
402
|
+
name_place[0] - width // 2,
|
|
403
|
+
name_place[1] - height // 2,
|
|
401
404
|
)
|
|
402
405
|
text.add((name_place1, entity.name, font))
|
|
403
406
|
|