Compare commits

..

403 Commits

Author SHA1 Message Date
13e4772f98 Release 3.11.5 2020-02-02 18:31:51 +00:00
4bc2f28c6d Provide a ChunkUtils stub for PHPStan, so it doesn't get confused when the extension is loaded
for some reason the presence of the type problems were reported as
problems on ChunkUtils.php, despite being outside of the project scope
and the errors not applying to the polyfill.
2020-02-02 18:12:41 +00:00
663469dfa7 travis: remove xdebug to improve build time
xdebug is almost completely useless here.
2020-02-02 16:30:00 +00:00
963abb718f build/server-phar: compress using gzip (except stub)
this produces a 75% reduction in phar size, at the expense of a slight degradation of autoloading speed and needing a writable tmpdir.
2020-02-02 16:27:38 +00:00
1f2fb73297 updated DevTools submodule to 1.14.0 2020-02-02 10:21:32 +00:00
ff55b520b9 updated composer dependencies 2020-02-01 22:55:27 +00:00
cedd8abf0c README: no need to specify 'community' Discord [ci skip] 2020-02-01 22:19:24 +00:00
496732999c reintroduce BedrockData submodule 2020-02-01 22:05:07 +00:00
6a8105f5a0 delete BedrockData submodule 2020-02-01 22:01:22 +00:00
0a566f8218 LevelProvider::generate() accepts class-string<Generator>, not any
string
2020-02-01 20:16:05 +00:00
829dd02eea Server: fixed more bad non-nullable phpdocs 2020-02-01 19:30:47 +00:00
b11c350b2b composer: use new pocketmine/log & pocketmine/classloader classes 2020-01-31 15:51:26 +00:00
f624e36faf composer: all of these packages are now available on packagist 2020-01-31 15:49:33 +00:00
14ce9c10bb BUILDING.md: fix typo 2020-01-31 13:27:29 +00:00
b27aaaeeb2 added build instructions, close #2839 2020-01-31 11:32:28 +00:00
f1083bd9c4 SimpleCommandMap: beware case mismatches in alias recursion, closes #3281 2020-01-31 10:36:47 +00:00
199fa61aef update composer dependencies 2020-01-30 22:41:58 +00:00
af82a6bbe1 phpstan: enable checkMissingIterableValueType 2020-01-30 22:31:42 +00:00
004f7ef82e phpstan: stub out the iterable bullshit with pthreads
this isn't a perfect fix, but it's better than it whining about all the things.
2020-01-30 22:31:15 +00:00
89ebd2b880 remove some dead ignoreErrors 2020-01-30 22:30:04 +00:00
799183e13e make use of phpstan class-string in some areas 2020-01-30 22:23:11 +00:00
260ac47588 add some phpstan array types 2020-01-30 22:23:11 +00:00
4ff4434a22 build/server-phar: mark metadata as mixed[] 2020-01-30 21:49:52 +00:00
5d8bb84269 add more mixed[] to item namespace 2020-01-30 21:48:11 +00:00
9eebfa7cc3 populate missing array value types in root namespace 2020-01-30 21:43:00 +00:00
d3021c6281 populate missing array value types in utils namespace, pass 2 2020-01-30 21:39:15 +00:00
9097d6c4d3 AutoUpdater: fixed type doc for updateInfo 2020-01-30 21:34:26 +00:00
da43ae82fe populate missing array value types in utils namespace, pass 1 2020-01-30 21:30:01 +00:00
60b405d944 populate missing array value types in updater namespace 2020-01-30 21:23:05 +00:00
92a752053d populate missing array value types in tile namespace 2020-01-30 21:20:42 +00:00
0537c66849 populate missing array value types in scheduler namespace 2020-01-30 21:19:15 +00:00
d94995e161 populate missing array value types in plugin namespace 2020-01-30 21:17:13 +00:00
58bc08838b populate missing array value types in permission namespace 2020-01-30 21:14:18 +00:00
fc0619ee6e populate missing array value types in network namespace 2020-01-30 21:12:00 +00:00
a5764b3ae9 populate missing array value types in level namespace 2020-01-30 21:01:59 +00:00
8bf469f7fc populate missing array value types in lang namespace 2020-01-30 20:55:03 +00:00
3b9a5c5ccc populate missing array value types in item namespace 2020-01-30 20:54:38 +00:00
4c36ca58e2 populate missing array value types in inventory namespace 2020-01-30 20:53:41 +00:00
a67fa5c007 populate missing array value types in event namespace 2020-01-30 20:52:54 +00:00
839a789180 populate missing array value types in entity namespace 2020-01-30 20:50:24 +00:00
e61c3e8bf6 populate missing array value types in command namespace 2020-01-30 20:48:14 +00:00
7ce6c8aa13 TimingsCommand: fix confusing indentation 2020-01-30 20:47:33 +00:00
9abcc99c10 Command: fixed spacing of phpdoc on execute() 2020-01-30 20:46:25 +00:00
5c8a625d88 populate missing iterable value types in block namespace 2020-01-30 20:43:13 +00:00
259f0425a9 ClientboundMapItemDataPacket: replace assoc array with MapDecoration class
I thought I'd done this already, but it appears not.
2020-01-30 20:05:18 +00:00
9cdea43794 provide more array type information for Internet functions 2020-01-29 20:45:03 +00:00
e007fad5b8 fix return types for Utils/Internet getURL()/postURL() 2020-01-29 20:43:09 +00:00
5cf2fcbbb7 simpleCurl() second return value is string[][], not string[] 2020-01-29 20:38:19 +00:00
9e6cbb5b6a Internet: fix type information for getURL(), postURL() and simpleCurl() 2020-01-29 20:20:52 +00:00
64b3d02974 Chunk: remove useless condition from populateSkyLight()
this was detected by latest bleeding-edge PHPStan.
2020-01-29 16:42:42 +00:00
640df1003c add some Generator generics for PHPStan 2020-01-29 16:38:50 +00:00
2b402e525a add some PHPStan-specific callable prototypes 2020-01-29 15:03:55 +00:00
e2871fad8e composer.json: move require-dev next to require 2020-01-28 14:32:55 +00:00
41d02003c2 Install PHPStan and PHPUnit via dev dependencies 2020-01-27 12:04:42 +00:00
156ecd9bd8 travis: use phpstan 0.12.8 2020-01-27 09:31:27 +00:00
fa7736efbb phpstan 0.12.7 2020-01-25 17:16:14 +00:00
d71a7ff2fa travis.sh: fix indentation 2020-01-25 17:15:37 +00:00
8184a6b114 SkinImage: enforce that height/width must be positive 2020-01-22 14:58:36 +00:00
b8d44ff162 SkinImage: fix formatting error 2020-01-22 14:58:00 +00:00
f6611a38bc Explosion: fix trailing whitespace in explodeA() phpdoc 2020-01-22 14:51:49 +00:00
24ed823d96 WritableBook: remove extra line from phpdoc on setPages() 2020-01-22 14:51:14 +00:00
f624871b3f strip extra blank lines (php-cs-fixer) 2020-01-22 14:50:29 +00:00
9cd6b3e1c7 fix remaining multiline @var annotations 2020-01-22 14:44:36 +00:00
aad1eb5b3e CoreConstants: fix EOF newline 2020-01-22 14:40:03 +00:00
bff5bf25ae LegacySkinAdapter: make resource patch validity check more robust 2020-01-22 14:36:40 +00:00
cda90fd7f1 Merge pull request #3280 from pmmp/stable-phpdoc-armageddon
Mass-removal of redundant @param / @return PhpDoc annotations
2020-01-22 10:48:50 +00:00
9f44adf04a pass 2, manual removal of incorrect non-nullable @param for nullable native types 2020-01-21 15:44:34 +00:00
c4793241f5 Mass removal of useless @param/@return PHPDoc annotations, pass 1 2020-01-21 15:10:18 +00:00
7532c609fb 3.11.5 is next 2020-01-20 18:06:46 +00:00
13f28d8454 Release 3.11.4 2020-01-20 18:06:46 +00:00
5a97c378fc phpstan: green on level 6, minus iterable types
iterable types are a big pain in the ass because of pthreads' awful architecture, and there's nothing I can do about that without BC-breaking changes to pthreads.
2020-01-20 17:54:55 +00:00
e5d62ec901 phpstan 0.12.6 2020-01-20 17:26:48 +00:00
cfd975009e Leaves: fix decay performance issue
this code was written with references in mind, but it looks like someone forgot the reference.
2020-01-20 11:52:11 +00:00
73257ffde7 updated pocketmine/spl dependency 2020-01-19 19:50:20 +00:00
8252bea699 phpstan: enable MissingMethodReturnTypehintRule
this was a bitch of a job, but it's one step closer to bypassing level 6.
2020-01-19 19:43:52 +00:00
ea935a1af5 pocketmine root: sweep missing return type information 2020-01-19 19:40:01 +00:00
e8a5fa8a37 updater: populate missing return type information 2020-01-19 19:38:41 +00:00
db734675d8 level: populate missing interface return types 2020-01-19 19:38:09 +00:00
6ede56015d level/biome: populate missing return type information 2020-01-19 19:37:08 +00:00
5334099fbf level/format: populate missing return type information 2020-01-19 19:36:34 +00:00
82e9072223 level/format/io: populate missing return type information 2020-01-19 19:35:45 +00:00
2c11742f9e Player: populate missing type information 2020-01-19 19:16:38 +00:00
bd4a63b668 Server: populate missing return type information 2020-01-19 19:09:08 +00:00
cd36af46bf Level: populate missing type information 2020-01-19 18:44:41 +00:00
aa7d55e21d level/generator: populate missing return type information 2020-01-19 18:07:54 +00:00
31e8efa6d1 level/light: populate missing return type information 2020-01-19 18:06:31 +00:00
facca13139 permission: populate missing return type information
PermissibleBase has some redundant phpdoc removed so that the Permissible interface can provide return types.
2020-01-19 17:23:52 +00:00
fffeeddca6 DataPacket: add magic method return types to keep phpstan happy
this really shouldn't be necessary, but it is what it is.
2020-01-19 17:14:34 +00:00
e6ba3ce8a6 item: populate missing return type information 2020-01-19 17:13:33 +00:00
11cae2f0c0 timings: populate missing return type information 2020-01-19 17:12:13 +00:00
f5a18df835 scheduler: populate missing return type information 2020-01-19 17:11:12 +00:00
1cc7027f92 plugin: populate missing return type information 2020-01-19 17:09:33 +00:00
8776b71d63 tile: populate missing return type information 2020-01-19 17:08:40 +00:00
0b9d0f3cdc utils: populate missing return type information 2020-01-19 17:07:48 +00:00
e419d76367 metadata: populate missing return type information 2020-01-19 17:06:48 +00:00
36cde9f352 inventory: populate missing return type information 2020-01-19 17:05:31 +00:00
05c602a044 event: populate missing return type information 2020-01-19 17:05:01 +00:00
0db7e57a15 lang: populate missing return type information 2020-01-19 17:04:25 +00:00
205e47c0c4 entity: populate missing return type information 2020-01-19 17:03:54 +00:00
e328d00cca command: populate missing return type info 2020-01-19 17:02:55 +00:00
ccbcc14600 Block: populate missing return type info 2020-01-19 17:02:03 +00:00
e544bc0d4b Item: added missing return type info for clearCustomBlockData() 2020-01-18 20:11:47 +00:00
fd27227cc7 Item: fix @return annotations for fluent methods (needed for correct auto complete) 2020-01-18 20:10:46 +00:00
b42966f61b network: explicitly specify @return void 2020-01-18 19:35:01 +00:00
ca86ec2ec2 Network: added missing return type information for getUpload() and getDownload() 2020-01-18 19:33:27 +00:00
97b6183404 PermissionManager: add native return types to private functions 2020-01-18 17:59:10 +00:00
0587d03c03 PluginDescription: add native return types to private functions 2020-01-18 17:57:24 +00:00
c7f1b605f2 PluginBase: remove useless duplicate doc comment from onLoad() stub 2020-01-18 17:56:44 +00:00
f069df65a8 PermissibleBase: added native returm types to private functions 2020-01-18 17:54:13 +00:00
1e624e7bb9 Attribute: add missing @return $this annotations 2020-01-18 17:50:58 +00:00
f16a530849 MainLogger: add native return types to private functions 2020-01-18 17:47:38 +00:00
7137b8a8a4 Config: added native void return types to private functions 2020-01-18 17:46:25 +00:00
ab57914322 CraftingDataPacket: added native return typehints to private methods 2020-01-18 17:45:15 +00:00
260869c0d5 Position: populate missing return type information for fromObject() 2020-01-18 17:44:14 +00:00
9135877da1 SetupWizard: add native void typehints to private methods 2020-01-18 17:39:06 +00:00
07cb603231 Liquid: add missing return type to getFluidHeightPercent() 2020-01-17 13:58:54 +00:00
f59094e6d6 Fence: add missing return type to canConnect() 2020-01-17 13:58:29 +00:00
d8acae5495 Door: add missing return type to getFullDamage() 2020-01-17 13:57:56 +00:00
239fe909be CobblestoneWall: add missing return type for canConnect() 2020-01-17 13:57:29 +00:00
c22576a266 CrashDump: add void native return types to private methods 2020-01-17 13:55:38 +00:00
bac788fd00 Timezone: add missing return type for detectSystemTimezone() 2020-01-15 20:18:35 +00:00
f6d96c5827 DataPacket: clean() returns $this, not void 2020-01-14 17:30:48 +00:00
b1458db47b Revert "CraftingDataPacket: fixed trying to return void result of parent function"
This reverts commit e12ecaf629.
2020-01-14 17:16:17 +00:00
2d2c9379cd DataPacket: apply @return void annotations to make phpstan happy
this eliminates 250+ errors on level 6.
2020-01-14 15:39:07 +00:00
3400771770 DataPacket: add missing return type info for pid() 2020-01-14 15:38:24 +00:00
e12ecaf629 CraftingDataPacket: fixed trying to return void result of parent function 2020-01-14 15:37:06 +00:00
1303cbfe02 UUID: add some missing return type annotations 2020-01-14 15:35:46 +00:00
ad4a211cba Color: add missing return type annotation for fromABGR() 2020-01-14 15:35:14 +00:00
d1e56c4611 Location: add missing return types for getYaw() and getPitch() 2020-01-14 15:34:40 +00:00
d9bbab54f4 Entity: fixing position and velocity sync on start/stop movement, closes #3133
the delta for velocity sync is WAYYYYYY too big, but that's a task for another commit.
2020-01-14 13:08:38 +00:00
07cf4eb7a9 Revert "Create .sonarcloud.properties"
This reverts commit 50a7663369.
2020-01-13 21:46:38 -06:00
50a7663369 Create .sonarcloud.properties 2020-01-13 21:31:36 -06:00
651ef500a3 Make pocketmine\PATH and pocketmine\RESOURCE_PATH always available
these are non-dependent on environment, so they can be determined with no external input.
    This fixes 2 PHPStan issues, fixes some code that couldn't run outside of PM, and makes it easier to write code that depends on PM.
2020-01-13 10:55:54 +00:00
30f2e75278 phpstan 0.12.5 2020-01-12 16:57:43 +00:00
2cfc25b4f8 phpstan: enable checkGenericClassInNonGenericObjectType 2020-01-11 23:04:16 +00:00
5bded9cff8 AttributeMap: add phpstan generic parameters for ArrayAccess 2020-01-11 23:03:21 +00:00
5816ff85ba don't depend on phpstan 0.12.4 phpdoc inheriting
this causes build failure because the parameter names are different to
the base class.
2020-01-11 22:08:16 +00:00
8f7d8347ee update pocketmine/spl dependency 2020-01-11 22:05:37 +00:00
3614d9a78d phpstan: enable MissingMethodParameterTypehintRule 2020-01-11 21:54:42 +00:00
818d0e19ab RCONInstance: remove always-false branch (readPacket() never returns null) 2020-01-11 21:54:03 +00:00
17720041a3 phpdoc: populate missing parameter typeinfo 2020-01-11 21:53:24 +00:00
c329ff7d4f SubChunk: remove nonsensical reference from internal function 2020-01-11 21:49:33 +00:00
8794292788 remove &$var reference notations in phpdoc
this isn't required by the spec and PHPStan chokes on it. I was previously having it ignore these errors, but it turns out that PHPStan is not making use of extended typeinfo provided if it can't parse the tag, which is problematic on level 6 and also a problem for array-of-type. Therefore, we are going to have to take the hit.
2020-01-11 21:20:55 +00:00
0a39e580e9 MainLogger: log exception chains in logException(), closes #2447
this method is simpler than #2447 and easier to apply to stable.
2020-01-09 21:01:12 +00:00
c4580dd56d MainLogger: extract a printErrorMessage() function from logException() 2020-01-09 20:51:13 +00:00
fab81d28bc MainLogger: always log exceptions with CRITICAL level
if we reached this point, it's almost always due to a general exception handler which doesn't know what else to do with the error.
2020-01-09 20:44:21 +00:00
039478223e phpstan: enable MissingFunctionReturnTypehintRule 2020-01-09 20:14:15 +00:00
64b5db4bf2 bootstrap: add some @return annotations for phpstan 2020-01-09 20:13:53 +00:00
c85f4256c7 phpstan: enable MissingFunctionParameterTypehintRule 2020-01-09 20:10:15 +00:00
1192b8bdf1 bootstrap: add PhpDoc to critical_error to make phpstan happy
it wants phpdoc or typehints, and we can't provide typehints because bootstrap needs to be compatible with old PHP versions.
2020-01-09 20:09:33 +00:00
6dcd2a4ece phpstan: start phasing in some level 6 checks 2020-01-09 19:56:04 +00:00
3fff0a0656 BigTree: evict unmaintained dead code
phpstan whines about all this stuff, and everything left is private, so we can get rid of it. Sadly we can't ditch the class without breaking BC, so that sticks with 4.0.
2020-01-09 14:26:46 +00:00
e1e1bfa5e3 CompressBatchedTask: remove useless code causing build failure
assuming that pthreads does not have leak issues, this code is pointless, and if pthreads does have leak issues, this may not prevent them anyway.
2020-01-09 14:19:35 +00:00
1eedac87b2 added missing @var property types (reported by phpstan) 2020-01-09 14:13:54 +00:00
cda3e6f4dc PluginDescription: clean up type information for extensions field 2020-01-09 11:20:01 +00:00
e6a58e2690 format/leveldb: fix crash on truncated level.dat file 2020-01-08 09:55:03 +00:00
27350c4673 3.11.4 is next 2020-01-04 16:46:55 +00:00
0d5704b156 Release 3.11.3 2020-01-04 16:46:55 +00:00
f355044626 resources: do not remove client-side resource packs when forcing resources
I wanted to make this into a dedicated option, but it had some side effects (see 4794ba236a).
I'll settle for just disabling this useless behaviour, since we have other ways to force vanilla resources anyway; setting this flag to always-false has no user-facing effects anyway.
2020-01-04 16:14:08 +00:00
4794ba236a Revert "resource packs: added new option remove_client_resources, fixed client packs being removed when forcing resource pack download"
This reverts commit 06ec8b8397.

unfortunately, this had some unanticipated side effects, thanks to
idiotic behaviour in the client ... when having optional downloads but
trying to force resources, the client chokes because it thinks the
server is forcing it to apply a pack that it doesn't have. Since
there's no way to detect when this problem occurs in the protocol, the
only option is to revert this.
2020-01-04 16:04:07 +00:00
6490a49c70 tests: drop lint.sh - no longer needed now that we have PHPStan 2020-01-04 15:23:53 +00:00
5cd7e11b29 Use specialized build script for Travis 2020-01-04 15:15:01 +00:00
08e3b8ffdc build: added specialized script to create a server phar
this is much easier to use than devtools, and allows us to make additional specializations for PM build that would otherwise just be a colossal pain in the ass.
2020-01-04 14:56:53 +00:00
9232f4509c TimingsHandler: don't bail on redundant attempts to stop non-running timers
while it would be nice to bail, providing the environment to allow bailing without breaking stuff requires some complex changes that would reduce performance when timings is not running. Considering the limited usefulness of bailing here anyway, and the fact that it just has to be prevented to not have side effects, it doesn't make a whole lot of sense right now.

