mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 03:06:55 +00:00
Compare commits
232 Commits
Author | SHA1 | Date | |
---|---|---|---|
763ef7f937 | |||
e51a2725de | |||
a0111d04ee | |||
958473b333 | |||
744f5a8384 | |||
fe348b0a9d | |||
8d842732e0 | |||
bee342691d | |||
36623d8a5b | |||
7eb9530346 | |||
bd85d53a0b | |||
ac37af3a46 | |||
208884422d | |||
da23568546 | |||
f0f6d85809 | |||
92bd1a755d | |||
3ee43c5a17 | |||
8ced6547f2 | |||
d29e96407e | |||
8214e50bcc | |||
802bc21c53 | |||
25b51b4dfd | |||
794ff643a7 | |||
37ae760417 | |||
ab4d6b1e36 | |||
383df298a6 | |||
7314aaf7f7 | |||
75fa2f1132 | |||
d5881dbe83 | |||
8404ce88bd | |||
7861822a0f | |||
e6485c4734 | |||
bd5bbbea10 | |||
0ac04b52ff | |||
2d37d361a7 | |||
d696049a0a | |||
1d876e30c8 | |||
ea7313779e | |||
5a8008367f | |||
911529a6cc | |||
bee6c546dc | |||
e3c900e071 | |||
e50311f1ea | |||
0bdb8a46f7 | |||
074583d104 | |||
3b7377370c | |||
1ac74fe5bc | |||
c494af618c | |||
557257baed | |||
75cc99a003 | |||
7dc839fbe8 | |||
d3fb8c46f5 | |||
fffa5488fd | |||
e60364d7c9 | |||
cf222324d6 | |||
d3c62988b0 | |||
b34d438ed9 | |||
f50c63a0c2 | |||
d1f59632c2 | |||
03003ffa50 | |||
7a1cdf88e8 | |||
4856dbd1c6 | |||
16d07e1f3d | |||
daed82612c | |||
16d72c7f86 | |||
ce5fa0e836 | |||
dc07fc42b4 | |||
fdf3c0c1c7 | |||
656ec60805 | |||
293af3d55d | |||
0ce25f8b29 | |||
06f8390b30 | |||
55ad6c6b95 | |||
46af92f781 | |||
2765e87677 | |||
5df916099d | |||
137972098f | |||
3d2f9f0e74 | |||
9d16f145dd | |||
ae1501884b | |||
5234327b3f | |||
689a052bda | |||
813bb98850 | |||
d9e6676176 | |||
bfc77a772a | |||
6bcb3aeb26 | |||
0f8a6481c6 | |||
db3e801478 | |||
0f261b7baa | |||
6c1dd81130 | |||
eed8c37eab | |||
6e0cebbe38 | |||
902dd4258b | |||
ce72f634b0 | |||
2dfca14714 | |||
2ffbb452bb | |||
468b3e8d44 | |||
035084a5ac | |||
869721a8ee | |||
787f6594b2 | |||
867ec6b509 | |||
b6e1a21566 | |||
694c9b151f | |||
ed69303b4a | |||
192fba9c88 | |||
018897062c | |||
b198f287db | |||
750462aa75 | |||
b1df4728d3 | |||
5eb2459355 | |||
1120dff492 | |||
bd1b18d9af | |||
01d465b038 | |||
d6fcc59a49 | |||
a45e232829 | |||
9497dff3ee | |||
df88e9272e | |||
ec328a8160 | |||
7cd7a7fbf6 | |||
9a12aa689e | |||
39ffc28f2a | |||
9242f89221 | |||
e35ed7f04a | |||
08f11412a4 | |||
2bb50792c3 | |||
85c50731f8 | |||
ff40c0a070 | |||
8f9574dec5 | |||
86ed0f1397 | |||
affed33066 | |||
9cde63a327 | |||
401de97719 | |||
dd0c5efb56 | |||
bb9ab525b6 | |||
8053066ac0 | |||
88d14e9923 | |||
702ab53e69 | |||
0163555d3e | |||
1c41667b9b | |||
c2299b521f | |||
3692ddab1d | |||
3ddfb97921 | |||
e7e476b65e | |||
f3f853056a | |||
bcc641a25a | |||
ebcc16d283 | |||
4bc2275fc3 | |||
ef7a843fa3 | |||
10698c892e | |||
43842691fe | |||
8637a04e2b | |||
d53810c6bc | |||
f3e35bb94a | |||
707847b46e | |||
e81c738010 | |||
8f3b95164a | |||
19601f998a | |||
2fba1073dd | |||
6b06e407c6 | |||
0b270342b1 | |||
23e4ca64e4 | |||
36207debe0 | |||
de28ddabdb | |||
c328d7359c | |||
5e72850a62 | |||
a9cbe4f63e | |||
beabc5a85c | |||
2a07638af3 | |||
d6fd9259cf | |||
16c09e3610 | |||
b78dd70f72 | |||
92784054cd | |||
98ea674d20 | |||
4b869c8615 | |||
ec79477b3e | |||
58ff381557 | |||
2b6d058760 | |||
535e1a0eb4 | |||
4133f98b23 | |||
d7a78ee00f | |||
e913b16804 | |||
6fc435da0e | |||
84e15b6b1a | |||
e9f2bf0085 | |||
5f26c21b9f | |||
ee4854d07c | |||
9a379734ba | |||
a7366324e5 | |||
39f731aa06 | |||
7c41aa66f1 | |||
98d129f1f4 | |||
99622c5ce7 | |||
ad64a074cb | |||
23f3097390 | |||
abf004de7d | |||
ff4b7612a6 | |||
2d95bdc10f | |||
50c5c1de92 | |||
e2e31d345d | |||
7145e16bce | |||
5485b63e6e | |||
f2f70480ee | |||
900c4adb66 | |||
5f8dc5829c | |||
e962f7fb0a | |||
a3e3a5f631 | |||
b156480550 | |||
7b8548b2b1 | |||
fbe17344fb | |||
e143fb80da | |||
795d6c8ddf | |||
6bd028f8b3 | |||
35c33ba980 | |||
895790f46c | |||
378c3d7994 | |||
9808f874c8 | |||
4198c445b0 | |||
42e8120961 | |||
2a4f85107d | |||
97f6b80969 | |||
a6f8379c40 | |||
bf4b96e144 | |||
4f26e5598c | |||
e00176b677 | |||
f32d588b9b | |||
f14a8e46be | |||
5851e7fe55 | |||
8e9a078ff9 | |||
b16f7e4dd5 | |||
15b9578245 | |||
765bd5ced7 | |||
df4c3ec4a6 |
6
.editorconfig
Normal file
6
.editorconfig
Normal file
@ -0,0 +1,6 @@
|
||||
# http://editorconfig.org/
|
||||
root = yes
|
||||
|
||||
[*]
|
||||
indent_size = 4
|
||||
indent_style = tab
|
11
.github/ISSUE_TEMPLATE.md
vendored
11
.github/ISSUE_TEMPLATE.md
vendored
@ -1,5 +1,5 @@
|
||||
### Issue description
|
||||
<!--- use our forum https://forums.pocketmine.net for questions -->
|
||||
<!--- use our forum https://forums.pmmp.io for questions -->
|
||||
Write a short description about the issue
|
||||
|
||||
### Steps to reproduce the issue
|
||||
@ -8,10 +8,15 @@ Write a short description about the issue
|
||||
2. ...
|
||||
|
||||
### OS and versions
|
||||
<!--- use the 'version' command in PocketMine-MP -->
|
||||
<!--- use the 'version' command in PocketMine-MP
|
||||
NOTE: LATEST is not a valid version.
|
||||
PocketMine version should include Jenkins build number and/or git commit hash.
|
||||
ALSO NOTE: NO support whatsoever will be provided for forks or spoons of PocketMine. Issues relating to non-official distributions will be closed as spam. Please send such issues to whoever is responsible for the fork or spoon you are using.
|
||||
-->
|
||||
* PocketMine-MP:
|
||||
* PHP:
|
||||
* OS:
|
||||
* Server OS:
|
||||
* Game version: PE/Win10 (delete as appropriate)
|
||||
|
||||
### Crashdump, backtrace or other files
|
||||
<!--- please use gist or anything else and add links here -->
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,6 +8,7 @@ timings/*
|
||||
*.phar
|
||||
server.properties
|
||||
/pocketmine.yml
|
||||
memoryDump_*/*
|
||||
|
||||
# Common IDEs
|
||||
.idea/*
|
||||
|
16
.gitmodules
vendored
16
.gitmodules
vendored
@ -1,17 +1,13 @@
|
||||
[submodule "src/pocketmine/gui"]
|
||||
path = src/pocketmine/gui
|
||||
url = https://github.com/PocketMine/PocketMine-MP-GUI.git
|
||||
branch = master
|
||||
[submodule "src/raklib"]
|
||||
path = src/raklib
|
||||
url = https://github.com/PocketMine/RakLib.git
|
||||
url = https://github.com/pmmp/RakLib.git
|
||||
branch = master
|
||||
[submodule "src/spl"]
|
||||
path = src/spl
|
||||
url = https://github.com/PocketMine/PocketMine-SPL.git
|
||||
[submodule "tests/TesterPlugin"]
|
||||
path = tests/TesterPlugin
|
||||
url = https://github.com/PocketMine/TesterPlugin.git
|
||||
url = https://github.com/pmmp/PocketMine-SPL.git
|
||||
[submodule "src/pocketmine/lang/locale"]
|
||||
path = src/pocketmine/lang/locale
|
||||
url = https://github.com/PocketMine/PocketMine-Language.git
|
||||
url = https://github.com/pmmp/PocketMine-Language.git
|
||||
[submodule "tests/preprocessor"]
|
||||
path = tests/preprocessor
|
||||
url = https://github.com/pmmp/preprocessor.git
|
||||
|
5
.mailmap
5
.mailmap
@ -1,5 +0,0 @@
|
||||
Shoghi Cervantes <shoghicp@gmail.com>
|
||||
Shoghi Cervantes <shoghicp@gmail.com> Shoghi Cervantes <shoghicp@pocketmine.net>
|
||||
Brandon V <brandon15811@gmail.com>
|
||||
Michael Yoo <sekjun9878@gmail.com> Michael Yoo <michael@yoo.id.au>
|
||||
Michael Yoo <sekjun9878@gmail.com> Michael Yoo <sekjun9878@sekjun9878.info>
|
@ -3,18 +3,15 @@ language: php
|
||||
php:
|
||||
- 7.0
|
||||
|
||||
branches:
|
||||
- master
|
||||
|
||||
before_script:
|
||||
- mkdir plugins
|
||||
- wget -O plugins/DevTools.phar https://github.com/PocketMine/DevTools/releases/download/v1.11.0/DevTools_v1.11.0.phar
|
||||
- pecl install channel://pecl.php.net/pthreads-3.1.6
|
||||
- pecl install channel://pecl.php.net/weakref-0.3.2
|
||||
- echo | pecl install channel://pecl.php.net/yaml-2.0.0RC7
|
||||
- echo | pecl install channel://pecl.php.net/yaml-2.0.0
|
||||
|
||||
script:
|
||||
- php tests/TravisTest.php
|
||||
- ./tests/lint.sh && ./tests/run.sh
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
109
CONTRIBUTING.md
109
CONTRIBUTING.md
@ -5,34 +5,39 @@
|
||||
You must follow these guidelines if you wish to contribute to the PocketMine-MP code base, or participate in issue tracking.
|
||||
|
||||
## I have a question
|
||||
* For questions, please refer to the _#pocketmine_ or _#mcpedevs_ IRC channel on Freenode. There is a [WebIRC](http://webchat.freenode.net?channels=pocketmine,mcpedevs&uio=d4) if you want.
|
||||
* For questions, please refer to the _#pmmp_ or _#pocketmine_ IRC channel on Freenode. There is a [WebIRC](http://webchat.freenode.net?channels=pmmp,pocketmine&uio=d4) if you do not want to install an IRC client.
|
||||
* You can ask directly to _[@PocketMine](https://twitter.com/PocketMine)_ in Twitter, but don't expect an immediate reply.
|
||||
* You may use our [Forum](http://forums.pocketmine.net) to ask questions.
|
||||
* You may use our [Forum](https://forums.pmmp.io) to ask questions.
|
||||
* We do not accept questions or support requests in our issue tracker.
|
||||
|
||||
## Creating an Issue
|
||||
- First, use the [Issue Search](https://github.com/PocketMine/PocketMine-MP/search?ref=cmdform&type=Issues) to check if anyone has reported it.
|
||||
- If your issue is related to a plugin, you must contact their original author instead of reporting it here.
|
||||
- If your issue is related to a PocketMine official plugin, or our Android application, you must create an issue on that specific repository.
|
||||
- **Support requests are not bugs.** Issues such as "How do I do this" are not bugs and are closed as soon as a collaborator spots it. They are referred to our Forum to seek assistance.
|
||||
- **No generic titles** such as "Question", "Help", "Crash Report" etc. If an issue has a generic title they will either be closed on the spot, or a collaborator will edit it to describe the actual symptom.
|
||||
- Information must be provided in the issue body, not in the title. No tags are allowed in the title, and do not change the title if the issue has been solved.
|
||||
- Similarly, no generic issue reports. It is the issue submitter's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**. If you do not provide us with a summary or instructions on how to reproduce the issue, it is a support request until the actual bug has been found and therefore the issue is closed.
|
||||
- To express appreciation, objection, confusion or other supported reactions on pull requests, issues or comments on them, use GitHub [reactions](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) rather than posting an individual comment with an emoji only. This helps keeping the issue/pull rqeuest conversation clean and readable.
|
||||
* First, use the [Issue Search](https://github.com/pmmp/PocketMine-MP/search?ref=cmdform&type=Issues) to check if anyone has reported it. Check also closed issues, as an issue you think is valid may actually be invalid.
|
||||
* If an issue has been _fixed_ and closed, create another issue.
|
||||
* If your issue is related to a plugin, do **not** report here. Contact the plugin's original author instead.
|
||||
* **Support requests are not bugs.** Issues such as "How do I do this" are not bugs and are closed as soon as a collaborator spots it. They are referred to our Forum to seek assistance. Please refer to the section [I have a quesetion](#i-have-a-question) instead.
|
||||
* **No generic titles** such as "Question", "Help", "Crash Report" etc.
|
||||
* If you just got a crash report but you don't understand it, please look for a line starting with `Message`. It summarizes the bug.
|
||||
* Information must be provided in the issue body, not in the title. No tags like `[BUG]` are allowed in the title, including `[SOLVED]` for solved issues.
|
||||
* Similarly, no generic issue reports. For bugs, it is the issue author's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**. If you do not provide us with a summary or instructions on how to reproduce the issue, it is a support request until the actual bug has been found and therefore the issue is closed.
|
||||
* In simple words, if your issue does not appear to be a bug or a feature request, or if the issue cannot be properly confirmed to be valid, the issue will be closed until further information is provided.
|
||||
* To express appreciation, objection, confusion or other supported reactions on pull requests, issues or comments on them, use GitHub [reactions](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) rather than posting an individual comment with an emoji only. This helps keeping the issue/pull rqeuest conversation clean and readable.
|
||||
* If your issue is related to the Pocketmine-MP website, forums, etc., please [talk to a human directly](#i-have-a-question).
|
||||
|
||||
## Contributing Code
|
||||
* Use the [Pull Request](https://github.com/PocketMine/PocketMine-MP/pull/new) system, your request will be checked and discussed.
|
||||
* __Create a single branch for that pull request__
|
||||
* Code using the syntax as in PocketMine-MP. See below for an example.
|
||||
* Use the [Pull Request](https://github.com/pmmp/PocketMine-MP/pull/new) system, your request will be checked and discussed.
|
||||
* Create each pull request on a new branch. Do not create a pull request on commits that exist in another pull request.
|
||||
* Code should use the same syntax as in PocketMine-MP. See below for an example.
|
||||
* The code must be clear and written in English, comments included.
|
||||
* Use descriptive commit titles
|
||||
* __No merge commits are allowed, or multiple features per pull request__
|
||||
* **Keep each pull request only contain one feature**. The only exception is when all features in the pull request are related to each other, and share the same core changes.
|
||||
* **Do not create pull requests that only bump the MCPE version**. If it is ready to be updated, the team will update the values directly. Do not change the MCPE version or protocol version in a pull request, unless you have updated the protocol (all packets) entirely.
|
||||
|
||||
**Thanks for contributing to PocketMine-MP!**
|
||||
|
||||
### Code Syntax
|
||||
|
||||
It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) with a few exceptions.
|
||||
|
||||
* Opening braces MUST go on the same line, and MUST NOT have spaces before.
|
||||
* `else if` MUST be written as `elseif`. _(It is in PSR-2, but using a SHOULD)_
|
||||
* Control structure keywords or opening braces MUST NOT have one space before or after them.
|
||||
@ -53,12 +58,17 @@ class ExampleClass{
|
||||
public $examplePublicVariable = "defaultValue";
|
||||
private $examplePrivateVariable;
|
||||
|
||||
/**
|
||||
* Creates an instance of ExampleClass
|
||||
* @param string $firstArgument the first argument
|
||||
* @param string|null $secondArgument default null
|
||||
*/
|
||||
public function __construct($firstArgument, &$secondArgument = null){
|
||||
if($firstArgument === "exampleValue"){ //Remember to use === instead == when possible
|
||||
//do things
|
||||
}elseif($firstArgument === "otherValue"){
|
||||
$secondArgument = function(){
|
||||
return [
|
||||
$this->examplePrivateVariable = [
|
||||
0 => "value1",
|
||||
1 => "value2",
|
||||
2 => "value3",
|
||||
@ -73,6 +83,7 @@ class ExampleClass{
|
||||
}
|
||||
```
|
||||
|
||||
<!-- TODO: RFC and voting on the forums instead -->
|
||||
### RFC and Voting
|
||||
* These are big Pull Requests or contributions that change important behavior.
|
||||
* RFCs will be tagged with the *PR: RFC* label
|
||||
@ -90,51 +101,71 @@ class ExampleClass{
|
||||
### Labels
|
||||
To provide a concise bug tracking environment, prevent the issue tracker from over flowing and to keep support requests out of the bug tracker, PocketMine-MP uses a label scheme a bit different from the default GitHub Issues labels.
|
||||
|
||||
PocketMine-MP uses GitHub Issues Labels. There are a total of 12 labels.
|
||||
|
||||
Note: For future reference, labels must not be longer than 15 letters.
|
||||
Labels are used to identify the type and status of issues and pull requests.
|
||||
|
||||
#### Categories
|
||||
Category labels are prefixed by `C:`. Multiple category labels may be applied to a single issue(but try to keep this to a minimum and do not overuse category labels).
|
||||
- C: Core - This label is applied when the bug results in a fatal crash, or is related to neither Gameplay nor Plugin API.
|
||||
- C: Gameplay - This label is applied when the bug effects the gameplay.
|
||||
- C: API - This label is applied when the bug effects the Plugin API.
|
||||
Multiple category labels may be applied to a single issue (but try to keep this to a minimum and do not overuse category labels).
|
||||
These labels may be applied to issues with bugs related to these, or pull requests that alter the behaviour of these or fix an issue with the same label applied.
|
||||
- `Category: Core` - Related to PocketMine-MP's core functionality, but not gameplay or API.
|
||||
- `Category: Gameplay` - Related to gameplay.
|
||||
- `Category: API` - Related to plugin API.
|
||||
- `Category: Client` - Related to client functionality or behaviour. This label may be applied to issues reporting client-related bugs, or PRs related to the client such as a protocol update. There are several sub-labels to account for the differences between supported clients.
|
||||
- `all`: Related to all versions of the client.
|
||||
- `W10`: Related only to Windows 10 Edition Beta.
|
||||
- `PE`: Related only to the Pocket Edition
|
||||
- `beta`: Related only to a beta version of the game.
|
||||
- `other`: Related only to an uncommon PE-compatible version of the client, such as VR Edition.
|
||||
- `Category: PHP` - Applied to issues caused by the PHP interpreter or its extensions.
|
||||
- `Category: Other` - Applied to issues which cannot be categorized with any of the above labels.
|
||||
|
||||
#### Pull Requests
|
||||
Pull Requests are prefixed by `PR:`. Only one label may be applied for a Pull Request.
|
||||
- PR: Bug Fix - This label is applied when the Pull Request fixes a bug.
|
||||
- PR: Contribution - This label is applied when the Pull Request contributes code to PocketMine-MP such as a new feature or an improvement.
|
||||
- PR: RFC - Request for Comments
|
||||
Pull Request labels are prefixed by `PR:`. Only one label may be applied for a Pull Request.
|
||||
- `PR: Bug Fix` - The Pull Request fixes a bug.
|
||||
- `PR: Contribution` - The Pull Request contributes new features or improvements, but does not fix a bug, nor controversial enough to be an RFC.
|
||||
- `PR: RFC` - Request for Comments. Refer to [RFC and Voting](#rfc-and-voting).
|
||||
|
||||
#### Status
|
||||
Status labels show the status of the issue. Multiple status labels may be applied.
|
||||
- Reproduced - This label is applied when the bug has been reproduced, or multiple people are reporting the same issue and symptoms in which case it is automatically assumed that the bug has been reproduced in different environments.
|
||||
- Debugged - This label is applied when the cause of the bug has been found.
|
||||
- Priority - This label is applied when the bug is easy to fix, or if the scale of the bug is global.
|
||||
- Won't Fix - This label is applied if the bug has been decided not be fixed for some reason. e.g. when the bug benefits gameplay. *This label may only be applied to a closed issue.*
|
||||
|
||||
*Issues*
|
||||
- `Status: Unconfirmed` - reported issues that have yet to be reproduced by a developer successfully.
|
||||
- `Status: Reproduced` - a bug that has been reproduced by a developer, or that multiple people are reporting the same issue and symptoms in which case it is automatically assumed that the bug has been reproduced in different environments.
|
||||
- `Status: Debugged` - the cause of the bug has been found, but has not yet been fixed.
|
||||
- `Status: Resolved` - applied to *valid* issues which have been fixed. *This label may only be applied to a closed issue.*
|
||||
|
||||
*Pull requests*
|
||||
- `Status: Insufficiently tested` - applied for pull requests that have not undergone tests strict enough.
|
||||
|
||||
#### Resolution
|
||||
Resolution labels show the resolution of an issue or pull request. These labels may only be applied to closed issues.
|
||||
- `Resolution: Invalid` - Applied to support request issues or issues not related to PocketMine.
|
||||
- `Resolution: Duplicate` - Applied to issues reporting the same problems as another issue.
|
||||
- `Resolution: Fixed` - Applied to an issue reporting a bug which has been fixed.
|
||||
- `Resolution: Works As Intended` - Applied to issues reporting false bugs which work the way they are intended to.
|
||||
- `Resolution: Won't Fix` - Applied to issues reporting bugs which will not be fixed, for example if the bug is beneficial.
|
||||
- `Resolution: Obsolete` - Applied to pull requests which are rendered unnecessary by other changes, such as another, similar pull request being merged.
|
||||
|
||||
#### Miscellaneous
|
||||
Miscellaneous labels are labels that show status not related to debugging that bug. The To-Do label and the Mojang label may not be applied to a single issue at the same time.
|
||||
- To-Do - This label is applied when the issue is not a bug, but a feature request or a list of features to be implemented that count towards a milestone.
|
||||
- Mojang - This label is applied when the issue is suspected of being caused by the Minecraft: Pocket Edition client, but has not been confirmed.
|
||||
- Invalid - This label is applied when the issue is reporting a false bug that works as intended, a support request, etc. *This label may only be applied to a closed issue.*
|
||||
- `Enhancement` - Applied to issues with viable feature requests or TODO lists.
|
||||
- `High priority` - Applied to issues or PRs related to critical bugs.
|
||||
|
||||
### Closing Issues
|
||||
To keep the bug tracker clear of non-related issues and to prevent it from overflowing, **issues must be closed as soon as possible** (This may sound unethical, but it is MUCH better than having the BUG TRACKER filled with SUPPORT REQUESTS and "I NEED HELP").
|
||||
|
||||
If an issue does not conform to the "Creating an Issue" guidelines above, the issue should be closed.
|
||||
|
||||
<!--
|
||||
### Milestones
|
||||
PocketMine-MP uses GitHub Milestones to set a goal for a new release. A milestone is set on the following occasions.
|
||||
|
||||
- A new Beta release
|
||||
- A new Stable release
|
||||
- A new Beta release
|
||||
- A new Stable release
|
||||
|
||||
A milestone must use the following format:
|
||||
```
|
||||
Alpha_<version_number> [release_title][release_version]
|
||||
<version_number> [release_title][release_version]
|
||||
```
|
||||
For example:
|
||||
```
|
||||
Alpha_1.4 beta2
|
||||
1.6.1b1
|
||||
```
|
||||
-->
|
||||
|
16
README.md
16
README.md
@ -1,5 +1,5 @@
|
||||
# 
|
||||
[](https://travis-ci.org/PocketMine/PocketMine-MP)
|
||||
[](https://travis-ci.org/pmmp/PocketMine-MP)
|
||||
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@ -18,26 +18,26 @@
|
||||
|
||||
__PocketMine-MP is a free, open-source software that creates Minecraft: Pocket Edition servers and allows extending its functionalities__
|
||||
|
||||
### [Homepage](http://www.pocketmine.net/)
|
||||
### [Homepage](https://pmmp.io/)
|
||||
|
||||
### [Forums](http://forums.pocketmine.net/)
|
||||
### [Forums](https://forums.pmmp.io/)
|
||||
|
||||
### [Documentation](http://pocketmine-mp.readthedocs.org/)
|
||||
### [Documentation](http://pmmp.readthedocs.org/)
|
||||
|
||||
### [Plugin Repository](http://plugins.pocketmine.net/)
|
||||
|
||||
<!--## [FAQ: Frequently Asked Questions](https://github.com/PocketMine/PocketMine-MP/wiki/Frequently-Asked-Questions)-->
|
||||
|
||||
### [Official Jenkins server](http://jenkins.pocketmine.net/)
|
||||
### [Official Jenkins server](https://jenkins.pmmp.io/)
|
||||
|
||||
### API Documentation
|
||||
* [Official Doxygen-generated documentation](http://docs.pocketmine.net/)
|
||||
* [Latest Doxygen generated from development](http://jenkins.pocketmine.net/job/PocketMine-MP-doc/doxygen/)
|
||||
* [Latest Doxygen generated from development](https://jenkins.pmmp.io/job/PocketMine-MP%20Docs/doxygen/)
|
||||
|
||||
### [Twitter @PocketMine](https://twitter.com/PocketMine)
|
||||
|
||||
### IRC Chat #pocketmine (or #mcpedevs) @ irc.freenode.net
|
||||
[#pocketmine + #mcpedevs channel WebIRC](http://webchat.freenode.net/?channels=pocketmine,mcpedevs)
|
||||
### IRC Chat #pmmp (or #pocketmine) @ irc.freenode.net
|
||||
[#pmmp + #pocketmine channel WebIRC](http://webchat.freenode.net/?channels=pmmp,pocketmine)
|
||||
|
||||
### Want to contribute?
|
||||
* Check the [Contributing Guidelines](CONTRIBUTING.md)
|
||||
|
@ -23,13 +23,13 @@ namespace pocketmine;
|
||||
|
||||
abstract class Collectable extends \Threaded implements \Collectable{
|
||||
|
||||
private $isGarbage = false;
|
||||
|
||||
public function isGarbage() : bool{
|
||||
return $this->isGarbage;
|
||||
}
|
||||
private $isGarbage = false;
|
||||
|
||||
public function setGarbage(){
|
||||
$this->isGarbage = true;
|
||||
}
|
||||
public function isGarbage() : bool{
|
||||
return $this->isGarbage;
|
||||
}
|
||||
|
||||
public function setGarbage(){
|
||||
$this->isGarbage = true;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ use pocketmine\event\Timings;
|
||||
use pocketmine\scheduler\GarbageCollectionTask;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
|
||||
class MemoryManager{
|
||||
|
||||
/** @var Server */
|
||||
@ -128,8 +127,8 @@ class MemoryManager{
|
||||
}
|
||||
|
||||
public function trigger($memory, $limit, $global = false, $triggerCount = 0){
|
||||
$this->server->getLogger()->debug("[Memory Manager] ".($global ? "Global " : "") ."Low memory triggered, limit ". round(($limit / 1024) / 1024, 2)."MB, using ". round(($memory / 1024) / 1024, 2)."MB");
|
||||
|
||||
$this->server->getLogger()->debug(sprintf("[Memory Manager] %sLow memory triggered, limit %gMB, using %gMB",
|
||||
$global ? "Global " : "", round(($limit / 1024) / 1024, 2), round(($memory / 1024) / 1024, 2)));
|
||||
if($this->cacheTrigger){
|
||||
foreach($this->server->getLevels() as $level){
|
||||
$level->clearCache(true);
|
||||
@ -150,7 +149,7 @@ class MemoryManager{
|
||||
$cycles = $this->triggerGarbageCollector();
|
||||
}
|
||||
|
||||
$this->server->getLogger()->debug("[Memory Manager] Freed " . round(($ev->getMemoryFreed() / 1024) / 1024, 2)."MB, $cycles cycles");
|
||||
$this->server->getLogger()->debug(sprintf("[Memory Manager] Freed %gMB, $cycles cycles", round(($ev->getMemoryFreed() / 1024) / 1024, 2)));
|
||||
}
|
||||
|
||||
public function check(){
|
||||
@ -266,7 +265,7 @@ class MemoryManager{
|
||||
$this->continueDump($property->getValue($object), $info["properties"][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
|
||||
}
|
||||
|
||||
fwrite($obData, "$hash@$className: ". json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
|
||||
fwrite($obData, "$hash@$className: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
|
||||
|
||||
if(!isset($objects["staticProperties"][$className])){
|
||||
$staticProperties[$className] = [];
|
||||
@ -324,7 +323,7 @@ class MemoryManager{
|
||||
$this->continueDump($value, $data[$key], $objects, $refCounts, $recursion + 1, $maxNesting, $maxStringSize);
|
||||
}
|
||||
}elseif(is_string($from)){
|
||||
$data = "(string) len(".strlen($from).") " . substr(Utils::printable($from), 0, $maxStringSize);
|
||||
$data = sprintf("(string) len(%d) " . substr(Utils::printable($from), 0, $maxStringSize), strlen($from));
|
||||
}elseif(is_resource($from)){
|
||||
$data = "(resource) " . print_r($from, true);
|
||||
}else{
|
||||
|
@ -21,12 +21,12 @@
|
||||
|
||||
namespace pocketmine;
|
||||
|
||||
|
||||
use pocketmine\metadata\Metadatable;
|
||||
use pocketmine\metadata\MetadataValue;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\plugin\Plugin;
|
||||
|
||||
class OfflinePlayer implements IPlayer{
|
||||
class OfflinePlayer implements IPlayer, Metadatable{
|
||||
|
||||
private $name;
|
||||
private $server;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -71,12 +71,13 @@ namespace pocketmine {
|
||||
use pocketmine\utils\Terminal;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\wizard\Installer;
|
||||
use raklib\RakLib;
|
||||
|
||||
const VERSION = "1.6dev";
|
||||
const API_VERSION = "2.0.0";
|
||||
const VERSION = "1.6.1dev";
|
||||
const API_VERSION = "2.1.0";
|
||||
const CODENAME = "Unleashed";
|
||||
const MINECRAFT_VERSION = "v0.15.0.0 alpha";
|
||||
const MINECRAFT_VERSION_NETWORK = "0.15.0.0";
|
||||
const MINECRAFT_VERSION = "v0.16.0.5 alpha";
|
||||
const MINECRAFT_VERSION_NETWORK = "0.16.0.5";
|
||||
|
||||
/*
|
||||
* Startup code. Do not look at it, it may harm you.
|
||||
@ -104,6 +105,11 @@ namespace pocketmine {
|
||||
}
|
||||
|
||||
if(!class_exists("ClassLoader", false)){
|
||||
if(!is_file(\pocketmine\PATH . "src/spl/ClassLoader.php")){
|
||||
echo "[CRITICAL] Unable to find the PocketMine-SPL library." . PHP_EOL;
|
||||
echo "[CRITICAL] Please use provided builds or clone the repository recursively." . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
require_once(\pocketmine\PATH . "src/spl/ClassLoader.php");
|
||||
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
|
||||
require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
|
||||
@ -114,6 +120,14 @@ namespace pocketmine {
|
||||
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
|
||||
$autoloader->register(true);
|
||||
|
||||
try{
|
||||
if(!class_exists(RakLib::class)){
|
||||
throw new \Exception;
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
echo "[CRITICAL] Unable to find the RakLib library." . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
set_time_limit(0); //Who set it to 30 seconds?!?!
|
||||
|
||||
@ -154,7 +168,7 @@ namespace pocketmine {
|
||||
//If system timezone detection fails or timezone is an invalid value.
|
||||
if($response = Utils::getURL("http://ip-api.com/json")
|
||||
and $ip_geolocation_data = json_decode($response, true)
|
||||
and $ip_geolocation_data['status'] != 'fail'
|
||||
and $ip_geolocation_data['status'] !== 'fail'
|
||||
and date_default_timezone_set($ip_geolocation_data['timezone'])
|
||||
){
|
||||
//Again, for redundancy.
|
||||
@ -175,7 +189,7 @@ namespace pocketmine {
|
||||
$default_timezone = timezone_name_from_abbr($timezone);
|
||||
ini_set("date.timezone", $default_timezone);
|
||||
date_default_timezone_set($default_timezone);
|
||||
} else {
|
||||
}else{
|
||||
date_default_timezone_set($timezone);
|
||||
}
|
||||
}
|
||||
@ -323,7 +337,7 @@ namespace pocketmine {
|
||||
if(function_exists("posix_kill")){
|
||||
posix_kill($pid, SIGKILL);
|
||||
}else{
|
||||
exec("kill -9 " . ((int)$pid) . " > /dev/null 2>&1");
|
||||
exec("kill -9 " . ((int) $pid) . " > /dev/null 2>&1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -401,10 +415,6 @@ namespace pocketmine {
|
||||
++$errors;
|
||||
}
|
||||
|
||||
if(!extension_loaded("uopz")){
|
||||
//$logger->notice("Couldn't find the uopz extension. Some functions may be limited");
|
||||
}
|
||||
|
||||
if(extension_loaded("pocketmine")){
|
||||
if(version_compare(phpversion("pocketmine"), "0.0.1") < 0){
|
||||
$logger->critical("You have the native PocketMine extension, but your version is lower than 0.0.1.");
|
||||
@ -415,6 +425,15 @@ namespace pocketmine {
|
||||
}
|
||||
}
|
||||
|
||||
if(extension_loaded("xdebug")){
|
||||
$logger->warning("
|
||||
|
||||
|
||||
You are running PocketMine with xdebug enabled. This has a major impact on performance.
|
||||
|
||||
");
|
||||
}
|
||||
|
||||
if(!extension_loaded("curl")){
|
||||
$logger->critical("Unable to find the cURL extension.");
|
||||
++$errors;
|
||||
@ -450,7 +469,7 @@ namespace pocketmine {
|
||||
|
||||
@define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN));
|
||||
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
|
||||
@ini_set("opcache.mmap_base", bin2hex(Utils::getRandomBytes(8, false))); //Fix OPCache address errors
|
||||
@ini_set("opcache.mmap_base", bin2hex(random_bytes(8))); //Fix OPCache address errors
|
||||
|
||||
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
|
||||
new Installer();
|
||||
@ -465,14 +484,14 @@ namespace pocketmine {
|
||||
|
||||
$logger->info("Stopping other threads");
|
||||
|
||||
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
|
||||
$logger->debug("Stopping " . (new \ReflectionClass($thread))->getShortName() . " thread");
|
||||
$thread->quit();
|
||||
}
|
||||
|
||||
$killer = new ServerKiller(8);
|
||||
$killer->start();
|
||||
|
||||
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
|
||||
$logger->debug("Stopping " . $thread->getThreadName() . " thread");
|
||||
$thread->quit();
|
||||
}
|
||||
|
||||
$logger->shutdown();
|
||||
$logger->join();
|
||||
|
||||
|
@ -104,6 +104,7 @@ use pocketmine\scheduler\SendUsageTask;
|
||||
use pocketmine\scheduler\ServerScheduler;
|
||||
use pocketmine\tile\Chest;
|
||||
use pocketmine\tile\EnchantTable;
|
||||
use pocketmine\tile\FlowerPot;
|
||||
use pocketmine\tile\Furnace;
|
||||
use pocketmine\tile\Sign;
|
||||
use pocketmine\tile\Skull;
|
||||
@ -667,6 +668,10 @@ class Server{
|
||||
$this->craftingManager->registerRecipe($recipe);
|
||||
}
|
||||
|
||||
public function shouldSavePlayerData() : bool{
|
||||
return (bool) $this->getProperty("player.save-player-data", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
@ -691,18 +696,20 @@ class Server{
|
||||
public function getOfflinePlayerData($name){
|
||||
$name = strtolower($name);
|
||||
$path = $this->getDataPath() . "players/";
|
||||
if(file_exists($path . "$name.dat")){
|
||||
try{
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
$nbt->readCompressed(file_get_contents($path . "$name.dat"));
|
||||
if($this->shouldSavePlayerData()){
|
||||
if(file_exists($path . "$name.dat")){
|
||||
try{
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
$nbt->readCompressed(file_get_contents($path . "$name.dat"));
|
||||
|
||||
return $nbt->getData();
|
||||
}catch(\Throwable $e){ //zlib decode error / corrupt data
|
||||
rename($path . "$name.dat", $path . "$name.dat.bak");
|
||||
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name]));
|
||||
return $nbt->getData();
|
||||
}catch(\Throwable $e){ //zlib decode error / corrupt data
|
||||
rename($path . "$name.dat", $path . "$name.dat.bak");
|
||||
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name]));
|
||||
}
|
||||
}else{
|
||||
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name]));
|
||||
}
|
||||
}else{
|
||||
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name]));
|
||||
}
|
||||
$spawn = $this->getDefaultLevel()->getSafeSpawn();
|
||||
$nbt = new CompoundTag("", [
|
||||
@ -743,56 +750,6 @@ class Server{
|
||||
$nbt->Motion->setTagType(NBT::TAG_Double);
|
||||
$nbt->Rotation->setTagType(NBT::TAG_Float);
|
||||
|
||||
if(file_exists($path . "$name.yml")){ //Importing old PocketMine-MP files
|
||||
$data = new Config($path . "$name.yml", Config::YAML, []);
|
||||
$nbt["playerGameType"] = (int) $data->get("gamemode");
|
||||
$nbt["Level"] = $data->get("position")["level"];
|
||||
$nbt["Pos"][0] = $data->get("position")["x"];
|
||||
$nbt["Pos"][1] = $data->get("position")["y"];
|
||||
$nbt["Pos"][2] = $data->get("position")["z"];
|
||||
$nbt["SpawnLevel"] = $data->get("spawn")["level"];
|
||||
$nbt["SpawnX"] = (int) $data->get("spawn")["x"];
|
||||
$nbt["SpawnY"] = (int) $data->get("spawn")["y"];
|
||||
$nbt["SpawnZ"] = (int) $data->get("spawn")["z"];
|
||||
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerOld", [$name]));
|
||||
foreach($data->get("inventory") as $slot => $item){
|
||||
if(count($item) === 3){
|
||||
$nbt->Inventory[$slot + 9] = new CompoundTag("", [
|
||||
new ShortTag("id", $item[0]),
|
||||
new ShortTag("Damage", $item[1]),
|
||||
new ByteTag("Count", $item[2]),
|
||||
new ByteTag("Slot", $slot + 9),
|
||||
new ByteTag("TrueSlot", $slot + 9)
|
||||
]);
|
||||
}
|
||||
}
|
||||
foreach($data->get("hotbar") as $slot => $itemSlot){
|
||||
if(isset($nbt->Inventory[$itemSlot + 9])){
|
||||
$item = $nbt->Inventory[$itemSlot + 9];
|
||||
$nbt->Inventory[$slot] = new CompoundTag("", [
|
||||
new ShortTag("id", $item["id"]),
|
||||
new ShortTag("Damage", $item["Damage"]),
|
||||
new ByteTag("Count", $item["Count"]),
|
||||
new ByteTag("Slot", $slot),
|
||||
new ByteTag("TrueSlot", $item["TrueSlot"])
|
||||
]);
|
||||
}
|
||||
}
|
||||
foreach($data->get("armor") as $slot => $item){
|
||||
if(count($item) === 2){
|
||||
$nbt->Inventory[$slot + 100] = new CompoundTag("", [
|
||||
new ShortTag("id", $item[0]),
|
||||
new ShortTag("Damage", $item[1]),
|
||||
new ByteTag("Count", 1),
|
||||
new ByteTag("Slot", $slot + 100)
|
||||
]);
|
||||
}
|
||||
}
|
||||
foreach($data->get("achievements") as $achievement => $status){
|
||||
$nbt->Achievements[$achievement] = new ByteTag($achievement, $status == true ? 1 : 0);
|
||||
}
|
||||
unlink($path . "$name.yml");
|
||||
}
|
||||
$this->saveOfflinePlayerData($name, $nbt);
|
||||
|
||||
return $nbt;
|
||||
@ -800,23 +757,25 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @param CompoundTag $nbtTag
|
||||
* @param bool $async
|
||||
* @param bool $async
|
||||
*/
|
||||
public function saveOfflinePlayerData($name, CompoundTag $nbtTag, $async = false){
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
try{
|
||||
$nbt->setData($nbtTag);
|
||||
if($this->shouldSavePlayerData()){
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
try{
|
||||
$nbt->setData($nbtTag);
|
||||
|
||||
if($async){
|
||||
$this->getScheduler()->scheduleAsyncTask(new FileWriteTask($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed()));
|
||||
}else{
|
||||
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed());
|
||||
if($async){
|
||||
$this->getScheduler()->scheduleAsyncTask(new FileWriteTask($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed()));
|
||||
}else{
|
||||
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed());
|
||||
}
|
||||
}catch(\Throwable $e){
|
||||
$this->logger->critical($this->getLanguage()->translateString("pocketmine.data.saveError", [$name, $e->getMessage()]));
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
}catch(\Throwable $e){
|
||||
$this->logger->critical($this->getLanguage()->translateString("pocketmine.data.saveError", [$name, $e->getMessage()]));
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1016,10 +975,6 @@ class Server{
|
||||
|
||||
return false;
|
||||
}
|
||||
//$entities = new Config($path."entities.yml", Config::YAML);
|
||||
//if(file_exists($path . "tileEntities.yml")){
|
||||
// @rename($path . "tileEntities.yml", $path . "tiles.yml");
|
||||
//}
|
||||
|
||||
try{
|
||||
$level = new Level($this, $name, $path, $provider);
|
||||
@ -1056,7 +1011,7 @@ class Server{
|
||||
return false;
|
||||
}
|
||||
|
||||
$seed = $seed === null ? Binary::readInt(@Utils::getRandomBytes(4, false)) : (int) $seed;
|
||||
$seed = $seed === null ? Binary::readInt(random_bytes(4)) : (int) $seed;
|
||||
|
||||
if(!isset($options["preset"])){
|
||||
$options["preset"] = $this->getConfigString("generator-settings", "");
|
||||
@ -1133,14 +1088,6 @@ class Server{
|
||||
if(LevelProviderManager::getProvider($path) === null){
|
||||
return false;
|
||||
}
|
||||
/*if(file_exists($path)){
|
||||
$level = new LevelImport($path);
|
||||
if($level->import() === false){ //Try importing a world
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1452,7 +1399,7 @@ class Server{
|
||||
"level-type" => "DEFAULT",
|
||||
"enable-query" => true,
|
||||
"enable-rcon" => false,
|
||||
"rcon.password" => substr(base64_encode(@Utils::getRandomBytes(20, false)), 3, 10),
|
||||
"rcon.password" => substr(base64_encode(random_bytes(20)), 3, 10),
|
||||
"auto-save" => true,
|
||||
]);
|
||||
|
||||
@ -1530,7 +1477,7 @@ class Server{
|
||||
}
|
||||
|
||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()]));
|
||||
define("BOOTUP_RANDOM", @Utils::getRandomBytes(16));
|
||||
define("BOOTUP_RANDOM", random_bytes(16));
|
||||
$this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
|
||||
|
||||
$this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId());
|
||||
@ -1558,10 +1505,10 @@ class Server{
|
||||
|
||||
InventoryType::init();
|
||||
Block::init();
|
||||
Enchantment::init();
|
||||
Item::init();
|
||||
Biome::init();
|
||||
Effect::init();
|
||||
Enchantment::init();
|
||||
Attribute::init();
|
||||
$this->craftingManager = new CraftingManager();
|
||||
|
||||
@ -1700,7 +1647,7 @@ class Server{
|
||||
|
||||
return count($recipients);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $popup
|
||||
* @param Player[]|null $recipients
|
||||
@ -1718,7 +1665,7 @@ class Server{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** @var Player[] $recipients */
|
||||
foreach($recipients as $recipient){
|
||||
$recipient->sendPopup($popup);
|
||||
@ -1778,7 +1725,7 @@ class Server{
|
||||
*
|
||||
* @param Player[] $players
|
||||
* @param DataPacket[]|string $packets
|
||||
* @param bool $forceSync
|
||||
* @param bool $forceSync
|
||||
*/
|
||||
public function batchPackets(array $players, array $packets, $forceSync = false){
|
||||
Timings::$playerNetworkTimer->startTiming();
|
||||
@ -1789,9 +1736,9 @@ class Server{
|
||||
if(!$p->isEncoded){
|
||||
$p->encode();
|
||||
}
|
||||
$str .= Binary::writeInt(strlen($p->buffer)) . $p->buffer;
|
||||
$str .= Binary::writeUnsignedVarInt(strlen($p->buffer)) . $p->buffer;
|
||||
}else{
|
||||
$str .= Binary::writeInt(strlen($p)) . $p;
|
||||
$str .= Binary::writeUnsignedVarInt(strlen($p)) . $p;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1880,7 +1827,7 @@ class Server{
|
||||
}
|
||||
|
||||
|
||||
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.notFound"));
|
||||
$sender->sendMessage(new TranslationContainer(TextFormat::GOLD . "%commands.generic.notFound"));
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1984,8 +1931,8 @@ class Server{
|
||||
|
||||
gc_collect_cycles();
|
||||
}catch(\Throwable $e){
|
||||
$this->logger->logException($e);
|
||||
$this->logger->emergency("Crashed while crashing, killing process");
|
||||
$this->logger->emergency(get_class($e) . ": ". $e->getMessage());
|
||||
@kill(getmypid());
|
||||
}
|
||||
|
||||
@ -2033,8 +1980,6 @@ class Server{
|
||||
|
||||
$this->tickProcessor();
|
||||
$this->forceShutdown();
|
||||
|
||||
gc_collect_cycles();
|
||||
}
|
||||
|
||||
public function handleSignal($signo){
|
||||
@ -2212,6 +2157,9 @@ class Server{
|
||||
$pk = new PlayerListPacket();
|
||||
$pk->type = PlayerListPacket::TYPE_ADD;
|
||||
foreach($this->playerList as $player){
|
||||
if($p === $player){
|
||||
continue; //fixes duplicates
|
||||
}
|
||||
$pk->entries[] = [$player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkinId(), $player->getSkinData()];
|
||||
}
|
||||
|
||||
@ -2263,14 +2211,14 @@ class Server{
|
||||
if($r > $this->baseTickRate){
|
||||
$level->tickRateCounter = $level->getTickRate();
|
||||
}
|
||||
$this->getLogger()->debug("Raising level \"".$level->getName()."\" tick rate to ".$level->getTickRate()." ticks");
|
||||
$this->getLogger()->debug("Raising level \"{$level->getName()}\" tick rate to {$level->getTickRate()} ticks");
|
||||
}elseif($tickMs >= 50){
|
||||
if($level->getTickRate() === $this->baseTickRate){
|
||||
$level->setTickRate(max($this->baseTickRate + 1, min($this->autoTickRateLimit, floor($tickMs / 50))));
|
||||
$this->getLogger()->debug("Level \"".$level->getName()."\" took ".round($tickMs, 2)."ms, setting tick rate to ".$level->getTickRate()." ticks");
|
||||
$this->getLogger()->debug(sprintf("Level \"%s\" took %gms, setting tick rate to %d ticks", $level->getName(), round($tickMs, 2), $level->getTickRate()));
|
||||
}elseif(($tickMs / $level->getTickRate()) >= 50 and $level->getTickRate() < $this->autoTickRateLimit){
|
||||
$level->setTickRate($level->getTickRate() + 1);
|
||||
$this->getLogger()->debug("Level \"".$level->getName()."\" took ".round($tickMs, 2)."ms, setting tick rate to ".$level->getTickRate()." ticks");
|
||||
$this->getLogger()->debug(sprintf("Level \"%s\" took %gms, setting tick rate to %d ticks", $level->getName(), round($tickMs, 2), $level->getTickRate()));
|
||||
}
|
||||
$level->tickRateCounter = $level->getTickRate();
|
||||
}
|
||||
@ -2340,9 +2288,9 @@ class Server{
|
||||
}
|
||||
|
||||
$d = Utils::getRealMemoryUsage();
|
||||
|
||||
|
||||
$u = Utils::getMemoryUsage(true);
|
||||
$usage = round(($u[0] / 1024) / 1024, 2) . "/" . round(($d[0] / 1024) / 1024, 2) . "/" . round(($u[1] / 1024) / 1024, 2) . "/".round(($u[2] / 1024) / 1024, 2)." MB @ " . Utils::getThreadCount() . " threads";
|
||||
$usage = sprintf("%g/%g/%g/%g MB @ %d threads", round(($u[0] / 1024) / 1024, 2), round(($d[0] / 1024) / 1024, 2), round(($u[1] / 1024) / 1024, 2), round(($u[2] / 1024) / 1024, 2), Utils::getThreadCount());
|
||||
|
||||
echo "\x1b]0;" . $this->getName() . " " .
|
||||
$this->getPocketMineVersion() .
|
||||
@ -2503,10 +2451,11 @@ class Server{
|
||||
|
||||
private function registerTiles(){
|
||||
Tile::registerTile(Chest::class);
|
||||
Tile::registerTile(EnchantTable::class);
|
||||
Tile::registerTile(FlowerPot::class);
|
||||
Tile::registerTile(Furnace::class);
|
||||
Tile::registerTile(Sign::class);
|
||||
Tile::registerTile(Skull::class);
|
||||
Tile::registerTile(EnchantTable::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ abstract class Worker extends \Worker{
|
||||
|
||||
/** @var \ClassLoader */
|
||||
protected $classLoader;
|
||||
|
||||
|
||||
protected $isKilled = false;
|
||||
|
||||
public function getClassLoader(){
|
||||
@ -73,7 +73,7 @@ abstract class Worker extends \Worker{
|
||||
$this->isKilled = true;
|
||||
|
||||
$this->notify();
|
||||
|
||||
|
||||
if($this->isRunning()){
|
||||
$this->shutdown();
|
||||
$this->notify();
|
||||
|
@ -21,36 +21,11 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class AcaciaWoodStairs extends Stair{
|
||||
class AcaciaWoodStairs extends WoodStairs{
|
||||
|
||||
protected $id = self::ACACIA_WOOD_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Acacia Wood Stairs";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
}
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class ActivatorRail extends Solid {
|
||||
class ActivatorRail extends Solid{
|
||||
|
||||
protected $id = self::ACTIVATOR_RAIL;
|
||||
protected $id = self::ACTIVATOR_RAIL;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Activator Rail";
|
||||
}
|
||||
public function getName(){
|
||||
return "Activator Rail";
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,10 @@ use pocketmine\Player;
|
||||
|
||||
class Anvil extends Fallable{
|
||||
|
||||
const TYPE_NORMAL = 0;
|
||||
const TYPE_SLIGHTLY_DAMAGED = 4;
|
||||
const TYPE_VERY_DAMAGED = 8;
|
||||
|
||||
protected $id = self::ANVIL;
|
||||
|
||||
public function isSolid(){
|
||||
@ -51,7 +55,12 @@ class Anvil extends Fallable{
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Anvil";
|
||||
static $names = [
|
||||
self::TYPE_NORMAL => "Anvil",
|
||||
self::TYPE_SLIGHTLY_DAMAGED => "Slightly Damaged Anvil",
|
||||
self::TYPE_VERY_DAMAGED => "Very Damaged Anvil"
|
||||
];
|
||||
return $names[$this->meta & 0x0c] ?? "Anvil";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
@ -60,20 +69,22 @@ class Anvil extends Fallable{
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($player instanceof Player){
|
||||
if($player->isCreative()){
|
||||
return true;
|
||||
}
|
||||
|
||||
$player->addWindow(new AnvilInventory($this));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$direction = ($player !== null ? $player->getDirection() : 0) & 0x03;
|
||||
$this->meta = ($this->meta & 0x0c) | $direction;
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[$this->id, 0, 1], //TODO break level
|
||||
[$this->id, $this->meta & 0x0c, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
|
@ -21,36 +21,11 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class BirchWoodStairs extends Stair{
|
||||
class BirchWoodStairs extends WoodStairs{
|
||||
|
||||
protected $id = self::BIRCH_WOOD_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Birch Wood Stairs";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
}
|
@ -25,8 +25,6 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\level\Level;
|
||||
@ -39,242 +37,7 @@ use pocketmine\metadata\MetadataValue;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\plugin\Plugin;
|
||||
|
||||
|
||||
class Block extends Position implements Metadatable{
|
||||
const AIR = 0;
|
||||
const STONE = 1;
|
||||
const GRASS = 2;
|
||||
const DIRT = 3;
|
||||
const COBBLESTONE = 4;
|
||||
const COBBLE = 4;
|
||||
const PLANK = 5;
|
||||
const PLANKS = 5;
|
||||
const WOODEN_PLANK = 5;
|
||||
const WOODEN_PLANKS = 5;
|
||||
const SAPLING = 6;
|
||||
const SAPLINGS = 6;
|
||||
const BEDROCK = 7;
|
||||
const WATER = 8;
|
||||
const STILL_WATER = 9;
|
||||
const LAVA = 10;
|
||||
const STILL_LAVA = 11;
|
||||
const SAND = 12;
|
||||
const GRAVEL = 13;
|
||||
const GOLD_ORE = 14;
|
||||
const IRON_ORE = 15;
|
||||
const COAL_ORE = 16;
|
||||
const LOG = 17;
|
||||
const WOOD = 17;
|
||||
const TRUNK = 17;
|
||||
const LEAVES = 18;
|
||||
const LEAVE = 18;
|
||||
const SPONGE = 19;
|
||||
const GLASS = 20;
|
||||
const LAPIS_ORE = 21;
|
||||
const LAPIS_BLOCK = 22;
|
||||
|
||||
const SANDSTONE = 24;
|
||||
const NOTE_BLOCK = 25;
|
||||
const BED_BLOCK = 26;
|
||||
const POWERED_RAIL = 27;
|
||||
const DETECTOR_RAIL = 28;
|
||||
const COBWEB = 30;
|
||||
const TALL_GRASS = 31;
|
||||
const BUSH = 32;
|
||||
const DEAD_BUSH = 32;
|
||||
const WOOL = 35;
|
||||
const DANDELION = 37;
|
||||
const POPPY = 38;
|
||||
const ROSE = 38;
|
||||
const RED_FLOWER = 38;
|
||||
const BROWN_MUSHROOM = 39;
|
||||
const RED_MUSHROOM = 40;
|
||||
const GOLD_BLOCK = 41;
|
||||
const IRON_BLOCK = 42;
|
||||
const DOUBLE_SLAB = 43;
|
||||
const DOUBLE_SLABS = 43;
|
||||
const SLAB = 44;
|
||||
const SLABS = 44;
|
||||
const BRICKS = 45;
|
||||
const BRICKS_BLOCK = 45;
|
||||
const TNT = 46;
|
||||
const BOOKSHELF = 47;
|
||||
const MOSS_STONE = 48;
|
||||
const MOSSY_STONE = 48;
|
||||
const OBSIDIAN = 49;
|
||||
const TORCH = 50;
|
||||
const FIRE = 51;
|
||||
const MONSTER_SPAWNER = 52;
|
||||
const WOOD_STAIRS = 53;
|
||||
const WOODEN_STAIRS = 53;
|
||||
const OAK_WOOD_STAIRS = 53;
|
||||
const OAK_WOODEN_STAIRS = 53;
|
||||
const CHEST = 54;
|
||||
const REDSTONE_WIRE = 55;
|
||||
const DIAMOND_ORE = 56;
|
||||
const DIAMOND_BLOCK = 57;
|
||||
const CRAFTING_TABLE = 58;
|
||||
const WORKBENCH = 58;
|
||||
const WHEAT_BLOCK = 59;
|
||||
const FARMLAND = 60;
|
||||
const FURNACE = 61;
|
||||
const BURNING_FURNACE = 62;
|
||||
const LIT_FURNACE = 62;
|
||||
const SIGN_POST = 63;
|
||||
const DOOR_BLOCK = 64;
|
||||
const WOODEN_DOOR_BLOCK = 64;
|
||||
const WOOD_DOOR_BLOCK = 64;
|
||||
const LADDER = 65;
|
||||
const RAIL = 66;
|
||||
const COBBLE_STAIRS = 67;
|
||||
const COBBLESTONE_STAIRS = 67;
|
||||
const WALL_SIGN = 68;
|
||||
const LEVER = 69;
|
||||
const STONE_PRESSURE_PLATE = 70;
|
||||
const IRON_DOOR_BLOCK = 71;
|
||||
const WOODEN_PRESSURE_PLATE = 72;
|
||||
const REDSTONE_ORE = 73;
|
||||
const GLOWING_REDSTONE_ORE = 74;
|
||||
const LIT_REDSTONE_ORE = 74;
|
||||
const REDSTONE_TORCH = 75;
|
||||
const LIT_REDSTONE_TORCH = 76;
|
||||
const STONE_BUTTON = 77;
|
||||
const SNOW = 78;
|
||||
const SNOW_LAYER = 78;
|
||||
const ICE = 79;
|
||||
const SNOW_BLOCK = 80;
|
||||
const CACTUS = 81;
|
||||
const CLAY_BLOCK = 82;
|
||||
const REEDS = 83;
|
||||
const SUGARCANE_BLOCK = 83;
|
||||
|
||||
const FENCE = 85;
|
||||
const PUMPKIN = 86;
|
||||
const NETHERRACK = 87;
|
||||
const SOUL_SAND = 88;
|
||||
const GLOWSTONE = 89;
|
||||
const GLOWSTONE_BLOCK = 89;
|
||||
|
||||
const PORTAL_BLOCK = 90;
|
||||
const LIT_PUMPKIN = 91;
|
||||
const JACK_O_LANTERN = 91;
|
||||
const CAKE_BLOCK = 92;
|
||||
|
||||
const TRAPDOOR = 96;
|
||||
const MONSTER_EGG_BLOCK = 97;
|
||||
const STONE_BRICKS = 98;
|
||||
const STONE_BRICK = 98;
|
||||
const BROWN_MUSHROOM_BLOCK = 99;
|
||||
const RED_MUSHROOM_BLOCK = 100;
|
||||
const IRON_BAR = 101;
|
||||
const IRON_BARS = 101;
|
||||
const GLASS_PANE = 102;
|
||||
const GLASS_PANEL = 102;
|
||||
const MELON_BLOCK = 103;
|
||||
const PUMPKIN_STEM = 104;
|
||||
const MELON_STEM = 105;
|
||||
const VINE = 106;
|
||||
const VINES = 106;
|
||||
const FENCE_GATE = 107;
|
||||
const BRICK_STAIRS = 108;
|
||||
const STONE_BRICK_STAIRS = 109;
|
||||
const MYCELIUM = 110;
|
||||
const WATER_LILY = 111;
|
||||
const LILY_PAD = 111;
|
||||
const NETHER_BRICKS = 112;
|
||||
const NETHER_BRICK_BLOCK = 112;
|
||||
const NETHER_BRICK_FENCE = 113;
|
||||
const NETHER_BRICKS_STAIRS = 114;
|
||||
const NETHER_WART_BLOCK = 115;
|
||||
const ENCHANTING_TABLE = 116;
|
||||
const ENCHANT_TABLE = 116;
|
||||
const ENCHANTMENT_TABLE = 116;
|
||||
const BREWING_STAND = 117;
|
||||
|
||||
const END_PORTAL_FRAME = 120;
|
||||
const END_STONE = 121;
|
||||
const REDSTONE_LAMP = 122;
|
||||
const LIT_REDSTONE_LAMP = 123;
|
||||
|
||||
const ACTIVATOR_RAIL = 126;
|
||||
const COCOA_BLOCK = 127;
|
||||
const SANDSTONE_STAIRS = 128;
|
||||
const EMERALD_ORE = 129;
|
||||
|
||||
const TRIPWIRE_HOOK = 131;
|
||||
const TRIPWIRE = 132;
|
||||
const EMERALD_BLOCK = 133;
|
||||
const SPRUCE_WOOD_STAIRS = 134;
|
||||
const SPRUCE_WOODEN_STAIRS = 134;
|
||||
const BIRCH_WOOD_STAIRS = 135;
|
||||
const BIRCH_WOODEN_STAIRS = 135;
|
||||
const JUNGLE_WOOD_STAIRS = 136;
|
||||
const JUNGLE_WOODEN_STAIRS = 136;
|
||||
|
||||
const COBBLE_WALL = 139;
|
||||
const STONE_WALL = 139;
|
||||
const COBBLESTONE_WALL = 139;
|
||||
const FLOWER_POT_BLOCK = 140;
|
||||
const CARROT_BLOCK = 141;
|
||||
const POTATO_BLOCK = 142;
|
||||
const WOODEN_BUTTON = 143;
|
||||
const MOB_HEAD = 144;
|
||||
const SKULL = 144;
|
||||
const ANVIL = 145;
|
||||
const TRAPPED_CHEST = 146;
|
||||
const WEIGHTED_PRESSURE_PLATE_LIGHT = 147;
|
||||
const WEIGHTED_PRESSURE_PLATE_HEAVY = 148;
|
||||
|
||||
const DAYLIGHT_SENSOR = 151;
|
||||
const REDSTONE_BLOCK = 152;
|
||||
const NETHER_QUARTZ_ORE = 153;
|
||||
|
||||
const QUARTZ_BLOCK = 155;
|
||||
const QUARTZ_STAIRS = 156;
|
||||
const DOUBLE_WOOD_SLAB = 157;
|
||||
const DOUBLE_WOODEN_SLAB = 157;
|
||||
const DOUBLE_WOOD_SLABS = 157;
|
||||
const DOUBLE_WOODEN_SLABS = 157;
|
||||
const WOOD_SLAB = 158;
|
||||
const WOODEN_SLAB = 158;
|
||||
const WOOD_SLABS = 158;
|
||||
const WOODEN_SLABS = 158;
|
||||
const STAINED_CLAY = 159;
|
||||
const STAINED_HARDENED_CLAY = 159;
|
||||
|
||||
const LEAVES2 = 161;
|
||||
const LEAVE2 = 161;
|
||||
const WOOD2 = 162;
|
||||
const TRUNK2 = 162;
|
||||
const LOG2 = 162;
|
||||
const ACACIA_WOOD_STAIRS = 163;
|
||||
const ACACIA_WOODEN_STAIRS = 163;
|
||||
const DARK_OAK_WOOD_STAIRS = 164;
|
||||
const DARK_OAK_WOODEN_STAIRS = 164;
|
||||
|
||||
const IRON_TRAPDOOR = 167;
|
||||
|
||||
const HAY_BALE = 170;
|
||||
const CARPET = 171;
|
||||
const HARDENED_CLAY = 172;
|
||||
const COAL_BLOCK = 173;
|
||||
const PACKED_ICE = 174;
|
||||
const DOUBLE_PLANT = 175;
|
||||
|
||||
const INVERTED_DAYLIGHT_SENSOR = 178;
|
||||
|
||||
const FENCE_GATE_SPRUCE = 183;
|
||||
const FENCE_GATE_BIRCH = 184;
|
||||
const FENCE_GATE_JUNGLE = 185;
|
||||
const FENCE_GATE_DARK_OAK = 186;
|
||||
const FENCE_GATE_ACACIA = 187;
|
||||
|
||||
const GRASS_PATH = 198;
|
||||
|
||||
const PODZOL = 243;
|
||||
const BEETROOT_BLOCK = 244;
|
||||
const STONECUTTER = 245;
|
||||
const GLOWING_OBSIDIAN = 246;
|
||||
class Block extends Position implements BlockIds, Metadatable{
|
||||
|
||||
/** @var \SplFixedArray */
|
||||
public static $list = null;
|
||||
@ -421,7 +184,7 @@ class Block extends Position implements Metadatable{
|
||||
self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class;
|
||||
|
||||
self::$list[self::ENCHANTING_TABLE] = EnchantingTable::class;
|
||||
self::$list[self::BREWING_STAND] = BrewingStand::class;
|
||||
self::$list[self::BREWING_STAND_BLOCK] = BrewingStand::class;
|
||||
self::$list[self::END_PORTAL_FRAME] = EndPortalFrame::class;
|
||||
self::$list[self::END_STONE] = EndStone::class;
|
||||
self::$list[self::REDSTONE_LAMP] = RedstoneLamp::class;
|
||||
@ -439,12 +202,12 @@ class Block extends Position implements Metadatable{
|
||||
self::$list[self::CARROT_BLOCK] = Carrot::class;
|
||||
self::$list[self::POTATO_BLOCK] = Potato::class;
|
||||
self::$list[self::WOODEN_BUTTON] = WoodenButton::class;
|
||||
self::$list[self::MOB_HEAD] = MobHead::class;
|
||||
self::$list[self::MOB_HEAD_BLOCK] = MobHead::class;
|
||||
self::$list[self::ANVIL] = Anvil::class;
|
||||
self::$list[self::TRAPPED_CHEST] = TrappedChest::class;
|
||||
self::$list[self::WEIGHTED_PRESSURE_PLATE_LIGHT] = WeightedPressurePlateLight::class;
|
||||
self::$list[self::WEIGHTED_PRESSURE_PLATE_HEAVY] = WeightedPressurePlateHeavy::class;
|
||||
|
||||
|
||||
self::$list[self::DAYLIGHT_SENSOR] = DaylightSensor::class;
|
||||
self::$list[self::REDSTONE_BLOCK] = Redstone::class;
|
||||
|
||||
|
230
src/pocketmine/block/BlockIds.php
Normal file
230
src/pocketmine/block/BlockIds.php
Normal file
@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
interface BlockIds{
|
||||
|
||||
const AIR = 0;
|
||||
const STONE = 1;
|
||||
const GRASS = 2;
|
||||
const DIRT = 3;
|
||||
const COBBLESTONE = 4, COBBLE = 4;
|
||||
const PLANK = 5, PLANKS = 5, WOODEN_PLANK = 5, WOODEN_PLANKS = 5;
|
||||
const SAPLING = 6, SAPLINGS = 6;
|
||||
const BEDROCK = 7;
|
||||
const WATER = 8;
|
||||
const STILL_WATER = 9;
|
||||
const LAVA = 10;
|
||||
const STILL_LAVA = 11;
|
||||
const SAND = 12;
|
||||
const GRAVEL = 13;
|
||||
const GOLD_ORE = 14;
|
||||
const IRON_ORE = 15;
|
||||
const COAL_ORE = 16;
|
||||
const LOG = 17, WOOD = 17, TRUNK = 17;
|
||||
const LEAVES = 18;
|
||||
const SPONGE = 19;
|
||||
const GLASS = 20;
|
||||
const LAPIS_ORE = 21;
|
||||
const LAPIS_BLOCK = 22;
|
||||
const DISPENSER = 23;
|
||||
const SANDSTONE = 24;
|
||||
const NOTE_BLOCK = 25, NOTEBLOCK = 25;
|
||||
const BED_BLOCK = 26;
|
||||
const POWERED_RAIL = 27;
|
||||
const DETECTOR_RAIL = 28;
|
||||
const STICKY_PISTON = 29;
|
||||
const COBWEB = 30;
|
||||
const TALL_GRASS = 31;
|
||||
const BUSH = 32, DEAD_BUSH = 32;
|
||||
const PISTON = 33;
|
||||
const PISTON_HEAD = 34;
|
||||
const WOOL = 35;
|
||||
|
||||
const DANDELION = 37;
|
||||
const POPPY = 38, ROSE = 38, RED_FLOWER = 38;
|
||||
const BROWN_MUSHROOM = 39;
|
||||
const RED_MUSHROOM = 40;
|
||||
const GOLD_BLOCK = 41;
|
||||
const IRON_BLOCK = 42;
|
||||
const DOUBLE_SLAB = 43, DOUBLE_SLABS = 43;
|
||||
const SLAB = 44, SLABS = 44, STONE_SLAB = 44;
|
||||
const BRICKS = 45, BRICKS_BLOCK = 45;
|
||||
const TNT = 46;
|
||||
const BOOKSHELF = 47;
|
||||
const MOSS_STONE = 48, MOSSY_STONE = 48;
|
||||
const OBSIDIAN = 49;
|
||||
const TORCH = 50;
|
||||
const FIRE = 51;
|
||||
const MONSTER_SPAWNER = 52;
|
||||
const WOOD_STAIRS = 53, WOODEN_STAIRS = 53, OAK_WOOD_STAIRS = 53, OAK_WOODEN_STAIRS = 53;
|
||||
const CHEST = 54;
|
||||
const REDSTONE_WIRE = 55;
|
||||
const DIAMOND_ORE = 56;
|
||||
const DIAMOND_BLOCK = 57;
|
||||
const CRAFTING_TABLE = 58, WORKBENCH = 58;
|
||||
const WHEAT_BLOCK = 59;
|
||||
const FARMLAND = 60;
|
||||
const FURNACE = 61;
|
||||
const BURNING_FURNACE = 62, LIT_FURNACE = 62;
|
||||
const SIGN_POST = 63;
|
||||
const DOOR_BLOCK = 64, WOODEN_DOOR_BLOCK = 64, WOOD_DOOR_BLOCK = 64;
|
||||
const LADDER = 65;
|
||||
const RAIL = 66;
|
||||
const COBBLESTONE_STAIRS = 67, COBBLE_STAIRS = 67;
|
||||
const WALL_SIGN = 68;
|
||||
const LEVER = 69;
|
||||
const STONE_PRESSURE_PLATE = 70;
|
||||
const IRON_DOOR_BLOCK = 71;
|
||||
const WOODEN_PRESSURE_PLATE = 72;
|
||||
const REDSTONE_ORE = 73;
|
||||
const GLOWING_REDSTONE_ORE = 74, LIT_REDSTONE_ORE = 74;
|
||||
const UNLIT_REDSTONE_TORCH = 75;
|
||||
const REDSTONE_TORCH = 76, LIT_REDSTONE_TORCH = 76;
|
||||
const STONE_BUTTON = 77;
|
||||
const SNOW = 78, SNOW_LAYER = 78;
|
||||
const ICE = 79;
|
||||
const SNOW_BLOCK = 80;
|
||||
const CACTUS = 81;
|
||||
const CLAY_BLOCK = 82;
|
||||
const REEDS = 83, SUGARCANE_BLOCK = 83;
|
||||
|
||||
const FENCE = 85;
|
||||
const PUMPKIN = 86;
|
||||
const NETHERRACK = 87;
|
||||
const SOUL_SAND = 88;
|
||||
const GLOWSTONE = 89, GLOWSTONE_BLOCK = 89;
|
||||
const PORTAL_BLOCK = 90, PORTAL = 90;
|
||||
const JACK_O_LANTERN = 91, LIT_PUMPKIN = 91;
|
||||
const CAKE_BLOCK = 92;
|
||||
const REPEATER_BLOCK = 93, UNPOWERED_REPEATER_BLOCK = 93;
|
||||
const POWERED_REPEATER_BLOCK = 94;
|
||||
const INVISIBLE_BEDROCK = 95;
|
||||
const TRAPDOOR = 96, WOODEN_TRAPDOOR = 96;
|
||||
const MONSTER_EGG_BLOCK = 97;
|
||||
const STONE_BRICKS = 98, STONE_BRICK = 98;
|
||||
const BROWN_MUSHROOM_BLOCK = 99;
|
||||
const RED_MUSHROOM_BLOCK = 100;
|
||||
const IRON_BARS = 101, IRON_BAR = 101;
|
||||
const GLASS_PANE = 102, GLASS_PANEL = 102;
|
||||
const MELON_BLOCK = 103;
|
||||
const PUMPKIN_STEM = 104;
|
||||
const MELON_STEM = 105;
|
||||
const VINES = 106, VINE = 106;
|
||||
const FENCE_GATE = 107, OAK_FENCE_GATE = 107;
|
||||
const BRICK_STAIRS = 108;
|
||||
const STONE_BRICK_STAIRS = 109;
|
||||
const MYCELIUM = 110;
|
||||
const LILY_PAD = 111, WATER_LILY = 111;
|
||||
const NETHER_BRICKS = 112, NETHER_BRICK_BLOCK = 112;
|
||||
const NETHER_BRICK_FENCE = 113;
|
||||
const NETHER_BRICK_STAIRS = 114, NETHER_BRICKS_STAIRS = 114;
|
||||
const NETHER_WART_BLOCK = 115;
|
||||
const ENCHANTING_TABLE = 116, ENCHANT_TABLE = 116, ENCHANTMENT_TABLE = 116;
|
||||
const BREWING_STAND_BLOCK = 117;
|
||||
const CAULDRON_BLOCK = 118;
|
||||
|
||||
const END_PORTAL_FRAME = 120, END_PORTAL = 120;
|
||||
const END_STONE = 121;
|
||||
|
||||
const REDSTONE_LAMP = 123, INACTIVE_REDSTONE_LAMP = 123;
|
||||
const LIT_REDSTONE_LAMP = 124, ACTIVE_REDSTONE_LAMP = 124;
|
||||
const DROPPER = 125;
|
||||
const ACTIVATOR_RAIL = 126;
|
||||
const COCOA_BLOCK = 127, COCOA_PODS = 127;
|
||||
const SANDSTONE_STAIRS = 128;
|
||||
const EMERALD_ORE = 129;
|
||||
|
||||
const TRIPWIRE_HOOK = 131;
|
||||
const TRIPWIRE = 132;
|
||||
const EMERALD_BLOCK = 133;
|
||||
const SPRUCE_WOOD_STAIRS = 134, SPRUCE_WOODEN_STAIRS = 134;
|
||||
const BIRCH_WOOD_STAIRS = 135, BIRCH_WOODEN_STAIRS = 135;
|
||||
const JUNGLE_WOOD_STAIRS = 136, JUNGLE_WOODEN_STAIRS = 136;
|
||||
|
||||
const COBBLESTONE_WALL = 139, COBBLE_WALL = 139, STONE_WALL = 139;
|
||||
const FLOWER_POT_BLOCK = 140;
|
||||
const CARROT_BLOCK = 141;
|
||||
const POTATO_BLOCK = 142;
|
||||
const WOODEN_BUTTON = 143;
|
||||
const MOB_HEAD_BLOCK = 144, SKULL_BLOCK = 144;
|
||||
const ANVIL = 145;
|
||||
const TRAPPED_CHEST = 146;
|
||||
const WEIGHTED_PRESSURE_PLATE_LIGHT = 147, LIGHT_WEIGHTED_PRESSURE_PLATE = 147, GOLD_PRESSURE_PLATE = 147;
|
||||
const WEIGHTED_PRESSURE_PLATE_HEAVY = 148, HEAVY_WEIGHTED_PRESSURE_PLATE = 148, IRON_PRESSURE_PLATE = 148;
|
||||
const COMPARATOR_BLOCK = 149, UNPOWERED_COMPARATOR_BLOCK = 149;
|
||||
const POWERED_COMPARATOR_BLOCK = 150;
|
||||
const DAYLIGHT_SENSOR = 151;
|
||||
const REDSTONE_BLOCK = 152;
|
||||
const NETHER_QUARTZ_ORE = 153;
|
||||
const HOPPER_BLOCK = 154;
|
||||
const QUARTZ_BLOCK = 155;
|
||||
const QUARTZ_STAIRS = 156;
|
||||
const DOUBLE_WOOD_SLAB = 157, DOUBLE_WOODEN_SLAB = 157, DOUBLE_WOOD_SLABS = 157, DOUBLE_WOODEN_SLABS = 157;
|
||||
const WOOD_SLAB = 158, WOODEN_SLAB = 158, WOOD_SLABS = 158, WOODEN_SLABS = 158;
|
||||
const STAINED_CLAY = 159, STAINED_HARDENED_CLAY = 159;
|
||||
|
||||
const LEAVES2 = 161;
|
||||
const WOOD2 = 162, TRUNK2 = 162, LOG2 = 162;
|
||||
const ACACIA_WOOD_STAIRS = 163, ACACIA_WOODEN_STAIRS = 163;
|
||||
const DARK_OAK_WOOD_STAIRS = 164, DARK_OAK_WOODEN_STAIRS = 164;
|
||||
const SLIME_BLOCK = 165;
|
||||
|
||||
const IRON_TRAPDOOR = 167;
|
||||
|
||||
const HAY_BALE = 170;
|
||||
const CARPET = 171;
|
||||
const HARDENED_CLAY = 172;
|
||||
const COAL_BLOCK = 173;
|
||||
const PACKED_ICE = 174;
|
||||
const DOUBLE_PLANT = 175;
|
||||
|
||||
const INVERTED_DAYLIGHT_SENSOR = 178, DAYLIGHT_SENSOR_INVERTED = 178;
|
||||
const RED_SANDSTONE = 179;
|
||||
const RED_SANDSTONE_STAIRS = 180;
|
||||
const DOUBLE_RED_SANDSTONE_SLAB = 181;
|
||||
const RED_SANDSTONE_SLAB = 182;
|
||||
const SPRUCE_FENCE_GATE = 183, FENCE_GATE_SPRUCE = 183;
|
||||
const BIRCH_FENCE_GATE = 184, FENCE_GATE_BIRCH = 184;
|
||||
const JUNGLE_FENCE_GATE = 185, FENCE_GATE_JUNGLE = 185;
|
||||
const DARK_OAK_FENCE_GATE = 186, FENCE_GATE_DARK_OAK = 186;
|
||||
const ACACIA_FENCE_GATE = 187, FENCE_GATE_ACACIA = 187;
|
||||
|
||||
const SPRUCE_DOOR_BLOCK = 193;
|
||||
const BIRCH_DOOR_BLOCK = 194;
|
||||
const JUNGLE_DOOR_BLOCK = 195;
|
||||
const ACACIA_DOOR_BLOCK = 196;
|
||||
const DARK_OAK_DOOR_BLOCK = 197;
|
||||
const GRASS_PATH = 198;
|
||||
const ITEM_FRAME_BLOCK = 199;
|
||||
|
||||
const PODZOL = 243;
|
||||
const BEETROOT_BLOCK = 244;
|
||||
const STONECUTTER = 245;
|
||||
const GLOWING_OBSIDIAN = 246;
|
||||
const NETHER_REACTOR = 247;
|
||||
const UPDATE_BLOCK = 248;
|
||||
const ATEUPD_BLOCK = 249;
|
||||
const BLOCK_MOVED_BY_PISTON = 250;
|
||||
const OBSERVER = 251;
|
||||
const INFO_RESERVED6 = 255;
|
||||
}
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Bookshelf extends Solid{
|
||||
|
@ -21,12 +21,11 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class BrewingStand extends Transparent{
|
||||
|
||||
protected $id = self::BREWING_STAND;
|
||||
protected $id = self::BREWING_STAND_BLOCK;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class BrickStairs extends Stair{
|
||||
|
@ -25,8 +25,8 @@ use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\tile\Furnace;
|
||||
@ -123,10 +123,6 @@ class BurningFurnace extends Solid{
|
||||
}
|
||||
}
|
||||
|
||||
if($player->isCreative()){
|
||||
return true;
|
||||
}
|
||||
|
||||
$player->addWindow($furnace->getInventory());
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\tile\Chest as TileChest;
|
||||
@ -86,7 +86,7 @@ class Chest extends Transparent{
|
||||
continue;
|
||||
}
|
||||
$c = $this->getSide($side);
|
||||
if($c instanceof Chest and $c->getDamage() === $this->meta){
|
||||
if($c->getId() === $this->id and $c->getDamage() === $this->meta){
|
||||
$tile = $this->getLevel()->getTile($c);
|
||||
if($tile instanceof TileChest and !$tile->isPaired()){
|
||||
$chest = $tile;
|
||||
@ -164,9 +164,6 @@ class Chest extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
if($player->isCreative()){
|
||||
return true;
|
||||
}
|
||||
$player->addWindow($chest->getInventory());
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class CobblestoneStairs extends Stair{
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class CocoaBlock extends Solid {
|
||||
class CocoaBlock extends Solid{
|
||||
|
||||
protected $id = self::COCOA_BLOCK;
|
||||
protected $id = self::COCOA_BLOCK;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Cocoa Block";
|
||||
}
|
||||
public function getName(){
|
||||
return "Cocoa Block";
|
||||
}
|
||||
}
|
||||
|
@ -21,28 +21,11 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class DarkOakWoodStairs extends Stair{
|
||||
class DarkOakWoodStairs extends WoodStairs{
|
||||
|
||||
protected $id = self::DARK_OAK_WOOD_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Dark Oak Wood Stairs";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class DaylightSensor extends Solid {
|
||||
class DaylightSensor extends Solid{
|
||||
|
||||
protected $id = self::DAYLIGHT_SENSOR;
|
||||
protected $id = self::DAYLIGHT_SENSOR;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Daylight Sensor";
|
||||
}
|
||||
public function getName(){
|
||||
return "Daylight Sensor";
|
||||
}
|
||||
}
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class DetectorRail extends Solid {
|
||||
class DetectorRail extends Solid{
|
||||
|
||||
protected $id = self::DETECTOR_RAIL;
|
||||
protected $id = self::DETECTOR_RAIL;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Detector Rail";
|
||||
}
|
||||
public function getName(){
|
||||
return "Detector Rail";
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ namespace pocketmine\block;
|
||||
use pocketmine\inventory\EnchantInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
@ -86,9 +85,6 @@ class EnchantingTable extends Transparent{
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($player instanceof Player){
|
||||
//TODO lock
|
||||
if($player->isCreative()){
|
||||
return true;
|
||||
}
|
||||
|
||||
$player->addWindow(new EnchantInventory($this));
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class EndStone extends Solid{
|
||||
|
@ -28,9 +28,9 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\ByteTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\DoubleTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\Player;
|
||||
|
||||
abstract class Fallable extends Solid{
|
||||
|
@ -26,13 +26,13 @@ use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class Fence extends Transparent{
|
||||
const FENCE_OAK = 0;
|
||||
const FENCE_OAK = 0;
|
||||
const FENCE_SPRUCE = 1;
|
||||
const FENCE_BIRCH = 2;
|
||||
const FENCE_JUNGLE = 3;
|
||||
const FENCE_ACACIA = 4;
|
||||
const FENCE_DARKOAK = 5;
|
||||
|
||||
|
||||
protected $id = self::FENCE;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
|
@ -59,7 +59,7 @@ class FenceGate extends Transparent{
|
||||
}
|
||||
|
||||
$i = ($this->getDamage() & 0x03);
|
||||
if($i === 2 and $i === 0){
|
||||
if($i === 2 or $i === 0){
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
@ -100,13 +100,9 @@ class FenceGate extends Transparent{
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
$faces = [
|
||||
0 => 3,
|
||||
1 => 0,
|
||||
2 => 1,
|
||||
3 => 2,
|
||||
];
|
||||
$this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04);
|
||||
$this->meta ^= 0x04; //Flip open/close state
|
||||
//TODO: Face player when opened
|
||||
|
||||
$this->getLevel()->setBlock($this, $this, true);
|
||||
$this->level->addSound(new DoorSound($this));
|
||||
return true;
|
||||
|
@ -21,9 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
|
||||
|
||||
abstract class Flowable extends Transparent{
|
||||
|
||||
public function canBeFlowedInto(){
|
||||
@ -42,7 +39,7 @@ abstract class Flowable extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
}
|
@ -22,8 +22,21 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\tile\FlowerPot as TileFlowerPot;
|
||||
use pocketmine\tile\Tile;
|
||||
|
||||
class FlowerPot extends Transparent{
|
||||
class FlowerPot extends Flowable{
|
||||
|
||||
const STATE_EMPTY = 0;
|
||||
const STATE_FULL = 1;
|
||||
|
||||
protected $id = self::FLOWER_POT_BLOCK;
|
||||
|
||||
@ -35,4 +48,90 @@ class FlowerPot extends Transparent{
|
||||
return "Flower Pot Block";
|
||||
}
|
||||
|
||||
public function canBeActivated(): bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
$this->x + (5 / 16),
|
||||
$this->y,
|
||||
$this->z + (5 / 16),
|
||||
$this->x + (11 / 16),
|
||||
$this->y + (6 / 16),
|
||||
$this->z + (11 / 16)
|
||||
);
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
||||
$nbt = new CompoundTag("", [
|
||||
new StringTag("id", Tile::FLOWER_POT),
|
||||
new IntTag("x", $block->x),
|
||||
new IntTag("y", $block->y),
|
||||
new IntTag("z", $block->z),
|
||||
new ShortTag("item", 0),
|
||||
new IntTag("mData", 0),
|
||||
]);
|
||||
|
||||
if($item->hasCustomBlockData()){
|
||||
foreach($item->getCustomBlockData() as $key => $v){
|
||||
$nbt->{$key} = $v;
|
||||
}
|
||||
}
|
||||
|
||||
Tile::createTile(Tile::FLOWER_POT, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent() === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
$pot = $this->getLevel()->getTile($this);
|
||||
if(!($pot instanceof TileFlowerPot)){
|
||||
return false;
|
||||
}
|
||||
if(!$pot->canAddItem($item)){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setDamage(self::STATE_FULL); //specific damage value is unnecessary, it just needs to be non-zero to show an item.
|
||||
$this->getLevel()->setBlock($this, $this, true, false);
|
||||
$pot->setItem($item);
|
||||
|
||||
if($player instanceof Player){
|
||||
if($player->isSurvival()){
|
||||
$item->setCount($item->getCount() - 1);
|
||||
$player->getInventory()->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$items = [[Item::FLOWER_POT, 0, 1]];
|
||||
$tile = $this->getLevel()->getTile($this);
|
||||
if($tile instanceof TileFlowerPot){
|
||||
if(($item = $tile->getItem())->getId() !== Item::AIR){
|
||||
$items[] = [$item->getId(), $item->getDamage(), 1];
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
}
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class GlassPane extends Thin{
|
||||
|
@ -22,7 +22,7 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
class GlowingObsidian extends Solid{
|
||||
class GlowingObsidian extends Transparent{
|
||||
|
||||
protected $id = self::GLOWING_OBSIDIAN;
|
||||
|
||||
|
@ -21,14 +21,10 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
|
||||
|
||||
class GrassPath extends Transparent{
|
||||
|
||||
protected $id = self::GRASS_PATH;
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class HardenedClay extends Solid{
|
||||
|
@ -21,28 +21,11 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class JungleWoodStairs extends Stair{
|
||||
class JungleWoodStairs extends WoodStairs{
|
||||
|
||||
protected $id = self::JUNGLE_WOOD_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Jungle Wood Stairs";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class Lever extends Solid {
|
||||
class Lever extends Solid{
|
||||
|
||||
protected $id = self::LEVER;
|
||||
protected $id = self::LEVER;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Lever";
|
||||
}
|
||||
public function getName(){
|
||||
return "Lever";
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class LitRedstoneLamp extends Solid {
|
||||
class LitRedstoneLamp extends Solid{
|
||||
|
||||
protected $id = self::LIT_REDSTONE_LAMP;
|
||||
protected $id = self::LIT_REDSTONE_LAMP;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Lit Redstone Lamp";
|
||||
}
|
||||
public function getName(){
|
||||
return "Lit Redstone Lamp";
|
||||
}
|
||||
}
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class LitRedstoneTorch extends Solid {
|
||||
class LitRedstoneTorch extends Solid{
|
||||
|
||||
protected $id = self::REDSTONE_TORCH;
|
||||
protected $id = self::REDSTONE_TORCH;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Lit Redstone Torch";
|
||||
}
|
||||
public function getName(){
|
||||
return "Lit Redstone Torch";
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,9 @@ use pocketmine\tile\Spawnable;
|
||||
use pocketmine\tile\Tile;
|
||||
|
||||
class MobHead extends Solid{
|
||||
protected $id = self::MOB_HEAD;
|
||||
|
||||
protected $id = self::MOB_HEAD_BLOCK;
|
||||
|
||||
protected $type;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
@ -59,7 +61,7 @@ class MobHead extends Solid{
|
||||
$nbt = new CompoundTag("", [
|
||||
new StringTag("id", Tile::SKULL),
|
||||
new ByteTag("SkullType", $item->getDamage()),
|
||||
new ByteTag("Rot", $rot),
|
||||
new ByteTag("Rot", $rot),
|
||||
new IntTag("x", (int) $this->x),
|
||||
new IntTag("y", (int) $this->y),
|
||||
new IntTag("z", (int) $this->z)
|
||||
|
@ -23,20 +23,19 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class NetherBrickFence extends Transparent {
|
||||
class NetherBrickFence extends Transparent{
|
||||
|
||||
protected $id = self::NETHER_BRICK_FENCE;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
if ($item instanceof Air){
|
||||
if($item instanceof Air){
|
||||
//Breaking by hand
|
||||
return 10;
|
||||
}
|
||||
else{
|
||||
}else{
|
||||
// Other breaktimes are equal to woodfences.
|
||||
return parent::getBreakTime($item);
|
||||
}
|
||||
@ -45,18 +44,17 @@ class NetherBrickFence extends Transparent {
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
return "Nether Brick Fence";
|
||||
}
|
||||
|
||||
|
||||
public function canConnect(Block $block){
|
||||
//TODO: activate comments when the NetherBrickFenceGate class has been created.
|
||||
return ($block instanceof NetherBrickFence /* or $block instanceof NetherBrickFenceGate */) ? true : $block->isSolid() and !$block->isTransparent();
|
||||
return ($block instanceof NetherBrickFence) or ($block->isSolid() and !$block->isTransparent());
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
@ -67,5 +65,5 @@ class NetherBrickFence extends Transparent {
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class NetherBrickStairs extends Stair{
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class NoteBlock extends Solid {
|
||||
class NoteBlock extends Solid{
|
||||
|
||||
protected $id = self::NOTE_BLOCK;
|
||||
protected $id = self::NOTE_BLOCK;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Note Block";
|
||||
}
|
||||
public function getName(){
|
||||
return "Note Block";
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class PackedIce extends Solid{
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Planks extends Solid{
|
||||
|
@ -21,14 +21,14 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class PoweredRail extends Solid {
|
||||
protected $id = self::POWERED_RAIL;
|
||||
class PoweredRail extends Solid{
|
||||
protected $id = self::POWERED_RAIL;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Powered Rail";
|
||||
}
|
||||
public function getName(){
|
||||
return "Powered Rail";
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class Quartz extends Solid{
|
||||
const QUARTZ_CHISELED = 1;
|
||||
const QUARTZ_PILLAR = 2;
|
||||
const QUARTZ_PILLAR2 = 3;
|
||||
|
||||
|
||||
protected $id = self::QUARTZ_BLOCK;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class QuartzStairs extends Stair{
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class Rail extends Solid {
|
||||
class Rail extends Solid{
|
||||
|
||||
protected $id = self::RAIL;
|
||||
protected $id = self::RAIL;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Rail";
|
||||
}
|
||||
public function getName(){
|
||||
return "Rail";
|
||||
}
|
||||
}
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class RedstoneLamp extends Solid {
|
||||
class RedstoneLamp extends Solid{
|
||||
|
||||
protected $id = self::REDSTONE_LAMP;
|
||||
protected $id = self::REDSTONE_LAMP;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Redstone Lamp";
|
||||
}
|
||||
public function getName(){
|
||||
return "Redstone Lamp";
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\Player;
|
||||
|
||||
class RedstoneOre extends Solid{
|
||||
|
||||
@ -41,6 +42,10 @@ class RedstoneOre extends Solid{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
return $this->getLevel()->setBlock($this, $this, true, false);
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL or $type === Level::BLOCK_UPDATE_TOUCH){
|
||||
$this->getLevel()->setBlock($this, Block::get(Item::GLOWING_REDSTONE_ORE, $this->meta));
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class RedstoneTorch extends Solid {
|
||||
class RedstoneTorch extends Solid{
|
||||
|
||||
protected $id = self::REDSTONE_TORCH;
|
||||
protected $id = self::REDSTONE_TORCH;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Redstone Torch";
|
||||
}
|
||||
public function getName(){
|
||||
return "Redstone Torch";
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Sand extends Fallable{
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class SandstoneStairs extends Stair{
|
||||
|
@ -24,7 +24,12 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\tile\Tile;
|
||||
|
||||
class SignPost extends Transparent{
|
||||
|
||||
@ -53,17 +58,38 @@ class SignPost extends Transparent{
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
if($face !== 0){
|
||||
if($face === 1){
|
||||
$this->meta = floor((($player->yaw + 180) * 16 / 360) + 0.5) & 0x0F;
|
||||
$this->getLevel()->setBlock($block, Block::get(Item::SIGN_POST, $this->meta), true);
|
||||
$nbt = new CompoundTag("", [
|
||||
"id" => new StringTag("id", Tile::SIGN),
|
||||
"x" => new IntTag("x", $block->x),
|
||||
"y" => new IntTag("y", $block->y),
|
||||
"z" => new IntTag("z", $block->z),
|
||||
"Text1" => new StringTag("Text1", ""),
|
||||
"Text2" => new StringTag("Text2", ""),
|
||||
"Text3" => new StringTag("Text3", ""),
|
||||
"Text4" => new StringTag("Text4", "")
|
||||
]);
|
||||
|
||||
return true;
|
||||
if($player !== null){
|
||||
$nbt->Creator = new StringTag("Creator", $player->getRawUniqueId());
|
||||
}
|
||||
|
||||
if($item->hasCustomBlockData()){
|
||||
foreach($item->getCustomBlockData() as $key => $v){
|
||||
$nbt->{$key} = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if($face === 1){
|
||||
$this->meta = floor((($player->yaw + 180) * 16 / 360) + 0.5) & 0x0f;
|
||||
$this->getLevel()->setBlock($block, $this, true);
|
||||
}else{
|
||||
$this->meta = $face;
|
||||
$this->getLevel()->setBlock($block, Block::get(Item::WALL_SIGN, $this->meta), true);
|
||||
|
||||
return true;
|
||||
$this->getLevel()->setBlock($block, new WallSign($this->meta), true);
|
||||
}
|
||||
|
||||
Tile::createTile(Tile::SIGN, $this->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -71,7 +97,7 @@ class SignPost extends Transparent{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->getId() === self::AIR){
|
||||
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
@ -81,12 +107,6 @@ class SignPost extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onBreak(Item $item){
|
||||
$this->getLevel()->setBlock($this, new Air(), true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[Item::SIGN, 0, 1],
|
||||
|
@ -143,7 +143,6 @@ class Slab extends Transparent{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Snow extends Solid{
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
|
||||
|
@ -21,28 +21,11 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class SpruceWoodStairs extends Stair{
|
||||
class SpruceWoodStairs extends WoodStairs{
|
||||
|
||||
protected $id = self::SPRUCE_WOOD_STAIRS;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Spruce Wood Stairs";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class StainedClay extends Solid{
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class StoneBrickStairs extends Stair{
|
||||
|
@ -53,7 +53,7 @@ class StoneBricks extends Solid{
|
||||
];
|
||||
return $names[$this->meta & 0x03];
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item){
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class StoneButton extends Solid {
|
||||
class StoneButton extends Solid{
|
||||
|
||||
protected $id = self::STONE_BUTTON;
|
||||
protected $id = self::STONE_BUTTON;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Stone Button";
|
||||
}
|
||||
public function getName(){
|
||||
return "Stone Button";
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class StonePressurePlate extends Solid {
|
||||
class StonePressurePlate extends Solid{
|
||||
|
||||
protected $id = self::STONE_PRESSURE_PLATE;
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
|
@ -23,7 +23,6 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\Player;
|
||||
|
||||
//TODO: check orientation
|
||||
class Stonecutter extends Solid{
|
||||
@ -42,18 +41,6 @@ class Stonecutter extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($player instanceof Player){
|
||||
$player->craftingType = 2;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
|
@ -26,8 +26,8 @@ use pocketmine\item\Item;
|
||||
use pocketmine\nbt\tag\ByteTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\DoubleTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\utils\Random;
|
||||
|
||||
|
@ -46,7 +46,7 @@ class TallGrass extends Flowable{
|
||||
];
|
||||
return $names[$this->meta & 0x03];
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getId() === self::GRASS){
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
|
||||
abstract class Thin extends Transparent{
|
||||
|
@ -23,8 +23,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\level\sound\DoorSound;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\Player;
|
||||
|
||||
class Trapdoor extends Transparent{
|
||||
@ -126,24 +126,20 @@ class Trapdoor extends Transparent{
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
if(($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1){
|
||||
$faces = [
|
||||
self::SIDE_SOUTH => self::MASK_SIDE_SOUTH,
|
||||
self::SIDE_NORTH => self::MASK_SIDE_NORTH,
|
||||
self::SIDE_EAST => self::MASK_SIDE_EAST,
|
||||
self::SIDE_WEST => self::MASK_SIDE_WEST,
|
||||
];
|
||||
echo $face, PHP_EOL, $faces[$face], PHP_EOL;
|
||||
$this->meta = $faces[$face] & self::MASK_SIDE;
|
||||
if($fy > 0.5){
|
||||
$this->meta |= self::MASK_UPPER;
|
||||
}
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
||||
return true;
|
||||
$directions = [
|
||||
0 => 1,
|
||||
1 => 3,
|
||||
2 => 0,
|
||||
3 => 2
|
||||
];
|
||||
if($player !== null){
|
||||
$this->meta = $directions[$player->getDirection() & 0x03];
|
||||
}
|
||||
|
||||
return false;
|
||||
if(($fy > 0.5 and $face !== self::SIDE_UP) or $face === self::SIDE_DOWN){
|
||||
$this->meta |= self::MASK_UPPER; //top half of block
|
||||
}
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -21,161 +21,13 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\Enum;
|
||||
use pocketmine\nbt\tag\Int as IntTag;
|
||||
use pocketmine\nbt\tag\String as StringTag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\tile\Chest as TileChest;
|
||||
use pocketmine\tile\Tile;
|
||||
class TrappedChest extends Chest{
|
||||
|
||||
class TrappedChest extends Transparent{
|
||||
//TODO: Redstone!
|
||||
|
||||
protected $id = self::CHEST;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2.5;
|
||||
}
|
||||
protected $id = self::TRAPPED_CHEST;
|
||||
|
||||
public function getName(){
|
||||
return "Trapped Chest";
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
$this->x + 0.0625,
|
||||
$this->y,
|
||||
$this->z + 0.0625,
|
||||
$this->x + 0.9375,
|
||||
$this->y + 0.9475,
|
||||
$this->z + 0.9375
|
||||
);
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$faces = [
|
||||
0 => 4,
|
||||
1 => 2,
|
||||
2 => 5,
|
||||
3 => 3,
|
||||
];
|
||||
|
||||
$chest = null;
|
||||
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
|
||||
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){
|
||||
continue;
|
||||
}elseif(($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)){
|
||||
continue;
|
||||
}
|
||||
$c = $this->getSide($side);
|
||||
if($c instanceof Chest and $c->getDamage() === $this->meta){
|
||||
$tile = $this->getLevel()->getTile($c);
|
||||
if($tile instanceof TileChest and !$tile->isPaired()){
|
||||
$chest = $tile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
$nbt = new CompoundTag("", [
|
||||
new Enum("Items", []),
|
||||
new StringTag("id", Tile::CHEST),
|
||||
new IntTag("x", $this->x),
|
||||
new IntTag("y", $this->y),
|
||||
new IntTag("z", $this->z)
|
||||
]);
|
||||
$nbt->Items->setTagType(NBT::TAG_Compound);
|
||||
|
||||
if($item->hasCustomName()){
|
||||
$nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
|
||||
}
|
||||
|
||||
if($item->hasCustomBlockData()){
|
||||
foreach($item->getCustomBlockData() as $key => $v){
|
||||
$nbt->{$key} = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||
|
||||
if($chest instanceof TileChest and $tile instanceof TileChest){
|
||||
$chest->pairWith($tile);
|
||||
$tile->pairWith($chest);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onBreak(Item $item){
|
||||
$t = $this->getLevel()->getTile($this);
|
||||
if($t instanceof TileChest){
|
||||
$t->unpair();
|
||||
}
|
||||
$this->getLevel()->setBlock($this, new Air(), true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($player instanceof Player){
|
||||
$top = $this->getSide(1);
|
||||
if($top->isTransparent() !== true){
|
||||
return true;
|
||||
}
|
||||
|
||||
$t = $this->getLevel()->getTile($this);
|
||||
$chest = null;
|
||||
if($t instanceof TileChest){
|
||||
$chest = $t;
|
||||
}else{
|
||||
$nbt = new CompoundTag("", [
|
||||
new Enum("Items", []),
|
||||
new StringTag("id", Tile::CHEST),
|
||||
new IntTag("x", $this->x),
|
||||
new IntTag("y", $this->y),
|
||||
new IntTag("z", $this->z)
|
||||
]);
|
||||
$nbt->Items->setTagType(NBT::TAG_Compound);
|
||||
$chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||
}
|
||||
|
||||
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof String){
|
||||
if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if($player->isCreative()){
|
||||
return true;
|
||||
}
|
||||
$player->addWindow($chest->getInventory());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class Tripwire extends Solid {
|
||||
class Tripwire extends Solid{
|
||||
|
||||
protected $id = self::TRIPWIRE;
|
||||
protected $id = self::TRIPWIRE;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Tripwire";
|
||||
}
|
||||
public function getName(){
|
||||
return "Tripwire";
|
||||
}
|
||||
}
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class TripwireHook extends Solid {
|
||||
class TripwireHook extends Solid{
|
||||
|
||||
protected $id = self::TRIPWIRE_HOOK;
|
||||
protected $id = self::TRIPWIRE_HOOK;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Tripwire Hook";
|
||||
}
|
||||
public function getName(){
|
||||
return "Tripwire Hook";
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\level\Level;
|
||||
|
||||
class WallSign extends SignPost{
|
||||
@ -40,8 +39,8 @@ class WallSign extends SignPost{
|
||||
5 => 4,
|
||||
];
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if(isset($faces[$this->meta])) {
|
||||
if ($this->getSide($faces[$this->meta])->getId() === self::AIR) {
|
||||
if(isset($faces[$this->meta])){
|
||||
if($this->getSide($faces[$this->meta])->getId() === self::AIR){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
}
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
|
@ -21,9 +21,7 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Item;
|
||||
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -37,10 +35,6 @@ class WaterLily extends Flowable{
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function isSolid(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Lily Pad";
|
||||
}
|
||||
@ -49,18 +43,14 @@ class WaterLily extends Flowable{
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
public function canPassThrough(){
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->x + 0.0625,
|
||||
$this->y,
|
||||
$this->z,
|
||||
$this->x,
|
||||
$this->y + 0.0625,
|
||||
$this->z
|
||||
$this->z + 0.0625,
|
||||
$this->x + 0.9375,
|
||||
$this->y + 0.015625,
|
||||
$this->z + 0.9375
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class WeightedPressurePlateHeavy extends Solid {
|
||||
class WeightedPressurePlateHeavy extends Solid{
|
||||
|
||||
protected $id = self::WEIGHTED_PRESSURE_PLATE_HEAVY;
|
||||
protected $id = self::WEIGHTED_PRESSURE_PLATE_HEAVY;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Weighted Pressure Plate Heavy";
|
||||
}
|
||||
public function getName(){
|
||||
return "Weighted Pressure Plate Heavy";
|
||||
}
|
||||
}
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class WeightedPressurePlateLight extends Solid {
|
||||
class WeightedPressurePlateLight extends Solid{
|
||||
|
||||
protected $id = self::WEIGHTED_PRESSURE_PLATE_LIGHT;
|
||||
protected $id = self::WEIGHTED_PRESSURE_PLATE_LIGHT;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Weighted Pressure Plate Light";
|
||||
}
|
||||
public function getName(){
|
||||
return "Weighted Pressure Plate Light";
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,8 @@ class Wood2 extends Wood{
|
||||
static $names = [
|
||||
0 => "Acacia Wood",
|
||||
1 => "Dark Oak Wood",
|
||||
2 => ""
|
||||
2 => "Unknown",
|
||||
3 => "Unknown"
|
||||
];
|
||||
return $names[$this->meta & 0x03];
|
||||
}
|
||||
|
@ -36,6 +36,14 @@ class WoodStairs extends Stair{
|
||||
return "Wood Stairs";
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getResistance(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
@ -45,8 +53,4 @@ class WoodStairs extends Stair{
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 2;
|
||||
}
|
||||
}
|
@ -21,15 +21,15 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class WoodenButton extends Solid {
|
||||
class WoodenButton extends Solid{
|
||||
|
||||
protected $id = self::WOODEN_BUTTON;
|
||||
protected $id = self::WOODEN_BUTTON;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Wooden Button";
|
||||
}
|
||||
public function getName(){
|
||||
return "Wooden Button";
|
||||
}
|
||||
}
|
||||
|
@ -22,10 +22,10 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
class WoodenPressurePlate extends Solid{
|
||||
|
||||
|
||||
protected $id = self::WOODEN_PRESSURE_PLATE;
|
||||
|
||||
public function __construct($meta = 0) {
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Wool extends Solid{
|
||||
|
@ -27,12 +27,18 @@ namespace pocketmine\command;
|
||||
use pocketmine\event\TextContainer;
|
||||
use pocketmine\event\TimingsHandler;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
abstract class Command{
|
||||
/** @var \stdClass */
|
||||
private static $defaultDataTemplate = null;
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
/** @var \stdClass */
|
||||
protected $commandData = null;
|
||||
|
||||
/** @var string */
|
||||
private $nextLabel;
|
||||
@ -75,16 +81,50 @@ abstract class Command{
|
||||
* @param string[] $aliases
|
||||
*/
|
||||
public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){
|
||||
$this->name = $name;
|
||||
$this->nextLabel = $name;
|
||||
$this->label = $name;
|
||||
$this->description = $description;
|
||||
$this->commandData = self::generateDefaultData();
|
||||
$this->name = $this->nextLabel = $this->label = $name;
|
||||
$this->setDescription($description);
|
||||
$this->usageMessage = $usageMessage === null ? "/" . $name : $usageMessage;
|
||||
$this->aliases = $aliases;
|
||||
$this->activeAliases = (array) $aliases;
|
||||
$this->setAliases($aliases);
|
||||
$this->timings = new TimingsHandler("** Command: " . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an \stdClass containing command data
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function getDefaultCommandData() : \stdClass{
|
||||
return $this->commandData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates modified command data for the specified player
|
||||
* for AvailableCommandsPacket.
|
||||
*
|
||||
* @param Player $player
|
||||
*
|
||||
* @return \stdClass|null
|
||||
*/
|
||||
public function generateCustomCommandData(Player $player){
|
||||
//TODO: fix command permission filtering on join
|
||||
/*if(!$this->testPermission($player)){
|
||||
return null;
|
||||
}*/
|
||||
$customData = clone $this->commandData;
|
||||
$customData->aliases = $this->getAliases();
|
||||
/*foreach($customData->overloads as &$overload){
|
||||
if(($p = @$overload->pocketminePermission) !== null and !$player->hasPermission($p)){
|
||||
unset($overload);
|
||||
}
|
||||
}*/
|
||||
return $customData;
|
||||
}
|
||||
|
||||
public function getOverloads(): \stdClass{
|
||||
return $this->commandData->overloads;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param string $commandLabel
|
||||
@ -105,14 +145,19 @@ abstract class Command{
|
||||
* @return string
|
||||
*/
|
||||
public function getPermission(){
|
||||
return $this->permission;
|
||||
return $this->commandData->pocketminePermission ?? null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string|null $permission
|
||||
*/
|
||||
public function setPermission($permission){
|
||||
$this->permission = $permission;
|
||||
if($permission !== null){
|
||||
$this->commandData->pocketminePermission = $permission;
|
||||
}else{
|
||||
unset($this->commandData->pocketminePermission);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +173,7 @@ abstract class Command{
|
||||
if($this->permissionMessage === null){
|
||||
$target->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));
|
||||
}elseif($this->permissionMessage !== ""){
|
||||
$target->sendMessage(str_replace("<permission>", $this->permission, $this->permissionMessage));
|
||||
$target->sendMessage(str_replace("<permission>", $this->getPermission(), $this->permissionMessage));
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -140,11 +185,11 @@ abstract class Command{
|
||||
* @return bool
|
||||
*/
|
||||
public function testPermissionSilent(CommandSender $target){
|
||||
if($this->permission === null or $this->permission === ""){
|
||||
if(($perm = $this->getPermission()) === null or $perm === ""){
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach(explode(";", $this->permission) as $permission){
|
||||
foreach(explode(";", $perm) as $permission){
|
||||
if($target->hasPermission($permission)){
|
||||
return true;
|
||||
}
|
||||
@ -197,7 +242,7 @@ abstract class Command{
|
||||
public function unregister(CommandMap $commandMap){
|
||||
if($this->allowChangesFrom($commandMap)){
|
||||
$this->commandMap = null;
|
||||
$this->activeAliases = $this->aliases;
|
||||
$this->activeAliases = $this->commandData->aliases;
|
||||
$this->label = $this->nextLabel;
|
||||
|
||||
return true;
|
||||
@ -240,7 +285,7 @@ abstract class Command{
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(){
|
||||
return $this->description;
|
||||
return $this->commandData->description;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -254,7 +299,7 @@ abstract class Command{
|
||||
* @param string[] $aliases
|
||||
*/
|
||||
public function setAliases(array $aliases){
|
||||
$this->aliases = $aliases;
|
||||
$this->commandData->aliases = $aliases;
|
||||
if(!$this->isRegistered()){
|
||||
$this->activeAliases = (array) $aliases;
|
||||
}
|
||||
@ -264,7 +309,7 @@ abstract class Command{
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription($description){
|
||||
$this->description = $description;
|
||||
$this->commandData->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -281,6 +326,13 @@ abstract class Command{
|
||||
$this->usageMessage = $usage;
|
||||
}
|
||||
|
||||
public static final function generateDefaultData() : \stdClass{
|
||||
if(self::$defaultDataTemplate === null){
|
||||
self::$defaultDataTemplate = json_decode(file_get_contents(Server::getInstance()->getFilePath() . "src/pocketmine/resources/command_default.json"));
|
||||
}
|
||||
return clone self::$defaultDataTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandSender $source
|
||||
* @param string $message
|
||||
@ -289,7 +341,7 @@ abstract class Command{
|
||||
public static function broadcastCommandMessage(CommandSender $source, $message, $sendToSource = true){
|
||||
if($message instanceof TextContainer){
|
||||
$m = clone $message;
|
||||
$result = "[".$source->getName().": ".($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ? "%" : "") . $m->getText() ."]";
|
||||
$result = "[" . $source->getName() . ": " . ($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ? "%" : "") . $m->getText() . "]";
|
||||
|
||||
$users = $source->getServer()->getPluginManager()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_ADMINISTRATIVE);
|
||||
$colored = TextFormat::GRAY . TextFormat::ITALIC . $result;
|
||||
|
@ -31,6 +31,8 @@ class CommandReader extends Thread{
|
||||
|
||||
public function __construct(){
|
||||
$this->buffer = new \Threaded;
|
||||
$opts = getopt("", ["disable-readline"]);
|
||||
$this->readline = (extension_loaded("readline") and !isset($opts["disable-readline"]));
|
||||
$this->start();
|
||||
}
|
||||
|
||||
@ -71,14 +73,10 @@ class CommandReader extends Thread{
|
||||
}
|
||||
|
||||
public function run(){
|
||||
$opts = getopt("", ["disable-readline"]);
|
||||
if(extension_loaded("readline") and !isset($opts["disable-readline"])){
|
||||
$this->readline = true;
|
||||
}else{
|
||||
if(!$this->readline){
|
||||
global $stdin;
|
||||
$stdin = fopen("php://stdin", "r");
|
||||
stream_set_blocking($stdin, 0);
|
||||
$this->readline = false;
|
||||
}
|
||||
|
||||
$lastLine = microtime(true);
|
||||
|
@ -23,7 +23,6 @@ namespace pocketmine\command;
|
||||
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
class FormattedCommandAlias extends Command{
|
||||
|
@ -24,7 +24,6 @@ namespace pocketmine\command;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\plugin\Plugin;
|
||||
|
||||
|
||||
class PluginCommand extends Command implements PluginIdentifiableCommand{
|
||||
|
||||
/** @var Plugin */
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\command;
|
||||
|
||||
|
||||
use pocketmine\event\TextContainer;
|
||||
|
||||
class RemoteConsoleCommandSender extends ConsoleCommandSender{
|
||||
|
@ -62,7 +62,6 @@ use pocketmine\command\defaults\VersionCommand;
|
||||
use pocketmine\command\defaults\WhitelistCommand;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
class SimpleCommandMap implements CommandMap{
|
||||
|
@ -26,7 +26,6 @@ use pocketmine\command\CommandSender;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\Player;
|
||||
|
||||
|
||||
class BanCommand extends VanillaCommand{
|
||||
|
||||
public function __construct($name){
|
||||
|
@ -26,7 +26,6 @@ use pocketmine\command\CommandSender;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\Player;
|
||||
|
||||
|
||||
class BanIpCommand extends VanillaCommand{
|
||||
|
||||
public function __construct($name){
|
||||
|
@ -24,7 +24,6 @@ namespace pocketmine\command\defaults;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
|
||||
|
||||
class BanListCommand extends VanillaCommand{
|
||||
|
||||
public function __construct($name){
|
||||
|
@ -25,7 +25,6 @@ use pocketmine\command\CommandSender;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\Server;
|
||||
|
||||
|
||||
class DefaultGamemodeCommand extends VanillaCommand{
|
||||
|
||||
public function __construct($name){
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user