dfpyre 0.4.3__tar.gz → 0.4.4__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.4.4/PKG-INFO ADDED
@@ -0,0 +1,478 @@
1
+ Metadata-Version: 2.1
2
+ Name: dfpyre
3
+ Version: 0.4.4
4
+ Summary: A package for external creation of code templates for the DiamondFire Minecraft server.
5
+ Home-page: https://github.com/Amp63/pyre
6
+ License: MIT
7
+ Keywords: diamondfire,minecraft
8
+ Author: Amp
9
+ Requires-Python: >=3.12,<4.0
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Requires-Dist: mcitemlib (>=0.1.0,<0.2.0)
14
+ Project-URL: Repository, https://github.com/Amp63/pyre
15
+ Description-Content-Type: text/markdown
16
+
17
+ # pyre
18
+
19
+ A package for external creation of code templates for the DiamondFire Minecraft server (mcdiamondfire.com).
20
+
21
+ PyPi Link: https://pypi.org/project/dfpyre/
22
+
23
+ ## Features
24
+ - All code block types
25
+ - All code item types
26
+ - Direct sending to DF via recode
27
+ - Automatic type conversion (int to num, str to text)
28
+ - Name checking ("did you mean ___?" for close matches)
29
+ - Default tag values
30
+
31
+ ## Documentation
32
+ ## Basics
33
+
34
+ - [Setting up a program](#setup)
35
+ - [Events and Actions](#eventsactions)
36
+ - [Building](#building)
37
+
38
+ ## Var Items
39
+
40
+ - [Text](#text)
41
+ - [Number](#number)
42
+ - [Variable](#variable)
43
+ - [Location](#location)
44
+ - [Item](#item)
45
+ - [Sound](#sound)
46
+ - [Particle](#particle)
47
+ - [Potion](#potion)
48
+ - [Game Value](#game-value)
49
+ - [Vector](#vector)
50
+
51
+ ## Conditionals and Loops
52
+
53
+ - [Conditionals and Brackets](#conditionalsbrackets)
54
+ - [Loops](#loops)
55
+
56
+ ## Functions and Procedures
57
+
58
+ - [Creating Functions and Procedures](#create-functionsprocedures)
59
+ - [Calling Functions and Procedures](#call-functionsprocedures)
60
+
61
+ ## Extras
62
+
63
+ - [Calling Functions with Parameters](#functions-with-parameters)
64
+ - [return_() method](#special-return)
65
+ - [Command List](#commands)
66
+
67
+ ___
68
+
69
+ ### Setup
70
+
71
+ To start creating in pyre, you have to create a DFTemplate object like so:
72
+
73
+ ```py
74
+ from dfpyre import *
75
+ t = DFTemplate()
76
+ ```
77
+
78
+ Basically everything stems from this template object.
79
+
80
+ This is the basic layout of a file:
81
+
82
+ ```py
83
+ from dfpyre import *
84
+ t = DFTemplate()
85
+ # [Event, Function, or Process]
86
+ # [Your code here]
87
+ t.build()
88
+ ```
89
+
90
+ The commented lines represent where you will insert calls to methods in the template object.
91
+
92
+ Here's a complete program that prints a message to every player when a player joins:
93
+
94
+ ```py
95
+ from dfpyre import *
96
+ t = DFTemplate()
97
+ t.playerEvent('Join')
98
+ t.playerAction('SendMessage', '%default has joined!', target='AllPlayers')
99
+ t.buildAndSend()
100
+ ```
101
+
102
+ ### Events/Actions
103
+
104
+ You can find a list of events and actions [here](#commands)
105
+
106
+ As shown in [setup](#setup), every code line must start with an event, function, or process. After that, you're free to put anything you want.
107
+
108
+ The following program sends a message to all players and gives a player 10 apples upon joining:
109
+
110
+ ```py
111
+ from dfpyre import *
112
+ t = DFTemplate()
113
+ t.playerEvent('Join')
114
+ t.playerAction('SendMessage', '%default has joined!', target='AllPlayers')
115
+ t.playerAction('GiveItems', item('apple', 10))
116
+ ```
117
+
118
+ ### Building
119
+
120
+ You basically have 2 different options for building your code line.
121
+ You can either:
122
+
123
+ 1. Save the compressed template code to a variable and send it to minecraft later
124
+ 2. Build and send directly to your minecraft client (recommended)
125
+
126
+ If you choose the first option, the code would look something like this:
127
+
128
+ ```py
129
+ from dfpyre import *
130
+ t = DFTemplate()
131
+ t.playerEvent('Join')
132
+ t.playerAction('SendMessage', '%default has joined!', target='AllPlayers')
133
+ templateCode, templateName = t.build() # NOTE: build() returns a tuple with code at index 0 and a formatted name at index 1.
134
+
135
+ sendToDf(code, name=templateName) # Send to minecraft client via recode item api
136
+ ```
137
+
138
+ If you choose the second option, you can do this:
139
+
140
+ ```py
141
+ from dfpyre import *
142
+ t = DFTemplate()
143
+ t.playerEvent('Join')
144
+ t.playerAction('SendMessage', '%default has joined!', target='AllPlayers')
145
+ t.buildAndSend() # builds and sends automatically to minecraft
146
+ ```
147
+
148
+ ### Variable Items
149
+
150
+ ### Text
151
+
152
+ Represents a diamondfire text item:
153
+
154
+ ```py
155
+ text('hello %default.')
156
+ ```
157
+
158
+ If a regular string is passed to a method as a chest parameter, it will automatically be converted to a text object:
159
+
160
+ ```py
161
+ # These do the same thing:
162
+ t.playerAction('SendMessage', text('%default joined.'))
163
+ t.playerAction('SendMessage', '%default joined.')
164
+ ```
165
+
166
+ ### Number
167
+
168
+ Represents a diamondfire number item:
169
+
170
+ ```py
171
+ num(5)
172
+ num(3.14)
173
+ ```
174
+
175
+ If a regular integer or float is passed to a method as a chest parameter, it will automatically be converted to a num object:
176
+
177
+ ```py
178
+ # These do the same thing:
179
+ t.setVariable('=', var('number'), num(10))
180
+ t.setVariable('=', var('number'), 10)
181
+ ```
182
+
183
+ ### Variable
184
+
185
+ Represents a diamondfire variable item:
186
+
187
+ ```py
188
+ var('num')
189
+ var('text1')
190
+ ```
191
+
192
+ You can set variable values by using the `setVariable` method:
193
+
194
+ ```py
195
+ t.setVariable('=', var('num'), 12) # sets 'num' to 12
196
+ t.setVariable('x', var('doubled'), var('num'), 2) # sets 'doubled' to 24
197
+ ```
198
+
199
+ You can set the scope of the variable by using the `scope` keyword:
200
+
201
+ ```py
202
+ t.setVariable('=', var(num1, scope='game'), 12) # both 'game' or 'unsaved' can be passed for the scope here
203
+ t.setVariable('=', var(num1, scope='saved'), 12)
204
+ t.setVariable('=', var(num1, scope='local'), 12)
205
+ ```
206
+
207
+ ### Location
208
+
209
+ Represents a diamondfire location item:
210
+
211
+ ```py
212
+ # (var= is not required if numbers are in order, but is more readable)
213
+ loc(x=25.5, y=50, z=25.5, pitch=0, yaw=-90)
214
+ ```
215
+
216
+ Example:
217
+
218
+ ```py
219
+ # teleport player on join
220
+ from dfpyre import *
221
+ t = DFTemplate()
222
+ t.playerEvent('Join')
223
+ t.playerAction('Teleport', loc(10, 50, 10))
224
+ ```
225
+
226
+ ### Item
227
+
228
+ Represents a minecraft item:
229
+
230
+ ```py
231
+ item('stick', count=5)
232
+ item('stone', 64)
233
+ ```
234
+
235
+ Extra nbt (enchants, lore, etc.) is not supported right now.
236
+
237
+ ### Sound
238
+
239
+ Represents a diamondfire sound item:
240
+
241
+ ```py
242
+ sound('Wood Break', pitch=1.5, vol=2.0)
243
+ ```
244
+
245
+ Example:
246
+
247
+ ```py
248
+ # plays 'Grass Place' sound on join
249
+ from dfpyre import *
250
+ t = DFTemplate()
251
+ t.playerEvent('Join')
252
+ t.playerAction('PlaySound', sound('Grass Place'))
253
+ ```
254
+
255
+ ### Particle
256
+
257
+ Represents a diamondfire particle item:
258
+
259
+ ```py
260
+ particle(name='Cloud', amount=10, horizontal=1.0, vertical=0.5, x=1.0, y=0.0, z=0.0, motionVariation=100)
261
+ ```
262
+
263
+ Example:
264
+
265
+ ```py
266
+ # plays a white cloud particle effect at 5, 50, 5
267
+ from dfpyre import *
268
+ t = DFTemplate()
269
+ t.playerEvent('Join')
270
+ t.playerAction('Particle', particle('Cloud'), loc(5, 50, 5))
271
+ ```
272
+
273
+ Currently, the particle object does not support colors.
274
+
275
+ ### Potion
276
+
277
+ Represents a diamondfire potion item:
278
+
279
+ ```py
280
+ # gives speed 1 for 1 minute
281
+ potion('Speed', dur=1200, amp=0)
282
+ ```
283
+
284
+ Example:
285
+
286
+ ```py
287
+ # gives the player infinite saturation 255
288
+ from dfpyre import *
289
+ t = DFTemplate()
290
+ t.playerEvent('Join')
291
+ t.playerAction('GivePotion', potion('Saturation', amp=254))
292
+ ```
293
+
294
+ ### Game Value
295
+
296
+ Represents a diamondfire game value item:
297
+
298
+ ```py
299
+ gamevalue('Player Count')
300
+ gamevalue('Location' target='Selection')
301
+ ```
302
+
303
+ Example:
304
+
305
+ ```py
306
+ # function that prints player count and cpu
307
+ from dfpyre import *
308
+ t = DFTemplate()
309
+ t.function('printData')
310
+ t.playerAction('SendMessage', gamevalue('Player Count'), gamevalue('CPU Usage'))
311
+ ```
312
+
313
+ ### Vector
314
+
315
+ Represents a diamondfire vector item:
316
+
317
+ ```py
318
+ vector(x=1.1, y=0.0, z=0.5)
319
+ ```
320
+
321
+ Example:
322
+
323
+ ```py
324
+ # sets the player's x velocity to 1.0 on join
325
+ from dfpyre import *
326
+ t = DFTemplate()
327
+ t.playerEvent('Join')
328
+ t.playerAction('SetVelocity', vector(x=1.0, y=0.0, z=0.0))
329
+ ```
330
+
331
+ ### Conditionals/Brackets
332
+
333
+ A list of conditionals and loops can be found [here](#commands).
334
+
335
+ A specific syntax must be followed when creating conditionals and loops. Each conditional statement must be followed by a `bracket()` method, which will contain code. Here's an example:
336
+
337
+ ```py
338
+ # prints 'clicked' when a player right clicks with a stick in their hand
339
+ from dfpyre import *
340
+ t = DFTemplate()
341
+ t.playerEvent('RightClick')
342
+ t.ifPlayer('IsHolding', item('stick'))
343
+ t.bracket(
344
+ t.playerAction('SendMessage', 'clicked')
345
+ )
346
+ ```
347
+
348
+ To create an `else` statement, use the `else_` method:
349
+
350
+ ```py
351
+ # says the player is 'on the ground' when grounded and 'in the air' otherwise.
352
+ from dfpyre import *
353
+ t = DFTemplate()
354
+ t.function('grounded')
355
+ t.ifPlayer('IsGrounded')
356
+ t.bracket(
357
+ t.playerAction('ActionBar', 'on the ground')
358
+ )
359
+ t.else_()
360
+ t.bracket(
361
+ t.playerAction('ActionBar', 'in the air')
362
+ )
363
+ t.build()
364
+ ```
365
+
366
+ ### Loops
367
+
368
+ As for loops, the bracket syntax is the same and will automatically change to "repeat-type" brackets:
369
+
370
+ ```py
371
+ # prints numbers 1-5
372
+ from dfpyre import *
373
+ t = DFTemplate()
374
+ t.playerEvent('Join')
375
+ t.repeat('Multiple', var('i'), 5)
376
+ t.bracket(
377
+ t.playerAction('SendMessage', var('i'))
378
+ )
379
+ ```
380
+
381
+ ### Creating Functions/Processes
382
+
383
+ To create a function or process, just start the template with a `function` or `process` method:
384
+
385
+ ```py
386
+ # function that gives a player 64 golden apples
387
+ from dfpyre import *
388
+ t = DFTemplate()
389
+ t.function('doStuff')
390
+ t.playerAction('GiveItems', item('golden_apple', 64))
391
+ ```
392
+
393
+ ### Calling Functions/Processes
394
+
395
+ Calling Functions and processes is also simple:
396
+
397
+ ```py
398
+ from dfpyre import *
399
+ t = DFTemplate()
400
+ t.playerEvent('Join')
401
+ t.callFunction('doStuff')
402
+ ```
403
+
404
+ Function parameters can also be inputted easier. Check [here](#functions-with-parameters) for more info.
405
+
406
+ ### Functions with Parameters
407
+
408
+ Lets say that we have this function that prints out double (numx2) of what was inputted (num):
409
+
410
+ ```py
411
+ # prints numbers 1-5
412
+ from dfpyre import *
413
+ t = DFTemplate()
414
+ t.function('double')
415
+ t.setVariable('x', var('numx2'), var('num'), 2)
416
+ t.playerAction('SendMessage', var('numx2'))
417
+ ```
418
+
419
+ To easily pass the required parameter `num`, we can use the `parameters` keyword like this:
420
+
421
+ ```py
422
+ # prints numbers 1-5
423
+ from dfpyre import *
424
+ t = DFTemplate()
425
+ t.playerEvent('Join')
426
+ t.callFunction('double', parameters={'num': 5})
427
+ ```
428
+
429
+ This basically just sets a local variable for each key in `parameters` before the function is called.
430
+
431
+ ### Special Return
432
+
433
+ Similar to [functions with parameters](#functions-with-parameters), `return_` is an extension of the `function` method.
434
+
435
+ When you want to return a given value from a function, you can use `return_` like this:
436
+
437
+ ```py
438
+ from dfpyre import *
439
+ t = DFTemplate()
440
+ t.function('return10')
441
+ t.return_(returndata={'retnum': 10})
442
+ t.buildAndSend()
443
+ ```
444
+
445
+ For each value in `returndata`, a local variable will be set for each entry.
446
+ After all of the variables are set, a `control('Return')` block is automatically added to the end of the line. This allows you to access these local variables after the function returns.
447
+
448
+ ### Method List
449
+
450
+ - Events / Function / Process
451
+ - playerEvent
452
+ - entityEvent
453
+ - function
454
+ - process
455
+ - callFunction
456
+ - startProcess
457
+
458
+ - Actions
459
+ - playerAction
460
+ - gameAction
461
+ - entityAction
462
+
463
+ - Conditionals / Loops
464
+ - ifPlayer
465
+ - ifVariable
466
+ - ifGame
467
+ - ifEntity
468
+ - else_ (dont forget underscore)
469
+ - repeat
470
+ - bracket (more info above)
471
+
472
+ - Other
473
+ - control
474
+ - selectObject
475
+ - setVariable
476
+
477
+ - Extras
478
+ - return_
@@ -2,10 +2,14 @@
2
2
  Contains class definitions for code items.
3
3
  """
4
4
 
5
+ from typing import Literal
5
6
  from dfpyre.style import isAmpersandCoded, ampersandToMinimessage
6
7
 
7
8
 
8
9
  class item:
10
+ """
11
+ Represents a Minecraft item.
12
+ """
9
13
  def __init__(self, itemID: str, count: int=1):
10
14
  self.id = itemID
11
15
  self.count = count
@@ -24,6 +28,9 @@ class item:
24
28
 
25
29
 
26
30
  class string:
31
+ """
32
+ Represents a DiamondFire string object. (`txt`)
33
+ """
27
34
  def __init__(self, value: str):
28
35
  self.value = value
29
36
  self.type = 'txt'
@@ -41,6 +48,9 @@ class string:
41
48
 
42
49
 
43
50
  class text:
51
+ """
52
+ Represents a DiamondFire styled text object (`comp`)
53
+ """
44
54
  def __init__(self, value: str):
45
55
  if isAmpersandCoded(value):
46
56
  value = ampersandToMinimessage(value)
@@ -60,6 +70,9 @@ class text:
60
70
 
61
71
 
62
72
  class num:
73
+ """
74
+ Represents a DiamondFire number object.
75
+ """
63
76
  def __init__(self, num: int|float):
64
77
  self.value = num
65
78
  self.type = 'num'
@@ -77,6 +90,9 @@ class num:
77
90
 
78
91
 
79
92
  class loc:
93
+ """
94
+ Represents a DiamondFire location object.
95
+ """
80
96
  def __init__(self, x: float=0, y: float=0, z: float=0, pitch: float=0, yaw: float=0):
81
97
  self.x = float(x)
82
98
  self.y = float(y)
@@ -105,7 +121,10 @@ class loc:
105
121
 
106
122
 
107
123
  class var:
108
- def __init__(self, name: str, scope: str='unsaved'):
124
+ """
125
+ Represents a DiamondFire variable object.
126
+ """
127
+ def __init__(self, name: str, scope: Literal['unsaved', 'saved', 'local', 'line']='unsaved'):
109
128
  if scope == 'game':
110
129
  scope = 'unsaved'
111
130
 
@@ -127,6 +146,9 @@ class var:
127
146
 
128
147
 
129
148
  class sound:
149
+ """
150
+ Represents a DiamondFire sound object.
151
+ """
130
152
  def __init__(self, name: str, pitch: float=1.0, vol: float=2.0):
131
153
  self.name = name
132
154
  self.pitch = pitch
@@ -148,6 +170,9 @@ class sound:
148
170
 
149
171
 
150
172
  class particle:
173
+ """
174
+ Represents a DiamondFire particle object.
175
+ """
151
176
  def __init__(self, name: str='Cloud', amount: int=1, horizontal: float=0.0, vertical: float=0.0,
152
177
  x: float=1.0, y: float=0.0, z: float=0.0, motionVariation: float=100):
153
178
  self.name = name
@@ -184,6 +209,9 @@ class particle:
184
209
 
185
210
 
186
211
  class potion:
212
+ """
213
+ Represents a DiamondFire potion object.
214
+ """
187
215
  def __init__(self, name: str, dur: int=1000000, amp: int=0):
188
216
  self.name = name
189
217
  self.dur = dur
@@ -205,6 +233,9 @@ class potion:
205
233
 
206
234
 
207
235
  class gamevalue:
236
+ """
237
+ Represents a DiamondFire game value object.
238
+ """
208
239
  def __init__(self, name: str, target: str='Default'):
209
240
  self.name = name
210
241
  self.target = target
@@ -224,6 +255,9 @@ class gamevalue:
224
255
 
225
256
 
226
257
  class vector:
258
+ """
259
+ Represents a DiamondFire vector object.
260
+ """
227
261
  def __init__(self, x: float=0.0, y: float=0.0, z: float=0.0):
228
262
  self.x = float(x)
229
263
  self.y = float(y)
@@ -1,4 +1,5 @@
1
- from mcitemlib.style import *
1
+ import re
2
+ from mcitemlib.style import STYLE_CODE_REGEX, FORMAT_CODES, StyledString
2
3
 
3
4
  def isAmpersandCoded(s: str) -> bool:
4
5
  return bool(re.match(STYLE_CODE_REGEX, s))
@@ -0,0 +1,19 @@
1
+ [tool.poetry]
2
+ name = "dfpyre"
3
+ version = "0.4.4"
4
+ description = "A package for external creation of code templates for the DiamondFire Minecraft server."
5
+ authors = ["Amp"]
6
+ readme = "README.md"
7
+ license = "MIT"
8
+ repository = "https://github.com/Amp63/pyre"
9
+ keywords = ["diamondfire", "minecraft"]
10
+
11
+
12
+ [tool.poetry.dependencies]
13
+ python = "^3.12"
14
+ mcitemlib = "^0.1.0"
15
+
16
+
17
+ [build-system]
18
+ requires = ["poetry-core"]
19
+ build-backend = "poetry.core.masonry.api"
dfpyre-0.4.3/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Amp
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
dfpyre-0.4.3/PKG-INFO DELETED
@@ -1,10 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: dfpyre
3
- Version: 0.4.3
4
- Summary: A package for externally creating code templates for the DiamondFire Minecraft server.
5
- Home-page: https://github.com/Amp63/pyre
6
- Author: Amp
7
- License: MIT
8
- Keywords: diamondfire,minecraft
9
- License-File: LICENSE
10
- Requires-Dist: mcitemlib
@@ -1,10 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: dfpyre
3
- Version: 0.4.3
4
- Summary: A package for externally creating code templates for the DiamondFire Minecraft server.
5
- Home-page: https://github.com/Amp63/pyre
6
- Author: Amp
7
- License: MIT
8
- Keywords: diamondfire,minecraft
9
- License-File: LICENSE
10
- Requires-Dist: mcitemlib
@@ -1,13 +0,0 @@
1
- LICENSE
2
- README.md
3
- setup.py
4
- dfpyre/__init__.py
5
- dfpyre/items.py
6
- dfpyre/pyre.py
7
- dfpyre/style.py
8
- dfpyre.egg-info/PKG-INFO
9
- dfpyre.egg-info/SOURCES.txt
10
- dfpyre.egg-info/dependency_links.txt
11
- dfpyre.egg-info/requires.txt
12
- dfpyre.egg-info/top_level.txt
13
- dfpyre/data/data.json
@@ -1 +0,0 @@
1
- mcitemlib
@@ -1 +0,0 @@
1
- dfpyre
dfpyre-0.4.3/setup.cfg DELETED
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
dfpyre-0.4.3/setup.py DELETED
@@ -1,18 +0,0 @@
1
- from setuptools import setup, find_packages
2
-
3
- VERSION = '0.4.3'
4
-
5
- setup(
6
- name='dfpyre',
7
- version=VERSION,
8
- description='A package for externally creating code templates for the DiamondFire Minecraft server.',
9
- author='Amp',
10
- url='https://github.com/Amp63/pyre',
11
- license='MIT',
12
- keywords=['diamondfire', 'minecraft'],
13
- packages=find_packages(),
14
- package_data={'dfpyre': ['data/data.json']},
15
- install_requires=[
16
- 'mcitemlib'
17
- ]
18
- )
File without changes
File without changes
File without changes
File without changes