closes #3261, closes #3269, closes #3254
2020-01-04 14:44:55 +00:00
cef77907c6 Timings: fixed grandparent timers not working correctly, closes #3229 2020-01-04 13:23:04 +00:00
06ec8b8397 resource packs: added new option remove_client_resources, fixed client packs being removed when forcing resource pack download 2020-01-04 13:16:47 +00:00
ee08286eca moved git hash detection code to its own unit 2020-01-02 21:01:31 +00:00
a83211f96a VersionInfo: add strict_types to stop CS tools screwing with it 2020-01-02 20:05:50 +00:00
0b3c4ee496 bootstrap: don't choke on paths that have spaces in them 2019-12-30 11:58:44 +00:00
54de518634 bootstrap: fixed incorrect git hash detection when cwd is not the repo root 2019-12-30 09:09:47 +00:00
a908197907 Effect: document that duration is expected in ticks 2019-12-29 19:03:32 +00:00
3e23a568ca phpstan: properly fixing FPs on constant comparisons 2019-12-29 14:25:44 +00:00
dadc5c1b87 3.11.3 is next 2019-12-29 13:11:30 +00:00
a37d740111 Release 3.11.2 2019-12-29 13:11:30 +00:00
2de0ec02ba phpstan 0.12.3 2019-12-28 17:22:08 +00:00
d83820477f TimingsHandler: throw on attempt to stop timer that is not running
I do not think that this bug is in effect in the core code, but I can't be sure.
2019-12-21 13:17:40 +00:00
8726604899 Merge #3251: Remove usages of empty() 2019-12-19 11:08:08 +00:00
9cbe378e8c Timezone: fix possible crash on CentOS 2019-12-18 11:23:24 +00:00
494660102e Replace empty() usages with count() 2019-12-18 11:23:24 +00:00
216138a37e PlayerAuthInputPacket: Fix assigning variable in static context 2019-12-17 22:04:24 +08:00
b08c38f8f9 build/make-release: remove redundant require_once
this is included by vendor/autoload.php since 3.7.x.
2019-12-17 11:47:07 +00:00
911b6feaf9 NetworkInventoryAction: remove dead code
the trading & beacon types need to be checked as well, but I don't have the tools to check that right now.
2019-12-17 11:17:40 +00:00
2cb6990698 Enchantment: don't throw exceptions on out of range IDs
this function is used for data deserialization, and data may have bad enchantment IDs in it.
2019-12-14 10:04:51 +00:00
f7d66613df CompletedUsingItemPacket: added missing #include, closes #3219 2019-12-13 19:50:40 +00:00
95c32d26df Explosion: fixed ray trace getting stuck on a block when it encounters an empty subchunk
this might have caused unexpected behaviour in large caves.
2019-12-13 18:07:59 +00:00
9e1f6a2486 protocol: updated particle IDs 2019-12-13 10:52:09 +00:00
76994f15ac phpstan: green on level 5 2019-12-12 18:27:26 +00:00
cf73d74bd0 format/anvil: fixed possible type violation on saving chunk 2019-12-12 18:24:21 +00:00
37a8d95464 world IO: fixed crashes when garbage data found in tile/entity NBT data 2019-12-12 18:21:23 +00:00
9a4b72add5 PlayerInventory: fix type violation when calling equipItem() for non-Player holder 2019-12-12 16:31:22 +00:00
919534d978 EnderChest: fixed crash when plugins overwrite tile classes with incompatible ones
relates to 47a959dace
2019-12-12 16:28:30 +00:00
cb598155a4 Server: add @return annotation to crashDump() to make phpstan happy
this is technically a bug in PHPStan, but it's easier to do this than report a bug.
2019-12-12 16:19:57 +00:00
00888fdc55 TranslationContainer::__construct() accepts float and int too (they can be casted to string) 2019-12-12 16:19:04 +00:00
77795ae3bc BaseLang::translateString() accepts float and int too (they can be casted to string) 2019-12-12 16:18:11 +00:00
f39fc7e525 CompressBatchedTask::__construct() accepts Player[] not string[] 2019-12-12 16:16:48 +00:00
77f7595e0e Location::__construct() accepts floats for x,y,z 2019-12-12 16:16:16 +00:00
e8d3a25028 Position::__construct() accepts floats for x,y,z 2019-12-12 16:15:49 +00:00
1370930ea9 Entity: remove redundant defaults from lastX lastY lastZ, remove nullability
these fields are never null because they are initialized in the constructor, and they are never written to with null nor ever expected to be null.
2019-12-12 16:14:30 +00:00
70c3008b7b phpstan: green on level 4 2019-12-12 13:00:57 +00:00
46930b98b7 Timings: add a dedicated field for checking initialization 2019-12-12 12:59:01 +00:00
92be8c8ec0 PopulationTask: don't assume anything about TLS return values
while these SHOULD be what we say they are, it's possible for something else to overwrite them with junk and make the server catch fire.
2019-12-12 12:19:54 +00:00
62069bc7af Level: fix return type content doc comment for getAdjacentChunks() 2019-12-12 12:18:35 +00:00
26230c1f9b Player: don't report never-played for a disconnected player
this should catch fire like everything else does.
2019-12-12 12:17:52 +00:00
a9fafbc5eb BanEntry: remove nullable return from parseDate()
this function never returns null
2019-12-12 11:59:41 +00:00
b8778cb791 LevelProvider: fix doc comment of ::generate()
this raised false positives on phpstan level 4
2019-12-12 11:59:12 +00:00
73c5fe5cf9 BaseInventory: correctly annotate content type of slots field
fixes warnings on phpstan level 4
2019-12-12 11:58:11 +00:00
b3cfa5a3a0 TimingsHandler: use weak comparison for stopTiming start check
this could be an int or float, and 0 !== 0.0.
2019-12-12 11:48:34 +00:00
6127a02a8b phpstan 0.12.2 2019-12-12 10:43:45 +00:00
dbca36e5e2 SkinImage: throw on wrong data length 2019-12-11 22:45:14 +00:00
1171bae691 login: read the correct key SkinAnimationData 2019-12-11 22:40:05 +00:00
494f8e8251 login: fixed missing base64_decode() for animation images 2019-12-11 22:39:40 +00:00
3c9af56e06 3.11.2 is next 2019-12-11 20:20:26 +00:00
40a2211a5a Release 3.11.1 2019-12-11 20:20:26 +00:00
0196aa21d7 updated BedrockData submodule, close #3222, close #3223 2019-12-11 20:19:17 +00:00
833f3e574b 3.11.1 is next 2019-12-11 18:35:03 +00:00
a386ff8ce7 Release 3.11.0 2019-12-11 18:35:03 +00:00
e6c3b0fc0d Changes for 1.14
there are no protocol changes in 1.14 that matter; the reason the protocol version has been bumped is because of new blocks, items, mobs and recipes.
2019-12-11 18:32:22 +00:00
9568364277 fix minor formatting issue in SkinAdapterSingleton 2019-12-09 21:19:15 +00:00
73d4ff6b52 more missed function imports 2019-12-09 21:16:35 +00:00
7e98aa1497 leveldb: remove usage of multi-import statement
this doesn't conform to the code style.
2019-12-09 20:28:02 +00:00
f00c69c513 added missing function imports 2019-12-09 20:13:02 +00:00
50a4c42f3f NetworkBinaryStream: fix misplaced import 2019-12-09 19:53:32 +00:00
6b61efcfc8 remove unused imports 2019-12-09 19:49:21 +00:00
1a99938e4b LegacySkinAdapter: clean up nonsensical code ordering 2019-12-09 18:26:20 +00:00
a4d68fb32b LegacySkinAdapter: fix some wacky cape handling logic
I added checks for length validity locally and ran into some interesting behaviour because of this code.
2019-12-09 18:16:46 +00:00
5682cc8d53 3.10.2 is next 2019-12-07 16:41:41 +00:00
4eb59c0372 Release 3.10.1 2019-12-07 16:41:41 +00:00
3486db3f1b update RakLib to 0.12.6 2019-12-07 14:20:35 +00:00
733d530ed0 fixing EOF newlines on new files 2019-12-07 10:08:29 +00:00
c10ce84035 fix invisible legacy skins which have empty geometry names 2019-12-07 10:02:22 +00:00
82d9e481d2 3.10.1 is next 2019-12-06 20:53:15 +00:00
d27c7f7141 Release 3.10.0 2019-12-06 20:53:15 +00:00
394c999710 Merge branch 'drew-1.13' into stable 2019-12-06 20:38:49 +00:00
6399dacba7 Release 3.9.8 2019-12-06 20:33:51 +00:00
b6bbf655d7 InventoryTransactionPacket: fixed crafting flags being set on useless empty transactions
this fixes some misleading debug noise when getting stuff from creative inventory and triggers some different spam instead.
2019-12-06 20:08:09 +00:00
3d2c018442 BiomeDefinitionListPacket: load pregenerated data from file 2019-12-06 11:32:33 +00:00
da8c54cf8b AvailableEntityIdentifiersPacket: load pregenerated data from file 2019-12-06 11:31:55 +00:00
8e984a1bc3 RuntimeBlockMapping: use new data, item frames & doors fixed
floor & ceiling item frames not supported though
2019-12-06 11:31:18 +00:00
124e60301a updated submodule to pmmp/BedrockData@a38b427888 2019-12-06 11:26:58 +00:00
4d13c48e5c UPnP: COM constructor never returns false anymore 2019-12-05 16:07:06 +00:00
9159e8f002 MainLogger: mark static logger field as nullable 2019-12-05 15:48:58 +00:00
f5aa461945 GlobalConstants: assume we are on 64-bit when declaring INT32_MASK
fixes a FP reported by phpstan level 4
2019-12-05 15:48:11 +00:00
16817ff301 Player: remove superfluous conditions for RESPAWN action handling
spawned is always true here because of the condition at the top of the function.
isOnline() is always true here because the handler won't even be called if it isn't.
2019-12-05 14:52:12 +00:00
18863b1098 Player: remove superfluous check from processMovement()
if we reached this branch, revert is always false because it is not modified between this branch and the parent one.
detected by phpstan level 4
2019-12-05 14:47:15 +00:00
e3cffca34b StartGamePacket: fixed possible type violation on decoding block table 2019-12-05 11:05:34 +00:00
d20d9fb689 Merge branch 'stable' into drew-1.13 2019-12-05 10:59:53 +00:00
7b1ae2a822 phpstan: green on level 3 2019-12-04 22:12:14 +00:00
8ecf5e02b9 bad fix for WritableBook phpstan warning
master has this shit so much better
2019-12-04 22:00:19 +00:00
39c607cbd5 Position: mark level field as nullable
allowing the level to be null is, to be honest, a big design flaw, but one that can't be fixed without BC breaks.
2019-12-04 21:31:35 +00:00
d867ffc60d MetadataStore: fix some doc comments 2019-12-04 21:14:09 +00:00
c57eb26fd5 phpstan-bugs: add some extra patterns for level 3 false positives 2019-12-04 19:50:15 +00:00
c35d91a104 phpstan: allow blanket ignoreErrors in src to reduce merge work for master 2019-12-04 19:42:18 +00:00
9fc260fb1a keep phpstan.neon.dist ignoreErrors sorted by file 2019-12-04 19:38:54 +00:00
73d0f799c2 Update to PHPStan 0.12.0 2019-12-04 10:29:49 +00:00
ecb2e6e3af PluginManager: remove useless information from softDepend debug
we don't report the parameter type anywhere else, and since PHP doesn't support overloading, we don't need to.
This fixes PHPStan 0.12 complaints about ReflectionNamedType. I figured this was the best solution instead of adding an extra few lines of code.
2019-12-04 10:17:25 +00:00
7b75b6928d AvailableCommandsPacket: fixed foreach docs
these probably aren't necessary at all to be honest.
2019-12-04 10:15:50 +00:00
753a8a6937 Event: remove useless @var $this annotations
we are not in a trait here, the scope is always Event.
2019-12-04 10:15:04 +00:00
bc76b1cafe Server: remove several redundant @var annotations (copy pasta)
these are all useless because it is implied by the parameter type anyway.
2019-12-04 10:14:15 +00:00
00e415fc79 move phpstan.neon to phpstan.neon.dist to allow phpstan.neon to be locally modified for development 2019-12-03 19:57:19 +00:00
dbbe1f2d5c Revert "Entity: remove redundant check from spawnTo()"
This reverts commit 3028832cd3.

When I created this commit, I made the flawed assumption that spawnTo()
would not be used by plugins. In addition, I was not aware that there
are some usages of spawnTo() in the core which do not check for chunk
usage, such as in Player->showPlayer().

This caused a collection of problems including memory leaks and crashes
due to disconnecting players not removing their references from viewed
entities.

The reverted commit may be the cause of #3178.
2019-12-03 10:41:13 +00:00
740f0a2314 crafting now works on 1.13, but it's not good 2019-12-02 21:50:52 +00:00
7fdfe947b0 inventory: fix some transactions being rejected for no good reason
since 1.13, transactions such as interacting with creative inventory cause a spoof windowID 124 slot 50 action to appear which changes air -> air. This currently gets rejected because only cursor is mapped to ID 124, and it only has a single slot.

It is not clear what the purpose of 124:50 is, but this fix filters out any actions which do not change anything, since they won't affect transaction balance anyway.
2019-12-02 21:41:08 +00:00
b7c4379700 StartGamePacket: fixed asymmetry in block table handling 2019-12-02 19:35:55 +00:00
20b7418916 PlayerAuthInputPacket: added encode & decode, and some aux classes 2019-12-02 15:14:59 +00:00
85521f5e7a EducationSettingsPacket: added encode & decode 2019-12-02 13:57:19 +00:00
f37ea6a203 AvailableCommandsPacket: fix nonsensical placement of HARDCODED_ENUMS 2019-12-02 12:57:05 +00:00
abf8081ebc RuntimeBlockMapping: add a type check for decoded NBT root type
this is kinda redundant since this function can blow up in so many other ways anyway, but it makes PHPStan happy, so it'll do.
2019-12-02 08:21:42 +00:00
8594cb3e74 AvailableCommandsPacket: fixed doc comment for putEnumConstraint() 2019-12-02 08:17:00 +00:00
d155de35ed Merge branch 'dktapps-drew-1.13' into stable 2019-12-01 22:03:03 -05:00
e37c8e3a5d Merge branch 'drew-1.13' of https://github.com/dktapps/PocketMine-MP into dktapps-drew-1.13 2019-12-01 22:02:40 -05:00
e38c0c0fe1 Merge remote-tracking branch 'upstream/stable' into stable 2019-12-01 21:55:50 -05:00
ce27c03774 PlayerChatEvent: fixed crash when non-CommandSender permissibles subscribe to broadcast permission
doing such a thing doesn't make any sense, but the system allows it, so it has to be accounted for.
2019-12-01 21:44:13 +00:00
c4a8781b5c Fixed doc type inconsistencies surrounding chat broadcast handling (several problems that are all related) 2019-12-01 21:40:11 +00:00
dbab8b5733 Level: fixed type doc of tickRateTime field 2019-12-01 21:21:42 +00:00
2b08bbc7b1 Server: fixed type doc comment of nextTick field 2019-12-01 21:18:20 +00:00
17037f5e9c Chunk: clean up nonsensical code in initChunk()
I have no idea why the extra check was there, or why the null assignment was used, because it doesn't make any sense.
2019-12-01 21:14:23 +00:00
fee3c17148 CraftingManager: fixed type doc of craftingDataCache field 2019-12-01 21:06:34 +00:00
25e6cb74b3 Squid: fixed type doc comment of swimDirection field 2019-12-01 21:06:03 +00:00
8d2e59222e Entity: fixed not calculating surrounding blocks on entity creation
it's unclear if this was actually causing any bugs, but if it was it would likely manifest in the form of, for example, not burning in lava.
2019-12-01 21:05:36 +00:00
cd778661c2 Entity: fixed type doc comment for blocksAround field 2019-12-01 21:03:57 +00:00
c2afc05e7c Entity: fix type doc comment for static knownEntities field 2019-12-01 21:03:29 +00:00
9be95bf263 Block: return [] instead of null in getMetadata() (return type is non-nullable) 2019-12-01 21:02:49 +00:00
4b65e1cbe1 Command: fix type doc comment for commandMap field 2019-12-01 21:01:57 +00:00
5caae37768 Server: fixed return type doc comment for getCommandAliases() 2019-12-01 21:00:49 +00:00
92e1811b06 DataPacket: fixed bad null assignment to buffer in clean()
this is never expected to be null, so implicitly relies on PHP magic behaviour to convert it to string when appended.
2019-12-01 20:36:56 +00:00
293c2710d0 PlayerCreationEvent: fixed doc comments for baseClass and playerClass fields 2019-12-01 20:19:59 +00:00
8a7017fd6b Enchantment: fixed doc comment for static enchantments field 2019-12-01 20:16:45 +00:00
15f8886958 phpstan: separate non-PM bugs from the main neon config
everything left in here is now a PM problem that needs to be looked into.
2019-12-01 20:12:41 +00:00
3226a9dc6a phpstan: ignore more optional-leveldb errors 2019-12-01 19:52:49 +00:00
1a1e3ff63b BaseInventory: fixed incorrect & redundant default value for slots field 2019-12-01 19:45:16 +00:00
ea413d0882 phpstan: analyze on level 2, close #3193 2019-12-01 19:32:03 +00:00
0890b5fc99 AsyncPool: assert() that the unstacked task is actually an AsyncTask
it's possible that it might not be if the workers were accessed directly, but that shouldn't be possible.
This also silences a PHPStan warning on level 2.
2019-12-01 19:28:05 +00:00
163ed225f2 NetworkBinaryStream: fixed crash when non-compound root tag is provided for itemstack 2019-12-01 18:41:02 +00:00
a4a6d3e094 PlayerCreationEvent: fixed illegal doc comment types 2019-12-01 18:08:25 +00:00
ecbf3e9722 GamemodeCommand: fix CommandSender assignment causing troubles for type inference on static analyzers
this would never crash, but in strongly typed code it would be a compile failure.
2019-12-01 09:33:12 +00:00
47a959dace block: fix some possible crashes when plugins overwrite tile classes in bad ways
phpstan was complaining on level 2, and it's not wrong to ...
2019-12-01 09:29:22 +00:00
3968f85c82 sync composer dependencies 2019-12-01 08:54:48 +00:00
d8188b807a CraftingDataPacket: read & write potion recipes 2019-11-30 21:18:54 +00:00
8e68655fc7 Merge branch 'stable' into drew-1.13 2019-11-30 21:15:50 +00:00
6d109bfc6f CraftingDataPacket: fixed not retaining cleanRecipes during decode 2019-11-30 21:15:37 +00:00
b7a5a53c9d MoveActorDeltaPacket: flags is now a short 2019-11-30 12:56:16 +00:00
76bd0f452c AvailableCommandsPacket: add special handling for enums which aren't referenced by any command directly
the CommandName enum is a magic enum used by the  argtype.

TODO: It's possible that not sending the CommandName enum might be causing client sided crashes. Investigate.
2019-11-30 12:41:44 +00:00
363556e9b6 AvailableCommandsPacket: encode & decode for enum value constraints
This is a peculiarly overengineered system that is used for restricting access to enum members under certain conditions, e.g. to disallow changing specific gamerules in survival.
2019-11-30 12:31:31 +00:00
6f08853b29 Merge branch 'stable' into drew-1.13 2019-11-30 12:04:46 +00:00
42d8357821 AvailableCommandsPacket: fixed missing decoded overloads with 0 arguments
these should be listed even if they have 0 arguments
2019-11-30 11:58:29 +00:00
f2ac63d235 update build/php submodule to pmmp/php-build-scripts@8308571448 2019-11-29 11:54:42 +00:00
5d17405b92 Better checks on resource patch 2019-11-28 19:48:34 -05:00
3dd53ad998 Remove offset for crafting grid 2019-11-28 19:42:34 -05:00
a303c4b294 Add some isset checks to prevent server from crashing on an invalid resourcepatch 2019-11-21 17:58:33 -05:00
fa56290bb4 Reflect StartGamePacket changes in Player 2019-11-21 15:05:09 -05:00
01d6cbe9c3 Added : void typehint to SkinAdapterSingleton & provide documentation 2019-11-21 15:01:34 -05:00
f682c16740 Changed eduMode to eduEditionOffer and added an unsignedVarInt in availablecommandspacket 2019-11-21 14:55:29 -05:00
74c09dc202 Remove inline assignment 2019-11-21 14:49:01 -05:00
0917b67573 Generate param docs for constructor 2019-11-21 14:46:10 -05:00
5cb0eafcb2 Should be checking the string, not an object 2019-11-21 14:24:47 -05:00
221e6db47d Remove persona capes off of classic skins, add checks for empty cape data when converting 2019-11-21 14:21:08 -05:00
8d06018d81 make toSkinData return statement multi lined 2019-11-21 13:54:22 -05:00
600e16d9f6 Fixed floatingtextparticle yet again 2019-11-21 13:54:00 -05:00
4340349db7 Generate getters for SkinData, applied suggested change, and fixed an underfined variable in PlayerListPacket 2019-11-21 13:52:27 -05:00
6105198313 Update AvailableCommandsPacket constants 2019-11-20 22:47:48 -05:00
c96ba13c23 Extract geometry name from resource patch 2019-11-20 22:42:56 -05:00
c8d0cb315b Move persona skin hack to legacyskinadapter 2019-11-20 21:52:49 -05:00
be9c413a9e Added network components for skins, to collect instead of throw out data 2019-11-20 21:43:41 -05:00
3e4366b30d readme: add XLM since Keybase made it so easy
... and also gave lots of keybase users free XLM. Well played, Keybase, you managed to make me adopt Stellar.
2019-11-20 10:51:07 +00:00
7f3460190b Merge pull request #5 from dktapps/drew-1.13
more 1.13
2019-11-12 14:19:31 -05:00
10d44292e1 fix classic capes 2019-11-12 12:27:50 -05:00
70f81334ae MultiplayerSettingsPacket 2019-11-12 11:58:40 -05:00
ead572fab9 fix skin sharing stupidity 2019-11-12 07:08:48 -05:00
ef8e286277 Merge branch 'stable' of https://github.com/drew-mcbe/pocketmine-mp into drew-1.13 2019-11-12 06:57:57 -05:00
ba5a5981a0 Update Player.php 2019-11-12 08:19:05 +00:00
c428596009 AddPlayerPacket: missing field 2019-11-11 16:36:55 -05:00
a81d8dd6d5 Return false in unexpected condition 2019-11-11 16:25:53 -05:00
5bcbef90ea Added variables for getSkin's animation for easier readability 2019-11-11 15:32:48 -05:00
1c67f094e3 Change get and put SkinImage visibility to private 2019-11-11 15:29:57 -05:00
99d350914e Remove convertToLegacyName 2019-11-11 15:29:42 -05:00
49a9e0a880 Remove changes to FloatingTextParticle 2019-11-11 15:26:36 -05:00
7b152def7d Move SkinAnimation and changed SerializedImage to SkinImage
Also change putImage and getImage to getSkinImage and putSkinImage
2019-11-11 15:23:48 -05:00
3eb78fb0ff Merge pull request #4 from dktapps/drew-1.13
moar 1.13 changes
2019-11-11 15:04:33 -05:00
38c759c86e ResourcePackStack: missing field 2019-11-11 14:58:45 -05:00
314ce1d012 build/make-release: push after 5 seconds instead of 10 2019-11-11 16:41:50 +00:00
7fcd40df15 add encode/decode for some new packets 2019-11-11 11:20:37 -05:00
ba39327b28 Merge remote-tracking branch 'origin/stable' into drew-1.13 2019-11-11 10:42:25 -05:00
8d2e3894ef DataPacket: fixed var_dump() not showing private & protected subclass properties 2019-11-11 15:41:08 +00:00
8ee0fbccc5 Merge branch 'stable' of https://github.com/drew-mcbe/pocketmine-mp into drew-1.13 2019-11-11 05:48:17 -05:00
fe4354959b SkinAnimation: fix typo 2019-11-11 10:07:45 +00:00
19377c86a4 PlayerSkinPacket: reduce diff pollution 2019-11-11 09:47:04 +00:00
fb23aade34 Clean up unused imports 2019-11-10 21:49:58 -05:00
57e9fe78a3 change buildPlatform parameter to -1 2019-11-10 21:45:33 -05:00
6b97281c58 Update SkinAnimation constants and docs 2019-11-10 21:41:00 -05:00
da67a085fc Remove unused imports and unused todo 2019-11-10 21:37:55 -05:00
e2fc7cdf88 Friendly BC skins (persona not supported) 2019-11-10 21:04:38 -05:00
635bb08fb9 Update playerskinpacket to use the strings 2019-11-10 19:39:07 -05:00
308d9ce3a8 auto generated baseline 2019-11-10 17:40:04 -05:00
5a76c38363 Merge remote-tracking branch 'origin/stable' into drew-1.13 2019-11-10 17:02:46 -05:00
54530da6c1 reduce visibility of offset to private 2019-11-10 00:09:29 -05:00
dd55a0bccd Use unknown os for PlayerListEntry 2019-11-10 00:01:12 -05:00
f03bd982b5 Empty fields in PlayerSkinPacket, thanks @Minejong 2019-11-09 23:56:18 -05:00
025cb73bf5 update travis pthreads 2019-11-09 17:34:04 +00:00
2a6ffb5aa9 updated build/php submodule 2019-11-09 17:33:25 +00:00
d53b84386f Merge pull request #3 from dktapps/drew-1.13
clean up 1.13 a little
2019-11-08 16:46:01 +05:00
a7ed933b37 superfluous import 2019-11-08 11:32:09 +00:00
29cc9283f8 reverse unnecessary formatting changes 2019-11-08 11:29:00 +00:00
e60962c31f reverse BC-breaking change to Player->changeSkin()
this change would cause LSP violations for subclasses
2019-11-08 11:22:55 +00:00
f6b5301e17 Player: remove unused import 2019-11-08 11:10:20 +00:00
73b923e3a1 cleanup eating clusterfuck 2019-11-08 11:08:22 +00:00
d2e4eb40b3 CompletedUsingItemPacket is superfluous 2019-11-08 08:29:25 +00:00
6a31628e78 Clean up whitespace disaster and add getIngredient back 2019-11-07 23:43:26 -05:00
bfb1ad1327 Removed PlayerUIInventory and BaseUIInventory 2019-11-07 23:17:01 -05:00
dfa603c335 Simplify if null statement 2019-11-07 20:06:46 -05:00
eef979db4c Switch to isUsingItem()
I don't plan on using this, as you informed me on discord that I didn't need the extra step, and it's a BC break anyway
2019-11-07 19:49:04 -05:00
6166c90bfd No need for a try catch statement around reading a file 2019-11-07 19:45:47 -05:00
35d1d0080a Removed count const and fixed BC break 2019-11-07 19:45:33 -05:00
3bacb1a9cb Moved skin back
Not too sure what I planned on doing with that
2019-11-07 19:45:20 -05:00
898af49e97 Add typehints to completedusingitempacket 2019-11-07 19:45:06 -05:00
3061eb4157 Fixed convertToLegacyName not using variables, add typehints to it too 2019-11-07 19:44:49 -05:00
b8d1d8f212 Clean up unused imports 2019-11-07 19:43:53 -05:00
8c6189775b Removed root directory runtime states 2019-11-07 19:33:53 -05:00
932418b951 fixing some PHPStan complaints about bootstrap
this isn't an ideal fix, but it'll do.
2019-11-07 18:22:37 +00:00
95812252d6 NetworkBinaryStream: fix a mistake in doc for putEntityRuntimeId() 2019-11-07 18:22:37 +00:00
7dec912d15 Fixed FloatingTextParticles 2019-11-06 23:22:41 -05:00
dbd36d66ae Cape data can be null 2019-11-06 23:01:06 -05:00
40b4166a6e created method sendCompletedUsingItemPacket for less duplication 2019-11-06 22:30:05 -05:00
51d18ffb89 Merge branch 'stable' of https://github.com/pmmp/PocketMine-MP into stable 2019-11-06 22:10:41 -05:00
af3c7b7c76 Updated ResourcePackType 2019-11-06 21:57:09 -05:00
3511ac010d Fixed crafting 2019-11-06 20:42:53 -05:00
cac3c356a5 Painting: fix dropping multiple items when multiple blockupdates occur in the same tick
test case: place sand on top of a line of signs, put a painting on the sand and break the supporting sign
fixes #2774 for stable
2019-11-06 14:29:43 -05:00
07f19dd4a1 Fixed respawning 2019-11-05 22:33:12 -05:00
17a17c31f3 Fixed items, but I'm not so sure how well this'll work out, it'll need improved in the future 2019-11-05 22:25:11 -05:00
75742b487f Fixed stupid mistake 2019-11-05 21:56:20 -05:00
4e9a2b6d8c Added CompletedUsingItemPacket 2019-11-05 21:19:49 -05:00
4ea907ae1a Start saving new skin data 2019-11-05 21:01:01 -05:00
8b912c1363 Removed some useless casts 2019-11-05 20:59:48 -05:00
080209c469 Fixed persona skins being messed up on join 2019-11-05 20:35:33 -05:00
5b11ddee35 Clean up duplicated skin entries 2019-11-05 20:30:41 -05:00
3b7ded0ba3 Fixed changing skins crashing the server 2019-11-05 20:25:45 -05:00
c5d3e9be76 phpstan: silence leveldb noise
maybe there's a better way to do this, but I don't know it yet.
2019-11-05 20:21:36 +00:00
714f4dc023 fortify CI with PHPStan 2019-11-05 19:42:37 +00:00
a86bcd5110 travis.sh: don't redownload phpunit if it already locally exists 2019-11-05 19:39:04 +00:00
7ffc477d76 introduced baseline PHPStan configuration 2019-11-05 11:16:49 +00:00
4cb0b319c0 load some non-class constants with composer
this makes PHPStan happy and also makes working with PM code externally less of a pain in the ass.
2019-11-05 11:16:22 +00:00
5ebe9859e9 Moved runtime_block_states to vanilla 2019-11-04 21:47:44 -05:00
cd2b60a860 Initial update to 1.13 2019-10-30 21:36:08 -04:00
5edff79f5f 3.9.8 is next 2019-10-28 16:07:35 +00:00
558 changed files with 5493 additions and 6133 deletions

