Compare commits

...

1828 Commits

Author SHA1 Message Date
593b0497b0 Fixed #1750 cannot place slabs against blocks 2014-09-22 11:58:15 +02:00
0907aedcef Fixed Entity/Block issues on negative coordinates, closes #2100 2014-09-22 11:48:39 +02:00
0a29e66b62 Fixed #2114 Removed Player collisions with other entities 2014-09-22 11:26:12 +02:00
3cc4afbcd6 Possible fix for #1920 2014-09-22 11:21:54 +02:00
d04e994d1b Added TPS load to /status 2014-09-21 12:18:51 +02:00
3d870629f2 Fixed ifconfig command typo 2014-09-21 12:18:26 +02:00
8dbe834dc3 Submodule update 2014-09-21 12:18:10 +02:00
36d8100e17 Protect against \0 attacks on name checking 2014-09-20 18:26:17 +02:00
b880bf13f8 Documented tool usage in Level::useBreakOn() 2014-09-20 18:25:53 +02:00
1ac08ce404 Fixed Utils::getUniqueID() on Linux due to /proc/cpuinfo 2014-09-20 12:39:57 +02:00
689b2ea877 Fixed #2104 Can't place blocks where non-solid entities exist 2014-09-20 11:10:46 +02:00
d1f22ee395 Block more player actions when dead, closes #2102 2014-09-19 20:19:27 +02:00
056ed4802f Send project name on usage 2014-09-19 15:08:40 +02:00
bcb65e9a48 Send build number on usage 2014-09-19 15:07:48 +02:00
5404ba77d0 Throw exception when Server::dispatchCommand() is called with an invalid CommandSender 2014-09-19 10:30:35 +02:00
ae54426836 Fixed date_default_timezone_set E_NOTICE 2014-09-19 10:26:44 +02:00
ee7d84dfbd Fixed T_DOUBLE_COLON 2014-09-19 09:48:02 +02:00
3e1ea23036 Fixed CallbackTask name 2014-09-19 09:46:38 +02:00
d312d2a143 Possible fix for #2046, removed embedded class names 2014-09-19 09:44:58 +02:00
8c627bd0af Remove level locks, possible fix for #2046 2014-09-18 11:44:16 +02:00
6fb7170556 Handle force parameter properly on Level::unload() 2014-09-18 11:38:03 +02:00
50f5c6d8ed RakLib patches 2014-09-18 09:22:52 +02:00
f9d5c5bd37 Improved event checking on PlayerInteractEvent 2014-09-16 17:49:44 +02:00
45dbb3f828 Improved block collision check 2014-09-16 12:02:33 +02:00
8a8a95480e Added Cactus damage 2014-09-16 12:02:18 +02:00
34139c7efe Added more death messages 2014-09-16 11:51:43 +02:00
f0e7713dce Added suffocation, drowning damage. Closes #1908 2014-09-16 11:51:31 +02:00
3ba099b309 Cobweb, Ladders and Water won't cause fall damage 2014-09-16 10:52:00 +02:00
c4a0c759dc Show fire to other clients 2014-09-16 10:48:56 +02:00
e9a2f88847 Added Fire, Lava damage 2014-09-16 10:42:29 +02:00
e608acbd1c Improved Player last damage check 2014-09-16 10:42:01 +02:00
42033da08b Fixed #2035 Invalid Fence Gate bounding box 2014-09-16 00:47:04 +02:00
69ab0d433b Removed old trigger_error() 2014-09-16 00:42:36 +02:00
44a30b7fac Added forced position strong check for Player 2014-09-16 00:32:03 +02:00
50b2f55583 Increased movement error range 2014-09-15 23:53:08 +02:00
da084d6908 Fixed door bounding boxes, closes#2075 2014-09-15 23:40:26 +02:00
7d51bc0004 Possible fix for #2077 2014-09-15 22:14:05 +02:00
87dbc18452 Removed position revert message on plugin event cancelled 2014-09-15 20:32:42 +02:00
5b8d4bba11 Fixed issues with placing doors 2014-09-15 20:32:27 +02:00
bb4c54106a Added temporal workaround for pthreads version check 2014-09-15 18:55:15 +02:00
1617b2509e Fixed plugin-related crash 2014-09-15 12:09:30 +02:00
ec293ebd9e Merge pull request #2071 from PocketMine/pthreads-fix
Removed pthreads workarounds, new pthreads version
2014-09-15 10:16:35 +02:00
9f9422f0ed Added Player->forceMovement check on teleport 2014-09-15 01:16:13 +02:00
da715e48e2 Bumped pthreads version 2014-09-13 12:07:04 +02:00
702b2e539c Update RakLib 2014-09-13 12:01:11 +02:00
63fc229c12 Enabled default PHP GC on generator thread 2014-09-12 15:57:02 +02:00
c71689a919 Optimized server sleep times 2014-09-12 15:56:21 +02:00
09428bc8c7 Merge branch 'master' into pthreads-fix 2014-09-12 13:32:53 +02:00
6c7e16d9d4 Added Permission/Permissible calculation timings 2014-09-12 13:08:59 +02:00
315ea2ea3c 64-bit Random optimizations 2014-09-12 12:58:21 +02:00
83eb9f778a Level generators can be set in server.properties 2014-09-12 01:05:32 +02:00
7923c40b33 Removed as Vector3 on Flat generator 2014-09-12 00:12:52 +02:00
d298adabad Merge branch 'master' into pthreads-fix 2014-09-11 22:06:10 +02:00
cfcf515f62 Added type hint to BlockEvent::getBlock() 2014-09-11 21:57:56 +02:00
b5deae7ba0 Added synchronization to GenerationThread::pushMainToThreadPacket() 2014-09-11 19:18:14 +02:00
d991c32435 Fixed Generator Thread as specified on krakjoe/pthreads#349 2014-09-11 19:10:25 +02:00
dbd1f3f96e Use pthreads interface on Chunk Generation THread, remove IPC sockets, improve performance 2014-09-11 18:05:14 +02:00
0bd7ab9def Added .mailmap file, fixes duplicated commiter names 2014-09-11 17:41:07 +02:00
665c275bb7 New improved RakLib version with pthreads changes 2014-09-11 17:18:54 +02:00
7ef2708fca Permission & interface optimization 2014-09-11 16:43:11 +02:00
78b4223795 Added PermissionAttachment::unsetPermissions(), PermissionAttachment::clearPermissions() 2014-09-11 12:43:53 +02:00
0328b4c5f5 Added PermissionAttachment::setPermissions()
This allows bulk permission without recalculating the new permissions until all everything is set. Permission plugins that set a big amount of nodes may want to use this method.
2014-09-11 12:39:01 +02:00
4624dfb472 Fixed Permissible::setPermission() not using the correct order on replacement 2014-09-11 12:17:03 +02:00
fba12c6ddf Fixed EntityMoveEvent not being cancelled correctly on players 2014-09-10 20:06:30 +02:00
60011a5ecf Fixed PermissionAttachment not recalculating its Permissible permissions 2014-09-10 20:05:41 +02:00
f4ae58dda2 Removed pthreads workarounds 2014-09-10 15:11:56 +02:00
8c939feed9 Added Pumpkin & Lit Pumpkin rotation, closes 2014-09-10 12:36:05 +02:00
02ca227085 Normalized Player pitch/yaw 2014-09-10 12:23:23 +02:00
1174b0c45c Added binary reading optimizations, faster 64-bit reading 2014-09-10 12:13:15 +02:00
8940360df4 Possible fix for #2061 2014-09-10 10:43:24 +02:00
bb34e06754 Fix division by zero when the server goes too fast 2014-09-09 19:13:35 +02:00
e06092cb99 Added Server::getTickUsage() 2014-09-09 18:46:20 +02:00
57373b8c5e TPS measurement improvement, moved interface handling to tick 2014-09-09 18:07:27 +02:00
317c6788a6 Updated RakLib path 2014-09-08 10:11:43 +02:00
0a4e0e3228 Fixed Item drop delay 2014-09-08 07:40:19 +02:00
d8c492de4a Merge pull request #2062 from Yosshi999/patch1
Fixed HeldItem were swapped in mining
2014-09-08 07:37:24 +02:00
05d59d587b Merge pull request #2063 from Yosshi999/patch2
Fixed Player's slot[0] disappears on loging in
2014-09-08 07:37:16 +02:00
7d387fe6aa Fixed TravisTest output 2014-09-07 19:54:13 +02:00
4f7a6a06be Fixed TravisTest pipes 2014-09-07 19:47:31 +02:00
344c84cfa6 Added --disable-readline CLI argument 2014-09-07 19:42:36 +02:00
bd721a13a3 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-09-07 19:33:01 +02:00
92b0b4d43c Implemented basic Travis-CI test 2014-09-07 19:32:21 +02:00
d0b0fbf992 Merge pull request #2064 from PEMapModder/patch-2
Fixed wrong cases
2014-09-07 09:02:54 +02:00
ab334e6962 Fixed wrong cases
I know this doesn't matter at all, but it is ugly in IDEs.
2014-09-07 13:21:05 +08:00
1ad6438e60 Fixed Player's slot[0] disappears on loging in 2014-09-07 11:37:54 +09:00
4ecec42c9d Fixed HeldItem were swapped in mining 2014-09-07 11:29:17 +09:00
84e62598ce Implemented attack cooldown 2014-09-06 16:52:52 +02:00
ad7acb93b6 Added cactus neighbour block check 2014-09-05 11:16:24 +02:00
ac4b4b08fd Fixed Level::setBlock() old calls 2014-09-05 11:00:13 +02:00
d3c308c5a8 Fixed possible Player crash on save 2014-09-05 10:50:19 +02:00
98e0583f34 Implemented Falling Sand 2014-09-05 10:50:06 +02:00
020351e20f Fixed #2052 2014-09-05 09:02:45 +02:00
f140fef52d Possible fix for level save issues, related to #1985 #1982 #1758 2014-09-04 12:37:27 +02:00
9980a0780a Fixed Server::getTicksPerSecond() 2014-09-04 12:22:16 +02:00
352497d88c Improves server ticking.
As I was lying in my bed, I came to a solution for the tick problem.
While remembering how most of the time the server is sleeping,
and how the TPS drops once costly operations are ticked,
I reviewed mentally that part of the code, Server::tick().

Then I saw it: I was setting the next execution time
using the time after it was executed as the base, but it should
have been done using the tick start time - that way if something takes
longer, the server will catch up and won't drop the TPS
until the CPU hits its limit.

I got up, got to my computer, and checked that function.
It was exactly as I saw in a near-dream state, so I fixed it
and tested things if they worked right.

Now I'm fully awake and I can't sleep anymore, so I wrote this.
2014-09-04 01:04:09 +02:00
ba08bfaa45 Do not report E_PARSE or E_COMPILE_ERROR crashes 2014-09-03 13:38:24 +02:00
dea4513c34 Possible fix for #2041 2014-09-03 11:55:49 +02:00
0eac084aa7 Added extra documentation to Level::setBlock() 2014-09-03 11:44:30 +02:00
e17ecf5795 Improved Arrow / Item movement 2014-09-03 10:55:14 +02:00
e94ddcabe0 Fixed dropped items going too fast 2014-09-01 23:37:31 +02:00
acf7eb1ce9 Remove scheduled updates from entities 2014-09-01 23:30:35 +02:00
dcfb7a7ac4 Fixed #2037 2014-09-01 17:47:28 +02:00
97c87aa8fa Added __debugInfo() to Server and Level 2014-09-01 17:37:28 +02:00
11f684d803 Improved CallbackTask timings data 2014-09-01 12:44:52 +02:00
ff48eb3d4d Added better Entity/Tile scheduled updates 2014-09-01 11:59:46 +02:00
e047b6a870 Fixed bows not getting damaged 2014-09-01 11:43:48 +02:00
c5626bae34 Do not set Level to null, closes #2032 2014-09-01 11:29:44 +02:00
3eac08f5ba Possible fix for #2027, properly check Player onGround flag 2014-09-01 02:32:16 +02:00
cc2555bb88 Fixed crash when chests are closed with viewers 2014-09-01 02:26:23 +02:00
705e4da789 Tick entities on Level, show correct timing reports 2014-09-01 01:56:13 +02:00
9b7a94b5ee Fixed timings ticks getting reset 2014-09-01 01:50:28 +02:00
bcdb6d8c2e Fixed timings name 2014-09-01 01:28:42 +02:00
eff63a661e Player creative check refactor 2014-08-31 10:49:20 +02:00
5a756d215d Fixed creative players dropping their inventory 2014-08-31 10:45:38 +02:00
422262d585 Fixed infinite Entity recursion on chunk load 2014-08-31 01:06:53 +02:00
b761a97660 Fixed crash due to class name conflict 2014-08-31 01:05:15 +02:00
7579cd763a Added Trapdoor bounding box 2014-08-30 23:57:57 +02:00
6bc5f60011 Added Cobble Wall bounding box 2014-08-30 23:52:06 +02:00
3eb8ca0d13 Added Soul Sand bounding box 2014-08-30 23:47:39 +02:00
a23352be88 Added Ladder bounding box 2014-08-30 23:45:08 +02:00
fa5f00a1ff Added Cake bounding boxe 2014-08-30 23:42:07 +02:00
d3a05adede Added Doors bounding boxes 2014-08-30 23:38:56 +02:00
f9182bd0f8 Added Iron bars bounding box 2014-08-30 23:30:10 +02:00
edad52c6ea Added Glass Pane bounding box 2014-08-30 23:30:01 +02:00
cd5e16f017 Added Fence Gate bounding box 2014-08-30 23:20:59 +02:00
310a7d6c04 Added Fence bounding box 2014-08-30 23:18:37 +02:00
ccea26c978 Added Farmland bounding box 2014-08-30 23:07:55 +02:00
cf542ac73a Added End Portal frame bounding box 2014-08-30 23:06:50 +02:00
3bf39df255 Added cactus bounding box 2014-08-30 23:06:27 +02:00
910e5e6181 Added stairs bounding box 2014-08-30 23:01:33 +02:00
a396b8c220 Fixed #2021 2014-08-30 21:45:32 +02:00
ec1fe6a083 Fixed EntityShootBowEventEvent crash 2014-08-30 19:07:17 +02:00
706c97b9b1 Made shooting bow use its durability 2014-08-30 18:46:09 +02:00
a04516a879 Added EntityShootBowEvent, made bow require an arrow 2014-08-30 18:43:32 +02:00
0f6dfd39b8 Made EntityDamageByEntityEvent call EntityDamageEvent handlers 2014-08-30 18:41:00 +02:00
36ee6d9966 Added arrow and suicide death messages 2014-08-30 18:30:39 +02:00
23793e0fc4 Added check for invalid entity attack 2014-08-30 18:24:24 +02:00
3409d332e7 Added survival check to movements 2014-08-30 17:57:30 +02:00
ca1b67a675 hmm 2014-08-30 17:07:50 +02:00
f5eed4f12b Disable RakLib port checking by default 2014-08-30 16:14:09 +02:00
7a10f91330 Fixed entity partial block moving 2014-08-30 15:31:22 +02:00
6477f4f077 Added Wooden Slab bounding box 2014-08-30 02:14:48 +02:00
3731e74696 Added Slab bounding box 2014-08-30 02:14:24 +02:00
c774e4c203 Added Carpet bounding box 2014-08-30 02:09:15 +02:00
d4907a2688 Added Chest bounding box 2014-08-30 02:07:50 +02:00
793520926b Added Bed bounding box 2014-08-30 02:06:46 +02:00
bf839e821c Added proper arrows and damage 2014-08-30 01:22:46 +02:00
7aeacf2705 Fixed armor crafting recipes 2014-08-29 14:49:41 +02:00
fc62c91c90 Fixed double physics calculation 2014-08-29 13:33:59 +02:00
98dd7f8c15 Use Entity::move() as player movement, protect against noclip cheat 2014-08-29 13:33:25 +02:00
7a1d25617f Fixed physics sneak flag 2014-08-29 13:02:08 +02:00
69b3ef326b Merge pull request #1994 from PocketMine/nbt-array
Added NBT <-> PHP array/type conversion methods
2014-08-29 12:17:10 +02:00
fadff2cc5b Removed debug code 2014-08-28 23:59:18 +02:00
43a0ef433e API version bump 2014-08-28 23:44:19 +02:00
9a1e7ca83c Implemented NBT::getArray() and NBT::setArray() 2014-08-28 23:43:04 +02:00
b9111b6f52 Fixed #1992 2014-08-28 23:19:44 +02:00
be70121f3a Renamed Item\Block to Item\ItemBlock 2014-08-28 22:28:32 +02:00
e2986992c7 Fixed AxisAlignedBB infinite expansion 2014-08-28 21:11:49 +02:00
9fb46d8fe8 Fixed entity physics 2014-08-28 18:26:37 +02:00
eab86f5f90 Replaced array() with [] 2014-08-28 17:04:22 +02:00
2f2afe2336 Fixed #1966 Face Lit Pumkins correctly 2014-08-28 11:00:41 +02:00
f7de1ede3f Made PocketMine loader backwards-compatible 2014-08-27 21:30:36 +02:00
812ae09a06 Merge branch 'php-5.6' 2014-08-27 21:24:52 +02:00
e473cd5e67 Improved unloaded tile entity handling 2014-08-27 18:18:33 +02:00
9e5e4fb362 Fixed possible Level::getBlock() crash 2014-08-27 18:11:23 +02:00
afa98866e0 Fixed Item after-clone behaviour 2014-08-27 18:11:02 +02:00
90fa40de34 Added entity id names 2014-08-27 17:42:38 +02:00
e6234c4c4d Removed cli_set_process_title() check 2014-08-27 12:45:14 +02:00
8f66d03d99 Improved Item::get() 2014-08-27 12:43:54 +02:00
8e9da9c84e Improved safe_var_dump(), Inventory::addItem() Inventory::removeItem() using argument unpacking 2014-08-27 12:29:04 +02:00
759d7e2545 Initial PHP 5.6 features support 2014-08-27 12:21:01 +02:00
f4b92bcdfc Fixed #1980 2014-08-27 11:41:00 +02:00
f7e2d31f0a Check player online status, closes #1983 2014-08-27 11:28:49 +02:00
e0fc3784ad Throw exception when saving an already-closed player, closes #1981 2014-08-26 22:02:43 +02:00
bf5630dc0d Fixed #1926 Teleport to non-generated chunks 2014-08-26 16:45:51 +02:00
472431752b Dropped items and arrows get deleted on Y < 0 2014-08-26 16:19:45 +02:00
c40f9f65a5 Optimize imports 2014-08-26 11:54:24 +02:00
f74af12914 Improved chunk ticking, enabled again. Disable it setting chunk-ticking.per-tick to 0 2014-08-26 11:52:45 +02:00
d169734781 Improved chunk sending 2014-08-26 11:50:51 +02:00
35b86af2af Fixed furnace achievement check 2014-08-26 10:56:33 +02:00
706bc8e8db Fixed undefined index on furnace recipes 2014-08-26 00:05:40 +02:00
b542c5b9bd Added Furnace progress fire 2014-08-26 00:05:18 +02:00
69800c6d79 Fixed #1911 Implemented FurnaceInventory callback 2014-08-26 00:03:16 +02:00
ea9fc3c72e Fixed #1879 Tile entities were not saved on chunk unload 2014-08-26 00:02:20 +02:00
8b90281355 Fixed #1953 Increased item PickupDelay to 2.5 seconds 2014-08-25 23:38:35 +02:00
92cabced97 Ctrl+C handling and kill signals are working again 2014-08-25 23:24:18 +02:00
cb645fa288 Moved spl to PocketMine-SPL 2014-08-25 21:02:33 +02:00
bda597a71e Moved spl to PocketMine-SPL 2014-08-25 20:54:53 +02:00
d6a0e284e3 Workaround BaseChunk::setBlock() recursion issues 2014-08-25 17:08:02 +02:00
1795c8c5e3 Fixed Chests/Furnaces not dropping contents when broken 2014-08-25 16:59:04 +02:00
c3b1b59118 Fixed #1970 Breaking blocks does not remove tile entities 2014-08-25 16:55:52 +02:00
a0df0a8fff Fixed player fall damage 2014-08-25 16:53:20 +02:00
049103ab7a Improved Block selection and construction performance 2014-08-25 16:39:47 +02:00
84c63c48ca Improved NBT IntArray read/write 2014-08-25 16:28:46 +02:00
20e11bd408 Improved player onGround collision check 2014-08-25 15:48:12 +02:00
456760b334 Removed unloaded chunk check 2014-08-25 15:43:48 +02:00
46e502430e Added teleport flag to MovePlayerPacket, improves player movement 2014-08-25 13:01:39 +02:00
87b800ebb9 Fixed #1967 Glowstone dust -> Glowstone recipe 2014-08-25 11:33:47 +02:00
9fdafb87b4 Fixed #1962 Fake client-side player entities 2014-08-24 23:12:12 +02:00
1fcfef20b0 Implemented beds 2014-08-24 20:34:24 +02:00
6109505786 Implemented correct time offsets and speed 2014-08-24 20:34:06 +02:00
764937dda4 Fixed #1961 2014-08-24 18:08:14 +02:00
8bf36315ae Updated RakLib 2014-08-24 17:21:05 +02:00
1ea0531ec7 Added RakLib port checking option 2014-08-24 17:16:37 +02:00
c47e359262 Updated blocks bounding boxes 2014-08-24 16:30:56 +02:00
f0f9bccb4b Fixed #1960 2014-08-24 15:57:13 +02:00
214dcef1ea Improved Air block collision check 2014-08-24 15:55:34 +02:00
4edadd764c Improved Level::getBlock() 2014-08-24 14:30:43 +02:00
01ebe74974 Performance improvements in blocks and Entities 2014-08-24 14:08:17 +02:00
84ce5f1c73 Performance improvements in NBT reading/writing 2014-08-24 13:59:37 +02:00
93a2bd36e0 Require PHP >= 5.5 2014-08-24 13:33:03 +02:00
fdd59e4506 Fixed default memory-limit values 2014-08-23 20:14:41 +02:00
9b86b1d45b Added --enable-profiler parameter to use with @krakjoe profiler 2014-08-23 20:14:04 +02:00
1a38003bc4 Fixed /version 2014-08-22 19:39:24 +02:00
60ea4d0e96 Removed hardcoded Server name from source 2014-08-22 18:31:17 +02:00
6077190a62 Deprecated Server::loadPlugin(Plugin) in favor of Server::enablePlugin(Plugin) 2014-08-22 17:43:29 +02:00
57299b9a29 Fixed #1948 /whitelist list is now working 2014-08-22 13:23:56 +02:00
bb08da701b Fixed header logo in PR #1944 2014-08-22 11:30:15 +02:00
ee593fe5e4 Merge pull request #1944 from PEMapModder/patch-2
Cleaned Mycelium.php and fixed its potential crash
2014-08-22 11:22:10 +02:00
e8b1b0fab6 Cleaned Mycelium.php and fixed its potential crash
Crash report: http://crash.pocketmine.net/view/27500
2014-08-22 11:05:47 +08:00
4858c7d82e Merge pull request #1912 from Intyre/feature/block
EndPortal, EndStone, MonsterSpawner, Mycelium and Podzol blocks added
2014-08-21 19:34:51 +02:00
ecc9e1d223 EndPortal meta and Endstone breaktime 2014-08-21 19:26:41 +02:00
a3cc676ac6 Improved player spawn, closes #1890 2014-08-21 19:18:06 +02:00
db7222976e Code cleanup 2014-08-21 17:26:41 +02:00
e1ef86074e Merge pull request #1937 from Yosshi999/patch
Fixed #1923 sending NULL to Level::getXZ()
2014-08-20 16:03:52 +02:00
9f4582349d Fixed #1923 sending NULL to Level::getXZ() 2014-08-20 22:32:19 +09:00
5dc3fe4fe9 Fix backwards-incompatible change 2014-08-19 16:26:37 +02:00
8446bd2ba5 Added thread stop message 2014-08-19 12:55:21 +02:00
9f34d22013 Detach invalid Workers on shutdown 2014-08-19 12:46:44 +02:00
973d6b5869 Removed 'unhandled data packet' debug message 2014-08-19 12:30:12 +02:00
40d2f8a373 Save level data automatically, closes #1927 2014-08-19 11:54:12 +02:00
b66f49dc5e Fixed infinite recursion when setting a block on an EmptyChunkSection 2014-08-19 11:37:02 +02:00
5c150f696c Fixed task not being freed from player on close 2014-08-19 11:31:23 +02:00
0246648a2c Possible solution for #1703 in-game action lag 2014-08-18 23:25:46 +02:00
532b12c6c0 Mycelium spreads like grass and MonsterSpawner breaktime added 2014-08-18 20:06:18 +02:00
34711dc346 Fixed #1889 Players drop their inventory when they die 2014-08-18 14:49:53 +02:00
3c231118a6 Fixed #1674 Wooden tools only craft with Oak wood 2014-08-18 14:43:08 +02:00
a816234ee8 Merge pull request #1917 from Yosshi999/patch2
creative & survival hotbar bugfix
2014-08-18 14:33:05 +02:00
baa34a7cca creative & survival hotbar bugfix
:P
2014-08-18 21:18:14 +09:00
daf1a8266d Merge pull request #1906 from PocketMine/MoreEvents
Added more events, API 1.3.0
2014-08-18 13:55:35 +02:00
4e6ff81674 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-08-18 13:51:21 +02:00
84a1b319c8 Modified chunk generation garbage collector 2014-08-18 13:49:43 +02:00
16774e66e6 Fixed crashes when default level is not loaded 2014-08-18 13:42:20 +02:00
67b97ade8b Workaround crash when placing paintings 2014-08-18 13:36:59 +02:00
0f04f4bc8a creative & survival hotbar bugfix 2014-08-17 21:55:31 +09:00
4c7b172cbe creative & survival hotbar bugfix
Supports Air
Bug fix
2014-08-17 21:51:32 +09:00
e91781cbf2 EndPortal, EndStone, MonsterSpawner, Mycelium and Podzol blocks added 2014-08-17 02:00:17 +02:00
cf0dc95a76 Merge pull request #1910 from Falkirks/master
Improve behaviour of showPlayer()
2014-08-16 20:26:56 +02:00
9fa7b9b5ea Fixed indent 2014-08-16 11:03:40 -07:00
badbe75d58 Check if player is online before showing 2014-08-16 11:00:57 -07:00
5eee4f9771 Fixed AddEntityPacket, added base Arrow 2014-08-16 16:37:57 +02:00
52d28795fa Added Villager spawn egg 2014-08-16 14:25:58 +02:00
c675605014 Added item activation, zombie spawn egg 2014-08-16 14:01:07 +02:00
758a6af678 Added Chiseled stone brick, red sand, end stone 2014-08-16 13:34:58 +02:00
6f30cd8a22 Removed PHP_VERSION constant on pocketmine namespace 2014-08-16 13:17:05 +02:00
8455e89784 Bump API version to 1.3.0 2014-08-16 13:08:46 +02:00
eee0eb5458 Added RemoteServerCommandEvent 2014-08-16 13:05:20 +02:00
7e4a191593 Added SignChangeEvent 2014-08-16 12:58:16 +02:00
8725ad522f Remove player unset limitations 2014-08-16 12:47:19 +02:00
a610a86579 Fixed #1901, EmptyChunkSection gets replaced by invalid Section 2014-08-16 11:54:08 +02:00
24134a06b8 Alternate chunk generation between multiple levels 2014-08-16 11:49:37 +02:00
de6f5309dc Fixed #1882 Race-condition on multiple world generation, causing lock of the geneartion thread 2014-08-16 11:18:26 +02:00
a2e231101e Added extra information to CONTRIBUTING.md about issue titles 2014-08-16 10:58:41 +02:00
918024e466 Load later plugins with custom loader, fixes API 2014-08-16 00:30:37 +02:00
9e74169d74 Better Anvil chunk loading 2014-08-15 17:04:16 +02:00
ec93ed3e3d Fixed crash on tile unloading 2014-08-15 16:37:39 +02:00
a7b44e3892 Stop submission of plugin syntax error crashes 2014-08-15 16:18:54 +02:00
31b92b392e Throw invalid event exception when a plugin tries to declare an abstract event 2014-08-15 16:15:12 +02:00
2f9494ed52 Fixed crash caused by a race condition on Query 2014-08-15 16:07:04 +02:00
7a5c583407 Throw exception when null chunk is passed to a Tile/Entity 2014-08-15 16:04:48 +02:00
f60e2860e8 Release strong weak references on close, closes #1883 2014-08-15 13:41:13 +02:00
9c95441402 Force despawn of players on quit 2014-08-13 20:43:46 +02:00
1f902d814e Move only own player from eye level 2014-08-13 20:25:43 +02:00
0ab3da88be Send player movements as direct packets 2014-08-13 19:32:25 +02:00
e6edace944 Move players from eye level, not top of head 2014-08-13 19:26:45 +02:00
3ee61d5ebb Improved chunk cache, clean invalid chunks 2014-08-13 19:21:42 +02:00
19d391b9b2 Added Exception handling on level loading 2014-08-13 10:48:53 +02:00
e462a89189 Order chunks to be generated 2014-08-13 09:51:43 +02:00
d616e73242 Fixed chunk sending 2014-08-13 09:41:13 +02:00
5ec6ccefda Merge pull request #1875 from KnownUnown/patch-1
Fixed AddMobPacket's Type - (is now int)
2014-08-12 19:34:42 +02:00
58d7599d6f Fixed AddMobPacket's Type - (is now int)
Thanks @Intyre!
2014-08-12 12:31:07 -05:00
0c5f920dfd Level formats can send chunks without creating an AsyncTask, API 1.2.1 (small fix, no changes) 2014-08-12 17:39:39 +02:00
67f6482c76 Implemented circular chunk sending 2014-08-12 17:30:01 +02:00
7b141b0b73 Remove head offset from client-side MovePlayerPacket 2014-08-12 17:16:31 +02:00
b17ce16262 Fixed RCON usage 2014-08-10 18:35:01 +02:00
fee7f5060b Made AsyncTask::onCompletion() implementation optional 2014-08-10 18:15:06 +02:00
76cd164aa4 Fixed source servers getting invalid AutoUpdater notifications 2014-08-10 13:25:15 +02:00
582f1540a7 Players are now moved using the head, closes #1842 2014-08-10 13:22:12 +02:00
4d7c953572 Possible fix for 'Invalid Chunk given' crash 2014-08-10 13:09:41 +02:00
06c01f14c6 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-08-10 12:28:03 +02:00
c43431c921 Fixed #1826 Block damage values were swapped in McRegion 2014-08-10 12:27:49 +02:00
4e1805ae02 Merge pull request #1859 from PEMapModder/patch-2
Update CONTRIBUTING.md
2014-08-10 12:09:32 +02:00
ac34b9eda0 Update CONTRIBUTING.md
PocketMine namespaces are all in lowercase letters.
2014-08-10 18:08:09 +08:00
3495c79c0c Fixed crashes related to ChunkEvent 2014-08-09 10:42:03 +02:00
77799d8f3d Fixed AsyncWorker includes 2014-08-08 18:06:07 +02:00
dfdf9ddb45 Merge pull request #1846 from milo1000/issue_1843
Issue 1843 - RCON worker threads synchronization corrected
2014-08-08 16:26:47 +02:00
86d423ae4d Hide timezone guess errors 2014-08-08 12:53:31 +02:00
eff454d103 Fixed AsyncWorker not getting the proper path and not using the correct class 2014-08-08 11:51:36 +02:00
51120fdd4f Added ThreadManager, removed PHP self-kill 2014-08-08 11:36:55 +02:00
5242e87026 Issue 1843 - RCON worker threads synchronization corrected 2014-08-07 10:19:23 +02:00
269a10fadd Modified Level and Chunk deprecated methods 2014-08-06 16:22:55 +02:00
232bf5ebe4 Modified Chunk provider saving 2014-08-06 16:22:49 +02:00
2904aa06ef Merge pull request #1838 from PEMapModder/patch-2
Fixes Position::fromObject() $strong parameter neglected
2014-08-06 11:12:53 +02:00
e10c70e776 A typo fix 2014-08-06 11:06:30 +08:00
2cead226db Fixes Position::fromObject() $strong parameter neglected 2014-08-05 23:45:09 +08:00
2784925a5e Merge pull request #1822 from LukeDarling/patch-1
fixed tell command so itdoesn'tlooklikethisanymore
2014-08-03 22:38:21 +02:00
d2a14e8303 fixed tell command so itdoesn'tlooklikethisanymore 2014-08-03 13:22:41 -04:00
071033ad5c Added new installer languages 2014-08-02 18:00:36 +02:00
1e3ed8640c Updated Installer wizard language 2014-08-02 17:54:48 +02:00
60a576e541 Added proper Entity->__toString() 2014-08-02 17:48:56 +02:00
eee7e659e9 Added ChunkLoadEvent, ChunkUnloadEvent, ChunkPopulateEvent 2014-08-02 17:19:33 +02:00
7ddfd4394d Merge pull request #1818 from 64FF00/master
Added getExecutor() and setExecutor() method to PluginCommand
2014-08-02 14:43:12 +02:00
f0f2eb9a01 ... 2014-08-02 10:17:27 +09:00
839f6621eb Added getExecutor() and setExecutor() method to PluginCommand
:D
2014-08-02 10:11:36 +09:00
7fcaa78de4 Catch uncatched thrown Exceptions to get useful backtraces 2014-08-01 17:04:16 +02:00
915443b508 Disabled chunk ticking until it is stable 2014-08-01 15:25:40 +02:00
e17a7005a1 Throw exception on invalid chunk 2014-08-01 14:33:50 +02:00
c1846e3bcf Improved chunk serialization 2014-08-01 13:22:48 +02:00
81feff6d0d Merge pull request #1813 from PocketMine/revert-1748-enabled-builtin-php
Revert "Enabled built-in PHP"
2014-08-01 12:50:05 +02:00
9b84d8c248 Revert "Enabled built-in PHP" 2014-08-01 12:49:53 +02:00
26ec562fbf Added worlds directive to pocketmine.yml to load extra worlds or use a plugin-provided generator 2014-08-01 12:24:08 +02:00
d10274ca7c Improved memory usage when chunks are saved/generated 2014-08-01 11:53:24 +02:00
7c68e42a86 Fixed chunk rotation on McRegion-based worlds 2014-08-01 11:52:13 +02:00
171de939cd Fixed crash on chunks that are used by an entity after generation 2014-07-31 20:05:07 +02:00
58bded4988 Merge pull request #1801 from PocketMine/McRegion
Added multiple level formats support, implemented McRegion
2014-07-31 19:28:39 +02:00
cb4a970631 Tuned generator to use a better way to process chunks, closes #1807 #1794 #1740 #1741 #1685 2014-07-31 19:27:01 +02:00
95b5979351 Removed SimpleChunk from generator, core, use binary representation of chunks 2014-07-31 14:28:17 +02:00
18d13fdc32 Added threaded chunk sending for all formats 2014-07-31 10:19:44 +02:00
1a442b793c Fixed Tiles/Entities not using the correct chunk type 2014-07-30 18:24:59 +02:00
765d4f30c7 Added caching to non-converted network chunks 2014-07-30 17:30:22 +02:00
2eced89e6f Do not send crash reports generated from a source PM installation 2014-07-30 17:05:46 +02:00
293102d8c4 Fixed typo, BLockLight -> BlockLight 2014-07-30 16:59:52 +02:00
25f5d409f1 Fixed loading invalid plugins crashing the server 2014-07-30 16:57:31 +02:00
4128b22e85 Reuse McRegion classes on Anvil 2014-07-30 16:38:56 +02:00
487ce00542 Correctly fixed #1659 PvP settings not working 2014-07-30 16:07:21 +02:00
a9cd03da2e Changed @williamtdr syntax 2014-07-30 16:05:36 +02:00
f5fee4c909 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-07-30 14:10:39 +02:00
016b08ecf2 Added block order detection, added support for non-sectioned level formats 2014-07-30 12:57:00 +02:00
3515a037c5 Merge pull request #1804 from PocketMine/revert-1760-patch-1
Revert API breaking changes "Remove similar player name check from the beginning limit"
2014-07-30 00:36:12 +02:00
d6e413e8ca Revert "Remove similar player name check from the beginning limit" 2014-07-30 00:34:54 +02:00
f991efd5bc Merge pull request #1803 from Falkirks/patch-1
Spelling on crashDump()
2014-07-30 00:12:08 +02:00
913c116e7b Spelling 2014-07-29 15:10:50 -07:00
8fafb85784 Added proper chunk saving in McRegion 2014-07-29 19:36:41 +02:00
b0aad89e7a Fixed a few typos in McRegion 2014-07-29 19:11:09 +02:00
ce018fd7c8 Bumped API version to 1.2.0 (backwards-compatible changes, related to level formats) 2014-07-29 18:55:27 +02:00
afe44e6c6f Added setting to select the default level format 2014-07-29 18:54:40 +02:00
e9311f5ceb Added base McRegion classes 2014-07-29 18:43:52 +02:00
b2978133f7 Added McRegion detection to Anvil 2014-07-29 17:21:07 +02:00
6b331535c6 Merge pull request #1748 from MinecrafterJPN/enabled-builtin-php
Enabled built-in PHP
2014-07-29 09:56:05 +02:00
3370052fac Do not send crash reports from non-phar plugins 2014-07-28 23:14:29 +02:00
7d8a961374 Throw exception when an invalid chunk is set as the parent of a Tile/Entity 2014-07-28 21:40:50 +02:00
e97139919a Added new exception when a plugin creates an orphaned PluginTask 2014-07-28 20:28:50 +02:00
81faddafb0 Fixed crash when using Level scheduled block update ReversePriorityQueue 2014-07-28 19:18:28 +02:00
d0936329aa Fixed crash reports using invalid lastError data 2014-07-28 15:41:13 +02:00
9124513584 Added RakLib version to crash information 2014-07-28 14:48:26 +02:00
e860c339e2 Fixed crash when cactus was updated 2014-07-28 14:46:52 +02:00
10c67a57a7 Added extra crash dump settings, added way to disable parts of it or change the host 2014-07-28 14:42:51 +02:00
b10e63b951 Removed debug values on Crash dump 2014-07-28 13:47:38 +02:00
409eeda6ee Added plugin crash detection 2014-07-28 13:20:13 +02:00
bf09c48d62 Fixed build number on crash dumps 2014-07-28 12:57:08 +02:00
aac646d343 Fixed full path phar on logs 2014-07-28 12:20:16 +02:00
ed90d58e32 Fixed crash when placing water or lava 2014-07-28 12:18:17 +02:00
e219f4784c Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-07-28 12:12:14 +02:00
b5a1c23c50 Moved rtfd documentation 2014-07-28 12:11:01 +02:00
14817df2c7 Merge pull request #1793 from Intyre/bug/inventory
player creative inventory bugfix
2014-07-28 11:36:32 +02:00
cc87064915 player creative inventory bugfix 2014-07-28 02:24:08 +02:00
aded24e6c6 Updated error path replace (again\!) 2014-07-27 23:05:49 +02:00
a95f8b45f1 Updated error path replace 2014-07-27 22:55:45 +02:00
7a3703d8b1 Fixed undefined $fullFile on CrashDump 2014-07-27 21:25:24 +02:00
ca59546ace Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-07-27 21:01:06 +02:00
2330f363bd Fix for thrown EmptyChunkSection modification exception 2014-07-27 20:54:28 +02:00
042861b51f Merge pull request #1790 from RobertClarke/patch-1
Small typo fix on main language file
2014-07-27 18:40:04 +02:00
98f42a936e Small typo fix 2014-07-27 17:36:40 +01:00
6d77b0883e Fixed getTrace() on crash with xdebug 2014-07-27 17:31:39 +02:00
f53d513894 Merge pull request #1789 from PocketMine/CrashDump
Added Crash Dumps and automatic reporting
2014-07-27 15:26:36 +02:00
e6e15ceffa Fixed typo in crash text 2014-07-27 14:09:34 +02:00
9d75baf212 Added automatic reporting 2014-07-27 14:00:00 +02:00
7b45df680e Added time and plugin cause 2014-07-27 12:39:38 +02:00
f93d5339bc Use correct syntax 2014-07-26 17:06:22 +02:00
677071e7cb Merge pull request #1782 from Yosshi999/master
Updated Stick crafting recipe to give x4
2014-07-26 16:22:12 +02:00
4fa6fb0546 Updated Stick crafting recipe to give x4 2014-07-26 22:48:41 +09:00
0ca614a2c3 Merge pull request #1781 from Intyre/versionbump
Support for MCPE v0.9.5
2014-07-26 15:47:59 +02:00
bdfa6c0bc5 link to docs added to README 2014-07-26 15:08:48 +02:00
ccb7e86cf1 changed version and protocol to support v0.9.5 2014-07-26 15:07:32 +02:00
03a970e91f Merge pull request #1777 from Striker209MPE/patch-5
Fixed an error related to AIR constant
2014-07-25 07:51:27 -05:00
b3e9bb8fec Fixed an error related to AIR constant
A E_NOTICE error happened: "Use of undefined constant AIR - assumed 'AIR'"

should be fixed
2014-07-25 11:44:08 +02:00
48b99486b0 Merge pull request #1775 from Intyre/docs
docs for pocketmine-mp.readthedocs.org
2014-07-25 07:03:06 +02:00
6921e6f2aa docs for pocketmine-mp.readthedocs.org 2014-07-25 06:58:57 +02:00
987f54ba08 Edit syntax to confirm with rest of document. 2014-07-24 15:13:12 -05:00
09ef1f1721 Merge pull request #1772 from Striker209MPE/patch-3
Fixed error with useBreakOn parameters
2014-07-24 15:11:59 -05:00
3eae7a1875 Fixed error with useBreakOn parameters
A E_RECOVERABLE_ERROR error happened: "Argument 1 passed to pocketmine\block\Block::getDrops() must be an instance of pocketmine\item\Item, null given

AND

A E_RECOVERABLE_ERROR error happened: "Argument 1 passed to pocketmine\block\Generic::onBreak() must be an instance of pocketmine\item\Item, null given

are fixed
2014-07-24 22:10:33 +02:00
21587ae3eb Merge pull request #1760 from PEMapModder/patch-1
Allow player names contained in existing online player list.
2014-07-23 09:48:11 -05:00
e5337d8949 Make Fire check more efficent - by @Tschrock 2014-07-23 09:46:30 -05:00
c92a1ba7fe Release similar player name check from the beginning
For example, some would like to write `map` for `pemapmodder`, and this is what existed in amai beetroot when we used `SQLite3::query("SELECT ... ALIKE")`.
2014-07-23 22:33:45 +08:00
2066e92f84 Revert "Proper Fire ID checking. Fix #1756."
This reverts commit cd943f52a1.
2014-07-23 09:08:18 -05:00
cd943f52a1 Proper Fire ID checking. Fix #1756. 2014-07-23 08:58:26 -05:00
c3424beda9 Revert "Update Level.php"
This reverts commit da9dfabae4.
2014-07-22 13:59:23 -05:00
b6506d1db8 Revert "Corrected parameters for setBlock()"
This reverts commit 2f3a011ed3.
2014-07-22 13:59:16 -05:00
4cec3e7e37 Merge pull request #1749 from Falkirks/patch-1
Fixed fire issue
2014-07-22 13:29:12 -05:00
2f3a011ed3 Corrected parameters for setBlock() 2014-07-22 07:05:13 -07:00
da9dfabae4 Update Level.php 2014-07-21 18:15:54 -07:00
4c83e9bb56 Update Level.php 2014-07-21 20:04:58 -05:00
090d159766 Enabled built-in PHP 2014-07-22 09:46:47 +09:00
14d86339fc Fixed previous error. 2014-07-21 18:27:50 -05:00
ccf34a9db8 #1745 part 2! 2014-07-21 15:29:40 -05:00
97af1b6008 Fix #1745 2014-07-21 13:02:24 -05:00
16d33b01f4 Fix #1663 2014-07-21 10:51:30 -05:00
fa318ce706 Merge pull request #1736 from swagking47/patch-5
Fix unintentional typo in InventoryTransactionEvent.php.
2014-07-21 10:15:19 -05:00
accea03d52 Merge pull request #1741 from PEMapModder/patch-6
Added count(Enum)
2014-07-21 10:10:40 -05:00
adcdf650a3 Added count(Enum) 2014-07-21 19:25:20 +08:00
e8e825322b Update InventoryTransactionEvent.php 2014-07-20 15:28:53 -04:00
1b36b10520 Merge pull request #1729 from PEMapModder/patch-5
Fixed wrong doccomment for Vector3::add()
2014-07-19 10:32:16 +02:00
0d37e96678 Fixed wrong doccomment for Vector3::add()
Yes I know it was me who wrote it wrong.
2014-07-19 11:59:31 +08:00
2448405e3a Fixed rcon password being shown 2014-07-18 11:58:39 +02:00
2e773a32ff Removed crash() 2014-07-18 11:55:24 +02:00
d8cba4f045 Implemented new crash dumps 2014-07-18 11:54:11 +02:00
07c1ed1c36 Moved pthreads check before its usage 2014-07-18 10:49:38 +02:00
d6711125a9 Bumped MCPE version to v0.9.4 2014-07-18 10:44:14 +02:00
b8802edd6d Only allow one thread per property, fixes #1668 2014-07-17 21:22:48 +02:00
71bf984e9e Better fix for shared STONE constant, closes #1711 2014-07-17 21:20:15 +02:00
9c9d786194 Fix #1659 2014-07-16 13:07:26 -05:00
bd2cb4b851 Fixed #1614, possible solution for #1678 2014-07-15 13:17:29 +02:00
6e77901453 Fixed inventory being sent before spawning 2014-07-14 16:54:29 +02:00
ebe8a902e5 Fixed being killed on teleport 2014-07-14 15:55:16 +02:00
304524f6d8 Fixed crash on /stop 2014-07-14 14:41:19 +02:00
cb879977d2 Use Player::getDisplayName() on more commands 2014-07-14 14:12:03 +02:00
096e238242 Fixed #1628 invalid sender x,y,z on /spawnpoint, closes #1671 2014-07-14 14:07:43 +02:00
f2d5daffc0 Whoops, Markdown spacing issue 2014-07-14 20:23:46 +09:30
12275125d2 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-07-14 12:48:09 +02:00
3d3b6826e4 Merge pull request #1669 from sekjun9878/master
Android issues to the correct repo @PEMapModder
2014-07-14 20:18:20 +09:30
3a8adfe2b8 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-07-14 12:47:34 +02:00
14116b6730 Android issues to the correct repo @PEMapModder 2014-07-14 20:17:30 +09:30
241d3d72af Merge pull request #1664 from sekjun9878/master
Issue Tracking Guidelines
2014-07-14 12:47:11 +02:00
79e864f4f1 Added far-generated loaded chunk to garbage collection 2014-07-14 12:46:03 +02:00
7812a3c4fc Added Won't Fix and Invalid as per @shoghicp's suggestion. Renamed PR: RFC to PR: Contribution 2014-07-14 20:15:26 +09:30
dbe5e9b4e9 Remove informal language from Contributing Guidelines 2014-07-14 17:25:28 +09:30
d743888b8d Issue Tracking Guidelines 2014-07-14 17:11:25 +09:30
0db009b08f Improved chunk generation queue 2014-07-14 03:10:25 +02:00
7cdf5a73eb Bumped MCPE version to 0.9.1 2014-07-14 02:21:04 +02:00
6c442551f7 Fixed client crashing (temp.), fixed clients not spawning. (Fixes #1640 #1636 #1590 #1573) 2014-07-14 02:19:14 +02:00
eccd82ca4b Moved player attack filter from Living to Player 2014-07-13 19:04:00 +02:00
6fbfa1836f Merge branch 'master' of https://github.com/PocketMine/PocketMine-MP 2014-07-13 22:04:41 +09:30
5dfb1fb9d5 Fix bug where a double quote would show when kick reason is not specified. 2014-07-13 22:03:54 +09:30
4a615f03b5 Merge pull request #1649 from PEMapModder/patch-2
Added doccomment for Vector3::add() and Vector3::subtract()
2014-07-13 12:26:46 +02:00
47503d84c2 Added doccomment for Vector3::add() and Vector3::subtract()
This is to avoid IDEs thinking that argument 1 for `Vector3::subtract()` must be an int. (But the fact is `Vector3` is OK too)
2014-07-13 13:43:09 +08:00
fdb7fa36b8 Fixed #1641 2014-07-13 01:10:16 +02:00
e29ddadd2f Fixed #1642 2014-07-13 01:04:10 +02:00
d2ed0aa9f0 Merge pull request #1634 from PocketMine/timings
Implemented Timings
2014-07-12 19:30:41 +02:00
a7944502cd Added small things 2014-07-12 19:27:51 +02:00
063d14ba63 Merge pull request #1638 from KnownUnown/master
Fix formality mistake
2014-07-12 18:42:11 +02:00
35ea9708a5 Fix formality mistake
Contractions such as "I've" should not be used in formal writing.
2014-07-12 11:36:03 -05:00
9a4ead54e3 Added more timings 2014-07-12 15:23:06 +02:00
0d55d5c653 Fixed typo 2014-07-12 14:36:22 +02:00
94bc817756 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-07-12 14:18:12 +02:00
52b0e8b1ee Updated RakLib, fixes random upload increase 2014-07-12 14:17:35 +02:00
9bdd294a66 Implemented global, tasks timings 2014-07-12 14:09:29 +02:00
0bfa9506d1 Updated API version to 1.1.0 (backwards-compatible) 2014-07-12 02:26:41 +02:00
67b0c4bc2e Added base timings 2014-07-12 02:26:06 +02:00
dd729ced68 Revert "Possible fix for #1628"
This reverts commit a6e22de6a3.
2014-07-11 10:21:58 -05:00
a6e22de6a3 Possible fix for #1628 2014-07-11 10:19:28 -05:00
7624eda7b1 Update damage sources for creative mode players 2014-07-11 16:24:04 +02:00
5e47dda0a8 Enable death through void, suicide 2014-07-11 09:18:15 -05:00
61043d2e0d Fix #1615
Players in creative cannot die from non-magic (plugin/console) causes.
2014-07-11 09:14:49 -05:00
3e882ef40d Revert "Fix #1615"
This reverts commit a8359f29a8.
2014-07-11 09:12:19 -05:00
a8359f29a8 Fix #1615
Players in creative cannot die from non-magic (plugin/console) causes.
2014-07-11 09:07:24 -05:00
167ee97569 Fix kick command broadcast message. 2014-07-11 22:14:57 +09:30
53214005cd Kick message reflects Vanila MCPC not Bukkit 2014-07-11 22:05:50 +09:30
6e74bb7faf Kick reason grammar 2014-07-11 21:52:57 +09:30
f60fdb5e61 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-07-11 12:47:19 +02:00
4bd2f3aea8 Use the world spawn by default for players, fixes #1616 2014-07-11 12:45:43 +02:00
dcba580115 Merge pull request #1626 from PEMapModder/patch-2
Fix #1622 /kick on unknown players crashes the server
2014-07-11 12:16:44 +02:00
63008c4ebb Fix #1622 2014-07-11 17:24:25 +08:00
c16f45ce39 Fixed unsigned fields being read as signed 2014-07-11 02:55:29 +02:00
f2fa13119a Added upload/download speed on title bar, referenced ChunkRequestTask 2014-07-11 02:23:40 +02:00
756a8fead6 Fixed #1604 2014-07-11 01:34:49 +02:00
7ed6ac2341 Fixed #1609 2014-07-11 01:18:37 +02:00
4a072b4163 Better chunk unload queues 2014-07-11 01:15:52 +02:00
91b2f81f3c Updated RakLib version 2014-07-11 00:53:48 +02:00
5c826cb9ab Fixed /list not showing the proper player count 2014-07-10 20:40:56 +02:00
20b0df4b57 Added deprecation warning on plugin events 2014-07-10 17:39:20 +02:00
1fab6bd589 Added settings.query-plugins setting 2014-07-10 17:24:12 +02:00
7dd4a843c6 Fixed #1598 spawning on a index-corrupted Anvil chunk 2014-07-10 16:52:59 +02:00
828f7f1590 Fall damage is now working 2014-07-10 16:16:11 +02:00
c9535162bd Added more damage sources 2014-07-10 14:02:56 +02:00
99c5ad789b Improved entity attack push 2014-07-10 13:29:29 +02:00
e6c510e7fd Fixed #1595 Undefined variable on QueryHandler 2014-07-10 13:15:24 +02:00
d3789d4fed Fixed /kick player name 2014-07-10 13:05:15 +02:00
8fbc63c14e Fixed /kill player name 2014-07-10 13:05:04 +02:00
4d0b184ca4 Fixed #1591, handle player disconnect and level change killing 2014-07-10 12:35:19 +02:00
589fde27c0 Reorder chunk unloading to leave chunks in memory for the GC time before removal 2014-07-10 01:32:18 +02:00
6cb55da9c7 Added correct save parameters to chunk unloading 2014-07-10 01:30:59 +02:00
0251ae93d8 Fixed #1578 Chunk garbage collection not marking chunks as unused 2014-07-10 01:17:51 +02:00
5b69f07a55 Tuned CPU usage on main lop and RakLib 2014-07-09 23:39:25 +02:00
9604907566 Fixed #1584 duplicated death messages 2014-07-09 20:25:40 +02:00
1f882f42d3 Save and restore entity health 2014-07-09 20:23:58 +02:00
981796fd4c Fixed #1583 not repeated Tasks getting repeated 2014-07-09 20:07:35 +02:00
3e53ecdfb3 Merge pull request #1585 from PEMapModder/master
Let plugin enable/disable events extend PluginEvent
2014-07-09 19:28:13 +02:00
cd324c3247 Let plugin enable/disable events extend PluginEvent 2014-07-10 00:40:16 +08:00
99d4ff5bdb Merge remote-tracking branch 'origin/master' 2014-07-09 18:43:33 +09:30
88bcaea292 Fixes #1570. Removed isValidPharFilename check as the function is very unreliable. 2014-07-09 18:42:57 +09:30
ff90b83a9f Merge pull request #1581 from PEMapModder/patch-1
Update cause of lava and fire damage
2014-07-09 16:38:12 +09:30
f3079f8444 Update cause of lava and fire damage 2014-07-09 14:40:50 +08:00
65523972c2 Implemented health, events, damage, motion push 2014-07-06 23:10:11 +02:00
25ecdcf6e2 Fixed physics BoundingBox 2014-07-06 12:59:41 +02:00
6b361389ad Fixed mirrored chunk sending 2014-07-06 12:36:23 +02:00
643a4c1ef5 Fixed motion, physics 2014-07-06 12:08:05 +02:00
0503adc08c Fixed PHP installation reading wrong php.ini 2014-07-06 02:40:13 +02:00
892119f791 Updated RakLib version, Query works again 2014-07-06 01:19:09 +02:00
1b6fcf7942 Added LevelLoadEvent 2014-07-06 00:07:42 +02:00
cbbdb42092 Added LevelUnloadEvent 2014-07-06 00:06:03 +02:00
81492acb0c Added LevelSaveEvent 2014-07-06 00:02:27 +02:00
6576c88a08 Added LevelInitEvent 2014-07-06 00:01:05 +02:00
637d9da5a6 Fixed worker pool AsyncTask storage 2014-07-05 22:02:14 +02:00
22552cdd72 Improved chunk sending, moved chunk encoding and compression to another thread 2014-07-05 20:41:44 +02:00
417cb94ea3 Use chunk unload queues in Level 2014-07-05 16:28:49 +02:00
4db97a007c Fixed typo on updater 2014-07-05 14:05:56 +02:00
519922b550 Improved chunk ticking 2014-07-05 14:05:39 +02:00
962847ffdf Merge pull request #1561 from PEMapModder/patch-1
Fix HandlerList.php wrong var name
2014-07-05 12:04:13 +02:00
b18783a0e7 Fix HandlerList.php wrong var name 2014-07-05 11:48:13 +08:00
5a8e6619e9 Fixed start.sh script 2014-07-04 01:07:40 +02:00
6b45c16a38 Added quotes to start.sh 2014-07-03 20:02:35 +02:00
8b2440ff96 Fixed ServerScheduler::addTask() period 2014-07-03 19:35:59 +02:00
32f67d7187 Updated build script 2014-07-03 13:52:48 +02:00
43635b501a Made logging better, plugin loggers can be attached by others 2014-07-02 23:33:29 +02:00
aa85993634 Made Server::getLogger() return a AttachableThreadedLogger 2014-07-02 23:23:33 +02:00
2f4fe4751c Merge pull request #1555 from PocketMine/LoggerAttachment
Implement LoggerAttachment (fixes #1547)
2014-07-02 23:13:22 +02:00
c8dd8f02eb Finished #1555 todo list 2014-07-02 23:11:39 +02:00
6c116678d7 Added autoloading of base namespace classes 2014-07-01 23:34:24 +02:00
75d2409a7c Added ThreadedLoggerAttachments 2014-07-01 20:50:51 +02:00
f7c23e89f0 Added move block while being teleported after spawning 2014-07-01 01:19:24 +02:00
f5a74a87e3 Updated composed packets 2014-07-01 01:11:09 +02:00
d4881260da Added check for registered alias command, useful when overriding 2014-06-30 21:14:00 +02:00
6d6059b61f Updated for new build 2014-06-30 21:07:27 +02:00
75bf3023a7 Swapped link order 2014-06-30 17:36:26 +02:00
f62cbcbcfa Removed -Wl,-Bstatic on Android 2014-06-30 17:32:27 +02:00
e5d8993d67 Changed library link order for Android 2014-06-30 17:29:19 +02:00
7bcc6d10b8 Enable assembly on cross-compile 2014-06-30 16:33:43 +02:00
308430c28d Disabled assembly on GMP 2014-06-30 16:03:40 +02:00
692a4fb57b Fixed reason on kick message 2014-06-30 01:17:55 +02:00
3fd18ca4af Updated installer PHP version 2014-06-30 00:53:48 +02:00
ca3fc33708 Added LDFLAGS to Android 2014-06-29 20:55:34 +02:00
e4bc9611f6 Compile GMP and mcrypt statically 2014-06-29 20:43:49 +02:00
3184a8e7d5 Added DNS lresolv MacOS 2014-06-29 18:24:09 +02:00
ff91113b81 Added flock_type patch for MacOS 2014-06-29 18:02:21 +02:00
f02fc664ba Removed ./buildconf for mcrypt (fails on MacOS) 2014-06-29 17:42:28 +02:00
e504421515 Added realloc env. variables for ARM to compile script 2014-06-29 17:33:31 +02:00
b80bae3352 Added realloc patch for ARM to compile script 2014-06-29 17:30:01 +02:00
311961f3aa Export compat. variables for malloc in compile script 2014-06-29 17:24:45 +02:00
1aa45500c0 Fixed mcrypt and malloc 2014-06-29 17:17:34 +02:00
58df00fa86 Fixed mcrypt having older config files 2014-06-29 17:10:20 +02:00
67baaf5308 Fixed GMP ABI 2014-06-29 17:04:22 +02:00
f20c862123 Fixed syntax error in compile script 2014-06-29 17:00:01 +02:00
a321aeca96 Compile fixes 2014-06-29 16:53:16 +02:00
487015d332 Updated to PHP 5.5.14, updated OpenSSL, updated cURL, added mcrypt and GMP to compile scripts 2014-06-29 16:28:18 +02:00
b064f1e71a Removed collision check crash on Slab 2014-06-28 02:38:04 +02:00
2ec0d86126 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-06-27 23:26:46 +02:00
cc36f8f997 Fixed kick messages 2014-06-27 23:26:35 +02:00
44f8541331 Merge pull request #1544 from Darunia18/patch-1
Update Explosion.php
2014-06-27 13:44:13 +02:00
87308d1c51 Update Explosion.php
Fixed bugs on lines 75 and 141.
2014-06-27 02:45:32 -04:00
84f9516f24 Merge pull request #1542 from MCMrARM/master
Fixed PlayerMetadataStore
2014-06-26 21:15:03 +02:00
fadf1a5d40 Fixed PlayerMetadataStore 2014-06-26 21:12:03 +02:00
401d7342dd Added nether reactor block to classes 2014-06-26 12:09:38 +02:00
7067c09228 Removed old code 2014-06-26 12:03:29 +02:00
3abec0a3c0 Modified Level::useBreakOn() to use events for creative block breaking 2014-06-26 12:03:02 +02:00
c2d760e6d9 Added RotateHeadPacket 2014-06-25 23:09:22 +02:00
de5e9df82b Fixes for chat formatting 2014-06-25 22:32:57 +02:00
b506ab349f Fixed TextFormat::toJSON() on nested formatting 2014-06-25 22:20:50 +02:00
e2f7cf61e3 Added TextFormat::toJSON() 2014-06-25 21:57:34 +02:00
03b1385f26 Fixed teleport command with a single target not teleporting correctly 2014-06-25 20:58:59 +02:00
2302a37311 Updated for build 9 2014-06-25 20:50:22 +02:00
9877271d70 Fixed kick messages 2014-06-25 20:50:16 +02:00
873e35f416 Fixed SendUsageTask 2014-06-25 13:06:44 +02:00
80aebf2932 Added AsyncTask::onCompletion() 2014-06-25 13:01:39 +02:00
f9d9d2b0e5 Updated for build 8 2014-06-25 02:21:25 +02:00
c8ee1da262 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-06-25 02:06:05 +02:00
79cc6ca559 Multiple fixes 2014-06-25 02:03:58 +02:00
a299b5f904 Update Furnace.php 2014-06-24 17:41:37 +02:00
fd9fdc30cb Allow changing gamemode without restarting the game (buggy) 2014-06-24 12:38:01 +02:00
ecbfff9b0f Added force-gamemode property 2014-06-24 12:18:51 +02:00
0e679139d2 Merge pull request #1532 from PEMapModder/patch-1
Fixed undefined variable $name notice for /pardon
2014-06-24 11:49:22 +02:00
f30922f439 Fixed undefined variable $name notice for /pardon 2014-06-24 17:48:32 +08:00
c775c3905d Added ServerCommandEvent::getSender() 2014-06-24 11:25:51 +02:00
a4593d4668 Fixed #1531 2014-06-23 23:24:27 +02:00
df68853c76 Fixed #1530 Container tiles not getting imported right when they are empty 2014-06-23 22:40:14 +02:00
88157d6e99 Added workaround for #1527 2014-06-23 22:35:02 +02:00
22533458ed Updated for MCPE 0.9.0 build 7 2014-06-23 21:50:07 +02:00
38a958ed08 Fixed #1526 $player->getPosition() returns a WeakRef error 2014-06-23 16:31:22 +02:00
396a3ff225 Limited block change packets to players using that chunk 2014-06-23 16:09:51 +02:00
bcb401c0c3 Added yaw/pitch on spawn 2014-06-23 16:07:59 +02:00
4b3addb8a0 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-06-23 15:26:51 +02:00
7cfeeae413 Send held item when changed 2014-06-23 15:26:20 +02:00
31a7410acd Fixed players and entities getting despawned 2014-06-23 15:25:44 +02:00
6c8f189499 Merge pull request #1525 from PEMapModder/patch-1
Fix /plugins crash
2014-06-23 14:00:26 +02:00
2e50fbbda4 Fix /plugins crash 2014-06-23 19:27:27 +08:00
fd4fc4ff94 Fixed Entity & Player loaded chunk indexes 2014-06-23 11:57:47 +02:00
496c004efc Changed default view-distance 2014-06-22 23:25:43 +02:00
6f9becdbb3 Added Empty chunk detection 2014-06-22 22:29:46 +02:00
36cdfd969d Fixed #799 Added Grass growth algorithm 2014-06-22 22:26:36 +02:00
0be2bd911f Fixed block updates not getting broadcasted 2014-06-22 21:56:58 +02:00
0e36107878 Fixed update ticks 2014-06-22 21:32:49 +02:00
279a438ae6 Fixed spawning of Tile entities via chunk packets 2014-06-22 18:05:42 +02:00
0d5eb149ab Fixed Level not saving chunks on auto save 2014-06-22 16:20:00 +02:00
557618c87d Fixed Level not saving chunks on unload 2014-06-22 16:15:37 +02:00
e0dda934ec Fixed Anvil region indexes in setChunk() 2014-06-22 16:15:23 +02:00
21f764590b Changed chunk-sending.per-second to chunk-sending.per-tick 2014-06-22 15:46:42 +02:00
bf49cafeae Added settings.async-workers to tune the amount of AsyncTask workers 2014-06-22 12:55:08 +02:00
7f795bc041 Fixed #1501 executing AsyncTasks blocks other threads 2014-06-22 12:50:24 +02:00
e381313747 New player chunk load queues with ACK notification 2014-06-21 19:41:06 +02:00
be0a31697a Fixed Double Chest inventory holder 2014-06-21 19:16:33 +02:00
14c558163e Updated languages 2014-06-21 18:21:16 +02:00
57437d3a06 Updated for MCPE 0.9.0 build 6 2014-06-19 17:26:03 +02:00
a0ce4b1d01 Updated Sign crafting recipe to give x3 2014-06-19 17:25:34 +02:00
a0ac660d57 Throw exception when a plugin tries to change the cancel event of a non-Cancellable event 2014-06-18 19:36:32 +02:00
825656feed Fixed installer language strings, bumped MCPE build to 5 (already compatible) 2014-06-18 19:23:14 +02:00
89a90c00fd Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-06-18 18:29:24 +02:00
83081456f2 Merge pull request #1508 from LegendOfMCPE/master
Fixed Explosion.php WeakRef issue
2014-06-18 18:28:32 +02:00
20e419a9c4 Fixed Explosion.php WeakRef issue 2014-06-18 11:42:41 +08:00
dda57f7b0f Signs can be placed again. TODO: spawn tile entities after chunk has been received and ACKed 2014-06-17 19:48:14 +02:00
85007a9dfe Fixed NBT compression, Anvil generated worlds are readable by Minecraft and other tools 2014-06-17 19:32:09 +02:00
f073a5b837 Fixed a few things 2014-06-17 18:46:16 +02:00
9e8f015dc0 Changed commands to use CommandSender::getServer() 2014-06-17 18:41:10 +02:00
f14fecbb5f Added /time command 2014-06-17 18:36:39 +02:00
b27637c926 Fixed default kick message 2014-06-17 17:27:17 +02:00
552c934486 Merge pull request #1506 from PEMapModder/master
Multiple permissions checked in Server::getInstance()
2014-06-17 16:15:39 +02:00
f202c9902a Multiple permissions checked in Server::getInstance()
This is done like the one in `Command::testPermissionSilent()`, where permissions are connected via semicolons (`;`) and they are checked with `OR`, where the player must have at least one permission to read.
2014-06-17 22:14:15 +08:00
3bd33a129f Added Player::getRemoveFormat() and Player::setRemoveFormat(bool) to choose showing colors in chat and nametags 2014-06-17 15:54:06 +02:00
79bc42c995 Added Player::getNameTag() and Player::setNameTag($name) 2014-06-17 15:28:57 +02:00
032710a2de Added integrated command aliases 2014-06-17 15:21:06 +02:00
e8cc52f99e Added chunk-sending.compression-level property 2014-06-17 14:34:14 +02:00
266b78aa31 Fixed warning on TickScheduler thread 2014-06-16 23:20:21 +02:00
8a89aee75d Added method to get info from the AutoUpdater 2014-06-16 23:20:07 +02:00
169c55443a Fixed #1213 2014-06-16 23:00:54 +02:00
77e914238c Fixed updater 2014-06-16 20:17:32 +02:00
73b9b2491f Added custom settings, update notification 2014-06-16 19:34:47 +02:00
89c61bb05e Fixed #1500 blocks cannot be placed in creative mode 2014-06-16 17:01:34 +02:00
6983ddf509 Added new implemented blocks to Creative menu 2014-06-16 16:41:49 +02:00
8bc3ff5726 Added Emerald ore, Emerald, Emerald block 2014-06-16 16:24:09 +02:00
b4e502be13 Added Diorite, Granite, Andesite, and polished versions 2014-06-16 16:16:21 +02:00
778ec96d72 Added Hardened Clay and Stained Clay 2014-06-16 16:02:01 +02:00
28926832df Added new Wood slabs, stairs, crafing recipes 2014-06-16 15:46:45 +02:00
b3820bedbc Added Acacia wood and Dark Oak wood 2014-06-16 15:30:43 +02:00
6722540bdc Added Red sand 2014-06-16 15:25:30 +02:00
2d5e98b6a3 Added new Saplings 2014-06-16 15:23:40 +02:00
bbb69429f3 Fixed setting biome color 2014-06-16 03:32:55 +02:00
e47198deaf Fixed Level methods 2014-06-16 03:14:18 +02:00
36ddbc6cb4 Fixed setBiomeColor() bug 2014-06-16 01:20:53 +02:00
a371890962 Fixed Chest and Furnace placing, Furnace open 2014-06-16 00:30:51 +02:00
e1c0976927 Fixed block placing in creative mode 2014-06-16 00:19:46 +02:00
40bf7fd22a Fixed player being kicked on death 2014-06-16 00:01:09 +02:00
214de28808 Player join message will be only shown if not empty (modified by plugins) 2014-06-15 23:53:31 +02:00
530b81674b Updated RakLib, improved network stream 2014-06-15 23:39:05 +02:00
e6224be46f Faster generation, ticks catch up when slower 2014-06-15 16:54:28 +02:00
ed5325c069 Fixed setting chunks on non-loaded regions 2014-06-15 14:50:49 +02:00
a5e78d775b Temp. fixed /status 2014-06-15 00:23:17 +02:00
c4673addf7 Added server-side join message (removed from client-side MCPE) 2014-06-15 00:14:28 +02:00
cb1c4da4ea Fixed chunk unload on level change 2014-06-15 00:07:21 +02:00
6f36e9af24 Fixed chunk unloading on same level 2014-06-15 00:03:35 +02:00
6977833b1a Fixed thread generator crashing, added thread generator garbage collector, fixed generation queues 2014-06-14 23:59:31 +02:00
30318569e1 Fixed player spawnpoint not being restored 2014-06-14 22:15:07 +02:00
429f7ffe8d Fixed SimpleChunk metadata 2014-06-14 22:11:19 +02:00
4354d76cae Fully fixed metadata sending 2014-06-14 21:44:02 +02:00
f3e6c726b0 Added BlockMetadataStore to Level and Block 2014-06-14 20:06:42 +02:00
694ccf2bc5 Fixed /reload 2014-06-14 18:46:40 +02:00
392f0110bb Updated build number 2014-06-13 23:26:52 +02:00
b0775e3e0c Fixed EntityMoveEvent cancellation for Player 2014-06-13 21:59:10 +02:00
ab2fb24fe5 Fixed PluginEvent 2014-06-13 20:15:53 +02:00
cbaeec54ff Added biomeIds and biomeColors to Anvil format 2014-06-13 20:04:07 +02:00
20759dcf07 Fixed block data network sending (Anvil::getBlockDataColumn() 2014-06-13 19:10:12 +02:00
189accc0d6 Fixed furnace processing bug 2014-06-13 18:45:53 +02:00
4e075987ab Merge pull request #1487 from PocketMine/master
Fixed FurnaceInventory crash
2014-06-12 17:53:55 +02:00
303c947d2a Fixed FurnaceInventory crash 2014-06-12 17:43:46 +02:00
b6ef52e89c Updated Normal generator 2014-06-11 00:29:01 +02:00
109b6dbf44 Updated to v0.9.0 build 2, now using Anvil worlds 2014-06-11 00:06:46 +02:00
fa50cbf4b3 Working Threaded Generation 2014-06-10 20:45:09 +02:00
392eb74901 Merge branch 'Level-Rewrite' into 0.9.0 2014-06-10 16:08:34 +02:00
5f163133ee Added grass color test 2014-06-10 15:24:33 +02:00
9be231fbca Made levels infinite 2014-06-10 15:05:59 +02:00
b6caad289d Faster chunk loading 2014-06-10 11:27:30 +02:00
3fbc411e17 0.9.0 clients can join 2014-06-09 23:47:09 +02:00
fb46faa320 Updated protocol changes from MCPE-6865 2014-06-09 15:19:24 +02:00
c180534f21 Bump protocol version 2014-06-09 11:52:12 +02:00
926e7ac0b1 Disabled Travis CI 2014-06-09 11:49:52 +02:00
409efcbb03 Updated raklib 2014-06-09 11:43:20 +02:00
115b4cf4ac Updated Levels :D 2014-06-09 11:35:52 +02:00
920e2a7c7e Merge branch 'Level-Rewrite' 2014-06-07 23:33:49 +02:00
2566f2c4cb Worked on chunk loading 2014-06-07 22:29:45 +02:00
d8f9f9231f Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-06-07 04:22:07 +02:00
93b236811a Updated RakLib 2014-06-07 04:22:00 +02:00
e4c7564e3e Delete mainLogger.php 2014-06-07 04:20:03 +02:00
41fe4a527a Update MainLogger.php 2014-06-07 04:19:19 +02:00
1c20fcc8c7 Fix for log file 2014-06-06 02:23:14 +02:00
5355a95d1d Fix for player->CID 2014-06-06 02:22:53 +02:00
e37b731e88 Fixed player block breaking 2014-06-05 18:27:50 +02:00
370a1a0041 Fixed seed generation 2014-06-05 18:13:33 +02:00
310ebb9817 Fixed timeout 2014-06-05 18:04:00 +02:00
fdc2edc421 Updated to new RakLib 2014-06-05 17:52:42 +02:00
c434961dfc Some fixes 2014-06-05 01:44:16 +02:00
ddf3e149c9 Merge branch 'Core-Rewrite'
Conflicts:
	src/API/PlayerAPI.php
	src/build/compile.sh
	src/build/jenkins.sh
2014-06-05 01:39:43 +02:00
3c4e35ff8d Updated default PHP version 2014-06-05 01:23:24 +02:00
2674902eaa Preparing to merge 2014-06-05 01:22:04 +02:00
596f4ddb0e Added lots of new events, enabled old features 2014-06-05 01:05:52 +02:00
2b73da5412 Added Animation 2014-06-05 00:41:24 +02:00
9884fe6473 Updated RakLib 2014-06-05 00:31:36 +02:00
2877f026ec Added item drop 2014-06-05 00:31:16 +02:00
99a0117a33 Implemented RakLib 2014-06-04 20:29:25 +02:00
cce9499a61 Merge branch 'Core-Rewrite' of github.com:PocketMine/PocketMine-MP into Core-Rewrite 2014-06-04 17:09:53 +02:00
905d572d42 Added RakLib library 2014-06-04 17:08:09 +02:00
e4cdfdf6e9 Update Logger 2014-06-04 02:15:29 +02:00
ea9e0b917b Moved $EXTRA_FLAGS 2014-06-04 02:07:38 +02:00
a76f56d0a9 Update compile.sh 2014-06-04 02:04:18 +02:00
ee0ab63202 Updated PHP version 2014-06-04 02:02:15 +02:00
2f6f851715 Updated PHP version 2014-06-04 02:00:48 +02:00
97f3959e83 Check for class loaded on SplClassLoader 2014-06-03 19:24:34 +02:00
ff48b0be53 Fixed Loggers 2014-06-02 22:59:56 +02:00
24d95fb7fd Added \ThreadedLogger abstract class 2014-06-02 14:47:38 +02:00
a17d847a82 Moved Logger interface to root 2014-06-02 14:41:43 +02:00
857c79cc05 Update pointer to track master 2014-06-01 02:24:26 +02:00
35551246d2 Linked PocketMine-MP GUI submodule 2014-06-01 02:18:15 +02:00
5117bbf7f4 Fixed ContainerSetContentPacket being spammed before join 2014-05-30 01:26:57 +02:00
0925898d8d Temporal fix for extra commit spam due to bug 2014-05-30 00:31:35 +02:00
325bcc367d Fixed motion update spam 2014-05-29 23:07:48 +02:00
97a687c03a Replaced PHPDoc on Config 2014-05-29 20:19:15 +02:00
c6632da159 Removed debug code from player data saving 2014-05-29 18:48:38 +02:00
96445c4613 Fixed item in hand in creative mode, player files are now readable by Minecraft PC 2014-05-29 18:45:49 +02:00
a45f8782b1 Fixed collision against other entities 2014-05-29 18:03:17 +02:00
61ce7f11d6 Implemented bounding box limits for item placing 2014-05-29 17:04:37 +02:00
49370c21d1 Removed locks from MainLogger 2014-05-29 04:11:20 +02:00
441b47e744 Fixed Logger getting paths relative to soruce code 2014-05-29 04:04:00 +02:00
8d40f843cf MainLogger can now have debug level disabled 2014-05-29 00:08:02 +02:00
7bd6f2ed91 Added Logger interface, threaded MainLogger and updated PluginLogger 2014-05-28 23:46:56 +02:00
9df56295f6 Removed debug message for Transactions 2014-05-28 19:44:50 +02:00
dafa4f1b1c Fixed null Items with id < 256 not working correctly 2014-05-28 17:58:09 +02:00
f66560ccd4 Update ContainerInventory on Transaction refused 2014-05-28 17:11:06 +02:00
f795a3f565 Fixed DroppedItems not being restored after save 2014-05-28 16:09:57 +02:00
130b2c4910 Fixed Chests and Furnaces not droping their contents when broken 2014-05-28 15:34:34 +02:00
c778e0467e Fixed touching items with an empty hand 2014-05-28 15:22:25 +02:00
70e340086d Fixed Inventory::addItem() not adding items properly 2014-05-28 15:08:07 +02:00
b9ec63f016 Fixed getting Entities by area 2014-05-28 14:41:09 +02:00
9aed430fda Added Furnace recipes 2014-05-28 00:29:36 +02:00
d5f160ea3d Added Stonecutter recipes 2014-05-27 23:59:59 +02:00
3ac60f9860 Added Normal and Big crafting recipes, fixed CraftingTransactionGroup count 2014-05-27 23:26:07 +02:00
6746987ce5 Added CraftItemEvent, Crafting system now uses Transactions 2014-05-27 17:49:22 +02:00
3fc1be1262 Fixed crash when removing Tiles 2014-05-27 16:15:23 +02:00
96b1831229 Fixed Tile entities not being read correctly 2014-05-27 16:02:03 +02:00
a669797ccb Fixed breaking Spawnable tiles and cancelling it 2014-05-27 12:12:45 +02:00
5e97da2e11 Added InventoryTransactionEvent 2014-05-27 01:56:25 +02:00
d92c5332da Added InventoryOpenEvent and InventoryPickupItemEvent 2014-05-27 01:44:56 +02:00
e1ccd7f9ea Added InventoryCloseEvent 2014-05-27 01:30:24 +02:00
6fcd5322d0 Implemented Transactions 2014-05-27 01:20:18 +02:00
160c633c08 Updated trigger_error to Exceptions, fixed bug in Plugin task deletion 2014-05-26 12:22:28 +02:00
ffa3e8a0aa Fixes for Chest & Furnace 2014-05-26 10:46:30 +02:00
274f972b58 Items can be picked up 2014-05-25 21:57:58 +02:00
03d7127e33 Finally, physics 2014-05-25 18:14:01 +02:00
933a28537b Fixed giving large amount of items, updated player inventory to correct size 2014-05-25 16:26:46 +02:00
4f2856dc09 Added base physics 2014-05-25 12:31:00 +02:00
ec055fd8d1 Items spawn, Tiles spawn, both are saved, blocks drop 2014-05-24 17:25:37 +02:00
f2dc9cdff7 Removed _ split from SplClassLoader 2014-05-24 17:25:02 +02:00
d8ea2e744f Added methods to add/remove Entities/Tiles from Levels 2014-05-24 13:49:58 +02:00
f9353a0ecd Fixed Events being called with reversed priority 2014-05-24 13:40:05 +02:00
abff932d8f Moved Entity::get() to Level::getEntity() and removed Entity::getAll() 2014-05-24 13:30:37 +02:00
ef6ca9d2cd Added Tile::saveNBT(), moved Player::broadcastPacket() to Server 2014-05-24 13:21:55 +02:00
1fd7e0431b Added CustomInventory, StoneCutter inventory type, network IDs, fixed viewer list bugs 2014-05-24 01:30:58 +02:00
f9103772c3 It works. (Inventory, windows, block placement) 2014-05-24 00:32:29 +02:00
5460ccf41c Server can be joined, again! (fixed weak references and blocks) 2014-05-23 23:12:15 +02:00
a2b3a4bb90 Removed not valid TimeCommand 2014-05-23 22:46:08 +02:00
683ab8d2cd Fixed invalid metadata and updated weak references on PluginManager 2014-05-23 22:30:37 +02:00
53749483c3 Implemented new Inventory windows on Player, Chest and Furnace 2014-05-23 20:53:06 +02:00
27e82ea60a Updated Inventory classes 2014-05-22 23:13:46 +02:00
48af130269 Fixed things 2014-05-22 20:48:17 +02:00
98e9b5594c Fixed slots overfilling (like on Armor slots) 2014-05-22 20:32:56 +02:00
9b950a98c7 Added BaseInventory 2014-05-22 20:25:58 +02:00
34c2510f0f Allow setting null damage on items 2014-05-22 19:33:10 +02:00
6cbd39de9b Added Inventory interfaces and types, updated long array() to [] 2014-05-22 18:59:16 +02:00
0be679c9d5 Updated method names: getMetadata() & setMetadata() to getDamage() & setDamage() on Block and Item classes 2014-05-22 18:37:28 +02:00
387677e957 Level rewrite middle step 2014-05-22 17:53:56 +02:00
c1546aac9c Updated Position to use Weak / strong references for Level objects 2014-05-22 04:14:06 +02:00
6328834681 Make PluginBase::getResource() return a file pointer instead of the file contents 2014-05-19 20:14:31 +02:00
99818a26f5 Added object metadata for Plugins, use WeakMap on perms 2014-05-19 20:07:27 +02:00
88f9347093 Updated PHP to 5.5.12 (added to jenkins.sh) 2014-05-19 18:11:38 +02:00
1fc475860d Updated PHP to 5.5.12, uopz to 2.0.4 2014-05-19 18:10:33 +02:00
e45bcf06fe Updated pthreads to 2.0.7, fixed WeakRef 2014-05-19 18:04:42 +02:00
29caf1363f Merge branch 'Core-Rewrite' of github.com:PocketMine/PocketMine-MP into Core-Rewrite 2014-05-19 17:34:30 +02:00
c15f05622e Added WeakRef as default extension 2014-05-19 17:33:04 +02:00
b9502b9c2c Merge pull request #1453 from onebone/Core-Rewrite
Added time command
2014-05-18 15:59:17 +02:00
3e575ad505 Added time command 2014-05-18 22:56:01 +09:00
f668a41f57 Merge pull request #1440 from PEMapModder/cr-br-6
Fixed a typo at PermissibleBase
2014-05-17 21:38:36 +02:00
dcd4af9dd0 Merge pull request #1451 from wiezz/patch-1
Little fix for generateLevel()
2014-05-17 21:38:23 +02:00
d01a82cf9f Little fix for generateLevel()
Check if $generator is the default value NULL instead of false
2014-05-17 21:34:27 +02:00
92169f4288 Fixed a typo
(Is this really a typo? But it seems so...)
2014-05-12 19:23:37 +08:00
c455c84d15 Update installer.sh 2014-05-04 17:59:30 +02:00
15c5dacab3 Removed old PluginManager::getInstance() 2014-04-28 01:42:20 +02:00
1001a47cd6 Typo fix to crash dump 2014-04-27 15:17:52 +09:30
46464eb504 Update installer.sh 2014-04-20 19:16:51 +02:00
1fd773486e Reverted to 03d46020ec 2014-04-20 18:11:13 +02:00
50c0bf424a Revert 25b98a5480 2014-04-21 00:50:20 +09:30
9644088b5d Added username sharding for player yaml saves. 2014-04-21 00:43:39 +09:30
25b98a5480 Merge branch 'master' of https://github.com/PocketMine/PocketMine-MP 2014-04-21 00:13:43 +09:30
3729c5b603 Faster aligned read/write 2014-04-14 12:34:57 +02:00
59392ac4e9 Fix small spelling typo. 2014-04-12 19:06:55 +09:30
346d267e4e Merge pull request #1387 from PEMapModder/patch-1
pocketmine\command\Command implements the __toString() magic method
2014-04-12 18:59:18 +09:30
e9aba34e6b Added /setworldspawn 2014-04-10 18:50:41 +02:00
1dc3d42b78 Working Anvil region format parsing 2014-04-10 16:52:53 +02:00
f23a05d42e Anvil garbage collector won't run if not needed 2014-04-10 06:02:33 +02:00
a1a1f1b8e4 Added Anvil in-place garbage cleaner 2014-04-10 05:58:31 +02:00
aa1de79337 New Chunk objects / structure, Anvil region loader [WiP] 2014-04-10 05:05:36 +02:00
abccfeac37 Updated Vector-related classes 2014-04-10 05:04:58 +02:00
9859333aae Edited tests since now everything goes faster 2014-04-09 04:16:17 +02:00
5ca4f50703 removed C extension by default 2014-04-09 04:10:12 +02:00
96e36dbcb3 better Binary 2014-04-09 04:09:39 +02:00
8da3aced07 Lowered microtime() 2014-04-09 03:17:47 +02:00
ab84be7f6a Added microtime() operation to benchmark 2014-04-09 03:16:48 +02:00
88fb84edc5 Lowered file operations 2014-04-09 03:05:25 +02:00
5e8ea04e52 Fixed tests and one-byte packet reading 2014-04-09 03:00:33 +02:00
3136c23795 Added small benchmark 2014-04-09 02:37:37 +02:00
366fa0e05d fixed version 2014-04-09 01:48:35 +02:00
42b34d55e0 fixed... 2014-04-09 01:41:30 +02:00
5070866fe0 Updated extension to 0.0.3 2014-04-09 01:12:56 +02:00
db15ae49a1 Updated to extension 0.0.2 2014-04-09 00:56:36 +02:00
71737c3e53 Added PocketMine native extension version 0.0.1 2014-04-08 22:08:35 +02:00
9fcbe2698a Modified compile flags 2014-04-08 17:42:54 +02:00
da5853083c crc fake random generator 2014-04-08 16:35:45 +02:00
1d40399b9c hacky things D: 2014-04-08 16:22:52 +02:00
d6f4e77b6c Another patch, added INT32_MASK 2014-04-08 16:05:27 +02:00
cb32a95e60 Why, PHP? 2014-04-08 15:52:34 +02:00
731fbbc8d1 Another 64-bit patch 2014-04-08 15:50:13 +02:00
29ab53a46f Patched... again 2014-04-08 15:46:32 +02:00
4c973ce625 Patched random generator on 64-bit 2014-04-08 15:43:13 +02:00
9d8e6d5f8c New Random generator 2014-04-08 15:41:32 +02:00
5abe5bd43d replaced binary with hexadecimal 2014-04-08 13:02:13 +02:00
89138ae4ce Added a few things 2014-04-08 13:00:52 +02:00
8d14c98da9 Fixed binary reading/writing of longs 2014-04-08 13:00:50 +02:00
669401afd4 Updated PHP extension version 2014-04-08 11:55:36 +02:00
8dbdffa517 Update compile.sh 2014-04-08 02:28:12 +02:00
efeaadf0ba Added PHP C extension version 2014-04-08 02:23:43 +02:00
999990756c Fixed invalid string type in writeMetadata() 2014-04-07 16:24:58 +02:00
c0de004472 Moved binary methods from Utils to Binary 2014-04-07 13:52:01 +02:00
62313d4a84 Update Command.php 2014-04-07 16:38:37 +08:00
ac02185ad0 Fixed start.sh on linux :P 2014-04-07 04:10:26 +02:00
d83b5c3a60 Oops 2014-04-07 03:25:31 +02:00
e405c2bf1c Merge branch 'Core-Rewrite' of github.com:PocketMine/PocketMine-MP into Core-Rewrite 2014-04-07 03:22:07 +02:00
039151c136 Fixed compile.sh :P 2014-04-07 03:21:58 +02:00
40b290739e Fixed compile.sh perms 2014-04-06 21:18:39 -04:00
93c82d5267 Added PocketMine C PHP extension 2014-04-07 03:14:55 +02:00
0000000bab Testing things ;) 2014-04-06 20:07:11 +02:00
4098252ec7 Use CommandExecutor by default on plugins :P 2014-04-05 21:44:29 +02:00
711519d4ff Fixed uopz on installer 2014-04-05 18:50:31 +02:00
0b9896ff5e Updated to PHP 5.5.11 on the installer 2014-04-05 18:43:42 +02:00
41c4c15549 Updated compiler to PHP 5.5.11 2014-04-05 16:33:41 +02:00
1a8cbdd6c7 Fixed players being able to add color codes in names and be shown on console (on kick) 2014-04-05 14:02:35 +02:00
7be9ea68c7 Added Config::getPath() and Config::setPath() 2014-04-05 10:36:18 +02:00
e390374c74 Updated README.md 2014-04-05 00:58:20 +02:00
6d58f32c91 Added PluginLogger 2014-04-05 00:20:09 +02:00
0d91be62cf Improved plugin loading 2014-04-04 22:11:31 +02:00
adcbc67a71 Updated installer to use new Raspberry Pi PHP builds 2014-04-04 15:59:18 +02:00
ddf59b8bee Fixed MySQLnd cross-compilation 2014-04-04 15:50:13 +02:00
5c8747cb87 Set -j on Linux builds to 2 2014-04-04 15:41:46 +02:00
5065fce415 Moved -ftree-parallelize-loops to x86 and x86_64 optimizations 2014-04-04 15:06:09 +02:00
e63f8b93a7 Updated cURL 2014-04-04 03:56:02 +02:00
848b4bc113 Disabled temporaly uopz on compile script 2014-04-04 03:09:24 +02:00
648b23d08f Get correct Phar path if not specified 2014-04-04 02:53:41 +02:00
0f0b866788 Hmm, typo 2014-04-04 02:01:42 +02:00
c6f189f93f Added ability to disallow auto-kick of logged in players without using external properties, and using the event system 2014-04-04 01:59:58 +02:00
076bf2f2fe Added /spawnpoint message 2014-04-04 01:54:38 +02:00
fb6cd22c83 Fixed /tp 2014-04-04 01:52:56 +02:00
327d183bed Disallow duplicate usernames and block new player 2014-04-03 18:14:36 -05:00
7a163f9ea5 Added option to not kick players on duplicate names 2014-04-03 18:06:10 -05:00
0a7d9f1c87 Enabled use of /tp <source> <target> 2014-04-03 18:04:26 -05:00
08c9321a55 Fix error on tapping block with air in hand 2014-04-03 16:40:16 -05:00
cbf1f7a2e8 Fix /spawnpoint from console with no coordinate crash 2014-04-03 16:37:00 -05:00
85f7cdb123 Temporarily fix placing blocks near water crash 2014-04-03 16:34:02 -05:00
d3a912b2ef Added jenkins branch 2014-04-03 22:28:28 +02:00
5173781725 Modified jenkins script 2014-04-03 20:36:15 +02:00
ab1fbae2f2 Added dependency search on loaded plugins 2014-04-03 20:06:18 +02:00
febc6af323 Added uopz doc stub 2014-04-03 17:23:49 +02:00
d972d38b41 Added uopz extension (for monkey patching) 2014-04-03 16:25:42 +02:00
80f9093875 Added /reload command (does not reload source code) 2014-04-03 15:49:00 +02:00
ee6dc989ce Added class not found exception to SplClassLoader 2014-04-03 14:01:44 +02:00
5da68059ee Added file_exists check to SplClassLoader 2014-04-03 13:59:26 +02:00
5052e58bd0 Added /status memory 2014-04-03 13:22:04 +02:00
2ad9e1fe29 Added /status title 2014-04-03 13:19:34 +02:00
908210969e Added permissions for /status 2014-04-03 13:17:10 +02:00
0865381881 Moved /status into debug.commands 2014-04-03 13:16:15 +02:00
b50d58e46f Merge branch 'Core-Rewrite' of github.com:PocketMine/PocketMine-MP into Core-Rewrite 2014-04-03 13:12:30 +02:00
4841e105d3 Added debug.level 2014-04-03 13:12:15 +02:00
6c938944e6 Merge pull request #1376 from williamtdr/Core-Rewrite
Re-enable support for debug information with /status
2014-04-03 13:11:13 +02:00
04917ecd5a Added correct PluginIdentifiableCommand 2014-04-03 13:08:11 +02:00
3d80362560 Re-enable support for SIGTERM for clean exit 2014-04-02 21:24:49 -05:00
48f2927e08 Re-enable support for debug information with /status 2014-04-02 21:14:22 -05:00
27fcf0286e Fixed terminal colors 2014-04-03 04:10:20 +02:00
2ab1997f21 v1.5.0 added /extractplugin 2014-04-03 03:38:16 +02:00
61192b172b Removed FolderPluginLoader, allow loading of plugins by other loaders 2014-04-03 02:34:57 +02:00
f71f10da0b Added entry on .gitignore for Netbeans 2014-04-03 01:14:59 +02:00
a2536ed308 Fixed Server::isLevelgenerated() 2014-04-03 00:35:38 +02:00
83eb032393 Fixed plugin resources 2014-04-02 23:48:00 +02:00
36027f1073 Removed TimeAPI 2014-04-02 20:29:38 +02:00
95628227b0 Removed ServerOld, ServerAPI 2014-04-02 20:27:34 +02:00
0f42cd9243 Added Asynchronous tasks, usage sending 2014-04-02 20:20:14 +02:00
11356b68ba Added RCON 2014-04-02 19:33:49 +02:00
379b70eca7 Removed PlayerAPI 2014-04-02 19:07:29 +02:00
c81266d1da Added /tp 2014-04-02 19:04:07 +02:00
8c4afcd21a Added /spawnpoint 2014-04-02 18:40:24 +02:00
5cadc665d1 Added /kill, base entity health methods 2014-04-02 18:27:49 +02:00
bec642310a Removed BlockAPI 2014-04-02 06:07:21 +02:00
df3e456162 Added /give, /gamemode 2014-04-02 05:59:26 +02:00
7cd29f0fcf Added block updates, correct block placing 2014-04-02 05:36:45 +02:00
a4630372fa Added /save-on, /save-off, /save-all 2014-04-02 04:37:58 +02:00
9a5ffbe56c Added Tool for Items, new items 2014-04-02 04:26:53 +02:00
ee23b42e23 Added Spawn protection, including item usage, added /whitelist 2014-04-02 03:37:51 +02:00
502c27273d Moved Level methods to Server 2014-04-02 02:58:20 +02:00
5865f17c75 Faster plugin filter loading 2014-04-01 21:57:32 +02:00
7e9304a0c9 Formatting 2014-04-01 19:48:28 +02:00
b4cc3bbd43 Added /op, /deop, /kick, OfflinePlayer, moved player list to Server instead of static Player 2014-04-01 19:46:48 +02:00
e60ea2eb15 Fixed event names 2014-04-01 13:13:43 +02:00
a38d300616 Updated PluginBase::getResources() for Phar plugins 2014-04-01 12:18:27 +02:00
e3ee317924 Fixed detection 2014-04-01 12:09:18 +02:00
=
c688039047 Removed ghost dirs 2014-04-01 05:13:36 +02:00
dd17652aca Fixed wrong paths 2014-04-01 05:06:12 +02:00
05a42712bf Added non-packaged plugins & pocketmine warnings 2014-04-01 04:59:44 +02:00
207c2c4aba Fixed namespaces paths 2014-04-01 04:47:04 +02:00
3605bc36c5 Fixed PluginManager::parseYamlCommands() 2014-04-01 02:12:05 +02:00
9cae532d7e Remove compile script DEBUG trap on php.ini generation 2014-04-01 01:47:28 +02:00
e8477fec53 Added /difficulty, removed old API files 2014-04-01 01:37:43 +02:00
760695e4bc Added Phar plugins 2014-03-31 23:49:43 +02:00
e8c4507ac6 Re-added kill 2014-03-31 22:51:00 +02:00
c167defa72 Fixed plugin dataFolder 2014-03-31 22:35:42 +02:00
5dafe8e7f0 Fixed lots of errors, added auto-save 2014-03-31 20:42:58 +02:00
8571796611 Load correct plugin permissions 2014-03-31 18:24:59 +02:00
b03ef8b61c More flexible match on plugin registration 2014-03-31 17:29:47 +02:00
0422540114 New automatic event listener plugin declaration 2014-03-31 17:01:56 +02:00
00d777a68d Fixed commands, NBT Player saving 2014-03-31 15:42:08 +02:00
2f03251795 Added /list, Player::canSee(), Player::showPlayer(), Player::hidePlayer(), removed RealHuman 2014-03-31 15:18:50 +02:00
f9a7385b47 Added /me and /say, fixed a bunch of things, chat working 2014-03-31 06:51:34 +02:00
22b5255421 Formatting 2014-03-31 05:53:51 +02:00
befe1c606f Added /ban, /ban-ip, /pardon, /pardon-ip 2014-03-31 05:51:42 +02:00
1ff381ebf4 Things are working ヽ༼ຈل͜ຈ༽ノ 2014-03-31 05:04:36 +02:00
2b8df410d1 Player is instanceof CommandSender 2014-03-31 02:53:37 +02:00
5bb909adf1 Fixed case 2014-03-30 23:51:41 +02:00
f789e6e6e3 Lots of new things added 2014-03-30 18:04:56 +02:00
ccec74076b Fixed PluginBase::getServer() 2014-03-30 14:35:58 +02:00
03d46020ec Update compile.sh 2014-03-29 06:11:24 +01:00
19efa5e8d9 I need a Mac 2014-03-29 05:16:17 +01:00
08c6265762 Added libcurl MacOS install_name_tool dynamic path patch 2014-03-29 05:08:14 +01:00
4098e5e3b8 Fixed invalid MacOS arch for 64-bit 2014-03-29 05:03:20 +01:00
829069b0c8 Removed WeakRef 2014-03-29 04:40:10 +01:00
de6e8f6fe1 Removed WeakRef 2014-03-29 04:39:45 +01:00
7599fb436d Fixed #1365 2014-03-29 04:35:12 +01:00
66cea2f8ea Update compile.sh 2014-03-29 04:14:29 +01:00
9cab86540b Update compile.sh 2014-03-29 04:10:52 +01:00
d9ce4f119f Update compile.sh 2014-03-29 04:05:10 +01:00
35511aa30e Update compile.sh 2014-03-29 04:01:50 +01:00
5ce7b57cac Update compile.sh 2014-03-29 03:54:28 +01:00
fc053d9d75 Update jenkins.sh 2014-03-29 03:30:16 +01:00
cb1b8c6c68 Update compile.sh 2014-03-29 03:30:02 +01:00
e03c8ed32e Updated compiler 2014-03-29 03:27:29 +01:00
0d30dca5aa Updated pthreads to 2.0.4 2014-03-28 23:50:09 +01:00
7e03109576 Moved default level registration 2014-03-28 13:07:36 +01:00
38809f7da2 Reformatting, removing unused imports 2014-03-28 12:57:08 +01:00
fd8e5b27e5 Added new global autoloader 2014-03-28 05:04:34 +01:00
b59926bece Added Recursive class loading in FolderPluginLoader 2014-03-28 04:25:17 +01:00
a7269c7900 Added /tell 2014-03-28 03:40:12 +01:00
2f20d95e5d Added new Event system 2014-03-28 02:13:03 +01:00
9e8cf2d42c Update CONTRIBUTING.md 2014-03-27 22:32:00 +01:00
926afa3903 New Task scheduler 2014-03-27 22:16:09 +01:00
9a2934b85b More unloading 2014-03-27 19:40:05 +01:00
1c341337a3 Set default console color at start 2014-03-27 18:58:36 +01:00
f60b526c9e Changed default log path 2014-03-27 18:53:20 +01:00
3bc3db0740 Added /stop, plugin disable / unload, remaining TaskCanceller classes 2014-03-27 18:49:43 +01:00
2385b94ba3 Added PluginBase::getCommand() 2014-03-27 14:56:02 +01:00
605231251a Fire plugin onLoad() 2014-03-27 14:35:44 +01:00
1c7be84703 Added CommandExecutor interface to PluginBase 2014-03-27 05:25:47 +01:00
530d705d39 Fully loadable plugins 2014-03-27 04:59:18 +01:00
120efad01f Colors fix D: 2014-03-26 20:23:04 +01:00
9fe68003eb Added Help command 2014-03-26 20:11:53 +01:00
76438e78d2 Changed Command inheritance 2014-03-26 18:10:49 +01:00
2112de42ad removed travis on Core-Rewrite 2014-03-26 16:50:36 +01:00
92a0ddb4fe Threaded networking :D 2014-03-26 16:48:27 +01:00
7ea9e4c862 It runs :O (Added more Permissions, executors and such things) 2014-03-26 04:14:53 +01:00
b1b8c89227 Removed SQLite3 from Recipe, converted to a lookup table 2014-03-25 18:53:39 +01:00
b6e0905c3e Implemented scheduler classes 2014-03-25 13:19:15 +01:00
af80c056c7 Added pthreads / yaml documentation stubs 2014-03-25 01:13:35 +01:00
5b90c4a716 safe_var_dump() now supports any amount of parameters 2014-03-23 21:56:50 +01:00
1429a74beb Player event 2014-03-23 15:14:11 +01:00
ee265d44bd Added more new Events 2014-03-23 13:41:45 +01:00
fd0fcecb46 Oops, seems like Utils::readInt() is reading an unsigned long because of PHP silliness 2014-03-23 01:55:26 +01:00
d18952a06e Removed not necessary code from Utils::readInt() and Utils::readLInt() 2014-03-23 01:50:15 +01:00
86f9d3e233 Merge branch 'master' of https://github.com/PocketMine/PocketMine-MP 2014-03-23 10:37:44 +10:30
f03ab9a587 Removed Deprecation 2014-03-23 00:43:45 +01:00
80cfa7cc84 Formatting code 2014-03-23 00:32:05 +01:00
af14c87572 Added new Plugin and Permissions stuff :D 2014-03-23 00:22:14 +01:00
28c5443b0d Changed player achievement method names 2014-03-23 00:21:51 +01:00
08c6c1c1ac Updated compile scripts 2014-03-23 00:19:54 +01:00
cb2b08b248 Fixed Level generators 2014-03-23 00:19:11 +01:00
63f1f7581f Renamed Stackable to Threaded 2014-03-18 01:00:35 +01:00
d53656b2a8 pthreads 2.0.2 \(^.^)/ 2014-03-18 00:50:03 +01:00
28e17fe808 Added PHP WeakRef 2014-03-15 13:19:48 +01:00
c266cb991c Fix /list adding a trailing comma. 2014-03-14 16:45:54 -05:00
6f0f86dc0c More docs 2014-03-14 03:11:23 +01:00
3ff8ddc652 Fixed a few errors in new Events 2014-03-14 02:02:31 +01:00
68abafef7a Added multiple Player events using the new system 2014-03-14 01:51:10 +01:00
279472b01a Added generic block relative place/break on Level 2014-03-13 23:04:49 +01:00
91c4cbfedb Moved Player::buffer 2014-03-13 10:51:38 +01:00
b24120a863 Updated all undefined constants/classes, place resent packets to the recovery queue for NACK 2014-03-13 10:48:33 +01:00
3c3b346fd3 Use NBT Compounds instead of a NBT codec in PMF level data 2014-03-12 22:54:32 +01:00
63542a2f13 Updated NBT library to remove read overhead 2014-03-12 22:40:19 +01:00
cc5a30a0c2 Fixed ANSI color codes on Windows 2014-03-12 14:07:14 +01:00
8f990472c6 Fixed PHP 5.4 issues 2014-03-12 14:03:42 +01:00
18117b91ed Fixed issues with CPU loop 2014-03-12 03:25:50 +01:00
e033af0e72 Added -s (static) flag to compiler 2014-03-12 02:41:49 +01:00
69c829c302 Use pthreads 1.0.1 2014-03-11 21:58:40 +01:00
a84f756fd5 Optimize Imports 2014-03-11 20:47:31 +01:00
b3a2d3164f Finally, I can spawn AGAIN! 2014-03-11 20:45:53 +01:00
b28bc3ae9b Merge branch 'master' of https://github.com/PocketMine/PocketMine-MP 2014-03-09 20:01:02 +10:30
b4df7c9456 Moved compile scripts 2014-03-08 18:16:55 +01:00
e0705c80e2 Fixed getopts on compile.sh 2014-03-08 18:14:43 +01:00
5d2884716d Update jenkins.sh 2014-03-08 13:53:27 +01:00
45ee209c58 Update jenkins.sh 2014-03-08 06:21:22 +01:00
564a504ef7 Update compile.sh 2014-03-08 05:49:27 +01:00
ba21d7f661 Update compile.sh 2014-03-08 05:35:31 +01:00
19d98869fd Modified compile.sh 2014-03-08 05:33:11 +01:00
099716920b Updated permissions 2014-03-08 04:43:15 +01:00
cbc64462e6 New directory structure. More powerful startup scripts 2014-03-08 04:41:43 +01:00
8d75bff34b Merge branch 'master' into Core-Rewrite
Conflicts:
	src/level/LevelImport.php
	src/pmf/LevelFormat.php
2014-03-08 03:34:53 +01:00
ababc879b5 Removed warning message about not-bundled PHP 2014-03-08 03:28:00 +01:00
a817234aa8 Do not generate Phar utilities by default, only generate extension 2014-03-07 23:29:28 +01:00
e246e10a82 Added NEON optimizations to iOS 2014-03-07 20:04:18 +01:00
5ad511cd11 Disabled phar cmdtools generation on crosscompile 2014-03-07 19:12:06 +01:00
47ad8b6fac Added PHP_VAR_NAME to crosscompile 2014-03-07 18:26:12 +01:00
a74f5809c7 Added -lresolv 2014-03-07 17:38:36 +01:00
8c02555a8d Added sed -i ".backup" 2014-03-07 17:02:05 +01:00
612cf98a08 typo fix 2014-03-07 16:42:18 +01:00
971e18d9b0 Added php.ini Phar directives 2014-03-07 16:33:29 +01:00
4a2dea4e45 Added correct toolchain for iOS 2014-03-07 16:25:40 +01:00
2916b0f049 Added Phar extension to PHP 2014-03-07 16:22:16 +01:00
bfe746235f Removed iOS -arch 2014-03-07 16:20:17 +01:00
604f068112 Added iOS flags 2014-03-07 15:41:08 +01:00
c7854a3417 Added arm flags 2014-03-07 15:33:32 +01:00
8bfd22c9ac Added arch-specific compile optimizations 2014-03-07 13:34:31 +01:00
052f641715 Fixed levels not being read properly 2014-03-07 06:29:35 +01:00
ee51f75c78 Fixed issues with zlib 2014-03-07 05:15:01 +01:00
73b78e1455 Updated helper scripts PHP version to 5.5.10 2014-03-07 04:49:26 +01:00
7ad7398f2b Updated PHP version to 5.5.10 2014-03-07 04:47:15 +01:00
e81f4430cb Fixed mac 32-bit compilation 2014-03-07 04:29:47 +01:00
c12c6f1f18 Added remaining env. vars to compile.sh 2014-03-07 04:24:41 +01:00
a375a17d17 New compile script 2014-03-07 04:21:21 +01:00
801e924783 Comments 2014-03-06 23:38:46 +01:00
993620341a Added Villager class and NPC interface 2014-03-06 23:33:35 +01:00
59246dd5ec Added API Docs link 2014-03-06 22:03:30 +01:00
f7c7eac05a Updated README.md 2014-03-06 21:48:06 +01:00
331a26931f It staaaarts! 2014-03-06 20:41:04 +01:00
56d3b89f57 Updated class constants 2014-03-06 19:31:41 +01:00
80356d8794 fixed syntax error 2014-03-06 19:29:33 +01:00
028adce245 Used namespacer to identify moved files 2014-03-06 19:28:20 +01:00
a54d33957e Added multiple comments and info 2014-03-06 18:52:23 +01:00
5c00b415a5 typos 2014-03-06 17:24:26 +01:00
18443c0cd7 Reformatted code 2014-03-06 17:17:45 +01:00
6a736aa822 Used namespacer on Blocks and Items 2014-03-06 17:16:05 +01:00
d490972a42 fix typo 2014-03-06 17:14:54 +01:00
6f74ef80f9 Added Block and Item namespaces 2014-03-06 17:14:15 +01:00
2e0d9153b3 used namespacer 2014-03-06 15:15:50 +01:00
64a9650765 fixed typo 2014-03-06 15:12:52 +01:00
419f246e68 Added Item namespace 2014-03-06 15:11:46 +01:00
e3f1db0f45 Added Network\Handler namespace 2014-03-06 13:19:00 +01:00
c08bf3ef86 Removed code remove comments 2014-03-06 13:16:44 +01:00
bbd66e6ad1 Removed code remove comments 2014-03-06 13:05:54 +01:00
a14deae634 Removed code remove comments 2014-03-06 12:58:54 +01:00
42ae544d0d Used namespacer tool 2014-03-06 05:47:00 +01:00
c9c6d5a5f4 Added Ores to objects 2014-03-06 05:43:40 +01:00
eeb8244f26 Fixed Normal generator name 2014-03-06 05:35:17 +01:00
e0267799fb Fixed class namespaces 2014-03-06 05:33:04 +01:00
da4bc302c4 Fixed Utils endianness 2014-03-06 04:10:07 +01:00
5109566c9f Updated .gitignore 2014-03-06 03:53:59 +01:00
5de9fa77d7 Moved objects 2014-03-06 03:16:03 +01:00
ee53e21159 small fixes 2014-03-06 03:03:42 +01:00
dd2d229f74 renamed PocketMine\PMF\Level to PocketMine\PMF\LevelFormat 2014-03-06 02:45:09 +01:00
e3c0ea6be5 fixed typo 2014-03-06 02:40:19 +01:00
5b02666828 fixed typo 2014-03-06 02:38:57 +01:00
bc0c185cb5 fixed typo 2014-03-06 02:36:30 +01:00
928519f226 fixed typo 2014-03-06 02:30:16 +01:00
edf0d44416 fixed typo 2014-03-06 02:27:28 +01:00
3465a5f7e8 fixed typo 2014-03-06 02:26:17 +01:00
024e219292 fixed typo 2014-03-06 02:22:52 +01:00
42b5af23db Moved files 2014-03-06 01:18:55 +01:00
5ea31b57ce First step to namespaces 2014-03-05 23:43:16 +01:00
23b8fc32ff removed DocBlock header for logo 2014-03-05 11:15:47 +01:00
5f53f61121 Faster NBT parsing 2014-03-05 10:37:14 +01:00
98c0dfef43 Removed entity.motion from Player 2014-03-05 10:17:22 +01:00
d69fe5d5e7 New events, item methods 2014-03-05 10:16:08 +01:00
2bdc8c400e EventHandler code cleanup 2014-03-05 03:42:22 +01:00
ccdf587135 go away E_NOTICEs 2014-03-05 02:53:20 +01:00
b00da18f41 faster packet decode using pure-PHP functions instead of core-PHP ones :P. WTF PHP 2014-03-05 02:49:40 +01:00
9c38ead76d fixed time not being sent correctly on creative mode the first time 2014-03-05 01:25:53 +01:00
274f8a6113 Block placement fixes 2014-03-05 01:19:05 +01:00
a529e7566a Removed not needed network steps, corrected slot methods 2014-03-05 00:54:12 +01:00
bf412b1c20 Do not sleep on main Thread when actions are being done 2014-03-04 20:37:15 +01:00
980ee223d0 Save correct NBT Compound tag on Level chunk save 2014-03-04 19:52:52 +01:00
5241d8ff13 Fixed derp x3 2014-03-04 19:49:39 +01:00
c6c0b75eae Fixed derp x2 2014-03-04 19:46:47 +01:00
547ca74feb Fixed derp 2014-03-04 19:46:06 +01:00
4697d9d4ed Added player NBT save format, auto-upgrade 2014-03-04 19:41:56 +01:00
4449af2213 Implemented InventorySourceEntity into HumanEntity 2014-03-04 19:40:30 +01:00
f6589db064 Send Entity motion, update on schedule 2014-03-03 00:27:44 +01:00
c904e8bc0e Remove ANSI characters on clean 2014-03-03 00:26:33 +01:00
12ddf530b1 Added AxisAlignedBB::getMixedBoundingBox() (?) 2014-03-02 23:32:48 +01:00
df20467f3b Added Player block place/break (to be rewritten soon) 2014-03-02 17:56:54 +01:00
9cc9de8dae New Random block update tick 2014-03-02 17:56:24 +01:00
f6daaf76c8 Update CONTRIBUTING.md 2014-03-02 02:05:40 +01:00
ca308f8159 Merge branch 'master' into Core-Rewrite
Conflicts:
	src/pmf/PMFLevel.php
2014-03-01 22:12:22 +01:00
11f5691104 Fixed Pocket format importing 2014-03-01 22:08:28 +01:00
c8deefdb12 derp 2014-03-01 21:55:10 +01:00
75b34b6c2a Merged master into Core-Rewrite 2014-03-01 21:48:09 +01:00
5bf440d820 Fixed level upgrade and direct save on load 2014-03-01 21:45:07 +01:00
4d9e781f27 Tuned PMFLevel version upgrade 2014-03-01 21:43:55 +01:00
2a23eadbb6 Fixed things 2014-03-01 21:42:40 +01:00
573fe0e5cc Save player position, removed several methods from PluginAPI 2014-03-01 20:32:49 +01:00
f8d91b5888 Rolling chunk load 2014-03-01 19:13:08 +01:00
fdbefa0571 Added index to Level::getUsingChunk() 2014-03-01 19:04:18 +01:00
c2ad811451 Added chunk move spawning logic 2014-03-01 19:01:24 +01:00
dad2f21888 Players are fully spawnable and can see each other! 2014-03-01 18:23:38 +01:00
9d02ed9a28 New chunk indexing and sending algorithm 2014-03-01 17:35:44 +01:00
8403a34eb3 Removed entities, tiles, players SQLite3 tables 2014-03-01 14:07:27 +01:00
648b02bc79 Added Entity level switch, global Player static container 2014-03-01 14:05:45 +01:00
914098310c Guess NBTTag_List components type automatically 2014-03-01 11:26:19 +01:00
734b066131 removed debug messages 2014-02-28 22:03:09 +01:00
5651fc1cb1 Fixed level block and chunk sending 2014-02-28 20:39:59 +01:00
f08bedf2fe Added Biome methods to Level 2014-02-28 20:04:41 +01:00
6ac5647e2c Fixed load order 2014-02-28 20:04:31 +01:00
c488c19db9 I can spawn!! 2014-02-28 19:47:08 +01:00
f1d6726615 Added TextFormat::toHTML() 2014-02-28 16:08:33 +01:00
573c3ea377 Added /msg alias to /tell :P 2014-02-28 16:08:19 +01:00
16eb45925a Remove non-implemented chat colors from player messages 2014-02-28 00:12:57 +01:00
6d5e2648cf extra changes 2014-02-28 00:00:04 +01:00
2bf3f0de73 Removed EntityAPI 2014-02-27 16:47:49 +01:00
e314f46b5b Added biome saving to PMFLevel version 2 2014-02-27 15:34:00 +01:00
dc8cc2ab9f fixed empty world generation 2014-02-27 15:17:45 +01:00
6bd91cf39e fixes, new Tile update algorithm 2014-02-27 15:12:05 +01:00
c9dfdc288d Updated global Tile code 2014-02-27 12:23:22 +01:00
44b9d33b65 removed debug code 2014-02-27 00:24:43 +01:00
9acc867a94 fix 2014-02-27 00:14:05 +01:00
103d0bf2ea Updated TextFormat constants 2014-02-27 00:11:06 +01:00
4a2852bb90 Reworked Level things to handle new NBT structure 2014-02-27 00:03:53 +01:00
398fbbfb31 Added array things to NBT 2014-02-27 00:03:27 +01:00
4ffdb029f0 Removed TileAPI 2014-02-27 00:02:59 +01:00
b7ca8aac5c New Tile structure 2014-02-27 00:02:28 +01:00
b374783486 Allow direct property naming on NBT TAG_Compound 2014-02-26 17:55:17 +01:00
3864630bcd New PMF level (uses NBT Entity and TileEntity) 2014-02-26 17:15:31 +01:00
38c5174da7 Merged branch master into Core-Rewrite (includes new NBT changes) 2014-02-26 16:26:59 +01:00
21671b133a New NBT library finished 2014-02-26 15:20:16 +01:00
9cfa49c112 Added core NBT modifications 2014-02-26 15:12:58 +01:00
0231bf406e new NBT fixes 2014-02-26 13:53:50 +01:00
28d1da1286 New NBT tags 2014-02-26 13:08:53 +01:00
85f8613803 Fix RCON packet structure #1278 2014-02-24 20:13:15 +01:00
8e1cd2d6bd Check for block changes each 2 ticks instead of each 15 ticks 2014-02-23 13:47:30 +01:00
24722e3c9a Added #1196 async function queuing
Type ID: ASYNC_FUNCTION
Params: array("function" => $functionName, "arguments" => array
$argumentArray)
2014-02-23 13:39:57 +01:00
13274ebefa send-usage is now an advanced property :P 2014-02-23 13:39:56 +01:00
378e9c8720 Merge pull request #1274 from iksaku/patch-1
/sudo param help more descriptive
2014-02-23 13:37:49 +01:00
ba761faf74 Update BanAPI.php
/sudo help more descriptive?
2014-02-22 22:43:58 -06:00
734abf2fbb Fix E_STRICT errors 2014-02-20 23:43:42 +01:00
46ff7d43f4 Forgot to remove crash debug code. Fix #1260 2014-02-20 23:41:36 +01:00
8208fd2389 Changed class name 2014-02-20 17:22:51 +01:00
fded039485 Fixed #1258 2014-02-20 13:13:46 +01:00
9bc69f4c17 Update memory data on crash 2014-02-20 11:24:48 +01:00
eb40c34547 Fix error dump not dumped on memory problems 2014-02-20 10:57:42 +01:00
772fa2b9e3 Query token now depends on the source IP 2014-02-20 09:00:17 +01:00
7bdc48509e things 2014-02-19 17:41:12 +01:00
be13d0a921 Merge remote-tracking branch 'origin/PluginAPI-Rewrite' into Entities 2014-02-19 15:59:01 +01:00
7a44e8041f Entity $chunkIndex 2014-02-19 15:37:59 +01:00
b36d754e5b Merge remote-tracking branch 'origin/master' into Entities 2014-02-19 15:28:23 +01:00
62ef1f6b20 Added more entities 2014-02-19 12:41:19 +01:00
d12ce8fd6c small fixes 2014-02-19 02:23:45 +01:00
dd177b689b Added -mmacosx-version-min=10.5 to compile.sh 2014-02-19 02:09:02 +01:00
b4c6a0bf22 oops, typo 2014-02-19 01:56:25 +01:00
f1b5f83fd4 Lots of typos fixed, undefined variables, unused code 2014-02-19 01:55:42 +01:00
3d3111fef6 Changed preg_match() code in Player username handling 2014-02-19 00:49:07 +01:00
a1b2cf4b34 Added -undefined dynamic_lookup 2014-02-18 21:36:52 +01:00
1961e82645 Downgrade OpenSSL to 0.9.8y 2014-02-18 21:31:04 +01:00
15881d328d Added -weak-lSystem to MacOS x86_64 2014-02-18 20:41:54 +01:00
80e2a7e486 Update installer.sh 2014-02-18 19:46:39 +01:00
08c1dbe3a7 fix fix* 2014-02-18 18:52:27 +01:00
0cfb5aa720 fixed typo 2014-02-18 18:42:41 +01:00
60cf2c824f This should do for MacOS x86 2014-02-18 18:22:27 +01:00
f8dc01ccb3 Fixed things compile.sh 2014-02-18 17:47:40 +01:00
2c9337f200 Revert "Added $WITH_OPENSSL again to PHP"
This reverts commit c290b07382.
2014-02-18 17:31:12 +01:00
c290b07382 Added $WITH_OPENSSL again to PHP 2014-02-18 17:26:36 +01:00
0e5c532f5e Changed Android OpenSSL target 2014-02-18 17:24:46 +01:00
9006e5afad Added custom zlib to OpenSSL 2014-02-18 17:13:36 +01:00
bd3544e917 Added DYLD_LIBRARY_PATH 2014-02-18 16:28:30 +01:00
f384dfc40a Changed @loader_path to @executable_path on MacOS 2014-02-18 15:33:32 +01:00
2ee76182ad Compile OpenSSL on MacOS 2014-02-18 15:16:10 +01:00
c7acc3f221 Updated -rpath for MacOS 2014-02-18 15:00:29 +01:00
4573389840 Use Github URL for zlib 2014-02-18 14:48:51 +01:00
ea2fc1fb03 MacOS 32-bit compilation 2014-02-18 14:37:56 +01:00
0245ebe9f6 Update jenkins.sh 2014-02-18 13:00:33 +01:00
d38ae3c230 Added tar.gz files to jenkins.sh 2014-02-18 11:58:34 +01:00
daf27f46be Update installer.sh 2014-02-18 11:54:33 +01:00
2e2990fe33 Update compile.sh 2014-02-18 11:25:01 +01:00
aae66930b6 Update compile.sh to remove unused data 2014-02-18 10:27:32 +01:00
7472238510 Updated installer to handle full paths right and discard warnings on PHP checking 2014-02-17 19:10:28 +01:00
943e038772 Remove OpenSSL from PHP build :P 2014-02-17 18:37:37 +01:00
42e7467dba Added OpenSSL to Jenkins 2014-02-17 18:32:02 +01:00
697d96e60c Updated compile script to handle shared libraries 2014-02-17 18:30:18 +01:00
5b5dcd6d77 Removed not used code in compile.sh 2014-02-17 14:43:58 +01:00
0e39131e76 *fix 2014-02-17 13:26:51 +01:00
109f97ae00 Added ODROID detection to installer.sh 2014-02-17 13:20:28 +01:00
8b4abcc558 Generate OpenSSL shared binaries 2014-02-17 03:09:58 +01:00
5f3772d14a fixed cURL SSL for Darwin 2014-02-17 02:13:35 +01:00
98c50f9a9c OpenSSL is now not enforced compile.sh 2014-02-17 01:46:28 +01:00
6b2bca10a3 Added PHP check on installer.sh 2014-02-16 22:51:25 +01:00
5f6c9b7fad Normal compile.sh 2014-02-16 20:47:32 +01:00
696792cd2a Pre-sed 2014-02-16 20:21:42 +01:00
7e979f40cb Use full path on compile.sh 2014-02-16 20:05:21 +01:00
b0a6631b8e Update jenkins.sh 2014-02-16 19:45:09 +01:00
bb680e6e67 Fix compile.sh things 2014-02-16 18:52:55 +01:00
e999de22d5 oh my god. well, this should do. works for 32 and 64 bit FINALLY 2014-02-16 18:16:17 +01:00
bab5a36d39 Well, I found what broke everything 2014-02-16 17:10:04 +01:00
1a7cdc5cea No OpenSSL for PHP :( 2014-02-16 17:03:36 +01:00
7497e32042 Update jenkins.sh 2014-02-16 16:56:19 +01:00
d0c5f27ed3 OpenSSL make depend :S 2014-02-16 16:54:48 +01:00
65940719c2 OpenSSL + cURL 2014-02-16 16:44:07 +01:00
9847f38a9f Include OpenSSL in builds 2014-02-16 16:10:05 +01:00
e22b70296f Update compile.sh 2014-02-16 13:52:10 +01:00
5725b5a1a8 Update compile.sh 2014-02-16 13:36:13 +01:00
e7565e4183 Update jenkins.sh 2014-02-16 13:34:41 +01:00
878c3a3e3a Update compile.sh 2014-02-16 13:27:29 +01:00
0915e751c4 Update jenkins.sh 2014-02-16 13:11:15 +01:00
e740124b43 Update jenkins.sh 2014-02-16 13:03:31 +01:00
b6ad889057 Trying to fix libssl.so.10 error, re-added libedit 2014-02-16 12:46:26 +01:00
0e4b7f85c4 */ 2014-02-15 20:19:33 +01:00
905fa23d18 methods* 2014-02-15 12:17:17 +01:00
d699a97bb7 small things 2014-02-15 01:39:37 +01:00
9301c04e1f Added pre-compiled Linux binaries to installer 2014-02-14 23:09:29 +01:00
12141fe2b1 Updated jenkins.sh 2014-02-14 22:41:50 +01:00
5d1c79379b *and 2014-02-14 21:49:26 +01:00
08149fa4b3 Fixed #1229 2014-02-14 20:56:00 +01:00
dfe7269019 Fixed #1193 using #1194 2014-02-14 20:53:15 +01:00
2b15c440ee Send inventory on invalid crafting/invalid movement of item 2014-02-14 19:54:14 +01:00
daf3198136 Tall Grass can be replaced 2014-02-14 19:37:57 +01:00
fdf519398a Do not unload spawn chunks 2014-02-14 19:37:39 +01:00
f0ff420659 Fixed negative chunk indexes on PMFLevel 2014-02-14 18:25:06 +01:00
4acb4541ab Infinite player chunk sending (not yet visible :( ) 2014-02-14 17:59:34 +01:00
7ea0bf5067 Merge remote-tracking branch 'origin/master' into Entities 2014-02-14 17:16:51 +01:00
cbe07a1fa0 Fixed PMFLevel infinite loop 2014-02-14 14:21:28 +01:00
47893ed765 Generate backtrace on error/crash 2014-02-14 14:21:13 +01:00
63f4f87d37 Fixed PMFLevel bugs, crashes and weird methods 2014-02-14 13:17:05 +01:00
c1251a25bd Removed water PMFLevel update that caused locks 2014-02-14 01:36:10 +01:00
da554fbf23 Fixed Trees 2014-02-14 00:25:44 +01:00
715e51b7c5 Automatic population on side loading 2014-02-14 00:19:26 +01:00
5d7198396d Added TallGrassPopulator 2014-02-13 22:39:53 +01:00
4fecbc2dbc Added water sand and gravel 2014-02-13 22:05:50 +01:00
9600d61454 Modified max-chunks-per-second default value 2014-02-13 20:48:50 +01:00
5929b510d5 Better, faster world generation. Needs more things 2014-02-13 20:44:15 +01:00
4eebbba5bf PHP 5.4, PHP 5.5 and PHP 5.6 on Travis CI 2014-02-13 11:06:55 +01:00
1bbf211a37 Set a world spawnpoint using /spawnpoint w:WORLD x y z 2014-02-13 09:47:30 +01:00
acece47a37 Merge remote-tracking branch 'origin/master' into Entities 2014-02-13 09:30:21 +01:00
4d1adb98a8 Removed $i on WorldGenerator 2014-02-13 09:29:50 +01:00
c3a6149b29 added protocol number to /version 2014-02-13 08:52:27 +01:00
89e556755d Updated WorldGenerator to use correct generation variables 2014-02-13 08:38:23 +01:00
ab5c6341fe Added /plugins and /version 2014-02-13 08:37:54 +01:00
d0af367395 Use integers instead of booleans 2014-02-13 01:59:08 +01:00
4523b15991 do not send chunk updates on chunk generation 2014-02-13 01:53:30 +01:00
bd73cced6e Do not send block changes during chunk generation 2014-02-13 01:47:18 +01:00
e4c8142681 Removed var_dump() 2014-02-13 01:41:40 +01:00
c9a2a0ea50 Updated API version 2014-02-13 01:34:42 +01:00
268e8c1164 Force PMF save on PMF Level upgrade 2014-02-13 01:34:41 +01:00
e83e424671 Removed entity limits 2014-02-13 01:34:39 +01:00
3e68972253 fix an include 2014-02-13 01:34:37 +01:00
7f86746cbe woo :D 2014-02-13 01:34:36 +01:00
1ab90b1409 PMFLevel upgrade tested 2014-02-13 01:34:35 +01:00
b7ed2f765c Added PMFLevel upgrade 2014-02-13 01:34:33 +01:00
f7b8ad0e37 Infinite generation, in-place chunk creation working. New PMF Format 2014-02-13 01:34:32 +01:00
8377416f48 Nice generation :D 2014-02-13 01:34:30 +01:00
f91e2a5cfe Better parameters ^^ 2014-02-13 01:34:29 +01:00
2d88739005 normalize 2014-02-13 01:34:27 +01:00
4e820ab89f Use single Perlin noise 2014-02-13 01:34:26 +01:00
1bc54dbc44 Such noise 2014-02-13 01:34:24 +01:00
26772082da Random generator with signed int/float methods 2014-02-13 01:34:23 +01:00
3cbcb4871a Changed a few packet things 2014-02-13 01:14:14 +01:00
ac50577255 Typo and fixed a filename 2014-02-12 19:28:33 +01:00
aff2b9882a Merge pull request #1214 from nno88551/patch-2
fixed disconnected message
2014-02-12 11:14:29 +01:00
4352fce82d fixed disconnected message 2014-02-12 19:12:07 +09:00
df865d3456 Entity changes 2014-02-11 20:50:09 +01:00
b392a357e9 More classes 2014-02-11 20:49:38 +01:00
aab0cfb0d8 Added AxisAlignedBB bounding box for entities 2014-02-11 19:37:04 +01:00
a373a581c5 Better fix for #1201 (case-insensitive) 2014-02-11 16:57:45 +01:00
fccca5827f Moar 2014-02-11 16:20:51 +01:00
1206cbf993 Basic Entity structure 2014-02-11 13:31:48 +01:00
89a0e84404 Fixed handlerPriority order 2014-02-11 12:47:28 +01:00
755cafa600 Alpha_1.4dev 2014-02-11 12:47:18 +01:00
c09bc259fc Added #1142 OP players can bypass the player limit 2014-02-11 10:27:53 +01:00
8b23568fe7 Changed codename to new scheme. Alpha_1.3.12 ready \o/ 2014-02-11 02:31:41 +01:00
ad3bf0998f Halt NBT parsing if end of data is found 2014-02-11 01:41:04 +01:00
9cd5c1581b oops x4 2014-02-10 21:38:32 +01:00
94f2da1e38 Oops x3 2014-02-10 20:52:10 +01:00
b635a54b13 Oops x2 2014-02-10 20:47:21 +01:00
5057a3965e Ooops, ;) 2014-02-10 20:46:47 +01:00
5bdb61117f Merge pull request #1188 from PocketMine/Faster-Network
Merge Faster-Network into master. Added new Networking system, new Event system
2014-02-10 19:07:12 +01:00
0bf74d4139 Two packet event types ;) 2014-02-10 18:46:58 +01:00
a2ec9d6688 Moved a file 2014-02-10 18:10:51 +01:00
4b14d5d900 Final structure with example events 2014-02-10 18:08:25 +01:00
a4cbb2f938 Added PluginEvent 2014-02-10 17:33:12 +01:00
9ab993c817 Basic event system written 2014-02-10 17:23:35 +01:00
830530d868 Basic Event types (extended from Bukkit) 2014-02-10 16:09:32 +01:00
7c12f6ce8a Implemented QueryPacket and QueryHandler 2014-02-10 15:05:12 +01:00
b9aa3a0e70 Removed old code for property migration 2014-02-10 13:29:21 +01:00
d925640f03 Moved max-chunks-per-second to server.properties, increased to 8 2014-02-10 13:28:54 +01:00
7e174eac5a Decreased SO_SNDBUF 2014-02-10 13:26:09 +01:00
d5ff5d0066 Merge branches 'Faster-Network' and 'master' of https://github.com/PocketMine/PocketMine-MP 2014-02-10 19:20:37 +10:30
8de39db59d Updated chunk packet field names 2014-02-09 14:39:17 +01:00
f1245a551e Increased UDP buffer size 2014-02-09 13:30:06 +01:00
11c9972eb9 Fixed RotateHeadPacket not having pitch 2014-02-09 05:53:16 +01:00
8739017002 Check if the specified length is correct 2014-02-09 05:37:40 +01:00
5c1550e116 Set max movement distance, disallows teleport cheat 2014-02-09 05:30:15 +01:00
072d0589d2 Fixed undefined $data on RotateHeadPacket 2014-02-09 05:08:32 +01:00
7ebaf7e552 Added Android, BSD detection to Utils::getOS() 2014-02-09 04:44:45 +01:00
0e1c099906 Added iOS detection to Utils::getOS() 2014-02-09 03:20:09 +01:00
c2d4dd093a Updated repo name on installer 2014-02-09 03:19:39 +01:00
6046b263dd Possible fix #1189 2014-02-08 23:44:58 +01:00
dfa28d9a9e WTF null packets crash the server?? 2014-02-08 23:29:42 +01:00
7f0693e7e7 Updated packet handling to eliminate loops 2014-02-08 23:01:22 +01:00
3fed63b248 Split packet handling verified 2014-02-08 22:49:13 +01:00
a8b26a3caf Halt parsing when invalid packets are found 2014-02-08 21:16:51 +01:00
296c6904b9 Hide leave messages from non-spawned players 2014-02-08 20:54:50 +01:00
dfd5733969 Handle unknown packets more gracefully 2014-02-08 19:21:45 +01:00
0ff647015c Handle all kind of unknown data packets 2014-02-08 19:17:49 +01:00
f255948eb6 Updated Query to new packet format 2014-02-08 17:56:48 +01:00
d8aea544f3 Fixed DoorBlock crashing the server 2014-02-08 16:55:20 +01:00
1c7539b51a Fixed data packets being sent on player disconnect 2014-02-08 14:52:06 +01:00
1f8e25710d Fixed set up wizard not updating the memory 2014-02-08 14:46:08 +01:00
b107191fdb Renamed ExplosionPacket to ExplodePacket 2014-02-08 13:39:41 +01:00
f77d5dcefd Fixed UseItemPacket 2014-02-08 13:34:05 +01:00
2c3ab612f2 Fixed AddEntityPacket 2014-02-08 13:02:10 +01:00
b8ff5716c7 Packets are cloned on broadcast 2014-02-08 11:47:52 +01:00
8b87733082 Faster-Network now usable! 2014-02-08 01:30:08 +01:00
1f5ff78f06 Fixed a few wrong fields 2014-02-08 01:25:03 +01:00
f6ecf51516 Added RakNetDataPacket::reset() to all the packets 2014-02-08 00:48:00 +01:00
580ef46513 Added packet pid to buffer by default 2014-02-08 00:36:30 +01:00
c40b00288b Merge remote-tracking branch 'origin/master' into Faster-Network 2014-02-08 00:31:14 +01:00
28a753ba60 Fixed split packet sending 2014-02-08 00:29:20 +01:00
5dd7727548 Reverted 8e37627bc0 2014-02-08 00:05:36 +01:00
61953b5507 Fixed online functions on Android - do not use DNS 2014-02-07 22:56:15 +01:00
d4791ceb6c removed time warning 2014-02-07 20:53:29 +01:00
bcee4e7c21 bypass a few errors on installer.sh 2014-02-07 19:23:16 +01:00
af6174508d MacOS fix 2014-02-07 19:15:00 +01:00
d8e34e9ac5 Added iOS support 2014-02-07 18:46:50 +01:00
951ac08703 Updated installer.sh 2014-02-07 18:13:19 +01:00
2562d8fc41 Fixed position error 2014-02-07 18:06:50 +01:00
ac3472eff4 Fixed spawning problems because of packets 2014-02-07 18:03:11 +01:00
84638098d0 Entity spawn packets 2014-02-07 17:24:50 +01:00
083bfcc83c More classes updated 2014-02-07 17:07:57 +01:00
95bff304e4 Changed all Player packets to new network 2014-02-07 16:44:10 +01:00
20f2ef0e82 Updated PHP binaries on the installer 2014-02-07 11:45:12 +01:00
1728656836 PHP 5.5.9 2014-02-07 11:21:31 +01:00
eb375be550 PocketMinecraftServer client join protocol 2014-02-07 01:06:49 +01:00
dbbfbdffaa RakNet data packet codec 2014-02-07 00:56:40 +01:00
c048564981 Server listing working 2014-02-07 00:46:04 +01:00
45a3b54d32 Fixed basic stuff around 2014-02-07 00:16:39 +01:00
0af197a0f7 New packet writing done 2014-02-06 23:30:09 +01:00
415c9f16f4 wow. much packet. many code. such classes 2014-02-06 22:49:13 +01:00
82a486169f Merge remote-tracking branch 'origin/master' into Faster-Network 2014-02-06 15:22:08 +01:00
14a7e0a201 Call Plugin::__destruct() on PluginAPI::__destruct() 2014-02-06 15:21:12 +01:00
84cdc3bde1 RakNetInfo 2014-02-06 15:19:15 +01:00
5700235f80 Merge remote-tracking branch 'origin/master' into Faster-Network 2014-02-06 14:48:00 +01:00
85438aff0d Added verbose error level names 2014-02-06 14:14:08 +01:00
a5efe15030 Fixed #1173 #486 #466 #483 ignore E_NOTICE unpack() errors 2014-02-06 14:13:37 +01:00
55216ae65b Typo 2014-02-06 14:06:08 +01:00
e4b475218b Fixed #1152 get correct timezone from abbr. 2014-02-06 14:02:27 +01:00
bf6e759d97 Added multiple player selection and exact match by default (fixes #1167) 2014-02-06 13:14:10 +01:00
8e37627bc0 Change spawnpoint to setspawn for bukkit compatibility 2014-02-06 21:31:04 +10:30
e2a77b05b7 Remove redundant closing tag 2014-02-06 21:20:29 +10:30
1694e8622d Updated installer languages 2014-02-06 11:45:31 +01:00
112c35c3a1 Fixed #1171 2014-02-05 18:50:04 +01:00
1b5dc2db4d Reset cache timer when used 2014-02-05 17:29:11 +01:00
61ecf3418e fix installer :s 2014-02-05 12:10:32 +01:00
838147c4eb Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-02-05 12:08:46 +01:00
3ac90dec47 New Raspbian build, fixes #1168 #1165 2014-02-05 12:07:03 +01:00
5030dc0bd1 Updated cURL 2014-02-05 11:57:27 +01:00
c80a64650b Merge pull request #1172 from pemapmodder/master
Added BOOK id
2014-02-05 11:11:39 +01:00
77ab494b70 BOOK ID missing? 2014-02-05 16:42:15 +08:00
5762d70414 Updayed ARMv7 Android flags 2014-02-04 14:08:54 +01:00
96d579e90f why is this so hard! 2014-02-04 14:04:07 +01:00
1ac14dba29 new -mtune 2014-02-04 14:01:42 +01:00
fc6515c37f -mtune=none 2014-02-04 12:58:09 +01:00
8bc60ca36f Removed -mtune 2014-02-04 12:56:23 +01:00
28af0e9f87 Updated compile.sh Android parameters 2014-02-04 12:40:16 +01:00
3bf812b3b3 Updated march for Android 2014-02-04 10:11:27 +01:00
0aeed7f458 Updated ARM toolchain to arm-unknown-linux-uclibcgnueabi 2014-02-04 07:50:28 +01:00
6325a2298e Fixed #1161 PluginAPI::readYAML() and PluginAPI::writeYAML() 2014-02-03 19:13:39 +01:00
34378b5776 Show player name on bad username kick 2014-02-03 01:10:30 +01:00
5cd2362c13 Added libtool 2014-02-02 19:12:51 +01:00
24ac7aa931 Added --target=arm-apple-darwin10 2014-02-02 19:09:03 +01:00
e39dad15e5 Added iOS sdk path 2014-02-02 19:06:35 +01:00
a1996063b6 llvm-? 2014-02-02 19:03:33 +01:00
11593ac96c Added experimental iOS cross-compile support 2014-02-02 19:02:29 +01:00
f9adbf33ec Fixed undefined chunk on PMFLevel::getMiniCHunk() 2014-02-02 12:05:35 +01:00
8bbc0af9b5 Fixed #1150 invalid Entity positions on startup 2014-02-02 02:30:21 +01:00
d299e39649 Fixed invalid array when a player has been kicked 2014-02-02 02:27:59 +01:00
5f3829692d Fixed unknown and impossible crash 2014-02-01 16:26:40 +01:00
dbde770fce Fixed typo o.O 2014-02-01 16:19:56 +01:00
cf1c2b3633 nope 2014-02-01 13:19:42 +01:00
df41f04d0f arm-none-linux-uclibceabi, maybe? 2014-02-01 12:53:59 +01:00
4ae7ccff9f Try with arm-none-linux-uclibcgnueabi 2014-02-01 12:50:41 +01:00
17d565e950 Added --enable-static-link for Android 2014-02-01 12:42:18 +01:00
ca99d60f53 Static uclibc linking 2014-02-01 12:32:12 +01:00
b867be9c9d Save install_data on jenkins 2014-02-01 12:15:22 +01:00
60a43df5c7 Removed gcc -pipe on normal build 2014-02-01 12:12:42 +01:00
fbbb114fc6 Removed gcc -pipe on test 2014-02-01 12:11:26 +01:00
e2b9e3d665 Fixed ARMv7 compilation 2014-02-01 11:28:10 +01:00
25d5ea367d Updated installer binaries 2014-02-01 11:27:56 +01:00
0329735712 Added $HAVE_MYSQLI 2014-02-01 01:27:59 +01:00
a9d0716bde Added $CONFIGURE_FLAGS to YAML compilation 2014-02-01 01:21:30 +01:00
6ba6aa5b61 Fixed jenkins script on places where cURL is not installed 2014-02-01 01:11:47 +01:00
9cc624b74e Force Entity health change on respawn 2014-02-01 01:06:05 +01:00
e619ebad61 such fix ¬¬ 2014-01-31 23:55:43 +01:00
e69da264dc Added prefix to libtool compilation 2014-01-31 23:53:48 +01:00
33bbbba806 Move libtoolize ¬¬ 2014-01-31 23:50:06 +01:00
666418752f fix 92dcb90804 2014-01-31 23:45:19 +01:00
92dcb90804 Added libtoolize env. variable 2014-01-31 23:42:48 +01:00
80376d3a4d Move libtool to correct location on jenkins Mac 2014-01-31 23:36:26 +01:00
0a10e76ff9 fixed typo 2014-01-31 23:31:42 +01:00
d313f82984 Added export to libtool 2014-01-31 23:30:59 +01:00
ab845c5dab Added libtool compilation on Mac for install.sh 2014-01-31 23:30:23 +01:00
951e9efb5e Updated installer.sh to include OPCache 2014-01-31 23:14:50 +01:00
329788e506 Save artifacts even when the build fails jenkins.sh 2014-01-31 21:15:12 +01:00
74ad2ddcdd Added cURL on Mac OSX Jenkins build 2014-01-31 21:05:13 +01:00
09cf39b9d5 Added quotes to URLs 2014-01-31 21:03:28 +01:00
d00b489e1d Added universal installer.sh 2014-01-31 17:51:48 +01:00
cf554c67f2 Be sure to respawn players correctly 2014-01-31 17:24:03 +01:00
331904691d Added cURL shared extension to php.ini 2014-01-31 16:21:07 +01:00
dd7c2c850b Updated jenkins.sh to include all binary files generated 2014-01-31 16:09:52 +01:00
263c580fe1 Removed curl from jenkins.sh for Mac 2014-01-31 16:00:36 +01:00
b9ee3fb185 Updated curl path 2014-01-31 16:00:09 +01:00
5e079b740c Modified cURL building 2014-01-31 15:55:16 +01:00
74d4b95a70 Changed jenkins.sh 2014-01-31 14:31:55 +01:00
ee3b1dc11a Added jenkins.sh 2014-01-31 13:55:06 +01:00
126f149f0b Increased hearts restored by Apples 2014-01-31 13:33:49 +01:00
e12290202b Fixed #1135 Entity despawn race condition 2014-01-31 13:30:30 +01:00
974862996b replaced download_file 2014-01-31 13:26:04 +01:00
bcd312ea16 Removed OPCache when cross-compiling 2014-01-31 01:50:59 +01:00
5ff34b22b5 Include OPCache and generate default php.ini 2014-01-31 01:43:57 +01:00
8a9dcbb646 Calculate time offset only if date.timezone is not set 2014-01-31 01:19:51 +01:00
b7c0e08b7d such debug. much fix 2014-01-31 00:45:16 +01:00
13bf17925f compile.sh now supports cURL client 2014-01-31 00:43:47 +01:00
b56a56df2b Merge remote-tracking branch 'origin/master' into Faster-Network 2014-01-30 10:10:20 +01:00
7403516aab Added extra machine data to Utils::getUniqueID() 2014-01-30 01:13:58 +01:00
7560a5416e Replaced printf with echo 2014-01-30 00:42:10 +01:00
eca8fbce30 Fixed undefined index on Slab 2014-01-30 00:42:01 +01:00
f7af625407 Well... printf "\n" | 2014-01-30 00:39:32 +01:00
e15509c352 Removed Spyc 2014-01-30 00:36:51 +01:00
b481c94f45 Added new PHP YAML extension 2014-01-30 00:36:44 +01:00
d8f4e88e5d Fixed Entities not being despawned on restart if they were off-limits 2014-01-29 23:53:58 +01:00
60bc72c6cb Fixed undefined indexes on cases where plugins did things wrong 2014-01-29 20:41:57 +01:00
cd52cb9ae6 Added exec to start.sh 2014-01-29 20:02:16 +01:00
eeeb6d42c2 Added --with-mysqli=mysqlnd to compile script 2014-01-29 19:43:26 +01:00
e799376559 such fail :S 2014-01-29 19:11:47 +01:00
e7aea41f80 More changes ;). Start.sh now supports the new compile path 2014-01-29 19:07:43 +01:00
55f4811847 Oops ;) 2014-01-29 18:56:21 +01:00
ac2abccf41 Compile all PHP binaries 2014-01-29 18:43:13 +01:00
09720a59ec Added Utils::getUniqueID(), returns a machine ID and a even more variable machine ID 2014-01-29 17:07:01 +01:00
7e8ae3a1e1 Main source for ticks is in the packet loop, and PHP ticks as a secondary backup one 2014-01-29 16:22:58 +01:00
73db6cbb96 Removed BitDeli 2014-01-29 12:43:59 +01:00
f2703f5cfb Move BitDeli Badge. 2014-01-29 20:49:53 +10:30
0703145155 Merge pull request #1129 from bitdeli-chef/master
Add a Bitdeli Badge to README
2014-01-29 02:18:42 -08:00
aadef6e2d3 Add a Bitdeli badge to README 2014-01-29 10:20:50 +00:00
edd2331b40 Added GCC -pipe and changed optimization to -O2 2014-01-29 03:27:31 +01:00
079db8d234 Added option to skip save in ServerAPI::serProperty() 2014-01-29 02:36:21 +01:00
c88b1c97b3 Added advanced caching (enable-advanced-cache) 2014-01-29 02:24:02 +01:00
b4971abe91 Added base Cache class for integrated caching 2014-01-29 02:23:27 +01:00
a297574656 Level::unloadChunk() now uses the saveEnabled property 2014-01-28 21:46:29 +01:00
4bcea9b3e5 ¬¬ world 2014-01-28 12:57:46 +01:00
0a27783604 Fixed offset calculation 2014-01-28 12:50:53 +01:00
9a4bae7d64 Improved crash dumps 2014-01-28 12:50:42 +01:00
f8b270e33f such fix. I even made a regular expression to find these 2014-01-28 12:50:24 +01:00
1526c6cae9 Fixed "Take this ridiculously retarded IF formatting!" by @sekjun9878 2014-01-28 11:37:29 +01:00
4002d3013d More OCD 2014-01-28 11:36:18 +01:00
763adb0360 OCD. Blame @sekjun9878 for making me shout in the train 2014-01-28 11:27:55 +01:00
439c0e8280 Removed obsolete Java Random 2014-01-28 11:25:12 +01:00
4aa7b3eaf8 Allow custom arch. build on compiler 2014-01-27 19:28:29 +01:00
cdefcbd72a Fixed #823 /help outputs ansi colors 2014-01-27 18:19:45 +01:00
101402fe56 Fixed #854 return not-safe spawn when safe spawn is not available 2014-01-27 18:16:28 +01:00
c52f6c9376 Fix #1117 fix 2014-01-27 17:46:41 +01:00
76e4bf6d5f Fixed #1117 enforce new pthreads version 2014-01-27 17:41:42 +01:00
431c06073d Updated Travis-CI to PHP 5.5.x and pthreads to 0.1.0 2014-01-27 15:22:12 +01:00
ac8f2646a7 pthreads 0.1.0 and Thread::kill(). Needs fix 2014-01-27 15:18:20 +01:00
b7cf5d08cc Save and send hotbar history 2014-01-27 14:00:53 +01:00
624eb93058 Save and send last slot used by player 2014-01-27 04:00:26 +01:00
01015d0db3 Fixed #1114 Furnace item duplication cheat 2014-01-27 01:13:59 +01:00
f95e8a2c51 Merge pull request #1109 from pemapmodder/master
Include level in $data for event item.drop
2014-01-26 15:36:24 -08:00
d94239771e Merge pull request #1112 from JWhy/patch-2
/op command: Show usage info if no user specified
2014-01-26 11:27:11 -08:00
49e5d930f1 Level included in data for event item.drop 2014-01-26 20:44:26 +08:00
1b227153a9 /op command: Show usage info if no user specified 2014-01-26 13:21:51 +01:00
ec70dd476a Updated Korean, Dutch and Chinese set-up wizard translations 2014-01-25 01:15:56 +01:00
f432f110a4 Fixed invalid Position object on teleport 2014-01-23 19:02:09 +01:00
9f4b5a40e1 Merge remote-tracking branch 'origin/master' into Faster-Network 2014-01-22 23:13:43 +01:00
4ae1709196 Fixed #1100 Item multiplication cheat 2014-01-22 22:11:54 +01:00
edfcdd0c17 Fixed #1031 Correct face when block is replaced 2014-01-22 17:31:23 +01:00
dcd9dbd1dd Fixed #1032 undefined index on PrimedTNT entities 2014-01-22 17:29:23 +01:00
f4d96e3a9b Temp. fix for Ladders popping out 2014-01-22 13:09:27 +01:00
cfb3bbfbf2 Fixed #1058 2014-01-22 01:36:30 +01:00
e659f435df Merge pull request #1099 from repeat83/patch-1
Fixed invalid indexes for Tile Entities
2014-01-21 12:28:55 -08:00
c7d33ee267 hmmm it's feature? 2014-01-21 23:04:02 +03:00
bede216762 Added Chinese to the language list 2014-01-19 01:07:57 +01:00
c13cc7c91d Added Chinese, updated Korean, Russian 2014-01-18 20:48:04 +01:00
0977daa3b4 Fixes #519 #861 #940 #505 #590 #761 #129 compilation on 64-bit systems 2014-01-18 12:44:17 +01:00
218fb5df3e Trying to fix issue #519 2014-01-18 12:23:45 +01:00
c9ab5ee0e9 API version is now 12 2014-01-17 22:31:22 +01:00
cc57475f91 Added player.block.place.bypass and player.block.break.bypass 2014-01-16 23:09:56 +01:00
6cf8698826 Updated German 2014-01-16 22:33:50 +01:00
718c858632 Added French, updated Korean and German 2014-01-16 16:27:04 +01:00
7a2d90c6d0 Updated German, Korean and Japanese 2014-01-16 12:52:10 +01:00
ee7d2f4ebf Updated Japanese 2014-01-16 00:33:39 +01:00
b5406af32e Updated Russian 2014-01-15 23:30:19 +01:00
0949734d38 Updated Russian and Italian 2014-01-15 22:36:24 +01:00
a3d62056d8 Fixed extra \n 2014-01-15 20:53:10 +01:00
40bdfd33ac Added Japanese, Italian 2014-01-15 20:51:38 +01:00
c0b247dd72 Update nl_NL.ini
Dutch translation fixed
2014-01-15 20:26:34 +01:00
f7ac3f5e8a Updated German 2014-01-15 20:10:57 +01:00
36c416fada Use DejaVu Sans Mono for the MinTTY console 2014-01-15 19:57:46 +01:00
81d938cc53 Removed wizard from Travis 2014-01-15 18:09:09 +01:00
609544b1ec Removed debug instruction 2014-01-15 18:07:55 +01:00
e2c678c8a6 Added set-up Wizard 2014-01-15 18:07:35 +01:00
5fe8141ba0 Alpha_1.3.12 "Henteko Minecart" Development 2014-01-15 18:07:23 +01:00
6a7b03e1bf Updated PHP and cURL 2014-01-13 04:35:36 +01:00
8c648fc6f7 PocketMine-MP Alpha_1.3.11 「甘いビートルート」 Added CODENAME 2014-01-13 04:16:38 +01:00
6c5356fc80 Merge branch 'master' of github.com:PocketMine/PocketMine-MP 2014-01-13 03:35:56 +01:00
70445bdeba Added timeout to Utils::getOnline(), fixes #1071 [gh#1071] 2014-01-13 03:34:40 +01:00
65767312a3 Merge pull request #1064 from wrewolf/patch-2
Update Lava.php
2014-01-12 18:28:54 -08:00
2551bd64ca Merge pull request #1063 from wrewolf/patch-1
Update Water.php
2014-01-12 18:28:43 -08:00
1f360c8bfb Update Lava.php 2014-01-12 12:05:17 +03:00
65a7560185 Update Lava.php
Fix Remove for Left Lavas
2014-01-10 09:45:21 +03:00
860f723518 Update Water.php
Fix Remove for Left Waters
2014-01-10 09:43:31 +03:00
969f0f05b0 Fix #1037 2014-01-04 11:59:07 +09:00
1ce7366cc3 Merge pull request #1025 from InusualZ/patch-1
Level::getAll()
2014-01-03 18:52:44 -08:00
3ed2155c5b Merge pull request #1030 from wallace/patch-1
Update compile.sh
2013-12-27 20:44:43 -08:00
1cc12616e8 Update compile.sh
Properly escape nested double quotes.
2013-12-25 21:46:04 -05:00
e3d3f91c54 Level::getAll() 2013-12-23 20:15:53 -05:00
039edead18 Merge remote-tracking branch 'origin/master' 2013-12-19 18:42:58 +10:30
a141ea5018 Config Object PHPDoc 2013-12-19 18:42:45 +10:30
b63e49acf8 Fixed slot AIR offset 2013-12-18 18:01:06 +01:00
5dc52ad97d Add PHPDoc Documentation to block types. 2013-12-18 20:05:04 +10:30
5eed43ddd0 Added Level::startTime() and Level::stopTime() 2013-12-18 09:45:00 +01:00
9137a36b55 MCPE 0.8.1 version change 2013-12-18 09:44:42 +01:00
5623fa3601 Even more grammar! 2013-12-17 15:45:56 -06:00
78d72201ce (ノಠ益ಠ)ノ彡┻━┻ 2013-12-17 22:30:45 +01:00
a0019bfa73 redeclare fix ;) 2013-12-17 12:03:01 +01:00
de5a3175bc Data Packet initial parsing 2013-12-17 12:00:26 +01:00
e6aeb03ec5 Merge remote-tracking branch 'origin/master' into Faster-Network 2013-12-17 11:01:12 +01:00
d4057a2113 Fixed #997 carrots converting to potatoes [gh#997] 2013-12-17 10:34:24 +01:00
1eab1e382a Merge pull request #1007 from InusualZ/fix
Fixed Event "entity.explosion"
2013-12-16 18:40:04 -08:00
351ac0d7af Fixed Event "entity.explosion"
The event don't listen to the handler
2013-12-16 19:42:35 -05:00
b457e63d20 Reverted Item despawn timer 2013-12-16 17:12:25 +01:00
3ef2471041 More Changes 2013-12-16 15:49:28 +01:00
7bc9500484 Increased error level 2013-12-16 13:06:33 +01:00
6d4472a339 Added Source SHA1 sum 2013-12-16 13:06:31 +01:00
e0b8527560 First changes 2013-12-16 13:06:01 +01:00
050d3424f0 Fix #999. 2013-12-14 16:14:41 +10:30
01e9ca7852 Fix #971. Add lowercase checking of Config. 2013-12-14 16:06:28 +10:30
e2298d861c Fix #996 2013-12-14 15:27:38 +10:30
3248066a37 Increased error level 2013-12-13 15:52:17 +01:00
a0b93ed5ff Added Source SHA1 sum 2013-12-13 15:52:08 +01:00
a8f2225c4c PHP 5.5.7 2013-12-13 13:10:19 +01:00
1a7e916928 Fixed player heads not being rotated 2013-12-13 01:17:55 +01:00
2b0fdd5062 Time syncronized again 2013-12-13 00:52:55 +01:00
af8b380d10 Added Cobweb to Creative Inventory 2013-12-13 00:34:37 +01:00
90e598bb2c Added minecart item (not placeable) 2013-12-13 00:33:07 +01:00
4d0eb5e529 Fixed #988 2013-12-09 21:55:49 +01:00
02dc06c58b Fixed plugin path 2013-12-09 21:50:58 +01:00
c23fc0057a PHP plugins are now included using include() 2013-12-08 17:17:47 +01:00
1693f5655e Updeted to protocol 14 MCPE v0.8.0 build 8 2013-12-08 13:25:21 +01:00
565fe70c7e v0.8.0 alpha version 2013-12-07 13:50:14 +01:00
7cf662fb81 Only show private messages in console when the sender or the target is the console 2013-12-07 12:44:23 +01:00
894325aef6 ¬¬ 2013-12-06 01:50:48 +01:00
423ead6b64 Added item pickup animation 2013-12-06 01:49:47 +01:00
a0a7042d43 Look! New PluginAPI! 2013-12-06 01:24:41 +01:00
14e1dda327 Removed KiwiIRC chat, use official freenode webirc 2013-12-04 18:19:39 +01:00
3cffa66490 added Entity::setHealth() force 2013-12-03 22:25:25 +01:00
2b28e26392 Fixed map chunks bug 2013-12-03 20:39:28 +01:00
8543c06db4 Merge pull request #975 from wiezz/master
Allow chat plugins to work with eachother
2013-12-03 10:04:43 -08:00
adcf95f486 Fix
Send the normal message when $data["message"] is removed by a plugin.
2013-12-03 18:33:37 +01:00
736c233e76 Allow chat plugins to work with eachother 2013-12-03 18:26:38 +01:00
fd2eb7b230 OOPS! 2013-12-03 02:10:43 +01:00
bad8365e28 Fixed zero-length packets spamming the console 2013-12-03 02:07:33 +01:00
e9e59c33cc Fixed 969 2013-12-02 17:45:01 +01:00
8532f53f8e Schedule player kick so it can read the reason 2013-12-02 01:00:11 +01:00
230a3c00fc Removed LevelAPI::isLoaded()
Not needed, everything can be obtained with current methods
2013-12-01 22:01:04 +01:00
d515da8963 Fixed Level::setMiniChunk() parameter bug 2013-12-01 21:37:33 +01:00
f5d69e6905 Fixed Level::getMiniChunk() parameter bug 2013-12-01 21:32:35 +01:00
bcf6571cc2 Delete PermissionsAPI. 2013-12-01 23:52:31 +10:30
7d0ff5e073 Formatting OCD
Please refer to CONTRIBUTING.md
2013-12-01 14:16:38 +01:00
5e2de356bf Modified update system to check the Github API 2013-12-01 14:14:37 +01:00
2d67af6fbd Sugarcane now grows when using bonemeal 2013-12-01 14:14:36 +01:00
bd8110edab MCPE v0.8.0 alpha build 5 2013-12-01 14:14:35 +01:00
25cd58bd99 Merge remote-tracking branch 'origin/master' 2013-11-30 13:10:27 +10:30
a6cd8ece1b Added isLoaded function to LevelAPI. Fixes #959. 2013-11-30 13:10:02 +10:30
0bac7418db Updated StackableArray 2013-11-29 00:18:38 +01:00
a4e38689db Added REDSTONE constant 2013-11-27 23:19:48 +01:00
f3f61e7a4a Cobblestone Walls height handling 2013-11-27 17:41:39 +01:00
bc48e70d6c Remove fire effects on Creative mode 2013-11-27 17:24:33 +01:00
b21ee37c07 MCPE v0.8.0 alpha build 4 2013-11-27 17:22:41 +01:00
2f7e5688e2 Fixed #418 Placing blocks on top of Snow replaces it now 2013-11-27 15:28:10 +01:00
0d6ae6067c Fixed #956 BEETROOT_BLOCK typo 2013-11-27 12:10:26 +01:00
3337e5980e Added ZIP to compile script 2013-11-27 00:18:13 +01:00
493b7532df Removed debug code 2013-11-26 17:28:48 +01:00
bd0d708274 Fixed Packet of Death 2013-11-26 17:23:45 +01:00
5ad72b4f49 Return a bowl when eating stew or soup 2013-11-26 15:29:34 +01:00
7b9edffa47 Mushroom Stew and Beetroot Soup are no longer stackable 2013-11-26 15:23:39 +01:00
6e9b70c9cb Better Tall Grass generation with bonemeal 2013-11-26 13:32:19 +01:00
0f01570d01 "Better" Tall Grass drops 2013-11-26 13:20:19 +01:00
cf5bc916c0 Reordered Creative inventory 2013-11-26 13:15:56 +01:00
35119befd9 Tall Grass now drops Melon and Pumpkin seeds with a probability of 1/15 2013-11-26 12:46:30 +01:00
02150da862 Tall Grass can now drop Carrots, potatoes, beetroot seeds 2013-11-26 12:45:27 +01:00
2044269d86 Added Shears, bedrock and Dyes to creative inventory 2013-11-26 12:42:09 +01:00
2d3ba111e0 Rewrote Generic Explosion drop 2013-11-26 12:28:05 +01:00
98097b0703 Check for $newPermissions is_array 2013-11-26 21:38:48 +10:30
c4ba06b58c Add Restriction Interface 2013-11-26 21:32:08 +10:30
3e12a41a91 permissions.request function use instead of additional argument for player variable. 2013-11-26 21:20:44 +10:30
daaa9394c4 PermissionsAPI Basic Structure Complete. Now uses restrictions. Player dedicated emitEvent functions. Use more anonymous functions. 2013-11-26 21:17:44 +10:30
71a1986980 Add EventRestriction 2013-11-26 20:00:15 +10:30
3352c36ba4 Merge branch 'master' of https://github.com/PocketMine/PocketMine-MP 2013-11-26 15:15:30 +10:30
d2fa06cb64 More comments. 2013-11-26 15:15:24 +10:30
0e9458fafc Merge pull request #950 from InusualZ/test
Fixed #332. Temporary Silk Touch fix. Replace this system with class-based silk touch variable.
2013-11-25 20:32:58 -08:00
75e4174a2b Repaired 2013-11-25 19:31:40 -05:00
509e67bfb7 No More Silk Touch On Explosion 2013-11-25 19:28:59 -05:00
0d25118eef Fixed gh#332
Crafting with buckets (milk) returns the bucket
2013-11-25 18:53:36 -05:00
c798a33363 Fixed gh#332
Crafting with buckets (milk) returns the bucket
2013-11-25 18:53:02 -05:00
5fc192b730 Fixed gh#332
Crafting with buckets (milk) returns the bucket
2013-11-25 18:27:34 -05:00
286b30cf4e Giant typo 2013-11-25 18:36:03 +01:00
a0fac71385 Added coding standards by request of @sekjun9878. Fixed #949 [gh#949] 2013-11-25 18:34:06 +01:00
273a74d566 Added Beetroot Soup food value 2013-11-25 18:01:19 +01:00
aefcab9a49 Really minor changes. 2013-11-25 22:37:30 +10:30
f5989d461c Fix possible variable bug with /tell. 2013-11-25 22:06:25 +10:30
68076fedc8 Some PHPDoc comment updates. 2013-11-25 22:05:07 +10:30
2339525478 Merge remote-tracking branch 'origin/master' 2013-11-25 20:34:57 +10:30
62f5f0d325 Add PHPDoc information to sub-APIs. 2013-11-25 20:34:48 +10:30
0ac81968b7 OCD 2013-11-25 11:02:33 +01:00
b8763a7a3f Add PHPDoc information for API parsing. 2013-11-25 20:28:19 +10:30
249e83db91 Merge branch 'master' of https://github.com/PocketMine/PocketMine-MP 2013-11-25 20:11:57 +10:30
e6f855abbd Add Default permission, and remove construct restriction in Permission interface. Note that all changes on permission API are untested therefore not enabled by default. 2013-11-25 20:11:38 +10:30
75e1a6e97e Added bowl crafting 2013-11-25 09:52:28 +01:00
fb9f7891c7 Added Beetroot soup, beetroot seeds, crafting 2013-11-25 09:42:41 +01:00
03e71ee3ff Added comment in Player.php 2013-11-25 09:35:54 +01:00
9cf91ca3fa Added beetroot IDs
TODO: Beetroot Soup ID
2013-11-25 09:34:57 +01:00
fc7c14ae16 BeetRoot soup doesn't need a class 2013-11-25 09:34:36 +01:00
5ac0907aeb Added $permissions property to Player so pthreads doesn't crash 2013-11-25 09:31:02 +01:00
2f3817322b Formatting OCD 2013-11-25 09:28:41 +01:00
624219f680 Merge remote-tracking branch 'origin/master' 2013-11-25 18:57:33 +10:30
646390812a Beetroot Soup Item template. @shoghicp Add in the Item ID to ItemID.php constants file. 2013-11-25 18:57:13 +10:30
7190d444e3 Revert "Remove Achievement API. Alters game play mechanics."
This reverts commit 2621aab2ef.
2013-11-25 09:26:12 +01:00
bfe0d04663 More notes in Contributions.md 2013-11-25 09:25:48 +01:00
44d63c74dd Update some comments on the recipes. 2013-11-25 18:50:01 +10:30
d7d5e66de6 Use interfaces and closures and abstracts and anonymous functions and all the fancy OOP PHP stuff. 2013-11-25 18:33:12 +10:30
eb7d8a3240 Minor Adjustments 2013-11-25 18:05:21 +10:30
698feccd54 Minor Adjustments. 2013-11-25 18:04:47 +10:30
d3e8cba132 Basic PermissionsAPI template for others to improve. 2013-11-25 18:02:31 +10:30
2621aab2ef Remove Achievement API. Alters game play mechanics. 2013-11-25 17:39:19 +10:30
6ab29f993d OCD 2013-11-24 23:29:17 +01:00
d11cf83a47 Added note about pull requests 2013-11-24 23:26:12 +01:00
336a40ae90 Merge pull request #947 from 99leonchang/master
Multiple orders for /gamemode
2013-11-24 14:20:04 -08:00
a8055eb59a Warn about not using the bin/ PHP binary 2013-11-24 20:09:04 +01:00
2b920033ff Drop boots on death 2013-11-24 19:23:56 +01:00
8665035381 Added Cocoa Beans crafting 2013-11-24 19:01:24 +01:00
e0021b8927 Fixed first hotbar item in Creative 2013-11-24 18:43:14 +01:00
44a9639150 Fixed POTATOE constant 2013-11-24 18:41:57 +01:00
e700179bb0 Multiple changes
* Fixed hoe durability
* Fixed some blocks hitbox
* Added Creative pseudo-inventory
* Added Carrots and Carrot Crops
* Added Potatoes, Baked potatoes and Potato Crops
2013-11-24 18:38:37 +01:00
f8d8052ec3 Correct placement for cakes and snow layers 2013-11-24 15:52:35 +01:00
0dc783f285 Added carpets, crafting recipes, placement 2013-11-24 15:50:02 +01:00
7cd5c5cde1 Fixed paintings resetting the hotbar 2013-11-24 15:18:58 +01:00
3968f3b298 Jungle Tree generation placeholder 2013-11-24 15:12:31 +01:00
9105e59f2a Jungle Sapling 2013-11-24 15:12:14 +01:00
5ac92ee0db Formatting 2013-11-24 20:48:03 +08:00
b5a53c04ac Merge pull request #5 from PocketMine/master
Fixed Wheat recipes
2013-11-24 04:40:15 -08:00
a93798719f Fixed Wheat recipes 2013-11-24 13:38:53 +01:00
1eda0d72a8 Different orders for /gamemode 2013-11-24 20:38:40 +08:00
1331c8aeb2 Merge pull request #4 from PocketMine/master
Update
2013-11-24 04:36:13 -08:00
b9e2576208 f 2013-11-24 20:34:58 +08:00
c25607588b Added sideway Hay Bales 2013-11-24 13:32:21 +01:00
ff8363e2ae Added Wooden Slabs, Double Wooden Slabs, new Wooden Slab crafting 2013-11-24 13:22:09 +01:00
64f7a78329 Added achievement.grant and achievement.broadcast handlers for more customization 2013-11-24 12:18:50 +01:00
f377eacc0f Merge pull request #3 from PocketMine/master
Update
2013-11-24 03:11:57 -08:00
8e452831e1 Fixed undefined $orderingChannel 2013-11-24 12:04:40 +01:00
2483614459 Merge pull request #944 from lloydw/master
Fix argument parsing
2013-11-24 02:52:17 -08:00
53fd9cb466 Merge pull request #945 from 99leonchang/master
AchievmentAPI logic change
2013-11-24 02:51:11 -08:00
1c5b473b36 Added player.craft handler 2013-11-24 11:45:18 +01:00
918fb62ce9 Logic changes 2013-11-24 12:42:31 +08:00
1350e1bc4e Merge pull request #2 from PocketMine/master
Update
2013-11-23 20:33:33 -08:00
5d53c259cf Fix argument parsing 2013-11-24 16:27:09 +13:00
5a71043ab0 Fix 2013-11-24 01:52:23 +01:00
6ff6a5fc91 More achievements 2013-11-24 01:10:05 +01:00
6de602a174 Fixed Coal Block ID 2013-11-24 00:52:21 +01:00
3ff4b9eae0 Achievements API 2013-11-24 00:51:04 +01:00
ae8c934b5f Allow accessing Config data keys directly 2013-11-23 19:14:45 +01:00
5803a4e649 Added Coal Blocks, crafting, fuel information 2013-11-23 18:18:02 +01:00
78f7964d57 Fixed bread crafting & added Hay Bales 2013-11-23 18:09:04 +01:00
78f9e40730 Added Compass and Clock 2013-11-23 17:54:19 +01:00
a0ca572d1f Added Cobblestone Walls, Mossy Stone Walls, crafting recipes, correct drops 2013-11-23 17:40:22 +01:00
af66e5a444 iron bars crafting 2013-11-23 17:23:03 +01:00
1ad00a453b Added Iron bars, Pumpkins, lit pumpkins and pumpkin grow, pumpkin growth, pumpkin seeds, pumpkin pie... 2013-11-23 16:36:30 +01:00
5fa6c5962e Added more Wood stairs, and planks 2013-11-23 15:51:09 +01:00
de98dd920b Sponges added 2013-11-23 15:34:32 +01:00
1a0bccf288 Sideway logs placement & correct drop 2013-11-23 15:21:48 +01:00
e4221b8552 Redstone Ore drops Redstone dust 2013-11-23 13:56:47 +01:00
ba7c9503d8 0.8.0 partial compatibility
* Not compatible with Creative mode
2013-11-23 13:52:13 +01:00
3d53b9eb3a Armor drop - tested 2013-11-23 11:06:01 +01:00
f32f379e97 Lava flow code reformatting 2013-11-23 11:04:36 +01:00
809ca802b3 PocketMine-MP Alpha_1.3.10 Stable Release 2013-11-23 11:00:22 +01:00
719df75886 Water flow code reformatting 2013-11-23 10:59:52 +01:00
14a40ac11e Remove keycodes from console input 2013-11-23 10:46:24 +01:00
c973abc36f Added --disable-ansi to disable console colors #887 2013-11-23 10:22:24 +01:00
54d37a432e Check that ServerAPI::request() works, fixes #916 [gh#916] 2013-11-23 10:17:38 +01:00
c7168a6c64 Fixed #926 [gh#926] 2013-11-23 10:11:25 +01:00
079d24055d Updated compile script
* PHP 5.5.6
* pthreads 0.0.45 (stable!)
* cURL 7.33.0
2013-11-22 23:42:48 +01:00
b1748b5393 Removed language include 2013-11-22 15:28:28 +01:00
dafb12c3d3 Merge pull request #1 from PocketMine/master
Merge pull request #930 from beN39sGroup/master
2013-11-22 05:58:19 -08:00
b66f34b308 Merge pull request #930 from beN39sGroup/master 2013-11-22 23:59:50 +10:30
1cb711d32d Temporaily fix multilanguage bug. Waiting on pull request author to remove multi language. 2013-11-22 22:56:02 +10:30
94a9b7b431 Merge pull request #925 from beN39sGroup/master
Liquid Performance
2013-11-22 03:12:16 -08:00
7acdb0dd3f Fix Performance Problem
Welcome, TPS!
2013-11-17 09:39:40 +09:00
fe70fa467d Slower Unflow & Basic for Multi Language
Slower Unflow!
I wanna Multi Language!
2013-11-15 19:14:02 +09:00
d4a5e4e5c4 Merge pull request #920 from beN39sGroup/master
Liquid Flowing. This requires further testing before stable release.
2013-11-12 21:48:02 -08:00
db289f9871 Mixable Lava & Water
I Wanna Make Cobblestone Generator!
2013-11-10 22:11:45 +09:00
b822b314cb Simple Flowable Lava & English Comment
Still A Flowing
2013-11-10 17:59:36 +09:00
77ca6da14c Simple Flowable Water!
Meet the 'Flowing' Water.
2013-11-10 17:19:50 +09:00
9373c93737 Prefix for Kick Flying when Player on Fence 2013-11-10 13:52:41 +09:00
cb47bf82c9 Reset player's armors after death UNTESTED. Fixes #896. 2013-11-09 20:44:09 +10:30
3498c876df Reset player's armors after death 2013-11-09 20:43:06 +10:30
df01e92ab6 Merge pull request #886 from JWhy/patch-1
Extract plugins/ path lookup to pluginsPath() function in PluginAPI
2013-11-09 01:34:54 -08:00
1f1f955eef Add plugin name info to Evaluation Error. 2013-11-09 20:00:24 +10:30
0e471ab38c Fixed leftover reference in pluginsPath() function 2013-10-22 14:53:12 +02:00
9f211bd7fb Extract plugins/ path lookup to pluginsPath() function in PluginAPI 2013-10-22 14:05:11 +02:00
af486917a1 Fixed #884 2013-10-22 21:26:30 +10:30
c197a58a3a Merge pull request #881 from JWhy/patch-1
Use DIRECTORY_SEPERATOR constant for safer cross-platform file access
2013-10-21 04:22:23 -07:00
ca0d682d87 Use DIRECTORY_SEPERATOR constant for safer cross-platform file access 2013-10-21 12:27:48 +02:00
70ec644658 Merge pull request #880 from JWhy/patch-1
Support other local date format for timezone detection to avoid startup errors
2013-10-20 21:55:48 -07:00
a860f16f4a Support other local date format for timezone detection to avoid startup errors
fixes PocketMine/PocketMine-MP#718
2013-10-21 06:12:27 +02:00
9ac72026b9 Fix #831 2013-10-19 11:47:53 +10:30
0ad0071107 Fix crash bug when @all is used in console. 2013-10-19 11:28:43 +10:30
386b2cb0ef Fix 805 2013-10-19 11:20:33 +10:30
58fce0e939 Fix /me @all critical server crash bug. Fix #840. Disabled usage of @all for non-ops. 2013-10-19 11:12:54 +10:30
780f60554d Fix #871 2013-10-19 10:58:49 +10:30
4aa0ae86fb Update config.php 2013-10-18 18:04:45 +10:30
f005b82a70 Fixed typo. Not Longer -> No Longer 2013-10-09 13:09:35 +10:30
c35c004827 Added the ability to shoot arrows
Credit to ljyloo (http://forums.pocketmine.net/index.php?threads/shooting-arrows-in-pm-server.508/#post-4338).
2013-10-08 16:52:37 -05:00
e179de1613 Better :3 2013-10-02 16:57:37 +02:00
3354df0360 More KiwiIRC Buttons 2013-10-03 00:25:38 +09:30
d8cfc06d3a KiwiIRC! 2013-10-03 00:24:48 +09:30
3b0e553e17 Merge pull request #812 from Humerus/patch-2
Made it so deop doesn't op the player.
2013-09-15 13:18:26 -07:00
c53ea830ea Made it so deop doesn't op the player. 2013-09-15 12:00:00 -04:00
0c1afe15fd Added .idea to .gitignore 2013-09-11 11:13:09 +02:00
6a24700f6e Fix compiler again 2013-09-10 22:52:24 +02:00
000dfc8601 Fix 64 bit builds 2013-09-10 22:49:33 +02:00
a011ad8fb6 Reverted DIAMOND_HOE to IRON_HOE 2013-09-10 20:11:31 +02:00
d41c30945b Level optimizations 2013-09-09 10:44:50 +02:00
b3c51c6d2e Faster level generator 2013-09-09 03:32:24 +02:00
4ccaccc126 Fixed Player::setSpawn() 2013-09-08 15:37:28 +02:00
8aef462a68 Fixed #784 Slabs replacing other slabs 2013-09-08 10:45:36 +02:00
c4a5a9c849 Better explosion damage calculation 2013-09-08 01:35:48 +02:00
275e27f7a9 Low level PMF level interface 2013-09-08 01:21:40 +02:00
1abe7626bf Using Vectors for explosions 2013-09-08 00:27:35 +02:00
7c9255e21e Incremented speedMeasure() size 2013-09-07 21:27:05 +02:00
0c6eaa0609 Fixed entity motion condition 2013-09-07 21:19:47 +02:00
1bc3b66afd Player check is done with equal name, not alike 2013-09-07 14:24:17 +02:00
df174d1b8e Tuned power again xD 2013-09-07 13:35:32 +02:00
f56dd60708 Correct item drop related to explosion power 2013-09-07 12:37:04 +02:00
2271d0b6fc Lowered TNT explosion force from 4 to 3 2013-09-07 12:28:18 +02:00
6d2eea8887 Level::getSafeSpawn() on player normal spawn 2013-09-07 12:05:04 +02:00
fb2bcdb722 Level::getSafeSpawn() look for solid block 2013-09-07 12:04:49 +02:00
c8dd85de75 Better fuse calculation 2013-09-07 11:55:14 +02:00
a00375b1a9 Perfect explosions 2013-09-07 11:40:22 +02:00
e7e05d37b3 Moved -mx32 flag 2013-09-07 10:30:08 +02:00
6ac54925ff Added -mx32 flag 2013-09-07 10:26:22 +02:00
555da94612 Moved patch location :P 2013-09-07 10:21:42 +02:00
774debb299 Fixed #781 2013-09-07 10:18:06 +02:00
9b63a0b0bf Fixed colors on MacOS 2013-09-07 10:13:14 +02:00
397b47d719 Added secondary explosions 2013-09-07 02:51:15 +02:00
5952e34995 PrimedTNT Entity implemented 2013-09-07 02:46:18 +02:00
0ddc48ca80 Vanilla-alike Explosions 2013-09-07 01:28:15 +02:00
24211764ce Tuned TNT force 2013-09-06 22:17:13 +02:00
4a2e3d3611 Fixed Flint & Steel order 2013-09-06 19:33:16 +02:00
e5841e623e Fixed comparison order with flint & steel metadata 2013-09-06 17:50:01 +02:00
215141d552 Added Diamond Hoe, Flint & Steel and Diamond Sword to the Creative inventory 2013-09-06 17:40:07 +02:00
94f8cfb59b Added Single Explosions [ignite TNT using fling & steel] 2013-09-06 13:46:52 +02:00
41b1a0f991 Fixed bottom bed offset 2013-09-05 22:58:49 +02:00
08d93fa021 Fixed #774 [gh#774] 2013-09-05 19:58:31 +02:00
ce65801d14 Keep window open 2013-09-05 17:17:54 +02:00
bb9923d210 Fixed position offset when sleeping on beds 2013-09-05 15:19:27 +02:00
ccac35d5a2 Fixed player catching fire after death 2013-09-05 00:39:06 +02:00
c11ee468a2 Added Door sounds 2013-09-05 00:37:07 +02:00
e48126a0c9 Fixed possible cases on infinite loop on addItem and removeItem 2013-09-04 21:29:21 +02:00
b56ee69f0d Alpha_1.3.10dev 2013-09-04 21:27:13 +02:00
4a46d8fd9c Fixed possible infinite loop in hasSpace 2013-09-04 21:26:22 +02:00
f29181a8ee Removed check on start.cmd 2013-09-04 20:49:25 +02:00
8515e7ff33 Fixed speed limiter 2013-09-04 20:49:14 +02:00
9db1b741a7 Another Typo ¬¬ 2013-09-04 20:34:48 +02:00
401c201a97 Fix start.cmd ¬¬ 2013-09-04 20:27:49 +02:00
fc3fb651b2 Fix fix fix 2013-09-04 20:25:36 +02:00
b4bfceeb6d Added README credits :) 2013-09-04 20:03:59 +02:00
a965103a03 Windows installer fix 2013-09-04 19:59:12 +02:00
f569587764 Alpha_1.3.9 2013-09-04 19:53:42 +02:00
1a9641e93a Dynamic title fix 2013-09-04 19:52:37 +02:00
b297ba16ed New starting scripts for mintty 2013-09-04 19:49:32 +02:00
809076b7d7 Added new text formatting system for future updates [like vanilla PC] 2013-09-04 19:49:19 +02:00
56d829eec6 Fixed #767 Players move laggy [gh#767] 2013-09-04 19:33:11 +02:00
7f15b27ff0 Fixed server crash when two players sleep together 2013-09-04 17:13:03 +02:00
28afadce0a Max chunk rate: 172kB/s => 256kB/s 2013-09-04 13:37:52 +02:00
ae92c968b4 PocketMine-MP Alpha_1.3.8 stable 2013-09-04 13:34:08 +02:00
2a2f2d8043 Changed newest MCPE version to 0.7.5 2013-09-04 13:33:50 +02:00
c9a7067e3f Added date on server logs 2013-09-04 13:32:36 +02:00
160aa3a199 Improved scripts 2013-09-04 13:29:27 +02:00
2b24dab57b Modified startup messages 2013-09-04 13:29:05 +02:00
49b7f60662 Doors fall when the block below is removed 2013-09-04 13:00:04 +02:00
19112f0d06 Updated blocks direct break 2013-09-04 12:59:08 +02:00
cf8e3e41ba Fixed Ice converting to water on creative 2013-09-04 12:56:35 +02:00
aff9349d20 Fixed SignPost Tile remove on block update break 2013-09-04 12:48:35 +02:00
71dd3fe3af Send broken bed block directly [no cache] 2013-09-04 12:41:04 +02:00
bee3e7d67a Fixed players sleeping on the same bed 2013-09-04 12:36:50 +02:00
dd5b1869e2 /spawn teleports to the server spawn instead of the player spawn 2013-09-04 10:49:19 +02:00
724d336853 Fixed blocks being placed on beds during day 2013-09-04 10:30:48 +02:00
3fe3aa2a62 Added force position on teleport [Fixes #356 gh#356] 2013-09-04 01:04:51 +02:00
bb9420753d Round of teleports on spawn 2013-09-03 22:55:47 +02:00
f14999c57f Check phase on sleep 2013-09-03 22:53:53 +02:00
40a20d1467 Send correct spawn position (client-side check) 2013-09-03 22:52:17 +02:00
4d2dc63182 Schedule a teleport on chunk load 2013-09-03 22:51:02 +02:00
1677ce4b1d Adds beds 2013-09-03 22:50:47 +02:00
f7508adb29 Fixed TimeAPI bugs 2013-09-03 22:40:48 +02:00
d86c9982b3 Fixed some item stack size 2013-09-03 20:33:15 +02:00
241a66f5d8 Stonecutter recipes fix 2013-09-02 01:13:21 +02:00
dc940ffcb6 Fix for cross compiling php 2013-09-01 13:51:40 -05:00
58d8fc339e Fix for invalid CPU usage limit 2013-08-31 21:26:55 +02:00
4d4786dc0d Fixed packet index when opening a furnace 2013-08-31 19:27:22 +02:00
8c6bf01815 Alpha_1.3.8dev 2013-08-31 19:26:50 +02:00
689 changed files with 52787 additions and 19820 deletions

1
.gitattributes vendored
View File

@ -5,6 +5,7 @@
*.txt text eol=lf
*.properties text eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
# Custom for Visual Studio
*.cs diff=csharp

16
.gitignore vendored
View File

@ -1,17 +1,16 @@
players/*
worlds/*
plugins/*
logs/*
bin/*
*.log
*.pmf
*.txt
*.phar
server.properties
pocketmine.yml
############
## Windows
############
# Common IDEs
.idea/*
nbproject/*
# Windows image file caches
Thumbs.db
@ -21,3 +20,8 @@ Desktop.ini
# Mac crap
.DS_Store
/nbproject/private/
# Sphinx-doc
/docs/build/
!/docs/requirements.txt

11
.gitmodules vendored Normal file
View File

@ -0,0 +1,11 @@
[submodule "src/pocketmine/gui"]
path = src/pocketmine/gui
url = https://github.com/PocketMine/PocketMine-MP-GUI.git
branch = master
[submodule "src/raklib"]
path = src/raklib
url = https://github.com/PocketMine/RakLib.git
branch = master
[submodule "src/spl"]
path = src/spl
url = https://github.com/PocketMine/PocketMine-SPL.git

5
.mailmap Normal file
View File

@ -0,0 +1,5 @@
Shoghi Cervantes <shoghicp@gmail.com>
Shoghi Cervantes <shoghicp@gmail.com> Shoghi Cervantes <shoghicp@pocketmine.net>
Brandon V <brandon15811@gmail.com>
Michael Yoo <sekjun9878@gmail.com> Michael Yoo <michael@yoo.id.au>
Michael Yoo <sekjun9878@gmail.com> Michael Yoo <sekjun9878@sekjun9878.info>

View File

@ -1,14 +1,21 @@
language: php
php:
- 5.4
- 5.6
branches:
- master
before_script:
- pecl install channel://pecl.php.net/pthreads-0.0.44
- mkdir plugins
- wget -O plugins/DevTools.phar https://github.com/PocketMine/DevTools/releases/download/v1.9.0/DevTools_v1.9.0.phar
- pecl install channel://pecl.php.net/pthreads-2.0.8
- pecl install channel://pecl.php.net/weakref-0.2.4
- echo | pecl install channel://pecl.php.net/yaml-1.1.1
script:
- php src/tests/ServerSuiteTest.php
- php tests/TravisTest.php
notifications:
email: false
webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0
#webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0

View File

@ -1,27 +1,126 @@
![](http://www.pocketmine.net/favicon.png)
![](http://cdn.pocketmine.net/img/PocketMine-MP-h.png)
# PocketMine-MP Contribution Gidelines
# PocketMine-MP Contribution Guidelines
Before contributing to PocketMine-MP, please read this.
You must follow these guidelines if you wish to contribute to the PocketMine-MP code base, or participate in issue tracking.
## I have a question
* For questions, please refer to the _#pocketmine_ or _#mcpedevs_ IRC channel on Freenode. There is a [WebIRC](http://webchat.freenode.net?channels=pocketmine,mcpedevs&uio=d4) if you want.
* You can ask directly to _[@PocketMine](https://twitter.com/PocketMine)_ in Twitter, but don't expect an immediate reply.
* You may use our [Forum](http://forums.pocketmine.net) to ask questions.
* We do not accept questions or support requests in our issue tracker.
## I've a question
* For questions, please refer to the _#mcpedevs_ IRC
channel on Freenode. There is a [WebIRC](http://webchat.freenode.net?channels=mcpedevs&uio=d4) if you want.
* You can ask directly to _[@PocketMine](https://twitter.com/PocketMine)_ in Twitter.
## Creating an Issue
- First, use the [Issue Search](https://github.com/PocketMine/PocketMine-MP/search?ref=cmdform&type=Issues) to check if anyone has reported it.
- If your issue is related to a plugin, you must contact their original author instead of reporting it here.
- If your issue is related to a PocketMine official plugin, or our Android application, you must create an issue on that specific repository.
- **Support requests are not bugs.** Issues such as "How do I do this" are not bugs and are closed as soon as a collaborator spots it. They are referred to our Forum to seek assistance.
- **No generic titles** such as "Question", "Help", "Crash Report" etc. If an issue has a generic title they will either be closed on the spot, or a collaborator will edit it to describe the actual symptom.
- Information must be provided in the issue body, not in the title. No tags are allowed in the title, and do not change the title if the issue has been solved.
- Similarly, no generic issue reports. It is the issue submitter's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**. If you do not provide us with a summary or instructions on how to reproduce the issue, it is a support request until the actual bug has been found and therefore the issue is closed.
## I want to create an issue
* First, use the [Issue Search](https://github.com/PocketMine/PocketMine-MP/search?ref=cmdform&type=Issues) to check if anyone has reported it.
* Is your issue related to a Plugin? If so, please contact their original author instead of reporting it here.
* And no, we won't update a Plugin because you need it.
* When reporting, give as much info as you can, and if the Issue is a crash, give the Crash Dump.
* Issues should be written in English.
## I want to contribute code
## Contributing Code
* Use the [Pull Request](https://github.com/PocketMine/PocketMine-MP/pull/new) system, your request will be checked and discussed.
* If you want to be part of PocketMine-MP, we will ask you to.
* Code using the syntax as in PocketMine-MP.
* __Create a single branch for that pull request__
* Code using the syntax as in PocketMine-MP. See below for an example.
* The code must be clear and written in English, comments included.
* Use descriptive commit titles
* __No merge commits are allowed, or multiple features per pull request__
**Thanks for contributing to PocketMine-MP!**
__Thanks for contributing to PocketMine-MP!__
### Code Syntax
It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) with a few exceptions.
* Opening braces MUST go on the same line, and MUST NOT have spaces before.
* `else if` MUST be written as `elseif`. _(It is in PSR-2, but using a SHOULD)_
* Control structure keywords or opening braces MUST NOT have one space after them.
* Code MUST use tabs for indenting.
* Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
* Files MUST use only the `<?php` tag.
* Files MUST NOT have an ending `?>` tag.
* Code MUST use namespaces.
* Strings SHOULD use the double quote `"` except when the single quote is required.
* Argument lists MAY NOT be split across multiple lines, except long arrays.
```php
<?php
namespace pocketmine\example;
class ExampleClass{
const EXAMPLE_CLASS_CONSTANT = 1;
public $examplePublicVariable = "defaultValue";
private $examplePrivateVariable;
public function __construct($firstArgument, &$secondArgument = null){
if($firstArgument === "exampleValue"){ //Remember to use === instead == when possible
//do things
}elseif($firstArgument === "otherValue"){
$secondArgument = function(){
return [
0 => "value1",
1 => "value2",
2 => "value3",
3 => "value4",
4 => "value5",
5 => "value6",
];
}
}
}
}
```
## Bug Tracking for Collaborators
### Labels
To provide a concise bug tracking environment, prevent the issue tracker from over flowing and to keep support requests out of the bug tracker, PocketMine-MP uses a label scheme a bit different from the default GitHub Issues labels.
PocketMine-MP uses GitHub Issues Labels. There are a total of 12 labels.
Note: For future reference, labels must not be longer than 15 letters.
#### Categories
Category labels are prefixed by `C:`. Multiple category labels may be applied to a single issue(but try to keep this to a minimum and do not overuse category labels).
- C: Core - This label is applied when the bug results in a fatal crash, or is related to neither Gameplay nor Plugin API.
- C: Gameplay - This label is applied when the bug effects the gameplay.
- C: API - This label is applied when the bug effects the Plugin API.
#### Pull Requests
Pull Requests are prefixed by `PR:`. Only one label may be applied for a Pull Request.
- PR: Bug Fix - This label is applied when the Pull Request fixes a bug.
- PR: Contribution - This label is applied when the Pull Request contributes code to PocketMine-MP such as a new feature or an improvement.
#### Status
Status labels show the status of the issue. Multiple status labels may be applied.
- Reproduced - This label is applied when the bug has been reproduced, or multiple people are reporting the same issue and symptoms in which case it is automatically assumed that the bug has been reproduced in different environments.
- Debugged - This label is applied when the cause of the bug has been found.
- Priority - This label is applied when the bug is easy to fix, or if the scale of the bug is global.
- Won't Fix - This label is applied if the bug has been decided not be fixed for some reason. e.g. when the bug benefits gameplay. *This label may only be applied to a closed issue.*
#### Miscellaneous
Miscellaneous labels are labels that show status not related to debugging that bug. The To-Do label and the Mojang label may not be applied to a single issue at the same time.
- To-Do - This label is applied when the issue is not a bug, but a feature request or a list of features to be implemented that count towards a milestone.
- Mojang - This label is applied when the issue is suspected of being caused by the Minecraft: Pocket Edition client, but has not been confirmed.
- Invalid - This label is applied when the issue is reporting a false bug that works as intended, a support request, etc. *This label may only be applied to a closed issue.*
### Closing Issues
To keep the bug tracker clear of non-related issues and to prevent it from overflowing, **issues must be closed as soon as possible** (This may sound unethical, but it is MUCH better than having the BUG TRACKER filled with SUPPORT REQUESTS and "I NEED HELP").
If an issue does not conform to the "Creating an Issue" guidelines above, the issue should be closed.
### Milestones
PocketMine-MP uses GitHub Milestones to set a goal for a new release. A milestone is set on the following occasions.
- A new Beta release
- A new Stable release
A milestone must use the following format:
```
Alpha_<version_number> [release_title][release_version]
```
For example:
```
Alpha_1.4 beta2
```

View File

@ -1,50 +1,55 @@
![](http://www.pocketmine.net/favicon.png)
# ![PocketMine-MP](http://cdn.pocketmine.net/img/PocketMine-MP-h.png)
# PocketMine-MP [![Build Status](https://travis-ci.org/PocketMine/PocketMine-MP.png?branch=master)](https://travis-ci.org/PocketMine/PocketMine-MP)
```
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.
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
```
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
__PocketMine-MP is a sofware for creating Minecraft Pocket Edition servers__. It has a Plugin API that enables a developer to extend it and add new features, or change default ones.
The entire server is done in PHP, and has been tested, profiled and optimized to run smoothly.
__PocketMine-MP is a free, open-source software that creates Minecraft: Pocket Edition servers and allows extending its functionalities__
### [Homepage](http://www.pocketmine.net/)
### [Forums](http://forums.pocketmine.net/)
### [Wiki](https://github.com/PocketMine/PocketMine-MP/wiki/)
### [Documentation](http://pocketmine-mp.readthedocs.org/)
### [FAQ: Frequently Asked Questions](https://github.com/PocketMine/PocketMine-MP/wiki/Frequently-Asked-Questions)
### [Plugin Repository](http://plugins.pocketmine.net/)
<!--## [FAQ: Frequently Asked Questions](https://github.com/PocketMine/PocketMine-MP/wiki/Frequently-Asked-Questions)-->
### [Official Jenkins server](http://jenkins.pocketmine.net/)
### API Documentation
* [Official Doxygen-generated documentation](http://docs.pocketmine.net/)
* [Latest Doxygen generated from development](http://jenkins.pocketmine.net/job/PocketMine-MP-doc/doxygen/)
### [Twitter @PocketMine](https://twitter.com/PocketMine)
## IRC #pocketmine (or #mcpedevs) @ irc.freenode.net
* [WebIRC](http://webchat.freenode.net?channels=pocketmine,mcpedevs&uio=d4)
### IRC Chat #pocketmine (or #mcpedevs) @ irc.freenode.net
[#pocketmine + #mcpedevs channel WebIRC](http://webchat.freenode.net/?channels=pocketmine,mcpedevs)
### Want to contribute?
* Check the [Contributing Guidelines](CONTRIBUTING.md)
## Third-party Libraries/Protocols Used
* __[PHP Sockets](http://php.net/manual/en/book.sockets.php)__
* __[PHP SQLite3](http://php.net/manual/en/book.sqlite3.php)__
* __[PHP BCMath](http://php.net/manual/en/book.bc.php)__
* __[PHP pthreads](https://github.com/krakjoe/pthreads)__ by _[krakjoe](https://github.com/krakjoe)_: Threading for PHP - Share Nothing, Do Everything.
* __[Spyc](https://github.com/mustangostang/spyc/blob/master/Spyc.php)__ by _[Vlad Andersen](https://github.com/mustangostang)_: A simple YAML loader/dumper class for PHP.
* __[ANSICON](https://github.com/adoxa/ansicon)__ by _[Jason Hood](https://github.com/adoxa)_: Process ANSI escape sequences for Windows console programs.
* __[PHP pthreads](http://pthreads.org/)__ by _[krakjoe](https://github.com/krakjoe)_: Threading for PHP - Share Nothing, Do Everything.
* __[PHP YAML](https://code.google.com/p/php-yaml/)__ by _Bryan Davis_: The Yaml PHP Extension provides a wrapper to the LibYAML library.
* __[LibYAML](http://pyyaml.org/wiki/LibYAML)__ by _Kirill Simonov_: A YAML 1.1 parser and emitter written in C.
* __[cURL](http://curl.haxx.se/)__: cURL is a command line tool for transferring data with URL syntax
* __[Zlib](http://www.zlib.net/)__: A Massively Spiffy Yet Delicately Unobtrusive Compression Library
* __[Source RCON Protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol)__
* __[UT3 Query Protocol](http://wiki.unrealadmin.org/UT3_query_protocol)__
* __[UT3 Query Protocol](http://wiki.unrealadmin.org/UT3_query_protocol)__

View File

@ -1,334 +0,0 @@
<?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/
*
*
*/
class BanAPI{
private $server;
private $whitelist;
private $banned;
private $ops;
private $bannedIPs;
private $cmdWL = array();//Command WhiteList
function __construct(){
$this->server = ServerAPI::request();
}
public function init(){
$this->whitelist = new Config(DATA_PATH."white-list.txt", CONFIG_LIST);//Open whitelist list file
$this->bannedIPs = new Config(DATA_PATH."banned-ips.txt", CONFIG_LIST);//Open Banned IPs list file
$this->banned = new Config(DATA_PATH."banned.txt", CONFIG_LIST);//Open Banned Usernames list file
$this->ops = new Config(DATA_PATH."ops.txt", CONFIG_LIST);//Open list of OPs
$this->server->api->console->register("banip", "<add|remove|list|reload> [IP|player]", array($this, "commandHandler"));
$this->server->api->console->register("ban", "<add|remove|list|reload> [username]", array($this, "commandHandler"));
$this->server->api->console->register("kick", "<player> [reason ...]", array($this, "commandHandler"));
$this->server->api->console->register("whitelist", "<on|off|list|add|remove|reload> [username]", array($this, "commandHandler"));
$this->server->api->console->register("op", "<player>", array($this, "commandHandler"));
$this->server->api->console->register("deop", "<player>", array($this, "commandHandler"));
$this->server->api->console->register("sudo", "<player>", array($this, "commandHandler"));
$this->server->api->console->alias("ban-ip", "banip add");
$this->server->api->console->alias("banlist", "ban list");
$this->server->api->console->alias("pardon", "ban remove");
$this->server->api->console->alias("pardon-ip", "banip remove");
$this->server->addHandler("console.command", array($this, "permissionsCheck"), 1);//Event handler when commands are issued. Used to check permissions of commands that go through the server.
$this->server->addHandler("player.block.break", array($this, "permissionsCheck"), 1);//Event handler for blocks
$this->server->addHandler("player.block.place", array($this, "permissionsCheck"), 1);//Event handler for blocks
$this->server->addHandler("player.flying", array($this, "permissionsCheck"), 1);//Flying Event
}
public function cmdWhitelist($cmd){//Whitelists a CMD so everyone can issue it - Even non OPs.
$this->cmdWhitelist[strtolower(trim($cmd))] = true;
}
public function isOp($username){//Is a player op?
$username = strtolower($username);
if($this->server->api->dhandle("op.check", $username) === true){
return true;
}elseif($this->ops->exists($username)){
return true;
}
return false;
}
public function permissionsCheck($data, $event){
switch($event){
case "player.flying"://OPs can fly around the server.
if($this->isOp($data->iusername)){
return true;
}
break;
case "player.block.break":
case "player.block.place"://Spawn protection detection. Allows OPs to place/break blocks in the spawn area.
if(!$this->isOp($data["player"]->iusername)){
$t = new Vector2($data["target"]->x, $data["target"]->z);
$s = new Vector2($this->server->spawn->x, $this->server->spawn->z);
if($t->distance($s) <= $this->server->api->getProperty("spawn-protection") and $this->server->api->dhandle($event.".spawn", $data) !== true){
return false;
}
}
return;
break;
case "console.command"://Checks if a command is allowed with the current user permissions.
if(isset($this->cmdWhitelist[$data["cmd"]])){
return;
}
if($data["issuer"] instanceof Player){
if($this->server->api->handle("console.check", $data) === true or $this->isOp($data["issuer"]->iusername)){
return;
}
}elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){
return;
}
return false;
break;
}
}
public function commandHandler($cmd, $params, $issuer, $alias){
$output = "";
switch($cmd){
case "sudo":
$target = strtolower(array_shift($params));
$player = $this->server->api->player->get($target);
if(!($player instanceof Player)){
$output .= "Player not connected.\n";
break;
}
$this->server->api->console->run(implode(" ", $params), $player);
$output .= "Command ran as ".$player->username.".\n";
break;
case "op":
$user = strtolower($params[0]);
$player = $this->server->api->player->get($user);
if(!($player instanceof Player)){
$this->ops->set($user);
$this->ops->save($user);
$output .= $user." is now op\n";
break;
}
$this->ops->set($player->iusername);
$this->ops->save();
$output .= $player->iusername." is now op\n";
$this->server->api->chat->sendTo(false, "You are now op.", $player->iusername);
break;
case "deop":
$user = strtolower($params[0]);
$player = $this->server->api->player->get($user);
if(!($player instanceof Player)){
$this->ops->set($user, false);
$this->ops->save($user);
$output .= $user." is no longer op\n";
break;
}
$this->ops->remove($player->iusername);
$this->ops->save();
$output .= $player->iusername." is not longer op\n";
$this->server->api->chat->sendTo(false, "You are no longer op.", $player->iusername);
break;
case "kick":
if(!isset($params[0])){
$output .= "Usage: /kick <player> [reason ...]\n";
}else{
$name = strtolower(array_shift($params));
$player = $this->server->api->player->get($name);
if($player === false){
$output .= "Player \"".$name."\" does not exist\n";
}else{
$reason = implode(" ", $params);
$reason = $reason == "" ? "No reason":$reason;
$player->close("You have been kicked: ".$reason);
if($issuer instanceof Player){
$this->server->api->chat->broadcast($player->username." has been kicked by ".$issuer->username.": $reason\n");
}else{
$this->server->api->chat->broadcast($player->username." has been kicked: $reason\n");
}
}
}
break;
case "whitelist":
$p = strtolower(array_shift($params));
switch($p){
case "remove":
$user = strtolower($params[0]);
$this->whitelist->remove($user);
$this->whitelist->save();
$output .= "Player \"$user\" removed from white-list\n";
break;
case "add":
$user = strtolower($params[0]);
$this->whitelist->set($user);
$this->whitelist->save();
$output .= "Player \"$user\" added to white-list\n";
break;
case "reload":
$this->whitelist = new Config(DATA_PATH."white-list.txt", CONFIG_LIST);
break;
case "list":
$output .= "White-list: ".implode(", ", $this->whitelist->getAll(true))."\n";
break;
case "on":
case "true":
case "1":
$output .= "White-list turned on\n";
$this->server->api->setProperty("white-list", true);
break;
case "off":
case "false":
case "0":
$output .= "White-list turned off\n";
$this->server->api->setProperty("white-list", false);
break;
default:
$output .= "Usage: /whitelist <on|off|list|add|remove|reload> [username]\n";
break;
}
break;
case "banip":
$p = strtolower(array_shift($params));
switch($p){
case "pardon":
case "remove":
$ip = strtolower($params[0]);
$this->bannedIPs->remove($ip);
$this->bannedIPs->save();
$output .= "IP \"$ip\" removed from ban list\n";
break;
case "add":
case "ban":
$ip = strtolower($params[0]);
$player = $this->server->api->player->get($ip);
if($player instanceof Player){
$ip = $player->ip;
$player->close("banned");
}
$this->bannedIPs->set($ip);
$this->bannedIPs->save();
$output .= "IP \"$ip\" added to ban list\n";
break;
case "reload":
$this->bannedIPs = new Config(DATA_PATH."banned-ips.txt", CONFIG_LIST);
break;
case "list":
$output .= "IP ban list: ".implode(", ", $this->bannedIPs->getAll(true))."\n";
break;
default:
$output .= "Usage: /banip <add|remove|list|reload> [IP|player]\n";
break;
}
break;
case "ban":
$p = strtolower(array_shift($params));
switch($p){
case "pardon":
case "remove":
$user = strtolower($params[0]);
$this->banned->remove($user);
$this->banned->save();
$output .= "Player \"$user\" removed from ban list\n";
break;
case "add":
case "ban":
$user = strtolower($params[0]);
$this->banned->set($user);
$this->banned->save();
$player = $this->server->api->player->get($user);
if($player !== false){
$player->close("You have been banned");
}
if($issuer instanceof Player){
$this->server->api->chat->broadcast($user." has been banned by ".$issuer->username."\n");
}else{
$this->server->api->chat->broadcast($user." has been banned\n");
}
$this->kick($user, "Banned");
$output .= "Player \"$user\" added to ban list\n";
break;
case "reload":
$this->banned = new Config(DATA_PATH."banned.txt", CONFIG_LIST);
break;
case "list":
$output .= "Ban list: ".implode(", ", $this->banned->getAll(true))."\n";
break;
default:
$output .= "Usage: /ban <add|remove|list|reload> [username]\n";
break;
}
break;
}
return $output;
}
public function ban($username){
$this->commandHandler("ban", array("add", $username), "console", "");
}
public function pardon($username){
$this->commandHandler("ban", array("pardon", $username), "console", "");
}
public function banIP($ip){
$this->commandHandler("banip", array("add", $ip), "console", "");
}
public function pardonIP($ip){
$this->commandHandler("banip", array("pardon", $ip), "console", "");
}
public function kick($username, $reason = "No Reason"){
$this->commandHandler("kick", array($username, $reason), "console", "");
}
public function reload(){
$this->commandHandler("ban", array("reload"), "console", "");
$this->commandHandler("banip", array("reload"), "console", "");
$this->commandHandler("whitelist", array("reload"), "console", "");
}
public function isIPBanned($ip){
if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){
return true;
}elseif($this->bannedIPs->exists($ip)){
return true;
}
return false;
}
public function isBanned($username){
$username = strtolower($username);
if($this->server->api->dhandle("api.ban.check", $username) === false){
return true;
}elseif($this->banned->exists($username)){
return true;
}
return false;
}
public function inWhitelist($username){
$username = strtolower($username);
if($this->isOp($username)){
return true;
}elseif($this->server->api->dhandle("api.ban.whitelist.check", $username) === false){
return true;
}elseif($this->whitelist->exists($username)){
return true;
}
return false;
}
}

View File

@ -1,825 +0,0 @@
<?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/
*
*
*/
class BlockAPI{
private $server;
private $scheduledUpdates = array();
private $randomUpdates = array();
public static $creative = array(
array(COBBLESTONE, 0),
array(STONE_BRICKS, 0),
array(STONE_BRICKS, 1),
array(STONE_BRICKS, 2),
array(MOSS_STONE, 0),
array(WOODEN_PLANKS, 0),
array(BRICKS, 0),
array(STONE, 0),
array(DIRT, 0),
array(GRASS, 0),
array(CLAY_BLOCK, 0),
array(SANDSTONE, 0),
array(SANDSTONE, 1),
array(SANDSTONE, 2),
array(SAND, 0),
array(GRAVEL, 0),
array(TRUNK, 0),
array(TRUNK, 1),
array(TRUNK, 2),
array(NETHER_BRICKS, 0),
array(NETHERRACK, 0),
array(COBBLESTONE_STAIRS, 0),
array(WOODEN_STAIRS, 0),
array(BRICK_STAIRS, 0),
array(SANDSTONE_STAIRS, 0),
array(STONE_BRICK_STAIRS, 0),
array(NETHER_BRICKS_STAIRS, 0),
array(QUARTZ_STAIRS, 0),
array(SLAB, 0),
array(SLAB, 1),
array(SLAB, 2),
array(SLAB, 3),
array(SLAB, 4),
array(SLAB, 5),
array(SLAB, 6),
array(QUARTZ_BLOCK, 0),
array(QUARTZ_BLOCK, 1),
array(QUARTZ_BLOCK, 2),
array(COAL_ORE, 0),
array(IRON_ORE, 0),
array(GOLD_ORE, 0),
array(DIAMOND_ORE, 0),
array(LAPIS_ORE, 0),
array(REDSTONE_ORE, 0),
array(GOLD_BLOCK, 0),
array(IRON_BLOCK, 0),
array(DIAMOND_BLOCK, 0),
array(LAPIS_BLOCK, 0),
array(OBSIDIAN, 0),
array(SNOW_BLOCK, 0),
array(GLASS, 0),
array(GLOWSTONE_BLOCK, 0),
array(NETHER_REACTOR, 0),
array(WOOL, 0),
array(WOOL, 7),
array(WOOL, 6),
array(WOOL, 5),
array(WOOL, 4),
array(WOOL, 3),
array(WOOL, 2),
array(WOOL, 1),
array(WOOL, 15),
array(WOOL, 14),
array(WOOL, 13),
array(WOOL, 12),
array(WOOL, 11),
array(WOOL, 10),
array(WOOL, 9),
array(WOOL, 8),
array(LADDER, 0),
array(TORCH, 0),
array(GLASS_PANE, 0),
array(BUCKET, 0),
array(BUCKET, 8),
array(BUCKET, 10),
array(WOODEN_DOOR, 0),
array(TRAPDOOR, 0),
array(FENCE, 0),
array(FENCE_GATE, 0),
array(BED, 0),
array(BOOKSHELF, 0),
array(PAINTING, 0),
array(WORKBENCH, 0),
array(STONECUTTER, 0),
array(CHEST, 0),
array(FURNACE, 0),
array(TNT, 0),
array(DANDELION, 0),
array(CYAN_FLOWER, 0),
array(BROWN_MUSHROOM, 0),
array(RED_MUSHROOM, 0),
array(CACTUS, 0),
array(MELON_BLOCK, 0),
array(SUGARCANE, 0),
array(SAPLING, 0),
array(SAPLING, 1),
array(SAPLING, 2),
array(LEAVES, 0),
array(LEAVES, 1),
array(LEAVES, 2),
array(SEEDS, 0),
array(MELON_SEEDS, 0),
array(DYE, 15), //Bonemeal
array(IRON_HOE, 0),
array(CAKE, 0),
array(EGG, 0),
array(IRON_SWORD, 0),
array(BOW, 0),
array(SIGN, 0),
array(SPAWN_EGG, MOB_CHICKEN),
array(SPAWN_EGG, MOB_COW),
array(SPAWN_EGG, MOB_PIG),
array(SPAWN_EGG, MOB_SHEEP),
);
public static function fromString($str, $multiple = false){
if($multiple === true){
$blocks = array();
foreach(explode(",",$str) as $b){
$blocks[] = BlockAPI::fromString($b, false);
}
return $blocks;
}else{
$b = explode(":", str_replace(" ", "_", trim($str)));
if(!isset($b[1])){
$meta = 0;
}else{
$meta = ((int) $b[1]) & 0xFFFF;
}
if(defined(strtoupper($b[0]))){
$item = BlockAPI::getItem(constant(strtoupper($b[0])), $meta);
if($item->getID() === AIR and strtoupper($b[0]) !== "AIR"){
$item = BlockAPI::getItem(((int) $b[0]) & 0xFFFF, $meta);
}
}else{
$item = BlockAPI::getItem(((int) $b[0]) & 0xFFFF, $meta);
}
return $item;
}
}
public static function get($id, $meta = 0, $v = false){
$id = (int) $id;
if(isset(Block::$class[$id])){
$classname = Block::$class[$id];
$b = new $classname($meta);
}else{
$b = new GenericBlock($id, $meta);
}
if($v instanceof Position){
$b->position($v);
}
return $b;
}
public static function getItem($id, $meta = 0, $count = 1){
$id = (int) $id;
if(isset(Item::$class[$id])){
$classname = Item::$class[$id];
$i = new $classname($meta, $count);
}else{
$i = new Item($id, $meta, $count);
}
return $i;
}
function __construct(){
$this->server = ServerAPI::request();
}
public function init(){
$this->server->schedule(1, array($this, "blockUpdateTick"), array(), true);
$this->server->api->console->register("give", "<player> <item[:damage]> [amount]", array($this, "commandHandler"));
}
public function commandHandler($cmd, $params, $issuer, $alias){
$output = "";
switch($cmd){
case "give":
if(!isset($params[0]) or !isset($params[1])){
$output .= "Usage: /give <player> <item[:damage]> [amount]\n";
break;
}
$player = $this->server->api->player->get($params[0]);
$item = BlockAPI::fromString($params[1]);
if(!isset($params[2])){
$item->count = $item->getMaxStackSize();
}else{
$item->count = (int) $params[2];
}
if($player instanceof Player){
if(($player->gamemode & 0x01) === 0x01){
$output .= "Player is in creative mode.\n";
break;
}
if($item->getID() == 0) {
$output .= "You cannot give an air block to a player.\n";
break;
}
$player->addItem($item->getID(), $item->getMetadata(), $item->count);
$output .= "Giving ".$item->count." of ".$item->getName()." (".$item->getID().":".$item->getMetadata().") to ".$player->username."\n";
}else{
$output .= "Unknown player.\n";
}
break;
}
return $output;
}
private function cancelAction(Block $block, Player $player, $send = true){
$player->dataPacket(MC_UPDATE_BLOCK, array(
"x" => $block->x,
"y" => $block->y,
"z" => $block->z,
"block" => $block->getID(),
"meta" => $block->getMetadata()
));
if($send === true){
$player->sendInventorySlot($player->slot);
}
return false;
}
public function playerBlockBreak(Player $player, Vector3 $vector){
$target = $player->level->getBlock($vector);
$item = $player->getSlot($player->slot);
if($this->server->api->dhandle("player.block.touch", array("type" => "break", "player" => $player, "target" => $target, "item" => $item)) === false){
return $this->cancelAction($target, $player, false);
}
if((!$target->isBreakable($item, $player) and $this->server->api->dhandle("player.block.break.invalid", array("player" => $player, "target" => $target, "item" => $item)) !== true) or ($player->gamemode & 0x02) === 0x02 or (($player->lastBreak - $player->getLag() / 1000) + $target->getBreakTime($item, $player) - 0.1) >= microtime(true)){
return $this->cancelAction($target, $player, false);
}
$player->lastBreak = microtime(true);
if($this->server->api->dhandle("player.block.break", array("player" => $player, "target" => $target, "item" => $item)) !== false){
$drops = $target->getDrops($item, $player);
if($target->onBreak($item, $player) === false){
return $this->cancelAction($target, $player, false);
}
if($item->useOn($target) and ($player->gamemode & 0x01) === 0 and $item->getMetadata() >= $item->getMaxDurability()){
$player->setSlot($player->slot, new Item(AIR, 0, 0), false);
}
}else{
return $this->cancelAction($target, $player, false);
}
if(($player->gamemode & 0x01) === 0x00 and count($drops) > 0){
foreach($drops as $drop){
$this->server->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2]));
}
}
return false;
}
public function playerBlockAction(Player $player, Vector3 $vector, $face, $fx, $fy, $fz){
if($face < 0 or $face > 5){
return false;
}
$target = $player->level->getBlock($vector);
$block = $target->getSide($face);
$item = $player->getSlot($player->slot);
if($target->getID() === AIR and $this->server->api->dhandle("player.block.place.invalid", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){ //If no block exists or not allowed in CREATIVE
$this->cancelAction($target, $player);
return $this->cancelAction($block, $player);
}
if($this->server->api->dhandle("player.block.touch", array("type" => "place", "player" => $player, "block" => $block, "target" => $target, "item" => $item)) === false){
return $this->cancelAction($block, $player);
}
$this->blockUpdate($target, BLOCK_UPDATE_TOUCH);
if($target->isActivable === true){
if($this->server->api->dhandle("player.block.activate", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== false and $target->onActivate($item, $player) === true){
return false;
}
}
if(($player->gamemode & 0x02) === 0x02){ //Adventure mode!!
return $this->cancelAction($block, $player, false);
}
if($block->y > 127 or $block->y < 0){
return false;
}
if($item->isActivable === true and $item->onActivate($player->level, $player, $block, $target, $face, $fx, $fy, $fz) === true){
if($item->count <= 0){
$player->setSlot($player->slot, BlockAPI::getItem(AIR, 0, 0), false);
}
return false;
}
if($item->isPlaceable()){
$hand = $item->getBlock();
$hand->position($block);
}elseif($block->getID() === FIRE){
$player->level->setBlock($block, new AirBlock());
return false;
}else{
return $this->cancelAction($block, $player, false);
}
if(!($block->isReplaceable === true or ($hand->getID() === SLAB and $block->getID() === SLAB))){
return $this->cancelAction($block, $player, false);
}
if($hand->isSolid === true and $player->entity->inBlock($block)){
return $this->cancelAction($block, $player, false); //Entity in block
}
if($this->server->api->dhandle("player.block.place", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) === false){
return $this->cancelAction($block, $player);
}elseif($hand->place($item, $player, $block, $target, $face, $fx, $fy, $fz) === false){
return $this->cancelAction($block, $player, false);
}
if($hand->getID() === SIGN_POST or $hand->getID() === WALL_SIGN){
$t = $this->server->api->tile->addSign($player->level, $block->x, $block->y, $block->z);
$t->data["creator"] = $player->username;
}
if(($player->gamemode & 0x01) === 0x00){
--$item->count;
if($item->count <= 0){
$player->setSlot($player->slot, BlockAPI::getItem(AIR, 0, 0), false);
}
}
return false;
}
/*
public function flowLavaOn($source, $face){
$down = 0;
if($face === BlockFace::BOTTOM){
$level = 0;
$down = 1;
}else{
$level = ($source[1] & 0x07) + 2;
if($level > 0x07){
return false;
}
}
$spread = $this->server->api->level->getBlockFace($source, $face);
if(($source[0] === 10 or $source[0] === 11) and $spread[0] === 10){
if($level < ($spread[1] & 0x07)){
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $spread[2][0],
"y" => $spread[2][1],
"z" => $spread[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], $spread[0], $level | $down, false);
return true;
}
}elseif($spread[0] === 9 or $spread[0] === 8){
if($source[0] === 11){
$this->server->api->level->setBlock($source[2][0], $source[2][1], $source[2][2], 49, 0);
}elseif($face === 0){
$this->server->api->level->setBlock($source[2][0], $source[2][1], $source[2][2], 1, 0);
}else{
$this->server->api->level->setBlock($source[2][0], $source[2][1], $source[2][2], 4, 0);
}
return true;
}elseif(isset(Material::$flowable[$spread[0]])){
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $spread[2][0],
"y" => $spread[2][1],
"z" => $spread[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], 10, $level | $down, false);
return true;
}elseif(($source[1] & 0x08) === 0x08){
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], $source[0], $source[1] & 0x07, false);
return true;
}
return false;
}
public function flowWaterOn($source, $face, &$spread = null){
$down = 0;
if($face === BlockFace::BOTTOM){
$level = 0;
$down = 1;
}else{
$level = ($source[1] & 0x07) + 1;
if($level > 0x07){
return false;
}
}
$spread = $this->server->api->level->getBlockFace($source, $face);
if(($source[0] === 8 or $source[0] === 9) and $spread[0] === 8){
if($level < ($spread[1] & 0x07)){
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $spread[2][0],
"y" => $spread[2][1],
"z" => $spread[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], $spread[0], $level | $down, false);
return true;
}
}elseif($spread[0] === 11){
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], 49, 0, true);
return true;
}elseif($spread[0] === 10){
if($face === 0 or ($spread[1] & 0x08) === 0){
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], 4, 0, true);
return true;
}
}elseif(isset(Material::$flowable[$spread[0]])){
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $spread[2][0],
"y" => $spread[2][1],
"z" => $spread[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], 8, $level | $down, false);
return true;
}elseif(($source[1] & 0x08) === 0x08){
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], $source[0], $source[1] & 0x07, false);
return true;
}
return false;
}
public function updateBlock($x, $y, $z, $type = BLOCK_UPDATE_NORMAL){
$block = $this->server->api->level->getBlock($x, $y, $z);
$changed = false;
switch($block[0]){
case 8:
case 9:
$faces = array();
if(!$this->flowWaterOn($block, 0, $floor) or $block[0] === 9){
$this->flowWaterOn($block, 2, $faces[0]);
$this->flowWaterOn($block, 3, $faces[1]);
$this->flowWaterOn($block, 4, $faces[2]);
$this->flowWaterOn($block, 5, $faces[3]);
}
if($block[0] === 8){
//Source creation
if(!isset(Material::$flowable[$floor[0]])){
$sources = 0;
foreach($faces as $i => $b){
if($b[0] === 9){
++$sources;
}
}
if($sources >= 2){
$this->server->api->level->setBlock($block[2][0], $block[2][1], $block[2][2], 9, 0, false);
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
break;
}
}
$drained = true;
$level = $block[1] & 0x07;
$up = $this->server->api->level->getBlockFace($block, BlockFace::UP);
if($up[0] === 8 or $up[0] === 9){
$drained = false;
}else{
$b = $this->server->api->level->getBlockFace($block, BlockFace::NORTH);
if($b[0] === 9 or ($b[0] === 8 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
$drained = false;
}else{
$b = $this->server->api->level->getBlockFace($block, BlockFace::SOUTH);
if($b[0] === 9 or ($b[0] === 8 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
$drained = false;
}else{
$b = $this->server->api->level->getBlockFace($block, BlockFace::EAST);
if($b[0] === 9 or ($b[0] === 8 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
$drained = false;
}else{
$b = $this->server->api->level->getBlockFace($block, BlockFace::WEST);
if($b[0] === 9 or ($b[0] === 8 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
$drained = false;
}
}
}
}
}
if($drained === true){
++$level;
if($level > 0x07){
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0] + 1,
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0] - 1,
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2] + 1,
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2] - 1,
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1] - 1,
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->api->level->setBlock($block[2][0], $block[2][1], $block[2][2], 0, 0, false);
}else{
$block[1] = ($block[1] & 0x08) | $level;
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0] + 1,
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0] - 1,
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2] + 1,
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2] - 1,
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1] - 1,
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(10, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->api->level->setBlock($block[2][0], $block[2][1], $block[2][2], $block[0], $block[1], false);
}
}
}
break;
case 10:
case 11:
if(!$this->flowLavaOn($block, 0) or $block[0] === 11){
$this->flowLavaOn($block, 2);
$this->flowLavaOn($block, 3);
$this->flowLavaOn($block, 4);
$this->flowLavaOn($block, 5);
}
if($block[0] === 10){
$drained = true;
$level = $block[1] & 0x07;
$up = $this->server->api->level->getBlockFace($block, BlockFace::UP);
if($up[0] === 10 or $up[0] === 11){
$drained = false;
}else{
$b = $this->server->api->level->getBlockFace($block, BlockFace::NORTH);
if($b[0] === 11 or ($b[0] === 10 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
$drained = false;
}else{
$b = $this->server->api->level->getBlockFace($block, BlockFace::SOUTH);
if($b[0] === 11 or ($b[0] === 10 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
$drained = false;
}else{
$b = $this->server->api->level->getBlockFace($block, BlockFace::EAST);
if($b[0] === 11 or ($b[0] === 10 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
$drained = false;
}else{
$b = $this->server->api->level->getBlockFace($block, BlockFace::WEST);
if($b[0] === 11 or ($b[0] === 10 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
$drained = false;
}
}
}
}
}
if($drained === true){
++$level;
if($level > 0x07){
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0] + 1,
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0] - 1,
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2] + 1,
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2] - 1,
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1] - 1,
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->api->level->setBlock($block[2][0], $block[2][1], $block[2][2], 0, 0, false);
}else{
$block[1] = ($block[1] & 0x08) | $level;
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0] + 1,
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0] - 1,
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2] + 1,
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2] - 1,
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1] - 1,
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->schedule(20, array($this, "blockScheduler"), array(
"x" => $block[2][0],
"y" => $block[2][1],
"z" => $block[2][2],
"type" => BLOCK_UPDATE_NORMAL,
));
$this->server->api->level->setBlock($block[2][0], $block[2][1], $block[2][2], $block[0], $block[1], false);
}
}
}
break;
}
if($type === BLOCK_TYPE_SCHEDULED){
$type = BLOCK_UPDATE_WEAK;
}
if($changed === true){
$this->updateBlocksAround($x, $y, $z, $type);
}
}*/
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
if($delay !== false){
$this->scheduleBlockUpdate($pos->getSide(0), $delay, $type);
$this->scheduleBlockUpdate($pos->getSide(1), $delay, $type);
$this->scheduleBlockUpdate($pos->getSide(2), $delay, $type);
$this->scheduleBlockUpdate($pos->getSide(3), $delay, $type);
$this->scheduleBlockUpdate($pos->getSide(4), $delay, $type);
$this->scheduleBlockUpdate($pos->getSide(5), $delay, $type);
}else{
$this->blockUpdate($pos->getSide(0), $type);
$this->blockUpdate($pos->getSide(1), $type);
$this->blockUpdate($pos->getSide(2), $type);
$this->blockUpdate($pos->getSide(3), $type);
$this->blockUpdate($pos->getSide(4), $type);
$this->blockUpdate($pos->getSide(5), $type);
}
}
public function blockUpdate(Position $pos, $type = BLOCK_UPDATE_NORMAL){
if(!($pos instanceof Block)){
$block = $pos->level->getBlock($pos);
}else{
$pos = new Position($pos->x, $pos->y, $pos->z, $pos->level);
$block = $pos->level->getBlock($pos);
}
if($block === false){
return false;
}
$level = $block->onUpdate($type);
if($level === BLOCK_UPDATE_NORMAL){
$this->blockUpdateAround($block, $level);
$this->server->api->entity->updateRadius($pos, 1);
}elseif($level === BLOCK_UPDATE_RANDOM){
$this->nextRandomUpdate($pos);
}
return $level;
}
public function scheduleBlockUpdate(Position $pos, $delay, $type = BLOCK_UPDATE_SCHEDULED){
$type = (int) $type;
if($delay < 0){
return false;
}
$index = $pos->x.".".$pos->y.".".$pos->z.".".$pos->level->getName().".".$type;
$delay = microtime(true) + $delay * 0.05;
if(!isset($this->scheduledUpdates[$index])){
$this->scheduledUpdates[$index] = $pos;
$this->server->query("INSERT INTO blockUpdates (x, y, z, level, type, delay) VALUES (".$pos->x.", ".$pos->y.", ".$pos->z.", '".$pos->level->getName()."', ".$type.", ".$delay.");");
return true;
}
return false;
}
public function nextRandomUpdate(Position $pos){
if(!isset($this->scheduledUpdates[$pos->x.".".$pos->y.".".$pos->z.".".$pos->level->getName().".".BLOCK_UPDATE_RANDOM])){
$X = (($pos->x >> 4) << 4);
$Y = (($pos->y >> 4) << 4);
$Z = (($pos->z >> 4) << 4);
$time = microtime(true);
$i = 0;
$offset = 0;
while(true){
$t = $offset + Utils::getRandomUpdateTicks() * 0.05;
$update = $this->server->query("SELECT COUNT(*) FROM blockUpdates WHERE level = '".$pos->level->getName()."' AND type = ".BLOCK_UPDATE_RANDOM." AND delay >= ".($time + $t - 1)." AND delay <= ".($time + $t + 1).";");
if($update instanceof SQLite3Result){
$update = $update->fetchArray(SQLITE3_NUM);
if($update[0] < 3){
break;
}
}else{
break;
}
$offset += mt_rand(25, 75);
}
$this->scheduleBlockUpdate($pos, $t / 0.05, BLOCK_UPDATE_RANDOM);
}
}
public function blockUpdateTick(){
$time = microtime(true);
if(count($this->scheduledUpdates) > 0){
$update = $this->server->query("SELECT x,y,z,level,type FROM blockUpdates WHERE delay <= ".$time.";");
if($update instanceof SQLite3Result){
$upp = array();
while(($up = $update->fetchArray(SQLITE3_ASSOC)) !== false){
$index = $up["x"].".".$up["y"].".".$up["z"].".".$up["level"].".".$up["type"];
if(isset($this->scheduledUpdates[$index])){
$upp[] = array((int) $up["type"], $this->scheduledUpdates[$index]);
unset($this->scheduledUpdates[$index]);
}
}
$this->server->query("DELETE FROM blockUpdates WHERE delay <= ".$time.";");
foreach($upp as $b){
$this->blockUpdate($b[1], $b[0]);
}
}
}
}
}

View File

@ -1,123 +0,0 @@
<?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/
*
*
*/
class ChatAPI{
private $server;
function __construct(){
$this->server = ServerAPI::request();
}
public function init(){
$this->server->api->console->register("tell", "<player> <private message ...>", array($this, "commandHandler"));
$this->server->api->console->register("me", "<action ...>", array($this, "commandHandler"));
$this->server->api->console->register("say", "<message ...>", array($this, "commandHandler"));
$this->server->api->ban->cmdWhitelist("tell");
$this->server->api->ban->cmdWhitelist("me");
}
public function commandHandler($cmd, $params, $issuer, $alias){
$output = "";
switch($cmd){
case "say":
$s = implode(" ", $params);
if(trim($s) == ""){
$output .= "Usage: /say <message>\n";
break;
}
$sender = ($issuer instanceof Player) ? "Server":ucfirst($issuer);
$this->server->api->chat->broadcast("[$sender] ".$s);
break;
case "me":
if(!($issuer instanceof Player)){
if($issuer === "rcon"){
$sender = "Rcon";
}else{
$sender = ucfirst($issuer);
}
}else{
$sender = $issuer->username;
}
$this->broadcast("* $sender ".implode(" ", $params));
break;
case "tell":
if(!isset($params[0]) or !isset($params[1])){
$output .= "Usage: /$cmd <player> <message>\n";
break;
}
if(!($issuer instanceof Player)){
$sender = ucfirst($issuer);
}else{
$sender = $issuer->username;
}
$n = array_shift($params);
$target = $this->server->api->player->get($n);
if($target instanceof Player){
$target = $target->username;
}else{
$target = strtolower($n);
if($t === "server" or $t === "console" or $t === "rcon"){
$target = "Console";
}
}
$mes = implode(" ", $params);
$output .= "[me -> ".$target."] ".$mes."\n";
if($target !== "Console" and $target !== "Rcon"){
$this->sendTo(false, "[".$sender." -> me] ".$mes, $target);
}
console("[INFO] [".$sender." -> ".$target."] ".$mes);
break;
}
return $output;
}
public function broadcast($message){
$this->send(false, $message);
}
public function sendTo($owner, $text, $player){
$this->send($owner, $text, array($player));
}
public function send($owner, $text, $whitelist = false, $blacklist = false){
$message = array(
"player" => $owner,
"message" => $text,
);
if($owner !== false){
if($owner instanceof Player){
if($whitelist === false){
console("[INFO] <".$owner->username."> ".$text);
}
}else{
if($whitelist === false){
console("[INFO] <".$owner."> ".$text);
}
}
}else{
if($whitelist === false){
console("[INFO] $text");
}
$message["player"] = "";
}
$this->server->handle("server.chat", new Container($message, $whitelist, $blacklist));
}
}

View File

@ -1,319 +0,0 @@
<?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/
*
*
*/
class ConsoleAPI{
private $loop, $server, $event, $help, $cmds, $alias;
function __construct(){
$this->help = array();
$this->cmds = array();
$this->alias = array();
$this->server = ServerAPI::request();
$this->last = microtime(true);
}
public function init(){
$this->server->schedule(2, array($this, "handle"), array(), true);
if(!defined("NO_THREADS")){
$this->loop = new ConsoleLoop();
}
$this->register("help", "[page|command name]", array($this, "defaultCommands"));
$this->register("status", "", array($this, "defaultCommands"));
$this->register("difficulty", "<0|1|2|3>", array($this, "defaultCommands"));
$this->register("stop", "", array($this, "defaultCommands"));
$this->register("defaultgamemode", "<mode>", array($this, "defaultCommands"));
$this->server->api->ban->cmdWhitelist("help");
}
function __destruct(){
$this->server->deleteEvent($this->event);
if(!defined("NO_THREADS")){
$this->loop->stop();
$this->loop->notify();
//$this->loop->join();
}
}
public function defaultCommands($cmd, $params, $issuer, $alias){
$output = "";
switch($cmd){
case "defaultgamemode":
$gms = array(
"0" => SURVIVAL,
"survival" => SURVIVAL,
"s" => SURVIVAL,
"1" => CREATIVE,
"creative" => CREATIVE,
"c" => CREATIVE,
"2" => ADVENTURE,
"adventure" => ADVENTURE,
"a" => ADVENTURE,
"3" => VIEW,
"view" => VIEW,
"viewer" => VIEW,
"spectator" => VIEW,
"v" => VIEW,
);
if(!isset($gms[strtolower($params[0])])){
$output .= "Usage: /$cmd <mode>\n";
break;
}
$this->server->api->setProperty("gamemode", $gms[strtolower($params[0])]);
$output .= "Default Gamemode is now ".strtoupper($this->server->getGamemode()).".\n";
break;
case "status":
if(!($issuer instanceof Player) and $issuer === "console"){
$this->server->debugInfo(true);
}
$info = $this->server->debugInfo();
$output .= "TPS: ".$info["tps"].", Memory usage: ".$info["memory_usage"]." (Peak ".$info["memory_peak_usage"].")\n";
break;
case "update-done":
$this->server->api->setProperty("last-update", time());
break;
case "stop":
$this->loop->stop = true;
$output .= "Stopping the server\n";
$this->server->close();
break;
case "difficulty":
$s = trim(array_shift($params));
if($s === "" or (((int) $s) > 3 and ((int) $s) < 0)){
$output .= "Usage: /difficulty <0|1|2|3>\n";
break;
}
$this->server->api->setProperty("difficulty", (int) $s);
$output .= "Difficulty changed to ".$this->server->difficulty."\n";
break;
case "?":
if($issuer !== "console" and $issuer !== "rcon"){
break;
}
case "help":
if(isset($params[0]) and !is_numeric($params[0])){
$c = trim(strtolower($params[0]));
if(isset($this->help[$c]) or isset($this->alias[$c])){
$c = isset($this->help[$c]) ? $c : $this->alias[$c];
if($this->server->api->dhandle("console.command.".$c, array("cmd" => $c, "parameters" => array(), "issuer" => $issuer, "alias" => false)) === false or $this->server->api->dhandle("console.command", array("cmd" => $c, "parameters" => array(), "issuer" => $issuer, "alias" => false)) === false){
break;
}
$output .= "Usage: /$c ".$this->help[$c]."\n";
break;
}
}
$cmds = array();
foreach($this->help as $c => $h){
if($this->server->api->dhandle("console.command.".$c, array("cmd" => $c, "parameters" => array(), "issuer" => $issuer, "alias" => false)) === false or $this->server->api->dhandle("console.command", array("cmd" => $c, "parameters" => array(), "issuer" => $issuer, "alias" => false)) === false){
continue;
}
$cmds[$c] = $h;
}
$max = ceil(count($cmds) / 5);
$page = (int) (isset($params[0]) ? min($max, max(1, intval($params[0]))):1);
$output .= "- Showing help page $page of $max (/help <page>) -\n";
$current = 1;
foreach($cmds as $c => $h){
$curpage = (int) ceil($current / 5);
if($curpage === $page){
$output .= "/$c ".$h."\n";
}elseif($curpage > $page){
break;
}
++$current;
}
break;
default:
$output .= "Command doesn't exist! Use /help\n";
break;
}
return $output;
}
public function alias($alias, $cmd){
$this->alias[strtolower(trim($alias))] = trim($cmd);
return true;
}
public function register($cmd, $help, $callback){
if(!is_callable($callback)){
return false;
}
$cmd = strtolower(trim($cmd));
$this->cmds[$cmd] = $callback;
$this->help[$cmd] = $help;
ksort($this->help, SORT_NATURAL | SORT_FLAG_CASE);
}
public function run($line = "", $issuer = "console", $alias = false){
if($line != ""){
$output = "";
$end = strpos($line, " ");
if($end === false){
$end = strlen($line);
}
$cmd = strtolower(substr($line, 0, $end));
$params = (string) substr($line, $end + 1);
if(isset($this->alias[$cmd])){
return $this->run($this->alias[$cmd] . ($params !== "" ? " " .$params:""), $issuer, $cmd);
}
if($issuer instanceof Player){
console("[DEBUG] \x1b[33m".$issuer->username."\x1b[0m issued server command: ".ltrim("$alias ")."/$cmd ".$params, true, true, 2);
}else{
console("[DEBUG] \x1b[33m*".$issuer."\x1b[0m issued server command: ".ltrim("$alias ")."/$cmd ".$params, true, true, 2);
}
if(preg_match_all('#@([@a-z]{1,})#', $params, $matches, PREG_OFFSET_CAPTURE) > 0){
$offsetshift = 0;
foreach($matches[1] as $selector){
if($selector[0]{0} === "@"){ //Escape!
$params = substr_replace($params, $selector[0], $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
--$offsetshift;
continue;
}
switch(strtolower($selector[0])){
case "u":
case "player":
case "username":
$p = ($issuer instanceof Player) ? $issuer->username:$issuer;
$params = substr_replace($params, $p, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
$offsetshift -= strlen($selector[0]) - strlen($p) + 1;
break;
case "w":
case "world":
$p = ($issuer instanceof Player) ? $issuer->level->getName():$this->server->api->level->getDefault()->getName();
$params = substr_replace($params, $p, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
$offsetshift -= strlen($selector[0]) - strlen($p) + 1;
break;
case "a":
case "all":
$output = "";
foreach($this->server->api->player->getAll() as $p){
$output .= $this->run($cmd . " ". substr_replace($params, $p->username, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1), $issuer, $alias);
}
return $output;
case "r":
case "random":
$l = array();
foreach($this->server->api->player->getAll() as $p){
if($p !== $issuer){
$l[] = $p;
}
}
if(count($l) === 0){
return;
}
$p = $l[mt_rand(0, count($l) - 1)]->username;
$params = substr_replace($params, $p, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
$offsetshift -= strlen($selector[0]) - strlen($p) + 1;
break;
}
}
}
$params = explode(" ", $params);
if(count($params) === 1 and $params[0] === ""){
$params = array();
}
if(($d1 = $this->server->api->dhandle("console.command.".$cmd, array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias))) === false
or ($d2 = $this->server->api->dhandle("console.command", array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias))) === false){
$output = "You don't have permissions to use this command.\n";
}elseif($d1 !== true and $d2 !== true){
if(isset($this->cmds[$cmd]) and is_callable($this->cmds[$cmd])){
$output = @call_user_func($this->cmds[$cmd], $cmd, $params, $issuer, $alias);
}elseif($this->server->api->dhandle("console.command.unknown", array("cmd" => $cmd, "params" => $params, "issuer" => $issuer, "alias" => $alias)) !== false){
$output = $this->defaultCommands($cmd, $params, $issuer, $alias);
}
}
if($output != "" and ($issuer instanceof Player)){
$issuer->sendChat(trim($output));
}
return $output;
}
}
public function handle($time){
if(defined("NO_THREADS")){
return;
}
if($this->loop->line !== false){
$line = trim($this->loop->line);
$this->loop->line = false;
$output = $this->run($line, "console");
if($output != ""){
$mes = explode("\n", trim($output));
foreach($mes as $m){
console("[CMD] ".$m);
}
}
}else{
$this->loop->notify();
}
}
}
class ConsoleLoop extends Thread{
public $line;
public $stop;
public $base;
public $ev;
public $fp;
public function __construct(){
$this->line = false;
$this->stop = false;
$this->start();
}
public function stop(){
$this->stop = true;
}
private function readLine(){
if($this->fp){
$line = trim(fgets($this->fp));
}else{
$line = trim(readline(""));
if($line != ""){
readline_add_history( $line );
}
}
return $line;
}
public function run(){
if(!extension_loaded("readline")){
$this->fp = fopen( "php://stdin", "r" );
}
while($this->stop === false){
$this->line = $this->readLine();
$this->wait();
$this->line = false;
}
if(!$this->haveReadline){
@fclose($fp);
}
exit(0);
}
}

View File

@ -1,173 +0,0 @@
<?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/
*
*
*/
class EntityAPI{
private $server;
private $entities;
private $eCnt = 1;
function __construct(){
$this->entities = array();
$this->server = ServerAPI::request();
}
public function get($eid){
if(isset($this->entities[$eid])){
return $this->entities[$eid];
}
return false;
}
public function init(){
$this->server->schedule(25, array($this, "updateEntities"), array(), true);
}
public function updateEntities(){
$l = $this->server->query("SELECT EID FROM entities WHERE hasUpdate = 1;");
if($l !== false and $l !== true){
while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
$e = $this->get($e["EID"]);
if($e instanceof Entity){
$e->update();
$this->server->query("UPDATE entities SET hasUpdate = 0 WHERE EID = ".$e->eid.";");
}
}
}
}
public function updateRadius(Position $center, $radius = 15, $class = false){
$this->server->query("UPDATE entities SET hasUpdate = 1 WHERE level = '".$center->level->getName()."' ".($class !== false ? "AND class = $class ":"")."AND abs(x - {$center->x}) <= $radius AND abs(y - {$center->y}) <= $radius AND abs(z - {$center->z}) <= $radius;");
}
public function getRadius(Position $center, $radius = 15, $class = false){
$entities = array();
$l = $this->server->query("SELECT EID FROM entities WHERE level = '".$center->level->getName()."' ".($class !== false ? "AND class = $class ":"")."AND abs(x - {$center->x}) <= $radius AND abs(y - {$center->y}) <= $radius AND abs(z - {$center->z}) <= $radius;");
if($l !== false and $l !== true){
while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
$e = $this->get($e["EID"]);
if($e instanceof Entity){
$entities[$e->eid] = $e;
}
}
}
return $entities;
}
public function getAll($level = null){
if($level instanceof Level){
$entities = array();
$l = $this->server->query("SELECT EID FROM entities WHERE level = '".$level->getName()."';");
if($l !== false and $l !== true){
while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
$e = $this->get($e["EID"]);
if($e instanceof Entity){
$entities[$e->eid] = $e;
}
}
}
return $entities;
}
return $this->entities;
}
public function heal($eid, $heal = 1, $cause){
$this->harm($eid, -$heal, $cause);
}
public function harm($eid, $attack = 1, $cause, $force = false){
$e = $this->get($eid);
if($e === false or $e->dead === true){
return false;
}
$e->setHealth($e->getHealth() - $attack, $cause, $force);
}
public function add(Level $level, $class, $type = 0, $data = array()){
$eid = $this->eCnt++;
$this->entities[$eid] = new Entity($level, $eid, $class, $type, $data);
$this->server->handle("entity.add", $this->entities[$eid]);
return $this->entities[$eid];
}
public function spawnToAll(Entity $e){
foreach($this->server->api->player->getAll($e->level) as $player){
if($player->eid !== false and $player->eid !== $e->eid and $e->class !== ENTITY_PLAYER){
$e->spawn($player);
}
}
}
public function drop(Position $pos, Item $item){
if($item->getID() === AIR or $item->count <= 0){
return;
}
$data = array(
"x" => $pos->x + mt_rand(-10, 10) / 50,
"y" => $pos->y + 0.19,
"z" => $pos->z + mt_rand(-10, 10) / 50,
//"speedX" => mt_rand(-3, 3) / 8,
"speedY" => mt_rand(5, 8) / 2,
//"speedZ" => mt_rand(-3, 3) / 8,
"item" => $item,
);
if($this->server->api->handle("item.drop", $data) !== false){
for($count = $item->count; $count > 0; ){
$item->count = min($item->getMaxStackSize(), $count);
$count -= $item->count;
$e = $this->add($pos->level, ENTITY_ITEM, $item->getID(), $data);
$this->spawnToAll($e);
$this->server->api->handle("entity.motion", $e);
}
}
}
public function spawnAll(Player $player){
foreach($this->getAll($player->level) as $e){
if($e->class !== ENTITY_PLAYER){
$e->spawn($player);
}
}
}
public function remove($eid){
if(isset($this->entities[$eid])){
$entity = $this->entities[$eid];
$this->entities[$eid] = null;
unset($this->entities[$eid]);
$entity->closed = true;
$this->server->query("DELETE FROM entities WHERE EID = ".$eid.";");
if($entity->class === ENTITY_PLAYER){
$this->server->api->player->broadcastPacket($this->server->api->player->getAll(), MC_REMOVE_PLAYER, array(
"clientID" => 0,
"eid" => $entity->eid,
));
}else{
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($entity->level), MC_REMOVE_ENTITY, array(
"eid" => $entity->eid,
));
}
$this->server->api->dhandle("entity.remove", $entity);
$entity = null;
unset($entity);
}
}
}

View File

@ -1,240 +0,0 @@
<?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/
*
*
*/
class LevelAPI{
private $server, $levels, $default;
public function __construct(){
$this->server = ServerAPI::request();
$this->levels = array();
}
public function get($name){
if(isset($this->levels[$name])){
return $this->levels[$name];
}
return false;
}
public function getDefault(){
return $this->levels[$this->default];
}
public function init(){
$this->server->api->console->register("seed", "[world]", array($this, "commandHandler"));
$this->server->api->console->register("save-all", "", array($this, "commandHandler"));
$this->server->api->console->register("save-on", "", array($this, "commandHandler"));
$this->server->api->console->register("save-off", "", array($this, "commandHandler"));
$this->default = $this->server->api->getProperty("level-name");
if($this->loadLevel($this->default) === false){
$this->generateLevel($this->default, $this->server->seed);
$this->loadLevel($this->default);
}
$this->server->spawn = $this->getDefault()->getSafeSpawn();
}
public function commandHandler($cmd, $params, $issuer, $alias){
$output = "";
switch($cmd){
case "save-all":
$save = $this->server->saveEnabled;
$this->server->saveEnabled = true;
$this->saveAll();
$this->server->saveEnabled = $save;
break;
case "save-on":
$this->server->saveEnabled = true;
break;
case "save-off":
$this->server->saveEnabled = false;
break;
case "seed":
if(!isset($params[0]) and ($issuer instanceof Player)){
$output .= "Seed: ".$issuer->level->getSeed()."\n";
}elseif(isset($params[0])){
if(($lv = $this->server->api->level->get(trim(implode(" ", $params)))) !== false){
$output .= "Seed: ".$lv->getSeed()."\n";
}
}else{
$output .= "Seed: ".$this->server->api->level->getDefault()->getSeed()."\n";
}
}
return $output;
}
public function generateLevel($name, $seed = false, $generator = false){
if($this->levelExists($name)){
return false;
}
$options = array();
if($this->server->api->getProperty("generator-settings") !== false and trim($this->server->api->getProperty("generator-settings")) != ""){
$options["preset"] = $this->server->api->getProperty("generator-settings");
}
if($generator !== false and class_exists($generator)){
$generator = new $generator($options);
}else{
if(strtoupper($this->server->api->getProperty("level-type")) == "FLAT"){
$generator = new SuperflatGenerator($options);
}else{
$generator = new TemporalGenerator($options);
}
}
$gen = new WorldGenerator($generator, $name, $seed === false ? Utils::readInt(Utils::getRandomBytes(4, false)):(int) $seed);
$gen->generate();
$gen->close();
return true;
}
public function levelExists($name){
if($name === ""){
return false;
}
$path = DATA_PATH."worlds/".$name."/";
if($this->get($name) === false and !file_exists($path."level.pmf")){
$level = new LevelImport($path);
if($level->import() === false){
return false;
}
}
return true;
}
public function unloadLevel(Level $level, $force = false){
$name = $level->getName();
if($name === $this->default and $force !== true){
return false;
}
console("[INFO] Unloading level \"".$name."\"");
$level->nextSave = PHP_INT_MAX;
$level->save();
foreach($this->server->api->player->getAll($level) as $player){
$player->teleport($this->server->spawn);
}
foreach($this->server->api->entity->getAll($level) as $entity){
if($entity->class !== ENTITY_PLAYER){
$entity->close();
}
}
foreach($this->server->api->tile->getAll($level) as $tile){
$tile->close();
}
$level->close();
unset($this->levels[$name]);
return true;
}
public function loadLevel($name){
if($this->get($name) !== false){
return true;
}elseif($this->levelExists($name) === false){
console("[NOTICE] Level \"".$name."\" not found");
return false;
}
$path = DATA_PATH."worlds/".$name."/";
console("[INFO] Preparing level \"".$name."\"");
$level = new PMFLevel($path."level.pmf");
$entities = new Config($path."entities.yml", CONFIG_YAML);
if(file_exists($path."tileEntities.yml")){
@rename($path."tileEntities.yml", $path."tiles.yml");
}
$tiles = new Config($path."tiles.yml", CONFIG_YAML);
$blockUpdates = new Config($path."bupdates.yml", CONFIG_YAML);
$this->levels[$name] = new Level($level, $entities, $tiles, $blockUpdates, $name);
foreach($entities->getAll() as $entity){
if(!isset($entity["id"])){
break;
}
if($entity["id"] === 64){ //Item Drop
$e = $this->server->api->entity->add($this->levels[$name], ENTITY_ITEM, $entity["Item"]["id"], array(
"meta" => $entity["Item"]["Damage"],
"stack" => $entity["Item"]["Count"],
"x" => $entity["Pos"][0],
"y" => $entity["Pos"][1],
"z" => $entity["Pos"][2],
"yaw" => $entity["Rotation"][0],
"pitch" => $entity["Rotation"][1],
));
}elseif($entity["id"] === FALLING_SAND){
$e = $this->server->api->entity->add($this->levels[$name], ENTITY_FALLING, $entity["id"], $entity);
$e->setPosition(new Vector3($entity["Pos"][0], $entity["Pos"][1], $entity["Pos"][2]), $entity["Rotation"][0], $entity["Rotation"][1]);
$e->setHealth($entity["Health"]);
}elseif($entity["id"] === OBJECT_PAINTING or $entity["id"] === OBJECT_ARROW){ //Painting
$e = $this->server->api->entity->add($this->levels[$name], ENTITY_OBJECT, $entity["id"], $entity);
$e->setPosition(new Vector3($entity["Pos"][0], $entity["Pos"][1], $entity["Pos"][2]), $entity["Rotation"][0], $entity["Rotation"][1]);
$e->setHealth(1);
}else{
$e = $this->server->api->entity->add($this->levels[$name], ENTITY_MOB, $entity["id"], $entity);
$e->setPosition(new Vector3($entity["Pos"][0], $entity["Pos"][1], $entity["Pos"][2]), $entity["Rotation"][0], $entity["Rotation"][1]);
$e->setHealth($entity["Health"]);
}
}
foreach($tiles->getAll() as $tile){
if(!isset($tile["id"])){
break;
}
$t = $this->server->api->tile->add($this->levels[$name], $tile["id"], $tile["x"], $tile["y"], $tile["z"], $tile);
}
$timeu = microtime(true);
foreach($blockUpdates->getAll() as $bupdate){
$this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"],(int) $bupdate["y"],(int) $bupdate["z"], $this->levels[$name]), (float) $bupdate["delay"], (int) $bupdate["type"]);
}
return true;
}
public function handle($data, $event){
switch($event){
}
}
public function saveAll(){
foreach($this->levels as $level){
$level->save();
}
}
public function __destruct(){
$this->saveAll();
foreach($this->levels as $level){
$this->unloadLevel($level, true);
}
}
public function getSpawn(){
return $this->server->spawn;
}
public function loadMap(){
if($this->mapName !== false and trim($this->mapName) !== ""){
if(!file_exists($this->mapDir."level.pmf")){
$level = new LevelImport($this->mapDir);
$level->import();
}
$this->level = new PMFLevel($this->mapDir."level.pmf");
console("[INFO] Preparing level \"".$this->level->getData("name")."\"");
$this->time = (int) $this->level->getData("time");
$this->seed = (int) $this->level->getData("seed");
$this->spawn = $this->level->getSpawn();
}
}
}

View File

@ -1,471 +0,0 @@
<?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/
*
*
*/
class PlayerAPI{
private $server;
function __construct(){
$this->server = ServerAPI::request();
}
public function init(){
$this->server->schedule(20 * 15, array($this, "handle"), 1, true, "server.regeneration");
$this->server->addHandler("player.death", array($this, "handle"), 1);
$this->server->api->console->register("list", "", array($this, "commandHandler"));
$this->server->api->console->register("kill", "<player>", array($this, "commandHandler"));
$this->server->api->console->register("gamemode", "<mode> [player]", array($this, "commandHandler"));
$this->server->api->console->register("tp", "[target player] <destination player|w:world> OR /tp [target player] <x> <y> <z>", array($this, "commandHandler"));
$this->server->api->console->register("spawnpoint", "[player] [x] [y] [z]", array($this, "commandHandler"));
$this->server->api->console->register("spawn", "", array($this, "commandHandler"));
$this->server->api->console->register("ping", "", array($this, "commandHandler"));
$this->server->api->console->alias("lag", "ping");
$this->server->api->console->alias("suicide", "kill");
$this->server->api->console->alias("tppos", "tp");
$this->server->api->ban->cmdWhitelist("list");
$this->server->api->ban->cmdWhitelist("ping");
$this->server->api->ban->cmdWhitelist("spawn");
$this->server->preparedSQL->selectPlayersToHeal = $this->server->database->prepare("SELECT EID FROM entities WHERE class = ".ENTITY_PLAYER." AND health < 20;");
}
public function handle($data, $event){
switch($event){
case "server.regeneration":
if($this->server->difficulty === 0){
$result = $this->server->preparedSQL->selectPlayersToHeal->execute();
if($result !== false){
while(($player = $result->fetchArray()) !== false){
if(($player = $this->server->api->entity->get($player["EID"])) !== false){
if($player->getHealth() <= 0){
continue;
}
$player->setHealth(min(20, $player->getHealth() + $data), "regeneration");
}
}
return true;
}
}
break;
case "player.death":
if(is_numeric($data["cause"])){
$e = $this->server->api->entity->get($data["cause"]);
if($e instanceof Entity){
switch($e->class){
case ENTITY_PLAYER:
$message = " was killed by ".$e->name;
break;
default:
$message = " was killed";
break;
}
}
}else{
switch($data["cause"]){
case "cactus":
$message = " was pricked to death";
break;
case "lava":
$message = " tried to swim in lava";
break;
case "fire":
$message = " went up in flames";
break;
case "burning":
$message = " burned to death";
break;
case "suffocation":
$message = " suffocated in a wall";
break;
case "water":
$message = " drowned";
break;
case "void":
$message = " fell out of the world";
break;
case "fall":
$message = " hit the ground too hard";
break;
default:
$message = " died";
break;
}
}
$this->server->api->chat->broadcast($data["player"]->username . $message);
return true;
break;
}
}
public function commandHandler($cmd, $params, $issuer, $alias){
$output = "";
switch($cmd){
case "spawnpoint":
if(!($issuer instanceof Player)){
$output .= "Please run this command in-game.\n";
break;
}
if(count($params) === 1 or count($params) === 4){
$target = $this->server->api->player->get(array_shift($params));
}else{
$target = $issuer;
}
if(!($target instanceof Player)){
$output .= "That player cannot be found.\n";
break;
}
if(count($params) === 3){
$spawn = new Position(floatval(array_shift($params)), floatval(array_shift($params)), floatval(array_shift($params)), $issuer->level);
}else{
$spawn = new Position($issuer->entity->x, $issuer->entity->y, $issuer->entity->z, $issuer->entity->level);
}
$target->setSpawn($spawn);
$output .= "Spawnpoint set correctly!\n";
break;
case "spawn":
if(!($issuer instanceof Player)){
$output .= "Please run this command in-game.\n";
break;
}
$spawn = $issuer->getSpawn();
$issuer->teleport($spawn);
break;
case "ping":
if(!($issuer instanceof Player)){
$output .= "Please run this command in-game.\n";
break;
}
$output .= "ping ".round($issuer->getLag(), 2)."ms, packet loss ".round($issuer->getPacketLoss() * 100, 2)."%, ".round($issuer->getBandwidth() / 1024, 2)." KB/s\n";
break;
case "gamemode":
$player = false;
$gms = array(
"0" => SURVIVAL,
"survival" => SURVIVAL,
"s" => SURVIVAL,
"1" => CREATIVE,
"creative" => CREATIVE,
"c" => CREATIVE,
"2" => ADVENTURE,
"adventure" => ADVENTURE,
"a" => ADVENTURE,
"3" => VIEW,
"view" => VIEW,
"viewer" => VIEW,
"spectator" => VIEW,
"v" => VIEW,
);
if($issuer instanceof Player){
$player = $issuer;
}
if(isset($params[1])){
$player = $this->server->api->player->get($params[1]);
}
if(!($player instanceof Player) or !isset($gms[strtolower($params[0])])){
$output .= "Usage: /$cmd <mode> [player]\n";
break;
}
if($player->setGamemode($gms[strtolower($params[0])])){
$output .= "Gamemode of ".$player->username." changed to ".$player->getGamemode()."\n";
}
break;
case "tp":
if(count($params) <= 2 or substr($params[0], 0, 2) === "w:" or substr($params[1], 0, 2) === "w:"){
if((!isset($params[1]) or substr($params[0], 0, 2) === "w:") and isset($params[0]) and ($issuer instanceof Player)){
$name = $issuer->username;
$target = implode(" ", $params);
}elseif(isset($params[1]) and isset($params[0])){
$name = array_shift($params);
$target = implode(" ", $params);
}else{
$output .= "Usage: /$cmd [target player] <destination player>\n";
break;
}
if($this->teleport($name, $target) !== false){
$output .= "\"$name\" teleported to \"$target\"\n";
}else{
$output .= "Couldn't teleport.\n";
}
}else{
if(!isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){
$name = $issuer->username;
$x = $params[0];
$y = $params[1];
$z = $params[2];
}elseif(isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0])){
$name = $params[0];
$x = $params[1];
$y = $params[2];
$z = $params[3];
}else{
$output .= "Usage: /$cmd [player] <x> <y> <z>\n";
break;
}
if($this->tppos($name, $x, $y, $z)){
$output .= "\"$name\" teleported to ($x, $y, $z)\n";
}else{
$output .= "Couldn't teleport.\n";
}
}
break;
case "kill":
case "suicide":
if(!isset($params[0]) and ($issuer instanceof Player)){
$player = $issuer;
}else{
$player = $this->get($params[0]);
}
if($player instanceof Player){
$player->entity->harm(1000, "console", true);
$player->sendChat("Ouch. That looks like it hurt.\n");
}else{
$output .= "Usage: /$cmd [player]\n";
}
break;
case "list":
$output .= "There are ".count($this->server->clients)."/".$this->server->maxClients." players online:\n";
if(count($this->server->clients) == 0){
break;
}
foreach($this->server->clients as $c){
$output .= $c->username.", ";
}
$output = substr($output, 0, -2)."\n";
break;
}
return $output;
}
public function teleport(&$name, &$target){
if(substr($target, 0, 2) === "w:"){
$lv = $this->server->api->level->get(substr($target, 2));
if($lv instanceof Level){
$origin = $this->get($name);
if($origin instanceof Player){
$name = $origin->username;
return $origin->teleport($lv->getSafeSpawn());
}
}else{
return false;
}
}
$player = $this->get($target);
if(($player instanceof Player) and ($player->entity instanceof Entity)){
$target = $player->username;
$origin = $this->get($name);
if($origin instanceof Player){
$name = $origin->username;
return $origin->teleport($player->entity);
}
}
return false;
}
public function tppos(&$name, &$x, &$y, &$z){
$player = $this->get($name);
if(($player instanceof Player) and ($player->entity instanceof Entity)){
$name = $player->username;
$x = $x{0} === "~" ? $player->entity->x + floatval(substr($x, 1)):floatval($x);
$y = $y{0} === "~" ? $player->entity->y + floatval(substr($y, 1)):floatval($y);
$z = $z{0} === "~" ? $player->entity->z + floatval(substr($z, 1)):floatval($z);
$player->teleport(new Vector3($x, $y, $z));
return true;
}
return false;
}
public function get($name, $alike = true){
$name = trim(strtolower($name));
if($name === ""){
return false;
}
$CID = $this->server->query("SELECT ip,port FROM players WHERE name ".($alike === true ? "LIKE '%".$name."%'":"= '".$name."'").";", true);
$CID = PocketMinecraftServer::clientID($CID["ip"], $CID["port"]);
if(isset($this->server->clients[$CID])){
return $this->server->clients[$CID];
}
return false;
}
public function getAll($level = null){
if($level instanceof Level){
$clients = array();
$l = $this->server->query("SELECT EID FROM entities WHERE level = '".$level->getName()."' AND class = '".ENTITY_PLAYER."';");
if($l !== false and $l !== true){
while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
$e = $this->getByEID($e["EID"]);
if($e instanceof Player){
$clients[$e->CID] = $e;
}
}
}
return $clients;
}
return $this->server->clients;
}
public function broadcastPacket(array $players, $id, $data = array()){
$data = new CustomPacketHandler($id, "", $data, true);
$packet = array("raw" => chr($id).$data->raw);
foreach($players as $p){
$p->dataPacket(false, $packet);
}
}
public function getByEID($eid){
$eid = (int) $eid;
$CID = $this->server->query("SELECT ip,port FROM players WHERE EID = '".$eid."';", true);
$CID = PocketMinecraftServer::clientID($CID["ip"], $CID["port"]);
if(isset($this->server->clients[$CID])){
return $this->server->clients[$CID];
}
return false;
}
public function online(){
$o = array();
foreach($this->server->clients as $p){
if($p->auth === true){
$o[] = $p->username;
}
}
return $o;
}
public function add($CID){
if(isset($this->server->clients[$CID])){
$player = $this->server->clients[$CID];
$player->data = $this->getOffline($player->username);
$player->gamemode = $player->data->get("gamemode");
if(($player->level = $this->server->api->level->get($player->data->get("position")["level"])) === false){
$player->level = $this->server->api->level->getDefault();
$player->data->set("position", array(
"level" => $player->level->getName(),
"x" => $player->level->getSpawn()->x,
"y" => $player->level->getSpawn()->y,
"z" => $player->level->getSpawn()->z,
));
}
$this->server->query("INSERT OR REPLACE INTO players (CID, ip, port, name) VALUES (".$player->CID.", '".$player->ip."', ".$player->port.", '".strtolower($player->username)."');");
}
}
public function spawnAllPlayers(Player $player){
foreach($this->getAll() as $p){
if($p !== $player and ($p->entity instanceof Entity)){
$p->entity->spawn($player);
if($p->level !== $player->level){
$player->dataPacket(MC_MOVE_ENTITY_POSROT, array(
"eid" => $p->entity->eid,
"x" => -256,
"y" => 128,
"z" => -256,
"yaw" => 0,
"pitch" => 0,
));
}
}
}
}
public function spawnToAllPlayers(Player $player){
foreach($this->getAll() as $p){
if($p !== $player and ($p->entity instanceof Entity)){
$player->entity->spawn($p);
if($p->level !== $player->level){
$p->dataPacket(MC_MOVE_ENTITY_POSROT, array(
"eid" => $player->entity->eid,
"x" => -256,
"y" => 128,
"z" => -256,
"yaw" => 0,
"pitch" => 0,
));
}
}
}
}
public function remove($CID){
if(isset($this->server->clients[$CID])){
$player = $this->server->clients[$CID];
unset($this->server->clients[$CID]);
$player->close();
if($player->username != "" and ($player->data instanceof Config)){
$this->saveOffline($player->data);
}
$this->server->query("DELETE FROM players WHERE name = '".$player->username."';");
if($player->entity instanceof Entity){
unset($player->entity->player);
unset($player->entity);
}
$this->server->api->entity->remove($player->eid);
$player = null;
unset($player);
}
}
public function getOffline($name){
$iname = strtolower($name);
$default = array(
"caseusername" => $name,
"position" => array(
"level" => $this->server->spawn->level->getName(),
"x" => $this->server->spawn->x,
"y" => $this->server->spawn->y,
"z" => $this->server->spawn->z,
),
"spawn" => array(
"level" => $this->server->spawn->level->getName(),
"x" => $this->server->spawn->x,
"y" => $this->server->spawn->y,
"z" => $this->server->spawn->z,
),
"inventory" => array_fill(0, PLAYER_SURVIVAL_SLOTS, array(AIR, 0, 0)),
"armor" => array_fill(0, 4, array(AIR, 0)),
"gamemode" => $this->server->gamemode,
"health" => 20,
"lastIP" => "",
"lastID" => 0,
);
if(!file_exists(DATA_PATH."players/".$iname.".yml")){
console("[NOTICE] Player data not found for \"".$iname."\", creating new profile");
$data = new Config(DATA_PATH."players/".$iname.".yml", CONFIG_YAML, $default);
$data->save();
}else{
$data = new Config(DATA_PATH."players/".$iname.".yml", CONFIG_YAML, $default);
}
if(($data->get("gamemode") & 0x01) === 1){
$data->set("health", 20);
}
$this->server->handle("player.offline.get", $data);
return $data;
}
public function saveOffline(Config $data){
$this->server->handle("player.offline.save", $data);
$data->save();
}
}

View File

@ -1,208 +0,0 @@
<?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/
*
*
*/
class PluginAPI extends stdClass{
private $server;
private $plugins = array();
public function __construct(){
$this->server = ServerAPI::request();
}
public function getList(){
$list = array();
foreach($this->plugins as $p){
$list[] = $p[1];
}
return $list;
}
public function getInfo($className){
$className = strtolower($className);
if(!isset($this->plugins[$className])){
return false;
}
$plugin = $this->plugins[$className];
return array($plugin[1], get_class_methods($plugin[0]));
}
public function load($file){
if(strtolower(substr($file, -3)) === "pmf"){
$pmf = new PMFPlugin($file);
$info = $pmf->getPluginInfo();
}else{
$content = file_get_contents($file);
$info = strstr($content, "*/", true);
$content = str_repeat(PHP_EOL, substr_count($info, "\n")).substr(strstr($content, "*/"),2);
if(preg_match_all('#([a-zA-Z0-9\-_]*)=([^\r\n]*)#u', $info, $matches) == 0){ //false or 0 matches
console("[ERROR] Failed parsing of ".basename($file));
return false;
}
$info = array();
foreach($matches[1] as $k => $i){
$v = $matches[2][$k];
switch(strtolower($v)){
case "on":
case "true":
case "yes":
$v = true;
break;
case "off":
case "false":
case "no":
$v = false;
break;
}
$info[$i] = $v;
}
$info["code"] = $content;
$info["class"] = trim(strtolower($info["class"]));
}
if(!isset($info["name"]) or !isset($info["version"]) or !isset($info["class"]) or !isset($info["author"])){
console("[ERROR] Failed parsing of ".basename($file));
return false;
}
console("[INFO] Loading plugin \"\x1b[32m".$info["name"]."\x1b[0m\" \x1b[35m".$info["version"]." \x1b[0mby \x1b[36m".$info["author"]."\x1b[0m");
if($info["class"] !== "none" and class_exists($info["class"])){
console("[ERROR] Failed loading plugin: class already exists");
return false;
}
if(eval($info["code"]) === false or ($info["class"] !== "none" and !class_exists($info["class"]))){
console("[ERROR] Failed loading plugin: evaluation error");
return false;
}
$className = $info["class"];
$apiversion = array_map("intval", explode(",", (string) $info["apiversion"]));
if(!in_array((string) CURRENT_API_VERSION, $apiversion)){
console("[WARNING] Plugin \"".$info["name"]."\" may not be compatible with the API (".$info["apiversion"]." != ".CURRENT_API_VERSION.")! It can crash or corrupt the server!");
}
if($info["class"] !== "none"){
$object = new $className($this->server->api, false);
if(!($object instanceof Plugin)){
console("[ERROR] Plugin \"\x1b[36m".$info["name"]."\x1b[0m\" doesn't use the Plugin Interface");
if(method_exists($object, "__destruct")){
$object->__destruct();
}
$object = null;
unset($object);
}else{
$this->plugins[$className] = array($object, $info);
}
}else{
$this->plugins[md5($info["name"])] = array(new DummyPlugin($this->server->api, false), $info);
}
}
public function get(Plugin $plugin){
foreach($this->plugins as &$p){
if($p[0] === $plugin){
return $p;
}
}
return false;
}
public function configPath(Plugin $plugin){
$p = $this->get($plugin);
if($p === false){
return false;
}
$path = DATA_PATH."plugins/".$p[1]["name"]."/";
$this->plugins[$p[1]["class"]][1]["path"] = $path;
@mkdir($path);
return $path;
}
public function createConfig(Plugin $plugin, $default = array()){
$p = $this->get($plugin);
if($p === false){
return false;
}
$path = $this->configPath($plugin);
$cnf = new Config($path."config.yml", CONFIG_YAML, $default);
$cnf->save();
return $path;
}
private function fillDefaults($default, &$yaml){
foreach($default as $k => $v){
if(is_array($v)){
if(!isset($yaml[$k]) or !is_array($yaml[$k])){
$yaml[$k] = array();
}
$this->fillDefaults($v, $yaml[$k]);
}elseif(!isset($yaml[$k])){
$yaml[$k] = $v;
}
}
}
public function readYAML($file){
return Spyc::YAMLLoad(file_get_contents($file));
}
public function writeYAML($file, $data){
return file_put_contents($file, Spyc::YAMLDump($data));
}
public function init(){
$this->server->event("server.start", array($this, "initAll"));
$this->loadAll();
}
public function loadAll(){
$dir = dir(DATA_PATH."plugins/");
while(false !== ($file = $dir->read())){
if($file{0} !== "."){
$ext = strtolower(substr($file, -3));
if($ext === "php" or $ext === "pmf"){
$this->load(DATA_PATH."plugins/" . $file);
}
}
}
}
public function initAll(){
console("[INFO] Starting plugins...");
foreach($this->plugins as $p){
$p[0]->init(); //ARGHHH!!! Plugin loading randomly fails!!
}
}
}
interface Plugin{
public function __construct(ServerAPI $api, $server = false);
public function init();
public function __destruct();
}
class DummyPlugin implements Plugin{
public function __construct(ServerAPI $api, $server = false){
}
public function init(){
}
public function __destruct(){
}
}

View File

@ -1,417 +0,0 @@
<?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/
*
*
*/
class ServerAPI{
public $restart = false;
private static $serverRequest = false;
private $asyncCalls = array();
private $server;
private $config;
private $apiList = array();
private $asyncCnt = 0;
private $rcon;
private $query;
public static function request(){
return self::$serverRequest;
}
public function start(){
return $this->run();
}
public function run(){
$this->load();
return $this->init();
}
public function load(){
@mkdir(DATA_PATH."players/", 0755);
@mkdir(DATA_PATH."worlds/", 0755);
@mkdir(DATA_PATH."plugins/", 0755);
console("[INFO] \x1b[33;1mPocketMine-MP ".MAJOR_VERSION." API #".CURRENT_API_VERSION.", LGPL License", true, true, 0);
console("[INFO] Loading properties...");
$this->config = new Config(DATA_PATH . "server.properties", CONFIG_PROPERTIES, array(
"server-name" => "Minecraft: PE Server",
"description" => "Server made using PocketMine-MP",
"motd" => "Welcome @player to this server!",
"server-ip" => "",
"server-port" => 19132,
"server-type" => "normal",
"memory-limit" => "128M",
"last-update" => false,
"white-list" => false,
"spawn-protection" => 16,
"view-distance" => 10,
"max-players" => 20,
"allow-flight" => false,
"spawn-animals" => true,
"spawn-mobs" => true,
"gamemode" => SURVIVAL,
"hardcore" => false,
"pvp" => true,
"difficulty" => 1,
"generator-settings" => "",
"level-name" => "world",
"level-seed" => "",
"level-type" => "DEFAULT",
"enable-query" => true,
"enable-rcon" => false,
"rcon.password" => substr(base64_encode(Utils::getRandomBytes(20, false)), 3, 10),
"send-usage" => true,
"auto-save" => true,
));
$this->parseProperties();
define("DEBUG", $this->getProperty("debug", 1));
if($this->getProperty("port") !== false){
$this->setProperty("server-port", $this->getProperty("port"));
$this->config->remove("port");
$this->config->remove("invisible");
}
$this->server = new PocketMinecraftServer($this->getProperty("server-name"), $this->getProperty("gamemode"), ($seed = $this->getProperty("level-seed")) != "" ? (int) $seed:false, $this->getProperty("server-port"), ($ip = $this->getProperty("server-ip")) != "" ? $ip:"0.0.0.0");
$this->server->api = $this;
self::$serverRequest = $this->server;
if($this->getProperty("upnp-forwarding") === true){
console("[INFO] [UPnP] Trying to port forward...");
UPnP_PortForward($this->getProperty("server-port"));
}
if($this->getProperty("last-update") === false or ($this->getProperty("last-update") + 3600) < time()){
console("[INFO] Checking for new server version");
console("[INFO] Last check: \x1b[36m".date("Y-m-d H:i:s", $this->getProperty("last-update"))."\x1b[0m");
$info = json_decode(Utils::curl_get("http://www.pocketmine.net/latest"), true);
if($this->server->version->isDev()){
if($info === false or !isset($info["development"])){
console("[ERROR] PocketMine API error");
}else{
$last = $info["development"]["date"];
if($last >= $this->getProperty("last-update") and $this->getProperty("last-update") !== false and GIT_COMMIT != $info["development"]["commit"]){
console("[NOTICE] \x1b[33mA new DEVELOPMENT version of PocketMine-MP has been released");
console("[NOTICE] \x1b[33mVersion \"".$info["development"]["version"]."\" [".substr($info["development"]["commit"], 0, 10)."]");
console("[NOTICE] \x1b[36mGet it at PocketMine.net or ".$info["development"]["download"]);
console("[NOTICE] This message will dissapear after issuing the command \"/update-done\"");
}else{
$this->setProperty("last-update", time());
console("[INFO] \x1b[36mThis is the latest DEVELOPMENT version");
}
}
}else{
if($info === false or !isset($info["stable"])){
console("[ERROR] PocketMine API error");
}else{
$newest = new VersionString(MAJOR_VERSION);
$newestN = $newest->getNumber();
$update = new VersionString($info["stable"]["version"]);
$updateN = $update->getNumber();
if($updateN > $newestN){
console("[NOTICE] \x1b[33mA new STABLE version of PocketMine-MP has been released");
console("[NOTICE] \x1b[36mVersion \"".$info["stable"]["version"]."\" #".$updateN);
console("[NOTICE] Get it at PocketMine.net or ".$info["stable"]["download"]);
console("[NOTICE] This message will dissapear as soon as you update");
}else{
$this->setProperty("last-update", time());
console("[INFO] \x1b[36mThis is the latest STABLE version");
}
}
}
}
$this->loadProperties();
$this->loadAPI("console", "ConsoleAPI");
$this->loadAPI("level", "LevelAPI");
$this->loadAPI("block", "BlockAPI");
$this->loadAPI("chat", "ChatAPI");
$this->loadAPI("ban", "BanAPI");
$this->loadAPI("entity", "EntityAPI");
$this->loadAPI("tile", "TileAPI");
$this->loadAPI("player", "PlayerAPI");
$this->loadAPI("time", "TimeAPI");
foreach($this->apiList as $ob){
if(is_callable(array($ob, "init"))){
$ob->init(); //Fails sometimes!!!
}
}
$this->loadAPI("plugin", "PluginAPI"); //fix :(
$this->plugin->init();
}
public function async(callable $callable, $params = array(), $remove = false){
$cnt = $this->asyncCnt++;
$this->asyncCalls[$cnt] = new Async($callable, $params);
return $remove === true ? $this->getAsync($cnt):$cnt;
}
public function getAsync($id){
if(!isset($this->asyncCalls[$id])){
return false;
}
$ob = $this->asyncCalls[$id];
unset($this->asyncCalls[$id]);
return $ob;
}
public function autoSave(){
console("[DEBUG] Saving....", true, true, 2);
$this->server->api->level->saveAll();
}
public function sendUsage(){
console("[DEBUG] Sending usage data...", true, true, 2);
$plist = "";
foreach($this->plugin->getList() as $p){
$plist .= str_replace(array(";", ":"), "", $p["name"]).":".str_replace(array(";", ":"), "", $p["version"]).";";
}
$this->asyncOperation(ASYNC_CURL_POST, array(
"url" => "http://stats.pocketmine.net/usage.php",
"data" => array(
"serverid" => $this->server->serverID,
"port" => $this->server->port,
"os" => Utils::getOS(),
"memory_total" => $this->getProperty("memory-limit"),
"memory_usage" => memory_get_usage(true),
"php_version" => PHP_VERSION,
"version" => MAJOR_VERSION,
"mc_version" => CURRENT_MINECRAFT_VERSION,
"protocol" => CURRENT_PROTOCOL,
"online" => count($this->server->clients),
"max" => $this->server->maxClients,
"plugins" => $plist,
),
), NULL);
}
public function __destruct(){
foreach($this->apiList as $i => $ob){
if(method_exists($ob, "__destruct")){
$ob->__destruct();
unset($this->apiList[$i]);
}
}
}
private function loadProperties(){
if(($memory = str_replace("B", "", strtoupper($this->getProperty("memory-limit")))) !== false){
$value = array("M" => 1, "G" => 1024);
$real = ((int) substr($memory, 0, -1)) * $value[substr($memory, -1)];
if($real < 128){
console("[WARNING] PocketMine-MP may not work right with less than 128MB of RAM", true, true, 0);
}
@ini_set("memory_limit", $memory);
}else{
$this->setProperty("memory-limit", "128M");
}
if($this->server instanceof PocketMinecraftServer){
$this->server->setType($this->getProperty("server-type"));
$this->server->maxClients = $this->getProperty("max-players");
$this->server->description = $this->getProperty("description");
$this->server->motd = $this->getProperty("motd");
$this->server->gamemode = $this->getProperty("gamemode");
$this->server->difficulty = $this->getProperty("difficulty");
$this->server->whitelist = $this->getProperty("white-list");
$this->server->reloadConfig();
}
}
private function writeProperties(){
$this->config->save();
}
private function parseProperties(){
foreach($this->config->getAll() as $n => $v){
switch($n){
case "last-update":
if($v === false){
$v = time();
}else{
$v = (int) $v;
}
break;
case "gamemode":
case "max-players":
case "server-port":
case "debug":
case "difficulty":
$v = (int) $v;
break;
case "server-id":
if($v !== false){
$v = preg_match("/[^0-9\-]/", $v) > 0 ? Utils::readInt(substr(md5($v, true), 0, 4)):$v;
}
break;
}
$this->config->set($n, $v);
}
if($this->getProperty("hardcore") == 1 and $this->getProperty("difficulty") < 3){
$this->setProperty("difficulty", 3);
}
}
public function init(){
if($this->getProperty("send-usage") !== false){
$this->server->schedule(6000, array($this, "sendUsage"), array(), true); //Send the info after 5 minutes have passed
$this->sendUsage();
}
if($this->getProperty("auto-save") === true){
$this->server->schedule(18000, array($this, "autoSave"), array(), true);
}
if(!defined("NO_THREADS") and $this->getProperty("enable-rcon") === true){
$this->rcon = new RCON($this->getProperty("rcon.password", ""), $this->getProperty("rcon.port", $this->getProperty("server-port")), ($ip = $this->getProperty("server-ip")) != "" ? $ip:"0.0.0.0", $this->getProperty("rcon.threads", 1), $this->getProperty("rcon.clients-per-thread", 50));
}
if($this->getProperty("enable-query") === true){
$this->query = new Query();
}
CraftingRecipes::init();
$this->server->init();
unregister_tick_function(array($this->server, "tick"));
$this->console->__destruct();
if($this->rcon instanceof RCON){
$this->rcon->stop();
}
$this->__destruct();
if($this->getProperty("upnp-forwarding") === true ){
console("[INFO] [UPnP] Removing port forward...");
UPnP_RemovePortForward($this->getProperty("server-port"));
}
return $this->restart;
}
/*-------------------------------------------------------------*/
public function asyncOperation($t, $d, $c = null){
return $this->server->asyncOperation($t, $d, $c);
}
public function addHandler($e, $c, $p = 5){
return $this->server->addHandler($e, $c, $p);
}
public function dhandle($e, $d){
return $this->server->handle($e, $d);
}
public function handle($e, &$d){
return $this->server->handle($e, $d);
}
public function schedule($t, $c, $d, $r = false, $e = "server.schedule"){
return $this->server->schedule($t, $c, $d, $r, $e);
}
public function event($e, $d){
return $this->server->event($e, $d);
}
public function trigger($e, $d){
return $this->server->trigger($e, $d);
}
public function deleteEvent($id){
return $this->server->deleteEvent($id);
}
public function getProperties(){
return $this->config->getAll();
}
public function getProperty($name, $default = false){
if(($v = arg($name)) !== false){ //Allow for command-line arguments
switch(strtolower(trim($v))){
case "on":
case "true":
case "yes":
$v = true;
break;
case "off":
case "false":
case "no":
$v = false;
break;
}
switch($name){
case "last-update":
if($v === false){
$v = time();
}else{
$v = (int) $v;
}
break;
case "gamemode":
case "max-players":
case "server-port":
case "debug":
case "difficulty":
case "time-per-second":
$v = (int) $v;
break;
case "server-id":
if($v !== false){
$v = preg_match("/[^0-9\-]/", $v) > 0 ? Utils::readInt(substr(md5($v, true), 0, 4)):$v;
}
break;
}
return $v;
}
return ($this->config->exists($name) ? $this->config->get($name):$default);
}
public function setProperty($name, $value){
$this->config->set($name, $value);
$this->writeProperties();
$this->loadProperties();
}
public function getList(){
return $this->apiList;
}
public function loadAPI($name, $class, $dir = false){
if(isset($this->$name)){
return false;
}elseif(!class_exists($class)){
$internal = false;
if($dir === false){
$internal = true;
$dir = FILE_PATH."src/API/";
}
$file = $dir.$class.".php";
if(!file_exists($file)){
console("[ERROR] API ".$name." [".$class."] in ".$dir." doesn't exist", true, true, 0);
return false;
}
require_once($file);
}else{
$internal = true;
}
$this->$name = new $class();
$this->apiList[] = $this->$name;
console("[".($internal === true ? "INTERNAL":"DEBUG")."] API \x1b[36m".$name."\x1b[0m [\x1b[30;1m".$class."\x1b[0m] loaded", true, true, ($internal === true ? 3:2));
}
}

View File

@ -1,116 +0,0 @@
<?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/
*
*
*/
class TileAPI{
private $server;
private $tiles;
private $tCnt = 1;
function __construct(){
$this->tiles = array();
$this->server = ServerAPI::request();
}
public function get(Position $pos){
$tile = $this->server->query("SELECT * FROM tiles WHERE level = '".$pos->level->getName()."' AND x = {$pos->x} AND y = {$pos->y} AND z = {$pos->z};", true);
if($tile !== false and $tile !== true and ($tile = $this->getByID($tile["ID"])) !== false){
return $tile;
}
return false;
}
public function getByID($id){
if($id instanceof Tile){
return $id;
}elseif(isset($this->tiles[$id])){
return $this->tiles[$id];
}
return false;
}
public function init(){
}
public function getAll($level = null){
if($level instanceof Level){
$tiles = array();
$l = $this->server->query("SELECT ID FROM tiles WHERE level = '".$level->getName()."';");
if($l !== false and $l !== true){
while(($t = $l->fetchArray(SQLITE3_ASSOC)) !== false){
$t = $this->getByID($t["ID"]);
if($t instanceof Tile){
$tiles[$t->id] = $t;
}
}
}
return $tiles;
}
return $this->tiles;
}
public function add(Level $level, $class, $x, $y, $z, $data = array()){
$id = $this->tCnt++;
$this->tiles[$id] = new Tile($level, $id, $class, $x, $y, $z, $data);
$this->spawnToAll($this->tiles[$id]);
return $this->tiles[$id];
}
public function addSign(Level $level, $x, $y, $z, $lines = array("", "", "", "")){
return $this->add($level, TILE_SIGN, $x, $y, $z, $data = array(
"id" => "Sign",
"x" => $x,
"y" => $y,
"z" => $z,
"Text1" => $lines[0],
"Text2" => $lines[1],
"Text3" => $lines[2],
"Text4" => $lines[3],
));
}
public function spawnToAll(Tile $t){
foreach($this->server->api->player->getAll($t->level) as $player){
if($player->eid !== false){
$t->spawn($player);
}
}
}
public function spawnAll(Player $player){
foreach($this->getAll($player->level) as $t){
$t->spawn($player);
}
}
public function remove($id){
if(isset($this->tiles[$id])){
$t = $this->tiles[$id];
$this->tiles[$id] = null;
unset($this->tiles[$id]);
$t->closed = true;
$t->close();
$this->server->query("DELETE FROM tiles WHERE ID = ".$id.";");
$this->server->api->dhandle("tile.remove", $t);
$t = null;
unset($t);
}
}
}

View File

@ -1,131 +0,0 @@
<?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/
*
*
*/
class TimeAPI{
var $phases = array(
"day" => 0,
"sunset" => 9500,
"night" => 10900,
"sunrise" => 17800,
);
private $server;
function __construct(){
$this->server = ServerAPI::request();
}
public function init(){
$this->server->api->console->register("time", "<check|set|add> [time]", array($this, "commandHandler"));
}
public function commandHandler($cmd, $params, $issuer, $alias){
$output = "";
switch($cmd){
case "time":
$level = false;
if($issuer instanceof Player){
$level = $issuer->level;
}
$p = strtolower(array_shift($params));
switch($p){
case "check":
$output .= "Time: ".$this->getDate($level).", ".$this->getPhase($level)." (".$this->get(true, $level).")\n";
break;
case "add":
$output .= "Set the time to ".$this->add(array_shift($params), $level)."\n";
break;
case "set":
$output .= "Set the time to ".$this->set(array_shift($params), $level)."\n";
break;
case "sunrise":
case "day":
case "sunset":
case "night":
$output .= "Set the time to ".$this->set($p, $level)."\n";
break;
default:
$output .= "Usage: /time <check|set|add> [time]\n";
break;
}
break;
}
return $output;
}
public function night(){
return $this->set("night");
}
public function day(){
return $this->set("day");
}
public function sunrise(){
return $this->set("sunrise");
}
public function sunset(){
return $this->set("sunset");
}
public function get($raw = false, $level = false){
if(!($level instanceof Level)){
$level = $this->server->api->level->getDefault();
}
return $raw === true ? $level->getTime():abs($level->getTime()) % 19200;
}
public function add($time, $level = false){
if(!($level instanceof Level)){
$level = $this->server->api->level->getDefault();
}
$level->setTime($level->getTime() + (int) $time);
}
public function getDate($time = false){
$time = !is_integer($time) ? $this->get(false, $time):$time;
return str_pad(strval((floor($time /800) + 6) % 24), 2, "0", STR_PAD_LEFT).":".str_pad(strval(floor(($time % 800) / 13.33)), 2, "0", STR_PAD_LEFT);
}
public function getPhase($time = false){
$time = !is_integer($time) ? $this->get(false, $time):$time;
if($time < $this->phase["sunset"]){
$time = "day";
}elseif($time < $this->phase["night"]){
$time = "sunset";
}elseif($time < $this->phase["sunrise"]){
$time = "night";
}else{
$time = "sunrise";
}
return $time;
}
public function set($time, $level = false){
if(!($level instanceof Level)){
$level = $this->server->api->level->getDefault();
}
if(is_string($time) and isset($this->phases[$time])){
$level->setTime($this->phases[$time]);
}else{
$level->setTime((int) $time);
}
return $level->getTime();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,676 +0,0 @@
<?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/
*
*
*/
class PocketMinecraftServer{
public $tCnt;
public $serverID, $interface, $database, $version, $invisible, $api, $tickMeasure, $preparedSQL, $seed, $gamemode, $name, $maxClients, $clients, $eidCnt, $custom, $description, $motd, $port, $saveEnabled;
private $serverip, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick, $ticks, $memoryStats, $async = array(), $asyncID = 0;
private function load(){
$this->version = new VersionString();
if(defined("DEBUG") and DEBUG >= 0){
@cli_set_process_title("PocketMine-MP ".MAJOR_VERSION);
}
if($this->version->isDev()){
console("[INFO] \x1b[31;1mThis is a Development version");
}
console("[INFO] Starting server for Minecraft: PE \x1b[36;1m".CURRENT_MINECRAFT_VERSION."\x1b[0m #".CURRENT_PROTOCOL." at ".$this->serverip.":".$this->port);
define("BOOTUP_RANDOM", Utils::getRandomBytes(16));
$this->serverID = $this->serverID === false ? Utils::readLong(Utils::getRandomBytes(8, false)):$this->serverID;
$this->seed = $this->seed === false ? Utils::readInt(Utils::getRandomBytes(4, false)):$this->seed;
$this->startDatabase();
$this->api = false;
$this->tCnt = 1;
$this->events = array();
$this->eventsID = array();
$this->handlers = array();
$this->invisible = false;
$this->levelData = false;
$this->difficulty = 1;
$this->tiles = array();
$this->entities = array();
$this->custom = array();
$this->evCnt = 1;
$this->handCnt = 1;
$this->eidCnt = 1;
$this->maxClients = 20;
$this->schedule = array();
$this->scheduleCnt = 1;
$this->description = "";
$this->whitelist = false;
$this->memoryStats = array();
$this->clients = array();
$this->spawn = false;
$this->saveEnabled = true;
$this->tickMeasure = array_fill(0, 40, 0);
$this->setType("normal");
$this->interface = new MinecraftInterface($this, "255.255.255.255", $this->port, true, false, $this->serverip);
$this->reloadConfig();
$this->stop = false;
$this->ticks = 0;
if(!defined("NO_THREADS")){
$this->asyncThread = new AsyncMultipleQueue();
}
}
function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){
$this->port = (int) $port;
$this->doTick = true;
$this->gamemode = (int) $gamemode;
$this->name = $name;
$this->motd = "Welcome to ".$name;
$this->serverID = false;
$this->seed = $seed;
$this->serverip = $serverip;
$this->load();
}
public function getTPS(){
$v = array_values($this->tickMeasure);
$tps = 40 / ($v[39] - $v[0]);
return round($tps, 4);
}
public function titleTick(){
$time = microtime(true);
if(defined("DEBUG") and DEBUG >= 0 and ENABLE_ANSI === true){
echo "\x1b]0;PocketMine-MP ".MAJOR_VERSION." | Online ". count($this->clients)."/".$this->maxClients." | RAM ".round((memory_get_usage() / 1024) / 1024, 2)."MB | U ".round(($this->interface->bandwidth[1] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2)." D ".round(($this->interface->bandwidth[0] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2)." kB/s | TPS ".$this->getTPS()."\x07";
}
$this->interface->bandwidth = array(0, 0, $time);
}
public function loadEvents(){
if(ENABLE_ANSI === true){
$this->schedule(30, array($this, "titleTick"), array(), true);
}
$this->schedule(20 * 15, array($this, "checkTicks"), array(), true);
$this->schedule(20 * 60, array($this, "checkMemory"), array(), true);
$this->schedule(20, array($this, "asyncOperationChecker"), array(), true);
}
public function checkTicks(){
if($this->getTPS() < 12){
console("[WARNING] Can't keep up! Is the server overloaded?");
}
}
public function checkMemory(){
$info = $this->debugInfo();
$data = $info["memory_usage"].",".$info["players"].",".$info["entities"];
$i = count($this->memoryStats) - 1;
if($i < 0 or $this->memoryStats[$i] !== $data){
$this->memoryStats[] = $data;
}
}
public function startDatabase(){
$this->preparedSQL = new stdClass();
$this->preparedSQL->entity = new stdClass();
$this->database = new SQLite3(":memory:");
$this->query("PRAGMA journal_mode = OFF;");
$this->query("PRAGMA encoding = \"UTF-8\";");
$this->query("PRAGMA secure_delete = OFF;");
$this->query("CREATE TABLE players (CID INTEGER PRIMARY KEY, EID NUMERIC, ip TEXT, port NUMERIC, name TEXT UNIQUE COLLATE NOCASE);");
$this->query("CREATE TABLE entities (EID INTEGER PRIMARY KEY, level TEXT, type NUMERIC, class NUMERIC, hasUpdate NUMERIC, name TEXT, x NUMERIC, y NUMERIC, z NUMERIC, yaw NUMERIC, pitch NUMERIC, health NUMERIC);");
$this->query("CREATE TABLE tiles (ID INTEGER PRIMARY KEY, level TEXT, class TEXT, x NUMERIC, y NUMERIC, z NUMERIC, spawnable NUMERIC);");
$this->query("CREATE TABLE actions (ID INTEGER PRIMARY KEY, interval NUMERIC, last NUMERIC, code TEXT, repeat NUMERIC);");
$this->query("CREATE TABLE handlers (ID INTEGER PRIMARY KEY, name TEXT, priority NUMERIC);");
$this->query("CREATE TABLE blockUpdates (level TEXT, x INTEGER, y INTEGER, z INTEGER, type INTEGER, delay NUMERIC);");
$this->query("CREATE TABLE recipes (id INTEGER PRIMARY KEY, type NUMERIC, recipe TEXT);");
$this->query("PRAGMA synchronous = OFF;");
$this->preparedSQL->selectHandlers = $this->database->prepare("SELECT DISTINCT ID FROM handlers WHERE name = :name ORDER BY priority DESC;");
$this->preparedSQL->selectActions = $this->database->prepare("SELECT ID,code,repeat FROM actions WHERE last <= (:time - interval);");
$this->preparedSQL->updateAction = $this->database->prepare("UPDATE actions SET last = :time WHERE ID = :id;");
$this->preparedSQL->entity->setPosition = $this->database->prepare("UPDATE entities SET x = :x, y = :y, z = :z, pitch = :pitch, yaw = :yaw WHERE EID = :eid ;");
$this->preparedSQL->entity->setLevel = $this->database->prepare("UPDATE entities SET level = :level WHERE EID = :eid ;");
}
public function query($sql, $fetch = false){
$result = $this->database->query($sql) or console("[ERROR] [SQL Error] ".$this->database->lastErrorMsg().". Query: ".$sql, true, true, 0);
if($fetch === true and ($result instanceof SQLite3Result)){
$result = $result->fetchArray(SQLITE3_ASSOC);
}
return $result;
}
public function reloadConfig(){
}
public function debugInfo($console = false){
$info = array();
$info["tps"] = $this->getTPS();
$info["memory_usage"] = round((memory_get_usage() / 1024) / 1024, 2)."MB";
$info["memory_peak_usage"] = round((memory_get_peak_usage() / 1024) / 1024, 2)."MB";
$info["entities"] = $this->query("SELECT count(EID) as count FROM entities;", true);
$info["entities"] = $info["entities"]["count"];
$info["players"] = $this->query("SELECT count(CID) as count FROM players;", true);
$info["players"] = $info["players"]["count"];
$info["events"] = count($this->eventsID);
$info["handlers"] = $this->query("SELECT count(ID) as count FROM handlers;", true);
$info["handlers"] = $info["handlers"]["count"];
$info["actions"] = $this->query("SELECT count(ID) as count FROM actions;", true);
$info["actions"] = $info["actions"]["count"];
$info["garbage"] = gc_collect_cycles();
$this->handle("server.debug", $info);
if($console === true){
console("[DEBUG] TPS: ".$info["tps"].", Memory usage: ".$info["memory_usage"]." (Peak ".$info["memory_peak_usage"]."), Entities: ".$info["entities"].", Events: ".$info["events"].", Handlers: ".$info["handlers"].", Actions: ".$info["actions"].", Garbage: ".$info["garbage"], true, true, 2);
}
return $info;
}
public function close($reason = "server stop"){
if($this->stop !== true){
if(is_int($reason)){
$reason = "signal stop";
}
if(($this->api instanceof ServerAPI) === true){
if(($this->api->chat instanceof ChatAPI) === true){
$this->api->chat->broadcast("Stopping server...");
}
}
$this->stop = true;
$this->trigger("server.close", $reason);
$this->interface->close();
if(!defined("NO_THREADS")){
@$this->asyncThread->stop = true;
}
}
}
public function setType($type = "normal"){
switch(trim(strtolower($type))){
case "normal":
case "demo":
$this->serverType = "MCCPP;Demo;";
break;
case "minecon":
$this->serverType = "MCCPP;MINECON;";
break;
}
}
public function asyncOperation($type, array $data, callable $callable = null){
if(defined("NO_THREADS")){
return false;
}
$d = "";
$type = (int) $type;
switch($type){
case ASYNC_CURL_GET:
$d .= Utils::writeShort(strlen($data["url"])).$data["url"].(isset($data["timeout"]) ? Utils::writeShort($data["timeout"]) : Utils::writeShort(10));
break;
case ASYNC_CURL_POST:
$d .= Utils::writeShort(strlen($data["url"])).$data["url"].(isset($data["timeout"]) ? Utils::writeShort($data["timeout"]) : Utils::writeShort(10));
$d .= Utils::writeShort(count($data["data"]));
foreach($data["data"] as $key => $value){
$d .= Utils::writeShort(strlen($key)).$key . Utils::writeInt(strlen($value)).$value;
}
break;
default:
return false;
}
$ID = $this->asyncID++;
$this->async[$ID] = $callable;
$this->asyncThread->input .= Utils::writeInt($ID).Utils::writeShort($type).$d;
return $ID;
}
public function asyncOperationChecker(){
if(defined("NO_THREADS")){
return false;
}
if(isset($this->asyncThread->output{5})){
$offset = 0;
$ID = Utils::readInt(substr($this->asyncThread->output, $offset, 4));
$offset += 4;
$type = Utils::readShort(substr($this->asyncThread->output, $offset, 2));
$offset += 2;
$data = array();
switch($type){
case ASYNC_CURL_GET:
case ASYNC_CURL_POST:
$len = Utils::readInt(substr($this->asyncThread->output, $offset, 4));
$offset += 4;
$data["result"] = substr($this->asyncThread->output, $offset, $len);
$offset += $len;
break;
}
$this->asyncThread->output = substr($this->asyncThread->output, $offset);
if(isset($this->async[$ID]) and $this->async[$ID] !== null and is_callable($this->async[$ID])){
if(is_array($this->async[$ID])){
$method = $this->async[$ID][1];
$result = $this->async[$ID][0]->$method($data, $type, $ID);
}else{
$result = $this->async[$ID]($data, $type, $ID);
}
}
unset($this->async[$ID]);
}
}
public function addHandler($event,callable $callable, $priority = 5){
if(!is_callable($callable)){
return false;
}elseif(isset(Deprecation::$events[$event])){
$sub = "";
if(Deprecation::$events[$event] !== false){
$sub = " Substitute \"".Deprecation::$events[$event]."\" found.";
}
console("[ERROR] Event \"$event\" has been deprecated.$sub [Adding handle to ".(is_array($callable) ? get_class($callable[0])."::".$callable[1]:$callable)."]");
}
$priority = (int) $priority;
$hnid = $this->handCnt++;
$this->handlers[$hnid] = $callable;
$this->query("INSERT INTO handlers (ID, name, priority) VALUES (".$hnid.", '".str_replace("'", "\\'", $event)."', ".$priority.");");
console("[INTERNAL] New handler ".(is_array($callable) ? get_class($callable[0])."::".$callable[1]:$callable)." to special event ".$event." (ID ".$hnid.")", true, true, 3);
return $hnid;
}
public function dhandle($e, $d){
return $this->handle($e, $d);
}
public function handle($event, &$data){
$this->preparedSQL->selectHandlers->reset();
$this->preparedSQL->selectHandlers->clear();
$this->preparedSQL->selectHandlers->bindValue(":name", $event, SQLITE3_TEXT);
$handlers = $this->preparedSQL->selectHandlers->execute();
$result = null;
if($handlers instanceof SQLite3Result){
$call = array();
while(($hn = $handlers->fetchArray(SQLITE3_ASSOC)) !== false){
$call[(int) $hn["ID"]] = true;
}
$handlers->finalize();
foreach($call as $hnid => $boolean){
if($result !== false and $result !== true){
$called[$hnid] = true;
$handler = $this->handlers[$hnid];
if(is_array($handler)){
$method = $handler[1];
$result = $handler[0]->$method($data, $event);
}else{
$result = $handler($data, $event);
}
}else{
break;
}
}
}elseif(isset(Deprecation::$events[$event])){
$sub = "";
if(Deprecation::$events[$event] !== false){
$sub = " Substitute \"".Deprecation::$events[$event]."\" found.";
}
console("[ERROR] Event \"$event\" has been deprecated.$sub [Handler]");
}
if($result !== false){
$this->trigger($event, $data);
}
return $result;
}
public function eventHandler($data, $event){
switch($event){
}
}
public function getGamemode(){
switch($this->gamemode){
case SURVIVAL:
return "survival";
case CREATIVE:
return "creative";
case ADVENTURE:
return "adventure";
case VIEW:
return "view";
}
}
public function init(){
register_tick_function(array($this, "tick"));
console("[INFO] Starting internal ticker calculation");
$t = 0;
while(true){
switch($t){
case 0:
declare(ticks=100);
break;
case 1:
declare(ticks=60);
break;
case 2:
declare(ticks=40);
break;
case 3:
declare(ticks=30);
break;
case 4:
declare(ticks=20);
break;
case 5:
declare(ticks=15);
break;
default:
declare(ticks=10);
break;
}
if($t > 5){
break;
}
$this->ticks = 0;
while($this->ticks < 20){
usleep(1);
}
if($this->getTPS() < 19.5){
++$t;
}else{
break;
}
}
$this->loadEvents();
register_shutdown_function(array($this, "dumpError"));
register_shutdown_function(array($this, "close"));
if(function_exists("pcntl_signal")){
pcntl_signal(SIGTERM, array($this, "close"));
pcntl_signal(SIGINT, array($this, "close"));
pcntl_signal(SIGHUP, array($this, "close"));
}
console("[INFO] Default game type: ".strtoupper($this->getGamemode()));
$this->trigger("server.start", microtime(true));
console('[INFO] Done ('.round(microtime(true) - START_TIME, 3).'s)! For help, type "help" or "?"');
$this->process();
}
public function dumpError(){
if($this->stop === true){
return;
}
console("[ERROR] An Unrecovereable has ocurred and the server has Crashed. Creating an Error Dump");
$dump = "```\r\n# PocketMine-MP Error Dump ".date("D M j H:i:s T Y")."\r\n";
$er = error_get_last();
$dump .= "Error: ".var_export($er, true)."\r\n\r\n";
$dump .= "Code: \r\n";
$file = @file($er["file"], FILE_IGNORE_NEW_LINES);
for($l = max(0, $er["line"] - 10); $l < $er["line"] + 10; ++$l){
$dump .= "[".($l + 1)."] ".@$file[$l]."\r\n";
}
$dump .= "\r\n\r\n";
$version = new VersionString();
$dump .= "PM Version: ".$version." #".$version->getNumber()." [Protocol ".CURRENT_PROTOCOL."]\r\n";
$dump .= "Commit: ".GIT_COMMIT."\r\n";
$dump .= "uname -a: ".php_uname("a")."\r\n";
$dump .= "PHP Version: " .phpversion()."\r\n";
$dump .= "Zend version: ".zend_version()."\r\n";
$dump .= "OS : " .PHP_OS.", ".Utils::getOS()."\r\n";
$dump .= "Debug Info: ".var_export($this->debugInfo(false), true)."\r\n\r\n\r\n";
global $arguments;
$dump .= "Parameters: ".var_export($arguments, true)."\r\n\r\n\r\n";
$p = $this->api->getProperties();
if($p["rcon.password"] != ""){
$p["rcon.password"] = "******";
}
$dump .= "server.properties: ".var_export($p, true)."\r\n\r\n\r\n";
if($this->api->plugin instanceof PluginAPI){
$plist = $this->api->plugin->getList();
$dump .= "Loaded plugins:\r\n";
foreach($plist as $p){
$dump .= $p["name"]." ".$p["version"]." by ".$p["author"]."\r\n";
}
$dump .= "\r\n\r\n";
}
$dump .= "Loaded Modules: ".var_export(get_loaded_extensions(), true)."\r\n";
$dump .= "Memory Usage Tracking: \r\n".chunk_split(base64_encode(gzdeflate(implode(";", $this->memoryStats), 9)))."\r\n";
ob_start();
phpinfo();
$dump .= "\r\nphpinfo(): \r\n".chunk_split(base64_encode(gzdeflate(ob_get_contents(), 9)))."\r\n";
ob_end_clean();
$dump .= "\r\n```";
$name = "Error_Dump_".date("D_M_j-H.i.s-T_Y");
logg($dump, $name, true, 0, true);
console("[ERROR] Please submit the \"{$name}.log\" file to the Bug Reporting page. Give as much info as you can.", true, true, 0);
}
public function tick(){
$time = microtime(true);
if($this->lastTick <= ($time - 0.05)){
$this->tickMeasure[] = $this->lastTick = $time;
unset($this->tickMeasure[key($this->tickMeasure)]);
++$this->ticks;
$this->tickerFunction($time);
}
}
public static function clientID($ip, $port){
//faster than string indexes in PHP
return crc32($ip . $port) ^ crc32($port . $ip . BOOTUP_RANDOM);
}
public function packetHandler($packet){
$data =& $packet["data"];
$CID = PocketMinecraftServer::clientID($packet["ip"], $packet["port"]);
if(isset($this->clients[$CID])){
$this->clients[$CID]->handlePacket($packet["pid"], $data);
}else{
if($this->handle("server.noauthpacket", $packet) === false){
return;
}
switch($packet["pid"]){
case 0x01:
case 0x02:
if($this->invisible === true){
$this->send(0x1c, array(
$data[0],
$this->serverID,
RAKNET_MAGIC,
$this->serverType,
), false, $packet["ip"], $packet["port"]);
break;
}
if(!isset($this->custom["times_".$CID])){
$this->custom["times_".$CID] = 0;
}
$ln = 15;
if($this->description == "" or substr($this->description, -1) != " "){
$this->description .= " ";
}
$txt = substr($this->description, $this->custom["times_".$CID], $ln);
$txt .= substr($this->description, 0, $ln - strlen($txt));
$this->send(0x1c, array(
$data[0],
$this->serverID,
RAKNET_MAGIC,
$this->serverType. $this->name . " [".count($this->clients)."/".$this->maxClients."] ".$txt,
), false, $packet["ip"], $packet["port"]);
$this->custom["times_".$CID] = ($this->custom["times_".$CID] + 1) % strlen($this->description);
break;
case 0x05:
$version = $data[1];
$size = strlen($data[2]);
if($version !== CURRENT_STRUCTURE){
console("[DEBUG] Incorrect structure #$version from ".$packet["ip"].":".$packet["port"], true, true, 2);
$this->send(0x1a, array(
CURRENT_STRUCTURE,
RAKNET_MAGIC,
$this->serverID,
), false, $packet["ip"], $packet["port"]);
}else{
$this->send(0x06, array(
RAKNET_MAGIC,
$this->serverID,
0,
strlen($packet["raw"]),
), false, $packet["ip"], $packet["port"]);
}
break;
case 0x07:
if($this->invisible === true){
break;
}
$port = $data[2];
$MTU = $data[3];
$clientID = $data[4];
if(count($this->clients) < $this->maxClients){
$this->clients[$CID] = new Player($clientID, $packet["ip"], $packet["port"], $MTU); //New Session!
$this->send(0x08, array(
RAKNET_MAGIC,
$this->serverID,
$this->port,
$data[3],
0,
), false, $packet["ip"], $packet["port"]);
}
break;
}
}
}
public function send($pid, $data = array(), $raw = false, $dest = false, $port = false){
return $this->interface->writePacket($pid, $data, $raw, $dest, $port);
}
public function process(){
$lastLoop = 0;
while($this->stop === false){
$packet = $this->interface->readPacket();
if($packet !== false){
$this->packetHandler($packet);
$lastLoop = 0;
}else{
++$lastLoop;
if($lastLoop < 16){
usleep(1);
}elseif($lastLoop >= 128){
usleep(100);
}elseif($lastLoop >= 256){
usleep(512);
}
}
}
}
public function trigger($event, $data = ""){
if(isset($this->events[$event])){
foreach($this->events[$event] as $evid => $ev){
if(!is_callable($ev)){
$this->deleteEvent($evid);
continue;
}
if(is_array($ev)){
$method = $ev[1];
$ev[0]->$method($data, $event);
}else{
$ev($data, $event);
}
}
}elseif(isset(Deprecation::$events[$event])){
$sub = "";
if(Deprecation::$events[$event] !== false){
$sub = " Substitute \"".Deprecation::$events[$event]."\" found.";
}
console("[ERROR] Event \"$event\" has been deprecated.$sub [Trigger]");
}
}
public function schedule($ticks, callable $callback, $data = array(), $repeat = false, $eventName = "server.schedule"){
if(!is_callable($callback)){
return false;
}
$chcnt = $this->scheduleCnt++;
$this->schedule[$chcnt] = array($callback, $data, $eventName);
$this->query("INSERT INTO actions (ID, interval, last, repeat) VALUES(".$chcnt.", ".($ticks / 20).", ".microtime(true).", ".(((bool) $repeat) === true ? 1:0).");");
return $chcnt;
}
public function tickerFunction($time){
//actions that repeat every x time will go here
$this->preparedSQL->selectActions->reset();
$this->preparedSQL->selectActions->bindValue(":time", $time, SQLITE3_FLOAT);
$actions = $this->preparedSQL->selectActions->execute();
if($actions instanceof SQLite3Result){
while(($action = $actions->fetchArray(SQLITE3_ASSOC)) !== false){
$cid = $action["ID"];
$this->preparedSQL->updateAction->reset();
$this->preparedSQL->updateAction->bindValue(":time", $time, SQLITE3_FLOAT);
$this->preparedSQL->updateAction->bindValue(":id", $cid, SQLITE3_INTEGER);
$this->preparedSQL->updateAction->execute();
$schedule = $this->schedule[$cid];
if(!is_callable($schedule[0])){
$return = false;
}else{
$return = call_user_func($schedule[0], $schedule[1], $schedule[2]);
}
if($action["repeat"] == 0 or $return === false){
$this->query("DELETE FROM actions WHERE ID = ".$action["ID"].";");
$this->schedule[$cid] = null;
unset($this->schedule[$cid]);
}
}
$actions->finalize();
}
}
public function event($event,callable $func){
if(!is_callable($func)){
return false;
}elseif(isset(Deprecation::$events[$event])){
$sub = "";
if(Deprecation::$events[$event] !== false){
$sub = " Substitute \"".Deprecation::$events[$event]."\" found.";
}
console("[ERROR] Event \"$event\" has been deprecated.$sub [Attach to ".(is_array($func) ? get_class($func[0])."::".$func[1]:$func)."]");
}
$evid = $this->evCnt++;
if(!isset($this->events[$event])){
$this->events[$event] = array();
}
$this->events[$event][$evid] = $func;
$this->eventsID[$evid] = $event;
console("[INTERNAL] Attached ".(is_array($func) ? get_class($func[0])."::".$func[1]:$func)." to event ".$event." (ID ".$evid.")", true, true, 3);
return $evid;
}
public function deleteEvent($id){
$id = (int) $id;
if(isset($this->eventsID[$id])){
$ev = $this->eventsID[$id];
$this->eventsID[$id] = null;
unset($this->eventsID[$id]);
$this->events[$ev][$id] = null;
unset($this->events[$ev][$id]);
if(count($this->events[$ev]) === 0){
unset($this->events[$ev]);
}
}
}
}

View File

@ -1,278 +0,0 @@
#!/bin/bash
COMPILER_VERSION="0.13"
PHP_VERSION="5.5.3"
ZEND_VM="GOTO"
LIBEDIT_VERSION="0.3"
ZLIB_VERSION="1.2.8"
PTHREADS_VERSION="0.0.44"
CURL_VERSION="curl-7_32_0"
echo "[PocketMine] PHP installer and compiler for Linux & Mac"
DIR="$(pwd)"
date > "$DIR/install.log" 2>&1
uname -a >> "$DIR/install.log" 2>&1
echo "[INFO] Checking dependecies"
type make >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"make\""; read -p "Press [Enter] to continue..."; exit 1; }
type autoconf >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"autoconf\""; read -p "Press [Enter] to continue..."; exit 1; }
type automake >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"automake\""; read -p "Press [Enter] to continue..."; exit 1; }
type libtool >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"libtool\""; read -p "Press [Enter] to continue..."; exit 1; }
type m4 >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"m4\""; read -p "Press [Enter] to continue..."; exit 1; }
type wget >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"wget\""; read -p "Press [Enter] to continue..."; exit 1; }
export CC="gcc"
COMPILE_FOR_ANDROID=no
RANLIB=ranlib
if [ "$1" == "rpi" ]; then
[ -z "$march" ] && march=armv6zk;
[ -z "$mtune" ] && mtune=arm1176jzf-s;
[ -z "$CFLAGS" ] && CFLAGS="-mfloat-abi=hard -mfpu=vfp";
echo "[INFO] Compiling for Raspberry Pi ARMv6zk hard float"
elif [ "$1" == "mac" ]; then
[ -z "$march" ] && march=prescott;
[ -z "$mtune" ] && mtune=generic;
[ -z "$CFLAGS" ] && CFLAGS="-fomit-frame-pointer";
echo "[INFO] Compiling for Intel MacOS"
elif [ "$1" == "crosscompile" ]; then
if [ "$2" == "android" ] || [ "$2" == "android-armv6" ]; then
COMPILE_FOR_ANDROID=yes
[ -z "$march" ] && march=armv6;
[ -z "$mtune" ] && mtune=generic;
TOOLCHAIN_PREFIX="arm-none-linux-gnueabi"
export CC="$TOOLCHAIN_PREFIX-gcc"
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX"
[ -z "$CFLAGS" ] && CFLAGS="-uclibc";
echo "[INFO] Cross-compiling for Android ARMv6"
elif [ "$2" == "android-armv7" ]; then
COMPILE_FOR_ANDROID=yes
[ -z "$march" ] && march=armv7a;
[ -z "$mtune" ] && mtune=generic-armv7-a;
TOOLCHAIN_PREFIX="arm-none-linux-gnueabi"
export CC="$TOOLCHAIN_PREFIX-gcc"
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX"
[ -z "$CFLAGS" ] && CFLAGS="-uclibc";
echo "[INFO] Cross-compiling for Android ARMv7"
elif [ "$2" == "rpi" ]; then
TOOLCHAIN_PREFIX="arm-linux-gnueabihf"
[ -z "$march" ] && march=armv6zk;
[ -z "$mtune" ] && mtune=arm1176jzf-s;
[ -z "$CFLAGS" ] && CFLAGS="-mfloat-abi=hard -mfpu=vfp";
export CC="$TOOLCHAIN_PREFIX-gcc"
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX"
[ -z "$CFLAGS" ] && CFLAGS="-uclibc";
echo "[INFO] Cross-compiling for Raspberry Pi ARMv6zk hard float"
elif [ "$2" == "mac" ]; then
[ -z "$march" ] && march=prescott;
[ -z "$mtune" ] && mtune=generic;
[ -z "$CFLAGS" ] && CFLAGS="-fomit-frame-pointer";
TOOLCHAIN_PREFIX="i686-apple-darwin10"
export CC="$TOOLCHAIN_PREFIX-gcc"
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX"
#zlib doesn't use the correct ranlib
RANLIB=$TOOLCHAIN_PREFIX-ranlib
echo "[INFO] Cross-compiling for Intel MacOS"
else
echo "Please supply a proper platform [android android-armv6 android-armv7 rpi mac] to cross-compile"
exit 1
fi
else
echo "[INFO] Compiling for current machine"
fi
type $CC >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"$CC\""; read -p "Press [Enter] to continue..."; exit 1; }
[ -z "$THREADS" ] && THREADS=1;
[ -z "$march" ] && march=native;
[ -z "$mtune" ] && mtune=native;
[ -z "$CFLAGS" ] && CFLAGS="";
[ -z "$CONFIGURE_FLAGS" ] && CONFIGURE_FLAGS="";
$CC -O3 -march=$march -mtune=$mtune -fno-gcse $CFLAGS -Q --help=target >> "$DIR/install.log" 2>&1
if [ $? -ne 0 ]; then
$CC -O3 -fno-gcse $CFLAGS -Q --help=target >> "$DIR/install.log" 2>&1
if [ $? -ne 0 ]; then
export CFLAGS="-O3 -fno-gcse "
else
export CFLAGS="-O3 -fno-gcse $CFLAGS"
fi
else
export CFLAGS="-O3 -march=$march -mtune=$mtune -fno-gcse $CFLAGS"
fi
rm -r -f install_data/ >> "$DIR/install.log" 2>&1
rm -r -f php5/ >> "$DIR/install.log" 2>&1
rm -r -f bin/ >> "$DIR/install.log" 2>&1
mkdir -m 0777 install_data >> "$DIR/install.log" 2>&1
mkdir -m 0777 php5 >> "$DIR/install.log" 2>&1
mkdir -m 0777 bin >> "$DIR/install.log" 2>&1
cd install_data
set -e
#PHP 5
echo -n "[PHP] downloading $PHP_VERSION..."
wget http://php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror -q -O - | tar -zx >> "$DIR/install.log" 2>&1
mv php-$PHP_VERSION php
echo " done!"
if [ 1 ] || [ "$1" == "crosscompile" ] || [ "$1" == "rpi" ]; then
HAVE_LIBEDIT="--without-libedit"
else
#libedit
echo -n "[libedit] downloading $LIBEDIT_VERSION..."
wget http://download.sourceforge.net/project/libedit/libedit/libedit-$LIBEDIT_VERSION/libedit-$LIBEDIT_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1
echo -n " checking..."
cd libedit
./configure --prefix="$DIR/install_data/php/ext/libedit" --enable-static >> "$DIR/install.log" 2>&1
echo -n " compiling..."
if make -j $THREADS >> "$DIR/install.log" 2>&1; then
echo -n " installing..."
make install >> "$DIR/install.log" 2>&1
HAVE_LIBEDIT="--with-libedit=\"$DIR/install_data/php/ext/libedit\""
else
echo -n " disabling..."
HAVE_LIBEDIT="--without-libedit"
fi
echo -n " cleaning..."
cd ..
rm -r -f ./libedit
echo " done!"
fi
#zlib
echo -n "[zlib] downloading $ZLIB_VERSION..."
wget http://zlib.net/zlib-$ZLIB_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1
mv zlib-$ZLIB_VERSION zlib
echo -n " checking..."
cd zlib
RANLIB=$RANLIB ./configure --prefix="$DIR/install_data/php/ext/zlib" \
--static >> "$DIR/install.log" 2>&1
echo -n " compiling..."
make -j $THREADS >> "$DIR/install.log" 2>&1
echo -n " installing..."
make install >> "$DIR/install.log" 2>&1
echo -n " cleaning..."
cd ..
rm -r -f ./zlib
echo " done!"
if [ "$(uname -s)" == "Darwin" ] && [ "$1" != "crosscompile" ] && [ "$2" != "curl" ]; then
HAVE_CURL="shared,/usr/local"
else
#curl
echo -n "[cURL] downloading $CURL_VERSION..."
wget https://github.com/bagder/curl/archive/$CURL_VERSION.tar.gz --no-check-certificate -q -O - | tar -zx >> "$DIR/install.log" 2>&1
mv curl-$CURL_VERSION curl
echo -n " checking..."
cd curl
./buildconf >> "$DIR/install.log" 2>&1
./configure --enable-ipv6 \
--enable-optimize \
--enable-http \
--enable-ftp \
--disable-dict \
--enable-file \
--disable-gopher \
--disable-imap \
--disable-pop3 \
--disable-rtsp \
--disable-smtp \
--disable-telnet \
--disable-tftp \
--prefix="$DIR/install_data/php/ext/curl" \
--disable-shared \
$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
echo -n " compiling..."
make -j $THREADS >> "$DIR/install.log" 2>&1
echo -n " installing..."
make install >> "$DIR/install.log" 2>&1
echo -n " cleaning..."
cd ..
rm -r -f ./curl
echo " done!"
HAVE_CURL="$DIR/install_data/php/ext/curl"
fi
#pthreads
echo -n "[PHP pthreads] downloading $PTHREADS_VERSION..."
wget http://pecl.php.net/get/pthreads-$PTHREADS_VERSION.tgz --no-check-certificate -q -O - | tar -zx >> "$DIR/install.log" 2>&1
mv pthreads-$PTHREADS_VERSION "$DIR/install_data/php/ext/pthreads"
echo " done!"
echo -n "[PHP]"
set +e
if which free >/dev/null; then
MAX_MEMORY=$(free -m | awk '/^Mem:/{print $2}')
else
MAX_MEMORY=$(top -l 1 | grep PhysMem: | awk '{print $10}' | tr -d 'a-zA-Z')
fi
if [ $MAX_MEMORY -gt 512 ] && [ "$1" != "crosscompile" ]; then
echo -n " enabling optimizations..."
OPTIMIZATION="--enable-inline-optimization "
else
OPTIMIZATION="--disable-inline-optimization "
fi
set -e
echo -n " checking..."
cd php
rm -rf ./aclocal.m4 >> "$DIR/install.log" 2>&1
rm -rf ./autom4te.cache/ >> "$DIR/install.log" 2>&1
rm -f ./configure >> "$DIR/install.log" 2>&1
./buildconf --force >> "$DIR/install.log" 2>&1
if [ "$1" == "crosscompile" ]; then
sed -i 's/pthreads_working=no/pthreads_working=yes/' ./configure
export LIBS="-lpthread -ldl"
fi
./configure $OPTIMIZATION--prefix="$DIR/php5" \
--exec-prefix="$DIR/php5" \
--with-curl="$HAVE_CURL" \
--with-zlib="$DIR/install_data/php/ext/zlib" \
$HAVE_LIBEDIT \
--disable-libxml \
--disable-xml \
--disable-dom \
--disable-simplexml \
--disable-xmlreader \
--disable-xmlwriter \
--disable-cgi \
--disable-session \
--disable-zip \
--disable-debug \
--disable-phar \
--enable-ctype \
--enable-sockets \
--enable-shared=no \
--enable-static=yes \
--enable-shmop \
--enable-pcntl \
--enable-pthreads \
--enable-maintainer-zts \
--enable-zend-signals \
--enable-embedded-mysqli \
--enable-bcmath \
--enable-cli \
--without-pear \
--without-iconv \
--disable-pdo \
--without-pdo-sqlite \
--with-zend-vm=$ZEND_VM \
$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
echo -n " compiling..."
if [ $COMPILE_FOR_ANDROID == "yes" ]; then
sed -i 's/-export-dynamic/-all-static/g' Makefile
fi
make -j $THREADS >> "$DIR/install.log" 2>&1
echo -n " installing..."
make install >> "$DIR/install.log" 2>&1
echo " done!"
cd "$DIR"
echo -n "[INFO] Cleaning up..."
rm -r -f install_data/ >> "$DIR/install.log" 2>&1
mv php5/bin/php bin/php
rm -r -f php5/ >> "$DIR/install.log" 2>&1
date >> "$DIR/install.log" 2>&1
echo " done!"
echo "[PocketMine] You should start the server now using \"./start.sh\""
echo "[PocketMine] If it doesn't works, please send the \"install.log\" file to the Bug Tracker"

View File

@ -1,71 +0,0 @@
<?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/
*
*
*/
set_time_limit(0);
date_default_timezone_set("GMT");
if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){
$time = time();
$time -= $time % 60;
exec("time.exe /T", $hour);
$i = array_map("intval", explode(":", trim($hour[0])));
exec("date.exe /T", $date);
$j = array_map("intval", explode("/", trim($date[0])));
$offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60;
}else{
exec("date +%s", $t);
$offset = round((intval(trim($t[0])) - time()) / 60) * 60;
}
$daylight = (int) date("I");
if($daylight === 0){
$offset -= 3600;
}
date_default_timezone_set(timezone_name_from_abbr("", $offset, $daylight));
gc_enable();
error_reporting(E_ALL ^ E_NOTICE);
ini_set("allow_url_fopen", 1);
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
ini_set("default_charset", "utf-8");
if(defined("POCKETMINE_COMPILE") and POCKETMINE_COMPILE === true){
define("FILE_PATH", realpath(dirname(__FILE__))."/");
}else{
define("FILE_PATH", realpath(dirname(__FILE__)."/../")."/");
}
set_include_path(get_include_path() . PATH_SEPARATOR . FILE_PATH);
ini_set("memory_limit", "128M"); //Default
define("LOG", true);
define("START_TIME", microtime(true));
define("MAJOR_VERSION", "Alpha_1.3.7");
define("CURRENT_MINECRAFT_VERSION", "0.7.4 alpha");
define("CURRENT_API_VERSION", 10);
define("CURRENT_PHP_VERSION", "5.5");
$gitsha1 = false;
if(file_exists(FILE_PATH.".git/refs/heads/master")){ //Found Git information!
define(GIT_COMMIT, strtolower(trim(file_get_contents(FILE_PATH.".git/refs/heads/master"))));
}else{ //Unknown :(
define(GIT_COMMIT, str_repeat("00", 20));
}

View File

@ -1,158 +0,0 @@
<?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/
*
*
*/
define("AIR", 0);
define("STONE", 1);
define("GRASS", 2);
define("DIRT", 3);
define("COBBLESTONE", 4);
define("COBBLE", 4);
define("PLANK", 5);
define("PLANKS", 5);
define("WOODEN_PLANK", 5);
define("WOODEN_PLANKS", 5);
define("SAPLING", 6);
define("SAPLINGS", 6);
define("BEDROCK", 7);
define("WATER", 8);
define("STILL_WATER", 9);
define("LAVA", 10);
define("STILL_LAVA", 11);
define("SAND", 12);
define("GRAVEL", 13);
define("GOLD_ORE", 14);
define("IRON_ORE", 15);
define("COAL_ORE", 16);
define("WOOD", 17);
define("TRUNK", 17);
define("LEAVES", 18);
define("LEAVE", 18);
define("GLASS", 20);
define("LAPIS_ORE", 21);
define("LAPIS_BLOCK", 22);
define("SANDSTONE", 24);
define("BED_BLOCK", 26);
define("COBWEB", 30);
define("TALL_GRASS", 31);
define("BUSH", 32);
define("DEAD_BUSH", 32);
define("WOOL", 35);
define("DANDELION", 37);
define("ROSE", 38);
define("CYAN_FLOWER", 38);
define("BROWN_MUSHROOM", 39);
define("RED_MUSHROOM", 40);
define("GOLD_BLOCK", 41);
define("IRON_BLOCK", 42);
define("DOUBLE_SLAB", 43);
define("DOUBLE_SLABS", 43);
define("SLAB", 44);
define("SLABS", 44);
define("BRICKS", 45);
define("BRICKS_BLOCK", 45);
define("TNT", 46);
define("BOOKSHELF", 47);
define("MOSS_STONE", 48);
define("MOSSY_STONE", 48);
define("OBSIDIAN", 49);
define("TORCH", 50);
define("FIRE", 51);
define("WOOD_STAIRS", 53);
define("WOODEN_STAIRS", 53);
define("CHEST", 54);
define("DIAMOND_ORE", 56);
define("DIAMOND_BLOCK", 57);
define("CRAFTING_TABLE", 58);
define("WORKBENCH", 58);
define("WHEAT_BLOCK", 59);
define("FARMLAND", 60);
define("FURNACE", 61);
define("BURNING_FURNACE", 62);
define("LIT_FURNACE", 62);
define("SIGN_POST", 63);
define("DOOR_BLOCK", 64);
define("WOODEN_DOOR_BLOCK", 64);
define("WOOD_DOOR_BLOCK", 64);
define("LADDER", 65);
define("COBBLE_STAIRS", 67);
define("COBBLESTONE_STAIRS", 67);
define("WALL_SIGN", 68);
define("IRON_DOOR_BLOCK", 71);
define("REDSTONE_ORE", 73);
define("GLOWING_REDSTONE_ORE", 74);
define("LIT_REDSTONE_ORE", 74);
define("SNOW", 78);
define("SNOW_LAYER", 78);
define("ICE", 79);
define("SNOW_BLOCK", 80);
define("CACTUS", 81);
define("CLAY_BLOCK", 82);
define("REEDS", 83);
define("SUGARCANE_BLOCK", 83);
define("FENCE", 85);
define("NETHERRACK", 87);
define("SOUL_SAND", 88);
define("GLOWSTONE", 89);
define("GLOWSTONE_BLOCK", 89);
define("CAKE_BLOCK", 92);
define("TRAPDOOR", 96);
define("STONE_BRICKS", 98);
define("STONE_BRICK", 98);
define("GLASS_PANE", 102);
define("GLASS_PANEL", 102);
define("MELON_BLOCK", 103);
define("MELON_STEM", 105);
define("FENCE_GATE", 107);
define("BRICK_STAIRS", 108);
define("STONE_BRICK_STAIRS", 109);
define("NETHER_BRICKS", 112);
define("NETHER_BRICK_BLOCK", 112);
define("NETHER_BRICKS_STAIRS", 114);
define("SANDSTONE_STAIRS", 128);
define("QUARTZ_BLOCK", 155);
define("QUARTZ_STAIRS", 156);
define("STONECUTTER", 245);
define("GLOWING_OBSIDIAN", 246);
define("NETHER_REACTOR", 247);

View File

@ -1,79 +0,0 @@
<?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/
*
*
*/
define("PMF_LEVEL_DEFLATE_LEVEL", 6);
//Gamemodes
define("SURVIVAL", 0);
define("CREATIVE", 1);
define("ADVENTURE", 2);
define("VIEW", 3);
define("VIEWER", 3);
//Players
define("MAX_CHUNK_RATE", 20 / arg("max-chunks-per-second", 3.5)); //Default rate ~172 kB/s
define("PLAYER_MAX_QUEUE", 1024);
define("PLAYER_SURVIVAL_SLOTS", 36);
define("PLAYER_CREATIVE_SLOTS", 112);
//Block Updates
define("BLOCK_UPDATE_NORMAL", 1);
define("BLOCK_UPDATE_RANDOM", 2);
define("BLOCK_UPDATE_SCHEDULED", 3);
define("BLOCK_UPDATE_WEAK", 4);
define("BLOCK_UPDATE_TOUCH", 5);
//Entities
define("ENTITY_PLAYER", 1);
define("ENTITY_MOB", 2);
define("MOB_CHICKEN", 10);
define("MOB_COW", 11);
define("MOB_PIG", 12);
define("MOB_SHEEP", 13);
define("MOB_ZOMBIE", 32);
define("MOB_CREEPER", 33);
define("MOB_SKELETON", 34);
define("MOB_SPIDER", 35);
define("MOB_PIGMAN", 36);
define("ENTITY_OBJECT", 3);
define("OBJECT_ARROW", 80);
define("OBJECT_PAINTING", 83);
define("ENTITY_ITEM", 4);
define("ENTITY_FALLING", 5);
define("FALLING_SAND", 66);
//TileEntities
define("TILE_SIGN", "Sign");
define("TILE_CHEST", "Chest");
define("CHEST_SLOTS", 27);
define("TILE_FURNACE", "Furnace");
define("FURNACE_SLOTS", 3);

View File

@ -1,150 +0,0 @@
<?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/
*
*
*/
define("IRON_SHOVEL", 256);//Implemented
define("IRON_PICKAXE", 257);//Implemented
define("IRON_AXE", 258);//Implemented
define("FLINT_STEEL", 259);
define("FLINT_AND_STEEL", 259);
define("APPLE", 260);//Implemented
define("BOW", 261);
define("ARROW", 262);
define("COAL", 263);//Implemented
define("DIAMOND", 264);//Implemented
define("IRON_INGOT", 265);//Implemented
define("GOLD_INGOT", 266);//Implemented
define("IRON_SWORD", 267);
define("WOODEN_SWORD", 268);//Implemented
define("WOODEN_SHOVEL", 269);//Implemented
define("WOODEN_PICKAXE", 270);//Implemented
define("WOODEN_AXE", 271);//Implemented
define("STONE_SWORD", 272);
define("STONE_SHOVEL", 273);
define("STONE_PICKAXE", 274);
define("STONE_AXE", 275);
define("DIAMOND_SWORD", 276);
define("DIAMOND_SHOVEL", 277);
define("DIAMOND_PICKAXE", 278);
define("DIAMOND_AXE", 279);
define("STICK", 280);//Implemented
define("STICKS", 280);
define("BOWL", 281);//Implemented
define("MUSHROOM_STEW", 282);
define("GOLD_SWORD", 283);
define("GOLD_SHOVEL", 284);
define("GOLD_PICKAXE", 285);
define("GOLD_AXE", 286);
define("GOLDEN_SWORD", 283);
define("GOLDEN_SHOVEL", 284);
define("GOLDEN_PICKAXE", 285);
define("GOLDEN_AXE", 286);
define("STRING", 287);
define("FEATHER", 288);//Implemented
define("GUNPOWDER", 289);
define("WOODEN_HOE", 290);
define("STONE_HOE", 291);
define("IRON_HOE", 292);//Implemented
define("DIAMOND_HOE", 293);
define("GOLD_HOE", 294);
define("GOLDEN_HOE", 294);
define("SEEDS", 295);
define("WHEAT_SEEDS", 295);
define("WHEAT", 296);
define("BREAD", 297);
define("LEATHER_CAP", 298);
define("LEATHER_TUNIC", 299);
define("LEATHER_PANTS", 300);
define("LEATHER_BOOTS", 301);
define("CHAIN_HELMET", 302);
define("CHAIN_CHESTPLATE", 303);
define("CHAIN_LEGGINGS", 304);
define("CHAIN_BOOTS", 305);
define("IRON_HELMET", 306);
define("IRON_CHESTPLATE", 307);
define("IRON_LEGGINGS", 308);
define("IRON_BOOTS", 309);
define("DIAMOND_HELMET", 310);
define("DIAMOND_CHESTPLATE", 311);
define("DIAMOND_LEGGINGS", 312);
define("DIAMOND_BOOTS", 313);
define("GOLD_HELMET", 314);
define("GOLD_CHESTPLATE", 315);
define("GOLD_LEGGINGS", 316);
define("GOLD_BOOTS", 317);
define("FLINT", 318);
define("RAW_PORKCHOP", 319);
define("COOKED_PORKCHOP", 320);
define("PAINTING", 321);
define("GOLDEN_APPLE", 322);
define("SIGN", 323);
define("WOODEN_DOOR", 324);
define("BUCKET", 325);
define("IRON_DOOR", 330);
define("SNOWBALL", 332);
define("LEATHER", 334);
define("BRICK", 336);
define("CLAY", 337);
define("SUGARCANE", 338);
define("SUGAR_CANE", 338);
define("SUGAR_CANES", 338);
define("PAPER", 339);
define("SLIMEBALL", 341);
define("EGG", 344);
define("COMPASS", 345);
define("GLOWSTONE_DUST", 348);
//define("RAW_FISH", 349);
//define("COOKED_FISH", 350);
define("DYE", 351);
define("BONE", 352);
define("SUGAR", 353);
define("CAKE", 354);
define("BED", 355);
//define("COOKIE", 357);
define("SHEARS", 359);
define("MELON", 360);
define("MELON_SLICE", 360);
define("MELON_SEEDS", 362);
define("RAW_BEEF", 363);
define("STEAK", 364);
define("COOKED_BEEF", 364);
define("RAW_CHICKEN", 365);
define("COOKED_CHICKEN", 366);
define("SPAWN_EGG", 383);
define("NETHER_BRICK", 405);
define("QUARTZ", 406);
define("NETHER_QUARTZ", 406);
define("CAMERA", 456);

View File

@ -1,84 +0,0 @@
<?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/
*
*
*/
/***REM_START***/
require_once(dirname(__FILE__)."/config.php");
require_once(FILE_PATH."/src/functions.php");
/***REM_END***/
define(DATA_PATH, realpath(arg("data-path", FILE_PATH))."/");
if(arg("enable-ansi", strpos(strtoupper(php_uname("s")), "WIN") === false ? true:false) === true){
define("ENABLE_ANSI", true);
}else{
define("ENABLE_ANSI", false);
}
set_error_handler("error_handler", E_ALL);
$errors = 0;
if(version_compare("5.4.0", PHP_VERSION) > 0){
console("[ERROR] Use PHP >= 5.4.0", true, true, 0);
++$errors;
}
if(php_sapi_name() !== "cli"){
console("[ERROR] You must run PocketMine-MP using the CLI.", true, true, 0);
++$errors;
}
if(!extension_loaded("sockets") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "sockets." . PHP_SHLIB_SUFFIX) === false){
console("[ERROR] Unable to find the Socket extension.", true, true, 0);
++$errors;
}
if(!extension_loaded("pthreads") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "pthreads." . PHP_SHLIB_SUFFIX) === false){
console("[ERROR] Unable to find the pthreads extension.", true, true, 0);
++$errors;
}
if(!extension_loaded("curl") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "curl." . PHP_SHLIB_SUFFIX) === false){
console("[ERROR] Unable to find the cURL extension.", true, true, 0);
++$errors;
}
if(!extension_loaded("sqlite3") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "sqlite3." . PHP_SHLIB_SUFFIX) === false){
console("[ERROR] Unable to find the SQLite3 extension.", true, true, 0);
++$errors;
}
if(!extension_loaded("zlib") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "zlib." . PHP_SHLIB_SUFFIX) === false){
console("[ERROR] Unable to find the Zlib extension.", true, true, 0);
++$errors;
}
if($errors > 0){
console("[ERROR] Please use the installer provided on the homepage.", true, true, 0);
exit(1); //Exit with error
}
/***REM_START***/
require_once(FILE_PATH."/src/math/Vector3.php");
require_once(FILE_PATH."/src/world/Position.php");
require_once(FILE_PATH."/src/pmf/PMF.php");
require_all(FILE_PATH . "src/");
/***REM_END***/

View File

@ -1,245 +0,0 @@
<?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/
*
*
*/
if(!function_exists("cli_set_process_title")){
function cli_set_process_title($title){
if(ENABLE_ANSI === true){
echo "\x1b]0;".$title."\x07";
return true;
}else{
return false;
}
}
}
function dummy(){
}
function safe_var_dump($var, $cnt = 0){
switch(true){
case is_array($var):
echo str_repeat(" ", $cnt)."array(".count($var).") {".PHP_EOL;
foreach($var as $key => $value){
echo str_repeat(" ", $cnt + 1)."[".(is_integer($key) ? $key:'"'.$key.'"')."]=>".PHP_EOL;
safe_var_dump($value, $cnt + 1);
}
echo str_repeat(" ", $cnt)."}".PHP_EOL;
break;
case is_integer($var):
echo str_repeat(" ", $cnt)."int(".$var.")".PHP_EOL;
break;
case is_float($var):
echo str_repeat(" ", $cnt)."float(".$var.")".PHP_EOL;
break;
case is_bool($var):
echo str_repeat(" ", $cnt)."bool(".($var === true ? "true":"false").")".PHP_EOL;
break;
case is_string($var):
echo str_repeat(" ", $cnt)."string(".strlen($var).") \"$var\"".PHP_EOL;
break;
case is_resource($var):
echo str_repeat(" ", $cnt)."resource() of type (".get_resource_type($var).")".PHP_EOL;
break;
case is_object($var):
echo str_repeat(" ", $cnt)."object(".get_class($var).")".PHP_EOL;
break;
case is_null($var):
echo str_repeat(" ", $cnt)."NULL".PHP_EOL;
break;
}
}
function kill($pid){
switch(Utils::getOS()){
case "win":
exec("taskkill.exe /F /PID ".((int) $pid)." > NUL");
break;
case "mac":
case "linux":
default:
exec("kill -9 ".((int) $pid)." > /dev/null 2>&1");
}
}
function require_all($path, &$count = 0){
$dir = dir($path."/");
$dirs = array();
while(false !== ($file = $dir->read())){
if($file !== "." and $file !== ".."){
if(!is_dir($path.$file) and strtolower(substr($file, -3)) === "php"){
require_once($path.$file);
++$count;
}elseif(is_dir($path.$file)){
$dirs[] = $path.$file."/";
}
}
}
foreach($dirs as $dir){
require_all($dir, $count);
}
}
function hard_unset(&$var){
if(is_object($var)){
$unset = new ReflectionClass($var);
foreach($unset->getProperties() as $prop){
$prop->setAccessible(true);
@hard_unset($prop->getValue($var));
$prop->setValue($var, null);
}
$var = null;
unset($var);
}elseif(is_array($var)){
foreach($var as $i => $v){
hard_unset($var[$i]);
}
$var = null;
unset($var);
}else{
$var = null;
unset($var);
}
}
function arg($name, $default = false){
global $arguments, $argv;
if(!isset($arguments)){
$arguments = arguments($argv);
}
if(isset($arguments["commands"][$name])){
return $arguments["commands"][$name];
}else{
return $default;
}
}
function arguments ( $args ){
if(!is_array($args)){
$args = array();
}
array_shift( $args );
$args = join( $args, ' ' );
preg_match_all('/ (--[\w\-]+ (?:[= ] [^-]+ [^\s-] )? ) | (-\w+) | (\w+) /x', $args, $match );
$args = array_shift( $match );
$ret = array(
'input' => array(),
'commands' => array(),
'flags' => array()
);
foreach ( $args as $arg ) {
// Is it a command? (prefixed with --)
if ( substr( $arg, 0, 2 ) === '--' ) {
$value = preg_split( '/[= ]/', $arg, 2 );
$com = substr( array_shift($value), 2 );
$value = join($value);
$ret['commands'][$com] = !empty($value) ? $value : true;
continue;
}
// Is it a flag? (prefixed with -)
if ( substr( $arg, 0, 1 ) === '-' ) {
$ret['flags'][] = substr( $arg, 1 );
continue;
}
$ret['input'][] = $arg;
continue;
}
return $ret;
}
function console($message, $EOL = true, $log = true, $level = 1){
if(!defined("DEBUG") or DEBUG >= $level){
$message .= $EOL === true ? PHP_EOL:"";
$time = (ENABLE_ANSI === true ? "\x1b[36m".date("H:i:s")."\x1b[0m":date("H:i:s")) . " ";
$replaced = preg_replace('/\x1b\[[0-9;]*m/', "", $time . $message);
if($log === true and (!defined("LOG") or LOG === true)){
logg($replaced, "console", false, $level);
}
if(ENABLE_ANSI === true){
$add = "";
if(preg_match("/\[([a-zA-Z0-9]*)\]/", $message, $matches) > 0){
$add .= "\x1b";
switch($matches[1]){
case "ERROR":
$add .= "[31;1m";
break;
case "INTERNAL":
case "DEBUG":
$add .= "[30;1m";
break;
case "WARNING":
$add .= "[33;1m";
break;
case "NOTICE":
$add .= "[37;1m";
break;
default:
$add = "";
break;
}
}
$message = $time . $add . $message . "\x1b[0m";
}else{
$message = $replaced;
}
echo $message;
}
}
function error_handler($errno, $errstr, $errfile, $errline){
if(error_reporting() === 0){ //@ error-control
return false;
}
console("[ERROR] A level ".$errno." error happened: \"$errstr\" in \"$errfile\" at line $errline", true, true, 0);
return true;
}
function logg($message, $name, $EOL = true, $level = 2, $close = false){
global $fpointers;
if((!defined("DEBUG") or DEBUG >= $level) and (!defined("LOG") or LOG === true)){
$message .= $EOL === true ? PHP_EOL:"";
if(!isset($fpointers)){
$fpointers = array();
}
if(!isset($fpointers[$name]) or $fpointers[$name] === false){
$fpointers[$name] = @fopen(DATA_PATH."/".$name.".log", "ab");
}
@fwrite($fpointers[$name], $message);
if($close === true){
fclose($fpointers[$name]);
unset($fpointers[$name]);
}
}
}

View File

@ -1,223 +0,0 @@
<?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/
*
*
*/
abstract class Block extends Position{
public static $class = array(
AIR => "AirBlock",
STONE => "StoneBlock",
GRASS => "GrassBlock",
DIRT => "DirtBlock",
COBBLESTONE => "CobblestoneBlock",
PLANKS => "PlanksBlock",
SAPLING => "SaplingBlock",
BEDROCK => "BedrockBlock",
WATER => "WaterBlock",
STILL_WATER => "StillWaterBlock",
LAVA => "LavaBlock",
STILL_LAVA => "StillLavaBlock",
SAND => "SandBlock",
GRAVEL => "GravelBlock",
GOLD_ORE => "GoldOreBlock",
IRON_ORE => "IronOreBlock",
COAL_ORE => "CoalOreBlock",
WOOD => "WoodBlock",
LEAVES => "LeavesBlock",
GLASS => "GlassBlock",
LAPIS_ORE => "LapisOreBlock",
LAPIS_BLOCK => "LapisBlock",
SANDSTONE => "SandstoneBlock",
BED_BLOCK => "BedBlock",
COBWEB => "CobwebBlock",
TALL_GRASS => "TallGrassBlock",
DEAD_BUSH => "DeadBushBlock",
WOOL => "WoolBlock",
DANDELION => "DandelionBlock",
CYAN_FLOWER => "CyanFlowerBlock",
BROWN_MUSHROOM => "BrownMushroomBlock",
RED_MUSHROOM => "RedMushRoomBlock",
GOLD_BLOCK => "GoldBlock",
IRON_BLOCK => "IronBlock",
DOUBLE_SLAB => "DoubleSlabBlock",
SLAB => "SlabBlock",
BRICKS_BLOCK => "BricksBlock",
TNT => "TNTBlock",
BOOKSHELF => "BookshelfBlock",
MOSS_STONE => "MossStoneBlock",
OBSIDIAN => "ObsidianBlock",
TORCH => "TorchBlock",
FIRE => "FireBlock",
WOOD_STAIRS => "WoodStairsBlock",
CHEST => "ChestBlock",
DIAMOND_ORE => "DiamondOreBlock",
DIAMOND_BLOCK => "DiamondBlock",
WORKBENCH => "WorkbenchBlock",
WHEAT_BLOCK => "WheatBlock",
FARMLAND => "FarmlandBlock",
FURNACE => "FurnaceBlock",
BURNING_FURNACE => "BurningFurnaceBlock",
SIGN_POST => "SignPostBlock",
WOOD_DOOR_BLOCK => "WoodDoorBlock",
LADDER => "LadderBlock",
COBBLESTONE_STAIRS => "CobblestoneStairsBlock",
WALL_SIGN => "WallSignBlock",
IRON_DOOR_BLOCK => "IronDoorBlock",
REDSTONE_ORE => "RedstoneOreBlock",
GLOWING_REDSTONE_ORE => "GlowingRedstoneOreBlock",
SNOW_LAYER => "SnowLayerBlock",
ICE => "IceBlock",
SNOW_BLOCK => "SnowBlock",
CACTUS => "CactusBlock",
CLAY_BLOCK => "ClayBlock",
SUGARCANE_BLOCK => "SugarcaneBlock",
FENCE => "FenceBlock",
NETHERRACK => "NetherrackBlock",
SOUL_SAND => "SoulSandBlock",
GLOWSTONE_BLOCK => "GlowstoneBlock",
CAKE_BLOCK => "CakeBlock",
TRAPDOOR => "TrapdoorBlock",
STONE_BRICKS => "StoneBricksBlock",
GLASS_PANE => "GlassPaneBlock",
MELON_BLOCK => "MelonBlock",
MELON_STEM => "MelonStemBlock",
FENCE_GATE => "FenceGateBlock",
BRICK_STAIRS => "BrickStairsBlock",
STONE_BRICK_STAIRS => "StoneBrickStairsBlock",
NETHER_BRICKS => "NetherBricksBlock",
NETHER_BRICKS_STAIRS => "NetherBricksStairsBlock",
SANDSTONE_STAIRS => "SandstoneStairsBlock",
QUARTZ_BLOCK => "QuartzBlock",
QUARTZ_STAIRS => "QuartzStairsBlock",
STONECUTTER => "StonecutterBlock",
GLOWING_OBSIDIAN => "GlowingObsidianBlock",
NETHER_REACTOR => "NetherReactorBlock",
);
protected $id;
protected $meta;
protected $name;
protected $breakTime;
public $isActivable = false;
public $breakable = true;
public $isFlowable = false;
public $isSolid = true;
public $isTransparent = false;
public $isReplaceable = false;
public $isPlaceable = true;
public $level = false;
public $hasPhysics = false;
public $isLiquid = false;
public $isFullBlock = true;
public $x = 0;
public $y = 0;
public $z = 0;
public function __construct($id, $meta = 0, $name = "Unknown"){
$this->id = (int) $id;
$this->meta = (int) $meta;
$this->name = $name;
$this->breakTime = 0.20;
}
final public function getName(){
return $this->name;
}
final public function getID(){
return $this->id;
}
final public function getMetadata(){
return $this->meta & 0x0F;
}
final public function position(Position $v){
$this->level = $v->level;
$this->x = (int) $v->x;
$this->y = (int) $v->y;
$this->z = (int) $v->z;
}
public function getDrops(Item $item, Player $player){
if(!isset(Block::$class[$this->id])){ //Unknown blocks
return array();
}else{
return array(
array($this->id, $this->meta, 1),
);
}
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.15;
}
return $this->breakTime;
}
public function getSide($side){
$v = parent::getSide($side);
if($this->level instanceof Level){
return $this->level->getBlock($v);
}
return $v;
}
final public function __toString(){
return "Block ". $this->name ." (".$this->id.":".$this->meta.")";
}
abstract function isBreakable(Item $item, Player $player);
abstract function onBreak(Item $item, Player $player);
abstract function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz);
abstract function onActivate(Item $item, Player $player);
abstract function onUpdate($type);
}
/***REM_START***/
require_once("block/GenericBlock.php");
require_once("block/SolidBlock.php");
require_once("block/TransparentBlock.php");
require_once("block/FallableBlock.php");
require_once("block/LiquidBlock.php");
require_once("block/StairBlock.php");
require_once("block/DoorBlock.php");
/***REM_END***/

View File

@ -1,275 +0,0 @@
<?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/
*
*
*/
class Item{
public static $class = array(
SUGARCANE => "SugarcaneItem",
WHEAT_SEEDS => "WheatSeedsItem",
MELON_SEEDS => "MelonSeedsItem",
SIGN => "SignItem",
WOODEN_DOOR => "WoodenDoorItem",
BUCKET => "BucketItem",
IRON_DOOR => "IronDoorItem",
CAKE => "CakeItem",
BED => "BedItem",
PAINTING => "PaintingItem",
COAL => "CoalItem",
APPLE => "AppleItem",
SPAWN_EGG => "SpawnEggItem",
DIAMOND => "DiamondItem",
STICK => "StickItem",
BOWL => "BowlItem",
FEATHER => "FeatherItem",
BRICK => "BrickItem",
IRON_INGOT => "IronIngotItem",
GOLD_INGOT => "GoldIngotItem",
IRON_SHOVEL => "IronShovelItem",
IRON_PICKAXE => "IronPickaxeItem",
IRON_AXE => "IronAxeItem",
IRON_HOE => "IronHoeItem",
WOODEN_SWORD => "WoodenSwordItem",
WOODEN_SHOVEL => "WoodenShovelItem",
WOODEN_PICKAXE => "WoodenPickaxeItem",
WOODEN_AXE => "WoodenAxeItem",
FLINT_STEEL => "FlintSteelItem",
);
protected $block;
protected $id;
protected $meta;
public $count;
protected $maxStackSize = 64;
protected $durability = 0;
protected $name;
public $isActivable = false;
public function __construct($id, $meta = 0, $count = 1, $name = "Unknown"){
$this->id = (int) $id;
$this->meta = (int) $meta;
$this->count = (int) $count;
$this->name = $name;
if(!isset($this->block) and $this->id <= 0xff and isset(Block::$class[$this->id])){
$this->block = BlockAPI::get($this->id, $this->meta);
$this->name = $this->block->getName();
}
if($this->isTool() !== false){
$this->maxStackSize = 1;
}
}
final public function getName(){
return $this->name;
}
final public function isPlaceable(){
return (($this->block instanceof Block) and $this->block->isPlaceable === true);
}
final public function getBlock(){
if($this->block instanceof Block){
return $this->block;
}else{
return BlockAPI::get(AIR);
}
}
final public function getID(){
return $this->id;
}
final public function getMetadata(){
return $this->meta;
}
final public function getMaxStackSize(){
return $this->maxStackSize;
}
final public function getFuelTime(){
if(!isset(FuelData::$duration[$this->id])){
return false;
}
if($this->id !== BUCKET or $this->meta === 10){
return FuelData::$duration[$this->id];
}
return false;
}
final public function getSmeltItem(){
if(!isset(SmeltingData::$product[$this->id])){
return false;
}
if(isset(SmeltingData::$product[$this->id][0]) and !is_array(SmeltingData::$product[$this->id][0])){
return BlockAPI::getItem(SmeltingData::$product[$this->id][0], SmeltingData::$product[$this->id][1]);
}
if(!isset(SmeltingData::$product[$this->id][$this->meta])){
return false;
}
return BlockAPI::getItem(SmeltingData::$product[$this->id][$this->meta][0], SmeltingData::$product[$this->id][$this->meta][1]);
}
public function useOn($object, $force = false){
if($this->isTool() or $force === true){
if(($object instanceof Entity) and !$this->isSword()){
$this->meta += 2;
}else{
$this->meta++;
}
return true;
}
return false;
}
final public function isTool(){
return ($this->id === FLINT_STEEL or $this->id === SHEARS or $this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false or $this->isSword() !== false);
}
final public function getMaxDurability(){
if(!$this->isTool() and $this->isHoe() === false and $this->id !== BOW){
return false;
}
$levels = array(
2 => 33,
1 => 60,
3 => 132,
4 => 251,
5 => 1562,
FLINT_STEEL => 65,
SHEARS => 239,
BOW => 385,
);
if(($type = $this->isPickaxe()) === false){
if(($type = $this->isAxe()) === false){
if(($type = $this->isSword()) === false){
if(($type = $this->isShovel()) === false){
if(($type = $this->isHoe()) === false){
$type = $this->id;
}
}
}
}
}
return $levels[$type];
}
final public function isPickaxe(){ //Returns false or level of the pickaxe
switch($this->id){
case IRON_PICKAXE:
return 4;
case WOODEN_PICKAXE:
return 1;
case STONE_PICKAXE:
return 3;
case DIAMOND_PICKAXE:
return 5;
case GOLD_PICKAXE:
return 2;
default:
return false;
}
}
final public function isAxe(){
switch($this->id){
case IRON_AXE:
return 4;
case WOODEN_AXE:
return 1;
case STONE_AXE:
return 3;
case DIAMOND_AXE:
return 5;
case GOLD_AXE:
return 2;
default:
return false;
}
}
final public function isSword(){
switch($this->id){
case IRON_SWORD:
return 4;
case WOODEN_SWORD:
return 1;
case STONE_SWORD:
return 3;
case DIAMOND_SWORD:
return 5;
case GOLD_SWORD:
return 2;
default:
return false;
}
}
final public function isShovel(){
switch($this->id){
case IRON_SHOVEL:
return 4;
case WOODEN_SHOVEL:
return 1;
case STONE_SHOVEL:
return 3;
case DIAMOND_SHOVEL:
return 5;
case GOLD_SHOVEL:
return 2;
default:
return false;
}
}
public function isHoe(){
switch($this->id){
case IRON_HOE:
case WOODEN_HOE:
case STONE_HOE:
case DIAMOND_HOE:
case GOLD_HOE:
return true;
default:
return false;
}
}
public function isShears(){
return ($this->id === SHEARS);
}
final public function __toString(){
return "Item ". $this->name ." (".$this->id.":".$this->meta.")";
}
public function getDestroySpeed(Block $block, Player $player){
return 1;
}
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
return false;
}
}

View File

@ -1,88 +0,0 @@
<?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/
*
*
*/
class DoorBlock extends TransparentBlock{
public function __construct($id, $meta = 0, $name = "Unknown"){
parent::__construct($id, $meta, $name);
$this->isSolid = false;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($face === 1){
$blockUp = $this->getSide(1);
$blockDown = $this->getSide(0);
if($blockUp->isReplaceable === false or $blockDown->isTransparent === true){
return false;
}
$direction = $player->entity->getDirection();
$face = array(
0 => 3,
1 => 4,
2 => 2,
3 => 5,
);
$next = $this->getSide($face[(($direction + 2) % 4)]);
$next2 = $this->getSide($face[$direction]);
$metaUp = 0x08;
if($next->getID() === $this->id or ($next2->isTransparent === false and $next->isTransparent === true)){ //Door hinge
$metaUp |= 0x01;
}
$this->level->setBlock($blockUp, BlockAPI::get($this->id, $metaUp)); //Top
$this->meta = $direction & 0x03;
$this->level->setBlock($block, $this); //Bottom
return true;
}
return false;
}
public function onBreak(Item $item, Player $player){
if(($this->meta & 0x08) === 0x08){
$down = $this->getSide(0);
if($down->getID() === $this->id){
$this->level->setBlock($down, new AirBlock());
}
}else{
$up = $this->getSide(1);
if($up->getID() === $this->id){
$this->level->setBlock($up, new AirBlock());
}
}
$this->level->setBlock($this, new AirBlock());
return true;
}
public function onActivate(Item $item, Player $player){
if(($this->meta & 0x08) === 0x08){ //Top
$down = $this->getSide(0);
if($down->getID() === $this->id){
$meta = $down->getMetadata() ^ 0x04;
$this->level->setBlock($down, BlockAPI::get($this->id, $meta));
return true;
}
return false;
}else{
$this->meta ^= 0x04;
$this->level->setBlock($this, $this);
}
return true;
}
}

View File

@ -1,63 +0,0 @@
<?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/
*
*
*/
class GenericBlock extends Block{
public function __construct($id, $meta = 0, $name = "Unknown"){
parent::__construct($id, $meta, $name);
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
return $this->level->setBlock($this, $this, true, false, true);
}
public function isBreakable(Item $item, Player $player){
return ($this->breakable);
}
public function onBreak(Item $item, Player $player){
return $this->level->setBlock($this, new AirBlock(), true, false, true);
}
public function onUpdate($type){
if($this->hasPhysics === true and $type === BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0);
if($down->getID() === AIR or ($down instanceof LiquidBlock)){
$data = array(
"x" => $this->x + 0.5,
"y" => $this->y + 0.5,
"z" => $this->z + 0.5,
"Tile" => $this->id,
);
$server = ServerAPI::request();
$this->level->setBlock($this, new AirBlock(), false, false, true);
$e = $server->api->entity->add($this->level, ENTITY_FALLING, FALLING_SAND, $data);
$server->api->entity->spawnToAll($e);
$server->api->block->blockUpdateAround(clone $this, BLOCK_UPDATE_NORMAL, 1);
}
return false;
}
return false;
}
public function onActivate(Item $item, Player $player){
return $this->isActivable;
}
}

View File

@ -1,31 +0,0 @@
<?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/
*
*
*/
class LiquidBlock extends TransparentBlock{
public function __construct($id, $meta = 0, $name = "Unknown"){
parent::__construct($id, $meta, $name);
$this->isLiquid = true;
$this->breakable = false;
$this->isReplaceable = true;
$this->isSolid = false;
$this->isFullBlock = true;
}
}

View File

@ -1,56 +0,0 @@
<?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/
*
*
*/
class StairBlock extends TransparentBlock{
public function __construct($id, $meta = 0, $name = "Unknown"){
parent::__construct($id, $meta, $name);
if(($this->meta & 0x04) === 0x04){
$this->isFullBlock = true;
}else{
$this->isFullBlock = false;
}
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array(
0 => 0,
1 => 2,
2 => 1,
3 => 3,
);
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
if(($fy > 0.5 and $face !== 1) or $face === 0){
$this->meta |= 0x04; //Upside-down stairs
}
$this->level->setBlock($block, $this);
return true;
}
public function getDrops(Item $item, Player $player){
if($item->isPickaxe() >= 1){
return array(
array($this->id, 0, 1),
);
}else{
return array();
}
}
}

View File

@ -1,33 +0,0 @@
<?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/
*
*
*/
class TransparentBlock extends GenericBlock{
public function __construct($id, $meta = 0, $name = "Unknown"){
parent::__construct($id, $meta, $name);
$this->isActivable = false;
$this->breakable = true;
$this->isFlowable = false;
$this->isTransparent = true;
$this->isReplaceable = false;
$this->isPlaceable = true;
$this->isSolid = true;
}
}

View File

@ -1,71 +0,0 @@
<?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/
*
*
*/
class SignPostBlock extends TransparentBlock{
public function __construct($meta = 0){
parent::__construct(SIGN_POST, $meta, "Sign Post");
$this->isSolid = false;
$this->isFullBlock = false;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($face !== 0){
$faces = array(
2 => 2,
3 => 3,
4 => 4,
5 => 5,
);
if(!isset($faces[$face])){
$this->meta = floor((($player->entity->yaw + 180) * 16 / 360) + 0.5) & 0x0F;
$this->level->setBlock($block, BlockAPI::get(SIGN_POST, $this->meta));
return true;
}else{
$this->meta = $faces[$face];
$this->level->setBlock($block, BlockAPI::get(WALL_SIGN, $this->meta));
return true;
}
}
return false;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace wit common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SIGN, 0, 1));
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}
return false;
}
public function onBreak(Item $item, Player $player){
$this->level->setBlock($this, new AirBlock(), true, true);
return true;
}
public function getDrops(Item $item, Player $player){
return array(
array(SIGN, 0, 1),
);
}
}

View File

@ -1,58 +0,0 @@
<?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/
*
*
*/
class TrapdoorBlock extends TransparentBlock{
public function __construct($meta = 0){
parent::__construct(TRAPDOOR, $meta, "Trapdoor");
$this->isActivable = true;
if(($this->meta & 0x04) === 0x04){
$this->isFullBlock = false;
}else{
$this->isFullBlock = true;
}
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if(($target->isTransparent === false or $target->getID() === SLAB) and $face !== 0 and $face !== 1){
$faces = array(
2 => 0,
3 => 1,
4 => 2,
5 => 3,
);
$this->meta = $faces[$face] & 0x03;
if($fy > 0.5){
$this->meta |= 0x08;
}
$this->level->setBlock($block, $this);
return true;
}
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
}
public function onActivate(Item $item, Player $player){
$this->meta ^= 0x04;
$this->level->setBlock($this, $this);
return true;
}
}

View File

@ -1,112 +0,0 @@
<?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/
*
*
*/
class WaterBlock extends LiquidBlock{
public function __construct($meta = 0){
parent::__construct(WATER, $meta, "Water");
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$ret = $this->level->setBlock($this, $this, true, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 10, BLOCK_UPDATE_NORMAL);
return $ret;
}
public function onUpdate($type){
return false;
$newId = $this->id;
$level = $this->meta & 0x07;
if($type !== BLOCK_UPDATE_NORMAL){
return false;
}
$falling = $this->meta >> 3;
$down = $this->getSide(0);
if($falling === 0){
$countSources = 0;
$maxLevel = $level;
$hasPath = false;
for($side = 2; $side <= 5; ++$side){
$b = $this->getSide($side);
if($b->isFlowable === true and $level < 0x07){
$d = $b->getSide(0);
$this->level->setBlock($b, new WaterBlock($level + 1), false, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
}elseif($b instanceof WaterBlock){
$oLevel = $b->getMetadata();
$oFalling = $oLevel >> 3;
$oLevel &= 0x07;
if($oFalling === 0){
if($oLevel === 0){
++$countSources;
$maxLevel = 1;
$hasPath = true;
}elseif($oLevel < 0x07 and ($oLevel + 1) <= $maxLevel){
$maxLevel = $oLevel + 1;
$hasPath = true;
}elseif(($level + 1) < $oLevel){
$this->level->setBlock($b, new WaterBlock($level + 1), false, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
}elseif($level === $oLevel){
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
}
}
}
}
if($countSources >= 2){
$level = 0; //Source block
}elseif($maxLevel < $level){
$level = $maxLevel;
}elseif($maxLevel === $level and $level > 0 and $hasPath === false){
if($level < 0x07){
++$level;
}else{
$newId = AIR;
$level = 0;
}
}
}
if($down->isFlowable){
$this->level->setBlock($down, new WaterBlock(0b1001), false, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
return false;
}elseif($down instanceof LiquidBlock){
if($down instanceof WaterBlock and ($down->getMetadata() >> 3) === 0){
$this->level->setBlock($down, new WaterBlock(0b1000 & min($down->getMetadata(), 1)), false, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
}
}else{
$falling = 0;
}
$newMeta = ($falling << 0x03) | $level;
if($newMeta !== $this->meta or $newId !== $this->id){
$this->id = $newId;
$this->meta = $newMeta;
$this->level->setBlock($this, $this, false, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
return false;
}
return false;
}
}

View File

@ -1,37 +0,0 @@
<?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/
*
*
*/
class AirBlock extends TransparentBlock{
public function __construct(){
parent::__construct(AIR, 0, "Air");
$this->isActivable = false;
$this->breakable = false;
$this->isFlowable = true;
$this->isTransparent = true;
$this->isReplaceable = true;
$this->isPlaceable = false;
$this->hasPhysics = false;
$this->isSolid = false;
$this->isFullBlock = true;
}
}

View File

@ -1,95 +0,0 @@
<?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/
*
*
*/
class BedBlock extends TransparentBlock{
public function __construct($type = 0){
parent::__construct(BED_BLOCK, $type, "Bed Block");
$this->isActivable = true;
$this->isFullBlock = false;
}
public function onActivate(Item $item, Player $player){
$player->dataPacket(MC_CLIENT_MESSAGE, array(
"message" => "This bed has been corrupted by your hands!"
));
return true;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->isTransparent === false){
$faces = array(
0 => 3,
1 => 4,
2 => 2,
3 => 5,
);
$d = $player->entity->getDirection();
$next = $this->getSide($faces[(($d + 3) % 4)]);
$downNext = $this->getSide(0);
if($next->isReplaceable === true and $downNext->isTransparent === false){
$meta = (($d + 3) % 4) & 0x03;
$this->level->setBlock($block, BlockAPI::get($this->id, $meta));
$this->level->setBlock($next, BlockAPI::get($this->id, $meta | 0x08));
return true;
}
}
return false;
}
public function onBreak(Item $item, Player $player){
$blockNorth = $this->getSide(2); //Gets the blocks around them
$blockSouth = $this->getSide(3);
$blockEast = $this->getSide(5);
$blockWest = $this->getSide(4);
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
if($blockNorth->getID() === $this->id and $blockNorth->meta !== 0x08){ //Checks if the block ID and meta are right
$this->level->setBlock($blockNorth, new AirBlock());
}elseif($blockSouth->getID() === $this->id and $blockSouth->meta !== 0x08){
$this->level->setBlock($blockSouth, new AirBlock());
}elseif($blockEast->getID() === $this->id and $blockEast->meta !== 0x08){
$this->level->setBlock($blockEast, new AirBlock());
}elseif($blockWest->getID() === $this->id and $blockWest->meta !== 0x08){
$this->level->setBlock($blockWest, new AirBlock());
}
}else{ //Bottom Part of Bed
if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
$this->level->setBlock($blockNorth, new AirBlock());
}elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
$this->level->setBlock($blockSouth, new AirBlock());
}elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){
$this->level->setBlock($blockEast, new AirBlock());
}elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){
$this->level->setBlock($blockWest, new AirBlock());
}
}
$this->level->setBlock($this, new AirBlock());
return true;
}
public function getDrops(Item $item, Player $player){
return array(
array(BED, 0, 1),
);
}
}

View File

@ -1,53 +0,0 @@
<?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/
*
*
*/
class FireBlock extends FlowableBlock{
public function __construct($meta = 0){
parent::__construct(FIRE, $meta, "Fire");
$this->isReplaceable = true;
$this->breakable = false;
$this->isFullBlock = true;
}
public function getDrops(Item $item, Player $player){
return array();
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
for($s = 0; $s <= 5; ++$s){
$side = $this->getSide($s);
if($side->getID() !== AIR and !($side instanceof LiquidBlock)){
return false;
}
}
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}elseif($type === BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== NETHERRACK){
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}
return false;
}
}

View File

@ -1,58 +0,0 @@
<?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/
*
*
*/
class CakeBlock extends TransparentBlock{
public function __construct($meta = 0){
parent::__construct(CAKE_BLOCK, 0, "Cake Block");
$this->isFullBlock = false;
$this->isActivable = true;
$this->meta = $meta & 0x07;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace wit common break method
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}
return false;
}
public function getDrops(Item $item, Player $player){
return array();
}
public function onActivate(Item $item, Player $player){
if($player->entity->getHealth() < 20){
++$this->meta;
$player->entity->heal(3, "cake");
if($this->meta >= 0x06){
$this->level->setBlock($this, new AirBlock());
}else{
$this->level->setBlock($this, $this);
}
return true;
}
return false;
}
}

View File

@ -1,59 +0,0 @@
<?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/
*
*
*/
class FenceGateBlock extends TransparentBlock{
public function __construct($meta = 0){
parent::__construct(FENCE_GATE, $meta, "Fence Gate");
$this->isActivable = true;
if(($this->meta & 0x04) === 0x04){
$this->isFullBlock = true;
}else{
$this->isFullBlock = false;
}
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array(
0 => 3,
1 => 0,
2 => 1,
3 => 2,
);
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
$this->level->setBlock($block, $this);
return true;
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
}
public function onActivate(Item $item, Player $player){
$faces = array(
0 => 3,
1 => 0,
2 => 1,
3 => 2,
);
$this->meta = ($faces[$player->entity->getDirection()] & 0x03) | ((~$this->meta) & 0x04);
$this->level->setBlock($this, $this);
return true;
}
}

View File

@ -1,70 +0,0 @@
<?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/
*
*
*/
class IronDoorBlock extends DoorBlock{
public function __construct($meta = 0){
parent::__construct(IRON_DOOR_BLOCK, $meta, "Iron Door Block");
//$this->isActivable = true;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace wit common break method
$this->level->setBlock($this, new AirBlock(), false);
if($this->getSide(1) instanceof DoorBlock){
$this->level->setBlock($this->getSide(1), new AirBlock(), false);
}
return BLOCK_UPDATE_NORMAL;
}
}
return false;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->isPickaxe()){
case 5:
return 0.95;
case 4:
return 1.25;
case 3:
return 1.9;
case 2:
return 0.65;
case 1:
return 3.75;
default:
return 25;
}
}
public function getDrops(Item $item, Player $player){
if($item->isPickaxe() >= 1){
return array(
array(IRON_DOOR, 0, 1),
);
}else{
return array();
}
}
}

View File

@ -1,108 +0,0 @@
<?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/
*
*
*/
class SlabBlock extends TransparentBlock{
public function __construct($meta = 0){
parent::__construct(SLAB, $meta, "Slab");
$names = array(
0 => "Stone",
1 => "Sandstone",
2 => "Wooden",
3 => "Cobblestone",
4 => "Brick",
5 => "Stone Brick",
//6 => "Nether Brick",
6 => "Quartz",
);
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Slab";
if(($this->meta & 0x08) === 0x08){
$this->isFullBlock = true;
}else{
$this->isFullBlock = false;
}
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$this->meta &= 0x07;
if($face === 0){
if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta));
return true;
}else{
$this->meta |= 0x08;
}
}elseif($face === 1){
if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta));
return true;
}
}elseif(!$player->entity->inBlock($block)){
if($block->getID() === SLAB){
if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta));
return true;
}
return false;
}else{
if($fy > 0.5){
$this->meta |= 0x08;
}
}
}else{
return false;
}
if($block->getID() === SLAB and ($target->getMetadata() & 0x07) !== ($this->meta & 0x07)){
return false;
}
$this->level->setBlock($block, $this);
return true;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->isPickaxe()){
case 5:
return 0.4;
case 4:
return 0.5;
case 3:
return 0.75;
case 2:
return 0.25;
case 1:
return 1.5;
default:
return 10;
}
}
public function getDrops(Item $item, Player $player){
if($item->isPickaxe() >= 1){
return array(
array($this->id, $this->meta & 0x07, 1),
);
}else{
return array();
}
}
}

View File

@ -1,46 +0,0 @@
<?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/
*
*
*/
class BrownMushroomBlock extends FlowableBlock{
public function __construct(){
parent::__construct(BROWN_MUSHROOM, 0, "Brown Mushroom");
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}
return false;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->isTransparent === false){
$this->level->setBlock($block, $this);
return true;
}
return false;
}
}

View File

@ -1,79 +0,0 @@
<?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/
*
*
*/
class CactusBlock extends TransparentBlock{
public function __construct($meta = 0){
parent::__construct(CACTUS, $meta, "Cactus");
$this->isFullBlock = false;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0);
if($down->getID() !== SAND and $down->getID() !== CACTUS){ //Replace wit common break method
$this->level->setBlock($this, new AirBlock(), false);
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
return BLOCK_UPDATE_NORMAL;
}
}elseif($type === BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== CACTUS){
if($this->meta == 0x0F){
for($y = 1; $y < 3; ++$y){
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getID() === AIR){
$this->level->setBlock($b, new CactusBlock());
break;
}
}
$this->meta = 0;
$this->level->setBlock($this, $this);
}else{
++$this->meta;
$this->level->setBlock($this, $this);
}
return BLOCK_UPDATE_RANDOM;
}
}
return false;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->getID() === SAND or $down->getID() === CACTUS){
$block0 = $this->getSide(2);
$block1 = $this->getSide(3);
$block2 = $this->getSide(4);
$block3 = $this->getSide(5);
if($block0->isTransparent === true and $block1->isTransparent === true and $block2->isTransparent === true and $block3->isTransparent === true){
$this->level->setBlock($this, $this);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true;
}
}
return false;
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
}
}

View File

@ -1,46 +0,0 @@
<?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/
*
*
*/
class CyanFlowerBlock extends FlowableBlock{
public function __construct(){
parent::__construct(CYAN_FLOWER, 0, "Cyan Flower");
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
$this->level->setBlock($block, $this);
return true;
}
return false;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}
return false;
}
}

View File

@ -1,46 +0,0 @@
<?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/
*
*
*/
class DandelionBlock extends FlowableBlock{
public function __construct(){
parent::__construct(DANDELION, 0, "Dandelion");
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
$this->level->setBlock($block, $this);
return true;
}
return false;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}
return false;
}
}

View File

@ -1,86 +0,0 @@
<?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/
*
*
*/
class MelonStemBlock extends FlowableBlock{
public function __construct($meta = 0){
parent::__construct(MELON_STEM, $meta, "Melon Stem");
$this->isActivable = true;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->getID() === FARMLAND){
$this->level->setBlock($block, $this);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true;
}
return false;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2)));
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}elseif($type === BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){
if($this->meta < 0x07){
++$this->meta;
$this->level->setBlock($this, $this);
return BLOCK_UPDATE_RANDOM;
}else{
for($side = 2; $side <= 5; ++$side){
$b = $this->getSide($side);
if($b->getID() === MELON_BLOCK){
return BLOCK_UPDATE_RANDOM;
}
}
$side = $this->getSide(mt_rand(2,5));
$d = $side->getSide(0);
if($side->getID() === AIR and ($d->getID() === FARMLAND or $d->getID() === GRASS or $d->getID() === DIRT)){
$this->level->setBlock($side, new MelonBlock());
}
}
}
return BLOCK_UPDATE_RANDOM;
}
return false;
}
public function onActivate(Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta = 0x07;
$this->level->setBlock($this, $this);
if(($player->gamemode & 0x01) === 0){
$item->count--;
}
return true;
}
return false;
}
public function getDrops(Item $item, Player $player){
return array(
array(MELON_SEEDS, 0, mt_rand(0, 2)),
);
}
}

View File

@ -1,87 +0,0 @@
<?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/
*
*
*/
class SaplingBlock extends FlowableBlock{
const OAK = 0;
const SPRUCE = 1;
const BIRCH = 2;
const BURN_TIME = 5;
public function __construct($meta = Sapling::OAK){
parent::__construct(SAPLING, $meta, "Sapling");
$this->isActivable = true;
$names = array(
0 => "Oak Sapling",
1 => "Spruce Sapling",
2 => "Birch Sapling",
);
$this->name = $names[$this->meta & 0x03];
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){
$this->level->setBlock($block, $this);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true;
}
return false;
}
public function onActivate(Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03);
if(($player->gamemode & 0x01) === 0){
$item->count--;
}
return true;
}
return false;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}elseif($type === BLOCK_UPDATE_RANDOM){ //Growth
if(mt_rand(1,7) === 1){
if(($this->meta & 0x08) === 0x08){
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03);
}else{
$this->meta |= 0x08;
$this->level->setBlock($this, $this);
return BLOCK_UPDATE_RANDOM;
}
}else{
return BLOCK_UPDATE_RANDOM;
}
}
return false;
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, $this->meta & 0x03, 1),
);
}
}

View File

@ -1,81 +0,0 @@
<?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/
*
*
*/
class SugarcaneBlock extends FlowableBlock{
public function __construct($meta = 0){
parent::__construct(SUGARCANE_BLOCK, $meta, "Sugarcane");
}
public function getDrops(Item $item, Player $player){
return array(
array(SUGARCANE, 0, 1),
);
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0);
if($down->isTransparent === true and $down->getID() !== SUGARCANE_BLOCK){ //Replace wit common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE));
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}elseif($type === BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== SUGARCANE_BLOCK){
if($this->meta === 0x0F){
for($y = 1; $y < 3; ++$y){
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getID() === AIR){
$this->level->setBlock($b, new SugarcaneBlock());
break;
}
}
$this->meta = 0;
$this->level->setBlock($this, $this);
}else{
++$this->meta;
$this->level->setBlock($this, $this);
}
return BLOCK_UPDATE_RANDOM;
}
}
return false;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->getID() === SUGARCANE_BLOCK){
$this->level->setBlock($block, new SugarcaneBlock());
return true;
}elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){
$block0 = $down->getSide(2);
$block1 = $down->getSide(3);
$block2 = $down->getSide(4);
$block3 = $down->getSide(5);
if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){
$this->level->setBlock($block, new SugarcaneBlock());
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true;
}
}
return false;
}
}

View File

@ -1,81 +0,0 @@
<?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/
*
*
*/
class WheatBlock extends FlowableBlock{
public function __construct($meta = 0){
parent::__construct(WHEAT_BLOCK, $meta, "Wheat Block");
$this->isActivable = true;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->getID() === FARMLAND){
$this->level->setBlock($block, $this);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true;
}
return false;
}
public function onActivate(Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta = 0x07;
$this->level->setBlock($this, $this);
if(($player->gamemode & 0x01) === 0){
$item->count--;
}
return true;
}
return false;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(WHEAT_SEEDS, 0, 1));
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}elseif($type === BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){
if($this->meta < 0x07){
++$this->meta;
$this->level->setBlock($this, $this);
return BLOCK_UPDATE_RANDOM;
}
}else{
return BLOCK_UPDATE_RANDOM;
}
}
return false;
}
public function getDrops(Item $item, Player $player){
$drops = array();
if($this->meta >= 0x07){
$drops[] = array(WHEAT, 0, 1);
$drops[] = array(WHEAT_SEEDS, 0, mt_rand(0, 3));
}else{
$drops[] = array(WHEAT_SEEDS, 0, 1);
}
return $drops;
}
}

View File

@ -1,106 +0,0 @@
<?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/
*
*
*/
class BurningFurnaceBlock extends SolidBlock{
public function __construct($meta = 0){
parent::__construct(BURNING_FURNACE, $meta, "Burning Furnace");
$this->isActivable = true;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array(
0 => 4,
1 => 2,
2 => 5,
3 => 3,
);
$this->meta = $faces[$player->entity->getDirection()];
$this->level->setBlock($block, $this);
return true;
}
public function onBreak(Item $item, Player $player){
$this->level->setBlock($this, new AirBlock(), true, true);
return true;
}
public function onActivate(Item $item, Player $player){
$server = ServerAPI::request();
$t = $server->api->tile->get($this);
$furnace = false;
if($t !== false){
$furnace = $t;
}else{
$furnace = $server->api->tile->add($this->level, TILE_FURNACE, $this->x, $this->y, $this->z, array(
"Items" => array(),
"id" => TILE_FURNACE,
"x" => $this->x,
"y" => $this->y,
"z" => $this->z
));
}
if(($player->gamemode & 0x01) === 0x01){
return true;
}
$furnace->openInventory($player);
return true;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->isPickaxe()){
case 5:
return 0.7;
case 4:
return 0.9;
case 3:
return 1.35;
case 2:
return 0.45;
case 1:
return 2.65;
default:
return 17.5;
}
}
public function getDrops(Item $item, Player $player){
$drops = array();
if($item->isPickaxe() >= 1){
$drops[] = array(FURNACE, 0, 1);
}
$t = ServerAPI::request()->api->tile->get($this);
if($t !== false and $t->class === TILE_FURNACE){
for($s = 0; $s < FURNACE_SLOTS; ++$s){
$slot = $t->getSlot($s);
if($slot->getID() > AIR and $slot->count > 0){
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
}
}
}
return $drops;
}
}

View File

@ -1,125 +0,0 @@
<?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/
*
*
*/
class ChestBlock extends TransparentBlock{
public function __construct($meta = 0){
parent::__construct(CHEST, $meta, "Chest");
$this->isActivable = true;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$server = ServerAPI::request();
$faces = array(
0 => 4,
1 => 2,
2 => 5,
3 => 3,
);
$chest = false;
$this->meta = $faces[$player->entity->getDirection()];
for($side = 2; $side <= 5; ++$side){
if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){
continue;
}elseif(($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)){
continue;
}
$c = $this->getSide($side);
if(($c instanceof ChestBlock) and $c->getMetadata() === $this->meta){
if((($tile = $server->api->tile->get($c)) instanceof Tile) and !$tile->isPaired()){
$chest = $tile;
break;
}
}
}
$this->level->setBlock($block, $this);
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
"Items" => array(),
"id" => TILE_CHEST,
"x" => $this->x,
"y" => $this->y,
"z" => $this->z
));
if($chest instanceof Tile){
$chest->pairWith($tile);
$tile->pairWith($chest);
}
return true;
}
public function onBreak(Item $item, Player $player){
$t = ServerAPI::request()->api->tile->get($this);
if($t !== false){
$t->unpair();
}
$this->level->setBlock($this, new AirBlock(), true, true);
return true;
}
public function onActivate(Item $item, Player $player){
$top = $this->getSide(1);
if($top->isTransparent !== true){
return true;
}
$server = ServerAPI::request();
$t = $server->api->tile->get($this);
$chest = false;
if($t !== false){
$chest = $t;
}else{
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
"Items" => array(),
"id" => TILE_CHEST,
"x" => $this->x,
"y" => $this->y,
"z" => $this->z
));
}
if(($player->gamemode & 0x01) === 0x01){
return true;
}
$chest->openInventory($player);
return true;
}
public function getDrops(Item $item, Player $player){
$drops = array(
array($this->id, 0, 1),
);
$t = ServerAPI::request()->api->tile->get($this);
if($t !== false and $t->class === TILE_CHEST){
for($s = 0; $s < CHEST_SLOTS; ++$s){
$slot = $t->getSlot($s);
if($slot->getID() > AIR and $slot->count > 0){
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
}
}
}
return $drops;
}
}

View File

@ -1,50 +0,0 @@
<?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/
*
*
*/
class SpawnEggItem extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(SPAWN_EGG, 0, $count, "Spawn Egg");
$this->meta = $meta;
$this->isActivable = true;
}
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
switch($this->meta){
case MOB_CHICKEN:
case MOB_SHEEP:
case MOB_COW:
case MOB_PIG:
$data = array(
"x" => $block->x + 0.5,
"y" => $block->y,
"z" => $block->z + 0.5,
);
$e = ServerAPI::request()->api->entity->add($block->level, ENTITY_MOB, $this->meta, $data);
ServerAPI::request()->api->entity->spawnToAll($e);
if(($player->gamemode & 0x01) === 0){
--$this->count;
}
return true;
break;
}
return false;
}
}

View File

@ -1,194 +0,0 @@
<?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/
*
*
*/
class Vector3{
public $x, $y, $z;
public function __construct($x = 0, $y = 0, $z = 0){
if(($x instanceof Vector3) === true){
$this->__construct($x->x, $x->y, $x->z);
}else{
$this->x = $x;
$this->y = $y;
$this->z = $z;
}
}
public function getX(){
return $this->x;
}
public function getY(){
return $this->y;
}
public function getZ(){
return $this->z;
}
public function getFloorX(){
return (int) $this->x;
}
public function getFloorY(){
return (int) $this->y;
}
public function getFloorZ(){
return (int) $this->z;
}
public function getRight(){
return $this->getX();
}
public function getUp(){
return $this->getY();
}
public function getForward(){
return $this->getZ();
}
public function getSouth(){
return $this->getX();
}
public function getWest(){
return $this->getZ();
}
public function add($x = 0, $y = 0, $z = 0){
if(($x instanceof Vector3) === true){
return $this->add($x->x, $x->y, $x->z);
}else{
return new Vector3($this->x + $x, $this->y + $y, $this->z + $z);
}
}
public function subtract($x = 0, $y = 0, $z = 0){
if(($x instanceof Vector3) === true){
return $this->add(-$x->x, -$x->y, -$x->z);
}else{
return $this->add(-$x, -$y, -$z);
}
}
public function multiply($number){
return new Vector3($this->x * $number, $this->y * $number, $this->z * $number);
}
public function divide($number){
return new Vector3($this->x / $number, $this->y / $number, $this->z / $number);
}
public function ceil(){
return new Vector3((int) ($this->x + 1), (int) ($this->y + 1), (int) ($this->z + 1));
}
public function floor(){
return new Vector3((int) $this->x, (int) $this->y, (int) $this->z);
}
public function round(){
return new Vector3(round($this->x), round($this->y), round($this->z));
}
public function abs(){
return new Vector3(abs($this->x), abs($this->y), abs($this->z));
}
public function getSide($side){
switch((int) $side){
case 0:
return new Vector3($this->x, $this->y - 1, $this->z);
case 1:
return new Vector3($this->x, $this->y + 1, $this->z);
case 2:
return new Vector3($this->x, $this->y, $this->z - 1);
case 3:
return new Vector3($this->x, $this->y, $this->z + 1);
case 4:
return new Vector3($this->x - 1, $this->y, $this->z);
case 5:
return new Vector3($this->x + 1, $this->y, $this->z);
default:
return $this;
}
}
public function distance($x = 0, $y = 0, $z = 0){
if(($x instanceof Vector3) === true){
return sqrt($this->distanceSquared($x->x, $x->y, $x->z));
}else{
return sqrt($this->distanceSquared($x, $y, $z));
}
}
public function distanceSquared($x = 0, $y = 0, $z = 0){
if(($x instanceof Vector3) === true){
return $this->distanceSquared($x->x, $x->y, $x->z);
}else{
return pow($this->x - $x, 2) + pow($this->y - $y, 2) + pow($this->z - $z, 2);
}
}
public function maxPlainDistance($x = 0, $z = 0){
if(($x instanceof Vector3) === true){
return $this->maxPlainDistance($x->x, $x->z);
}else{
return max(abs($this->x - $x), abs($this->z - $z));
}
}
public function length(){
return sqrt($this->lengthSquared());
}
public function lengthSquared(){
return $this->x * $this->x + $this->y * $this->y + $this->z * $this->z;
}
public function normalize(){
$len = $this->length();
if($len != 0){
return $this->divide($len);
}
return new Vector3(0, 0, 0);
}
public function dot(Vector3 $v){
return $this->x * $v->x + $this->y * $v->y + $this->z * $v->z;
}
public function cross(Vector3 $v){
return new Vector3(
$this->y * $v->z - $this->z * $v->y,
$this->z * $v->x - $this->x * $v->z,
$this->x * $v->y - $this->y * $v->x
);
}
public function __toString(){
return "Vector3(x=".$this->x.",y=".$this->y.",z=".$this->z.")";
}
}

View File

@ -1,840 +0,0 @@
<?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/
*
*
*/
class CustomPacketHandler{
public $offset;
public $raw;
public $c;
public $data;
public $name = "";
public function get($len = true, $check = true){
if($len === true){
$data = substr($this->raw, $this->offset);
if($check === true){
$this->offset = strlen($this->raw);
}
return $data;
}
$data = substr($this->raw, $this->offset, $len);
if($check === true){
$this->offset += $len;
}
return $data;
}
public function __construct($pid, $raw = "", $data = array(), $create = false){
$this->raw = $raw;
$this->data = $data;
$this->offset = 0;
$this->c = (bool) $create;
if($pid === false){
return;
}
switch($pid){
case MC_PING:
if($this->c === false){
$this->data["time"] = Utils::readLong($this->get(8));
}else{
$this->raw .= Utils::writeLong($this->data["time"]);
}
break;
case MC_PONG:
if($this->c === false){
$this->data["ptime"] = Utils::readLong($this->get(8));
$this->data["time"] = Utils::readLong($this->get(8));
}else{
$this->raw .= Utils::writeLong($this->data["ptime"]);
$this->raw .= Utils::writeLong($this->data["time"]);
}
break;
case MC_CLIENT_CONNECT:
if($this->c === false){
$this->data["clientID"] = Utils::readLong($this->get(8));
$this->data["session"] = Utils::readLong($this->get(8));
$this->data["unknown2"] = $this->get(1);
}else{
$this->raw .= Utils::writeLong($this->data["clientID"]);
$this->raw .= Utils::writeLong($this->data["session"]);
$this->raw .= "\x00";
}
break;
case MC_SERVER_HANDSHAKE:
if($this->c === false){
$this->data["cookie"] = $this->get(4); // 043f57fe
$this->data["security"] = $this->get(1);
$this->data["port"] = Utils::readShort($this->get(2), false);
$this->data["dataArray"] = Utils::readDataArray($this->get(true, false), 10, $offset);
$this->get($offset);
$this->data["timestamp"] = $this->get(2);
$this->data["session"] = Utils::readLong($this->get(8));
$this->data["session2"] = Utils::readLong($this->get(8));
}else{
$this->raw .= "\x04\x3f\x57\xfe";
$this->raw .= "\xcd";
$this->raw .= Utils::writeShort($this->data["port"]);
$this->raw .= Utils::writeDataArray(array(
"\xf5\xff\xff\xf5",
"\xff\xff\xff\xff",
"\xff\xff\xff\xff",
"\xff\xff\xff\xff",
"\xff\xff\xff\xff",
"\xff\xff\xff\xff",
"\xff\xff\xff\xff",
"\xff\xff\xff\xff",
"\xff\xff\xff\xff",
"\xff\xff\xff\xff",
));
$this->raw .= "\x00\x00";
$this->raw .= Utils::writeLong($this->data["session"]);
$this->raw .= Utils::writeLong($this->data["session2"]);
}
break;
case MC_CLIENT_HANDSHAKE:
if($this->c === false){
$this->data["cookie"] = $this->get(4); // 043f57fe
$this->data["security"] = $this->get(1);
$this->data["port"] = Utils::readShort($this->get(2), false);
$this->data["dataArray0"] = $this->get(ord($this->get(1)));
$this->data["dataArray"] = Utils::readDataArray($this->get(true, false), 9, $offset);
$this->get($offset);
$this->data["timestamp"] = $this->get(2);
$this->data["session2"] = Utils::readLong($this->get(8));
$this->data["session"] = Utils::readLong($this->get(8));
}else{
$this->raw .= "\x04\x3f\x57\xfe";
$this->raw .= "\xed";
$this->raw .= Utils::writeShort($this->data["port"]);
$w = array_shift($this->data["dataArray"]);
$this->raw .= chr(strlen($w)).$w;
$this->raw .= Utils::writeDataArray($this->data["dataArray"]);
$this->raw .= "\x00\x00";
$this->raw .= Utils::writeLong($this->data["session2"]);
$this->raw .= Utils::writeLong($this->data["session"]);
}
break;
case MC_SERVER_FULL:
if($this->c === false){
}else{
$this->raw .= RAKNET_MAGIC;
$this->raw .= Utils::writeLong($this->data["serverID"]);
}
break;
case MC_DISCONNECT:
//null
break;
case MC_BANNED:
if($this->c === false){
}else{
$this->raw .= RAKNET_MAGIC;
$this->raw .= Utils::writeLong($this->data["serverID"]);
}
break;
case MC_LOGIN:
if($this->c === false){
$this->data["username"] = $this->get(Utils::readShort($this->get(2), false));
$this->data["protocol1"] = Utils::readInt($this->get(4));
$this->data["protocol2"] = Utils::readInt($this->get(4));
$this->data["clientId"] = Utils::readInt($this->get(4));
$this->data["realms_data"] = $this->get(Utils::readShort($this->get(2), false));
}else{
$this->raw .= Utils::writeShort(strlen($this->data["username"])).$this->data["username"];
$this->raw .= Utils::writeInt(CURRENT_PROTOCOL).
Utils::writeInt(CURRENT_PROTOCOL).
Utils::writeInt($this->data["clientId"]);
$this->raw .= Utils::writeShort(strlen($this->data["realms_data"])).$this->data["realms_data"];
}
break;
case MC_LOGIN_STATUS:
if($this->c === false){
$this->data["status"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["status"]);
}
break;
case MC_READY:
if($this->c === false){
$this->data["status"] = ord($this->get(1));
}else{
$this->raw .= chr($this->data["status"]);
}
break;
case MC_CHAT:
if($this->c === false){
$this->data["player"] = $this->get(Utils::readShort($this->get(2), false));
$this->data["message"] = $this->get(Utils::readShort($this->get(2), false));
}else{
$this->raw .= Utils::writeShort(strlen($this->data["player"])).$this->data["player"];
$this->raw .= Utils::writeShort(strlen($this->data["message"])).$this->data["message"];
}
break;
case MC_SET_TIME:
if($this->c === false){
$this->data["time"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["time"]);
}
break;
case MC_START_GAME:
if($this->c === false){
$this->data["seed"] = Utils::readInt($this->get(4));
$this->data["generator"] = Utils::readInt($this->get(4));
$this->data["gamemode"] = Utils::readInt($this->get(4));
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readFloat($this->get(4));
$this->data["y"] = Utils::readFloat($this->get(4));
$this->data["z"] = Utils::readFloat($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["seed"]);
$this->raw .= Utils::writeInt($this->data["generator"]);
$this->raw .= Utils::writeInt($this->data["gamemode"]);
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeFloat($this->data["x"]);
$this->raw .= Utils::writeFloat($this->data["y"]);
$this->raw .= Utils::writeFloat($this->data["z"]);
}
break;
case MC_ADD_MOB:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["type"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readFloat($this->get(4));
$this->data["y"] = Utils::readFloat($this->get(4));
$this->data["z"] = Utils::readFloat($this->get(4));
$this->data["pitch"] = Utils::readByte($this->get(1));
$this->data["yaw"] = Utils::readByte($this->get(1));
$this->data["metadata"] = Utils::readMetadata($this->get(true));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeInt($this->data["type"]);
$this->raw .= Utils::writeFloat($this->data["x"]);
$this->raw .= Utils::writeFloat($this->data["y"]);
$this->raw .= Utils::writeFloat($this->data["z"]);
$this->raw .= Utils::writeByte($this->data["pitch"]);
$this->raw .= Utils::writeByte($this->data["yaw"]);
$this->raw .= Utils::writeMetadata($this->data["metadata"]);
}
break;
case MC_ADD_PLAYER:
if($this->c === false){
$this->data["clientID"] = Utils::readLong($this->get(8));
$this->data["username"] = $this->get(Utils::readShort($this->get(2), false));
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readFloat($this->get(4));
$this->data["y"] = Utils::readFloat($this->get(4));
$this->data["z"] = Utils::readFloat($this->get(4));
$this->data["pitch"] = Utils::readByte($this->get(1));
$this->data["yaw"] = Utils::readByte($this->get(1));
$this->data["unknown1"] = Utils::readShort($this->get(2));
$this->data["unknown2"] = Utils::readShort($this->get(2));
$this->data["metadata"] = Utils::readMetadata($this->get(true));
}else{
$this->raw .= Utils::writeLong($this->data["clientID"]);
$this->raw .= Utils::writeShort(strlen($this->data["username"])).$this->data["username"];
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeFloat($this->data["x"]);
$this->raw .= Utils::writeFloat($this->data["y"]);
$this->raw .= Utils::writeFloat($this->data["z"]);
$this->raw .= Utils::writeByte($this->data["pitch"]);
$this->raw .= Utils::writeByte($this->data["yaw"]);
$this->raw .= Utils::writeShort($this->data["unknown1"]);
$this->raw .= Utils::writeShort($this->data["unknown2"]);
$this->raw .= Utils::writeMetadata($this->data["metadata"]);
}
break;
case MC_REMOVE_PLAYER:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["clientID"] = Utils::readLong($this->get(8));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeLong($this->data["clientID"]);
}
break;
case MC_ADD_ENTITY:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["type"] = ord($this->get(1));
$this->data["x"] = Utils::readFloat($this->get(4));
$this->data["y"] = Utils::readFloat($this->get(4));
$this->data["z"] = Utils::readFloat($this->get(4));
$this->data["did"] = Utils::readInt($this->get(4));
if($this->data["did"] > 0){
$this->data["speedX"] = Utils::readShort($this->get(2));
$this->data["speedY"] = Utils::readShort($this->get(2));
$this->data["speedZ"] = Utils::readShort($this->get(2));
}
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= chr($this->data["type"]);
$this->raw .= Utils::writeFloat($this->data["x"]);
$this->raw .= Utils::writeFloat($this->data["y"]);
$this->raw .= Utils::writeFloat($this->data["z"]);
$this->raw .= Utils::writeInt($this->data["did"]);
if($this->data["did"] > 0){
$this->raw .= Utils::writeShort($this->data["speedX"]);
$this->raw .= Utils::writeShort($this->data["speedY"]);
$this->raw .= Utils::writeShort($this->data["speedZ"]);
}
}
break;
case MC_REMOVE_ENTITY:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
}
break;
case MC_ADD_ITEM_ENTITY:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["block"] = Utils::readShort($this->get(2), false);
$this->data["stack"] = ord($this->get(1));
$this->data["meta"] = Utils::readShort($this->get(2), false);
$this->data["x"] = Utils::readFloat($this->get(4));
$this->data["y"] = Utils::readFloat($this->get(4));
$this->data["z"] = Utils::readFloat($this->get(4));
$this->data["yaw"] = Utils::readByte($this->get(1));
$this->data["pitch"] = Utils::readByte($this->get(1));
$this->data["roll"] = Utils::readByte($this->get(1));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeShort($this->data["block"]);
$this->raw .= chr($this->data["stack"]);
$this->raw .= Utils::writeShort($this->data["meta"]);
$this->raw .= Utils::writeFloat($this->data["x"]);
$this->raw .= Utils::writeFloat($this->data["y"]);
$this->raw .= Utils::writeFloat($this->data["z"]);
$this->raw .= Utils::writeByte($this->data["yaw"]);
$this->raw .= Utils::writeByte($this->data["pitch"]);
$this->raw .= Utils::writeByte($this->data["roll"]);
}
break;
case MC_TAKE_ITEM_ENTITY:
if($this->c === false){
$this->data["target"] = Utils::readInt($this->get(4));
$this->data["eid"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["target"]);
$this->raw .= Utils::writeInt($this->data["eid"]);
}
break;
case MC_MOVE_ENTITY:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readFloat($this->get(4));
$this->data["y"] = Utils::readFloat($this->get(4));
$this->data["z"] = Utils::readFloat($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeFloat($this->data["x"]);
$this->raw .= Utils::writeFloat($this->data["y"]);
$this->raw .= Utils::writeFloat($this->data["z"]);
}
break;
case MC_MOVE_ENTITY_POSROT:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readFloat($this->get(4));
$this->data["y"] = Utils::readFloat($this->get(4));
$this->data["z"] = Utils::readFloat($this->get(4));
$this->data["yaw"] = Utils::readFloat($this->get(4));
$this->data["pitch"] = Utils::readFloat($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeFloat($this->data["x"]);
$this->raw .= Utils::writeFloat($this->data["y"]);
$this->raw .= Utils::writeFloat($this->data["z"]);
$this->raw .= Utils::writeFloat($this->data["yaw"]);
$this->raw .= Utils::writeFloat($this->data["pitch"]);
}
break;
case MC_MOVE_PLAYER:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readFloat($this->get(4));
$this->data["y"] = Utils::readFloat($this->get(4));
$this->data["z"] = Utils::readFloat($this->get(4));
$this->data["yaw"] = Utils::readFloat($this->get(4));
$this->data["pitch"] = Utils::readFloat($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeFloat($this->data["x"]);
$this->raw .= Utils::writeFloat($this->data["y"]);
$this->raw .= Utils::writeFloat($this->data["z"]);
$this->raw .= Utils::writeFloat($this->data["yaw"]);
$this->raw .= Utils::writeFloat($this->data["pitch"]);
}
break;
case MC_PLACE_BLOCK:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
$this->data["y"] = ord($this->get(1));
$this->data["block"] = ord($this->get(1));
$this->data["meta"] = ord($this->get(1));
$this->data["face"] = Utils::readByte($this->get(1));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["z"]);
$this->raw .= chr($this->data["y"]);
$this->raw .= chr($this->data["block"]);
$this->raw .= chr($this->data["meta"]);
$this->raw .= chr($this->data["face"]);
}
break;
case MC_REMOVE_BLOCK: //Sent when a player removes a block, not used
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
$this->data["y"] = ord($this->get(1));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["z"]);
$this->raw .= chr($this->data["y"]);
}
break;
case MC_UPDATE_BLOCK:
if($this->c === false){
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
$this->data["y"] = ord($this->get(1));
$this->data["block"] = ord($this->get(1));
$this->data["meta"] = ord($this->get(1));
}else{
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["z"]);
$this->raw .= chr($this->data["y"]);
$this->raw .= chr($this->data["block"]);
$this->raw .= chr($this->data["meta"]);
}
break;
case MC_ADD_PAINTING:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["y"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
$this->data["direction"] = Utils::readInt($this->get(4));
$this->data["title"] = $this->get(Utils::readShort($this->get(2), false));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["y"]);
$this->raw .= Utils::writeInt($this->data["z"]);
$this->raw .= Utils::writeInt($this->data["direction"]);
$this->raw .= Utils::writeShort(strlen($this->data["title"])).$this->data["title"];
}
break;
case MC_EXPLOSION:
if($this->c === false){
$this->data["x"] = Utils::readFloat($this->get(4));
$this->data["y"] = Utils::readFloat($this->get(4));
$this->data["z"] = Utils::readFloat($this->get(4));
$this->data["radius"] = Utils::readFloat($this->get(4));
$this->data["count"] = Utils::readInt($this->get(4));
$this->data["records"] = array();
for($r = 0; $r < $this->data["count"]; ++$r){
$this->data["records"][] = new Vector3(Utils::readByte($this->get(1)), Utils::readByte($this->get(1)), Utils::readByte($this->get(1)));
}
}else{
$this->raw .= Utils::writeFloat($this->data["x"]);
$this->raw .= Utils::writeFloat($this->data["y"]);
$this->raw .= Utils::writeFloat($this->data["z"]);
$this->raw .= Utils::writeFloat($this->data["radius"]);
$this->data["records"] = (array) $this->data["records"];
$this->raw .= Utils::writeInt(count($this->data["records"]));
if(count($this->data["records"]) > 0){
foreach($this->data["records"] as $record){
$this->raw .= Utils::writeByte($record->x) . Utils::writeByte($record->y) . Utils::writeByte($record->z);
}
}
}
break;
case MC_LEVEL_EVENT:
if($this->c === false){
$this->data["unknown1"] = Utils::readShort($this->get(2));
$this->data["unknown2"] = Utils::readShort($this->get(2));
$this->data["unknown3"] = Utils::readShort($this->get(2));
$this->data["unknown4"] = Utils::readShort($this->get(2));
$this->data["unknown5"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeShort($this->data["unknown1"]);
$this->raw .= Utils::writeShort($this->data["unknown2"]);
$this->raw .= Utils::writeShort($this->data["unknown3"]);
$this->raw .= Utils::writeShort($this->data["unknown4"]);
$this->raw .= Utils::writeInt($this->data["unknown5"]);
}
break;
case MC_TILE_EVENT:
if($this->c === false){
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["y"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
$this->data["case1"] = Utils::readInt($this->get(4));
$this->data["case2"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["y"]);
$this->raw .= Utils::writeInt($this->data["z"]);
$this->raw .= Utils::writeInt($this->data["case1"]);
$this->raw .= Utils::writeInt($this->data["case2"]);
}
break;
case MC_ENTITY_EVENT:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["event"] = ord($this->get(1));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= chr($this->data["event"]);
}
break;
case MC_REQUEST_CHUNK:
if($this->c === false){
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["z"]);
}
break;
case MC_CHUNK_DATA:
if($this->c === false){
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
$this->data["data"] = $this->get(true);
}else{
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["z"]);
$this->raw .= $this->data["data"];
}
break;
case MC_PLAYER_EQUIPMENT:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["block"] = Utils::readShort($this->get(2), false);
$this->data["meta"] = Utils::readShort($this->get(2), false);
$this->data["slot"] = ord($this->get(1));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeShort($this->data["block"]);
$this->raw .= Utils::writeShort($this->data["meta"]);
$this->raw .= chr($this->data["slot"]);
}
break;
case MC_PLAYER_ARMOR_EQUIPMENT:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["slot0"] = ord($this->get(1));
$this->data["slot1"] = ord($this->get(1));
$this->data["slot2"] = ord($this->get(1));
$this->data["slot3"] = ord($this->get(1));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= chr($this->data["slot0"]);
$this->raw .= chr($this->data["slot1"]);
$this->raw .= chr($this->data["slot2"]);
$this->raw .= chr($this->data["slot3"]);
}
break;
case MC_INTERACT:
if($this->c === false){
$this->data["action"] = Utils::readByte($this->get(1));
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["target"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeByte($this->data["action"]);
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeInt($this->data["target"]);
}
break;
case MC_USE_ITEM:
if($this->c === false){
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["y"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
$this->data["face"] = Utils::readInt($this->get(4));
$this->data["block"] = Utils::readShort($this->get(2));
$this->data["meta"] = Utils::readByte($this->get(1));
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["fx"] = Utils::readFloat($this->get(4));
$this->data["fy"] = Utils::readFloat($this->get(4));
$this->data["fz"] = Utils::readFloat($this->get(4));
$this->data["posX"] = Utils::readFloat($this->get(4));
$this->data["posY"] = Utils::readFloat($this->get(4));
$this->data["posZ"] = Utils::readFloat($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["y"]);
$this->raw .= Utils::writeInt($this->data["z"]);
$this->raw .= Utils::writeInt($this->data["face"]);
$this->raw .= Utils::writeShort($this->data["block"]);
$this->raw .= Utils::writeByte($this->data["meta"]);
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeFloat($this->data["fx"]);
$this->raw .= Utils::writeFloat($this->data["fy"]);
$this->raw .= Utils::writeFloat($this->data["fz"]);
$this->raw .= Utils::writeFloat($this->data["posX"]);
$this->raw .= Utils::writeFloat($this->data["posY"]);
$this->raw .= Utils::writeFloat($this->data["posZ"]);
}
break;
case MC_PLAYER_ACTION:
if($this->c === false){
$this->data["action"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["y"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
$this->data["face"] = Utils::readInt($this->get(4));
$this->data["eid"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["action"]);
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["y"]);
$this->raw .= Utils::writeInt($this->data["z"]);
$this->raw .= Utils::writeInt($this->data["face"]);
$this->raw .= Utils::writeInt($this->data["eid"]);
}
break;
case MC_SET_ENTITY_DATA:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["metadata"] = Utils::readMetadata($this->get(true));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeMetadata($this->data["metadata"]);
}
break;
case MC_SET_ENTITY_MOTION:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["speedX"] = Utils::readShort($this->get(2));
$this->data["speedY"] = Utils::readShort($this->get(2));
$this->data["speedZ"] = Utils::readShort($this->get(2));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeShort($this->data["speedX"]);
$this->raw .= Utils::writeShort($this->data["speedY"]);
$this->raw .= Utils::writeShort($this->data["speedZ"]);
}
break;
case MC_HURT_ARMOR:
if($this->c === false){
$this->data["health"] = Utils::readByte($this->get(1));
}else{
$this->raw .= Utils::writeByte($this->data["health"]);
}
break;
case MC_SET_HEALTH:
if($this->c === false){
$this->data["health"] = Utils::readByte($this->get(1));
}else{
$this->raw .= Utils::writeByte($this->data["health"]);
}
break;
case MC_SET_SPAWN_POSITION:
if($this->c === false){
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
$this->data["y"] = ord($this->get(1));
}else{
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["z"]);
$this->raw .= chr($this->data["y"]);
}
break;
case MC_ANIMATE:
if($this->c === false){
$this->data["action"] = Utils::readByte($this->get(1));
$this->data["eid"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeByte($this->data["action"]);
$this->raw .= Utils::writeInt($this->data["eid"]);
}
break;
case MC_RESPAWN:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["x"] = Utils::readFloat($this->get(4));
$this->data["y"] = Utils::readFloat($this->get(4));
$this->data["z"] = Utils::readFloat($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeFloat($this->data["x"]);
$this->raw .= Utils::writeFloat($this->data["y"]);
$this->raw .= Utils::writeFloat($this->data["z"]);
}
break;
case MC_SEND_INVENTORY:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["windowid"] = ord($this->get(1));
$this->data["count"] = Utils::readShort($this->get(2), false);
$this->data["slots"] = array();
for($s = 0; $s < $this->data["count"]; ++$s){
$this->data["slots"][$s] = Utils::readSlot($this);
}
if($this->data["windowid"] === 1){ //Armor is also sent
$this->data["armor"] = array(
Utils::readSlot($this),
Utils::readSlot($this),
Utils::readSlot($this),
Utils::readSlot($this)
);
}
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= chr($this->data["windowid"]);
$this->raw .= Utils::writeShort(count($this->data["slots"]));
foreach($this->data["slots"] as $slot){
$this->raw .= Utils::writeSlot($slot);
}
if($this->data["windowid"] === 1 and isset($this->data["armor"])){
$this->raw .= Utils::writeSlot($this->data["armor"][0]);
$this->raw .= Utils::writeSlot($this->data["armor"][1]);
$this->raw .= Utils::writeSlot($this->data["armor"][2]);
$this->raw .= Utils::writeSlot($this->data["armor"][3]);
}
}
break;
case MC_DROP_ITEM:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["unknown1"] = ord($this->get(1));
$this->data["block"] = Utils::readShort($this->get(2), false);
$this->data["stack"] = ord($this->get(1));
$this->data["meta"] = Utils::readShort($this->get(2), false);
}else{
$this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= chr($this->data["unknown1"]);
$this->raw .= Utils::writeShort($this->data["block"]);
$this->raw .= chr($this->data["stack"]);
$this->raw .= Utils::writeShort($this->data["meta"]);
}
break;
case MC_CONTAINER_OPEN:
if($this->c === false){
$this->data["windowid"] = ord($this->get(1));
$this->data["type"] = ord($this->get(1));
$this->data["slots"] = ord($this->get(1));
//$this->data["title"] = $this->get(Utils::readShort($this->get(2), false));
}else{
$this->raw .= chr($this->data["windowid"]);
$this->raw .= chr($this->data["type"]);
$this->raw .= chr($this->data["slots"]);
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["y"]);
$this->raw .= Utils::writeInt($this->data["z"]);
}
break;
case MC_CONTAINER_CLOSE:
if($this->c === false){
$this->data["windowid"] = ord($this->get(1));
}else{
$this->raw .= chr($this->data["windowid"]);
}
break;
case MC_CONTAINER_SET_SLOT:
if($this->c === false){
$this->data["windowid"] = ord($this->get(1));
$this->data["slot"] = Utils::readShort($this->get(2), false);
$this->data["block"] = Utils::readShort($this->get(2), false);
$this->data["stack"] = ord($this->get(1));
$this->data["meta"] = Utils::readShort($this->get(2), false);
}else{
$this->raw .= chr($this->data["windowid"]);
$this->raw .= Utils::writeShort($this->data["slot"]);
$this->raw .= Utils::writeShort($this->data["block"]);
$this->raw .= chr($this->data["stack"]);
$this->raw .= Utils::writeShort($this->data["meta"]);
}
break;
case MC_CONTAINER_SET_CONTENT:
if($this->c === false){
$this->data["windowid"] = ord($this->get(1));
$this->data["count"] = Utils::readShort($this->get(2), false);
$this->data["slots"] = array();
for($s = 0; $s < $this->data["count"]; ++$s){
$this->data["slots"][$s] = Utils::readSlot($this);
}
}else{
$this->raw .= chr($this->data["windowid"]);
$this->raw .= Utils::writeShort(count($this->data["slots"]));
foreach($this->data["slots"] as $slot){
$this->raw .= Utils::writeSlot($slot);
}
}
break;
case MC_CONTAINER_SET_DATA:
if($this->c === false){
$this->data["windowid"] = ord($this->get(1));
$this->data["property"] = Utils::readShort($this->get(2));
$this->data["value"] = Utils::readShort($this->get(2));
}else{
$this->raw .= chr($this->data["windowid"]);
$this->raw .= Utils::writeShort($this->data["property"]);
$this->raw .= Utils::writeShort($this->data["value"]);
}
break;
case MC_CLIENT_MESSAGE:
if($this->c === false){
$this->data["message"] = $this->get(Utils::readShort($this->get(2), false));
}else{
$this->raw .= Utils::writeShort(strlen($this->data["message"])).$this->data["message"];
}
break;
case MC_ADVENTURE_SETTINGS:
if($this->c === false){
$this->data["flags"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeInt($this->data["flags"]);
}
break;
case MC_ENTITY_DATA:
if($this->c === false){
$this->data["x"] = Utils::readShort($this->get(2));
$this->data["y"] = ord($this->get(1));
$this->data["z"] = Utils::readShort($this->get(2));
$this->data["namedtag"] = $this->get(true);
}else{
$this->raw .= Utils::writeShort($this->data["x"]);
$this->raw .= chr($this->data["y"]);
$this->raw .= Utils::writeShort($this->data["z"]);
$this->raw .= $this->data["namedtag"];
}
break;
default:
if($this->c === false){
console("[DEBUG] Received unknown Data Packet ID 0x".dechex($pid), true, true, 2);
}else{
console("[DEBUG] Sent unknown Data Packet ID 0x".dechex($pid), true, true, 2);
}
break;
}
}
}

View File

@ -1,263 +0,0 @@
<?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/
*
*
*/
class MinecraftInterface{
public $client;
public $bandwidth;
private $socket;
private $data;
private $chunked;
private $toChunk;
private $needCheck;
function __construct($object, $server, $port = 25565, $listen = false, $client = false, $serverip = "0.0.0.0"){
$this->socket = new UDPSocket($server, $port, (bool) $listen, $serverip);
if($this->socket->connected === false){
console("[ERROR] Couldn't bind to $serverip:".$port, true, true, 0);
exit(1);
}
$this->bandwidth = array(0, 0, microtime(true));
$this->client = (bool) $client;
$this->start = microtime(true);
$this->chunked = array();
$this->toChunk = array();
$this->needCheck = array();
$object->schedule(1, array($this, "checkChunked"), array(), true);
}
public function close(){
return $this->socket->close(false);
}
protected function getStruct($pid){
if(isset(Protocol::$raknet[$pid])){
return Protocol::$raknet[$pid];
}
return false;
}
public function readPacket(){
$pk = $this->popPacket();
if($this->socket->connected === false){
return $pk;
}
$buf = "";
$source = false;
$port = 1;
$len = $this->socket->read($buf, $source, $port);
if($len === false){
return $pk;
}
$this->bandwidth[0] += $len;
$this->parsePacket($buf, $source, $port);
return ($pk !== false ? $pk : $this->popPacket());
}
private function parsePacket($buf, $source, $port){
$pid = ord($buf{0});
$struct = $this->getStruct($pid);
if($struct === false){
if(ServerAPI::request()->api->dhandle("server.unknownpacket", array(
"pid" => $pid,
"data" => array(),
"raw" => $buf,
"ip" => $source,
"port" => $port
)) !== true){
console("[ERROR] Unknown Packet ID 0x".Utils::strToHex(chr($pid)), true, true, 2);
}
return false;
}
$packet = new Packet($pid, $struct, $buf);
@$packet->parse();
if($pid === 0x99){
$CID = PocketMinecraftServer::clientID($source, $port);
if(!isset($this->chunked[$CID]) and $packet->data[0] !== 0){ //Drop packet
return false;
}
switch($packet->data[0]){
case 0:
$this->initChunked($CID, $source, $port);
return false;
case 1:
$this->stopChunked($CID);
return false;
case 3:
$this->ackChunked($CID, $data[1]["id"], $data[1]["index"]);
return false;
case 4:
$this->receiveChunked($CID, $data[1]["id"], $data[1]["index"], $data[1]["count"], $data[1]["data"]);
return true;
}
}
$this->data[] = array($pid, $packet->data, $buf, $source, $port);
return true;
}
public function checkChunked($CID){
$time = microtime(true);
foreach($this->needCheck as $CID => $packets){
if($packets[-1] < $time){
$d = $this->chunked[$CID];
unset($packets[-1]);
foreach($packets as $packet){
$this->writePacket(0x99, $packet, true, $d[1], $d[2], true);
}
$this->needCheck[$CID][-1] = $time + 5;
}
}
foreach($this->toChunk as $CID => $packets){
$d = $this->chunked[$CID];
$raw = "";
$MTU = 512;
foreach($packets as $packet){
$raw .= $packet;
if(($len = strlen($packet)) > $MTU){
$MTU = $len;
}
}
if($MTU > $d[0][2]){
$this->chunked[$CID][0][2] = $MTU;
}else{
$MTU = $d[0][2];
}
$raw = str_split(gzdeflate($raw, DEFLATEPACKET_LEVEL), $MTU - 9); // - 1 - 2 - 2 - 2 - 2
$count = count($raw);
$messageID = $this->chunked[$CID][0][0]++;
$this->chunked[$CID][0][0] &= 0xFFFF;
if(!isset($this->needCheck[$CID])){
$this->needCheck[$CID] = array();
}
$this->needCheck[$CID][$messageID] = array(-1 => $time + 1);
foreach($raw as $index => $r){
$p = "\x99\x02".Utils::writeShort($messageID).Utils::writeShort($index).Utils::writeShort($count).Utils::writeShort(strlen($r)).$r;
$this->needCheck[$CID][$messageID][$index] = $p;
$this->writePacket(0x99, $p, true, $d[1], $d[2], true);
}
unset($this->toChunk[$CID]);
}
}
public function isChunked($CID){
return isset($this->chunked[$CID]);
}
private function initChunked($CID, $source, $port){
console("[DEBUG] Starting DEFLATEPacket for $source:$port", true, true, 2);
$this->chunked[$CID] = array(
0 => array(0, 0, 0), //index, sent/received; MTU
1 => $source,
2 => $port,
3 => array(), //Received packets
);
$this->writePacket(0x99, array(
0 => 0, //start
), false, $source, $port, true);
}
public function stopChunked($CID){
if(!isset($this->chunked[$CID])){
return false;
}
$this->writePacket(0x99, array(
0 => 1, //stop
), false, $this->chunked[$CID][1], $this->chunked[$CID][2], true);
console("[DEBUG] Stopping DEFLATEPacket for ".$this->chunked[$CID][1].":".$this->chunked[$CID][2], true, true, 2);
$this->chunked[$CID][3] = null;
$this->chunked[$CID][4] = null;
unset($this->chunked[$CID]);
unset($this->toChunk[$CID]);
unset($this->needCheck[$CID]);
}
private function ackChunked($CID, $ID, $index){
unset($this->needCheck[$CID][$ID][$index]);
if(count($this->needCheck[$CID][$ID]) <= 1){
unset($this->needCheck[$CID][$ID]);
}
}
private function receiveChunked($CID, $ID, $index, $count, $data){
if(!isset($this->chunked[$CID][3][$ID])){
$this->chunked[$CID][3][$ID] = array();
}
$this->chunked[$CID][3][$ID][$index] = $data;
if(count($this->chunked[$CID][3][$ID]) === $count){
ksort($this->chunked[$CID][3][$ID]);
$data = gzinflate(implode($this->chunked[$CID][3][$ID]), 524280);
unset($this->chunked[$CID][3][$ID]);
if($data === false or strlen($data) === 0){
console("[ERROR] Invalid DEFLATEPacket for ".$this->chunked[$CID][1].":".$this->chunked[$CID][2], true, true, 2);
}
$offset = 0;
while(($plen = Utils::readShort(substr($data, $offset, 2), false)) !== 0xFFFF or $offset >= $len){
$offset += 2;
$packet = substr($data, $offset, $plen);
$this->parsePacket($packet, $this->chunked[$CID][1], $this->chunked[$CID][2]);
}
}
}
public function popPacket(){
if(count($this->data) > 0){
$p = each($this->data);
unset($this->data[$p[0]]);
$p = $p[1];
return array("pid" => $p[0], "data" => $p[1], "raw" => $p[2], "ip" => $p[3], "port" => $p[4]);
}
return false;
}
public function writePacket($pid, $data = array(), $raw = false, $dest = false, $port = false, $force = false){
$CID = PocketMinecraftServer::clientID($dest, $port);
if($raw === false){
$packet = new Packet($pid, $this->getStruct($pid));
$packet->data = $data;
@$packet->create();
if($force === false and $this->isChunked($CID)){
if(!isset($this->toChunk[$CID])){
$this->toChunk[$CID] = array();
}
$this->toChunk[$CID][] = $packet->raw;
$write = strlen($packet->raw);
}else{
$write = $this->socket->write($packet->raw, $dest, $port);
$this->bandwidth[1] += $write;
}
}else{
if($force === false and $this->isChunked($CID)){
if(!isset($this->toChunk[$CID])){
$this->toChunk[$CID] = array();
}
$this->toChunk[$CID][] = $data;
$write = strlen($data);
}else{
$write = $this->socket->write($data, $dest, $port);
$this->bandwidth[1] += $write;
}
}
return $write;
}
}
?>

View File

@ -1,339 +0,0 @@
<?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/
*
*
*/
class Packet{
private $struct;
protected $pid, $packet;
public $data, $raw;
function __construct($pid, $struct, $data = ""){
$this->pid = $pid;
$this->offset = 1;
$this->raw = $data;
$this->data = array();
if($data === ""){
$this->addRaw(chr($pid));
}
$this->struct = $struct;
}
public function create($raw = false){
foreach($this->struct as $field => $type){
if(!isset($this->data[$field])){
$this->data[$field] = "";
}
if($raw === true){
$this->addRaw($this->data[$field]);
continue;
}
switch($type){
case "special1":
switch($this->pid){
case 0x99:
if($this->data[0] >= 2){
$this->addRaw(Utils::writeShort($this->data[1]["id"]));
$this->addRaw(Utils::writeShort($this->data[1]["index"]));
if($this->data[0] === 2){
$this->addRaw(Utils::writeShort($this->data[1]["count"]));
$this->addRaw(Utils::writeShort(strlen($this->data[1]["data"])).$this->data[1]["data"]);
}
}
break;
case 0xc0:
case 0xa0:
$payload = "";
$records = 0;
$pointer = 0;
sort($this->data[$field], SORT_NUMERIC);
$max = count($this->data[$field]);
while($pointer < $max){
$type = true;
$curr = $start = $this->data[$field][$pointer];
for($i = $start + 1; $i < $max; ++$i){
$n = $this->data[$field][$i];
if(($n - $curr) === 1){
$curr = $end = $n;
$type = false;
$pointer = $i + 1;
}else{
break;
}
}
++$pointer;
if($type === false){
$payload .= Utils::writeBool(false);
$payload .= strrev(Utils::writeTriad($start));
$payload .= strrev(Utils::writeTriad($end));
}else{
$payload .= Utils::writeBool(true);
$payload .= strrev(Utils::writeTriad($start));
}
++$records;
}
$this->addRaw(Utils::writeShort($records) . $payload);
break;
case 0x05:
$this->addRaw($this->data[$field]);
break;
}
break;
case "customData":
$this->addRaw(chr($this->data[1]));
if($this->data[2]["id"] === false){
$this->addRaw($this->data[2]["raw"]);
}else{
switch($this->data[1]){
case 0x40:
$reply = new CustomPacketHandler($this->data[2]["id"], "", $this->data[2], true);
$this->addRaw(Utils::writeShort((strlen($reply->raw) + 1) << 3));
$this->addRaw(strrev(Utils::writeTriad($this->data[2]["count"])));
$this->addRaw(chr($this->data[2]["id"]));
$this->addRaw($reply->raw);
break;
case 0x00:
$raw = new CustomPacketHandler($this->data[2]["id"], "", $this->data[2], true);
$raw = $raw->raw;
$this->addRaw(Utils::writeShort((strlen($raw) + 1) << 3));
$this->addRaw(chr($this->data[2]["id"]));
$this->addRaw($raw);
break;
}
}
break;
case "magic":
$this->addRaw(RAKNET_MAGIC);
break;
case "float":
$this->addRaw(Utils::writeFloat($this->data[$field]));
break;
case "triad":
$this->addRaw(Utils::writeTriad($this->data[$field]));
break;
case "itriad":
$this->addRaw(strrev(Utils::writeTriad($this->data[$field])));
break;
case "int":
$this->addRaw(Utils::writeInt($this->data[$field]));
break;
case "double":
$this->addRaw(Utils::writeDouble($this->data[$field]));
break;
case "long":
$this->addRaw(Utils::writeLong($this->data[$field]));
break;
case "bool":
case "boolean":
$this->addRaw(Utils::writeBool($this->data[$field]));
break;
case "ubyte":
case "byte":
$this->addRaw(Utils::writeByte($this->data[$field]));
break;
case "short":
$this->addRaw(Utils::writeShort($this->data[$field]));
break;
case "string":
$this->addRaw(Utils::writeShort(strlen($this->data[$field])));
$this->addRaw($this->data[$field]);
break;
default:
$this->addRaw(Utils::writeByte($this->data[$field]));
break;
}
}
}
private function get($len = true){
if($len === true){
$data = substr($this->raw, $this->offset);
$this->offset = strlen($this->raw);
return $data;
}
$data = substr($this->raw, $this->offset, $len);
$this->offset += $len;
return $data;
}
protected function addRaw($str){
$this->raw .= $str;
return $str;
}
public function parse(){
foreach($this->struct as $field => $type){
switch($type){
case "special1":
switch($this->pid){
case 0x07:
$this->data[] = $this->get(5);
break;
case 0x99:
if($this->data[0] >= 2){ //
$messageID = Utils::readShort($this->get(2), false);
$messageIndex = Utils::readShort($this->get(2), false);
$this->data[1] = array("id" => $messageID, "index" => $messageIndex);
if($this->data[0] === 2){
$this->data[1]["count"] = Utils::readShort($this->get(2), false);
$dataLength = Utils::readShort($this->get(2), false);
$this->data[1]["data"] = $this->get($dataLength);
}
}
break;
case 0xc0:
case 0xa0:
$cnt = Utils::readShort($this->get(2), false);
$this->data[$field] = array();
for($i = 0; $i < $cnt; ++$i){
if(Utils::readBool($this->get(1)) === false){
$start = Utils::readTriad(strrev($this->get(3)));
$end = Utils::readTriad(strrev($this->get(3)));
for($c = $start; $c <= $end; ++$c){
$this->data[$field][] = $c;
}
}else{
$this->data[$field][] = Utils::readTriad(strrev($this->get(3)));
}
}
break;
case 0x05:
$this->data[] = $this->get(true);
break;
}
break;
case "customData":
$raw = $this->get(true);
$len = strlen($raw);
$offset = 0;
$this->data["packets"] = array();
while($len > $offset){
$pid = ord($raw{$offset});
++$offset;
$reliability = ($pid & 0b11100000) >> 5;
$hasSplit = ($pid & 0b00010000) >> 4;
$length = Utils::readShort(substr($raw, $offset, 2), false);
$offset += 2;
if($reliability === 2
or $reliability === 3
or $reliability === 4
or $reliability === 6
or $reliability === 7){
$messageIndex = Utils::readTriad(strrev(substr($raw, $offset, 3)));
$offset += 3;
}else{
$messageIndex = 0;
}
if($reliability === 1
or $reliability === 3
or $reliability === 4
or $reliability === 7){
$orderIndex = Utils::readTriad(strrev(substr($raw, $offset, 3)));
$offset += 3;
$orderChannel = ord($raw{$offset}); //5 bits, 32 values
++$offset;
}else{
$orderIndex = 0;
$orderChannel = 0;
}
if($hasSplit === 1){
$splitCount = Utils::readInt(substr($raw, $offset, 4));
$offset += 4;
$splitID = Utils::readShort(substr($raw, $offset, 2));
$offset += 2;
$splitIndex = Utils::readInt(substr($raw, $offset, 4));
$offset += 4;
//error! no split packets allowed!
break;
}else{
$splitCount = 0;
$splitID = 0;
$splitIndex = 0;
}
if($length == 0
or $orderingChannel >= 32
or ($hasSplit === 1 and $splitIndex >= $splitCount)){
continue;
}
$ln = ceil($length / 8);
$id = ord($raw{$offset});
++$offset;
$pak = substr($raw, $offset, $ln - 1);
$offset += $ln - 1;
$pk = new CustomPacketHandler($id, $pak);
$pk->data["length"] = $ln;
$pk->data["id"] = $id;
$pk->data["counter"] = $messageIndex;
$pk->data["packetName"] = $pk->name;
$this->data["packets"][] = array($pid, $pk->data, $pak);
}
break;
case "magic":
$this->data[] = $this->get(16);
break;
case "triad":
$this->data[] = Utils::readTriad($this->get(3));
break;
case "itriad":
$this->data[] = Utils::readTriad(strrev($this->get(3)));
break;
case "int":
$this->data[] = Utils::readInt($this->get(4));
break;
case "string":
$this->data[] = $this->get(Utils::readShort($this->get(2)));
break;
case "long":
$this->data[] = Utils::readLong($this->get(8));
break;
case "byte":
$this->data[] = Utils::readByte($this->get(1));
break;
case "ubyte":
$this->data[] = ord($this->get(1));
break;
case "float":
$this->data[] = Utils::readFloat($this->get(4));
break;
case "double":
$this->data[] = Utils::readDouble($this->get(8));
break;
case "ushort":
$this->data[] = Utils::readShort($this->get(2), false);
break;
case "short":
$this->data[] = Utils::readShort($this->get(2));
break;
case "bool":
case "boolean":
$this->data[] = Utils::readBool($this->get(1));
break;
}
}
}
}

View File

@ -1,341 +0,0 @@
<?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/
*
*
*/
define("DEFLATEPACKET_LEVEL", 1);
define("CURRENT_STRUCTURE", 5);
define("CURRENT_PROTOCOL", 12);
define("RAKNET_MAGIC", "\x00\xff\xff\x00\xfe\xfe\xfe\xfe\xfd\xfd\xfd\xfd\x12\x34\x56\x78");
define("MC_PING", 0x00);
define("MC_PONG", 0x03);
define("MC_CLIENT_CONNECT", 0x09);
define("MC_SERVER_HANDSHAKE", 0x10);
define("MC_CLIENT_HANDSHAKE", 0x13);
define("MC_SERVER_FULL", 0x14);
define("MC_DISCONNECT", 0x15);
define("MC_BANNED", 0x17);
define("MC_LOGIN", 0x82);
define("MC_LOGIN_STATUS", 0x83);
define("MC_READY", 0x84);
define("MC_CHAT", 0x85);
define("MC_SET_TIME", 0x86);
define("MC_START_GAME", 0x87);
define("MC_ADD_MOB", 0x88);
define("MC_ADD_PLAYER", 0x89);
define("MC_REMOVE_PLAYER", 0x8a);
define("MC_ADD_ENTITY", 0x8c);
define("MC_REMOVE_ENTITY", 0x8d);
define("MC_ADD_ITEM_ENTITY", 0x8e);
define("MC_TAKE_ITEM_ENTITY", 0x8f);
define("MC_MOVE_ENTITY", 0x90);
define("MC_MOVE_ENTITY_POSROT", 0x93);
define("MC_MOVE_PLAYER", 0x94);
define("MC_PLACE_BLOCK", 0x95);
define("MC_REMOVE_BLOCK", 0x96);
define("MC_UPDATE_BLOCK", 0x97);
define("MC_ADD_PAINTING", 0x98);
define("MC_EXPLOSION", 0x99);
define("MC_LEVEL_EVENT", 0x9a);
define("MC_TILE_EVENT", 0x9b);
define("MC_ENTITY_EVENT", 0x9c);
define("MC_REQUEST_CHUNK", 0x9d);
define("MC_CHUNK_DATA", 0x9e);
define("MC_PLAYER_EQUIPMENT", 0x9f);
define("MC_PLAYER_ARMOR_EQUIPMENT", 0xa0);
define("MC_INTERACT", 0xa1);
define("MC_USE_ITEM", 0xa2);
define("MC_PLAYER_ACTION", 0xa3);
define("MC_HURT_ARMOR", 0xa5);
define("MC_SET_ENTITY_DATA", 0xa6);
define("MC_SET_ENTITY_MOTION", 0xa7);
//define("MC_SET_RIDING_PACKET", 0xa8);
define("MC_SET_HEALTH", 0xa9);
define("MC_SET_SPAWN_POSITION", 0xaa);
define("MC_ANIMATE", 0xab);
define("MC_RESPAWN", 0xac);
define("MC_SEND_INVENTORY", 0xad);
define("MC_DROP_ITEM", 0xae);
define("MC_CONTAINER_OPEN", 0xaf);
define("MC_CONTAINER_CLOSE", 0xb0);
define("MC_CONTAINER_SET_SLOT", 0xb1);
define("MC_CONTAINER_SET_DATA", 0xb2);
define("MC_CONTAINER_SET_CONTENT", 0xb3);
//define("MC_CONTAINER_ACK", 0xb4);
define("MC_CLIENT_MESSAGE", 0xb5);
define("MC_ADVENTURE_SETTINGS", 0xb6);
define("MC_ENTITY_DATA", 0xb7);
class Protocol{
public static $dataName = array(
MC_PING => "Ping",
MC_CLIENT_CONNECT => "Client Connect",
MC_SERVER_HANDSHAKE => "Server Handshake",
MC_CLIENT_HANDSHAKE => "Client Handshake",
//MC_SERVER_FULL => "Server Full",
MC_DISCONNECT => "Disconnect",
0x18 => "Unknown",
MC_LOGIN => "Login",
MC_LOGIN_STATUS => "Login Status",
MC_READY => "Ready",
MC_CHAT => "Chat",
MC_SET_TIME => "Set Time",
MC_START_GAME => "Start Game",
MC_ADD_MOB => "Add Mob",
MC_ADD_PLAYER => "Add Player",
MC_ADD_ENTITY => "Add Entity",
MC_REMOVE_ENTITY => "Remove Entity",
MC_ADD_ITEM_ENTITY => "Add Item",
MC_TAKE_ITEM_ENTITY => "Take Item",
MC_MOVE_ENTITY => "Move Entity",
MC_MOVE_ENTITY_POSROT => "Move Entity PosRot",
MC_MOVE_PLAYER => "Move Player",
MC_PLACE_BLOCK => "Place Block",
MC_REMOVE_BLOCK => "Remove Block",
MC_UPDATE_BLOCK => "Update Block",
MC_ADD_PAINTING => "Add Painting",
MC_EXPLOSION => "Explosion",
MC_LEVEL_EVENT => "Level Event",
MC_ENTITY_EVENT => "Entity Event",
MC_REQUEST_CHUNK => "Chunk Request",
MC_CHUNK_DATA => "Chunk Data",
MC_PLAYER_EQUIPMENT => "Player Equipment",
MC_PLAYER_ARMOR_EQUIPMENT => "Player Armor",
MC_INTERACT => "Interact",
MC_USE_ITEM => "Use Item",
MC_PLAYER_ACTION => "Player Action",
MC_SET_ENTITY_DATA => "Entity Data",
MC_SET_ENTITY_MOTION => "Entity Motion",
MC_HURT_ARMOR => "Hurt Armor",
MC_SET_HEALTH => "Set Health",
MC_SET_SPAWN_POSITION => "Set Spawn Position",
MC_ANIMATE => "Animate",
MC_RESPAWN => "Respawn",
MC_SEND_INVENTORY => "Send Inventory",
MC_DROP_ITEM => "Drop Item",
MC_CONTAINER_OPEN => "Open Container",
MC_CONTAINER_CLOSE => "Close Container",
MC_CONTAINER_SET_SLOT => "Set Container Slot",
MC_CLIENT_MESSAGE => "Client Message",
MC_ADVENTURE_SETTINGS => "Adventure Settings",
MC_ENTITY_DATA => "Entity Data",
);
public static $packetName = array(
0x01 => "ID_CONNECTED_PING_OPEN_CONNECTIONS", //RakNet
0x02 => "ID_UNCONNECTED_PING_OPEN_CONNECTIONS", //RakNet
0x05 => "ID_OPEN_CONNECTION_REQUEST_1", //RakNet
0x06 => "ID_OPEN_CONNECTION_REPLY_1", //RakNet
0x07 => "ID_OPEN_CONNECTION_REQUEST_2", //RakNet
0x08 => "ID_OPEN_CONNECTION_REPLY_2", //RakNet
0x1a => "ID_INCOMPATIBLE_PROTOCOL_VERSION", //RakNet
0x1c => "ID_UNCONNECTED_PONG", //RakNet
0x1d => "ID_ADVERTISE_SYSTEM", //RakNet
0x80 => "Custom Packet", //Minecraft Implementation
0x84 => "Custom Packet", //Minecraft Implementation
0x88 => "Custom Packet", //Minecraft Implementation
0x8c => "Custom Packet", //Minecraft Implementation
0xa0 => "NACK", //Minecraft Implementation
0xc0 => "ACK", //Minecraft Implementation
);
public static $raknet = array(
0x01 => array(
"long", //Ping ID
"magic",
),
0x02 => array(
"long", //Ping ID
"magic",
),
0x05 => array(
"magic",
"byte", //Protocol Version
"special1", //MTU Size Null Lenght
),
0x06 => array(
"magic",
"long", //Server GUID
"byte", //Server Security
"short", //MTU Size
),
0x07 => array(
"magic",
"special1", //Security Cookie
"short", //Server UDP Port
"short", //MTU Size
"long", //Client GUID
),
0x08 => array(
"magic",
"long", //Server GUID
"short", //Client UDP Port
"short", //MTU Size
"byte", //Security
),
0x1a => array(
"byte", //Server Version
"magic",
"long", //Server GUID
),
0x1c => array(
"long", //Ping ID
"long", //Server GUID
"magic",
"string", //Data
),
0x1d => array(
"long", //Ping ID
"long", //Server GUID
"magic",
"string", //Data
),
0x80 => array(
"itriad",
"customData",
),
0x81 => array(
"itriad",
"customData",
),
0x82 => array(
"itriad",
"customData",
),
0x83 => array(
"itriad",
"customData",
),
0x84 => array(
"itriad",
"customData",
),
0x85 => array(
"itriad",
"customData",
),
0x86 => array(
"itriad",
"customData",
),
0x87 => array(
"itriad",
"customData",
),
0x88 => array(
"itriad",
"customData",
),
0x89 => array(
"itriad",
"customData",
),
0x8a => array(
"itriad",
"customData",
),
0x8b => array(
"itriad",
"customData",
),
0x8c => array(
"itriad",
"customData",
),
0x8d => array(
"itriad",
"customData",
),
0x8e => array(
"itriad",
"customData",
),
0x8f => array(
"itriad",
"ubyte",
"customData",
),
0x99 => array(
"byte",
"special1",
),
0xa0 => array(
"special1",
),
0xc0 => array(
"special1",
),
);
}

View File

@ -1,133 +0,0 @@
<?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/
*
*
*/
/*
Implementation of the UT3 Query Protocol (GameSpot)
Source: http://wiki.unrealadmin.org/UT3_query_protocol
*/
class Query{
private $socket, $server, $lastToken, $token, $longData, $timeout;
public function __construct(){
console("[INFO] Starting GS4 status listener");
$this->server = ServerAPI::request();
$addr = ($ip = $this->server->api->getProperty("server-ip")) != "" ? $ip:"0.0.0.0";
$port = $this->server->api->getProperty("server-port");
console("[INFO] Setting query port to $port");
/*
The Query protocol is built on top of the existing Minecraft PE UDP network stack.
Because the 0xFE packet does not exist in the MCPE protocol,
we can identify Query packets and remove them from the packet queue.
Then, the Query class handles itself sending the packets in raw form, because
packets can conflict with the MCPE ones.
*/
$this->server->addHandler("server.unknownpacket", array($this, "packetHandler"), 50);
$this->server->schedule(20 * 30, array($this, "regenerateToken"), array(), true);
$this->regenerateToken();
$this->lastToken = $this->token;
$this->regenerateInfo();
console("[INFO] Query running on $addr:$port");
}
public function regenerateInfo(){
$str = "";
$plist = "PocketMine-MP ".MAJOR_VERSION;
$pl = $this->server->api->plugin->getList();
if(count($pl) > 0){
$plist .= ":";
foreach($pl as $p){
$plist .= " ".str_replace(array(";", ":", " "), array("", "", "_"), $p["name"])." ".str_replace(array(";", ":", " "), array("", "", "_"), $p["version"]).";";
}
$plist = substr($plist, 0, -1);
}
$KVdata = array(
"splitnum" => chr(128),
"hostname" => $this->server->name,
"gametype" => ($this->server->gamemode & 0x01) === 0 ? "SMP":"CMP",
"game_id" => "MINECRAFTPE",
"version" => CURRENT_MINECRAFT_VERSION,
"server_engine" => "PocketMine-MP ".MAJOR_VERSION,
"plugins" => $plist,
"map" => $this->server->api->level->getDefault()->getName(),
"numplayers" => count($this->server->clients),
"maxplayers" => $this->server->maxClients,
"whitelist" => $this->server->api->getProperty("white-list") === true ? "on":"off",
"hostport" => $this->server->api->getProperty("server-port"),
//"hostip" => $this->server->api->getProperty("server-ip", "0.0.0.0")
);
foreach($KVdata as $key => $value){
$str .= $key."\x00".$value."\x00";
}
$str .= "\x00\x01player_\x00\x00";
foreach($this->server->clients as $player){
if($player->username != ""){
$str .= $player->username."\x00";
}
}
$str .= "\x00";
$this->longData = $str;
$this->timeout = microtime(true) + 5;
}
public function regenerateToken(){
$this->lastToken = $this->token;
$this->token = Utils::readInt("\x00".Utils::getRandomBytes(3, false));
}
public function packetHandler(&$packet, $event){
if($event !== "server.unknownpacket"){
return;
}
$magic = substr($packet["raw"], 0, 2);
$offset = 2;
if($magic !== "\xfe\xfd"){
return;
}
$type = ord($packet["raw"]{2});
++$offset;
$sessionID = Utils::readInt(substr($packet["raw"], $offset, 4));
$offset += 4;
$payload = substr($packet["raw"], $offset);
switch($type){
case 9: //Handshake
$this->server->send(9, chr(9).Utils::writeInt($sessionID).$this->token."\x00", true, $packet["ip"], $packet["port"]);
break;
case 0: //Stat
$token = Utils::readInt(substr($payload, 0, 4));
if($token !== $this->token and $token !== $this->lastToken){
break;
}
if(strlen($payload) === 8){
if($this->timeout < microtime(true)){
$this->regenerateInfo();
}
$this->server->send(0, chr(0).Utils::writeInt($sessionID).$this->longData, true, $packet["ip"], $packet["port"]);
}else{
$this->server->send(0, chr(0).Utils::writeInt($sessionID).$this->server->name."\x00".(($this->server->gamemode & 0x01) === 0 ? "SMP":"CMP")."\x00".$this->server->api->level->getDefault()->getName()."\x00".count($this->server->clients)."\x00".$this->server->maxClients."\x00".Utils::writeLShort($this->server->api->getProperty("server-port")).$this->server->api->getProperty("server-ip", "0.0.0.0")."\x00", true, $packet["ip"], $packet["port"]);
}
break;
}
return true;
}
}

View File

@ -1,76 +0,0 @@
<?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/
*
*
*/
class UDPSocket{
public $connected, $sock, $server;
function __construct($server, $port, $listen = false, $serverip = "0.0.0.0"){
$this->server = $server;
$this->port = $port;
$this->sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($this->sock, SOL_SOCKET, SO_BROADCAST, 1); //Allow sending broadcast messages
if($listen !== true){
$this->connected = true;
$this->unblock();
}else{
if(socket_bind($this->sock, $serverip, $port) === true){
socket_set_option($this->sock, SOL_SOCKET, SO_REUSEADDR, 0);
socket_set_option($this->sock, SOL_SOCKET, SO_SNDBUF, 65535);
socket_set_option($this->sock, SOL_SOCKET, SO_RCVBUF, 65535);
$this->unblock();
$this->connected = true;
}else{
$this->connected = false;
}
}
}
public function close($error = 125){
$this->connected = false;
return @socket_close($this->sock);
}
public function block(){
socket_set_block($this->sock);
}
public function unblock(){
socket_set_nonblock($this->sock);
}
public function read(&$buf, &$source, &$port){
if($this->connected === false){
return false;
}
return @socket_recvfrom($this->sock, $buf, 65535, 0, $source, $port);
}
public function write($data, $dest = false, $port = false){
if($this->connected === false){
return false;
}
return @socket_sendto($this->sock, $data, strlen($data), 0, ($dest === false ? $this->server:$dest), ($port === false ? $this->port:$port));
}
}
?>

View File

@ -1,417 +0,0 @@
<?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/
*
*
*/
define("PMF_CURRENT_LEVEL_VERSION", 0x00);
class PMFLevel extends PMF{
private $levelData = array();
private $locationTable = array();
public $isLoaded = true;
private $log = 4;
private $payloadOffset = 0;
private $chunks = array();
private $chunkChange = array();
public function getData($index){
if(!isset($this->levelData[$index])){
return false;
}
return ($this->levelData[$index]);
}
public function setData($index, $data){
if(!isset($this->levelData[$index])){
return false;
}
$this->levelData[$index] = $data;
return true;
}
public function close(){
$chunks = null;
unset($chunks, $chunkChange, $locationTable);
parent::close();
}
public function __construct($file, $blank = false){
if(is_array($blank)){
$this->create($file, 0);
$this->levelData = $blank;
$this->createBlank();
$this->isLoaded = true;
$this->log = (int) ((string) log($this->levelData["width"], 2));
}else{
if($this->load($file) !== false){
$this->parseInfo();
if($this->parseLevel() === false){
$this->isLoaded = false;
}else{
$this->isLoaded = true;
$this->log = (int) ((string) log($this->levelData["width"], 2));
}
}else{
$this->isLoaded = false;
}
}
}
public function saveData($locationTable = true){
$this->levelData["version"] = PMF_CURRENT_LEVEL_VERSION;
@ftruncate($this->fp, 5);
$this->seek(5);
$this->write(chr($this->levelData["version"]));
$this->write(Utils::writeShort(strlen($this->levelData["name"])).$this->levelData["name"]);
$this->write(Utils::writeInt($this->levelData["seed"]));
$this->write(Utils::writeInt($this->levelData["time"]));
$this->write(Utils::writeFloat($this->levelData["spawnX"]));
$this->write(Utils::writeFloat($this->levelData["spawnY"]));
$this->write(Utils::writeFloat($this->levelData["spawnZ"]));
$this->write(chr($this->levelData["width"]));
$this->write(chr($this->levelData["height"]));
$extra = gzdeflate($this->levelData["extra"], PMF_LEVEL_DEFLATE_LEVEL);
$this->write(Utils::writeShort(strlen($extra)).$extra);
$this->payloadOffset = ftell($this->fp);
if($locationTable !== false){
$this->writeLocationTable();
}
}
private function createBlank(){
$this->saveData(false);
$this->locationTable = array();
$cnt = pow($this->levelData["width"], 2);
@mkdir(dirname($this->file)."/chunks/", 0755);
for($index = 0; $index < $cnt; ++$index){
$this->chunks[$index] = false;
$this->chunkChange[$index] = false;
$this->locationTable[$index] = array(
0 => 0,
);
$this->write(Utils::writeShort(0));
$X = $Z = null;
$this->getXZ($index, $X, $Z);
@file_put_contents($this->getChunkPath($X, $Z), gzdeflate("", PMF_LEVEL_DEFLATE_LEVEL));
}
if(!file_exists(dirname($this->file)."/entities.yml")){
$entities = new Config(dirname($this->file)."/entities.yml", CONFIG_YAML);
$entities->save();
}
if(!file_exists(dirname($this->file)."/tiles.yml")){
$tiles = new Config(dirname($this->file)."/tiles.yml", CONFIG_YAML);
$tiles->save();
}
}
protected function parseLevel(){
if($this->getType() !== 0x00){
return false;
}
$this->seek(5);
$this->levelData["version"] = ord($this->read(1));
if($this->levelData["version"] > PMF_CURRENT_LEVEL_VERSION){
return false;
}
$this->levelData["name"] = $this->read(Utils::readShort($this->read(2), false));
$this->levelData["seed"] = Utils::readInt($this->read(4));
$this->levelData["time"] = Utils::readInt($this->read(4));
$this->levelData["spawnX"] = Utils::readFloat($this->read(4));
$this->levelData["spawnY"] = Utils::readFloat($this->read(4));
$this->levelData["spawnZ"] = Utils::readFloat($this->read(4));
$this->levelData["width"] = ord($this->read(1));
$this->levelData["height"] = ord($this->read(1));
if(($this->levelData["width"] !== 16 and $this->levelData["width"] !== 32) or $this->levelData["height"] !== 8){
return false;
}
$lastseek = ftell($this->fp);
if(($len = $this->read(2)) === false or ($this->levelData["extra"] = @gzinflate($this->read(Utils::readShort($len, false)))) === false){ //Corruption protection
console("[NOTICE] Empty/corrupt location table detected, forcing recovery");
fseek($this->fp, $lastseek);
$c = gzdeflate("");
$this->write(Utils::writeShort(strlen($c)).$c);
$this->payloadOffset = ftell($this->fp);
$this->levelData["extra"] = "";
$cnt = pow($this->levelData["width"], 2);
for($index = 0; $index < $cnt; ++$index){
$this->write("\x00\xFF"); //Force index recreation
}
fseek($this->fp, $this->payloadOffset);
}else{
$this->payloadOffset = ftell($this->fp);
}
return $this->readLocationTable();
}
public function getIndex($X, $Z){
$X = (int) $X;
$Z = (int) $Z;
return ($Z << $this->log) + $X;
}
public function getXZ($index, &$X = null, &$Z = null){
$X = $index >> $this->log;
$Z = $index & (pow($this->log, 2) - 1);
return array($X, $Z);
}
private function readLocationTable(){
$this->locationTable = array();
$cnt = pow($this->levelData["width"], 2);
$this->seek($this->payloadOffset);
for($index = 0; $index < $cnt; ++$index){
$this->chunks[$index] = false;
$this->chunkChange[$index] = false;
$this->locationTable[$index] = array(
0 => Utils::readShort($this->read(2)), //16 bit flags
);
}
return true;
}
private function writeLocationTable(){
$cnt = pow($this->levelData["width"], 2);
@ftruncate($this->fp, $this->payloadOffset);
$this->seek($this->payloadOffset);
for($index = 0; $index < $cnt; ++$index){
$this->write(Utils::writeShort($this->locationTable[$index][0]));
}
}
private function getChunkPath($X, $Z){
return dirname($this->file)."/chunks/".$Z.".".$X.".pmc";
}
public function loadChunk($X, $Z){
$X = (int) $X;
$Z = (int) $Z;
$index = $this->getIndex($X, $Z);
if($this->isChunkLoaded($X, $Z)){
return true;
}elseif(!isset($this->locationTable[$index])){
return false;
}
$info = $this->locationTable[$index];
$this->seek($info[0]);
$chunk = @gzopen($this->getChunkPath($X, $Z), "rb");
if($chunk === false){
return false;
}
$this->chunks[$index] = array();
$this->chunkChange[$index] = array(-1 => false);
for($Y = 0; $Y < $this->levelData["height"]; ++$Y){
$t = 1 << $Y;
if(($info[0] & $t) === $t){
// 4096 + 2048 + 2048, Block Data, Meta, Light
if(strlen($this->chunks[$index][$Y] = gzread($chunk, 8192)) < 8192){
console("[NOTICE] Empty corrupt chunk detected [$X,$Z,:$Y], recovering contents");
$this->fillMiniChunk($X, $Z, $Y);
}
}else{
$this->chunks[$index][$Y] = false;
}
}
@gzclose($chunk);
return true;
}
public function unloadChunk($X, $Z, $save = true){
$X = (int) $X;
$Z = (int) $Z;
if(!$this->isChunkLoaded($X, $Z)){
return false;
}elseif($save !== false){
$this->saveChunk($X, $Z);
}
$index = $this->getIndex($X, $Z);
$this->chunks[$index] = null;
$this->chunkChange[$index] = null;
unset($this->chunks[$index], $this->chunkChange[$index]);
return true;
}
public function isChunkLoaded($X, $Z){
$index = $this->getIndex($X, $Z);
if(!isset($this->chunks[$index]) or $this->chunks[$index] === false){
return false;
}
return true;
}
protected function isMiniChunkEmpty($X, $Z, $Y){
$index = $this->getIndex($X, $Z);
if($this->chunks[$index][$Y] !== false){
if(substr_count($this->chunks[$index][$Y], "\x00") < 8192){
return false;
}
}
return true;
}
protected function fillMiniChunk($X, $Z, $Y){
if($this->isChunkLoaded($X, $Z) === false){
return false;
}
$index = $this->getIndex($X, $Z);
$this->chunks[$index][$Y] = str_repeat("\x00", 8192);
$this->chunkChange[$index][-1] = true;
$this->chunkChange[$index][$Y] = 8192;
$this->locationTable[$index][0] |= 1 << $Y;
return true;
}
public function getMiniChunk($X, $Z, $Y){
if($this->loadChunk($X, $Z) === false){
return str_repeat("\x00", 8192);
}
$index = $this->getIndex($X, $Z);
if($this->chunks[$index][$Y] === false){
return str_repeat("\x00", 8192);
}
return $this->chunks[$index][$Y];
}
public function setMiniChunk($X, $Z, $Y, $data){
if($this->isChunkLoaded($X, $Z) === false){
$this->loadChunk($X, $Z);
}
if(strlen($data) !== 8192){
return false;
}
$index = $this->getIndex($X, $Z);
$this->chunks[$index][$Y] = (string) $data;
$this->chunkChange[$index][-1] = true;
$this->chunkChange[$index][$Y] = 8192;
$this->locationTable[$index][0] |= 1 << $Y;
return true;
}
public function getBlock($x, $y, $z){
$X = $x >> 4;
$Z = $z >> 4;
$Y = $y >> 4;
if($x < 0 or $z < 0 or $X >= $this->levelData["width"] or $Z >= $this->levelData["width"] or $Y >= $this->levelData["height"] or $y < 0){
return array(AIR, 0);
}
$index = $this->getIndex($X, $Z);
if(!isset($this->chunks[$index]) or $this->chunks[$index] === false){
if($this->loadChunk($X, $Z) === false){
return array(AIR, 0);
}
}elseif($this->chunks[$index][$Y] === false){
return array(AIR, 0);
}
$aX = $x - ($X << 4);
$aZ = $z - ($Z << 4);
$aY = $y - ($Y << 4);
$bindex = (int) ($aY + ($aX << 5) + ($aZ << 9));
$mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9));
$b = ord($this->chunks[$index][$Y]{$bindex});
$m = ord($this->chunks[$index][$Y]{$mindex});
if(($y & 1) === 0){
$m = $m & 0x0F;
}else{
$m = $m >> 4;
}
return array($b, $m);
}
public function setBlock($x, $y, $z, $block, $meta = 0){
$X = $x >> 4;
$Z = $z >> 4;
$Y = $y >> 4;
$block &= 0xFF;
$meta &= 0x0F;
if($X >= 32 or $Z >= 32 or $Y >= $this->levelData["height"] or $y < 0){
return false;
}
$index = $this->getIndex($X, $Z);
if(!isset($this->chunks[$index]) or $this->chunks[$index] === false){
if($this->loadChunk($X, $Z) === false){
return false;
}
}elseif($this->chunks[$index][$Y] === false){
$this->fillMiniChunk($X, $Z, $Y);
}
$aX = $x - ($X << 4);
$aZ = $z - ($Z << 4);
$aY = $y - ($Y << 4);
$bindex = (int) ($aY + ($aX << 5) + ($aZ << 9));
$mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9));
$old_b = ord($this->chunks[$index][$Y]{$bindex});
$old_m = ord($this->chunks[$index][$Y]{$mindex});
if(($y & 1) === 0){
$m = ($old_m & 0xF0) | $meta;
}else{
$m = ($meta << 4) | ($old_m & 0x0F);
}
if($old_b !== $block or $old_m !== $m){
$this->chunks[$index][$Y]{$bindex} = chr($block);
$this->chunks[$index][$Y]{$mindex} = chr($m);
if(!isset($this->chunkChange[$index][$Y])){
$this->chunkChange[$index][$Y] = 1;
}else{
++$this->chunkChange[$index][$Y];
}
$this->chunkChange[$index][-1] = true;
return true;
}
return false;
}
public function saveChunk($X, $Z){
$X = (int) $X;
$Z = (int) $Z;
if(!$this->isChunkLoaded($X, $Z)){
return false;
}
$index = $this->getIndex($X, $Z);
if(!isset($this->chunkChange[$index]) or $this->chunkChange[$index][-1] === false){//No changes in chunk
return true;
}
$chunk = @gzopen($this->getChunkPath($X, $Z), "wb".PMF_LEVEL_DEFLATE_LEVEL);
$bitmap = 0;
for($Y = 0; $Y < $this->levelData["height"]; ++$Y){
if($this->chunks[$index][$Y] !== false and ((isset($this->chunkChange[$index][$Y]) and $this->chunkChange[$index][$Y] === 0) or !$this->isMiniChunkEmpty($X, $Z, $Y))){
gzwrite($chunk, $this->chunks[$index][$Y]);
$bitmap |= 1 << $Y;
}else{
$this->chunks[$index][$Y] = false;
}
$this->chunkChange[$index][$Y] = 0;
}
$this->chunkChange[$index][-1] = false;
$this->locationTable[$index][0] = $bitmap;
$this->seek($this->payloadOffset + ($index << 1));
$this->write(Utils::writeShort($this->locationTable[$index][0]));
return true;
}
public function doSaveRound(){
foreach($this->chunks as $index => $chunk){
$this->getXZ($index, $X, $Z);
$this->saveChunk($X, $Z);
}
}
}

View File

@ -1,81 +0,0 @@
<?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/
*
*
*/
/***REM_START***/
require_once(FILE_PATH."/src/pmf/PMF.php");
/***REM_END***/
define("PMF_CURRENT_PLUGIN_VERSION", 0x02);
class PMFPlugin extends PMF{
private $pluginData = array();
public function __construct($file){
$this->load($file);
$this->parseInfo();
$this->parsePlugin();
}
public function getPluginInfo(){
return $this->pluginData;
}
protected function parsePlugin(){
if($this->getType() !== 0x01){
return false;
}
$this->seek(5);
$this->pluginData["fversion"] = ord($this->read(1));
if($this->pluginData["fversion"] > PMF_CURRENT_PLUGIN_VERSION){
return false;
}
$this->pluginData["name"] = $this->read(Utils::readShort($this->read(2), false));
$this->pluginData["version"] = $this->read(Utils::readShort($this->read(2), false));
$this->pluginData["author"] = $this->read(Utils::readShort($this->read(2), false));
if($this->pluginData["fversion"] >= 0x01){
$this->pluginData["apiversion"] = $this->read(Utils::readShort($this->read(2), false));
}else{
$this->pluginData["apiversion"] = Utils::readShort($this->read(2), false);
}
$this->pluginData["class"] = $this->read(Utils::readShort($this->read(2), false));
$this->pluginData["identifier"] = $this->read(Utils::readShort($this->read(2), false)); //Will be used to check for updates
if($this->pluginData["fversion"] >= 0x02){
$data = explode(";", gzinflate($this->read(Utils::readInt($this->read(4)))));
$this->pluginData["extra"] = array();
foreach($data as $v){
$v = trim($v);
if($v != ""){
$v = base64_decode($v);
$kl = strpos($v, ":");
$this->pluginData["extra"][substr($v, 0, $kl)] = substr($v, $kl + 1);
}
}
}else{
$this->pluginData["extra"] = gzinflate($this->read(Utils::readShort($this->read(2), false)));
}
$this->pluginData["code"] = "";
while(!feof($this->fp)){
$this->pluginData["code"] .= $this->read(4096);
}
$this->pluginData["code"] = gzinflate($this->pluginData["code"]);
}
}

View File

@ -0,0 +1,135 @@
<?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
*
*
*/
namespace pocketmine;
use pocketmine\utils\TextFormat;
/**
* Handles the achievement list and a bit more
*/
abstract class Achievement{
/**
* @var array[]
*/
public static $list = [
/*"openInventory" => array(
"name" => "Taking Inventory",
"requires" => [],
),*/
"mineWood" => [
"name" => "Getting Wood",
"requires" => [ //"openInventory",
],
],
"buildWorkBench" => [
"name" => "Benchmarking",
"requires" => [
"mineWood",
],
],
"buildPickaxe" => [
"name" => "Time to Mine!",
"requires" => [
"buildWorkBench",
],
],
"buildFurnace" => [
"name" => "Hot Topic",
"requires" => [
"buildPickaxe",
],
],
"acquireIron" => [
"name" => "Acquire hardware",
"requires" => [
"buildFurnace",
],
],
"buildHoe" => [
"name" => "Time to Farm!",
"requires" => [
"buildWorkBench",
],
],
"makeBread" => [
"name" => "Bake Bread",
"requires" => [
"buildHoe",
],
],
"bakeCake" => [
"name" => "The Lie",
"requires" => [
"buildHoe",
],
],
"buildBetterPickaxe" => [
"name" => "Getting an Upgrade",
"requires" => [
"buildPickaxe",
],
],
"buildSword" => [
"name" => "Time to Strike!",
"requires" => [
"buildWorkBench",
],
],
"diamonds" => [
"name" => "DIAMONDS!",
"requires" => [
"acquireIron",
],
],
];
public static function broadcast(Player $player, $achievementId){
if(isset(Achievement::$list[$achievementId])){
if(Server::getInstance()->getConfigString("announce-player-achievements", true) === true){
Server::getInstance()->broadcastMessage($player->getDisplayName() . " has just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
}else{
$player->sendMessage("You have just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
}
return true;
}
return false;
}
public static function add($achievementId, $achievementName, array $requires = []){
if(!isset(Achievement::$list[$achievementId])){
Achievement::$list[$achievementId] = [
"name" => $achievementName,
"requires" => $requires,
];
return true;
}
return false;
}
}

View File

@ -0,0 +1,32 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine;
class CompatibleClassLoader extends \BaseClassLoader{
/**
* @deprecated
*/
public function add($namespace, $paths){
$this->addPath(array_shift($paths));
}
}

View File

@ -0,0 +1,248 @@
<?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
*
*
*/
namespace pocketmine;
use pocketmine\network\protocol\Info;
use pocketmine\plugin\PluginBase;
use pocketmine\plugin\PluginLoadOrder;
use pocketmine\utils\Utils;
use pocketmine\utils\VersionString;
use raklib\RakLib;
class CrashDump{
/** @var Server */
private $server;
private $fp;
private $time;
private $data = [];
private $encodedData = null;
private $path;
public function __construct(Server $server){
$this->time = time();
$this->server = $server;
$this->path = $this->server->getDataPath() . "CrashDump_" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
$this->fp = fopen($this->path, "wb");
$this->data["time"] = $this->time;
$this->addLine($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", $this->time));
$this->addLine();
$this->baseCrash();
$this->generalData();
$this->pluginsData();
$this->extraData();
$this->encodeData();
}
public function getPath(){
return $this->path;
}
public function getEncodedData(){
return $this->encodedData;
}
public function getData(){
return $this->data;
}
private function encodeData(){
$this->addLine();
$this->addLine("----------------------REPORT THE DATA BELOW THIS LINE-----------------------");
$this->addLine();
$this->addLine("===BEGIN CRASH DUMP===");
$this->encodedData = zlib_encode(json_encode($this->data, JSON_UNESCAPED_SLASHES), ZLIB_ENCODING_DEFLATE, 9);
foreach(str_split(base64_encode($this->encodedData), 76) as $line){
$this->addLine($line);
}
$this->addLine("===END CRASH DUMP===");
}
private function pluginsData(){
if(class_exists("pocketmine\\plugin\\PluginManager", false)){
$this->addLine();
$this->addLine("Loaded plugins:");
$this->data["plugins"] = [];
foreach($this->server->getPluginManager()->getPlugins() as $p){
$d = $p->getDescription();
$this->data["plugins"][$d->getName()] = [
"name" => $d->getName(),
"version" => $d->getVersion(),
"authors" => $d->getAuthors(),
"api" => $d->getCompatibleApis(),
"enabled" => $p->isEnabled(),
"depends" => $d->getDepend(),
"softDepends" => $d->getSoftDepend(),
"main" => $d->getMain(),
"load" => $d->getOrder() === PluginLoadOrder::POSTWORLD ? "POSTWORLD" : "STARTUP",
"website" => $d->getWebsite()
];
$this->addLine($d->getName() . " " . $d->getVersion() . " by " . implode(", ", $d->getAuthors()) . " for API(s) " . implode(", ", $d->getCompatibleApis()));
}
}
}
private function extraData(){
global $arguments;
if($this->server->getProperty("auto-report.send-settings", true) !== false){
$this->data["parameters"] = (array) $arguments;
$this->data["server.properties"] = @file_get_contents($this->server->getDataPath() . "server.properties");
$this->data["server.properties"] = preg_replace("#^rcon\\.password=(.*)$#m", "rcon.password=******", $this->data["server.properties"]);
$this->data["pocketmine.yml"] = @file_get_contents($this->server->getDataPath() . "pocketmine.yml");
}else{
$this->data["pocketmine.yml"] = "";
$this->data["server.properties"] = "";
$this->data["parameters"] = [];
}
$extensions = [];
foreach(get_loaded_extensions() as $ext){
$extensions[$ext] = phpversion($ext);
}
$this->data["extensions"] = $extensions;
if($this->server->getProperty("auto-report.send-phpinfo", true) !== false){
ob_start();
phpinfo();
$this->data["phpinfo"] = ob_get_contents();
ob_end_clean();
}
}
private function baseCrash(){
global $lastExceptionError, $lastError;
if(isset($lastExceptionError)){
$error = $lastExceptionError;
}else{
$error = (array) error_get_last();
$error["trace"] = getTrace(4);
$errorConversion = [
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
E_PARSE => "E_PARSE",
E_NOTICE => "E_NOTICE",
E_CORE_ERROR => "E_CORE_ERROR",
E_CORE_WARNING => "E_CORE_WARNING",
E_COMPILE_ERROR => "E_COMPILE_ERROR",
E_COMPILE_WARNING => "E_COMPILE_WARNING",
E_USER_ERROR => "E_USER_ERROR",
E_USER_WARNING => "E_USER_WARNING",
E_USER_NOTICE => "E_USER_NOTICE",
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED",
];
$error["fullFile"] = $error["file"];
$error["file"] = cleanPath($error["file"]);
$error["type"] = isset($errorConversion[$error["type"]]) ? $errorConversion[$error["type"]] : $error["type"];
if(($pos = strpos($error["message"], "\n")) !== false){
$error["message"] = substr($error["message"], 0, $pos);
}
}
if(isset($lastError)){
$this->data["lastError"] = $lastError;
}
$this->data["error"] = $error;
unset($this->data["error"]["fullFile"]);
unset($this->data["error"]["trace"]);
$this->addLine("Error: " . $error["message"]);
$this->addLine("File: " . $error["file"]);
$this->addLine("Line: " . $error["line"]);
$this->addLine("Type: " . $error["type"]);
if(strpos($error["file"], "src/pocketmine/") === false and strpos($error["file"], "src/raklib/") === false and file_exists($error["fullFile"])){
$this->addLine();
$this->addLine("THIS CRASH WAS CAUSED BY A PLUGIN");
$this->data["plugin"] = true;
$reflection = new \ReflectionClass(PluginBase::class);
$file = $reflection->getProperty("file");
$file->setAccessible(true);
foreach($this->server->getPluginManager()->getPlugins() as $plugin){
$filePath = \pocketmine\cleanPath($file->getValue($plugin));
if(strpos($error["file"], $filePath) === 0){
$this->data["plugin"] = $plugin->getName();
$this->addLine("BAD PLUGIN: " . $plugin->getDescription()->getFullName());
break;
}
}
}else{
$this->data["plugin"] = false;
}
$this->addLine();
$this->addLine("Code:");
$this->data["code"] = [];
if($this->server->getProperty("auto-report.send-code", true) !== false){
$file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES);
for($l = max(0, $error["line"] - 10); $l < $error["line"] + 10; ++$l){
$this->addLine("[" . ($l + 1) . "] " . @$file[$l]);
$this->data["code"][$l + 1] = @$file[$l];
}
}
$this->addLine();
$this->addLine("Backtrace:");
foreach(($this->data["trace"] = $error["trace"]) as $line){
$this->addLine($line);
}
$this->addLine();
}
private function generalData(){
$version = new VersionString();
$this->data["general"] = [];
$this->data["general"]["version"] = $version->get(false);
$this->data["general"]["build"] = $version->getBuild();
$this->data["general"]["protocol"] = Info::CURRENT_PROTOCOL;
$this->data["general"]["api"] = \pocketmine\API_VERSION;
$this->data["general"]["git"] = \pocketmine\GIT_COMMIT;
$this->data["general"]["raklib"] = RakLib::VERSION;
$this->data["general"]["uname"] = php_uname("a");
$this->data["general"]["php"] = phpversion();
$this->data["general"]["zend"] = zend_version();
$this->data["general"]["php_os"] = PHP_OS;
$this->data["general"]["os"] = Utils::getOS();
$this->addLine("PocketMine-MP version: " . $version->get(false) . " #" . $version->getBuild() . " [Protocol " . Info::CURRENT_PROTOCOL . "; API " . API_VERSION . "]");
$this->addLine("Git commit: " . GIT_COMMIT);
$this->addLine("uname -a: " . php_uname("a"));
$this->addLine("PHP Version: " . phpversion());
$this->addLine("Zend version: " . zend_version());
$this->addLine("OS : " . PHP_OS . ", " . Utils::getOS());
}
public function addLine($line = ""){
fwrite($this->fp, $line . PHP_EOL);
}
public function add($str){
fwrite($this->fp, $str);
}
}

View File

@ -0,0 +1,78 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine;
use pocketmine\permission\ServerOperator;
interface IPlayer extends ServerOperator{
/**
* @return bool
*/
public function isOnline();
/**
* @return string
*/
public function getName();
/**
* @return bool
*/
public function isBanned();
/**
* @param bool $banned
*/
public function setBanned($banned);
/**
* @return bool
*/
public function isWhitelisted();
/**
* @param bool $value
*/
public function setWhitelisted($value);
/**
* @return Player|null
*/
public function getPlayer();
/**
* @return int|double
*/
public function getFirstPlayed();
/**
* @return int|double
*/
public function getLastPlayed();
/**
* @return mixed
*/
public function hasPlayedBefore();
}

View File

@ -0,0 +1,134 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine;
use pocketmine\metadata\MetadataValue;
use pocketmine\nbt\tag\Compound;
use pocketmine\plugin\Plugin;
class OfflinePlayer implements IPlayer{
private $name;
private $server;
private $namedtag;
/**
* @param Server $server
* @param string $name
*/
public function __construct(Server $server, $name){
$this->server = $server;
$this->name = $name;
if(file_exists($this->server->getDataPath() . "players/" . strtolower($this->getName()) . ".dat")){
$this->namedtag = $this->server->getOfflinePlayerData($this->name);
}else{
$this->namedtag = null;
}
}
public function isOnline(){
return $this->getPlayer() !== null;
}
public function getName(){
return $this->name;
}
public function getServer(){
return $this->server;
}
public function isOp(){
return $this->server->isOp(strtolower($this->getName()));
}
public function setOp($value){
if($value === $this->isOp()){
return;
}
if($value === true){
$this->server->addOp(strtolower($this->getName()));
}else{
$this->server->removeOp(strtolower($this->getName()));
}
}
public function isBanned(){
return $this->server->getNameBans()->isBanned(strtolower($this->getName()));
}
public function setBanned($value){
if($value === true){
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
}else{
$this->server->getNameBans()->remove($this->getName());
}
}
public function isWhitelisted(){
return $this->server->isWhitelisted(strtolower($this->getName()));
}
public function setWhitelisted($value){
if($value === true){
$this->server->addWhitelist(strtolower($this->getName()));
}else{
$this->server->removeWhitelist(strtolower($this->getName()));
}
}
public function getPlayer(){
return $this->server->getPlayerExact($this->getName());
}
public function getFirstPlayed(){
return $this->namedtag instanceof Compound ? $this->namedtag["firstPlayed"] : null;
}
public function getLastPlayed(){
return $this->namedtag instanceof Compound ? $this->namedtag["lastPlayed"] : null;
}
public function hasPlayedBefore(){
return $this->namedtag instanceof Compound;
}
public function setMetadata($metadataKey, MetadataValue $metadataValue){
$this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $metadataValue);
}
public function getMetadata($metadataKey){
return $this->server->getPlayerMetadata()->getMetadata($this, $metadataKey);
}
public function hasMetadata($metadataKey){
return $this->server->getPlayerMetadata()->hasMetadata($this, $metadataKey);
}
public function removeMetadata($metadataKey, Plugin $plugin){
$this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $plugin);
}
}

2578
src/pocketmine/Player.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,389 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace {
function safe_var_dump(){
static $cnt = 0;
foreach(func_get_args() as $var){
switch(true){
case is_array($var):
echo str_repeat(" ", $cnt) . "array(" . count($var) . ") {" . PHP_EOL;
foreach($var as $key => $value){
echo str_repeat(" ", $cnt + 1) . "[" . (is_integer($key) ? $key : '"' . $key . '"') . "]=>" . PHP_EOL;
++$cnt;
safe_var_dump($value);
--$cnt;
}
echo str_repeat(" ", $cnt) . "}" . PHP_EOL;
break;
case is_integer($var):
echo str_repeat(" ", $cnt) . "int(" . $var . ")" . PHP_EOL;
break;
case is_float($var):
echo str_repeat(" ", $cnt) . "float(" . $var . ")" . PHP_EOL;
break;
case is_bool($var):
echo str_repeat(" ", $cnt) . "bool(" . ($var === true ? "true" : "false") . ")" . PHP_EOL;
break;
case is_string($var):
echo str_repeat(" ", $cnt) . "string(" . strlen($var) . ") \"$var\"" . PHP_EOL;
break;
case is_resource($var):
echo str_repeat(" ", $cnt) . "resource() of type (" . get_resource_type($var) . ")" . PHP_EOL;
break;
case is_object($var):
echo str_repeat(" ", $cnt) . "object(" . get_class($var) . ")" . PHP_EOL;
break;
case is_null($var):
echo str_repeat(" ", $cnt) . "NULL" . PHP_EOL;
break;
}
}
}
function dummy(){
}
}
namespace pocketmine {
use LogLevel;
use pocketmine\utils\Binary;
use pocketmine\utils\MainLogger;
use pocketmine\utils\Utils;
use pocketmine\wizard\Installer;
use raklib\RakLib;
const VERSION = "Alpha_1.4dev";
const API_VERSION = "1.4.0";
const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
const MINECRAFT_VERSION = "v0.9.5 alpha";
/*
* Startup code. Do not look at it, it may harm you.
* Most of them are hacks to fix date-related bugs, or basic functions used after this
* This is the only non-class based file on this project.
* Enjoy it as much as I did writing it. I don't want to do it again.
*/
if(\Phar::running(true) !== ""){
@define("pocketmine\\PATH", \Phar::running(true) . "/");
}else{
@define("pocketmine\\PATH", \getcwd() . DIRECTORY_SEPARATOR);
}
if(!extension_loaded("pthreads")){
echo "[CRITICAL] Unable to find the pthreads extension." . PHP_EOL;
echo "[CRITICAL] Please use the installer provided on the homepage." . PHP_EOL;
exit(1);
}
if(!class_exists("ClassLoader", false)){
require_once(\pocketmine\PATH . "src/spl/ClassLoader.php");
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
}
$autoloader = new CompatibleClassLoader();
$autoloader->addPath(\pocketmine\PATH . "src");
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "raklib");
$autoloader->register(true);
set_time_limit(0); //Who set it to 30 seconds?!?!
if(ini_get("date.timezone") == ""){ //No Timezone set
date_default_timezone_set("GMT");
if(strpos(" " . strtoupper(php_uname("s")), " WIN") !== false){
$time = time();
$time -= $time % 60;
//TODO: Parse different time & date formats by region. ¬¬ world
//Example: USA
@exec("time.exe /T", $hour);
$i = array_map("intval", explode(":", trim($hour[0])));
@exec("date.exe /T", $date);
$j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0])));
$offset = @round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60;
}else{
@exec("date +%s", $t);
$offset = @round((intval(trim($t[0])) - time()) / 60) * 60;
}
$daylight = (int) date("I");
$d = timezone_name_from_abbr("", $offset, $daylight);
@ini_set("date.timezone", $d);
@date_default_timezone_set($d);
}else{
$d = @date_default_timezone_get();
if(strpos($d, "/") === false){
$d = timezone_name_from_abbr($d);
@ini_set("date.timezone", $d);
@date_default_timezone_set($d);
}
}
gc_enable();
error_reporting(-1);
ini_set("allow_url_fopen", 1);
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
ini_set("default_charset", "utf-8");
ini_set("memory_limit", "256M"); //Default
define("pocketmine\\START_TIME", microtime(true));
$opts = getopt("", ["enable-ansi", "disable-ansi", "data:", "plugins:", "no-wizard", "enable-profiler"]);
define("pocketmine\\DATA", isset($opts["data"]) ? realpath($opts["data"]) . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? realpath($opts["plugins"]) . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
define("pocketmine\\ANSI", ((strpos(strtoupper(php_uname("s")), "WIN") === false or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"])));
$logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
if(isset($opts["enable-profiler"])){
if(function_exists("profiler_enable")){
\profiler_enable();
$logger->notice("Execution is being profiled");
}else{
$logger->notice("No profiler found. Please install https://github.com/krakjoe/profiler");
}
}
function kill($pid){
switch(Utils::getOS()){
case "win":
exec("taskkill.exe /F /PID " . ((int) $pid) . " > NUL");
break;
case "mac":
case "linux":
default:
exec("kill -9 " . ((int) $pid) . " > /dev/null 2>&1");
}
}
function getTrace($start = 1, $trace = null){
if($trace === null){
if(function_exists("xdebug_get_function_stack")){
$trace = array_reverse(xdebug_get_function_stack());
}else{
$e = new \Exception();
$trace = $e->getTrace();
}
}
$messages = [];
$j = 0;
for($i = (int) $start; isset($trace[$i]); ++$i, ++$j){
$params = "";
if(isset($trace[$i]["args"]) or isset($trace[$i]["params"])){
if(isset($trace[$i]["args"])){
$args = $trace[$i]["args"];
}else{
$args = $trace[$i]["params"];
}
foreach($args as $name => $value){
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . @strval($value)) . ", ";
}
}
$messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . substr($params, 0, -2) . ")";
}
return $messages;
}
function cleanPath($path){
return rtrim(str_replace(["\\", ".php", "phar://", rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), "/"), rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH), "/")], ["/", "", "", "", ""], $path), "/");
}
function error_handler($errno, $errstr, $errfile, $errline, $trace = null){
global $lastError;
if(error_reporting() === 0){ //@ error-control
return false;
}
$errorConversion = [
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
E_PARSE => "E_PARSE",
E_NOTICE => "E_NOTICE",
E_CORE_ERROR => "E_CORE_ERROR",
E_CORE_WARNING => "E_CORE_WARNING",
E_COMPILE_ERROR => "E_COMPILE_ERROR",
E_COMPILE_WARNING => "E_COMPILE_WARNING",
E_USER_ERROR => "E_USER_ERROR",
E_USER_WARNING => "E_USER_WARNING",
E_USER_NOTICE => "E_USER_NOTICE",
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED",
];
$type = ($errno === E_ERROR or $errno === E_WARNING or $errno === E_USER_ERROR or $errno === E_USER_WARNING) ? LogLevel::ERROR : LogLevel::NOTICE;
$errno = isset($errorConversion[$errno]) ? $errorConversion[$errno] : $errno;
if(($pos = strpos($errstr, "\n")) !== false){
$errstr = substr($errstr, 0, $pos);
}
$logger = MainLogger::getLogger();
$oldFile = $errfile;
$errfile = cleanPath($errfile);
$logger->log($type, "An $errno error happened: \"$errstr\" in \"$errfile\" at line $errline");
foreach(($trace = getTrace($trace === null ? 3 : 0, $trace)) as $i => $line){
$logger->debug($line);
}
$lastError = [
"type" => $type,
"message" => $errstr,
"fullFile" => $oldFile,
"file" => $errfile,
"line" => $errline,
"trace" => $trace
];
return true;
}
set_error_handler("\\pocketmine\\error_handler", E_ALL);
$errors = 0;
if(version_compare("5.6.0", PHP_VERSION) > 0){
$logger->critical("You must use PHP >= 5.6");
++$errors;
}
if(php_sapi_name() !== "cli"){
$logger->critical("You must run PocketMine-MP using the CLI.");
++$errors;
}
if(!extension_loaded("sockets")){
$logger->critical("Unable to find the Socket extension.");
++$errors;
}
$pthreads_version = phpversion("pthreads");
if(substr_count($pthreads_version, ".") < 2){
$pthreads_version = "0.$pthreads_version";
}
if(version_compare($pthreads_version, "2.0.8") < 0){
$logger->critical("pthreads >= 2.0.8 is required, while you have $pthreads_version.");
++$errors;
}
if(!extension_loaded("uopz")){
//$logger->notice("Couldn't find the uopz extension. Some functions may be limited");
}
if(extension_loaded("pocketmine")){
if(version_compare(phpversion("pocketmine"), "0.0.1") < 0){
$logger->critical("You have the native PocketMine extension, but your version is lower than 0.0.1.");
++$errors;
}elseif(version_compare(phpversion("pocketmine"), "0.0.4") > 0){
$logger->critical("You have the native PocketMine extension, but your version is higher than 0.0.4.");
++$errors;
}
}
if(!extension_loaded("Weakref") and !extension_loaded("weakref")){
$logger->critical("Unable to find the Weakref extension.");
++$errors;
}
if(!extension_loaded("curl")){
$logger->critical("Unable to find the cURL extension.");
++$errors;
}
if(!extension_loaded("sqlite3")){
$logger->critical("Unable to find the SQLite3 extension.");
++$errors;
}
if(!extension_loaded("yaml")){
$logger->critical("Unable to find the YAML extension.");
++$errors;
}
if(!extension_loaded("zlib")){
$logger->critical("Unable to find the Zlib extension.");
++$errors;
}
if($errors > 0){
$logger->critical("Please use the installer provided on the homepage, or recompile PHP again.");
$logger->shutdown();
$logger->join();
exit(1); //Exit with error
}
if(file_exists(\pocketmine\PATH . ".git/refs/heads/master")){ //Found Git information!
define("pocketmine\\GIT_COMMIT", strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master"))));
}else{ //Unknown :(
define("pocketmine\\GIT_COMMIT", str_repeat("00", 20));
}
@define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN));
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
@ini_set("opcache.mmap_base", bin2hex(Utils::getRandomBytes(8, false))); //Fix OPCache address errors
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
new Installer();
}
if(substr(__FILE__, 0, 7) !== "phar://"){
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
}
ThreadManager::init();
$server = new Server($autoloader, $logger, \pocketmine\PATH, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
$logger->info("Stopping other threads");
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
if($thread->isRunning()){
$logger->debug("Stopping " . (new \ReflectionClass($thread))->getShortName() . " thread");
if($thread instanceof Thread){
$thread->kill();
if($thread->isRunning() or !$thread->join()){
$thread->detach();
}
}elseif($thread instanceof Worker){
$thread->kill();
sleep(1);
if($thread->isRunning() or !$thread->join()){
$thread->detach();
}
}
}elseif(!$thread->isJoined()){
$logger->debug("Joining " . (new \ReflectionClass($thread))->getShortName() . " thread");
$thread->join();
}
}
$logger->shutdown();
$logger->join();
exit(0);
}

2092
src/pocketmine/Server.php Normal file

File diff suppressed because it is too large Load Diff

34
src/pocketmine/Thread.php Normal file
View File

@ -0,0 +1,34 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine;
/**
* This class must be extended by all custom threading classes
*/
abstract class Thread extends \Thread{
public final function start($options = PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);
return parent::start($options);
}
}

View File

@ -0,0 +1,69 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine;
class ThreadManager extends \Threaded{
/** @var ThreadManager */
private static $instance = null;
public static function init(){
self::$instance = new ThreadManager();
}
/**
* @return ThreadManager
*/
public static function getInstance(){
return self::$instance;
}
/**
* @param Worker|Thread $thread
*/
public function add($thread){
if($thread instanceof Thread or $thread instanceof Worker){
$this->{spl_object_hash($thread)} = $thread;
}
}
/**
* @param Worker|Thread $thread
*/
public function remove($thread){
if($thread instanceof Thread or $thread instanceof Worker){
unset($this->{spl_object_hash($thread)});
}
}
/**
* @return Worker[]|Thread[]
*/
public function getAll(){
$array = [];
foreach($this as $key => $thread){
$array[$key] = $thread;
}
return $array;
}
}

34
src/pocketmine/Worker.php Normal file
View File

@ -0,0 +1,34 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine;
/**
* This class must be extended by all custom threading classes
*/
abstract class Worker extends \Worker{
public final function start($options = PTHREADS_INHERIT_ALL){
ThreadManager::getInstance()->add($this);
return parent::start($options);
}
}

View File

@ -0,0 +1,36 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
class AcaciaWoodStairs extends Stair{
public function __construct($meta = 0){
parent::__construct(self::ACACIA_WOOD_STAIRS, $meta, "Acacia Wood Stairs");
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
}

View File

@ -0,0 +1,51 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
/**
* Air block
*/
class Air extends Transparent{
public $isActivable = false;
public $breakable = false;
public $isFlowable = true;
public $isTransparent = true;
public $isReplaceable = true;
public $isPlaceable = false;
public $hasPhysics = false;
public $isSolid = false;
public $isFullBlock = true;
protected $id = self::AIR;
protected $meta = 0;
protected $name = "Air";
protected $hardness = 0;
public function __construct(){
}
public function getBoundingBox(){
return null;
}
}

View File

@ -0,0 +1,160 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\network\protocol\ChatPacket;
use pocketmine\Player;
class Bed extends Transparent{
public function __construct($type = 0){
parent::__construct(self::BED_BLOCK, $type, "Bed Block");
$this->isActivable = true;
$this->isFullBlock = false;
$this->hardness = 1;
}
public function getBoundingBox(){
return new AxisAlignedBB(
$this->x,
$this->y,
$this->z,
$this->x + 1,
$this->y + 0.5625,
$this->z + 1
);
}
public function onActivate(Item $item, Player $player = null){
$time = $this->getLevel()->getTime() % Level::TIME_FULL;
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
if($player instanceof Player and !$isNight){
$pk = new ChatPacket;
$pk->message = "You can only sleep at night";
$player->dataPacket($pk);
return true;
}
$blockNorth = $this->getSide(2); //Gets the blocks around them
$blockSouth = $this->getSide(3);
$blockEast = $this->getSide(5);
$blockWest = $this->getSide(4);
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
$b = $this;
}else{ //Bottom Part of Bed
if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
$b = $blockNorth;
}elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
$b = $blockSouth;
}elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){
$b = $blockEast;
}elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){
$b = $blockWest;
}else{
if($player instanceof Player){
$pk = new ChatPacket;
$pk->message = "This bed is incomplete";
$player->dataPacket($pk);
}
return true;
}
}
if($player instanceof Player and $player->sleepOn($b) === false){
$pk = new ChatPacket;
$pk->message = "This bed is occupied";
$player->dataPacket($pk);
}
return true;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->isTransparent === false){
$faces = [
0 => 3,
1 => 4,
2 => 2,
3 => 5,
];
$d = $player instanceof Player ? $player->getDirection() : 0;
$next = $this->getSide($faces[(($d + 3) % 4)]);
$downNext = $this->getSide(0);
if($next->isReplaceable === true and $downNext->isTransparent === false){
$meta = (($d + 3) % 4) & 0x03;
$this->getLevel()->setBlock($block, Block::get($this->id, $meta), true, true);
$this->getLevel()->setBlock($next, Block::get($this->id, $meta | 0x08), true, true);
return true;
}
}
return false;
}
public function onBreak(Item $item){
$blockNorth = $this->getSide(2); //Gets the blocks around them
$blockSouth = $this->getSide(3);
$blockEast = $this->getSide(5);
$blockWest = $this->getSide(4);
if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed
if($blockNorth->getID() === $this->id and $blockNorth->meta !== 0x08){ //Checks if the block ID and meta are right
$this->getLevel()->setBlock($blockNorth, new Air(), true, true);
}elseif($blockSouth->getID() === $this->id and $blockSouth->meta !== 0x08){
$this->getLevel()->setBlock($blockSouth, new Air(), true, true);
}elseif($blockEast->getID() === $this->id and $blockEast->meta !== 0x08){
$this->getLevel()->setBlock($blockEast, new Air(), true, true);
}elseif($blockWest->getID() === $this->id and $blockWest->meta !== 0x08){
$this->getLevel()->setBlock($blockWest, new Air(), true, true);
}
}else{ //Bottom Part of Bed
if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockNorth, new Air(), true, true);
}elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockSouth, new Air(), true, true);
}elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockEast, new Air(), true, true);
}elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){
$this->getLevel()->setBlock($blockWest, new Air(), true, true);
}
}
$this->getLevel()->setBlock($this, new Air(), true, true);
return true;
}
public function getDrops(Item $item){
return [
[Item::BED, 0, 1],
];
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,17 +19,19 @@
*
*/
class BedrockBlock extends SolidBlock{
namespace pocketmine\block;
use pocketmine\item\Item;
class Bedrock extends Solid{
public function __construct(){
parent::__construct(BEDROCK, 0, "Bedrock");
parent::__construct(self::BEDROCK, 0, "Bedrock");
$this->breakable = false;
$this->hardness = 18000000;
}
public function isBreakable(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return true;
}
public function isBreakable(Item $item){
return false;
}
}

View File

@ -0,0 +1,97 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
class Beetroot extends Flowable{
public function __construct($meta = 0){
parent::__construct(self::BEETROOT_BLOCK, $meta, "Beetroot Block");
$this->isActivable = true;
$this->hardness = 0;
}
public function getBoundingBox(){
return null;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::FARMLAND){
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$this->meta = 0x07;
$this->getLevel()->setBlock($this, $this, true, true);
$item->count--;
return true;
}
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //TODO: Replace with common break method
$this->getLevel()->dropItem($this, Item::get(Item::BEETROOT_SEEDS, 0, 1));
$this->getLevel()->setBlock($this, new Air(), false);
return Level::BLOCK_UPDATE_NORMAL;
}
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){
if($this->meta < 0x07){
++$this->meta;
$this->getLevel()->setBlock($this, $this, true);
return Level::BLOCK_UPDATE_RANDOM;
}
}else{
return Level::BLOCK_UPDATE_RANDOM;
}
}
return false;
}
public function getDrops(Item $item){
$drops = [];
if($this->meta >= 0x07){
$drops[] = [Item::BEETROOT, 0, 1];
$drops[] = [Item::BEETROOT_SEEDS, 0, mt_rand(0, 3)];
}else{
$drops[] = [Item::BEETROOT_SEEDS, 0, 1];
}
return $drops;
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,15 +19,18 @@
*
*/
class WoodDoorBlock extends DoorBlock{
namespace pocketmine\block;
use pocketmine\item\Item;
class BirchWoodStairs extends Stair{
public function __construct($meta = 0){
parent::__construct(WOOD_DOOR_BLOCK, $meta, "Wood Door Block");
$this->isActivable = true;
parent::__construct(self::BIRCH_WOOD_STAIRS, $meta, "Birch Wood Stairs");
}
public function getDrops(Item $item, Player $player){
return array(
array(WOODEN_DOOR, 0, 1),
);
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
}

View File

@ -0,0 +1,997 @@
<?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/
*
*
*/
/**
* All Block classes are in here
*/
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\entity\Villager;
use pocketmine\entity\Zombie;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\level\MovingObjectPosition;
use pocketmine\level\Position;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\metadata\Metadatable;
use pocketmine\metadata\MetadataValue;
use pocketmine\Player;
use pocketmine\plugin\Plugin;
abstract class Block extends Position implements Metadatable{
const AIR = 0;
const STONE = 1;
const GRASS = 2;
const DIRT = 3;
const COBBLESTONE = 4;
const COBBLE = 4;
const PLANK = 5;
const PLANKS = 5;
const WOODEN_PLANK = 5;
const WOODEN_PLANKS = 5;
const SAPLING = 6;
const SAPLINGS = 6;
const BEDROCK = 7;
const WATER = 8;
const STILL_WATER = 9;
const LAVA = 10;
const STILL_LAVA = 11;
const SAND = 12;
const GRAVEL = 13;
const GOLD_ORE = 14;
const IRON_ORE = 15;
const COAL_ORE = 16;
const WOOD = 17;
const TRUNK = 17;
const LOG = 17;
const LEAVES = 18;
const LEAVE = 18;
const SPONGE = 19;
const GLASS = 20;
const LAPIS_ORE = 21;
const LAPIS_BLOCK = 22;
const SANDSTONE = 24;
const BED_BLOCK = 26;
const COBWEB = 30;
const TALL_GRASS = 31;
const BUSH = 32;
const DEAD_BUSH = 32;
const WOOL = 35;
const DANDELION = 37;
const ROSE = 38;
const POPPY = 38;
const BROWN_MUSHROOM = 39;
const RED_MUSHROOM = 40;
const GOLD_BLOCK = 41;
const IRON_BLOCK = 42;
const DOUBLE_SLAB = 43;
const DOUBLE_SLABS = 43;
const SLAB = 44;
const SLABS = 44;
const BRICKS = 45;
const BRICKS_BLOCK = 45;
const TNT = 46;
const BOOKSHELF = 47;
const MOSS_STONE = 48;
const MOSSY_STONE = 48;
const OBSIDIAN = 49;
const TORCH = 50;
const FIRE = 51;
const MONSTER_SPAWNER = 52;
const WOOD_STAIRS = 53;
const WOODEN_STAIRS = 53;
const OAK_WOOD_STAIRS = 53;
const OAK_WOODEN_STAIRS = 53;
const CHEST = 54;
const DIAMOND_ORE = 56;
const DIAMOND_BLOCK = 57;
const CRAFTING_TABLE = 58;
const WORKBENCH = 58;
const WHEAT_BLOCK = 59;
const FARMLAND = 60;
const FURNACE = 61;
const BURNING_FURNACE = 62;
const LIT_FURNACE = 62;
const SIGN_POST = 63;
const DOOR_BLOCK = 64;
const WOODEN_DOOR_BLOCK = 64;
const WOOD_DOOR_BLOCK = 64;
const LADDER = 65;
const COBBLE_STAIRS = 67;
const COBBLESTONE_STAIRS = 67;
const WALL_SIGN = 68;
const IRON_DOOR_BLOCK = 71;
const REDSTONE_ORE = 73;
const GLOWING_REDSTONE_ORE = 74;
const LIT_REDSTONE_ORE = 74;
const SNOW = 78;
const SNOW_LAYER = 78;
const ICE = 79;
const SNOW_BLOCK = 80;
const CACTUS = 81;
const CLAY_BLOCK = 82;
const REEDS = 83;
const SUGARCANE_BLOCK = 83;
const FENCE = 85;
const PUMPKIN = 86;
const NETHERRACK = 87;
const SOUL_SAND = 88;
const GLOWSTONE = 89;
const GLOWSTONE_BLOCK = 89;
const LIT_PUMPKIN = 91;
const JACK_O_LANTERN = 91;
const CAKE_BLOCK = 92;
const TRAPDOOR = 96;
const STONE_BRICKS = 98;
const STONE_BRICK = 98;
const IRON_BAR = 101;
const IRON_BARS = 101;
const GLASS_PANE = 102;
const GLASS_PANEL = 102;
const MELON_BLOCK = 103;
const PUMPKIN_STEM = 104;
const MELON_STEM = 105;
const FENCE_GATE = 107;
const BRICK_STAIRS = 108;
const STONE_BRICK_STAIRS = 109;
const MYCELIUM = 110;
const NETHER_BRICKS = 112;
const NETHER_BRICK_BLOCK = 112;
const NETHER_BRICKS_STAIRS = 114;
const END_PORTAL = 120;
const END_STONE = 121;
const SANDSTONE_STAIRS = 128;
const EMERALD_ORE = 129;
const EMERALD_BLOCK = 133;
const SPRUCE_WOOD_STAIRS = 134;
const SPRUCE_WOODEN_STAIRS = 134;
const BIRCH_WOOD_STAIRS = 135;
const BIRCH_WOODEN_STAIRS = 135;
const JUNGLE_WOOD_STAIRS = 136;
const JUNGLE_WOODEN_STAIRS = 136;
const COBBLE_WALL = 139;
const STONE_WALL = 139;
const COBBLESTONE_WALL = 139;
const CARROT_BLOCK = 141;
const POTATO_BLOCK = 142;
const QUARTZ_BLOCK = 155;
const QUARTZ_STAIRS = 156;
const DOUBLE_WOOD_SLAB = 157;
const DOUBLE_WOODEN_SLAB = 157;
const DOUBLE_WOOD_SLABS = 157;
const DOUBLE_WOODEN_SLABS = 157;
const WOOD_SLAB = 158;
const WOODEN_SLAB = 158;
const WOOD_SLABS = 158;
const WOODEN_SLABS = 158;
const STAINED_CLAY = 159;
const STAINED_HARDENED_CLAY = 159;
const LEAVES2 = 161;
const LEAVE2 = 161;
const WOOD2 = 162;
const TRUNK2 = 162;
const LOG2 = 162;
const ACACIA_WOOD_STAIRS = 163;
const ACACIA_WOODEN_STAIRS = 163;
const DARK_OAK_WOOD_STAIRS = 164;
const DARK_OAK_WOODEN_STAIRS = 164;
const HAY_BALE = 170;
const CARPET = 171;
const HARDENED_CLAY = 172;
const COAL_BLOCK = 173;
const PODZOL = 243;
const BEETROOT_BLOCK = 244;
const STONECUTTER = 245;
const GLOWING_OBSIDIAN = 246;
const NETHER_REACTOR = 247;
public static $creative = [
//Building
[Item::COBBLESTONE, 0],
[Item::STONE_BRICKS, 0],
[Item::STONE_BRICKS, 1],
[Item::STONE_BRICKS, 2],
[Item::STONE_BRICKS, 3],
[Item::MOSS_STONE, 0],
[Item::WOODEN_PLANKS, 0],
[Item::WOODEN_PLANKS, 1],
[Item::WOODEN_PLANKS, 2],
[Item::WOODEN_PLANKS, 3],
[Item::WOODEN_PLANKS, 4],
[Item::WOODEN_PLANKS, 5],
[Item::BRICKS, 0],
[Item::STONE, 0],
[Item::STONE, 1],
[Item::STONE, 2],
[Item::STONE, 3],
[Item::STONE, 4],
[Item::STONE, 5],
[Item::STONE, 6],
[Item::DIRT, 0],
[Item::PODZOL, 0],
[Item::GRASS, 0],
[Item::MYCELIUM, 0],
[Item::CLAY_BLOCK, 0],
[Item::HARDENED_CLAY, 0],
[Item::STAINED_CLAY, 0],
[Item::STAINED_CLAY, 7],
[Item::STAINED_CLAY, 6],
[Item::STAINED_CLAY, 5],
[Item::STAINED_CLAY, 4],
[Item::STAINED_CLAY, 3],
[Item::STAINED_CLAY, 2],
[Item::STAINED_CLAY, 1],
[Item::STAINED_CLAY, 15],
[Item::STAINED_CLAY, 14],
[Item::STAINED_CLAY, 13],
[Item::STAINED_CLAY, 12],
[Item::STAINED_CLAY, 11],
[Item::STAINED_CLAY, 10],
[Item::STAINED_CLAY, 9],
[Item::STAINED_CLAY, 8],
[Item::SANDSTONE, 0],
[Item::SANDSTONE, 1],
[Item::SANDSTONE, 2],
[Item::SAND, 0],
[Item::SAND, 1],
[Item::GRAVEL, 0],
[Item::TRUNK, 0],
[Item::TRUNK, 1],
[Item::TRUNK, 2],
[Item::TRUNK, 3],
[Item::TRUNK2, 0],
[Item::TRUNK2, 1],
[Item::NETHER_BRICKS, 0],
[Item::NETHERRACK, 0],
[Item::BEDROCK, 0],
[Item::COBBLESTONE_STAIRS, 0],
[Item::OAK_WOODEN_STAIRS, 0],
[Item::SPRUCE_WOODEN_STAIRS, 0],
[Item::BIRCH_WOODEN_STAIRS, 0],
[Item::JUNGLE_WOODEN_STAIRS, 0],
[Item::ACACIA_WOODEN_STAIRS, 0],
[Item::DARK_OAK_WOODEN_STAIRS, 0],
[Item::BRICK_STAIRS, 0],
[Item::SANDSTONE_STAIRS, 0],
[Item::STONE_BRICK_STAIRS, 0],
[Item::NETHER_BRICKS_STAIRS, 0],
[Item::QUARTZ_STAIRS, 0],
[Item::SLAB, 0],
[Item::SLAB, 1],
[Item::WOODEN_SLAB, 0],
[Item::WOODEN_SLAB, 1],
[Item::WOODEN_SLAB, 2],
[Item::WOODEN_SLAB, 3],
[Item::WOODEN_SLAB, 4],
[Item::WOODEN_SLAB, 5],
[Item::SLAB, 3],
[Item::SLAB, 4],
[Item::SLAB, 5],
[Item::SLAB, 6],
[Item::QUARTZ_BLOCK, 0],
[Item::QUARTZ_BLOCK, 1],
[Item::QUARTZ_BLOCK, 2],
[Item::COAL_ORE, 0],
[Item::IRON_ORE, 0],
[Item::GOLD_ORE, 0],
[Item::DIAMOND_ORE, 0],
[Item::LAPIS_ORE, 0],
[Item::REDSTONE_ORE, 0],
[Item::EMERALD_ORE, 0],
[Item::OBSIDIAN, 0],
[Item::ICE, 0],
[Item::SNOW_BLOCK, 0],
[Item::END_STONE, 0],
//Decoration
[Item::COBBLESTONE_WALL, 0],
[Item::COBBLESTONE_WALL, 1],
//TODO: Lilly Pad
[Item::GOLD_BLOCK, 0],
[Item::IRON_BLOCK, 0],
[Item::DIAMOND_BLOCK, 0],
[Item::LAPIS_BLOCK, 0],
[Item::COAL_BLOCK, 0],
[Item::EMERALD_BLOCK, 0],
[Item::SNOW_LAYER, 0],
[Item::GLASS, 0],
[Item::GLOWSTONE_BLOCK, 0],
//TODO: Vines
[Item::NETHER_REACTOR, 0],
[Item::LADDER, 0],
[Item::SPONGE, 0],
[Item::GLASS_PANE, 0],
[Item::WOODEN_DOOR, 0],
[Item::TRAPDOOR, 0],
[Item::FENCE, 0],
[Item::FENCE_GATE, 0],
[Item::IRON_BARS, 0],
[Item::BED, 0],
[Item::BOOKSHELF, 0],
[Item::PAINTING, 0],
[Item::WORKBENCH, 0],
[Item::STONECUTTER, 0],
[Item::CHEST, 0],
[Item::FURNACE, 0],
//TODO: End Portal
[Item::END_PORTAL, 0],
[Item::DANDELION, 0],
[Item::POPPY, 0],
//TODO: blue orchid
//TODO: Allium
//TODO: Azure Bluet
//TODO: Red Tulip
//TODO: Orange Tulip
//TODO: White Tulip
//TODO: Pink Tulip
//TODO: Oxeye Daisy
//TODO: Lilac
//TODO: Double Tallgrass
//TODO: Large Fern
//TODO: Rose Bush
//TODO: Peony
[Item::BROWN_MUSHROOM, 0],
[Item::RED_MUSHROOM, 0],
//TODO: Mushroom block (brown, cover)
//TODO: Mushroom block (red, cover)
//TODO: Mushroom block (brown, stem)
//TODO: Mushroom block (red, stem)
[Item::CACTUS, 0],
[Item::MELON_BLOCK, 0],
[Item::PUMPKIN, 0],
[Item::LIT_PUMPKIN, 0],
[Item::COBWEB, 0],
[Item::HAY_BALE, 0],
[Item::TALL_GRASS, 1],
[Item::TALL_GRASS, 2],
[Item::DEAD_BUSH, 0],
[Item::SAPLING, 0],
[Item::SAPLING, 1],
[Item::SAPLING, 2],
[Item::SAPLING, 3],
[Item::SAPLING, 4],
[Item::SAPLING, 5],
[Item::LEAVES, 0],
[Item::LEAVES, 1],
[Item::LEAVES, 2],
[Item::LEAVES, 3],
[Item::LEAVES, 3],
[Item::LEAVES2, 0],
[Item::LEAVES2, 1],
[Item::CAKE, 0],
[Item::SIGN, 0],
[Item::MONSTER_SPAWNER, 0],
[Item::WOOL, 0],
[Item::WOOL, 7],
[Item::WOOL, 6],
[Item::WOOL, 5],
[Item::WOOL, 4],
[Item::WOOL, 3],
[Item::WOOL, 2],
[Item::WOOL, 1],
[Item::WOOL, 15],
[Item::WOOL, 14],
[Item::WOOL, 13],
[Item::WOOL, 12],
[Item::WOOL, 11],
[Item::WOOL, 10],
[Item::WOOL, 9],
[Item::WOOL, 8],
[Item::CARPET, 0],
[Item::CARPET, 7],
[Item::CARPET, 6],
[Item::CARPET, 5],
[Item::CARPET, 4],
[Item::CARPET, 3],
[Item::CARPET, 2],
[Item::CARPET, 1],
[Item::CARPET, 15],
[Item::CARPET, 14],
[Item::CARPET, 13],
[Item::CARPET, 12],
[Item::CARPET, 11],
[Item::CARPET, 10],
[Item::CARPET, 9],
[Item::CARPET, 8],
//Tools
//TODO [Item::RAILS, 0],
//TODO [Item::POWERED_RAILS, 0],
[Item::TORCH, 0],
[Item::BUCKET, 0],
[Item::BUCKET, 8],
[Item::BUCKET, 10],
[Item::TNT, 0],
[Item::IRON_HOE, 0],
[Item::IRON_SWORD, 0],
[Item::BOW, 0],
[Item::SHEARS, 0],
[Item::FLINT_AND_STEEL, 0],
[Item::CLOCK, 0],
[Item::COMPASS, 0],
[Item::MINECART, 0],
[Item::SPAWN_EGG, Villager::NETWORK_ID],
//[Item::SPAWN_EGG, 10], //Chicken
//[Item::SPAWN_EGG, 11], //Cow
//[Item::SPAWN_EGG, 12], //Pig
//[Item::SPAWN_EGG, 13], //Sheep
//TODO: Wolf
//TODO: Mooshroom
//TODO: Creeper
//TODO: Enderman
//TODO: Silverfish
//TODO: Skeleton
//TODO: Slime
[Item::SPAWN_EGG, Zombie::NETWORK_ID],
//TODO: PigZombie
//TODO: Replace with Entity constants
//Seeds
[Item::SUGARCANE, 0],
[Item::WHEAT, 0],
[Item::SEEDS, 0],
[Item::MELON_SEEDS, 0],
[Item::PUMPKIN_SEEDS, 0],
[Item::CARROT, 0],
[Item::POTATO, 0],
[Item::BEETROOT_SEEDS, 0],
[Item::EGG, 0],
[Item::DYE, 0],
[Item::DYE, 7],
[Item::DYE, 6],
[Item::DYE, 5],
[Item::DYE, 4],
[Item::DYE, 3],
[Item::DYE, 2],
[Item::DYE, 1],
[Item::DYE, 15],
[Item::DYE, 14],
[Item::DYE, 13],
[Item::DYE, 12],
[Item::DYE, 11],
[Item::DYE, 10],
[Item::DYE, 9],
[Item::DYE, 8],
];
/** @var Block[] */
public static $list = [];
protected $id;
protected $meta;
protected $name = "Unknown";
protected $breakTime = 0.20;
protected $hardness = 10;
public $isActivable = false;
public $breakable = true;
public $isFlowable = false;
public $isSolid = true;
public $isTransparent = false;
public $isReplaceable = false;
public $isPlaceable = true;
public $hasPhysics = false;
public $isLiquid = false;
public $isFullBlock = true;
public $x = 0;
public $y = 0;
public $z = 0;
public $frictionFactor = 0.6;
public static function init(){
if(count(self::$list) === 0){
self::$list = [
self::AIR => Air::class,
self::STONE => Stone::class,
self::GRASS => Grass::class,
self::DIRT => Dirt::class,
self::COBBLESTONE => Cobblestone::class,
self::PLANKS => Planks::class,
self::SAPLING => Sapling::class,
self::BEDROCK => Bedrock::class,
self::WATER => Water::class,
self::STILL_WATER => StillWater::class,
self::LAVA => Lava::class,
self::STILL_LAVA => StillLava::class,
self::SAND => Sand::class,
self::GRAVEL => Gravel::class,
self::GOLD_ORE => GoldOre::class,
self::IRON_ORE => IronOre::class,
self::COAL_ORE => CoalOre::class,
self::WOOD => Wood::class,
self::LEAVES => Leaves::class,
self::SPONGE => Sponge::class,
self::GLASS => Glass::class,
self::LAPIS_ORE => LapisOre::class,
self::LAPIS_BLOCK => Lapis::class,
self::SANDSTONE => Sandstone::class,
self::BED_BLOCK => Bed::class,
self::COBWEB => Cobweb::class,
self::TALL_GRASS => TallGrass::class,
self::DEAD_BUSH => DeadBush::class,
self::WOOL => Wool::class,
self::DANDELION => Dandelion::class,
self::POPPY => CyanFlower::class,
self::BROWN_MUSHROOM => BrownMushroom::class,
self::RED_MUSHROOM => RedMushroom::class,
self::GOLD_BLOCK => Gold::class,
self::IRON_BLOCK => Iron::class,
self::DOUBLE_SLAB => DoubleSlab::class,
self::SLAB => Slab::class,
self::BRICKS_BLOCK => Bricks::class,
self::TNT => TNT::class,
self::BOOKSHELF => Bookshelf::class,
self::MOSS_STONE => MossStone::class,
self::OBSIDIAN => Obsidian::class,
self::TORCH => Torch::class,
self::FIRE => Fire::class,
self::MONSTER_SPAWNER => MonsterSpawner::class,
self::WOOD_STAIRS => WoodStairs::class,
self::CHEST => Chest::class,
self::DIAMOND_ORE => DiamondOre::class,
self::DIAMOND_BLOCK => Diamond::class,
self::WORKBENCH => Workbench::class,
self::WHEAT_BLOCK => Wheat::class,
self::FARMLAND => Farmland::class,
self::FURNACE => Furnace::class,
self::BURNING_FURNACE => BurningFurnace::class,
self::SIGN_POST => SignPost::class,
self::WOOD_DOOR_BLOCK => WoodDoor::class,
self::LADDER => Ladder::class,
self::COBBLESTONE_STAIRS => CobblestoneStairs::class,
self::WALL_SIGN => WallSign::class,
self::IRON_DOOR_BLOCK => IronDoor::class,
self::REDSTONE_ORE => RedstoneOre::class,
self::GLOWING_REDSTONE_ORE => GlowingRedstoneOre::class,
self::SNOW_LAYER => SnowLayer::class,
self::ICE => Ice::class,
self::SNOW_BLOCK => Snow::class,
self::CACTUS => Cactus::class,
self::CLAY_BLOCK => Clay::class,
self::SUGARCANE_BLOCK => Sugarcane::class,
self::FENCE => Fence::class,
self::PUMPKIN => Pumpkin::class,
self::NETHERRACK => Netherrack::class,
self::SOUL_SAND => SoulSand::class,
self::GLOWSTONE_BLOCK => Glowstone::class,
self::LIT_PUMPKIN => LitPumpkin::class,
self::CAKE_BLOCK => Cake::class,
self::TRAPDOOR => Trapdoor::class,
self::STONE_BRICKS => StoneBricks::class,
self::IRON_BARS => IronBars::class,
self::GLASS_PANE => GlassPane::class,
self::MELON_BLOCK => Melon::class,
self::PUMPKIN_STEM => PumpkinStem::class,
self::MELON_STEM => MelonStem::class,
self::FENCE_GATE => FenceGate::class,
self::BRICK_STAIRS => BrickStairs::class,
self::STONE_BRICK_STAIRS => StoneBrickStairs::class,
self::MYCELIUM => Mycelium::class,
self::NETHER_BRICKS => NetherBrick::class,
self::NETHER_BRICKS_STAIRS => NetherBrickStairs::class,
self::END_PORTAL => EndPortal::class,
self::END_STONE => EndStone::class,
self::SANDSTONE_STAIRS => SandstoneStairs::class,
self::EMERALD_ORE => EmeraldOre::class,
self::EMERALD_BLOCK => Emerald::class,
self::SPRUCE_WOOD_STAIRS => SpruceWoodStairs::class,
self::BIRCH_WOOD_STAIRS => BirchWoodStairs::class,
self::JUNGLE_WOOD_STAIRS => JungleWoodStairs::class,
self::STONE_WALL => StoneWall::class,
self::CARROT_BLOCK => Carrot::class,
self::POTATO_BLOCK => Potato::class,
self::QUARTZ_BLOCK => Quartz::class,
self::QUARTZ_STAIRS => QuartzStairs::class,
self::DOUBLE_WOOD_SLAB => DoubleWoodSlab::class,
self::WOOD_SLAB => WoodSlab::class,
self::STAINED_CLAY => StainedClay::class,
self::LEAVES2 => Leaves2::class,
self::WOOD2 => Wood2::class,
self::ACACIA_WOOD_STAIRS => AcaciaWoodStairs::class,
self::DARK_OAK_WOOD_STAIRS => DarkOakWoodStairs::class,
self::HAY_BALE => HayBale::class,
self::CARPET => Carpet::class,
self::HARDENED_CLAY => HardenedClay::class,
self::COAL_BLOCK => Coal::class,
self::PODZOL => Podzol::class,
self::BEETROOT_BLOCK => Beetroot::class,
self::STONECUTTER => Stonecutter::class,
self::GLOWING_OBSIDIAN => GlowingObsidian::class,
self::NETHER_REACTOR => NetherReactor::class,
];
}
}
/**
* @param int $id
* @param int $meta
* @param Position $pos
*
* @return Block
*/
public static function get($id, $meta = 0, Position $pos = null){
if(isset(self::$list[$id])){
$block = self::$list[$id];
$block = new $block($meta);
}else{
$block = new Generic($id, $meta);
}
if($pos instanceof Position){
$block->position($pos);
}
return $block;
}
/**
* @param int $id
* @param int $meta
* @param string $name
*/
public function __construct($id, $meta = 0, $name = "Unknown"){
$this->id = (int) $id;
$this->meta = (int) $meta;
$this->name = $name;
}
/**
* @return int
*/
final public function getHardness(){
return $this->hardness;
}
/**
* @return string
*/
final public function getName(){
return $this->name;
}
/**
* @return int
*/
final public function getID(){
return $this->id;
}
/**
* @return int
*/
final public function getDamage(){
return $this->meta;
}
/**
* @param int $meta
*/
final public function setDamage($meta){
$this->meta = $meta & 0x0F;
}
/**
* Sets the block position to a new Position object
*
* @param Position $v
*/
final public function position(Position $v){
$this->x = (int) $v->x;
$this->y = (int) $v->y;
$this->z = (int) $v->z;
$this->level = $v->level;
}
/**
* Returns an array of Item objects to be dropped
*
* @param Item $item
*
* @return array
*/
public function getDrops(Item $item){
if(!isset(self::$list[$this->id])){ //Unknown blocks
return [];
}else{
return [
[$this->id, $this->meta, 1],
];
}
}
/**
* Returns the seconds that this block takes to be broken using an specific Item
*
* @param Item $item
*
* @return float
*/
public function getBreakTime(Item $item){
return $this->breakTime;
}
/**
* Returns the Block on the side $side, works like Vector3::side()
*
* @param int $side
* @param int $step
*
* @return Block
*/
public function getSide($side, $step = 1){
$v = parent::getSide($side, $step);
if($this->isValid()){
return $this->getLevel()->getBlock($v);
}
return Block::get(Item::AIR, 0, $v);
}
/**
* @return string
*/
final public function __toString(){
return "Block " . $this->name . " (" . $this->id . ":" . $this->meta . ")";
}
/**
* Returns if the item can be broken with an specific Item
*
* @param Item $item
*
* @return bool
*/
abstract function isBreakable(Item $item);
/**
* Do the actions needed so the block is broken with the Item
*
* @param Item $item
*
* @return mixed
*/
abstract function onBreak(Item $item);
/**
* Checks for collision against an AxisAlignedBB
*
* @param AxisAlignedBB $bb
* @param Block[] $list
*/
public function collidesWithBB(AxisAlignedBB $bb, &$list = []){
$bb2 = $this->getBoundingBox();
if($bb2 !== null and $bb2->intersectsWith($bb)){
$list[] = $bb2;
}
}
/**
* @param Entity $entity
*/
public function onEntityCollide(Entity $entity){
}
/**
* @return AxisAlignedBB
*/
public function getBoundingBox(){
return new AxisAlignedBB(
$this->x,
$this->y,
$this->z,
$this->x + 1,
$this->y + 1,
$this->z + 1
);
}
public function calculateIntercept(Vector3 $pos1, Vector3 $pos2){
$bb = $this->getBoundingBox();
if($bb === null){
return null;
}
$v1 = $pos1->getIntermediateWithXValue($pos2, $bb->minX);
$v2 = $pos1->getIntermediateWithXValue($pos2, $bb->maxX);
$v3 = $pos1->getIntermediateWithYValue($pos2, $bb->minY);
$v4 = $pos1->getIntermediateWithYValue($pos2, $bb->maxY);
$v5 = $pos1->getIntermediateWithZValue($pos2, $bb->minZ);
$v6 = $pos1->getIntermediateWithZValue($pos2, $bb->maxZ);
if($v1 !== null and !$bb->isVectorInYZ($v1)){
$v1 = null;
}
if($v2 !== null and !$bb->isVectorInYZ($v2)){
$v2 = null;
}
if($v3 !== null and !$bb->isVectorInXZ($v3)){
$v3 = null;
}
if($v4 !== null and !$bb->isVectorInXZ($v4)){
$v4 = null;
}
if($v5 !== null and !$bb->isVectorInXY($v5)){
$v5 = null;
}
if($v6 !== null and !$bb->isVectorInXY($v6)){
$v6 = null;
}
$vector = $v1;
if($v2 !== null and ($vector === null or $pos1->distanceSquared($v2) < $pos1->distanceSquared($vector))){
$vector = $v2;
}
if($v3 !== null and ($vector === null or $pos1->distanceSquared($v3) < $pos1->distanceSquared($vector))){
$vector = $v3;
}
if($v4 !== null and ($vector === null or $pos1->distanceSquared($v4) < $pos1->distanceSquared($vector))){
$vector = $v4;
}
if($v5 !== null and ($vector === null or $pos1->distanceSquared($v5) < $pos1->distanceSquared($vector))){
$vector = $v5;
}
if($v6 !== null and ($vector === null or $pos1->distanceSquared($v6) < $pos1->distanceSquared($vector))){
$vector = $v6;
}
if($vector === null){
return null;
}
$f = -1;
if($vector === $v1){
$f = 4;
}elseif($vector === $v2){
$f = 5;
}elseif($vector === $v3){
$f = 0;
}elseif($vector === $v4){
$f = 1;
}elseif($vector === $v5){
$f = 2;
}elseif($vector === $v6){
$f = 3;
}
return MovingObjectPosition::fromBlock($this->x, $this->y, $this->z, $f, $vector->add($this->x, $this->y, $this->z));
}
/**
* Places the Block, using block space and block target, and side. Returns if the block has been placed.
*
* @param Item $item
* @param Block $block
* @param Block $target
* @param int $face
* @param float $fx
* @param float $fy
* @param float $fz
* @param Player $player = null
*
* @return bool
*/
abstract function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null);
/**
* Do actions when activated by Item. Returns if it has done anything
*
* @param Item $item
* @param Player $player
*
* @return bool
*/
abstract function onActivate(Item $item, Player $player = null);
/**
* Fires a block update on the Block
*
* @param int $type
*
* @return void
*/
abstract function onUpdate($type);
public function setMetadata($metadataKey, MetadataValue $metadataValue){
if($this->getLevel() instanceof Level){
$this->getLevel()->getBlockMetadata()->setMetadata($this, $metadataKey, $metadataValue);
}
}
public function getMetadata($metadataKey){
if($this->getLevel() instanceof Level){
$this->getLevel()->getBlockMetadata()->getMetadata($this, $metadataKey);
}
}
public function hasMetadata($metadataKey){
if($this->getLevel() instanceof Level){
$this->getLevel()->getBlockMetadata()->hasMetadata($this, $metadataKey);
}
}
public function removeMetadata($metadataKey, Plugin $plugin){
if($this->getLevel() instanceof Level){
$this->getLevel()->getBlockMetadata()->removeMetadata($this, $metadataKey, $plugin);
}
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,9 +19,13 @@
*
*/
class BookshelfBlock extends SolidBlock{
namespace pocketmine\block;
class Bookshelf extends Solid{
public function __construct(){
parent::__construct(BOOKSHELF, 0, "Bookshelf");
parent::__construct(self::BOOKSHELF, 0, "Bookshelf");
$this->hardness = 7.5;
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,9 +19,12 @@
*
*/
class BrickStairsBlock extends StairBlock{
namespace pocketmine\block;
class BrickStairs extends Stair{
public function __construct($meta = 0){
parent::__construct(BRICK_STAIRS, $meta, "Brick Stairs");
parent::__construct(self::BRICK_STAIRS, $meta, "Brick Stairs");
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,15 +19,17 @@
*
*/
class BricksBlock extends SolidBlock{
namespace pocketmine\block;
use pocketmine\item\Item;
class Bricks extends Solid{
public function __construct(){
parent::__construct(BRICKS_BLOCK, 0, "Bricks");
parent::__construct(self::BRICKS_BLOCK, 0, "Bricks");
$this->hardness = 30;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.4;
@ -43,14 +45,14 @@ class BricksBlock extends SolidBlock{
return 10;
}
}
public function getDrops(Item $item, Player $player){
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return array(
array(BRICKS_BLOCK, 0, 1),
);
return [
[Item::BRICKS_BLOCK, 0, 1],
];
}else{
return array();
return [];
}
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,28 +19,44 @@
*
*/
class RedMushroomBlock extends FlowableBlock{
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
class BrownMushroom extends Flowable{
public function __construct(){
parent::__construct(RED_MUSHROOM, 0, "Red Mushroom");
parent::__construct(self::BROWN_MUSHROOM, 0, "Brown Mushroom");
$this->hardness = 0;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace wit common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
$this->getLevel()->dropItem($this, Item::get($this->id));
$this->getLevel()->setBlock($this, new Air(), false, false, true);
return Level::BLOCK_UPDATE_NORMAL;
}
}
return false;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->isTransparent === false){
$this->level->setBlock($block, $this);
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
}
public function getBoundingBox(){
return null;
}
}

View File

@ -0,0 +1,131 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\Enum;
use pocketmine\nbt\tag\Int;
use pocketmine\nbt\tag\String;
use pocketmine\Player;
use pocketmine\tile\Furnace;
use pocketmine\tile\Tile;
class BurningFurnace extends Solid{
public function __construct($meta = 0){
parent::__construct(self::BURNING_FURNACE, $meta, "Burning Furnace");
$this->isActivable = true;
$this->hardness = 17.5;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = [
0 => 4,
1 => 2,
2 => 5,
3 => 3,
];
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new Compound(false, [
new Enum("Items", []),
new String("id", Tile::FURNACE),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
new Furnace($this->getLevel()->getChunkAt($this->x >> 4, $this->z >> 4), $nbt);
return true;
}
public function onBreak(Item $item){
$this->getLevel()->setBlock($this, new Air(), true, true, true);
return true;
}
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
$t = $this->getLevel()->getTile($this);
$furnace = false;
if($t instanceof Furnace){
$furnace = $t;
}else{
$nbt = new Compound(false, [
new Enum("Items", []),
new String("id", Tile::FURNACE),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$furnace = new Furnace($this->getLevel()->getChunkAt($this->x >> 4, $this->z >> 4), $nbt);
}
if(($player->getGamemode() & 0x01) === 0x01){
return true;
}
$player->addWindow($furnace->getInventory());
}
return true;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.7;
case 4:
return 0.9;
case 3:
return 1.35;
case 2:
return 0.45;
case 1:
return 2.65;
default:
return 17.5;
}
}
public function getDrops(Item $item){
$drops = [];
if($item->isPickaxe() >= 1){
$drops[] = [Item::FURNACE, 0, 1];
}
$t = $this->getLevel()->getTile($this);
if($t instanceof Furnace){
for($s = 0; $s < $t->getInventory()->getSize(); ++$s){
$slot = $t->getInventory()->getItem($s);
if($slot->getID() > Item::AIR and $slot->getCount() > 0){
$drops[] = [$slot->getID(), $slot->getDamage(), $slot->getCount()];
}
}
}
return $drops;
}
}

View File

@ -0,0 +1,124 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3 as Vector3;
use pocketmine\Player;
use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\Server;
class Cactus extends Transparent{
public function __construct($meta = 0){
parent::__construct(self::CACTUS, $meta, "Cactus");
$this->isFullBlock = false;
$this->hardness = 2;
}
public function getBoundingBox(){
return new AxisAlignedBB(
$this->x + 0.0625,
$this->y,
$this->z + 0.0625,
$this->x + 0.9375,
$this->y + 1,
$this->z + 0.9375
);
}
public function onEntityCollide(Entity $entity){
$ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_CONTACT, 1);
Server::getInstance()->getPluginManager()->callEvent($ev);
if(!$ev->isCancelled()){
$entity->attack($ev->getFinalDamage(), $ev);
}
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0);
if($down->getID() !== self::SAND and $down->getID() !== self::CACTUS){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), false);
$this->getLevel()->dropItem($this, Item::get($this->id));
return;
}else{
for($side = 2; $side <= 5; ++$side){
$b = $this->getSide($side);
if(!$b->isFlowable){
$this->getLevel()->setBlock($this, new Air(), false);
$this->getLevel()->dropItem($this, Item::get($this->id));
return;
}
}
}
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== self::CACTUS){
if($this->meta == 0x0F){
for($y = 1; $y < 3; ++$y){
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getID() === self::AIR){
$this->getLevel()->setBlock($b, new Cactus(), true);
break;
}
}
$this->meta = 0;
$this->getLevel()->setBlock($this, $this);
}else{
++$this->meta;
$this->getLevel()->setBlock($this, $this);
}
return;
}
}
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::SAND or $down->getID() === self::CACTUS){
$block0 = $this->getSide(2);
$block1 = $this->getSide(3);
$block2 = $this->getSide(4);
$block3 = $this->getSide(5);
if($block0->isTransparent === true and $block1->isTransparent === true and $block2->isTransparent === true and $block3->isTransparent === true){
$this->getLevel()->setBlock($this, $this, true);
return true;
}
}
return false;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
}

View File

@ -0,0 +1,94 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\Player;
class Cake extends Transparent{
public function __construct($meta = 0){
parent::__construct(self::CAKE_BLOCK, 0, "Cake Block");
$this->isFullBlock = false;
$this->isActivable = true;
$this->meta = $meta & 0x07;
$this->hardness = 2.5;
}
public function getBoundingBox(){
$f = (1 + $this->getDamage() * 2) / 16;
return new AxisAlignedBB(
$this->x + $f,
$this->y,
$this->z + 0.0625,
$this->x + 1 - 0.0625,
$this->y + 0.5,
$this->z + 1 - 0.0625
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() !== self::AIR){
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), true);
return Level::BLOCK_UPDATE_NORMAL;
}
}
return false;
}
public function getDrops(Item $item){
return [];
}
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player and $player->getHealth() < 20){
++$this->meta;
$player->heal(3, "cake");
if($this->meta >= 0x06){
$this->getLevel()->setBlock($this, new Air(), true);
}else{
$this->getLevel()->setBlock($this, $this, true);
}
return true;
}
return false;
}
}

View File

@ -0,0 +1,91 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\Player;
class Carpet extends Flowable{
public function __construct($meta = 0){
parent::__construct(self::CARPET, $meta, "Carpet");
$names = [
0 => "White Carpet",
1 => "Orange Carpet",
2 => "Magenta Carpet",
3 => "Light Blue Carpet",
4 => "Yellow Carpet",
5 => "Lime Carpet",
6 => "Pink Carpet",
7 => "Gray Carpet",
8 => "Light Gray Carpet",
9 => "Cyan Carpet",
10 => "Purple Carpet",
11 => "Blue Carpet",
12 => "Brown Carpet",
13 => "Green Carpet",
14 => "Red Carpet",
15 => "Black Carpet",
];
$this->name = $names[$this->meta];
$this->hardness = 0;
$this->isFullBlock = false;
$this->isSolid = true;
}
public function getBoundingBox(){
return new AxisAlignedBB(
$this->x,
$this->y,
$this->z,
$this->x + 1,
$this->y + 0.0625,
$this->z + 1
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() !== self::AIR){
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === self::AIR){ //TODO: Replace with common break method
$this->getLevel()->dropItem($this, Item::get($this->id, $this->meta, 1));
$this->getLevel()->setBlock($this, new Air(), true);
return Level::BLOCK_UPDATE_NORMAL;
}
}
return false;
}
}

View File

@ -0,0 +1,98 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
class Carrot extends Flowable{
public function __construct($meta = 0){
parent::__construct(self::CARROT_BLOCK, $meta, "Carrot Block");
$this->isActivable = true;
$this->hardness = 0;
}
public function getBoundingBox(){
return null;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::FARMLAND){
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$this->meta = 0x07;
$this->getLevel()->setBlock($this, $this, true);
$item->count--;
return true;
}
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
//TODO
//Server::getInstance()->api->entity->drop($this, Item::get(CARROT, 0, 1));
$this->getLevel()->setBlock($this, new Air(), false, false, true);
return Level::BLOCK_UPDATE_NORMAL;
}
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){
if($this->meta < 0x07){
++$this->meta;
$this->getLevel()->setBlock($this, $this, true);
return Level::BLOCK_UPDATE_RANDOM;
}
}else{
return Level::BLOCK_UPDATE_RANDOM;
}
}
return false;
}
public function getDrops(Item $item){
$drops = [];
if($this->meta >= 0x07){
$drops[] = [Item::CARROT, 0, mt_rand(1, 4)];
}else{
$drops[] = [Item::CARROT, 0, 1];
}
return $drops;
}
}

View File

@ -0,0 +1,161 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\Enum;
use pocketmine\nbt\tag\Int;
use pocketmine\nbt\tag\String;
use pocketmine\Player;
use pocketmine\tile\Chest as TileChest;
use pocketmine\tile\Tile;
class Chest extends Transparent{
const SLOTS = 27;
public function __construct($meta = 0){
parent::__construct(self::CHEST, $meta, "Chest");
$this->isActivable = true;
$this->hardness = 15;
}
public function getBoundingBox(){
return new AxisAlignedBB(
$this->x + 0.0625,
$this->y,
$this->z + 0.0625,
$this->x + 0.9375,
$this->y + 0.875,
$this->z + 0.9375
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = [
0 => 4,
1 => 2,
2 => 5,
3 => 3,
];
$chest = false;
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
for($side = 2; $side <= 5; ++$side){
if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){
continue;
}elseif(($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)){
continue;
}
$c = $this->getSide($side);
if($c instanceof Chest and $c->getDamage() === $this->meta){
$tile = $this->getLevel()->getTile($c);
if($tile instanceof TileChest and !$tile->isPaired()){
$chest = $tile;
break;
}
}
}
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new Compound(false, [
new Enum("Items", []),
new String("id", Tile::CHEST),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$tile = new TileChest($this->getLevel()->getChunkAt($this->x >> 4, $this->z >> 4), $nbt);
if($chest instanceof TileChest){
$chest->pairWith($tile);
$tile->pairWith($chest);
}
return true;
}
public function onBreak(Item $item){
$t = $this->getLevel()->getTile($this);
if($t instanceof TileChest){
$t->unpair();
}
$this->getLevel()->setBlock($this, new Air(), true, true, true);
return true;
}
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
$top = $this->getSide(1);
if($top->isTransparent !== true){
return true;
}
$t = $this->getLevel()->getTile($this);
$chest = null;
if($t instanceof TileChest){
$chest = $t;
}else{
$nbt = new Compound(false, [
new Enum("Items", []),
new String("id", Tile::CHEST),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$chest = new TileChest($this->getLevel()->getChunkAt($this->x >> 4, $this->z >> 4), $nbt);
}
if(($player->gamemode & 0x01) === 0x01){
return true;
}
$player->addWindow($chest->getInventory());
}
return true;
}
public function getDrops(Item $item){
$drops = [
[$this->id, 0, 1],
];
$t = $this->getLevel()->getTile($this);
if($t instanceof TileChest){
for($s = 0; $s < $t->getRealInventory()->getSize(); ++$s){
$slot = $t->getRealInventory()->getItem($s);
if($slot->getID() > Item::AIR and $slot->getCount() > 0){
$drops[] = [$slot->getID(), $slot->getDamage(), $slot->getCount()];
}
}
}
return $drops;
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,14 +19,19 @@
*
*/
class ClayBlock extends SolidBlock{
namespace pocketmine\block;
use pocketmine\item\Item;
class Clay extends Solid{
public function __construct(){
parent::__construct(CLAY_BLOCK, 0, "Clay Block");
parent::__construct(self::CLAY_BLOCK, 0, "Clay Block");
$this->hardness = 3;
}
public function getDrops(Item $item, Player $player){
return array(
array(CLAY, 0, 4),
);
public function getDrops(Item $item){
return [
[Item::CLAY, 0, 4],
];
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,39 +19,40 @@
*
*/
class StoneBlock extends SolidBlock{
namespace pocketmine\block;
use pocketmine\item\Item;
class Coal extends Solid{
public function __construct(){
parent::__construct(STONE, 0, "Stone");
parent::__construct(self::COAL_BLOCK, 0, "Coal Block");
$this->hardness = 30;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.4;
return 0.95;
case 4:
return 0.5;
return 1.25;
case 3:
return 0.75;
return 1.9;
case 2:
return 0.25;
return 0.65;
case 1:
return 1.5;
return 3.75;
default:
return 7.5;
return 25;
}
}
public function getDrops(Item $item, Player $player){
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return array(
array(COBBLESTONE, 0, 1),
);
return [
[Item::COAL_BLOCK, 0, 1],
];
}else{
return array();
return [];
}
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,15 +19,17 @@
*
*/
class CoalOreBlock extends SolidBlock{
namespace pocketmine\block;
use pocketmine\item\Item;
class CoalOre extends Solid{
public function __construct(){
parent::__construct(COAL_ORE, 0, "Coal Ore");
parent::__construct(self::COAL_ORE, 0, "Coal Ore");
$this->hardness = 15;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.6;
@ -43,15 +45,15 @@ class CoalOreBlock extends SolidBlock{
return 15;
}
}
public function getDrops(Item $item, Player $player){
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return array(
array(COAL, 0, 1),
);
return [
[Item::COAL, 0, 1],
];
}else{
return array();
return [];
}
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,15 +19,17 @@
*
*/
class MossStoneBlock extends SolidBlock{
namespace pocketmine\block;
use pocketmine\item\Item;
class Cobblestone extends Solid{
public function __construct(){
parent::__construct(MOSS_STONE, 0, "Moss Stone");
parent::__construct(self::COBBLESTONE, 0, "Cobblestone");
$this->hardness = 30;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.4;
@ -43,14 +45,14 @@ class MossStoneBlock extends SolidBlock{
return 10;
}
}
public function getDrops(Item $item, Player $player){
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return array(
array(MOSS_STONE, 0, 1),
);
return [
[Item::COBBLESTONE, 0, 1],
];
}else{
return array();
return [];
}
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,9 +19,12 @@
*
*/
class CobblestoneStairsBlock extends StairBlock{
namespace pocketmine\block;
class CobblestoneStairs extends Stair{
public function __construct($meta = 0){
parent::__construct(COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs");
parent::__construct(self::COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs");
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,13 +19,24 @@
*
*/
class CobwebBlock extends FlowableBlock{
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\entity\Entity;
class Cobweb extends Flowable{
public function __construct(){
parent::__construct(COBWEB, 0, "Cobweb");
parent::__construct(self::COBWEB, 0, "Cobweb");
$this->isSolid = true;
$this->isFullBlock = false;
$this->hardness = 25;
}
public function onEntityCollide(Entity $entity){
$entity->fallDistance = 0;
}
public function getDrops(Item $item){
return [];
}
public function getDrops(Item $item, Player $player){
return array();
}
}

View File

@ -0,0 +1,62 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
class CyanFlower extends Flowable{
public function __construct(){
parent::__construct(self::POPPY, 0, "Cyan Flower");
$this->hardness = 0;
}
public function getBoundingBox(){
return null;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //TODO: Replace with common break method
$this->getLevel()->dropItem($this, Item::get($this->id, 0, 1));
$this->getLevel()->setBlock($this, new Air(), false, false, true);
return Level::BLOCK_UPDATE_NORMAL;
}
}
return false;
}
}

View File

@ -0,0 +1,63 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
class Dandelion extends Flowable{
public function __construct(){
parent::__construct(self::DANDELION, 0, "Dandelion");
$this->hardness = 0;
}
public function getBoundingBox(){
return null;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
//TODO
//Server::getInstance()->api->entity->drop($this, Item::get($this->id));
$this->getLevel()->setBlock($this, new Air(), false, false, true);
return Level::BLOCK_UPDATE_NORMAL;
}
}
return false;
}
}

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