1155 Commits

Author SHA1 Message Date
Dylan K. Taylor
57a86d9ed7 Player: remove useless InteractPacket handler
all the things we cared about in here don't exist anymore, so there's no sense in the handler still existing. It can be restored when we want to use the things it still does.
2018-07-20 12:39:48 +01:00
Dylan K. Taylor
25cfcada26 Player: clean up container close handling 2018-07-20 12:36:44 +01:00
Dylan K. Taylor
bdd9a7eb52 Kill BatchPacket, clean up batching related things
DataPacketSendEvent and DataPacketReceiveEvent will no longer capture BatchPackets
In most places strings are now used instead of DataPackets, to remove limitations on what data can be sent to a network interface
Removed CraftingManager's cyclic dependency on Server

There is a lot more work to do aside from this, but this commit is intended to clean up what is necessary to fix the handling of BatchPacket.
2018-07-20 12:36:44 +01:00
Dylan K. Taylor
85647c03bf Move IP/port to NetworkSession 2018-07-20 12:36:43 +01:00
Dylan K. Taylor
f969f3b77f Flatten NetworkSession hierarchy in preparation for refactor 2018-07-20 12:36:43 +01:00
Dylan K. Taylor
1144620f2b Level: minor de-spaghettification of chunk requesting
Now the Level tells the player to request chunks on tick, instead of the server doing it.
2018-07-18 16:49:58 +01:00
Dylan K. Taylor
e57dd3e8ba Merge branch 'release/3.2' 2018-07-18 15:14:41 +01:00
Dylan K. Taylor
efe4b0cd3a Merge branch 'release/3.1' into release/3.2 2018-07-18 15:14:34 +01:00
Dylan K. Taylor
4274640845 Player: fixed on-ground state not being updated when walking horizontally
it's possible to walk off a tower while flying without moving vertically, and this code previously wouldn't detect that, leaving a gaping hole in the anti-cheat.
2018-07-18 15:14:18 +01:00
Dylan K. Taylor
36e197e2a9 Move more session logic out of Player 2018-07-18 12:48:58 +01:00
Dylan K. Taylor
4d1e2d1b3a Rename SourceInterface -> NetworkInterface
SourceInterface doesn't make sense really...
2018-07-18 11:03:21 +01:00
Dylan K. Taylor
1b7cd156aa Merge branch 'release/3.0' into release/3.1 2018-07-12 18:04:19 +01:00
Dylan K. Taylor
ebbbc581ca Player: clean up cursor inventory when closing main inventory 2018-07-12 17:52:22 +01:00
TheNewHEROBRINEX
0c350f2f57 Add quitMessage parameter to Player::kick() 2018-07-09 18:40:30 +01:00
TheNewHEROBRINEX
bfcef2ab6b Add setReason() method to PlayerKickEvent 2018-07-09 18:36:19 +01:00
Dylan K. Taylor
0f0d12bebc Merge branch 'release/3.0' into release/3.1 2018-07-02 16:58:15 +01:00
Dylan K. Taylor
905259a4e1 Fixed not being able to place blocks inside dead players
closes #2265
2018-06-29 16:38:35 +01:00
Dylan K. Taylor
8c672cb7c8 Implemented Sharpness, Fire Aspect and Knockback enchantments 2018-06-24 12:13:54 +01:00
Dylan K. Taylor
6c6630d845 Player: avoid doing some post-melee attack actions if attacking killed the attacker
This can happen when an attacker attacks a victim wearing thorns armour while having low health, which prior to this commit would cause the tool to be duplicated.
2018-06-22 17:17:40 +01:00
Dylan K. Taylor
2d3ce9e8b0 Remove some fully qualified function calls
PhpStorm can't see these or understand how they are being called, which is very annoying for bug hunting. Additionally, we already have the CodeOptimizer for this.
2018-06-18 12:23:19 +01:00
Dylan K. Taylor
a080a9b75c Player: remove redundant parameter from checkNearEntities() 2018-06-11 12:25:01 +01:00
Dylan K. Taylor
137a05c418 Player: remove useless return value from orderChunks() 2018-06-11 12:22:46 +01:00
Dylan K. Taylor
245f5c6bef Player: remove obsolete TODO 2018-06-11 12:20:11 +01:00
Dylan K. Taylor
47742d74c8 Player: Drop load queue on level switch
This ensures that the player doesn't request bad chunks if it was teleported from an invalid level.
2018-06-09 16:21:41 +01:00
Dylan K. Taylor
601811f0f8 Player: Account for the possibility of Level being null in switchLevel()
the Entity base also accounts for this, and assuming that this is automatically valid is causing lots of crashes. I am not sure of the circumstances under which this is suddenly becoming null, but this shouldn't assume that the level is valid nonetheless.
2018-06-09 16:20:51 +01:00
Dylan K. Taylor
37b445f210 Updated Math dependency 2018-06-09 13:05:25 +01:00
Dylan K. Taylor
d03f36ebee First look at splitting up AsyncPool and ServerScheduler
This commit contains quite a few breaking changes with respect to how AsyncTasks are handled. This is necessary to allow separation of the ServerScheduler and the AsyncPool, because in the future the ServerScheduler may be removed and instead there will be isolated per-plugin sync-task schedulers - but we cannot have every plugin with its own worker pool for memory usage reasons if nothing else.