1
.gitignore vendored
View File

@ -13,6 +13,7 @@ server.properties
memory_dumps/*
resource_packs/
server.lock
/phpstan.neon
# Common IDEs
.idea/

6
.gitmodules vendored
View File

@ -7,9 +7,9 @@
[submodule "tests/plugins/PocketMine-DevTools"]
path = tests/plugins/PocketMine-DevTools
url = https://github.com/pmmp/PocketMine-DevTools.git
[submodule "src/pocketmine/resources/vanilla"]
path = src/pocketmine/resources/vanilla
url = https://github.com/pmmp/BedrockData.git
[submodule "build/php"]
path = build/php
url = https://github.com/pmmp/php-build-scripts.git
[submodule "src/pocketmine/resources/vanilla"]
path = src/pocketmine/resources/vanilla
url = https://github.com/pmmp/BedrockData.git

View File

@ -5,20 +5,24 @@ php:
- 7.3
before_script:
- phpenv config-rm xdebug.ini
# - pecl install channel://pecl.php.net/pthreads-3.1.6
- echo | pecl install channel://pecl.php.net/yaml-2.0.4
- git clone https://github.com/pmmp/pthreads.git
- cd pthreads
- git checkout 6ca019c58b4fa09ee2ff490f2444e34bef0773d0
- git checkout 1b7da492b944146fa9680f6399bd9c6c6c6095e0
- phpize
- ./configure
- make
- make install
- cd ..
- echo "extension=pthreads.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- composer install
script:
- composer install
- ./vendor/bin/phpstan analyze --no-progress --memory-limit=2G
- ./vendor/bin/phpunit --bootstrap vendor/autoload.php --fail-on-warning tests/phpunit
- composer install --no-dev
- ./tests/travis.sh -t4
notifications:

38
BUILDING.md Normal file
View File

@ -0,0 +1,38 @@
# Building
## Pre-requisites
- A bash shell (git bash is sufficient for Windows)
- [`git`](https://git-scm.com) available in your shell
- PHP 7.2 or newer available in your shell
- [`composer`](https://getcomposer.org) available in your shell
## Custom PHP binaries
Because PocketMine-MP requires several non-standard PHP extensions and configuration, PMMP provides scripts to build custom binaries for running PocketMine-MP, as well as prebuilt binaries.
- [Prebuilt binaries](https://jenkins.pmmp.io/job/PHP-7.3-Aggregate)
- [Compile scripts](https://github.com/pmmp/php-build-scripts) are provided as a submodule in the path `build/php`
If you use a custom binary, you'll need to replace `composer` usages in this guide with `path/to/your/php path/to/your/composer.phar`.
## Setting up environment
1. `git clone --recursive https://github.com/pmmp/PocketMine-MP.git`
2. `composer install`
## Checking out a different branch to build
1. `git checkout <branch to checkout>`
2. `git submodule update --init`
3. Re-run `composer install` to synchronize dependencies.
## Optimizing for release builds
1. Add the flags `--no-dev --classmap-authoritative` to your `composer install` command. This will reduce build size and improve autoloading speed.
2. Preprocess the source code by running `build/preprocessor/PreProcessor.php`. Usage instructions are provided in `build/preprocessor/README.md`.
### Note
Preprocessor requires that the `cpp` (c preprocessor) is available in your PATH.
## Building `PocketMine-MP.phar`
Run `build/server.phar` using your preferred PHP binary. It'll drop a `PocketMine-MP.phar` into the current working directory.
You can also use the `--out` option to change the output filename.
## Running PocketMine-MP from source code
Run `src/pocketmine/PocketMine.php` using your preferred PHP binary.

View File

@ -13,10 +13,11 @@
## Discussion/Help
- [Forums](https://forums.pmmp.io/)
- [Community Discord](https://discord.gg/bmSAZBG)
- [Discord](https://discord.gg/bmSAZBG)
- [StackOverflow](https://stackoverflow.com/tags/pocketmine)
## For developers
* [Building and running from source](BUILDING.md)
* [Latest API documentation](https://jenkins.pmmp.io/job/PocketMine-MP-doc/doxygen/) - Doxygen documentation generated from development
* [DevTools](https://github.com/pmmp/PocketMine-DevTools/) - Development tools plugin for creating plugins
* [ExamplePlugin](https://github.com/pmmp/ExamplePlugin/) - Example plugin demonstrating some basic API features
@ -25,6 +26,7 @@
## Donate
- Bitcoin Cash (BCH): `qq3r46hn6ljnhnqnfwxt5pg3g447eq9jhvw5ddfear`
- Bitcoin (BTC): `171u8K9e4FtU6j3e5sqNoxKUgEw9qWQdRV`
- Stellar Lumens (XLM): `GAAC5WZ33HCTE3BFJFZJXONMEIBNHFLBXM2HJVAZHXXPYA3HP5XPPS7T`
- [Patreon](https://www.patreon.com/pocketminemp)
## Licensing information

View File

@ -36,7 +36,6 @@ use function system;
use const pocketmine\BASE_VERSION;
use const STDIN;
require_once dirname(__DIR__) . '/src/pocketmine/VersionInfo.php';
require_once dirname(__DIR__) . '/vendor/autoload.php';
if(isset($argv[1])){
@ -76,6 +75,6 @@ system('git tag ' . $currentVer->getBaseVersion());
replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true);
system('git add "' . $versionInfoPath . '"');
system('git commit -m "' . $nextVer->getBaseVersion() . ' is next" --include "' . $versionInfoPath . '"');
echo "pushing changes in 10 seconds\n";
sleep(10);
echo "pushing changes in 5 seconds\n";
sleep(5);
system('git push origin HEAD ' . $currentVer->getBaseVersion());

159
build/server-phar.php Normal file
View File

@ -0,0 +1,159 @@
<?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/
*
*
*/
declare(strict_types=1);
namespace pocketmine\build\server_phar;
use pocketmine\utils\Git;
require dirname(__DIR__) . '/vendor/autoload.php';
/**
* @param string[] $strings
* @param string|null $delim
*
* @return string[]
*/
function preg_quote_array(array $strings, string $delim = null) : array{
return array_map(function(string $str) use ($delim) : string{ return preg_quote($str, $delim); }, $strings);
}
/**
* @param string $pharPath
* @param string $basePath
* @param string[] $includedPaths
* @param mixed[] $metadata
* @param string $stub
* @param int $signatureAlgo
* @param int|null $compression
* @phpstan-param array<string, mixed> $metadata
*
* @return \Generator|string[]
*/
function buildPhar(string $pharPath, string $basePath, array $includedPaths, array $metadata, string $stub, int $signatureAlgo = \Phar::SHA1, ?int $compression = null){
$basePath = rtrim(str_replace("/", DIRECTORY_SEPARATOR, $basePath), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$includedPaths = array_map(function($path){
return rtrim(str_replace("/", DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}, $includedPaths);
yield "Creating output file $pharPath";
if(file_exists($pharPath)){
yield "Phar file already exists, overwriting...";
try{
\Phar::unlinkArchive($pharPath);
}catch(\PharException $e){
//unlinkArchive() doesn't like dodgy phars
unlink($pharPath);
}
}
yield "Adding files...";
$start = microtime(true);
$phar = new \Phar($pharPath);
$phar->setMetadata($metadata);
$phar->setStub($stub);
$phar->setSignatureAlgorithm($signatureAlgo);
$phar->startBuffering();
//If paths contain any of these, they will be excluded
$excludedSubstrings = preg_quote_array([
realpath($pharPath), //don't add the phar to itself
], '/');
$folderPatterns = preg_quote_array([
DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR,
DIRECTORY_SEPARATOR . '.' //"Hidden" files, git dirs etc
], '/');
//Only exclude these within the basedir, otherwise the project won't get built if it itself is in a directory that matches these patterns
$basePattern = preg_quote(rtrim($basePath, DIRECTORY_SEPARATOR), '/');
foreach($folderPatterns as $p){
$excludedSubstrings[] = $basePattern . '.*' . $p;
}
$regex = sprintf('/^(?!.*(%s))^%s(%s).*/i',
implode('|', $excludedSubstrings), //String may not contain any of these substrings
preg_quote($basePath, '/'), //String must start with this path...
implode('|', preg_quote_array($includedPaths, '/')) //... and must be followed by one of these relative paths, if any were specified. If none, this will produce a null capturing group which will allow anything.
);
$directory = new \RecursiveDirectoryIterator($basePath, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS | \FilesystemIterator::CURRENT_AS_PATHNAME); //can't use fileinfo because of symlinks
$iterator = new \RecursiveIteratorIterator($directory);
$regexIterator = new \RegexIterator($iterator, $regex);
$count = count($phar->buildFromIterator($regexIterator, $basePath));
yield "Added $count files";
if($compression !== null){
yield "Compressing files...";
$phar->compressFiles($compression);
yield "Finished compression";
}
$phar->stopBuffering();
yield "Done in " . round(microtime(true) - $start, 3) . "s";
}
function main() : void{
if(ini_get("phar.readonly") == 1){
echo "Set phar.readonly to 0 with -dphar.readonly=0" . PHP_EOL;
exit(1);
}
$opts = getopt("", ["out:"]);
$gitHash = Git::getRepositoryStatePretty(dirname(__DIR__));
echo "Git hash detected as $gitHash" . PHP_EOL;
foreach(buildPhar(
$opts["out"] ?? getcwd() . DIRECTORY_SEPARATOR . "PocketMine-MP.phar",
dirname(__DIR__) . DIRECTORY_SEPARATOR,
[
'src',
'vendor'
],
[
'git' => $gitHash
],
<<<'STUB'
<?php
$tmpDir = sys_get_temp_dir();
if(!is_readable($tmpDir) or !is_writable($tmpDir)){
echo "ERROR: tmpdir $tmpDir is not accessible." . PHP_EOL;
echo "Check that the directory exists, and that the current user has read/write permissions for it." . PHP_EOL;
echo "Alternatively, set 'sys_temp_dir' to a different directory in your php.ini file." . PHP_EOL;
exit(1);
}
require("phar://" . __FILE__ . "/src/pocketmine/PocketMine.php");
__HALT_COMPILER();
STUB
,
\Phar::SHA1,
\Phar::GZ
) as $line){
echo $line . PHP_EOL;
}
}
if(!defined('pocketmine\_PHPSTAN_ANALYSIS')){
main();
}

20
changelogs/3.10.md Normal file
View File

@ -0,0 +1,20 @@
**For Minecraft: Bedrock Edition 1.13.0**
### Note about API versions
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
Plugin developers should **only** update their required API to this version if you need the changes in this build.
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
# 3.10.0
- Added support for Minecraft: Bedrock Edition 1.13.0
- Removed compatibility with 1.12.0
## Note about skins
PocketMine-MP **does not support skins made in the Charactor Creator** (known as Persona skins), due to technical changes which would require premature backwards compatibility breaks. The dev team has decided not to support Persona yet.
These skins will be **replaced with a random solid-colour skin. This is not a bug.**
Skins chosen from the Classic tab (classic skins) will continue to work as normal.
# 3.10.1
- Fixed custom plugin-created skins being invisible when no geometry name was specified.
- Updated RakLib to 0.12.6 to fix security bugs.

68
changelogs/3.11.md Normal file
View File

@ -0,0 +1,68 @@
**For Minecraft: Bedrock Edition 1.14.0**
### Note about API versions
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
Plugin developers should **only** update their required API to this version if you need the changes in this build.
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
# 3.11.0
- Added support for Minecraft: Bedrock Edition 1.14.0
- Removed compatibility with 1.13.0
# 3.11.1
- Fixed blocks with incorrect properties when placed or interacted with.
# 3.11.2
## Core
- PHPStan 0.12.3 with level 5 is now used for automated static analysis.
- Fixed a possible crash when plugins override the `EnderChest` tile class with something incompatible.
- Fixed disconnected players being considered as never played.
- Fixed enchantments with IDs outside the range 0-255 in item NBT crashing the server.
- Fixed particles rendering incorrectly.
- Timings handlers are no longer able to underflow; they now throw exceptions when attempting to be stopped more times than they were started.
- Fixed explosion rays getting stuck in empty subchunks (possible incorrect behaviour in large caves).
- Fixed bad tile/entity NBT data being propagated from world providers in some cases.
- Fixed a possible crash when detecting timezone on CentOS.
- Fixed many cases of incorrectly documented types in the API found by PHPStan.
- Generation tasks no longer assume that generator instances stored in TLS are always valid, fixing a possible crash.
## Protocol
- Fixed skin animation image corruption in LoginPacket handling caused by incorrect data handling.
- Fixed skin animation extra data not being decoded from LoginPacket.
- `SkinImage` now throws `InvalidArgumentException` if it receives an unexpected amount of bytes for the given image heigh/width.
- Fixed broken code in `PlayerAuthInputPacket::create()`.
- Removed some dead constants from `NetworkInventoryAction`.
# 3.11.3
- Fixed some PHPStan false-positives in release builds.
- Git hash is now correctly detected for source builds when the working directory is not the repository root.
- Added a specialized build script `build/server-phar.php` for creating server phars.
- Fixed timings crashing the server.
- Timings chains now work correctly.
- Fixed some minor timing errors in chained timings.
- Forcing resource packs no longer causes removal of client-sided resource packs. If this behaviour is desired, use a vanilla resource pack at the bottom of your resource stack (as was necessary for non-forced packs).
- Added documentation to the API to clarify that effect durations are in ticks.
# 3.11.4
- Fixed performance issue in leaf decay.
- Fixed entity position desync when entities stop moving, but still have velocity on the client.
- Fixed a crash when encountering truncated `level.dat` files in LevelDB worlds.
- Core code is now analyzed using PHPStan level 6.
- The core constants `pocketmine\PATH` and `pocketmine\RESOURCE_PATH` are now unconditionally available when including the Composer autoloader.
- Populate type information in lots of places where it was previously missing; this will improve the quality of static analysis for plugins.
- `MainLogger::logException()` now logs previous exceptions recursively.
- `MainLogger::logException()` now always logs exceptions as `critical`.
# 3.11.5
- PHPStan and PHPUnit are now managed as Composer dev dependencies.
- Core code is now analyzed using PHPStan level 6 (full, including iterable types checking).
- Improved type information available to PHPStan in many areas.
- Mass-removal of useless PHPDoc.
- Fixed incorrect documentation of `Internet::getURL()`, `Internet::postURL()` and `Internet::simpleCurl()`.
- Fixed crash on use of case-mismatched recursive command aliases.
- Basic build instructions are now provided in `BUILDING.md`.
- `build/server-phar.php` now uses GZIP compression on created phars, providing a 75% size reduction.
- `ClientboundMapItemDataPacket` now uses `MapDecoration` objects for decorations instead of associative arrays.
- Updated Composer dependencies to get bug fixes in `pocketmine/nbt` and other libraries.
- Packages `pocketmine/classloader` and `pocketmine/log` are now required; these provide classes previously part of `pocketmine/spl`. This change has no effect on API compatibility.

View File

@ -104,4 +104,26 @@ Plugin developers should **only** update their required API to this version if y
# 3.9.7
- Fixed a crash that could occur during timezone detection.
- Squid no longer spin around constantly in enclosed spaces. Their performance impact is reduced.
- Cleaned up the bootstrap file.
- Cleaned up the bootstrap file.
# 3.9.8
- Added [PHPStan](https://github.com/phpstan/phpstan) configuration. PHPStan is now used on CI for automated QA, which should improve stability and quality going forward.
- The following constants are now autoloaded when loading the Composer autoloader:
- `pocketmine\NAME`
- `pocketmine\BASE_VERSION`
- `pocketmine\IS_DEVELOPMENT_BUILD`
- `pocketmine\BUILD_NUMBER`
- `INT32_MIN`
- `INT32_MAX`
- `INT32_MASK`
- Fixed memory leaks and crashes caused by plugin use of `Player->showPlayer()` and `Entity->spawnTo()`.
- Fixed crashes that could occur when tile classes were overridden with classes incompatible with the originals.
- Fixed improper handling of non-Compound root NBT tags on network itemstack decoding.
- Fixed paintings dropping multiple items when destroyed by block updates.
- Fixed `var_dump()` not showing private and protected properties of `DataPacket` subclasses.
- Fixed overloads with zero arguments being missing when decoding `AvailableCommandsPacket`.
- `CraftingDataPacket` now retains the `cleanRecipes` field when decoding.
- Fixed `Block->getMetadata()` returning null (non-iterable).
- `PlayerChatEvent` documentation has been updated to specify that `CommandSender` recipients are accepted. This behaviour was already present in previous versions, but incorrectly documented.
- Fixed various issues with PHPDoc comments reported by PHPStan.
- Fixed various minor code nits reported by PHPStan.

View File

@ -24,49 +24,34 @@
"ext-yaml": ">=2.0.0",
"ext-zip": "*",
"ext-zlib": ">=1.2.11",
"pocketmine/raklib": "^0.12.5",
"pocketmine/spl": "^0.3.0",
"pocketmine/raklib": "^0.12.7",
"pocketmine/spl": "^0.4.0",
"pocketmine/binaryutils": "^0.1.9",
"pocketmine/nbt": "^0.2.10",
"pocketmine/math": "^0.2.0",
"pocketmine/snooze": "^0.1.0",
"pocketmine/classloader": "^0.1.0",
"pocketmine/log": "^0.1.0",
"daverandom/callback-validator": "dev-master",
"adhocore/json-comment": "^0.0.7"
},
"require-dev": {
"phpstan/phpstan": "^0.12.8",
"irstea/phpunit-shim": "^7.5"
},
"autoload": {
"psr-4": {
"": ["src"]
}
},
"files": [
"src/pocketmine/CoreConstants.php",
"src/pocketmine/GlobalConstants.php",
"src/pocketmine/VersionInfo.php"
]
},
"autoload-dev": {
"psr-4": {
"pocketmine\\": "tests/phpunit/"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/pmmp/RakLib"
},
{
"type": "vcs",
"url": "https://github.com/pmmp/SPL"
},
{
"type": "vcs",
"url": "https://github.com/pmmp/BinaryUtils"
},
{
"type": "vcs",
"url": "https://github.com/pmmp/NBT"
},
{
"type": "vcs",
"url": "https://github.com/pmmp/Math"
},
{
"type": "vcs",
"url": "https://github.com/pmmp/Snooze"
}
]
}
}

