dfpyre 0.8.3__tar.gz → 0.8.5__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.
Potentially problematic release.
This version of dfpyre might be problematic. Click here for more details.
- {dfpyre-0.8.3 → dfpyre-0.8.5}/PKG-INFO +2 -2
- {dfpyre-0.8.3 → dfpyre-0.8.5}/README.md +1 -1
- {dfpyre-0.8.3 → dfpyre-0.8.5}/dfpyre/items.py +69 -19
- {dfpyre-0.8.3 → dfpyre-0.8.5}/pyproject.toml +1 -1
- {dfpyre-0.8.3 → dfpyre-0.8.5}/LICENSE +0 -0
- {dfpyre-0.8.3 → dfpyre-0.8.5}/dfpyre/__init__.py +0 -0
- {dfpyre-0.8.3 → dfpyre-0.8.5}/dfpyre/action_literals.py +0 -0
- {dfpyre-0.8.3 → dfpyre-0.8.5}/dfpyre/actiondump.py +0 -0
- {dfpyre-0.8.3 → dfpyre-0.8.5}/dfpyre/data/actiondump_min.json +0 -0
- {dfpyre-0.8.3 → dfpyre-0.8.5}/dfpyre/pyre.py +0 -0
- {dfpyre-0.8.3 → dfpyre-0.8.5}/dfpyre/scriptgen.py +0 -0
- {dfpyre-0.8.3 → dfpyre-0.8.5}/dfpyre/style.py +0 -0
- {dfpyre-0.8.3 → dfpyre-0.8.5}/dfpyre/util.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dfpyre
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.5
|
|
4
4
|
Summary: A package for creating and modifying code templates for the DiamondFire Minecraft server.
|
|
5
5
|
Home-page: https://github.com/Amp63/pyre
|
|
6
6
|
License: MIT
|
|
@@ -38,7 +38,7 @@ This module works best with [CodeClient](https://modrinth.com/mod/codeclient) in
|
|
|
38
38
|
- All code block types
|
|
39
39
|
- All code item types
|
|
40
40
|
- Direct sending to DF via recode or codeclient
|
|
41
|
-
- Automatic type conversion (int to
|
|
41
|
+
- Automatic type conversion (`int` to `Number`, `str` to `String`)
|
|
42
42
|
- Auto completed action names (if your IDE supports type hints)
|
|
43
43
|
- Warnings for unrecognized actions and tags
|
|
44
44
|
- Shorthand format for variables
|
|
@@ -20,7 +20,7 @@ This module works best with [CodeClient](https://modrinth.com/mod/codeclient) in
|
|
|
20
20
|
- All code block types
|
|
21
21
|
- All code item types
|
|
22
22
|
- Direct sending to DF via recode or codeclient
|
|
23
|
-
- Automatic type conversion (int to
|
|
23
|
+
- Automatic type conversion (`int` to `Number`, `str` to `String`)
|
|
24
24
|
- Auto completed action names (if your IDE supports type hints)
|
|
25
25
|
- Warnings for unrecognized actions and tags
|
|
26
26
|
- Shorthand format for variables
|
|
@@ -7,7 +7,7 @@ import re
|
|
|
7
7
|
from typing import Literal, Any
|
|
8
8
|
from dfpyre.style import is_ampersand_coded, ampersand_to_minimessage
|
|
9
9
|
from dfpyre.util import PyreException, warn
|
|
10
|
-
from mcitemlib.itemlib import Item as NbtItem
|
|
10
|
+
from mcitemlib.itemlib import Item as NbtItem, MCItemlibException
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
NUMBER_REGEX = r'^-?\d*\.?\d+$'
|
|
@@ -23,7 +23,7 @@ def convert_argument(arg: Any):
|
|
|
23
23
|
if shorthand_match:
|
|
24
24
|
scope = VAR_SCOPES[shorthand_match.group(1)]
|
|
25
25
|
return Variable(shorthand_match.group(2), scope)
|
|
26
|
-
return
|
|
26
|
+
return String(arg)
|
|
27
27
|
return arg
|
|
28
28
|
|
|
29
29
|
|
|
@@ -32,21 +32,6 @@ def _add_slot(d: dict, slot: int|None):
|
|
|
32
32
|
d['slot'] = slot
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
class Item(NbtItem):
|
|
36
|
-
"""
|
|
37
|
-
Represents a Minecraft item.
|
|
38
|
-
"""
|
|
39
|
-
type = 'item'
|
|
40
|
-
|
|
41
|
-
def format(self, slot: int|None):
|
|
42
|
-
formatted_dict = {"item": {"id": self.type, "data": {"item": self.get_nbt()}}}
|
|
43
|
-
_add_slot(formatted_dict, slot)
|
|
44
|
-
return formatted_dict
|
|
45
|
-
|
|
46
|
-
def __repr__(self) -> str:
|
|
47
|
-
return f'{self.__class__.__name__}({self.get_id()}, {self.get_count()})'
|
|
48
|
-
|
|
49
|
-
|
|
50
35
|
class String:
|
|
51
36
|
"""
|
|
52
37
|
Represents a DiamondFire string object. (`txt`)
|
|
@@ -107,6 +92,71 @@ class Number:
|
|
|
107
92
|
Num = Number # Number alias
|
|
108
93
|
|
|
109
94
|
|
|
95
|
+
class Item(NbtItem):
|
|
96
|
+
"""
|
|
97
|
+
Represents a Minecraft item.
|
|
98
|
+
"""
|
|
99
|
+
type = 'item'
|
|
100
|
+
|
|
101
|
+
def format(self, slot: int|None):
|
|
102
|
+
formatted_dict = {"item": {"id": self.type, "data": {"item": self.get_nbt()}}}
|
|
103
|
+
_add_slot(formatted_dict, slot)
|
|
104
|
+
return formatted_dict
|
|
105
|
+
|
|
106
|
+
def __repr__(self) -> str:
|
|
107
|
+
return f'{self.__class__.__name__}({self.get_id()}, {self.get_count()})'
|
|
108
|
+
|
|
109
|
+
def set_tag(self, tag_name: str, tag_value: str|int|float|String|Number):
|
|
110
|
+
"""
|
|
111
|
+
Add a DiamondFire custom tag to this item.
|
|
112
|
+
"""
|
|
113
|
+
if isinstance(tag_value, String):
|
|
114
|
+
tag_value = tag_value.value
|
|
115
|
+
elif isinstance(tag_value, Number):
|
|
116
|
+
tag_value = float(tag_value.value)
|
|
117
|
+
elif isinstance(tag_value, int):
|
|
118
|
+
tag_value = float(tag_value)
|
|
119
|
+
|
|
120
|
+
try:
|
|
121
|
+
item_tags = self.get_custom_data('PublicBukkitValues')
|
|
122
|
+
except MCItemlibException:
|
|
123
|
+
item_tags = {}
|
|
124
|
+
|
|
125
|
+
item_tags[f'hypercube:{tag_name}'] = tag_value
|
|
126
|
+
self.set_custom_data('PublicBukkitValues', item_tags)
|
|
127
|
+
|
|
128
|
+
def get_tag(self, tag_name: str) -> str|float|None:
|
|
129
|
+
"""
|
|
130
|
+
Get a DiamondFire custom tag from this item.
|
|
131
|
+
"""
|
|
132
|
+
try:
|
|
133
|
+
item_tags = self.get_custom_data('PublicBukkitValues')
|
|
134
|
+
except MCItemlibException:
|
|
135
|
+
return None
|
|
136
|
+
|
|
137
|
+
try:
|
|
138
|
+
return item_tags[f'hypercube:{tag_name}']
|
|
139
|
+
except KeyError:
|
|
140
|
+
return None
|
|
141
|
+
|
|
142
|
+
def remove_tag(self, tag_name: str) -> bool:
|
|
143
|
+
"""
|
|
144
|
+
Remove a DiamondFire custom tag from this item.
|
|
145
|
+
|
|
146
|
+
:return: `True` on success, `False` on fail
|
|
147
|
+
"""
|
|
148
|
+
try:
|
|
149
|
+
item_tags = self.get_custom_data('PublicBukkitValues')
|
|
150
|
+
except MCItemlibException:
|
|
151
|
+
return False
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
del item_tags[f'hypercube:{tag_name}']
|
|
155
|
+
return True
|
|
156
|
+
except KeyError:
|
|
157
|
+
return False
|
|
158
|
+
|
|
159
|
+
|
|
110
160
|
class Location:
|
|
111
161
|
"""
|
|
112
162
|
Represents a DiamondFire location object.
|
|
@@ -335,7 +385,7 @@ class Parameter:
|
|
|
335
385
|
return f'{self.__class__.__name__}({self.name}, type: {raw_type})'
|
|
336
386
|
|
|
337
387
|
|
|
338
|
-
def item_from_dict(item_dict: dict) ->
|
|
388
|
+
def item_from_dict(item_dict: dict) -> Any:
|
|
339
389
|
item_id = item_dict['id']
|
|
340
390
|
item_data = item_dict['data']
|
|
341
391
|
|
|
@@ -393,4 +443,4 @@ def item_from_dict(item_dict: dict) -> object:
|
|
|
393
443
|
return
|
|
394
444
|
|
|
395
445
|
else:
|
|
396
|
-
raise PyreException(f'Unrecognized item id `{item_id}`')
|
|
446
|
+
raise PyreException(f'Unrecognized item id `{item_id}`')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|