The following things have changed:
- ServerScheduler: scheduleAsyncTask(), scheduleAsyncTaskToWorker(), getAsyncTaskPoolSize(), increaseAsyncTaskPoolSize() and similar methods have all been removed. Additionally the static \$WORKERS field has been removed.
- Server: added API method getAsyncPool(). This grants you direct access to the server's AsyncPool. Calls to getScheduler()->scheduleAsyncTask() and scheduleAsyncTaskToWorker() should be replaced with getAsyncPool()->submitTask() and submitTaskToWorker() respectively.
2018-05-30 12:20:10 +01:00
Dylan K. Taylor
b003295d01 Player: reduce duplicated code in PlayerActionPacket handler 2018-05-28 19:38:29 +01:00
Dylan K. Taylor
87ff1c0382 Player: don't catch Throwable on transaction creation failure 2018-05-28 17:00:59 +01:00
Dylan K. Taylor
2eaba7c936 Timings: added timings for Player->checkNearEntities() 2018-05-28 16:27:03 +01:00
Dylan K. Taylor
8cf0fc63d8 Player: spawn at safe-spawn on level not found, instead of real spawn 2018-05-26 12:20:58 +01:00
Dylan K. Taylor
9dd0ee7f05 Entity: replaced motion and lastMotion fields with vectors 2018-05-24 12:11:41 +01:00
Dylan K. Taylor
1c4dd4f280 Player: broadcast entity event to self as well when sending to all viewers
this fixes several bugs with entity events and removes the need for a hit animation hack.
2018-05-23 09:28:46 +01:00
Dylan K. Taylor
faa88a55e4 EntityDamageEvent: break API
The general purpose of this is to split up base damage from modifiers.

- Added methods getBaseDamage(), setBaseDamage(), getOriginalBaseDamage(), getModifiers(), getOriginalModifiers()
- setDamage() renamed to setModifier() and type is now mandatory
- getDamage() renamed to getModifier() and type is now mandatory
- getOriginalDamage() renamed to getOriginalModifier() and type is now mandatory
- Removed MODIFIER_BASE constant
- Constructors now accept: float baseDamage, float[] modifiers instead of just float[] modifiers
2018-05-22 19:05:25 +01:00
SalmonDE
2f03f5f6d5 Fix a grammar error in Player (#2197) 2018-05-20 21:27:40 +01:00
Dylan K. Taylor
adb9390b53 Entity: Rename isInsideOfWater() to isUnderwater() 2018-05-19 18:10:43 +01:00
Dylan K. Taylor
807af2e6fb Human: change doFoodTick() visibility to protected 2018-05-19 16:30:41 +01:00
Dylan K. Taylor
0bb5e88b5c Hinting up Entity API to PHP 7.2 standards 2018-05-19 10:46:47 +01:00
Dylan K. Taylor
f757ba1851 Merge branch 'release/alpha12' 2018-05-17 19:27:26 -04:00
Dylan K. Taylor
8c1c8f34cc Player: confine command data resending on permission recalculate to post-spawn only
this fixes crashes when PurePerms causes this to be recalculated on player login - the client doesn't like receiving this before StartGame and crashes.

Confining this to post-spawn should not cause any issues since any permission recalculation in login events will be reflected immediately afterwards when the initial command data is sent anyway.

This same bug popped up at 1.1... I don't know why it wasn't fixed properly back then.
2018-05-17 19:26:42 -04:00
Dylan K. Taylor
c285295037 Merge branch 'release/alpha12' 2018-05-17 18:40:24 +01:00
Dylan K. Taylor
7e70569ba2 Player: Send all open inventories instead of hardcoded selection
Players have a few associated inventories which might need sending nowadays, such as main, armour, offhand (not implemented yet), cursor, crafting (if it ever worked). Under these conditions we should be sending all open windows.
2018-05-11 09:28:59 +01:00
Dylan K. Taylor
b21572774a Tool: cleanup durability handling, closes #379
long overdue... this isn't quite as extensible as the original api3/blocks system was, but this is primarily intended to replace Item->useOn(). If plugins want to use it it can be extended later on.
2018-05-10 19:48:51 +01:00
Dylan K. Taylor
b8523cb304 Merge branch 'remove-weak-position' 2018-05-10 13:53:07 +01:00
Dylan K. Taylor
38c3f00ef7 avoid crashes when XUID is null 2018-05-05 13:33:13 +01:00
Dylan K. Taylor
68638f9779 Fixed translations
Apparently the translation type doesn't translate unless this flag is set now...
2018-05-04 22:14:02 +01:00
Dylan K. Taylor
fe8102c062 Silence another stupid spam bug 2018-05-02 12:03:29 +01:00
Dylan K. Taylor
0247dff909 Fixed mis-uses of Item->isTool()
this has been wrongly used to indicate a durable item, but not just tools are durable items.
2018-05-01 20:05:02 +01:00
Dylan K. Taylor
a889a0e517 Workaround for player hitbox bug on respawn
this happens when a player respawns before their death animation ends. I don't know why, but their bounding box height suddenly becomes zero. This solves the bug by simply resending the height and width properties to viewers on respawn.

Closes #2135.
2018-04-04 20:11:16 +01:00
Dylan K. Taylor
ef2dd1de92 Inventory: Use exceptions to report back why a transaction failed
Returning false all the time could mean any one of a range of things. Throwing exceptions is better in that it allows us to catch them and see what actually broke.
2018-04-04 12:11:24 +01:00