296
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "377d9e0ab5f1a9a4ef9b664706d26f5b",
"content-hash": "e75353b6127ffbd846cdbad57b83a65f",
"packages": [
{
"name": "adhocore/json-comment",
@ -92,84 +92,159 @@
},
{
"name": "pocketmine/binaryutils",
"version": "0.1.10",
"version": "0.1.11",
"source": {
"type": "git",
"url": "https://github.com/pmmp/BinaryUtils.git",
"reference": "435f2ee265bce75ef1aa9563f9b60ff36d705e80"
"reference": "e8cb65db1b7998eebb739b124f2a989fe87366eb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/435f2ee265bce75ef1aa9563f9b60ff36d705e80",
"reference": "435f2ee265bce75ef1aa9563f9b60ff36d705e80",
"url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/e8cb65db1b7998eebb739b124f2a989fe87366eb",
"reference": "e8cb65db1b7998eebb739b124f2a989fe87366eb",
"shasum": ""
},
"require": {
"php": ">=7.2",
"php-64bit": "*"
},
"require-dev": {
"phpstan/phpstan": "^0.12.8"
},
"type": "library",
"autoload": {
"psr-4": {
"pocketmine\\utils\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"description": "Classes and methods for conveniently handling binary data",
"support": {
"source": "https://github.com/pmmp/BinaryUtils/tree/0.1.10",
"issues": "https://github.com/pmmp/BinaryUtils/issues"
},
"time": "2019-10-21T14:40:32+00:00"
"time": "2020-01-28T12:09:56+00:00"
},
{
"name": "pocketmine/math",
"version": "0.2.3",
"name": "pocketmine/classloader",
"version": "0.1.0",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Math.git",
"reference": "68be8a79fd0169043ef514797c304517cb8a6071"
"url": "https://github.com/pmmp/ClassLoader.git",
"reference": "4ccdb30e48f030bfcad04bb0a208d198ec631993"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Math/zipball/68be8a79fd0169043ef514797c304517cb8a6071",
"reference": "68be8a79fd0169043ef514797c304517cb8a6071",
"url": "https://api.github.com/repos/pmmp/ClassLoader/zipball/4ccdb30e48f030bfcad04bb0a208d198ec631993",
"reference": "4ccdb30e48f030bfcad04bb0a208d198ec631993",
"shasum": ""
},
"require": {
"ext-pthreads": "~3.2.0",
"ext-reflection": "*",
"php": ">=7.2.0"
},
"conflict": {
"pocketmine/spl": "<0.4"
},
"require-dev": {
"phpstan/phpstan": "^0.12.8"
},
"type": "library",
"autoload": {
"classmap": [
"./src"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"description": "Ad-hoc autoloading components used by PocketMine-MP",
"time": "2020-01-31T14:25:52+00:00"
},
{
"name": "pocketmine/log",
"version": "0.1.0",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Log.git",
"reference": "62c1f0ea5a5c0ae4b308f9bd231fb11638ff866e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Log/zipball/62c1f0ea5a5c0ae4b308f9bd231fb11638ff866e",
"reference": "62c1f0ea5a5c0ae4b308f9bd231fb11638ff866e",
"shasum": ""
},
"require": {
"ext-pthreads": "~3.2.0",
"php": ">=7.2"
},
"conflict": {
"pocketmine/spl": "<0.4"
},
"require-dev": {
"phpstan/phpstan": "^0.12.8"
},
"type": "library",
"autoload": {
"classmap": [
"./src"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"description": "Logging components used by PocketMine-MP and related projects",
"time": "2020-01-31T14:31:47+00:00"
},
{
"name": "pocketmine/math",
"version": "0.2.4",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Math.git",
"reference": "b1c28b236df8b795d7b06cf8421f9962b12ac410"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Math/zipball/b1c28b236df8b795d7b06cf8421f9962b12ac410",
"reference": "b1c28b236df8b795d7b06cf8421f9962b12ac410",
"shasum": ""
},
"require": {
"php": ">=7.2.0",
"php-64bit": "*"
},
"require-dev": {
"phpstan/phpstan": "^0.12.8"
},
"type": "library",
"autoload": {
"psr-4": {
"pocketmine\\math\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"description": "PHP library containing math related code used in PocketMine-MP",
"support": {
"source": "https://github.com/pmmp/Math/tree/0.2.3",
"issues": "https://github.com/pmmp/Math/issues"
},
"time": "2019-10-21T14:35:10+00:00"
"time": "2020-01-28T14:11:54+00:00"
},
{
"name": "pocketmine/nbt",
"version": "0.2.11",
"version": "0.2.13",
"source": {
"type": "git",
"url": "https://github.com/pmmp/NBT.git",
"reference": "78784b93632c51f0fad0719b2d6ffe072529db6d"
"reference": "6fc56f864a5375471f6e2d0f9f89f2462a1d8433"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/NBT/zipball/78784b93632c51f0fad0719b2d6ffe072529db6d",
"reference": "78784b93632c51f0fad0719b2d6ffe072529db6d",
"url": "https://api.github.com/repos/pmmp/NBT/zipball/6fc56f864a5375471f6e2d0f9f89f2462a1d8433",
"reference": "6fc56f864a5375471f6e2d0f9f89f2462a1d8433",
"shasum": ""
},
"require": {
@ -178,39 +253,35 @@
"php-64bit": "*",
"pocketmine/binaryutils": "^0.1.9"
},
"require-dev": {
"irstea/phpunit-shim": "^7.5",
"phpstan/phpstan": "^0.12.8"
},
"type": "library",
"autoload": {
"psr-4": {
"pocketmine\\nbt\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"pocketmine\\nbt\\": "tests/phpunit/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"description": "PHP library for working with Named Binary Tags",
"support": {
"source": "https://github.com/pmmp/NBT/tree/0.2.11",
"issues": "https://github.com/pmmp/NBT/issues"
},
"time": "2019-10-21T14:50:43+00:00"
"time": "2020-01-28T17:03:46+00:00"
},
{
"name": "pocketmine/raklib",
"version": "0.12.5",
"version": "0.12.7",
"source": {
"type": "git",
"url": "https://github.com/pmmp/RakLib.git",
"reference": "874db2d3c24117db2221c1e4550380478aeea852"
"reference": "01abb4e78e2ef69a83d50037d558e0b274f8245b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/874db2d3c24117db2221c1e4550380478aeea852",
"reference": "874db2d3c24117db2221c1e4550380478aeea852",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/01abb4e78e2ef69a83d50037d558e0b274f8245b",
"reference": "01abb4e78e2ef69a83d50037d558e0b274f8245b",
"shasum": ""
},
"require": {
@ -221,8 +292,11 @@
"php-64bit": "*",
"php-ipv6": "*",
"pocketmine/binaryutils": "^0.1.9",
"pocketmine/snooze": "^0.1.0",
"pocketmine/spl": "^0.3.0"
"pocketmine/log": "^0.1.0",
"pocketmine/snooze": "^0.1.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.8"
},
"type": "library",
"autoload": {
@ -230,84 +304,170 @@
"raklib\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0"
],
"description": "A RakNet server implementation written in PHP",
"support": {
"source": "https://github.com/pmmp/RakLib/tree/0.12",
"issues": "https://github.com/pmmp/RakLib/issues"
},
"time": "2019-07-22T14:38:20+00:00"
"time": "2020-01-31T15:33:05+00:00"
},
{
"name": "pocketmine/snooze",
"version": "0.1.1",
"version": "0.1.2",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Snooze.git",
"reference": "b7bd231bdb75e69300cac89ccd515fc731c38c40"
"reference": "88420da3d9335dbcb3ee2decfd5e5453d057dcdf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Snooze/zipball/b7bd231bdb75e69300cac89ccd515fc731c38c40",
"reference": "b7bd231bdb75e69300cac89ccd515fc731c38c40",
"url": "https://api.github.com/repos/pmmp/Snooze/zipball/88420da3d9335dbcb3ee2decfd5e5453d057dcdf",
"reference": "88420da3d9335dbcb3ee2decfd5e5453d057dcdf",
"shasum": ""
},
"require": {
"ext-pthreads": ">=3.1.7dev",
"php-64bit": ">=7.2.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.8"
},
"type": "library",
"autoload": {
"psr-4": {
"pocketmine\\snooze\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"description": "Thread notification management library for code using the pthreads extension",
"support": {
"source": "https://github.com/pmmp/Snooze/tree/0.1.1",
"issues": "https://github.com/pmmp/Snooze/issues"
},
"time": "2019-01-04T15:54:45+00:00"
"time": "2020-01-28T19:08:10+00:00"
},
{
"name": "pocketmine/spl",
"version": "0.3.2",
"version": "0.4.1",
"source": {
"type": "git",
"url": "https://github.com/pmmp/SPL.git",
"reference": "7fd53857cd000491ba69e8db865792a024dd2c49"
"reference": "ff0579a0be41bbe65d3637607715c0f87728a838"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/SPL/zipball/7fd53857cd000491ba69e8db865792a024dd2c49",
"reference": "7fd53857cd000491ba69e8db865792a024dd2c49",
"url": "https://api.github.com/repos/pmmp/SPL/zipball/ff0579a0be41bbe65d3637607715c0f87728a838",
"reference": "ff0579a0be41bbe65d3637607715c0f87728a838",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"require-dev": {
"phpstan/phpstan": "^0.12.8"
},
"type": "library",
"autoload": {
"exclude-from-classmap": [
"stubs"
],
"classmap": [
"./"
"./src"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"description": "Standard library files required by PocketMine-MP and related projects",
"support": {
"source": "https://github.com/pmmp/SPL/tree/master"
},
"time": "2018-08-12T15:17:39+00:00"
"time": "2020-01-31T16:18:03+00:00"
}
],
"packages-dev": [
{
"name": "irstea/phpunit-shim",
"version": "7.5.20",
"source": {
"type": "git",
"url": "https://gitlab.irstea.fr/pole-is/tools/phpunit-shim.git",
"reference": "81cd2d11e12165fddd2731033187dce4fbe8e013"
},
"require": {
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-xml": "*",
"php": "^7.1"
},
"replace": {
"phpunit/phpunit": "self.version"
},
"suggest": {
"ext-soap": "*",
"ext-xdebug": "*"
},
"bin": [
"phpunit"
],
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Shim repository for phpunit/phpunit",
"homepage": "https://phpunit.de/",
"keywords": [
"phpunit",
"shim",
"testing",
"xunit"
],
"time": "2020-01-09T03:20:19+00:00"
},
{
"name": "phpstan/phpstan",
"version": "0.12.8",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "62a552602b7586d82826231f2fd4cbfe39fe0b1d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/62a552602b7586d82826231f2fd4cbfe39fe0b1d",
"reference": "62a552602b7586d82826231f2fd4cbfe39fe0b1d",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.12-dev"
}
},
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"time": "2020-01-26T23:36:48+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {

110
phpstan.neon.dist Normal file
View File

@ -0,0 +1,110 @@
includes:
- tests/phpstan/configs/com-dotnet-magic.neon
- tests/phpstan/configs/custom-leveldb.neon
- tests/phpstan/configs/gc-hacks.neon
- tests/phpstan/configs/phpstan-bugs.neon
- tests/phpstan/configs/pthreads-bugs.neon
- tests/phpstan/configs/runtime-type-checks.neon
parameters:
level: 6
autoload_files:
- tests/phpstan/bootstrap.php
- src/pocketmine/PocketMine.php
- build/server-phar.php
paths:
- src
- build/server-phar.php
dynamicConstantNames:
- pocketmine\IS_DEVELOPMENT_BUILD
- pocketmine\DEBUG
stubFiles:
- tests/phpstan/stubs/pthreads.stub
- tests/phpstan/stubs/chunkutils.stub
reportUnmatchedIgnoredErrors: false #no other way to silence platform-specific non-warnings
ignoreErrors:
-
message: "#^Cannot instantiate interface pocketmine\\\\level\\\\format\\\\io\\\\LevelProvider\\.$#"
count: 1
path: src/pocketmine/Server.php
-
message: "#^Call to an undefined method pocketmine\\\\command\\\\CommandSender\\:\\:teleport\\(\\)\\.$#"
count: 1
path: src/pocketmine/command/defaults/TeleportCommand.php
# comment: "not actually possible, but high cost to fix warning"
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\EntityDeathEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\Living but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/EntityDeathEvent.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\EntityShootBowEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\Living but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/EntityShootBowEvent.php
-
message: "#^Property pocketmine\\\\event\\\\entity\\\\EntityShootBowEvent\\:\\:\\$projectile \\(pocketmine\\\\entity\\\\projectile\\\\Projectile\\) does not accept pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/EntityShootBowEvent.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\ItemDespawnEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\object\\\\ItemEntity but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/ItemDespawnEvent.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\ItemSpawnEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\object\\\\ItemEntity but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/ItemSpawnEvent.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\ProjectileHitEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\projectile\\\\Projectile but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/ProjectileHitEvent.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\ProjectileLaunchEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\projectile\\\\Projectile but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/pocketmine/event/entity/ProjectileLaunchEvent.php
-
message: "#^Constructor of class pocketmine\\\\level\\\\generator\\\\hell\\\\Nether has an unused parameter \\$options\\.$#"
count: 1
path: src/pocketmine/level/generator/hell/Nether.php
-
message: "#^Constructor of class pocketmine\\\\level\\\\generator\\\\normal\\\\Normal has an unused parameter \\$options\\.$#"
count: 1
path: src/pocketmine/level/generator/normal/Normal.php
-
message: "#^Constructor of class pocketmine\\\\scheduler\\\\TaskScheduler has an unused parameter \\$logger\\.$#"
count: 1
path: src/pocketmine/scheduler/TaskScheduler.php
-
message: "#^Constant pocketmine\\\\COMPOSER_AUTOLOADER_PATH not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\DATA not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\GIT_COMMIT not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\PLUGIN_PATH not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\START_TIME not found\\.$#"
path: src
-
message: "#^Constant pocketmine\\\\VERSION not found\\.$#"
path: src

View File

@ -30,9 +30,7 @@ use pocketmine\utils\TextFormat;
* Handles the achievement list and a bit more
*/
abstract class Achievement{
/**
* @var array[]
*/
/** @var array[] */
public static $list = [
/*"openInventory" => array(
"name" => "Taking Inventory",
@ -106,13 +104,6 @@ abstract class Achievement{
];
/**
* @param Player $player
* @param string $achievementId
*
* @return bool
*/
public static function broadcast(Player $player, string $achievementId) : bool{
if(isset(Achievement::$list[$achievementId])){
$translation = new TranslationContainer("chat.type.achievement", [$player->getDisplayName(), TextFormat::GREEN . Achievement::$list[$achievementId]["name"] . TextFormat::RESET]);
@ -129,11 +120,7 @@ abstract class Achievement{
}
/**
* @param string $achievementId
* @param string $achievementName
* @param array $requires
*
* @return bool
* @param string[] $requires
*/
public static function add(string $achievementId, string $achievementName, array $requires = []) : bool{
if(!isset(Achievement::$list[$achievementId])){

View File

@ -25,12 +25,16 @@ namespace pocketmine;
abstract class Collectable extends \Threaded{
/** @var bool */
private $isGarbage = false;
public function isGarbage() : bool{
return $this->isGarbage;
}
/**
* @return void
*/
public function setGarbage(){
$this->isGarbage = true;
}

View File

@ -0,0 +1,33 @@
<?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/
*
*
*/
declare(strict_types=1);
namespace pocketmine;
// composer autoload doesn't use require_once and also pthreads can inherit things
if(defined('pocketmine\_CORE_CONSTANTS_INCLUDED')){
return;
}
define('pocketmine\_CORE_CONSTANTS_INCLUDED', true);
define('pocketmine\PATH', dirname(__DIR__, 2) . '/');
define('pocketmine\RESOURCE_PATH', __DIR__ . '/resources/');

View File

@ -96,8 +96,14 @@ class CrashDump{
/** @var Server */
private $server;
/** @var resource */
private $fp;
/** @var int */
private $time;
/**
* @var mixed[]
* @phpstan-var array<string, mixed>
*/
private $data = [];
/** @var string */
private $encodedData = "";
@ -134,15 +140,22 @@ class CrashDump{
return $this->path;
}
/**
* @return string
*/
public function getEncodedData(){
return $this->encodedData;
}
/**
* @return mixed[]
* @phpstan-return array<string, mixed>
*/
public function getData() : array{
return $this->data;
}
private function encodeData(){
private function encodeData() : void{
$this->addLine();
$this->addLine("----------------------REPORT THE DATA BELOW THIS LINE-----------------------");
$this->addLine();
@ -158,7 +171,7 @@ class CrashDump{
$this->addLine("===END CRASH DUMP===");
}
private function pluginsData(){
private function pluginsData() : void{
if($this->server->getPluginManager() instanceof PluginManager){
$this->addLine();
$this->addLine("Loaded plugins:");
@ -182,7 +195,7 @@ class CrashDump{
}
}
private function extraData(){
private function extraData() : void{
global $argv;
if($this->server->getProperty("auto-report.send-settings", true) !== false){
@ -209,7 +222,7 @@ class CrashDump{
}
}
private function baseCrash(){
private function baseCrash() : void{
global $lastExceptionError, $lastError;
if(isset($lastExceptionError)){
@ -317,7 +330,7 @@ class CrashDump{
return false;
}
private function generalData(){
private function generalData() : void{
$version = new VersionString(\pocketmine\BASE_VERSION, \pocketmine\IS_DEVELOPMENT_BUILD, \pocketmine\BUILD_NUMBER);
$this->data["general"] = [];
$this->data["general"]["name"] = $this->server->getName();
@ -340,10 +353,20 @@ class CrashDump{
$this->addLine("OS : " . PHP_OS . ", " . Utils::getOS());
}
/**
* @param string $line
*
* @return void
*/
public function addLine($line = ""){
fwrite($this->fp, $line . PHP_EOL);
}
/**
* @param string $str
*
* @return void
*/
public function add($str){
fwrite($this->fp, $str);
}

View File

@ -0,0 +1,30 @@
<?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/
*
*
*/
// composer autoload doesn't use require_once and also pthreads can inherit things
if(defined('pocketmine\_GLOBAL_CONSTANTS_INCLUDED')){
return;
}
define('pocketmine\_GLOBAL_CONSTANTS_INCLUDED', true);
const INT32_MIN = -0x80000000;
const INT32_MAX = 0x7fffffff;
const INT32_MASK = 0xffffffff;

View File

@ -27,33 +27,21 @@ use pocketmine\permission\ServerOperator;
interface IPlayer extends ServerOperator{
/**
* @return bool
*/
public function isOnline() : bool;
/**
* @return string
*/
public function getName() : string;
/**
* @return bool
*/
public function isBanned() : bool;
/**
* @param bool $banned
* @return void
*/
public function setBanned(bool $banned);
/**
* @return bool
*/
public function isWhitelisted() : bool;
/**
* @param bool $value
* @return void
*/
public function setWhitelisted(bool $value);
@ -72,9 +60,6 @@ interface IPlayer extends ServerOperator{
*/
public function getLastPlayed();
/**
* @return bool
*/
public function hasPlayedBefore() : bool;
}

View File

@ -115,7 +115,7 @@ class MemoryManager{
$this->init();
}
private function init(){
private function init() : void{
$this->memoryLimit = ((int) $this->server->getProperty("memory.main-limit", 0)) * 1024 * 1024;
$defaultMemory = 1024;
@ -169,26 +169,16 @@ class MemoryManager{
gc_enable();
}
/**
* @return bool
*/
public function isLowMemory() : bool{
return $this->lowMemory;
}
/**
* @return bool
*/
public function canUseChunkCache() : bool{
return !$this->lowMemory or !$this->lowMemDisableChunkCache;
}
/**
* Returns the allowed chunk radius based on the current memory usage.
*
* @param int $distance
*
* @return int
*/
public function getViewDistance(int $distance) : int{
return ($this->lowMemory and $this->lowMemChunkRadiusOverride > 0) ? (int) min($this->lowMemChunkRadiusOverride, $distance) : $distance;
@ -197,10 +187,7 @@ class MemoryManager{
/**
* Triggers garbage collection and cache cleanup to try and free memory.
*
* @param int $memory
* @param int $limit
* @param bool $global
* @param int $triggerCount
* @return void
*/
public function trigger(int $memory, int $limit, bool $global = false, int $triggerCount = 0){
$this->server->getLogger()->debug(sprintf("[Memory Manager] %sLow memory triggered, limit %gMB, using %gMB",
@ -230,6 +217,8 @@ class MemoryManager{
/**
* Called every tick to update the memory manager state.
*
* @return void
*/
public function check(){
Timings::$memoryManagerTimer->startTiming();
@ -268,9 +257,6 @@ class MemoryManager{
Timings::$memoryManagerTimer->stopTiming();
}
/**
* @return int
*/
public function triggerGarbageCollector() : int{
Timings::$garbageCollectorTimer->startTiming();
@ -294,9 +280,7 @@ class MemoryManager{
/**
* Dumps the server memory into the specified output folder.
*
* @param string $outputFolder
* @param int $maxNesting
* @param int $maxStringSize
* @return void
*/
public function dumpServerMemory(string $outputFolder, int $maxNesting, int $maxStringSize){
$this->server->getLogger()->notice("[Dump] After the memory dump is done, the server might crash");
@ -314,11 +298,8 @@ class MemoryManager{
* Static memory dumper accessible from any thread.
*
* @param mixed $startingObject
* @param string $outputFolder
* @param int $maxNesting
* @param int $maxStringSize
* @param \Logger $logger
*
* @return void
* @throws \ReflectionException
*/
public static function dumpMemory($startingObject, string $outputFolder, int $maxNesting, int $maxStringSize, \Logger $logger){
@ -451,7 +432,6 @@ class MemoryManager{
fwrite($obData, "$hash@$className: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
}
}while($continue);
$logger->info("[Dump] Wrote " . count($objects) . " objects");
@ -472,14 +452,11 @@ class MemoryManager{
/**
* @param mixed $from
* @param mixed &$data
* @param object[] &$objects
* @param int[] &$refCounts
* @param int $recursion
* @param int $maxNesting
* @param int $maxStringSize
* @param mixed $data reference parameter
* @param object[] $objects reference parameter
* @param int[] $refCounts reference parameter
*/
private static function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize){
private static function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize) : void{
if($maxNesting <= 0){
$data = "(error) NESTING LIMIT REACHED";
return;

View File

@ -37,10 +37,6 @@ class OfflinePlayer implements IPlayer, Metadatable{
/** @var CompoundTag|null */
private $namedtag = null;
/**
* @param Server $server
* @param string $name
*/
public function __construct(Server $server, string $name){
$this->server = $server;
$this->name = $name;
@ -57,6 +53,9 @@ class OfflinePlayer implements IPlayer, Metadatable{
return $this->name;
}
/**
* @return Server
*/
public function getServer(){
return $this->server;
}

File diff suppressed because it is too large Load Diff

View File

@ -21,13 +21,9 @@
declare(strict_types=1);
namespace {
const INT32_MIN = -0x80000000;
const INT32_MAX = 0x7fffffff;
}
namespace pocketmine {
use pocketmine\utils\Git;
use pocketmine\utils\MainLogger;
use pocketmine\utils\ServerKiller;
use pocketmine\utils\Terminal;
@ -40,6 +36,10 @@ namespace pocketmine {
const MIN_PHP_VERSION = "7.2.0";
/**
* @param string $message
* @return void
*/
function critical_error($message){
echo "[ERROR] $message" . PHP_EOL;
}
@ -121,6 +121,10 @@ namespace pocketmine {
return $messages;
}
/**
* @param \Logger $logger
* @return void
*/
function emit_performance_warnings(\Logger $logger){
if(extension_loaded("xdebug")){
$logger->warning("Xdebug extension is enabled. This has a major impact on performance.");
@ -136,6 +140,9 @@ namespace pocketmine {
}
}
/**
* @return void
*/
function set_ini_entries(){
ini_set("allow_url_fopen", '1');
ini_set("display_errors", '1');
@ -144,8 +151,11 @@ namespace pocketmine {
ini_set('assert.exception', '1');
}
/**
* @return void
*/
function server(){
if(!empty($messages = check_platform_dependencies())){
if(count($messages = check_platform_dependencies()) > 0){
echo PHP_EOL;
$binary = version_compare(PHP_VERSION, "5.4") >= 0 ? PHP_BINARY : "unknown";
critical_error("Selected PHP binary ($binary) does not satisfy some requirements.");
@ -160,19 +170,12 @@ namespace pocketmine {
error_reporting(-1);
set_ini_entries();
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
if(\Phar::running(true) !== ""){
define('pocketmine\PATH', \Phar::running(true) . "/");
}else{
define('pocketmine\PATH', dirname(__FILE__, 3) . DIRECTORY_SEPARATOR);
}
$opts = getopt("", ["bootstrap:"]);
if(isset($opts["bootstrap"])){
$bootstrap = realpath($opts["bootstrap"]) ?: $opts["bootstrap"];
}else{
$bootstrap = \pocketmine\PATH . 'vendor/autoload.php';
$bootstrap = dirname(__FILE__, 3) . '/vendor/autoload.php';
}
define('pocketmine\COMPOSER_AUTOLOADER_PATH', $bootstrap);
@ -192,12 +195,7 @@ namespace pocketmine {
$gitHash = str_repeat("00", 20);
if(\Phar::running(true) === ""){
if(Utils::execute("git rev-parse HEAD", $out) === 0 and $out !== false and strlen($out = trim($out)) === 40){
$gitHash = trim($out);
if(Utils::execute("git diff --quiet") === 1 or Utils::execute("git diff --cached --quiet") === 1){ //Locally-modified
$gitHash .= "-dirty";
}
}
$gitHash = Git::getRepositoryStatePretty(\pocketmine\PATH);
}else{
$phar = new \Phar(\Phar::running(false));
$meta = $phar->getMetadata();
@ -208,8 +206,6 @@ namespace pocketmine {
define('pocketmine\GIT_COMMIT', $gitHash);
define('pocketmine\RESOURCE_PATH', \pocketmine\PATH . 'src' . DIRECTORY_SEPARATOR . 'pocketmine' . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR);
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-ansi", "disable-ansi"]);
define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : realpath(getcwd()) . DIRECTORY_SEPARATOR);
@ -297,5 +293,7 @@ namespace pocketmine {
exit($exitCode);
}
\pocketmine\server();
if(!defined('pocketmine\_PHPSTAN_ANALYSIS')){
\pocketmine\server();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -33,12 +33,19 @@ abstract class Thread extends \Thread{
/** @var string|null */
protected $composerAutoloaderPath;
/** @var bool */
protected $isKilled = false;
/**
* @return \ClassLoader|null
*/
public function getClassLoader(){
return $this->classLoader;
}
/**
* @return void
*/
public function setClassLoader(\ClassLoader $loader = null){
$this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH;
@ -54,6 +61,8 @@ abstract class Thread extends \Thread{
* WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable.
* If you do not do this, you will not be able to use new classes that were not loaded when the thread was started
* (unless you are using a custom autoloader).
*
* @return void
*/
public function registerClassLoader(){
if($this->composerAutoloaderPath !== null){
@ -64,6 +73,11 @@ abstract class Thread extends \Thread{
}
}
/**
* @param int|null $options TODO: pthreads bug
*
* @return bool
*/
public function start(?int $options = \PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);
@ -75,6 +89,8 @@ abstract class Thread extends \Thread{
/**
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*
* @return void
*/
public function quit(){
$this->isKilled = true;

View File

@ -31,6 +31,9 @@ class ThreadManager extends \Volatile{
/** @var ThreadManager */
private static $instance = null;
/**
* @return void
*/
public static function init(){
self::$instance = new ThreadManager();
}
@ -44,6 +47,8 @@ class ThreadManager extends \Volatile{
/**
* @param Worker|Thread $thread
*
* @return void
*/
public function add($thread){
if($thread instanceof Thread or $thread instanceof Worker){
@ -53,6 +58,8 @@ class ThreadManager extends \Volatile{
/**
* @param Worker|Thread $thread
*
* @return void
*/
public function remove($thread){
if($thread instanceof Thread or $thread instanceof Worker){

View File

@ -19,9 +19,18 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
// composer autoload doesn't use require_once and also pthreads can inherit things
// TODO: drop this file and use a final class with constants
if(defined('pocketmine\_VERSION_INFO_INCLUDED')){
return;
}
const _VERSION_INFO_INCLUDED = true;
const NAME = "PocketMine-MP";
const BASE_VERSION = "3.9.7";
const BASE_VERSION = "3.11.5";
const IS_DEVELOPMENT_BUILD = false;
const BUILD_NUMBER = 0;

View File

@ -33,12 +33,19 @@ abstract class Worker extends \Worker{
/** @var string|null */
protected $composerAutoloaderPath;
/** @var bool */
protected $isKilled = false;
/**
* @return \ClassLoader|null
*/
public function getClassLoader(){
return $this->classLoader;
}
/**
* @return void
*/
public function setClassLoader(\ClassLoader $loader = null){
$this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH;
@ -54,6 +61,8 @@ abstract class Worker extends \Worker{
* WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable.
* If you do not do this, you will not be able to use new classes that were not loaded when the thread was started
* (unless you are using a custom autoloader).
*
* @return void
*/
public function registerClassLoader(){
if($this->composerAutoloaderPath !== null){
@ -64,6 +73,11 @@ abstract class Worker extends \Worker{
}
}
/**
* @param int|null $options TODO: pthreads bug
*
* @return bool
*/
public function start(?int $options = \PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);
@ -75,6 +89,8 @@ abstract class Worker extends \Worker{
/**
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*
* @return void
*/
public function quit(){
$this->isKilled = true;

View File

@ -26,7 +26,6 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
/**
* Air block
*/

View File

@ -99,6 +99,11 @@ abstract class BaseRail extends Flowable{
return false;
}
/**
* @param int[] $connections
* @param int[][] $lookup
* @phpstan-param array<int, list<int>> $lookup
*/
protected static function searchState(array $connections, array $lookup) : int{
$meta = array_search($connections, $lookup, true);
if($meta === false){
@ -114,9 +119,7 @@ abstract class BaseRail extends Flowable{
/**
* Returns a meta value for the rail with the given connections.
*
* @param array $connections
*
* @return int
* @param int[] $connections
*
* @throws \InvalidArgumentException if no state matches the given connections
*/
@ -164,6 +167,12 @@ abstract class BaseRail extends Flowable{
return $connections;
}
/**
* @param int[] $constraints
*
* @return true[]
* @phpstan-return array<int, true>
*/
private function getPossibleConnectionDirections(array $constraints) : array{
switch(count($constraints)){
case 0:
@ -188,6 +197,10 @@ abstract class BaseRail extends Flowable{
}
}
/**
* @return true[]
* @phpstan-return array<int, true>
*/
protected function getPossibleConnectionDirectionsOneConstraint(int $constraint) : array{
$opposite = Vector3::getOppositeSide($constraint & ~self::FLAG_ASCEND);
@ -247,6 +260,9 @@ abstract class BaseRail extends Flowable{
}
}
/**
* @param int[] $connections
*/
private function updateState(array $connections) : void{
if(count($connections) === 1){
$connections[] = Vector3::getOppositeSide($connections[0] & ~self::FLAG_ASCEND);

View File

@ -69,13 +69,13 @@ class Bed extends Transparent{
return ($this->meta & self::BITFLAG_HEAD) !== 0;
}
/**
* @return bool
*/
public function isOccupied() : bool{
return ($this->meta & self::BITFLAG_OCCUPIED) !== 0;
}
/**
* @return void
*/
public function setOccupied(bool $occupied = true){
if($occupied){
$this->meta |= self::BITFLAG_OCCUPIED;
@ -90,12 +90,6 @@ class Bed extends Transparent{
}
}
/**
* @param int $meta
* @param bool $isHead
*
* @return int
*/
public static function getOtherHalfSide(int $meta, bool $isHead = false) : int{
$rotation = $meta & 0x03;
$side = -1;
@ -122,9 +116,6 @@ class Bed extends Transparent{
return $side;
}
/**
* @return Bed|null
*/
public function getOtherHalf() : ?Bed{
$other = $this->getSide(self::getOtherHalfSide($this->meta, $this->isHeadPart()));
if($other instanceof Bed and $other->getId() === $this->getId() and $other->isHeadPart() !== $this->isHeadPart() and (($other->getDamage() & 0x03) === ($this->getDamage() & 0x03))){

View File

@ -40,6 +40,7 @@ use pocketmine\network\mcpe\protocol\types\RuntimeBlockMapping;
use pocketmine\Player;
use pocketmine\plugin\Plugin;
use function array_merge;
use function count;
use function get_class;
use const PHP_INT_MAX;
@ -49,12 +50,6 @@ class Block extends Position implements BlockIds, Metadatable{
* Returns a new Block instance with the specified ID, meta and position.
*
* This function redirects to {@link BlockFactory#get}.
*
* @param int $id
* @param int $meta
* @param Position|null $pos
*
* @return Block
*/
public static function get(int $id, int $meta = 0, Position $pos = null) : Block{
return BlockFactory::get($id, $meta, $pos);
@ -72,7 +67,6 @@ class Block extends Position implements BlockIds, Metadatable{
/** @var AxisAlignedBB|null */
protected $boundingBox = null;
/** @var AxisAlignedBB[]|null */
protected $collisionBoxes = null;
@ -89,16 +83,10 @@ class Block extends Position implements BlockIds, Metadatable{
$this->itemId = $itemId;
}
/**
* @return string
*/
public function getName() : string{
return $this->fallbackName ?? "Unknown";
}
/**
* @return int
*/
final public function getId() : int{
return $this->id;
}
@ -106,8 +94,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns the ID of the item form of the block.
* Used for drops for blocks (some blocks such as doors have a different item ID).
*
* @return int
*/
public function getItemId() : int{
return $this->itemId ?? $this->getId();
@ -115,22 +101,15 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* @internal
* @return int
*/
public function getRuntimeId() : int{
return RuntimeBlockMapping::toStaticRuntimeId($this->getId(), $this->getDamage());
}
/**
* @return int
*/
final public function getDamage() : int{
return $this->meta;
}
/**
* @param int $meta
*/
final public function setDamage(int $meta) : void{
if($meta < 0 or $meta > 0xf){
throw new \InvalidArgumentException("Block damage values must be 0-15, not $meta");
@ -144,8 +123,6 @@ class Block extends Position implements BlockIds, Metadatable{
*
* If your block should not have any meta value when it's dropped as an item, override this to return 0 in
* descendent classes.
*
* @return int
*/
public function getVariantBitmask() : int{
return -1;
@ -153,24 +130,18 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns the block meta, stripped of non-variant flags.
* @return int
*/
public function getVariant() : int{
return $this->meta & $this->getVariantBitmask();
}
/**
* AKA: Block->isPlaceable
* @return bool
*/
public function canBePlaced() : bool{
return true;
}
/**
* @return bool
*/
public function canBeReplaced() : bool{
return false;
}
@ -181,15 +152,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Places the Block, using block space and block target, and side. Returns if the block has been placed.
*
* @param Item $item
* @param Block $blockReplace
* @param Block $blockClicked
* @param int $face
* @param Vector3 $clickVector
* @param Player|null $player
*
* @return bool
*/
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
return $this->getLevel()->setBlock($this, $this, true, true);
@ -197,18 +159,11 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns if the block can be broken with an specific Item
*
* @param Item $item
*
* @return bool
*/
public function isBreakable(Item $item) : bool{
return true;
}
/**
* @return int
*/
public function getToolType() : int{
return BlockToolType::TYPE_NONE;
}
@ -222,8 +177,6 @@ class Block extends Position implements BlockIds, Metadatable{
* Otherwise, 1 should be returned if a tool is required, 0 if not.
*
* @see Item::getBlockToolHarvestLevel()
*
* @return int
*/
public function getToolHarvestLevel() : int{
return 0;
@ -235,10 +188,6 @@ class Block extends Position implements BlockIds, Metadatable{
*
* In most cases this is also used to determine whether block drops should be created or not, except in some
* special cases such as vines.
*
* @param Item $tool
*
* @return bool
*/
public function isCompatibleWithTool(Item $tool) : bool{
if($this->getHardness() < 0){
@ -253,23 +202,14 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Do the actions needed so the block is broken with the Item
*
* @param Item $item
* @param Player|null $player
*
* @return bool
*/
public function onBreak(Item $item, Player $player = null) : bool{
return $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true, true);
}
/**
* Returns the seconds that this block takes to be broken using an specific Item
*
* @param Item $item
*
* @return float
* @throws \InvalidArgumentException if the item efficiency is not a positive number
*/
public function getBreakTime(Item $item) : float{
@ -299,8 +239,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns whether random block updates will be done on this block.
*
* @return bool
*/
public function ticksRandomly() : bool{
return false;
@ -323,11 +261,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Do actions when activated by Item. Returns if it has done anything
*
* @param Item $item
* @param Player|null $player
*
* @return bool
*/
public function onActivate(Item $item, Player $player = null) : bool{
return false;
@ -335,7 +268,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns a base value used to compute block break times.
* @return float
*/
public function getHardness() : float{
return 10;
@ -343,15 +275,11 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns the block's resistance to explosions. Usually 5x hardness.
* @return float
*/
public function getBlastResistance() : float{
return $this->getHardness() * 5;
}
/**
* @return float
*/
public function getFrictionFactor() : float{
return 0.6;
}
@ -379,16 +307,11 @@ class Block extends Position implements BlockIds, Metadatable{
* Examples of this behaviour include leaves and cobwebs.
*
* Light-diffusing blocks are included by the heightmap.
*
* @return bool
*/
public function diffusesSkyLight() : bool{
return false;
}
/**
* @return bool
*/
public function isTransparent() : bool{
return false;
}
@ -399,7 +322,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* AKA: Block->isFlowable
* @return bool
*/
public function canBeFlowedInto() : bool{
return false;
@ -415,21 +337,17 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns whether entities can climb up this block.
* @return bool
*/
public function canClimb() : bool{
return false;
}
public function addVelocityToEntity(Entity $entity, Vector3 $vector) : void{
}
/**
* Sets the block position to a new Position object
*
* @param Position $v
*/
final public function position(Position $v) : void{
$this->x = (int) $v->x;
@ -442,8 +360,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns an array of Item objects to be dropped
*
* @param Item $item
*
* @return Item[]
*/
public function getDrops(Item $item) : array{
@ -461,8 +377,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns an array of Items to be dropped when the block is broken using the correct tool type.
*
* @param Item $item
*
* @return Item[]
*/
public function getDropsForCompatibleTool(Item $item) : array{
@ -474,8 +388,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns an array of Items to be dropped when the block is broken using a compatible Silk Touch-enchanted tool.
*
* @param Item $item
*
* @return Item[]
*/
public function getSilkTouchDrops(Item $item) : array{
@ -486,10 +398,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns how much XP will be dropped by breaking this block with the given item.
*
* @param Item $item
*
* @return int
*/
public function getXpDropForTool(Item $item) : int{
if($item->hasEnchantment(Enchantment::SILK_TOUCH) or !$this->isCompatibleWithTool($item)){
@ -501,8 +409,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns how much XP this block will drop when broken with an appropriate tool.
*
* @return int
*/
protected function getXpDropAmount() : int{
return 0;
@ -511,8 +417,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns whether Silk Touch enchanted tools will cause this block to drop as itself. Since most blocks drop
* themselves anyway, this is implicitly true.
*
* @return bool
*/
public function isAffectedBySilkTouch() : bool{
return true;
@ -520,7 +424,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns the item that players will equip when middle-clicking on this block.
* @return Item
*/
public function getPickedItem() : Item{
return ItemFactory::get($this->getItemId(), $this->getVariant());
@ -528,7 +431,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns the time in ticks which the block will fuel a furnace for.
* @return int
*/
public function getFuelTime() : int{
return 0;
@ -537,8 +439,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns the chance that the block will catch fire from nearby fire sources. Higher values lead to faster catching
* fire.
*
* @return int
*/
public function getFlameEncouragement() : int{
return 0;
@ -546,8 +446,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns the base flammability of this block. Higher values lead to the block burning away more quickly.
*
* @return int
*/
public function getFlammability() : int{
return 0;
@ -555,8 +453,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns whether fire lit on this block will burn indefinitely.
*
* @return bool
*/
public function burnsForever() : bool{
return false;
@ -564,8 +460,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns whether this block can catch fire.
*
* @return bool
*/
public function isFlammable() : bool{
return $this->getFlammability() > 0;
@ -581,9 +475,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Returns the Block on the side $side, works like Vector3::getSide()
*
* @param int $side
* @param int $step
*
* @return Block
*/
public function getSide(int $side, int $step = 1){
@ -642,10 +533,6 @@ class Block extends Position implements BlockIds, Metadatable{
/**
* Checks for collision against an AxisAlignedBB
*
* @param AxisAlignedBB $bb
*
* @return bool
*/
public function collidesWithBB(AxisAlignedBB $bb) : bool{
foreach($this->getCollisionBoxes() as $bb2){
@ -657,9 +544,6 @@ class Block extends Position implements BlockIds, Metadatable{
return false;
}
/**
* @param Entity $entity
*/
public function onEntityCollide(Entity $entity) : void{
}
@ -686,9 +570,6 @@ class Block extends Position implements BlockIds, Metadatable{
return [];
}
/**
* @return AxisAlignedBB|null
*/
public function getBoundingBox() : ?AxisAlignedBB{
if($this->boundingBox === null){
$this->boundingBox = $this->recalculateBoundingBox();
@ -696,9 +577,6 @@ class Block extends Position implements BlockIds, Metadatable{
return $this->boundingBox;
}
/**
* @return AxisAlignedBB|null
*/
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return new AxisAlignedBB(
$this->x,
@ -719,15 +597,9 @@ class Block extends Position implements BlockIds, Metadatable{
$this->collisionBoxes = null;
}
/**
* @param Vector3 $pos1
* @param Vector3 $pos2
*
* @return RayTraceResult|null
*/
public function calculateIntercept(Vector3 $pos1, Vector3 $pos2) : ?RayTraceResult{
$bbs = $this->getCollisionBoxes();
if(empty($bbs)){
if(count($bbs) === 0){
return null;
}
@ -763,7 +635,7 @@ class Block extends Position implements BlockIds, Metadatable{
return $this->level->getBlockMetadata()->getMetadata($this, $metadataKey);
}
return null;
return [];
}
public function hasMetadata(string $metadataKey) : bool{

View File

@ -334,7 +334,6 @@ class BlockFactory{
* NOTE: If you are registering a new block type, you will need to add it to the creative inventory yourself - it
* will not automatically appear there.
*
* @param Block $block
* @param bool $override Whether to override existing registrations
*
* @throws \RuntimeException if something attempted to override an already-registered block without specifying the
@ -364,12 +363,6 @@ class BlockFactory{
/**
* Returns a new Block instance with the specified ID, meta and position.
*
* @param int $id
* @param int $meta
* @param Position $pos
*
* @return Block
*/
public static function get(int $id, int $meta = 0, Position $pos = null) : Block{
if($meta < 0 or $meta > 0xf){
@ -398,7 +391,6 @@ class BlockFactory{
/**
* @internal
* @return \SplFixedArray
*/
public static function getBlockStatesArray() : \SplFixedArray{
return self::$fullList;
@ -406,10 +398,6 @@ class BlockFactory{
/**
* Returns whether a specified block ID is already registered in the block factory.
*
* @param int $id
*
* @return bool
*/
public static function isRegistered(int $id) : bool{
$b = self::$fullList[$id << 4];
@ -419,11 +407,6 @@ class BlockFactory{
/**
* @internal
* @deprecated
*
* @param int $id
* @param int $meta
*
* @return int
*/
public static function toStaticRuntimeId(int $id, int $meta = 0) : int{
return RuntimeBlockMapping::toStaticRuntimeId($id, $meta);
@ -433,8 +416,6 @@ class BlockFactory{
* @deprecated
* @internal
*
* @param int $runtimeId
*
* @return int[] [id, meta]
*/
public static function fromStaticRuntimeId(int $runtimeId) : array{

View File

@ -80,6 +80,9 @@ class BurningFurnace extends Solid{
$furnace = $this->getLevel()->getTile($this);
if(!($furnace instanceof TileFurnace)){
$furnace = Tile::createTile(Tile::FURNACE, $this->getLevel(), TileFurnace::createNBT($this));
if(!($furnace instanceof TileFurnace)){
return true;
}
}
if(!$furnace->canOpenWith($item->getCustomName())){

View File

@ -109,6 +109,9 @@ class Chest extends Transparent{
$chest = $t;
}else{
$chest = Tile::createTile(Tile::CHEST, $this->getLevel(), TileChest::createNBT($this));
if(!($chest instanceof TileChest)){
return true;
}
}
if(

View File

@ -111,6 +111,9 @@ class CobblestoneWall extends Transparent{
);
}
/**
* @return bool
*/
public function canConnect(Block $block){
return $block instanceof static or $block instanceof FenceGate or ($block->isSolid() and !$block->isTransparent());
}

View File

@ -53,16 +53,10 @@ class ConcretePowder extends Fallable{
}
}
/**
* @return null|Block
*/
public function tickFalling() : ?Block{
return $this->checkAdjacentWater();
}
/**
* @return null|Block
*/
private function checkAdjacentWater() : ?Block{
for($i = 1; $i < 6; ++$i){ //Do not check underneath
if($this->getSide($i) instanceof Water){

View File

@ -41,7 +41,6 @@ abstract class Crops extends Flowable{
return false;
}
public function onActivate(Item $item, Player $player = null) : bool{
if($this->meta < 7 and $item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$block = clone $this;

View File

@ -39,7 +39,6 @@ class Dandelion extends Flowable{
return "Dandelion";
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === Block::GRASS or $down->getId() === Block::DIRT or $down->getId() === Block::FARMLAND){

View File

@ -29,14 +29,13 @@ use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
abstract class Door extends Transparent{
public function isSolid() : bool{
return false;
}
private function getFullDamage(){
private function getFullDamage() : int{
$damage = $this->getDamage();
$isUp = ($damage & 0x08) > 0;

View File

@ -68,7 +68,6 @@ class DoublePlant extends Flowable{
/**
* Returns whether this double-plant has a corresponding other half.
* @return bool
*/
public function isValidHalfPlant() : bool{
if($this->meta & self::BITFLAG_TOP){

View File

@ -84,6 +84,9 @@ class EnderChest extends Chest{
$enderChest = $t;
}else{
$enderChest = Tile::createTile(Tile::ENDER_CHEST, $this->getLevel(), TileEnderChest::createNBT($this));
if(!($enderChest instanceof TileEnderChest)){
return true;
}
}
if(!$this->getSide(Vector3::SIDE_UP)->isTransparent()){

View File

@ -45,9 +45,6 @@ abstract class Fallable extends Solid{
}
}
/**
* @return null|Block
*/
public function tickFalling() : ?Block{
return null;
}

View File

@ -48,7 +48,6 @@ class Farmland extends Transparent{
return BlockToolType::TYPE_SHOVEL;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return new AxisAlignedBB(
$this->x,

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use function count;
abstract class Fence extends Transparent{
@ -85,7 +86,7 @@ abstract class Fence extends Transparent{
);
}
if(empty($bbs)){
if(count($bbs) === 0){
//centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made)
return [
new AxisAlignedBB(
@ -102,6 +103,9 @@ abstract class Fence extends Transparent{
return $bbs;
}
/**
* @return bool
*/
public function canConnect(Block $block){
return $block instanceof static or $block instanceof FenceGate or ($block->isSolid() and !$block->isTransparent());
}

View File

@ -39,7 +39,6 @@ class FenceGate extends Transparent{
return BlockToolType::TYPE_AXE;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
if(($this->getDamage() & 0x04) > 0){

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\block;
class Furnace extends BurningFurnace{
protected $id = self::FURNACE;

View File

@ -1,6 +1,5 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\TieredTool;
class GlowingObsidian extends Solid{

View File

@ -47,6 +47,9 @@ class ItemFrame extends Flowable{
$tile = $this->level->getTile($this);
if(!($tile instanceof TileItemFrame)){
$tile = Tile::createTile(Tile::ITEM_FRAME, $this->getLevel(), TileItemFrame::createNBT($this));
if(!($tile instanceof TileItemFrame)){
return true;
}
}
if($tile->hasItem()){

View File

@ -90,7 +90,6 @@ class Ladder extends Transparent{
);
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
if(!$blockClicked->isTransparent()){
$faces = [

View File

@ -39,6 +39,7 @@ class Leaves extends Transparent{
public const DARK_OAK = 1;
protected $id = self::LEAVES;
/** @var int */
protected $woodType = self::WOOD;
public function __construct(int $meta = 0){
@ -67,8 +68,11 @@ class Leaves extends Transparent{
return true;
}
protected function findLog(Block $pos, array $visited, int $distance, ?int $fromSide = null) : bool{
/**
* @param true[] $visited reference parameter
* @phpstan-param array<string, true> $visited
*/
protected function findLog(Block $pos, array &$visited, int $distance, ?int $fromSide = null) : bool{
$index = $pos->x . "." . $pos->y . "." . $pos->z;
if(isset($visited[$index])){
return false;

View File

@ -29,6 +29,7 @@ use pocketmine\item\ItemFactory;
class Leaves2 extends Leaves{
protected $id = self::LEAVES2;
/** @var int */
protected $woodType = self::WOOD2;
public function getName() : string{

View File

@ -38,6 +38,7 @@ use function min;
abstract class Liquid extends Transparent{
/** @var int */
public $adjacentSources = 0;
/** @var Vector3|null */
@ -90,6 +91,9 @@ abstract class Liquid extends Transparent{
abstract public function getBucketEmptySound() : int;
/**
* @return float
*/
public function getFluidHeightPercent(){
$d = $this->meta;
if($d >= 8){
@ -207,8 +211,6 @@ abstract class Liquid extends Transparent{
/**
* Returns how many liquid levels are lost per block flowed horizontally. Affects how far the liquid can flow.
*
* @return int
*/
public function getFlowDecayPerBlock() : int{
return 1;
@ -430,6 +432,9 @@ abstract class Liquid extends Transparent{
return ($decay >= 0 && $blockDecay >= $decay) ? $decay : $blockDecay;
}
/**
* @return void
*/
protected function checkForHarden(){
}

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\block;
class MossyCobblestone extends Cobblestone{
protected $id = self::MOSSY_COBBLESTONE;

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;

View File

@ -57,7 +57,6 @@ class SignPost extends Transparent{
return null;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
if($face !== Vector3::SIDE_DOWN){

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\block;
class Sponge extends Solid{
protected $id = self::SPONGE;

View File

@ -74,6 +74,9 @@ class TNT extends Solid{
}
}
/**
* @return void
*/
public function ignite(int $fuse = 80){
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true);

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use function count;
abstract class Thin extends Transparent{
@ -77,7 +78,7 @@ abstract class Thin extends Transparent{
);
}
if(empty($bbs)){
if(count($bbs) === 0){
//centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made)
return [
new AxisAlignedBB(

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\block;
abstract class Transparent extends Block{
public function isTransparent() : bool{

View File

@ -55,7 +55,6 @@ class WaterLily extends Flowable{
);
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
if($blockClicked instanceof Water){
$up = $blockClicked->getSide(Vector3::SIDE_UP);

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\block;
class Wood2 extends Wood{
public const ACACIA = 0;

View File

@ -50,12 +50,10 @@ abstract class Command{
/** @var string[] */
private $aliases = [];
/**
* @var string[]
*/
/** @var string[] */
private $activeAliases = [];
/** @var CommandMap */
/** @var CommandMap|null */
private $commandMap = null;
/** @var string */
@ -74,9 +72,6 @@ abstract class Command{
public $timings;
/**
* @param string $name
* @param string $description
* @param string $usageMessage
* @param string[] $aliases
*/
public function __construct(string $name, string $description = "", string $usageMessage = null, array $aliases = []){
@ -88,18 +83,13 @@ abstract class Command{
}
/**
* @param CommandSender $sender
* @param string $commandLabel
* @param string[] $args
* @param string[] $args
*
* @return mixed
* @throws CommandException
*/
abstract public function execute(CommandSender $sender, string $commandLabel, array $args);
/**
* @return string
*/
public function getName() : string{
return $this->name;
}
@ -111,19 +101,13 @@ abstract class Command{
return $this->permission;
}
/**
* @param string|null $permission
* @return void
*/
public function setPermission(string $permission = null){
$this->permission = $permission;
}
/**
* @param CommandSender $target
*
* @return bool
*/
public function testPermission(CommandSender $target) : bool{
if($this->testPermissionSilent($target)){
return true;
@ -138,11 +122,6 @@ abstract class Command{
return false;
}
/**
* @param CommandSender $target
*
* @return bool
*/
public function testPermissionSilent(CommandSender $target) : bool{
if($this->permission === null or $this->permission === ""){
return true;
@ -157,9 +136,6 @@ abstract class Command{
return false;
}
/**
* @return string
*/
public function getLabel() : string{
return $this->label;
}
@ -181,10 +157,6 @@ abstract class Command{
/**
* Registers the command into a Command map
*
* @param CommandMap $commandMap
*
* @return bool
*/
public function register(CommandMap $commandMap) : bool{
if($this->allowChangesFrom($commandMap)){
@ -196,11 +168,6 @@ abstract class Command{
return false;
}
/**
* @param CommandMap $commandMap
*
* @return bool
*/
public function unregister(CommandMap $commandMap) : bool{
if($this->allowChangesFrom($commandMap)){
$this->commandMap = null;
@ -213,18 +180,10 @@ abstract class Command{
return false;
}
/**
* @param CommandMap $commandMap
*
* @return bool
*/
private function allowChangesFrom(CommandMap $commandMap) : bool{
return $this->commandMap === null or $this->commandMap === $commandMap;
}
/**
* @return bool
*/
public function isRegistered() : bool{
return $this->commandMap !== null;
}
@ -236,29 +195,22 @@ abstract class Command{
return $this->activeAliases;
}
/**
* @return string|null
*/
public function getPermissionMessage() : ?string{
return $this->permissionMessage;
}
/**
* @return string
*/
public function getDescription() : string{
return $this->description;
}
/**
* @return string
*/
public function getUsage() : string{
return $this->usageMessage;
}
/**
* @param string[] $aliases
*
* @return void
*/
public function setAliases(array $aliases){
$this->aliases = $aliases;
@ -268,30 +220,30 @@ abstract class Command{
}
/**
* @param string $description
* @return void
*/
public function setDescription(string $description){
$this->description = $description;
}
/**
* @param string $permissionMessage
* @return void
*/
public function setPermissionMessage(string $permissionMessage){
$this->permissionMessage = $permissionMessage;
}
/**
* @param string $usage
* @return void
*/
public function setUsage(string $usage){
$this->usageMessage = $usage;
}
/**
* @param CommandSender $source
* @param TextContainer|string $message
* @param bool $sendToSource
*
* @return void
*/
public static function broadcastCommandMessage(CommandSender $source, $message, bool $sendToSource = true){
if($message instanceof TextContainer){
@ -326,9 +278,6 @@ abstract class Command{
}
}
/**
* @return string
*/
public function __toString() : string{
return $this->name;
}

View File

@ -23,16 +23,10 @@ declare(strict_types=1);
namespace pocketmine\command;
interface CommandExecutor{
/**
* @param CommandSender $sender
* @param Command $command
* @param string $label
* @param string[] $args
*
* @return bool
*/
public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool;

View File

@ -23,30 +23,17 @@ declare(strict_types=1);
namespace pocketmine\command;
interface CommandMap{
/**
* @param string $fallbackPrefix
* @param Command[] $commands
*
* @return void
*/
public function registerAll(string $fallbackPrefix, array $commands);
/**
* @param string $fallbackPrefix
* @param Command $command
* @param string|null $label
*
* @return bool
*/
public function register(string $fallbackPrefix, Command $command, string $label = null) : bool;
/**
* @param CommandSender $sender
* @param string $cmdLine
*
* @return bool
*/
public function dispatch(CommandSender $sender, string $cmdLine) : bool;
/**
@ -55,11 +42,8 @@ interface CommandMap{
public function clearCommands();
/**
* @param string $name
*
* @return Command|null
*/
public function getCommand(string $name);
}

View File

@ -54,7 +54,9 @@ class CommandReader extends Thread{
/** @var \Threaded */
protected $buffer;
/** @var bool */
private $shutdown = false;
/** @var int */
private $type = self::TYPE_STREAM;
/** @var SleeperNotifier|null */
@ -71,6 +73,9 @@ class CommandReader extends Thread{
}
}
/**
* @return void
*/
public function shutdown(){
$this->shutdown = true;
}
@ -94,7 +99,7 @@ class CommandReader extends Thread{
throw new \ThreadException($message);
}
private function initStdin(){
private function initStdin() : void{
if(is_resource(self::$stdin)){
fclose(self::$stdin);
}
@ -111,8 +116,6 @@ class CommandReader extends Thread{
* Checks if the specified stream is a FIFO pipe.
*
* @param resource $stream
*
* @return bool
*/
private function isPipe($stream) : bool{
return is_resource($stream) and (!stream_isatty($stream) or ((fstat($stream)["mode"] & 0170000) === 0010000));
@ -185,6 +188,9 @@ class CommandReader extends Thread{
return null;
}
/**
* @return void
*/
public function run(){
$this->registerClassLoader();

View File

@ -31,6 +31,8 @@ interface CommandSender extends Permissible{
/**
* @param TextContainer|string $message
*
* @return void
*/
public function sendMessage($message);
@ -39,23 +41,18 @@ interface CommandSender extends Permissible{
*/
public function getServer();
/**
* @return string
*/
public function getName() : string;
/**
* Returns the line height of the command-sender's screen. Used for determining sizes for command output pagination
* such as in the /help command.
*
* @return int
*/
public function getScreenLineHeight() : int;
/**
* Sets the line height used for command output pagination for this command sender. `null` will reset it to default.
*
* @param int|null $height
* @return void
*/
public function setScreenLineHeight(int $height = null);
}

View File

@ -37,6 +37,7 @@ use const PHP_INT_MAX;
class ConsoleCommandSender implements CommandSender{
/** @var PermissibleBase */
private $perm;
/** @var int|null */
@ -48,8 +49,6 @@ class ConsoleCommandSender implements CommandSender{
/**
* @param Permission|string $name
*
* @return bool
*/
public function isPermissionSet($name) : bool{
return $this->perm->isPermissionSet($name);
@ -57,27 +56,16 @@ class ConsoleCommandSender implements CommandSender{
/**
* @param Permission|string $name
*
* @return bool
*/
public function hasPermission($name) : bool{
return $this->perm->hasPermission($name);
}
/**
* @param Plugin $plugin
* @param string $name
* @param bool $value
*
* @return PermissionAttachment
*/
public function addAttachment(Plugin $plugin, string $name = null, bool $value = null) : PermissionAttachment{
return $this->perm->addAttachment($plugin, $name, $value);
}
/**
* @param PermissionAttachment $attachment
*
* @return void
*/
public function removeAttachment(PermissionAttachment $attachment){
@ -104,6 +92,8 @@ class ConsoleCommandSender implements CommandSender{
/**
* @param TextContainer|string $message
*
* @return void
*/
public function sendMessage($message){
if($message instanceof TextContainer){
@ -117,22 +107,16 @@ class ConsoleCommandSender implements CommandSender{
}
}
/**
* @return string
*/
public function getName() : string{
return "CONSOLE";
}
/**
* @return bool
*/
public function isOp() : bool{
return true;
}
/**
* @param bool $value
* @return void
*/
public function setOp(bool $value){

View File

@ -32,10 +32,10 @@ use function strpos;
use function substr;
class FormattedCommandAlias extends Command{
/** @var string[] */
private $formatStrings = [];
/**
* @param string $alias
* @param string[] $formatStrings
*/
public function __construct(string $alias, array $formatStrings){
@ -65,10 +65,7 @@ class FormattedCommandAlias extends Command{
}
/**
* @param string $formatString
* @param array $args
*
* @return string
* @param string[] $args
*/
private function buildCommand(string $formatString, array $args) : string{
$index = strpos($formatString, '$');
@ -143,13 +140,6 @@ class FormattedCommandAlias extends Command{
return $formatString;
}
/**
* @param int $i
* @param int $j
* @param int $k
*
* @return bool
*/
private static function inRange(int $i, int $j, int $k) : bool{
return $i >= $j and $i <= $k;
}

View File

@ -34,10 +34,6 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{
/** @var CommandExecutor */
private $executor;
/**
* @param string $name
* @param Plugin $owner
*/
public function __construct(string $name, Plugin $owner){
parent::__construct($name);
$this->owningPlugin = $owner;
@ -69,15 +65,12 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{
}
/**
* @param CommandExecutor $executor
* @return void
*/
public function setExecutor(CommandExecutor $executor){
$this->executor = $executor;
}
/**
* @return Plugin
*/
public function getPlugin() : Plugin{
return $this->owningPlugin;
}

View File

@ -27,8 +27,5 @@ use pocketmine\plugin\Plugin;
interface PluginIdentifiableCommand{
/**
* @return Plugin
*/
public function getPlugin() : Plugin;
}

View File

@ -41,6 +41,9 @@ class RemoteConsoleCommandSender extends ConsoleCommandSender{
$this->messages .= trim($message, "\r\n") . "\n";
}
/**
* @return string
*/
public function getMessage(){
return $this->messages;
}

View File

@ -72,6 +72,7 @@ use function explode;
use function implode;
use function min;
use function preg_match_all;
use function strcasecmp;
use function stripslashes;
use function strpos;
use function strtolower;
@ -79,9 +80,7 @@ use function trim;
class SimpleCommandMap implements CommandMap{
/**
* @var Command[]
*/
/** @var Command[] */
protected $knownCommands = [];
/** @var Server */
@ -92,7 +91,7 @@ class SimpleCommandMap implements CommandMap{
$this->setDefaultCommands();
}
private function setDefaultCommands(){
private function setDefaultCommands() : void{
$this->registerAll("pocketmine", [
new BanCommand("ban"),
new BanIpCommand("ban-ip"),
@ -137,20 +136,12 @@ class SimpleCommandMap implements CommandMap{
]);
}
public function registerAll(string $fallbackPrefix, array $commands){
foreach($commands as $command){
$this->register($fallbackPrefix, $command);
}
}
/**
* @param string $fallbackPrefix
* @param Command $command
* @param string|null $label
*
* @return bool
*/
public function register(string $fallbackPrefix, Command $command, string $label = null) : bool{
if($label === null){
$label = $command->getName();
@ -177,11 +168,6 @@ class SimpleCommandMap implements CommandMap{
return $registered;
}
/**
* @param Command $command
*
* @return bool
*/
public function unregister(Command $command) : bool{
foreach($this->knownCommands as $lbl => $cmd){
if($cmd === $command){
@ -194,14 +180,6 @@ class SimpleCommandMap implements CommandMap{
return true;
}
/**
* @param Command $command
* @param bool $isAlias
* @param string $fallbackPrefix
* @param string $label
*
* @return bool
*/
private function registerAlias(Command $command, bool $isAlias, string $fallbackPrefix, string $label) : bool{
$this->knownCommands[$fallbackPrefix . ":" . $label] = $command;
if(($command instanceof VanillaCommand or $isAlias) and isset($this->knownCommands[$label])){
@ -226,8 +204,8 @@ class SimpleCommandMap implements CommandMap{
* This method is intended to provide capability for handling commands with spaces in their name.
* The referenced parameters will be modified accordingly depending on the resulting matched command.
*
* @param string &$commandName
* @param string[] &$args
* @param string $commandName reference parameter
* @param string[] $args reference parameter
*
* @return Command|null
*/
@ -296,7 +274,6 @@ class SimpleCommandMap implements CommandMap{
return $this->knownCommands;
}
/**
* @return void
*/
@ -318,22 +295,21 @@ class SimpleCommandMap implements CommandMap{
$commandName = "";
$command = $this->matchCommand($commandName, $args);
if($command === null){
$bad[] = $commandString;
}elseif($commandName === $alias){
}elseif(strcasecmp($commandName, $alias) === 0){
$recursive[] = $commandString;
}else{
$targets[] = $commandString;
}
}
if(!empty($recursive)){
if(count($recursive) > 0){
$this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.command.alias.recursive", [$alias, implode(", ", $recursive)]));
continue;
}
if(!empty($bad)){
if(count($bad) > 0){
$this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.command.alias.notFound", [$alias, implode(", ", $bad)]));
continue;
}

View File

@ -75,7 +75,7 @@ class BanIpCommand extends VanillaCommand{
return true;
}
private function processIPBan(string $ip, CommandSender $sender, string $reason){
private function processIPBan(string $ip, CommandSender $sender, string $reason) : void{
$sender->getServer()->getIPBans()->addBan($ip, $reason, null, $sender->getName());
foreach($sender->getServer()->getOnlinePlayers() as $player){

View File

@ -124,7 +124,6 @@ class EffectCommand extends VanillaCommand{
self::broadcastCommandMessage($sender, new TranslationContainer("%commands.effect.success", [$effect->getName(), $instance->getAmplifier(), $player->getDisplayName(), $instance->getDuration() / 20, $effect->getId()]));
}
return true;
}
}

View File

@ -88,7 +88,6 @@ class EnchantCommand extends VanillaCommand{
$item->addEnchantment(new EnchantmentInstance($enchantment, $level));
$player->getInventory()->setItemInHand($item);
self::broadcastCommandMessage($sender, new TranslationContainer("%commands.enchant.success", [$player->getName()]));
return true;
}

View File

@ -60,7 +60,6 @@ class GamemodeCommand extends VanillaCommand{
return true;
}
$target = $sender;
if(isset($args[1])){
$target = $sender->getServer()->getPlayer($args[1]);
if($target === null){
@ -68,7 +67,9 @@ class GamemodeCommand extends VanillaCommand{
return true;
}
}elseif(!($sender instanceof Player)){
}elseif($sender instanceof Player){
$target = $sender;
}else{
throw new InvalidCommandSyntaxException();
}

View File

@ -68,7 +68,6 @@ class KickCommand extends VanillaCommand{
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.player.notFound"));
}
return true;
}
}

View File

@ -119,7 +119,6 @@ class ParticleCommand extends VanillaCommand{
return true;
}
$sender->sendMessage(new TranslationContainer("commands.particle.success", [$name, $count]));
$random = new Random((int) (microtime(true) * 1000) + mt_rand());
@ -137,13 +136,6 @@ class ParticleCommand extends VanillaCommand{
}
/**
* @param string $name
* @param Vector3 $pos
* @param float $xd
* @param float $yd
* @param float $zd
* @param int|null $data
*
* @return Particle|null
*/
private function getParticle(string $name, Vector3 $pos, float $xd, float $yd, float $zd, int $data = null){

View File

@ -85,7 +85,6 @@ class TimeCommand extends VanillaCommand{
return true;
}
if(count($args) < 2){
throw new InvalidCommandSyntaxException();
}

View File

@ -126,18 +126,25 @@ class TimingsCommand extends VanillaCommand{
/** @var string */
private $host;
/**
* @param string[] $data
* @phpstan-param array<string, string> $data
*/
public function __construct(CommandSender $sender, string $host, string $agent, array $data){
parent::__construct([
["page" => "https://$host?upload=true", "extraOpts" => [
CURLOPT_HTTPHEADER => [
"User-Agent: $agent",
"Content-Type: application/x-www-form-urlencoded"
],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_AUTOREFERER => false,
CURLOPT_FOLLOWLOCATION => false
]]
[
"page" => "https://$host?upload=true",
"extraOpts" => [
CURLOPT_HTTPHEADER => [
"User-Agent: $agent",
"Content-Type: application/x-www-form-urlencoded"
],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_AUTOREFERER => false,
CURLOPT_FOLLOWLOCATION => false
]
]
], $sender);
$this->host = $host;
}

View File

@ -21,10 +21,8 @@
declare(strict_types=1);
namespace pocketmine\command\defaults;
use pocketmine\command\CommandSender;
use pocketmine\command\utils\InvalidCommandSyntaxException;
use pocketmine\Player;

View File

@ -36,12 +36,7 @@ abstract class VanillaCommand extends Command{
public const MIN_COORD = -30000000;
/**
* @param CommandSender $sender
* @param mixed $value
* @param int $min
* @param int $max
*
* @return int
*/
protected function getInteger(CommandSender $sender, $value, int $min = self::MIN_COORD, int $max = self::MAX_COORD) : int{
$i = (int) $value;
@ -55,15 +50,6 @@ abstract class VanillaCommand extends Command{
return $i;
}
/**
* @param float $original
* @param CommandSender $sender
* @param string $input
* @param float $min
* @param float $max
*
* @return float
*/
protected function getRelativeDouble(float $original, CommandSender $sender, string $input, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
if($input[0] === "~"){
$value = $this->getDouble($sender, substr($input, 1));
@ -75,12 +61,7 @@ abstract class VanillaCommand extends Command{
}
/**
* @param CommandSender $sender
* @param mixed $value
* @param float $min
* @param float $max
*
* @return float
*/
protected function getDouble(CommandSender $sender, $value, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
$i = (double) $value;

View File

@ -84,7 +84,7 @@ class VersionCommand extends VanillaCommand{
return true;
}
private function describeToSender(Plugin $plugin, CommandSender $sender){
private function describeToSender(Plugin $plugin, CommandSender $sender) : void{
$desc = $plugin->getDescription();
$sender->sendMessage(TextFormat::DARK_GREEN . $desc->getName() . TextFormat::WHITE . " version " . TextFormat::DARK_GREEN . $desc->getVersion());

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\entity;
interface Ageable{
public function isBaby() : bool;
}

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\entity;
abstract class Animal extends Creature implements Ageable{
public function isBaby() : bool{

View File

@ -46,14 +46,22 @@ class Attribute{
public const HORSE_JUMP_STRENGTH = 14;
public const ZOMBIE_SPAWN_REINFORCEMENTS = 15;
/** @var int */
private $id;
/** @var float */
protected $minValue;
/** @var float */
protected $maxValue;
/** @var float */
protected $defaultValue;
/** @var float */
protected $currentValue;
/** @var string */
protected $name;
/** @var bool */
protected $shouldSend;
/** @var bool */
protected $desynchronized = true;
/** @var Attribute[] */
@ -79,15 +87,6 @@ class Attribute{
}
/**
* @param int $id
* @param string $name
* @param float $minValue
* @param float $maxValue
* @param float $defaultValue
* @param bool $shouldSend
*
* @return Attribute
*
* @throws \InvalidArgumentException
*/
public static function addAttribute(int $id, string $name, float $minValue, float $maxValue, float $defaultValue, bool $shouldSend = true) : Attribute{
@ -98,20 +97,10 @@ class Attribute{
return self::$attributes[$id] = new Attribute($id, $name, $minValue, $maxValue, $defaultValue, $shouldSend);
}
/**
* @param int $id
*
* @return Attribute|null
*/
public static function getAttribute(int $id) : ?Attribute{
return isset(self::$attributes[$id]) ? clone self::$attributes[$id] : null;
}
/**
* @param string $name
*
* @return Attribute|null
*/
public static function getAttributeByName(string $name) : ?Attribute{
foreach(self::$attributes as $a){
if($a->getName() === $name){
@ -137,6 +126,9 @@ class Attribute{
return $this->minValue;
}
/**
* @return $this
*/
public function setMinValue(float $minValue){
if($minValue > ($max = $this->getMaxValue())){
throw new \InvalidArgumentException("Minimum $minValue is greater than the maximum $max");
@ -153,6 +145,9 @@ class Attribute{
return $this->maxValue;
}
/**
* @return $this
*/
public function setMaxValue(float $maxValue){
if($maxValue < ($min = $this->getMinValue())){
throw new \InvalidArgumentException("Maximum $maxValue is less than the minimum $min");
@ -169,6 +164,9 @@ class Attribute{
return $this->defaultValue;
}
/**
* @return $this
*/
public function setDefaultValue(float $defaultValue){
if($defaultValue > $this->getMaxValue() or $defaultValue < $this->getMinValue()){
throw new \InvalidArgumentException("Default $defaultValue is outside the range " . $this->getMinValue() . " - " . $this->getMaxValue());
@ -190,10 +188,6 @@ class Attribute{
}
/**
* @param float $value
* @param bool $fit
* @param bool $forceSend
*
* @return $this
*/
public function setValue(float $value, bool $fit = false, bool $forceSend = false){

View File

@ -25,6 +25,9 @@ namespace pocketmine\entity;
use function array_filter;
/**
* @phpstan-implements \ArrayAccess<int, float>
*/
class AttributeMap implements \ArrayAccess{
/** @var Attribute[] */
private $attributes = [];
@ -33,11 +36,6 @@ class AttributeMap implements \ArrayAccess{
$this->attributes[$attribute->getId()] = $attribute;
}
/**
* @param int $id
*
* @return Attribute|null
*/
public function getAttribute(int $id) : ?Attribute{
return $this->attributes[$id] ?? null;
}
@ -58,14 +56,15 @@ class AttributeMap implements \ArrayAccess{
});
}
/**
* @param int $offset
*/
public function offsetExists($offset) : bool{
return isset($this->attributes[$offset]);
}
/**
* @param int $offset
*
* @return float
*/
public function offsetGet($offset) : float{
return $this->attributes[$offset]->getValue();
@ -79,6 +78,9 @@ class AttributeMap implements \ArrayAccess{
$this->attributes[$offset]->setValue($value);
}
/**
* @param int $offset
*/
public function offsetUnset($offset) : void{
throw new \RuntimeException("Could not unset an attribute from an attribute map");
}

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\entity;
abstract class Creature extends Living{
}

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\entity;
interface Damageable{
}

View File

@ -32,110 +32,68 @@ use function is_string;
class DataPropertyManager{
/**
* @var mixed[][]
* @phpstan-var array<int, array{0: int, 1: mixed}>
*/
private $properties = [];
/**
* @var mixed[][]
* @phpstan-var array<int, array{0: int, 1: mixed}>
*/
private $dirtyProperties = [];
public function __construct(){
}
/**
* @param int $key
*
* @return int|null
*/
public function getByte(int $key) : ?int{
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_BYTE);
assert(is_int($value) or $value === null);
return $value;
}
/**
* @param int $key
* @param int $value
* @param bool $force
*/
public function setByte(int $key, int $value, bool $force = false) : void{
$this->setPropertyValue($key, Entity::DATA_TYPE_BYTE, $value, $force);
}
/**
* @param int $key
*
* @return int|null
*/
public function getShort(int $key) : ?int{
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_SHORT);
assert(is_int($value) or $value === null);
return $value;
}
/**
* @param int $key
* @param int $value
* @param bool $force
*/
public function setShort(int $key, int $value, bool $force = false) : void{
$this->setPropertyValue($key, Entity::DATA_TYPE_SHORT, $value, $force);
}
/**
* @param int $key
*
* @return int|null
*/
public function getInt(int $key) : ?int{
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_INT);
assert(is_int($value) or $value === null);
return $value;
}
/**
* @param int $key
* @param int $value
* @param bool $force
*/
public function setInt(int $key, int $value, bool $force = false) : void{
$this->setPropertyValue($key, Entity::DATA_TYPE_INT, $value, $force);
}
/**
* @param int $key
*
* @return float|null
*/
public function getFloat(int $key) : ?float{
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_FLOAT);
assert(is_float($value) or $value === null);
return $value;
}
/**
* @param int $key
* @param float $value
* @param bool $force
*/
public function setFloat(int $key, float $value, bool $force = false) : void{
$this->setPropertyValue($key, Entity::DATA_TYPE_FLOAT, $value, $force);
}
/**
* @param int $key
*
* @return null|string
*/
public function getString(int $key) : ?string{
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_STRING);
assert(is_string($value) or $value === null);
return $value;
}
/**
* @param int $key
* @param string $value
* @param bool $force
*/
public function setString(int $key, string $value, bool $force = false) : void{
$this->setPropertyValue($key, Entity::DATA_TYPE_STRING, $value, $force);
}
@ -150,87 +108,44 @@ class DataPropertyManager{
$this->setPropertyValue($key, Entity::DATA_TYPE_COMPOUND_TAG, $value, $force);
}
/**
* @param int $key
*
* @return null|Vector3
*/
public function getBlockPos(int $key) : ?Vector3{
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_POS);
assert($value instanceof Vector3 or $value === null);
return $value;
}
/**
* @param int $key
* @param null|Vector3 $value
* @param bool $force
*/
public function setBlockPos(int $key, ?Vector3 $value, bool $force = false) : void{
$this->setPropertyValue($key, Entity::DATA_TYPE_POS, $value ? $value->floor() : null, $force);
}
/**
* @param int $key
*
* @return int|null
*/
public function getLong(int $key) : ?int{
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_LONG);
assert(is_int($value) or $value === null);
return $value;
}
/**
* @param int $key
* @param int $value
* @param bool $force
*/
public function setLong(int $key, int $value, bool $force = false) : void{
$this->setPropertyValue($key, Entity::DATA_TYPE_LONG, $value, $force);
}
/**
* @param int $key
*
* @return null|Vector3
*/
public function getVector3(int $key) : ?Vector3{
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_VECTOR3F);
assert($value instanceof Vector3 or $value === null);
return $value;
}
/**
* @param int $key
* @param null|Vector3 $value
* @param bool $force
*/
public function setVector3(int $key, ?Vector3 $value, bool $force = false) : void{
$this->setPropertyValue($key, Entity::DATA_TYPE_VECTOR3F, $value ? $value->asVector3() : null, $force);
}
/**
* @param int $key
*/
public function removeProperty(int $key) : void{
unset($this->properties[$key]);
}
/**
* @param int $key
*
* @return bool
*/
public function hasProperty(int $key) : bool{
return isset($this->properties[$key]);
}
/**
* @param int $key
*
* @return int
*/
public function getPropertyType(int $key) : int{
if(isset($this->properties[$key])){
return $this->properties[$key][0];
@ -246,9 +161,6 @@ class DataPropertyManager{
}
/**
* @param int $key
* @param int $type
*
* @return mixed
*/
public function getPropertyValue(int $key, int $type){
@ -259,10 +171,7 @@ class DataPropertyManager{
}
/**
* @param int $key
* @param int $type
* @param mixed $value
* @param bool $force
*/
public function setPropertyValue(int $key, int $type, $value, bool $force = false) : void{
if(!$force){
@ -274,7 +183,8 @@ class DataPropertyManager{
/**
* Returns all properties.
*
* @return array
* @return mixed[][]
* @phpstan-return array<int, array{0: int, 1: mixed}>
*/
public function getAll() : array{
return $this->properties;
@ -283,7 +193,8 @@ class DataPropertyManager{
/**
* Returns properties that have changed and need to be broadcasted.
*
* @return array
* @return mixed[][]
* @phpstan-return array<int, array{0: int, 1: mixed}>
*/
public function getDirty() : array{
return $this->dirtyProperties;

View File

@ -93,27 +93,14 @@ class Effect{
self::registerEffect(new Effect(Effect::CONDUIT_POWER, "%potion.conduitPower", new Color(0x1d, 0xc2, 0xd1)));
}
/**
* @param Effect $effect
*/
public static function registerEffect(Effect $effect) : void{
self::$effects[$effect->getId()] = $effect;
}
/**
* @param int $id
*
* @return Effect|null
*/
public static function getEffect(int $id) : ?Effect{
return self::$effects[$id] ?? null;
}
/**
* @param string $name
*
* @return Effect|null
*/
public static function getEffectByName(string $name) : ?Effect{
$const = self::class . "::" . strtoupper($name);
if(defined($const)){
@ -154,7 +141,6 @@ class Effect{
/**
* Returns the effect ID as per Minecraft PE
* @return int
*/
public function getId() : int{
return $this->id;
@ -162,7 +148,6 @@ class Effect{
/**
* Returns the translation key used to translate this effect's name.
* @return string
*/
public function getName() : string{
return $this->name;
@ -170,7 +155,6 @@ class Effect{
/**
* Returns a Color object representing this effect's particle colour.
* @return Color
*/
public function getColor() : Color{
return clone $this->color;
@ -179,8 +163,6 @@ class Effect{
/**
* Returns whether this effect is harmful.
* TODO: implement inverse effect results for undead mobs
*
* @return bool
*/
public function isBad() : bool{
return $this->bad;
@ -188,15 +170,13 @@ class Effect{
/**
* Returns whether the effect is by default an instant effect.
* @return bool
*/
public function isInstantEffect() : bool{
return $this->defaultDuration <= 1;
}
/**
* Returns the default duration this effect will apply for if a duration is not specified.
* @return int
* Returns the default duration (in ticks) this effect will apply for if a duration is not specified.
*/
public function getDefaultDuration() : int{
return $this->defaultDuration;
@ -204,7 +184,6 @@ class Effect{
/**
* Returns whether this effect will give the subject potion bubbles.
* @return bool
*/
public function hasBubbles() : bool{
return $this->hasBubbles;
@ -212,10 +191,6 @@ class Effect{
/**
* Returns whether the effect will do something on the current tick.
*
* @param EffectInstance $instance
*
* @return bool
*/
public function canTick(EffectInstance $instance) : bool{
switch($this->id){
@ -248,12 +223,6 @@ class Effect{
/**
* Applies effect results to an entity. This will not be called unless canTick() returns true.
*
* @param Living $entity
* @param EffectInstance $instance
* @param float $potency
* @param null|Entity $source
* @param null|Entity $sourceOwner
*/
public function applyEffect(Living $entity, EffectInstance $instance, float $potency = 1.0, ?Entity $source = null, ?Entity $sourceOwner = null) : void{
switch($this->id){
@ -314,9 +283,6 @@ class Effect{
/**
* Applies effects to the entity when the effect is first added.
*
* @param Living $entity
* @param EffectInstance $instance
*/
public function add(Living $entity, EffectInstance $instance) : void{
switch($this->id){
@ -347,9 +313,6 @@ class Effect{
/**
* Removes the effect from the entity, resetting any changed values back to their original defaults.
*
* @param Living $entity
* @param EffectInstance $instance
*/
public function remove(Living $entity, EffectInstance $instance) : void{
switch($this->id){

View File

@ -47,12 +47,7 @@ class EffectInstance{
private $color;
/**
* @param Effect $effectType
* @param int|null $duration Passing null will use the effect type's default duration
* @param int $amplifier
* @param bool $visible
* @param bool $ambient
* @param null|Color $overrideColor
*/
public function __construct(Effect $effectType, ?int $duration = null, int $amplifier = 0, bool $visible = true, bool $ambient = false, ?Color $overrideColor = null){
$this->effectType = $effectType;
@ -67,22 +62,19 @@ class EffectInstance{
return $this->effectType->getId();
}
/**
* @return Effect
*/
public function getType() : Effect{
return $this->effectType;
}
/**
* @return int
* Returns the number of ticks remaining until the effect expires.
*/
public function getDuration() : int{
return $this->duration;
}
/**
* @param int $duration
* Sets the number of ticks remaining until the effect expires.
*
* @throws \InvalidArgumentException
*
@ -100,8 +92,6 @@ class EffectInstance{
/**
* Decreases the duration by the given number of ticks, without dropping below zero.
*
* @param int $ticks
*
* @return $this
*/
public function decreaseDuration(int $ticks) : EffectInstance{
@ -112,32 +102,23 @@ class EffectInstance{
/**
* Returns whether the duration has run out.
*
* @return bool
*/
public function hasExpired() : bool{
return $this->duration <= 0;
}
/**
* @return int
*/
public function getAmplifier() : int{
return $this->amplifier;
}
/**
* Returns the level of this effect, which is always one higher than the amplifier.
*
* @return int
*/
public function getEffectLevel() : int{
return $this->amplifier + 1;
}
/**
* @param int $amplifier
*
* @return $this
*/
public function setAmplifier(int $amplifier) : EffectInstance{
@ -148,16 +129,12 @@ class EffectInstance{
/**
* Returns whether this effect will produce some visible effect, such as bubbles or particles.
*
* @return bool
*/
public function isVisible() : bool{
return $this->visible;
}
/**
* @param bool $visible
*
* @return $this
*/
public function setVisible(bool $visible = true) : EffectInstance{
@ -170,16 +147,12 @@ class EffectInstance{
* Returns whether the effect originated from the ambient environment.
* Ambient effects can originate from things such as a Beacon's area of effect radius.
* If this flag is set, the amount of visible particles will be reduced by a factor of 5.
*
* @return bool
*/
public function isAmbient() : bool{
return $this->ambient;
}
/**
* @param bool $ambient
*
* @return $this
*/
public function setAmbient(bool $ambient = true) : EffectInstance{
@ -191,8 +164,6 @@ class EffectInstance{
/**
* Returns the particle colour of this effect instance. This can be overridden on a per-EffectInstance basis, so it
* is not reflective of the default colour of the effect.
*
* @return Color
*/
public function getColor() : Color{
return clone $this->color;
@ -200,10 +171,6 @@ class EffectInstance{
/**
* Sets the colour of this EffectInstance.
*
* @param Color $color
*
* @return EffectInstance
*/
public function setColor(Color $color) : EffectInstance{
$this->color = clone $color;
@ -213,8 +180,6 @@ class EffectInstance{
/**
* Resets the colour of this EffectInstance to the default specified by its type.
*
* @return EffectInstance
*/
public function resetColor() : EffectInstance{
$this->color = $this->effectType->getColor();

View File

@ -317,10 +317,17 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
public const DATA_PLAYER_FLAG_SLEEP = 1;
public const DATA_PLAYER_FLAG_DEAD = 2; //TODO: CHECK
/** @var int */
public static $entityCount = 1;
/** @var Entity[] */
/**
* @var string[]
* @phpstan-var array<int|string, class-string<Entity>>
*/
private static $knownEntities = [];
/** @var string[][] */
/**
* @var string[][]
* @phpstan-var array<class-string<Entity>, list<string>>
*/
private static $saveNames = [];
/**
@ -352,17 +359,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
PaintingMotive::init();
}
/**
* Creates an entity with the specified type, level and NBT, with optional additional arguments to pass to the
* entity's constructor
*
* @param int|string $type
* @param Level $level
* @param CompoundTag $nbt
* @param mixed ...$args
*
* @return Entity|null
*/
public static function createEntity($type, Level $level, CompoundTag $nbt, ...$args) : ?Entity{
if(isset(self::$knownEntities[$type])){
@ -380,15 +382,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
* @param string $className Class that extends Entity
* @param bool $force Force registration even if the entity does not have a valid network ID
* @param string[] $saveNames An array of save names which this entity might be saved under. Defaults to the short name of the class itself if empty.
* @phpstan-param class-string<Entity> $className
*
* NOTE: The first save name in the $saveNames array will be used when saving the entity to disk. The reflection
* name of the class will be appended to the end and only used if no other save names are specified.
*
* @return bool
*/
public static function registerEntity(string $className, bool $force = false, array $saveNames = []) : bool{
/** @var Entity $className */
$class = new \ReflectionClass($className);
if(is_a($className, Entity::class, true) and !$class->isAbstract()){
if($className::NETWORK_ID !== -1){
@ -416,13 +415,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Helper function which creates minimal NBT needed to spawn an entity.
*
* @param Vector3 $pos
* @param Vector3|null $motion
* @param float $yaw
* @param float $pitch
*
* @return CompoundTag
*/
public static function createBaseNBT(Vector3 $pos, ?Vector3 $motion = null, float $yaw = 0.0, float $pitch = 0.0) : CompoundTag{
return new CompoundTag("", [
@ -443,9 +435,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
]);
}
/**
* @var Player[]
*/
/** @var Player[] */
protected $hasSpawned = [];
/** @var int */
@ -460,15 +450,15 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/** @var EntityDamageEvent|null */
protected $lastDamageCause = null;
/** @var Block[] */
protected $blocksAround = [];
/** @var Block[]|null */
protected $blocksAround = null;
/** @var float|null */
public $lastX = null;
/** @var float|null */
public $lastY = null;
/** @var float|null */
public $lastZ = null;
/** @var float */
public $lastX;
/** @var float */
public $lastY;
/** @var float */
public $lastZ;
/** @var Vector3 */
protected $motion;
@ -480,7 +470,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/** @var Vector3 */
public $temporalVector;
/** @var float */
public $lastYaw;
/** @var float */
@ -504,6 +493,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/** @var float */
private $health = 20.0;
/** @var int */
private $maxHealth = 20;
/** @var float */
@ -650,73 +640,42 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
/**
* @return string
*/
public function getNameTag() : string{
return $this->propertyManager->getString(self::DATA_NAMETAG);
}
/**
* @return bool
*/
public function isNameTagVisible() : bool{
return $this->getGenericFlag(self::DATA_FLAG_CAN_SHOW_NAMETAG);
}
/**
* @return bool
*/
public function isNameTagAlwaysVisible() : bool{
return $this->propertyManager->getByte(self::DATA_ALWAYS_SHOW_NAMETAG) === 1;
}
/**
* @param string $name
*/
public function setNameTag(string $name) : void{
$this->propertyManager->setString(self::DATA_NAMETAG, $name);
}
/**
* @param bool $value
*/
public function setNameTagVisible(bool $value = true) : void{
$this->setGenericFlag(self::DATA_FLAG_CAN_SHOW_NAMETAG, $value);
}
/**
* @param bool $value
*/
public function setNameTagAlwaysVisible(bool $value = true) : void{
$this->propertyManager->setByte(self::DATA_ALWAYS_SHOW_NAMETAG, $value ? 1 : 0);
}
/**
* @return string|null
*/
public function getScoreTag() : ?string{
return $this->propertyManager->getString(self::DATA_SCORE_TAG);
}
/**
* @param string $score
*/
public function setScoreTag(string $score) : void{
$this->propertyManager->setString(self::DATA_SCORE_TAG, $score);
}
/**
* @return float
*/
public function getScale() : float{
return $this->propertyManager->getFloat(self::DATA_SCALE);
}
/**
* @param float $value
*/
public function setScale(float $value) : void{
if($value <= 0){
throw new \InvalidArgumentException("Scale must be greater than 0");
@ -787,7 +746,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns whether the entity is able to climb blocks such as ladders or vines.
* @return bool
*/
public function canClimb() : bool{
return $this->getGenericFlag(self::DATA_FLAG_CAN_CLIMB);
@ -795,8 +753,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Sets whether the entity is able to climb climbable blocks.
*
* @param bool $value
*/
public function setCanClimb(bool $value = true) : void{
$this->setGenericFlag(self::DATA_FLAG_CAN_CLIMB, $value);
@ -804,8 +760,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns whether this entity is climbing a block. By default this is only true if the entity is climbing a ladder or vine or similar block.
*
* @return bool
*/
public function canClimbWalls() : bool{
return $this->getGenericFlag(self::DATA_FLAG_WALLCLIMBING);
@ -813,8 +767,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Sets whether the entity is climbing a block. If true, the entity can climb anything.
*
* @param bool $value
*/
public function setCanClimbWalls(bool $value = true) : void{
$this->setGenericFlag(self::DATA_FLAG_WALLCLIMBING, $value);
@ -822,7 +774,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns the entity ID of the owning entity, or null if the entity doesn't have an owner.
* @return int|null
*/
public function getOwningEntityId() : ?int{
return $this->propertyManager->getLong(self::DATA_OWNER_EID);
@ -830,7 +781,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns the owning entity, or null if the entity was not found.
* @return Entity|null
*/
public function getOwningEntity() : ?Entity{
$eid = $this->getOwningEntityId();
@ -844,8 +794,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Sets the owner of the entity. Passing null will remove the current owner.
*
* @param Entity|null $owner
*
* @throws \InvalidArgumentException if the supplied entity is not valid
*/
public function setOwningEntity(?Entity $owner) : void{
@ -860,7 +808,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns the entity ID of the entity's target, or null if it doesn't have a target.
* @return int|null
*/
public function getTargetEntityId() : ?int{
return $this->propertyManager->getLong(self::DATA_TARGET_EID);
@ -869,8 +816,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns the entity's target entity, or null if not found.
* This is used for things like hostile mobs attacking entities, and for fishing rods reeling hit entities in.
*
* @return Entity|null
*/
public function getTargetEntity() : ?Entity{
$eid = $this->getTargetEntityId();
@ -884,8 +829,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Sets the entity's target entity. Passing null will remove the current target.
*
* @param Entity|null $target
*
* @throws \InvalidArgumentException if the target entity is not valid
*/
public function setTargetEntity(?Entity $target) : void{
@ -900,7 +843,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns whether this entity will be saved when its chunk is unloaded.
* @return bool
*/
public function canSaveWithChunk() : bool{
return $this->savedWithChunk;
@ -909,8 +851,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Sets whether this entity will be saved when its chunk is unloaded. This can be used to prevent the entity being
* saved to disk.
*
* @param bool $value
*/
public function setCanSaveWithChunk(bool $value) : void{
$this->savedWithChunk = $value;
@ -918,8 +858,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns the short save name
*
* @return string
*/
public function getSaveId() : string{
if(!isset(self::$saveNames[static::class])){
@ -985,9 +923,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
/**
* @param EntityDamageEvent $source
*/
public function attack(EntityDamageEvent $source) : void{
$source->call();
if($source->isCancelled()){
@ -999,9 +934,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->setHealth($this->getHealth() - $source->getFinalDamage());
}
/**
* @param EntityRegainHealthEvent $source
*/
public function heal(EntityRegainHealthEvent $source) : void{
$source->call();
if($source->isCancelled()){
@ -1018,10 +950,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Called to tick entities while dead. Returns whether the entity should be flagged for despawn yet.
*
* @param int $tickDiff
*
* @return bool
*/
protected function onDeathUpdate(int $tickDiff) : bool{
return true;
@ -1031,17 +959,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
return $this->health > 0;
}
/**
* @return float
*/
public function getHealth() : float{
return $this->health;
}
/**
* Sets the health of the Entity. This won't send any update to the players
*
* @param float $amount
*/
public function setHealth(float $amount) : void{
if($amount == $this->health){
@ -1060,30 +983,18 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
}
/**
* @return int
*/
public function getMaxHealth() : int{
return $this->maxHealth;
}
/**
* @param int $amount
*/
public function setMaxHealth(int $amount) : void{
$this->maxHealth = $amount;
}
/**
* @param EntityDamageEvent $type
*/
public function setLastDamageCause(EntityDamageEvent $type) : void{
$this->lastDamageCause = $type;
}
/**
* @return EntityDamageEvent|null
*/
public function getLastDamageCause() : ?EntityDamageEvent{
return $this->lastDamageCause;
}
@ -1102,7 +1013,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->justCreated = false;
$changedProperties = $this->propertyManager->getDirty();
if(!empty($changedProperties)){
if(count($changedProperties) > 0){
$this->sendData($this->hasSpawned, $changedProperties);
$this->propertyManager->clearDirtyProperties();
}
@ -1146,15 +1057,11 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->setGenericFlag(self::DATA_FLAG_ONFIRE, $this->isOnFire());
}
/**
* @return int
*/
public function getFireTicks() : int{
return $this->fireTicks;
}
/**
* @param int $fireTicks
* @throws \InvalidArgumentException
*/
public function setFireTicks(int $fireTicks) : void{
@ -1210,15 +1117,19 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
protected function updateMovement(bool $teleport = false) : void{
//TODO: hack for client-side AI interference: prevent client sided movement when motion is 0
$this->setImmobile($this->motion->x == 0 and $this->motion->y == 0 and $this->motion->z == 0);
$diffPosition = ($this->x - $this->lastX) ** 2 + ($this->y - $this->lastY) ** 2 + ($this->z - $this->lastZ) ** 2;
$diffRotation = ($this->yaw - $this->lastYaw) ** 2 + ($this->pitch - $this->lastPitch) ** 2;
$diffMotion = $this->motion->subtract($this->lastMotion)->lengthSquared();
if($teleport or $diffPosition > 0.0001 or $diffRotation > 1.0){
$still = $this->motion->lengthSquared() == 0.0;
$wasStill = $this->lastMotion->lengthSquared() == 0.0;
if($wasStill !== $still){
//TODO: hack for client-side AI interference: prevent client sided movement when motion is 0
$this->setImmobile($still);
}
if($teleport or $diffPosition > 0.0001 or $diffRotation > 1.0 or (!$wasStill and $still)){
$this->lastX = $this->x;
$this->lastY = $this->y;
$this->lastZ = $this->z;
@ -1229,7 +1140,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->broadcastMovement($teleport);
}
if($diffMotion > 0.0025 or ($diffMotion > 0.0001 and $this->motion->lengthSquared() <= 0.0001)){ //0.05 ** 2
if($diffMotion > 0.0025 or $wasStill !== $still){ //0.05 ** 2
$this->lastMotion = clone $this->motion;
$this->broadcastMotion();
@ -1391,9 +1302,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
return false;
}
/**
* @return int|null
*/
public function getDirection() : ?int{
$rotation = ($this->yaw - 90) % 360;
if($rotation < 0){
@ -1412,9 +1320,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
}
/**
* @return Vector3
*/
public function getDirectionVector() : Vector3{
$y = -sin(deg2rad($this->pitch));
$xz = cos(deg2rad($this->pitch));
@ -1452,7 +1357,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
return true;
}
$this->timings->startTiming();
if($this->hasMovementUpdate()){
@ -1481,7 +1385,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$hasUpdate = $this->entityBaseTick($tickDiff);
Timings::$timerEntityBaseTick->stopTiming();
$this->timings->stopTiming();
//if($this->isStatic())
@ -1504,8 +1407,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Flags the entity as needing a movement update on the next tick. Setting this forces a movement update even if the
* entity's motion is zero. Used to trigger movement updates when blocks change near entities.
*
* @param bool $value
*/
final public function setForceMovementUpdate(bool $value = true) : void{
$this->forceMovementUpdate = $value;
@ -1515,7 +1416,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns whether the entity needs a movement update on the next tick.
* @return bool
*/
public function hasMovementUpdate() : bool{
return (
@ -1535,10 +1435,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->fallDistance = 0.0;
}
/**
* @param float $distanceThisTick
* @param bool $onGround
*/
protected function updateFallState(float $distanceThisTick, bool $onGround) : void{
if($onGround){
if($this->fallDistance > 0){
@ -1552,8 +1448,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Called when a falling entity hits the ground.
*
* @param float $fallDistance
*/
public function fall(float $fallDistance) : void{
@ -1619,7 +1513,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->isCollided = $this->onGround;
$this->updateFallState($dy, $this->onGround);
Timings::$entityMoveTimer->stopTiming();
return true;
@ -1704,7 +1597,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->boundingBox->offset(0, 0, $dz);
if($this->stepHeight > 0 and $fallingFlag and $this->ySize < 0.05 and ($movX != $dx or $movZ != $dz)){
$cx = $dx;
$cy = $dy;
@ -1817,8 +1709,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns whether this entity can be moved by currents in liquids.
*
* @return bool
*/
public function canBeMovedByCurrents() : bool{
return true;
@ -1954,10 +1844,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* @param Vector3|Position|Location $pos
* @param float|null $yaw
* @param float|null $pitch
*
* @return bool
*/
public function teleport(Vector3 $pos, ?float $yaw = null, ?float $pitch = null) : bool{
if($pos instanceof Location){
@ -2026,8 +1912,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Called by spawnTo() to send whatever packets needed to spawn the entity to the client.
*
* @param Player $player
*/
protected function sendSpawnPacket(Player $player) : void{
$pk = new AddActorPacket();
@ -2044,11 +1928,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$player->dataPacket($pk);
}
/**
* @param Player $player
*/
public function spawnTo(Player $player) : void{
if(!isset($this->hasSpawned[$player->getLoaderId()])){
if(!isset($this->hasSpawned[$player->getLoaderId()]) and $this->chunk !== null and isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])){
$this->hasSpawned[$player->getLoaderId()] = $player;
$this->sendSpawnPacket($player);
@ -2076,9 +1957,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* @deprecated WARNING: This function DOES NOT permanently hide the entity from the player. As soon as the entity or
* player moves, the player will once again be able to see the entity.
*
* @param Player $player
* @param bool $send
*/
public function despawnFrom(Player $player, bool $send = true) : void{
if(isset($this->hasSpawned[$player->getLoaderId()])){
@ -2115,7 +1993,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Returns whether the entity has been "closed".
* @return bool
*/
public function isClosed() : bool{
return $this->closed;
@ -2155,12 +2032,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
}
/**
* @param int $propertyId
* @param int $flagId
* @param bool $value
* @param int $propertyType
*/
public function setDataFlag(int $propertyId, int $flagId, bool $value = true, int $propertyType = self::DATA_TYPE_LONG) : void{
if($this->getDataFlag($propertyId, $flagId) !== $value){
$flags = (int) $this->propertyManager->getPropertyValue($propertyId, $propertyType);
@ -2169,22 +2040,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
}
/**
* @param int $propertyId
* @param int $flagId
*
* @return bool
*/
public function getDataFlag(int $propertyId, int $flagId) : bool{
return (((int) $this->propertyManager->getPropertyValue($propertyId, -1)) & (1 << $flagId)) > 0;
}
/**
* Wrapper around {@link Entity#getDataFlag} for generic data flag reading.
*
* @param int $flagId
*
* @return bool
*/
public function getGenericFlag(int $flagId) : bool{
return $this->getDataFlag($flagId >= 64 ? self::DATA_FLAGS2 : self::DATA_FLAGS, $flagId % 64);
@ -2192,9 +2053,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* Wrapper around {@link Entity#setDataFlag} for generic data flag setting.
*
* @param int $flagId
* @param bool $value
*/
public function setGenericFlag(int $flagId, bool $value = true) : void{
$this->setDataFlag($flagId >= 64 ? self::DATA_FLAGS2 : self::DATA_FLAGS, $flagId % 64, $value, self::DATA_TYPE_LONG);
@ -2202,7 +2060,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
/**
* @param Player[]|Player $player
* @param array $data Properly formatted entity data, defaults to everything
* @param mixed[][] $data Properly formatted entity data, defaults to everything
* @phpstan-param array<int, array{0: int, 1: mixed}> $data
*/
public function sendData($player, ?array $data = null) : void{
if(!is_array($player)){
@ -2225,6 +2084,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
}
/**
* @param Player[]|null $players
*/
public function broadcastEntityEvent(int $eventId, ?int $eventData = null, ?array $players = null) : void{
$pk = new ActorEventPacket();
$pk->entityRuntimeId = $this->id;
@ -2279,6 +2141,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
* @param string $name
* @param mixed $value
*
* @return void
* @throws \ErrorException
* @throws \InvalidArgumentException
*/

View File

@ -23,8 +23,10 @@ declare(strict_types=1);
namespace pocketmine\entity;
interface Explosive{
/**
* @return void
*/
public function explode();
}

View File

@ -53,6 +53,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\PlayerListPacket;
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
use pocketmine\network\mcpe\protocol\types\SkinAdapterSingleton;
use pocketmine\Player;
use pocketmine\utils\UUID;
use function array_filter;
@ -60,6 +61,7 @@ use function array_merge;
use function array_rand;
use function array_values;
use function ceil;
use function count;
use function in_array;
use function max;
use function min;
@ -79,6 +81,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/** @var UUID */
protected $uuid;
/** @var string */
protected $rawUUID;
public $width = 0.6;
@ -88,10 +91,14 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/** @var Skin */
protected $skin;
/** @var int */
protected $foodTickTimer = 0;
/** @var int */
protected $totalXp = 0;
/** @var int */
protected $xpSeed;
/** @var int */
protected $xpCooldown = 0;
protected $baseOffset = 1.62;
@ -109,9 +116,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
}
/**
* @param CompoundTag $skinTag
*
* @return Skin
* @throws \InvalidArgumentException
*/
protected static function deserializeSkinNBT(CompoundTag $skinTag) : Skin{
@ -130,32 +134,21 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
* @deprecated
*
* Checks the length of a supplied skin bitmap and returns whether the length is valid.
*
* @param string $skin
*
* @return bool
*/
public static function isValidSkin(string $skin) : bool{
return in_array(strlen($skin), Skin::ACCEPTED_SKIN_SIZES, true);
}
/**
* @return UUID|null
*/
public function getUniqueId() : ?UUID{
return $this->uuid;
}
/**
* @return string
*/
public function getRawUniqueId() : string{
return $this->rawUUID;
}
/**
* Returns a Skin object containing information about this human's skin.
* @return Skin
*/
public function getSkin() : Skin{
return $this->skin;
@ -164,8 +157,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Sets the human's skin. This will not send any update to viewers, you need to do that manually using
* {@link sendSkin}.
*
* @param Skin $skin
*/
public function setSkin(Skin $skin) : void{
$skin->validate();
@ -182,7 +173,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
public function sendSkin(?array $targets = null) : void{
$pk = new PlayerSkinPacket();
$pk->uuid = $this->getUniqueId();
$pk->skin = $this->skin;
$pk->skin = SkinAdapterSingleton::get()->toSkinData($this->skin);
$this->server->broadcastPacket($targets ?? $this->hasSpawned, $pk);
}
@ -203,8 +194,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
* WARNING: This method does not check if full and may throw an exception if out of bounds.
* Use {@link Human::addFood()} for this purpose
*
* @param float $new
*
* @throws \InvalidArgumentException
*/
public function setFood(float $new) : void{
@ -234,8 +223,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Returns whether this Human may consume objects requiring hunger.
*
* @return bool
*/
public function isHungry() : bool{
return $this->getFood() < $this->getMaxFood();
@ -249,8 +236,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
* WARNING: This method does not check if saturated and may throw an exception if out of bounds.
* Use {@link Human::addSaturation()} for this purpose
*
* @param float $saturation
*
* @throws \InvalidArgumentException
*/
public function setSaturation(float $saturation) : void{
@ -269,8 +254,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* WARNING: This method does not check if exhausted and does not consume saturation/food.
* Use {@link Human::exhaust()} for this purpose.
*
* @param float $exhaustion
*/
public function setExhaustion(float $exhaustion) : void{
$this->attributeMap->getAttribute(Attribute::EXHAUSTION)->setValue($exhaustion);
@ -279,9 +262,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Increases a human's exhaustion level.
*
* @param float $amount
* @param int $cause
*
* @return float the amount of exhaustion level increased
*/
public function exhaust(float $amount, int $cause = PlayerExhaustEvent::CAUSE_CUSTOM) : float{
@ -329,7 +309,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Returns the player's experience level.
* @return int
*/
public function getXpLevel() : int{
return (int) $this->attributeMap->getAttribute(Attribute::EXPERIENCE_LEVEL)->getValue();
@ -337,10 +316,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Sets the player's experience level. This does not affect their total XP or their XP progress.
*
* @param int $level
*
* @return bool
*/
public function setXpLevel(int $level) : bool{
return $this->setXpAndProgress($level, null);
@ -348,11 +323,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Adds a number of XP levels to the player.
*
* @param int $amount
* @param bool $playSound
*
* @return bool
*/
public function addXpLevels(int $amount, bool $playSound = true) : bool{
$oldLevel = $this->getXpLevel();
@ -372,10 +342,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Subtracts a number of XP levels from the player.
*
* @param int $amount
*
* @return bool
*/
public function subtractXpLevels(int $amount) : bool{
return $this->addXpLevels(-$amount);
@ -383,7 +349,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Returns a value between 0.0 and 1.0 to indicate how far through the current level the player is.
* @return float
*/
public function getXpProgress() : float{
return $this->attributeMap->getAttribute(Attribute::EXPERIENCE)->getValue();
@ -391,10 +356,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Sets the player's progress through the current level to a value between 0.0 and 1.0.
*
* @param float $progress
*
* @return bool
*/
public function setXpProgress(float $progress) : bool{
return $this->setXpAndProgress(null, $progress);
@ -402,7 +363,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Returns the number of XP points the player has progressed into their current level.
* @return int
*/
public function getRemainderXp() : int{
return (int) (ExperienceUtils::getXpToCompleteLevel($this->getXpLevel()) * $this->getXpProgress());
@ -412,8 +372,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
* Returns the amount of XP points the player currently has, calculated from their current level and progress
* through their current level. This will be reduced by enchanting deducting levels and is used to calculate the
* amount of XP the player drops on death.
*
* @return int
*/
public function getCurrentTotalXp() : int{
return ExperienceUtils::getXpToReachLevel($this->getXpLevel()) + $this->getRemainderXp();
@ -422,10 +380,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Sets the current total of XP the player has, recalculating their XP level and progress.
* Note that this DOES NOT update the player's lifetime total XP.
*
* @param int $amount
*
* @return bool
*/
public function setCurrentTotalXp(int $amount) : bool{
$newLevel = ExperienceUtils::getLevelFromXp($amount);
@ -437,10 +391,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
* Adds an amount of XP to the player, recalculating their XP level and progress. XP amount will be added to the
* player's lifetime XP.
*
* @param int $amount
* @param bool $playSound Whether to play level-up and XP gained sounds.
*
* @return bool
*/
public function addXp(int $amount, bool $playSound = true) : bool{
$this->totalXp += $amount;
@ -471,10 +422,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Takes an amount of XP from the player, recalculating their XP level and progress.
*
* @param int $amount
*
* @return bool
*/
public function subtractXp(int $amount) : bool{
return $this->addXp(-$amount);
@ -507,8 +454,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Returns the total XP the player has collected in their lifetime. Resets when the player dies.
* XP levels being removed in enchanting do not reduce this number.
*
* @return int
*/
public function getLifetimeTotalXp() : int{
return $this->totalXp;
@ -517,8 +462,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Sets the lifetime total XP of the player. This does not recalculate their level or progress. Used for player
* score when they die. (TODO: add this when MCPE supports it)
*
* @param int $amount
*/
public function setLifetimeTotalXp(int $amount) : void{
if($amount < 0){
@ -530,7 +473,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Returns whether the human can pickup XP orbs (checks cooldown time)
* @return bool
*/
public function canPickupXp() : bool{
return $this->xpCooldown === 0;
@ -553,7 +495,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
}
}
if(!empty($equipment)){
if(count($equipment) > 0){
$repairItem = $equipment[$k = array_rand($equipment)];
if($repairItem->getDamage() > 0){
$repairAmount = min($repairItem->getDamage(), $xpValue * 2);
@ -574,8 +516,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Sets the duration in ticks until the human can pick up another XP orb.
*
* @param int $value
*/
public function resetXpCooldown(int $value = 2) : void{
$this->xpCooldown = $value;
@ -850,7 +790,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/* we don't use Server->updatePlayerListData() because that uses batches, which could cause race conditions in async compression mode */
$pk = new PlayerListPacket();
$pk->type = PlayerListPacket::TYPE_ADD;
$pk->entries = [PlayerListEntry::createAdditionEntry($this->uuid, $this->id, $this->getName(), $this->skin)];
$pk->entries = [PlayerListEntry::createAdditionEntry($this->uuid, $this->id, $this->getName(), SkinAdapterSingleton::get()->toSkinData($this->skin))];
$player->dataPacket($pk);
}
@ -895,10 +835,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Wrapper around {@link Entity#getDataFlag} for player-specific data flag reading.
*
* @param int $flagId
*
* @return bool
*/
public function getPlayerFlag(int $flagId) : bool{
return $this->getDataFlag(self::DATA_PLAYER_FLAGS, $flagId);
@ -906,9 +842,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/**
* Wrapper around {@link Entity#setDataFlag} for player-specific data flag setting.
*
* @param int $flagId
* @param bool $value
*/
public function setPlayerFlag(int $flagId, bool $value = true) : void{
$this->setDataFlag(self::DATA_PLAYER_FLAGS, $flagId, $value, self::DATA_TYPE_BYTE);

View File

@ -70,6 +70,7 @@ abstract class Living extends Entity implements Damageable{
protected $gravity = 0.08;
protected $drag = 0.02;
/** @var int */
protected $attackTime = 0;
/** @var int */
@ -77,6 +78,7 @@ abstract class Living extends Entity implements Damageable{
/** @var int */
protected $maxDeadTicks = 25;
/** @var float */
protected $jumpVelocity = 0.42;
/** @var EffectInstance[] */
@ -185,7 +187,6 @@ abstract class Living extends Entity implements Damageable{
}
}
public function hasLineOfSight(Entity $entity) : bool{
//TODO: head height
return true;
@ -211,8 +212,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Removes the effect with the specified ID from the mob.
*
* @param int $effectId
*/
public function removeEffect(int $effectId) : void{
if(isset($this->effects[$effectId])){
@ -238,10 +237,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Returns the effect instance active on this entity with the specified ID, or null if the mob does not have the
* effect.
*
* @param int $effectId
*
* @return EffectInstance|null
*/
public function getEffect(int $effectId) : ?EffectInstance{
return $this->effects[$effectId] ?? null;
@ -249,10 +244,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Returns whether the specified effect is active on the mob.
*
* @param int $effectId
*
* @return bool
*/
public function hasEffect(int $effectId) : bool{
return isset($this->effects[$effectId]);
@ -260,10 +251,9 @@ abstract class Living extends Entity implements Damageable{
/**
* Returns whether the mob has any active effects.
* @return bool
*/
public function hasEffects() : bool{
return !empty($this->effects);
return count($this->effects) > 0;
}
/**
@ -271,8 +261,6 @@ abstract class Living extends Entity implements Damageable{
* If a weaker effect of the same type is already applied, it will be replaced.
* If a weaker or equal-strength effect is already applied but has a shorter duration, it will be replaced.
*
* @param EffectInstance $effect
*
* @return bool whether the effect has been successfully applied.
*/
public function addEffect(EffectInstance $effect) : bool{
@ -332,7 +320,7 @@ abstract class Living extends Entity implements Damageable{
}
}
if(!empty($colors)){
if(count($colors) > 0){
$this->propertyManager->setInt(Entity::DATA_POTION_COLOR, Color::mix(...$colors)->toARGB());
$this->propertyManager->setByte(Entity::DATA_POTION_AMBIENT, $ambient ? 1 : 0);
}else{
@ -343,8 +331,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Sends the mob's potion effects to the specified player.
*
* @param Player $player
*/
public function sendPotionEffects(Player $player) : void{
foreach($this->effects as $effect){
@ -371,10 +357,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Causes the mob to consume the given Consumable object, applying applicable effects, health bonuses, food bonuses,
* etc.
*
* @param Consumable $consumable
*
* @return bool
*/
public function consumeObject(Consumable $consumable) : bool{
foreach($consumable->getAdditionalEffects() as $effect){
@ -388,7 +370,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Returns the initial upwards velocity of a jumping entity in blocks/tick, including additional velocity due to effects.
* @return float
*/
public function getJumpVelocity() : float{
return $this->jumpVelocity + ($this->hasEffect(Effect::JUMP) ? ($this->getEffect(Effect::JUMP)->getEffectLevel() / 10) : 0);
@ -415,8 +396,6 @@ abstract class Living extends Entity implements Damageable{
* Returns how many armour points this mob has. Armour points provide a percentage reduction to damage.
* For mobs which can wear armour, this should return the sum total of the armour points provided by their
* equipment.
*
* @return int
*/
public function getArmorPoints() : int{
$total = 0;
@ -429,10 +408,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Returns the highest level of the specified enchantment on any armour piece that the entity is currently wearing.
*
* @param int $enchantmentId
*
* @return int
*/
public function getHighestArmorEnchantmentLevel(int $enchantmentId) : int{
$result = 0;
@ -443,9 +418,6 @@ abstract class Living extends Entity implements Damageable{
return $result;
}
/**
* @return ArmorInventory
*/
public function getArmorInventory() : ArmorInventory{
return $this->armorInventory;
}
@ -457,8 +429,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Called prior to EntityDamageEvent execution to apply modifications to the event's damage, such as reduction due
* to effects or armour.
*
* @param EntityDamageEvent $source
*/
public function applyDamageModifiers(EntityDamageEvent $source) : void{
if($source->canBeReducedByArmor()){
@ -486,8 +456,6 @@ abstract class Living extends Entity implements Damageable{
* Called after EntityDamageEvent execution to apply post-hurt effects, such as reducing absorption or modifying
* armour durability.
* This will not be called by damage sources causing death.
*
* @param EntityDamageEvent $source
*/
protected function applyPostDamageEffects(EntityDamageEvent $source) : void{
$this->setAbsorption(max(0, $this->getAbsorption() + $source->getModifier(EntityDamageEvent::MODIFIER_ABSORPTION)));
@ -517,8 +485,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Damages the worn armour according to the amount of damage given. Each 4 points (rounded down) deals 1 damage
* point to each armour piece, but never less than 1 total.
*
* @param float $damage
*/
public function damageArmor(float $damage) : void{
$durabilityRemoved = (int) max(floor($damage / 4), 1);
@ -713,15 +679,11 @@ abstract class Living extends Entity implements Damageable{
}
}
return !empty($this->effects);
return count($this->effects) > 0;
}
/**
* Ticks the entity's air supply, consuming it when underwater and regenerating it when out of water.
*
* @param int $tickDiff
*
* @return bool
*/
protected function doAirSupplyTick(int $tickDiff) : bool{
$ticks = $this->getAirSupplyTicks();
@ -757,7 +719,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Returns whether the entity can currently breathe.
* @return bool
*/
public function canBreathe() : bool{
return $this->hasEffect(Effect::WATER_BREATHING) or $this->hasEffect(Effect::CONDUIT_POWER) or !$this->isUnderwater();
@ -765,7 +726,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Returns whether the entity is currently breathing or not. If this is false, the entity's air supply will be used.
* @return bool
*/
public function isBreathing() : bool{
return $this->getGenericFlag(self::DATA_FLAG_BREATHING);
@ -774,8 +734,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Sets whether the entity is currently breathing. If false, it will cause the entity's air supply to be used.
* For players, this also shows the oxygen bar.
*
* @param bool $value
*/
public function setBreathing(bool $value = true) : void{
$this->setGenericFlag(self::DATA_FLAG_BREATHING, $value);
@ -784,8 +742,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Returns the number of ticks remaining in the entity's air supply. Note that the entity may survive longer than
* this amount of time without damage due to enchantments such as Respiration.
*
* @return int
*/
public function getAirSupplyTicks() : int{
return $this->propertyManager->getShort(self::DATA_AIR);
@ -793,8 +749,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Sets the number of air ticks left in the entity's air supply.
*
* @param int $ticks
*/
public function setAirSupplyTicks(int $ticks) : void{
$this->propertyManager->setShort(self::DATA_AIR, $ticks);
@ -802,7 +756,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Returns the maximum amount of air ticks the entity's air supply can contain.
* @return int
*/
public function getMaxAirSupplyTicks() : int{
return $this->propertyManager->getShort(self::DATA_MAX_AIR);
@ -810,8 +763,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Sets the maximum amount of air ticks the air supply can hold.
*
* @param int $ticks
*/
public function setMaxAirSupplyTicks(int $ticks) : void{
$this->propertyManager->setShort(self::DATA_MAX_AIR, $ticks);
@ -835,16 +786,14 @@ abstract class Living extends Entity implements Damageable{
/**
* Returns the amount of XP this mob will drop on death.
* @return int
*/
public function getXpDropAmount() : int{
return 0;
}
/**
* @param int $maxDistance
* @param int $maxLength
* @param array $transparent
* @param true[] $transparent
* @phpstan-param array<int, true> $transparent
*
* @return Block[]
*/
@ -886,14 +835,12 @@ abstract class Living extends Entity implements Damageable{
}
/**
* @param int $maxDistance
* @param array $transparent
*
* @return Block|null
* @param true[] $transparent
* @phpstan-param array<int, true> $transparent
*/
public function getTargetBlock(int $maxDistance, array $transparent = []) : ?Block{
$line = $this->getLineOfSight($maxDistance, 1, $transparent);
if(!empty($line)){
if(count($line) > 0){
return array_shift($line);
}
@ -903,8 +850,6 @@ abstract class Living extends Entity implements Damageable{
/**
* Changes the entity's yaw and pitch to make it look at the specified Vector3 position. For mobs, this will cause
* their heads to turn.
*
* @param Vector3 $target
*/
public function lookAt(Vector3 $target) : void{
$horizontal = sqrt(($target->x - $this->x) ** 2 + ($target->z - $this->z) ** 2);

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\entity;
abstract class Monster extends Creature{
}

Some files were not shown because too many files have changed in this diff Show More