3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-17 13:30:06 +01:00
Commit graph

2229 Commits

Autor SHA1 Nachricht Datum
h31ix
743d0fb603 Properly return contents of Inventory. Fixes BUKKIT-3930
When an array of an inventory's contents is requested, we loop through the contents of the NMS inventory's ItemStacks in order to return Bukkit ItemStacks that can be used through the API. However, the NMS ItemStack can, in some cases, be larger than the physical size of the inventory. Using the size of the NMS array as a limit on the loop that follows can result in an ArrayIndexOutOfBoundsException because the Bukkit array's length is the actual size of the inventory, and thus will be smaller.

With this commit we use the smaller of the two arrays' length as the limit in the loop, thus eliminating the possibility that the smaller array will be asked for an index higher than its length.
2013-04-02 16:10:04 -05:00
Travis Watkins
c33908509a Set world on fixed tile entity to avoid NPE. Addresses BUKKIT-3949 2013-04-01 00:06:09 -05:00
Travis Watkins
311f0c86a4 Fix mismatched tile entities for new blocks. Fixes BUKKIT-3949 2013-03-31 19:38:25 -05:00
Travis Watkins
71a475f076 Don't update physics when block place is cancelled. Fixes BUKKIT-3939
When a block placement happens we currently update physics on the
attempted placement and update again if the placement is cancelled.
To correct the first one we simply set the block without applying
physics. To correct the second we have to add a new method to
BlockState that lets us update without applying physics and use
this method method when putting the block back.
2013-03-31 19:18:42 -05:00
Travis Watkins
d3dbb1bb50 Correct slot types for brewing stand. Fixes BUKKIT-3937 2013-03-31 18:41:36 -05:00
Wesley Wolfe
f859d45727 Throw exception for disabled plugin tasks. Fixes BUKKIT-3951
Without this check, any non-null reference to a plugin is considered
'valid' for registering a task in the scheduler. This is obviously
unintentional behavior and has been changed to throw an
IllegalPluginAccessException. It is now consistent with the
SimplePluginManager event registration contract.

This in affect also addresses BUKKIT-3950 for uninitialized plugin
references (ones without a description).
2013-03-31 15:37:17 -05:00
Travis Watkins
af964c8331 Limit hopper to valid directions. Fixes BUKKIT-3940 2013-03-31 13:29:13 -05:00
Travis Watkins
06ebe6b705 Add BlockHopper from mc-dev for diff visibility. 2013-03-31 13:20:30 -05:00
Travis Watkins
a1c38cd8f3 Include anvil result in inventory size. Fixes BUKKIT-3741 2013-03-30 02:51:26 -05:00
Travis Watkins
af7ea28bc7 Only call event when turning pressure plate on. Fixes BUKKIT-3881 2013-03-29 22:48:49 -05:00
Travis Watkins
82e05d435b Special case large chests for hopper events. Fixes BUKKIT-3916
Large chests work in a different fashion as they are a combination of
two other inventories. This causes their getOwner method to always return
null as their is no correct return. To compensate for this for the hopper
events we special case them to use their CraftBukkit counterpart that has
the information we need for the event.
2013-03-29 22:27:07 -05:00
Travis Watkins
ee572114dd Add Beacon block state for hopper events. Fixes BUKKIT-3932 2013-03-29 22:26:27 -05:00
EdGruberman
377be0a79e Call PotionSplashEvent even for no effects. Fixes BUKKIT-3618
When a splash potion has no applicable effects we currently do not call
PotionSplashEvent. This means plugins are unable to make custom
potions with reliable splash handling as they have to relicate the
functionality themselves.

With this commit we simply make the event fire regardless of the effects
on the potion.
2013-03-28 21:14:48 -05:00
gjmcferrin@gmail.com
adbee6049e Call appropriate event for zombies igniting players. Adds BUKKIT-3915 2013-03-28 21:10:42 -05:00
Wesley Wolfe
acd637d48b Properly copy collection references in ItemMeta.clone(). Fixes BUKKIT-3913
When cloning an item, all references are copied to the new item. For
collections, this makes internal changes become visible in both the old and
new items.

In CraftMetaItem, clone was not making copies of the appropriate collections
and has been fixed for non-null values.

In CraftMetaEnchantedBook and CraftMetaPotion, clone was using possible empty
collection references and has been changed to explicitly null-check instead.
2013-03-28 20:01:01 -05:00
Travis Watkins
1a7e5a75ae Correct missed diff on skeletons. Fixes BUKKIT-3912 2013-03-28 19:42:27 -05:00
Andre LeBlanc
08f3df82eb Improve calling of ProjectileHitEvent. Fixes BUKKIT-3872 2013-03-26 07:13:14 -04:00
riking
45d3e2514d Add missing semicolon
I should try to compile before I say "this change is okay".
I should try to compile before I say "this change is okay".
I should try to compile before I say "this change is okay".
I should try to compile before I say "this change is okay".
for i in range(100)
2013-03-25 17:12:22 -07:00
Kristofer Henriksson
3c02fb02a1 Allow plugins to enchant already enchanted items. Fixes BUKKIT-1956
This causes the server to generate PrepareItemEnchantEvent even in the
case that an item is already enchanted or otherwise would normally not
be enchantable.
2013-03-25 15:56:15 -07:00
Black-Hole
02a5d09ddf Call EntityChangeBlockEvent when boats destroy blocks. Fixes BUKKIT-3871 2013-03-25 16:55:48 -04:00
Andre LeBlanc
18d7bc7ca3 Allow fishing success rate to be adjustable. Adds BUKKIT-3837 2013-03-25 14:45:24 -04:00
GJ
96ba65d506 Add methods to check conflicting enchantments. Adds BUKKIT-3830 2013-03-25 10:51:54 -04:00
Travis Watkins
5f089137ee Cleanup comments, formatting, etc 2013-03-25 00:51:36 -05:00
Patrick Seidel
7c40a073d8 Add ability to change player item in hand. Adds BUKKIT-3318 2013-03-24 14:04:27 -04:00
Travis Watkins
b532042973 Don't assume all hoppers are blocks. Fixes BUKKIT-3883 2013-03-24 12:38:57 -05:00
riking
8d3ba07f93 Add check for Thorns damage - Fixes BUKKIT-3505 2013-03-23 19:45:46 -07:00
Carlos Cobo
62c6d223e4 Include ThrownPotion in spawn methods. Adds BUKKIT-2542 2013-03-23 19:05:14 -07:00
EdGruberman
e1b50b0110 Identify outside slot independent of inventory type. Fixes BUKKIT-2768 2013-03-23 16:23:03 -07:00
Dennis Bliefernicht
e61a6bab05 Implement InventoryMoveItemEvent. Adds BUKKIT-3765
This makes droppers, hoppers and hopper minecarts fire an
InventoryMoveItemEvent whenever an item is being moved from or to another
inventory.
2013-03-23 16:12:52 -06:00
me4502
b10474253c Fire VehicleEnterEvent for loaded chunks only. Fixes BUKKIT-3831 2013-03-23 10:58:01 -06:00
James Clarke
3ad423af07 ANSI color codes now reset text attributes. Fixes BUKKIT-3508
The client resets all formatting after a color code is received, but currently the ANSI codes do not, and so the console does not accurately reflect the appearance of the formatted text. Instead, the ANSI color codes are now set to reset all text attributes.
2013-03-23 00:26:22 -04:00
Travis Watkins
444ced306a Cleanup and rework physical interaction events. Fixes BUKKIT-3686
Currently when dealing with physical interactions with pressure plates
and tripwires we immediately block their activation as soon as a single
entity involved has their event cancelled. We also fire events whenever
an entity intersects the block a wooden button is in even if they aren't
actually pressing it. To correct this we move the button interaction to
the correct place and modify all three to only block the activation if
every entity is blocked from using them instead of just one of them.
2013-03-22 17:18:19 -05:00
Xephi
ae19f2c46f Implement Dropper interface. Adds BUKKIT-3750 2013-03-21 22:33:16 -06:00
Xephi
978de7e9da Add BlockDropper for diff visibility 2013-03-21 21:42:47 -06:00
Travis Watkins
6f9e4f8541 Stationary lava is also a LAVA ignition cause. 2013-03-21 16:59:45 -05:00
Olof Larsson
abee107830 Add ability to modify ThrownPotion properties. Adds BUKKIT-3197 2013-03-21 15:18:27 -04:00
AlphaBlend
2c5b2a8f6f Add method to get the source of a TNTPrimed. Adds BUKKIT-3815 2013-03-21 12:47:46 -06:00
Andre LeBlanc
83e0e0770a Add Fish (Hook) entity to PlayerFishEvent. Adds BUKKIT-1025 2013-03-20 15:58:37 -07:00
Travis Watkins
696543cf3f Update CraftBukkit to Minecraft 1.5.1 2013-03-20 15:09:23 -05:00
Travis Watkins
6aaa1e83df Really don't filter out -1 data in ItemStack. 2013-03-20 11:11:47 -05:00
Travis Watkins
b325ffc8f6 Handle filled buckets dispensing up and down. Fixes BUKKIT-3814 2013-03-20 10:24:22 -05:00
Travis Watkins
2fc755cc65 Don't filter out -1 data in ItemStack. Fixes BUKKIT-3824 2013-03-20 09:44:17 -05:00
Travis Watkins
26d1f9189a Readd missed diff for minecart container size. Fixes BUKKIT-3826 2013-03-20 09:44:17 -05:00
Nate Mortensen
dc19d3788f BlockState for Command Blocks. Adds BUKKIT-3805. 2013-03-19 20:54:38 -06:00
Edmond Poon
e639690e45 Validate Server method input. Addresses BUKKIT-3687
CraftServer methods that implement the Server interface will throw an
IllegalArgumentException if a method cannot operate on a null input
and given a null pointer.

This causes methods to fail early and identify that a plugin is
responsible for passing in an invalid argument. This will only
change the exception thrown, if there originally was a thrown
exception. This helps with hunting down legitimate problems
with CraftBukkit.
2013-03-18 23:40:10 -06:00
Travis Watkins
51d4e647fb Only filter data on block items, not all items. 2013-03-18 18:22:13 -05:00
Travis Watkins
d26336eb40 Add /testfor command support to command block. Adds BUKKIT-3813 2013-03-18 17:12:21 -05:00
Travis Watkins
596047aa6b Only set player weather if a plugin requested it.
If the server changes the weather it will set the per-player weather
variable and future changes will not apply. We should only set this
variable when a plugin is requesting per-player weather and not when
the server it doing it.
2013-03-18 13:58:16 -05:00
T00thpick1
1bde25bb33 Implement per-player Weather API. Adds BUKKIT-812 2013-03-18 13:03:54 -05:00
Yariv Livay
a7a5f273e3 Implement new cause versions of BlockIgniteEvent. Addresses BUKKIT-3609, BUKKIT-3656, BUKKIT-3657 2013-03-18 12:47:01 -05:00
Travis Watkins
2e6cfdb3cc Implement InventoryPickupItemEvent. Adds BUKKIT-3798 2013-03-18 12:35:43 -05:00
Michael Limiero
2642fbdf7e Make CraftMinecartHopper work as InventoryHolder. Adds BUKKIT-3796 2013-03-18 12:16:37 -05:00
Chad Waters
93fd33e218 Implement Entity.isOnGround(). Adds BUKKIT-3787 2013-03-17 22:25:05 -05:00
Travis Watkins
5df704bf5a Use name given to command block instead of "@". Fixes BUKKIT-3803 2013-03-17 20:19:32 -05:00
Michael Limiero
d802168cd5 Implement Hopper block state and inventory methods. Adds BUKKIT-3749 2013-03-17 12:59:27 -05:00
Travis Watkins
6f68fc4ba4 Add missing getOwner method for container minecarts. 2013-03-16 18:32:01 -05:00
Travis Watkins
737e8c5127 Allow special crafting data value on items. Fixes BUKKIT-3780 2013-03-16 18:16:00 -05:00
Travis Watkins
5515b0ee2b Handle double trapped chest inventory. Fixes BUKKIT-3772 2013-03-16 17:14:21 -05:00
Travis Watkins
0e60f1f7b8 Fire BlockDispenseEvent for new dispenser behaviors. Fixes BUKKIT-3774 2013-03-16 16:55:27 -05:00
Travis Watkins
fbe609bdbe Add new DispenseBehavior files from mc-dev for diff visibility. 2013-03-16 16:48:08 -05:00
Travis Watkins
ff1c1daf69 Allow data on tool items. Fixes BUKKIT-3773 2013-03-16 14:51:22 -05:00
Travis Watkins
2e47a1eb80 Comment out vanilla debug message. 2013-03-16 13:45:42 -05:00
Travis Watkins
515830cda9 Filter negative values for all items. 2013-03-16 13:26:29 -05:00
Travis Watkins
6d88d545e9 Filter data for items that shouldn't have it and filter wool.
We used to fall Item.filterData() for this but that method is meant for
converting item data to block data during placement and does the wrong
thing for this case. Instead we just see if the item should have data and
if not set it to zero. We also have to filter wool data explicitly because
clients crash when given invalid wool data.
2013-03-16 13:14:09 -05:00
Travis Watkins
a76a5bd36f Ignore invalid inventory slots. Fixes BUKKIT-3737 2013-03-16 10:28:12 -05:00
Travis Watkins
9a38f2022a Use Chest block state for trapped chests. Fixes BUKKIT-3762 2013-03-16 09:46:32 -05:00
Travis Watkins
5903b9f5ca Don't set health directly, will interfere with scoreboard system. 2013-03-16 08:57:57 -05:00
Travis Watkins
7466321212 Limit mob names to 64 chars to avoid client crash. Fixes BUKKIT-3753 2013-03-16 08:32:31 -05:00
Travis Watkins
4fa8c24e42 Always consume bonemeal when used on a sapling. Fixes BUKKIT-3755
In Minecraft 1.5 saplings do not grow with a single use of bonemeal anymore.
Our code assumes they will and only takes away bonemeal from the player
when the tree grows successfully (not cancelled by a plugin). Instead we
now always remove a bonemeal even if a plugin is the reason a tree didn't
grow as this matches the vanilla logic more closely.
2013-03-16 08:05:03 -05:00
Travis Watkins
d47849df8c Remove duplicate place logic for snow. Fixes BUKKIT-3756 2013-03-16 07:38:54 -05:00
Wesley Wolfe
2cb9cbf05c Handle the newly refactored minecarts. 2013-03-16 02:15:51 -05:00
Travis Watkins
b2c72b968e Use proper naming convention for boolean methods. 2013-03-15 14:25:37 -05:00
Travis Watkins
83d29e461c Update CraftBukkit to Minecraft 1.5 2013-03-15 13:28:59 -05:00
Wesley Wolfe
ba6e4c38cf Fix compilation error with exception names 2013-03-02 16:33:35 -06:00
Nate Mortensen
032c7366ad Use the correct CB object for ContainerBrewingStand. Fixes BUKKIT-3357 2013-03-02 16:01:14 -06:00
Eimref
cf7dfeda62 Add proper logging for custom channel exceptions. 2013-03-02 15:57:00 -06:00
Travis Watkins
f6c574dd04 Implement PlayerItemConsumeEvent. Adds BUKKIT-2349 2013-03-02 00:33:46 -06:00
Andrzej Pomirski
993e19b3fb Close inventory on teleport. FIXES BUKKIT-3021. 2013-02-10 17:22:34 -06:00
EdGruberman
d06e597ca5 Check TravelAgent.findOrCreate(Location) for null; Fixes BUKKIT-3590
If a custom TravelAgent is used and returns null for findOrCreate method
a NullPointerException will occur.
Conflicts:
	src/main/java/net/minecraft/server/PlayerList.java
2013-02-10 17:21:59 -06:00
James Clarke
5bb81b75c7 Set CraftTravelAgent.DEFAULT to a non-null value. Fixes BUKKIT-3578
Currently, CraftTravelAgent will call s() on the passed-in WorldServer in order to set DEFAULT. However, s() will always return null at this point, because WorldServer.P will still be null, as it is set after the constructor is called. Instead, we set CraftTravelAgent.DEFAULT to the instance that is being constructed.
2013-02-06 16:45:22 -06:00
feildmaster
2e99e02094 Use entity UUID instead of EntityID for metadata. Fixes BUKKIT-3582
The entity id is a non-unique, non-persistent value, and will cause
entities to lose their respective meta data on chunk unloading, and
teleportation.
2013-02-06 16:32:19 -06:00
EdGruberman
efe8e9a7f5 Always return a TravelAgent; Fixes BUKKIT-3541
Recent changes caused PlayerPortalEvent to suddenly return null
unexpectedly and could end up in NPEs resulting that did not before.
This commit addresses that situation by always ensuring a TravelAgent
instance is returned.

The TravelAgent for world 0 is returned arbitrarily in an effort to
compensate for plugins that are implementation dependent and expect some
form of a TravelAgent to be accessible in the event at all times.
2013-02-04 18:53:06 -06:00
James Clarke
4d3865a036 Fix players spawning above portals. Fixes BUKKIT-3542.
Vanilla does not check for blocks in which the player could
suffocate when changing dimension, so portals will happily spawn
players in blocks when using a portal under certain
circumstances. However, we currently check for these instances
and move the player up until they will not suffocate. This means
that players can sometimes be taken to above the target portal,
making it seem as if a portal was not created. Instead, we now
disable this suffocation check when moveToWorld is called from
changeDimension, mirroring vanilla behavior more accurately.
2013-02-04 18:53:05 -06:00
James Clarke
d661c67a70 Always use the set exit location for portal events. Fixes BUKKIT-3555. 2013-02-04 18:53:04 -06:00
James Clarke
94da64ee93 Use the result of EntityPortalExitEvent. Fixes BUKKIT-3559. 2013-02-04 18:53:03 -06:00
feildmaster
b4b7cacf5e Fix NPE when getting bed spawn location. 2013-01-29 17:25:39 -06:00
feildmaster
37975946a2 Fix contract with Player.getBedSpawnLocation. Fixes BUKKIT-3525
Getting the bed spawn location is supposed to check if the bed is
valid, however, it currently did not do so.
2013-01-29 10:11:57 -06:00
feildmaster
0576395ddd When leaving the end, always target the main world. Fixes BUKKIT-3517 2013-01-29 09:48:52 -06:00
feildmaster
b0e43c8097 Make command blocks only select players on its world. Fixes BUKKIT-3515 2013-01-28 17:01:08 -06:00
EdGruberman
132fdbc4ac Target default world when returning from The End; Fixes BUKKIT-3494
Due to the having to generate new logic to avoid using the customized
PlayerConnection.moveToWorld, entities returning from The End were not
properly calculating their exit target.  This commit corrects that
logic.
2013-01-28 11:26:32 -06:00
Wesley Wolfe
50e74b3b49 Remove erroneous break statement in scheduler. Fixes BUKKIT-3395 2013-01-27 23:00:14 -06:00
feildmaster
1053a1e29d Update Fireballs to account for ExplosionPower. Fixes BUKKIT-3460
Adds BUKKIT-3516
2013-01-27 16:43:30 -06:00
feildmaster
f20d6e3595 Ignore block functions for skulls on BlockPlace. Fixes BUKKIT-3495
Skulls don't normally get block data applied to them, so we shouldn't
apply it either.
2013-01-27 11:31:27 -06:00
feildmaster
899b9c17cc Direct all BlockPlaceEvents to a singular location. Fixes BUKKIT-3438
By having a single function to process BlockPlacement logic, we make
it so that there is consistent behavior throughout all BlockPlace
events. This should allow for easier troubleshooting and less diffs
in source.

This also fixes BUKKIT-3463 by including the correct coordinates that
were clicked to the event.
2013-01-27 10:44:32 -06:00
feildmaster
528bbbdcd8 Fix TileEntities and Blocks getting out of sync. Fixes BUKKIT-3501
Also fixes: BUKKIT-3477 and BUKKIT-3488

Minecraft likes to double check that tile entities get set after they
are placed, however we didn't set tile entities until after our event
was called. This caused the world to have multiple tile entities in a
single block location; to fix this we now set tile entities before
the event.
2013-01-27 10:34:59 -06:00
QuarterAnimal
6e438ccb32 Call BlockGrowEvent for Cocoa plants. Fixes BUKKIT-2525 2013-01-24 19:57:52 -06:00
QuarterAnimal
d74cf36f1c Add BlockCocoa for diff visibility. 2013-01-24 19:57:15 -06:00
QuarterAnimal
b82375a596 Preserve source block in mushroom spread event. Fixes BUKKIT-3354 2013-01-24 19:50:21 -06:00
feildmaster
f10c986136 Properly calculate level cost for books. Fixes BUKKIT-3410 2013-01-24 18:10:03 -06:00
feildmaster
f1efe717bd Call BlockPlaceEvent for skulls the same as other blocks. BUKKIT-3406
When the skull BlockPlaceEvent was added it was made so the event
would be called after all the data has been set, however this is a
behavior change that is inconsistent with other BlockPlaceEvents.
Instead, if people wish to get the block data they should schedule
a task.

Relates to: BUKKIT-3438
2013-01-23 20:41:05 -06:00
EdGruberman
9df87d3399 Compensate for allow-nether/allow-end as false; Fixes BUKKIT-3466
When either of those settings are false, the worlds are not loaded and
therefore will not be targeted for portal exits.  Existing worlds are
iterated directly to avoid defaulting to the first world if a direct
dimension match is not found.

Plugins must also specify exit from custom Bukkit worlds to comply with
original commit: https://github.com/Bukkit/CraftBukkit/commit/2dc2af0

This commit introduces a constant to clarify the dependency on the
CraftBukkit implementation of custom worlds having a dimension offset.
2013-01-23 20:11:01 -06:00
feildmaster
488e45b4ff Reload ban files when reloading the server. Adds BUKKIT-3470 2013-01-23 06:24:40 -06:00
feildmaster
641ecc4f34 Return the valid max value for piston direction. Fixes BUKKIT-2191
By returning the following value (7) we remove the need to special
case pistons in any way (other than the original purpose of this
check, which is to ensure pistons have valid data)
2013-01-23 06:15:21 -06:00
feildmaster
9ba0ddc292 Refactor processBlockPlace logic. Fixes BUKKIT-3406 and BUKKIT-3454
The previous logic was faulty since it lost the logic of "placing" the
block. It was also taking into account data that could have been
changed outside of the processing of this event, which is irrelevant
to the processing of this event.
2013-01-19 08:14:17 -06:00
feildmaster
6a499c8589 Fix broken null contract with Jukebox.setPlaying, Fixes BUKKIT-3429
The javadocs state that a null may be used to remove the currently
playing sound, however this causes a NullPointerException.

It also doesn't process registering the record correctly, along with
processing non-valid items.
2013-01-19 08:14:17 -06:00
EdGruberman
d834ca4c6c [Bleeding] Add experimental support for entity portal traveling 2013-01-19 06:20:33 -06:00
EdGruberman
9cb320654d Add BlockEnderPortal for diff visibility 2013-01-19 06:20:32 -06:00
Wesley Wolfe
01fc296fef Improve the item meta deserialization code-style
Fixed the ItemMetaFireworkTest

Add set power unit tests for FireworkMeta
2013-01-18 02:58:07 -06:00
Zloteanu Nikita
5934a65729 Always call PotionSplashEvent. Fixes BUKKIT-3363
This change allows plugins to add recipients to a PotionSplashEvent
when it would have otherwise had none.
2013-01-17 22:55:09 -06:00
feildmaster
d577b840d4 Place beds with the correct data. Fixes BUKKIT-3447 2013-01-17 12:17:37 -06:00
feildmaster
e59af9908b Update CraftBukkit to Minecraft 1.4.7 2013-01-17 03:50:24 -06:00
feildmaster
315127782a Initialize entity data before spawning them. Fixes BUKKIT-3209
Vanilla does the initialize before spawning everywhere except in the
SpawnerCreature, our spawn event depends on this behavior to be
consistent.
2013-01-16 23:05:18 -06:00
bloodmc
b581068464 Fix entities traveling sideways. Addresses BUKKIT-3443
Original: Update mappings to correct 1.4.6 version.
2013-01-16 23:05:18 -06:00
feildmaster
ccbd3d84e8 Get the BlockState before changing the block. Fixes BUKKIT-3441 2013-01-16 20:21:38 -06:00
feildmaster
98aea835b5 Handle beds and doors the same way as other blocks. Fixes BUKKIT-3437
Relates to: BUKKIT-3438
2013-01-16 08:06:00 -06:00
feildmaster
614ef2f8c5 Throw BlockPlaceEvent when placing double slabs. Fixes BUKKIT-2469 2013-01-16 08:05:59 -06:00
cexikitin
8bc9e712e1 Spawn monsters without prematurely exiting. Fixes BUKKIT-3425
By using return 0, we exit the loop prematurely preventing other
creature types from being spawned if one type is set to 0. By using
continue we move on to the other types and allow them to spawn
properly.
2013-01-14 19:24:08 -06:00
Wesley Wolfe
dd7ba4a258 Various ItemMeta fixes.
Fixes BUKKIT-3408, BUKKIT-3190, BUKKIT-3191, BUKKIT-3407

These changes relate mostly to semantical changes for serialization
contract, exception of changing the map scaling value from byte to boolean,
what it should have been in the first place. Appropriate unit tests were
added for CraftMapMeta, as they were missing.
2013-01-09 05:04:08 -06:00
Wesley Wolfe
182681e384 Update calls to DyeColor getData and getByData. Addresses BUKKIT-2786
These two methods are now deprecated and replaced by the strictly
equivalent calls using wool data.
2013-01-05 17:15:49 -06:00
feildmaster
baaf8e1d86 Implement fishing experience. Adds BUKKIT-3348 2013-01-01 23:59:47 -06:00
feildmaster
fb0be1fc0a Move the tile entity with the falling block. Adds BUKKIT-3349
Allows for interesting things to be done with world.spawn()
2013-01-01 23:58:46 -06:00
feildmaster
8f0c1aed6b Fix "setSitting" on tameable animals. Fixes BUKKIT-1534
This makes it so animals (tame or not) will sit properly and not move
around.

Wild animals that are sitting may override the sitting position if
they are attacking.
2013-01-01 22:28:44 -06:00
feildmaster
05512942db Add PathfinderGoalSit for diff visibility 2013-01-01 22:28:43 -06:00
Mike Primm
32924f9757 [Bleeding] Fix corruption due to thread safety issues. Fixes BUKKIT-3333
The 'tag' NBTTagCompound field of the ItemStack assumes that it is OK to
save a reference to an NBT supplied via load() and assumes it is OK to
supply a reference to the internal field during a save(). Neither is true,
as Chunk NBT structures are required to be read-only once created (due to
being written asynchronously off the server thread AND due to the potential
to be passed to a new Chunk if the same chunk is reloaded before the
writing of the NBT is completed by the File I/O thread). Keeping a live
reference to the NBT copy passed in, or to the NBT value passed back
during saving, creates serious thread safety issues which can result in
corrupted data being written to the world data files.

The specific issue here was uncovered by the recent change to use
setName("") on the ItemStack.tag object. When a chunk is being loaded
again before its save is completed, this results in name of the field
in the NBT being set to "". This causes it to be saved as "" instead
of "tag" resulting in it not being properly reloaded in the future which
results in the itemstack losing all of its metadata.
2012-12-30 23:31:22 -06:00
Wesley Wolfe
bb83795815 Return the level, not ID. Fixes BUKKIT-3326
CraftItemStack was erroneously using the enchantment ID instead of level
for the return value of remove enchantment.
2012-12-29 20:53:27 -06:00
Wesley Wolfe
8954cb291c /dev/null does not accept EnchantmentThorns 2012-12-29 19:18:37 -06:00
feildmaster
7b5a8d0c23 Don't teleport entities that are considered dead. Addresses BUKKIT-1331
Teleportation should never be processed on dead entities. If you wish
to teleport an entity, do it on a living entity. If you wish to
teleport a player, set their respawn location in PlayerRespawnEvent.
2012-12-29 19:18:36 -06:00
Mike Primm
fb0eed177a [Bleeding] Implement periodic chunk garbage collector
This adds two settings to bukkit.yml, allowing activation and control of
two chunk garbage collection triggering conditions:
chunk-gc/period-in-ticks controls a periodic GC, run once every N ticks
(default is 600); chunk-gc/load-threshold causes the GC to run once
after every N calls to loadChunk() on a given world (this call is an API
call used by plugins, and is distinct from the path taken for routine
player movement-based loading).  In both cases, setting to zero will
disable the given GC scheduling strategy.

In either case, the act of doing the GC is simply one of scanning the
loaded chunks, seeing which are NOT being used by one or more players
(due to view-distance) and which are not already queued for unload, and
queueing them for a normal unload.  Ultimately, the unload is then
processed the same as if the chunk were unloaded due to leaving the
view-distance range of all players, so the impact on plugins should be
no different (and strategies such as handling the ChunkUnloadEvent in
order to prevent unload will still work).

The initial interval for the periodic GC is randomized on a per-world
basis, in order to avoid all world being GCed at the same time -
minimizing potential lag spikes.
2012-12-29 16:50:05 -06:00
feildmaster
538de63a03 Fix persistence on tamed pets. Fixes BUKKIT-3300
With the persistence api introduced, pets did not have their
persistence flag updated to reflect their persistence. This caused
tame ocelots to not persist under specific conditions.
2012-12-28 20:27:41 -06:00
feildmaster
509e3d2a32 Update maxhealth for entities that have variable max health. Fixes BUKKIT-3308
Slimes and wolves have health that can change based on certain
conditions. So we check if their max health should be updated, and if
it has been customized in any way.

We also scale the wolf's health for their tail
2012-12-27 21:05:40 -06:00
feildmaster
b908c192bf Fix removing enchantments causing the enchantment tag to remain. 2012-12-27 20:48:56 -06:00
feildmaster
54b2707ba7 Fix discrepancies in NBT and ItemMeta. Fixes BUKKIT-3279
An ItemStack gains the tag name "tag" when the stack is serialized
to NBT, however items don't have a tag *until* they are serialized at
least once. So to solve this, we remove the tag name when loading the
NBT data.

Another problem with NBT are TagLists, when transferring tag lists
between the server and the client the names are lost, and so we
simply don't add a name to the tag.
2012-12-27 20:45:21 -06:00
Travis Watkins
25732f0487 Fire BlockRedstoneEvent for repeaters. Fixes BUKKIT-1157 2012-12-27 15:40:18 -06:00
Travis Watkins
186a679730 Add BlockDiode from mc-dev for diff visibility. 2012-12-27 15:26:49 -06:00
Wizjany
5963da294f Don't update physics until after the place event. Fixes BUKKIT-3316
If you cancel a BlockPlaceEvent for a sign the world is updated as if
the block was placed and then destroyed. To avoid this we set the block
without updating physics then apply the update after the event.
2012-12-27 15:22:19 -06:00
cexikitin
49da990ee3 Never remove players when unloading chunks. Fixes BUKKIT-3129
When unloading chunks we have a check to ensure we do not remove players
from the world due to the issues this would cause. However, our check
to see if the player is in this chunk is reversed and is in fact entirely
wrong. Even if the player isn't currently in this chunk we do not want
to remove them as that will still cause the same issues.
2012-12-27 15:16:33 -06:00
feildmaster
3a0c5aff0c Fix fireballs being motionless (again). Fixes BUKKIT-3299
The key "direction" incorrectly mapped to variables that were already
set in the entity. In order to prevent loading incorrect data we
renamed "direction" to "power."
2012-12-25 05:58:49 -06:00
feildmaster
155b83e2c7 Perform permission removals after the quit event. Fixes BUKKIT-3303
The player would have no permissions (other than their OP status)
when checked in the Quit event. This is because we removed permissions
before the event occurred. By calling it afterwards, we can persist
the data until the server finally removes the player.
2012-12-24 22:11:04 -06:00
feildmaster
f726d07f11 Fix Skull BlockState setting illegal values on owner. 2012-12-24 14:32:08 -06:00
feildmaster
8292b73f30 Fix fireworks being short lived. Fixes BUKKIT-3291 2012-12-23 17:06:26 -06:00
feildmaster
edd90ccf16 Properly update fireworks. Fixes BUKKIT-3289 2012-12-23 08:59:15 -06:00
feildmaster
ced0646351 Implement entity max health methods. Adds BUKKIT-266 2012-12-23 07:29:06 -06:00
feildmaster
4e1793f363 Report valid health when getting Entity health. Fixes BUKKIT-3210 2012-12-23 07:29:05 -06:00
Wesley Wolfe
ed6aab8200 Remove runner leak on async tasks. Fixes BUKKIT-3288
In some situations, an async task could be cancelled with no tasks
pending. This means the finally {} block from run() never gets executed
properly on the last async task to have run, as it expected to be
executed again.

This fix takes the only spot that the task period is set to cancelled
and will check to see if the task should be purged from the runners
list.
2012-12-23 05:13:33 -06:00
Travis Watkins
717fbbeffa Update firework power when modifying meta. Fixes BUKKIT-3272 2012-12-22 13:07:18 -06:00
Travis Watkins
f72a08c22e Fire BlockDispenseEvent for fireworks. Adds BUKKIT-3246 2012-12-22 13:07:18 -06:00
Travis Watkins
da571ef428 Add DispenseBehaviorFireworks and EntityFireworks for diff visibility 2012-12-22 13:06:55 -06:00
feildmaster
dc85940526 Allow fireworks to be created. Adds BUKKIT-3262 2012-12-22 12:24:16 -06:00
Wesley Wolfe
6dc13b688a One record per JukeBox. 2012-12-22 05:48:11 -06:00
Wesley Wolfe
2fd78a6549 Add BlockJukeBox for diff visibility 2012-12-22 05:45:52 -06:00
feildmaster
2ee62eb580 Implement API to get and set FireworkMeta on Firework entities 2012-12-21 23:56:54 -06:00
meiskam
fdb4b2d911 Implement Skull BlockState. Adds BUKKIT-3259 2012-12-21 22:47:11 -06:00
meiskam
39e2af7bd1 Added TileEntitySkull for diff visibility 2012-12-21 21:56:47 -06:00
Wesley Wolfe
78d384de93 Zero is not less than zero. Fixes BUKKIT-3259 2012-12-21 21:48:09 -06:00
feildmaster
a0cf0d03f4 Check file existence before determining readOnly. Fixes BUKKIT-3255 2012-12-21 19:31:39 -06:00
feildmaster
ec211ed952 Update enchantment handling to 1.4.6. Fixes BUKKIT-3256 2012-12-21 19:31:28 -06:00
feildmaster
f71be2506d Fix loading Items entities with an invalid item. Addresses BUKKIT-3249 2012-12-21 16:07:59 -06:00
feildmaster
118682ce5c Don't save server properties when it's read only. Fixes BUKKIT-3250 2012-12-21 15:40:39 -06:00
feildmaster
0216d09033 Fix command line arguments being ignored. Fixes BUKKIT-3247 2012-12-21 15:40:39 -06:00
feildmaster
e937307596 Add a null check for Item Entities. Fixes BUKKIT-3249 2012-12-21 15:40:27 -06:00
Wesley Wolfe
b870755edb Use max inventory size for new stack. Fixes BUKKIT-3240 2012-12-21 11:10:23 -06:00
Wesley Wolfe
708252c020 Implement 1.4.6 ItemMeta. Adds BUKKIT-3236, BUKKIT-3237
Some meta functionality is refactored into common methods.

CraftItemStack uses the ItemMetaKey identifiers for enchantments.

Refactored unit test to include extra functionality; initially only
checking the presence of the DelegateDeserialization annotation.
2012-12-21 10:36:34 -06:00
Wojciech Stryjewski
f377a7680f Add API to allow plugins to request players switch to a texture pack. Adds BUKKIT-2579
The setTexturePack method causes the player's client to
download and switch to a texture pack specified by a URL.

Note: Players can disable server textures on their client, in which
case this API would not affect them.
2012-12-20 22:09:38 -05:00
feildmaster
f4836fb428 Add the ability to make Enchanted Books. Fixes BUKKIT-3220 2012-12-20 20:51:51 -06:00
feildmaster
bd0daa6d54 Remove obsolete fix for the end
The end was getting block offsets, causing client side issues.
2012-12-20 19:15:37 -06:00
Travis Watkins
ca7f67da9d Fetch correct info for skulls in block.getDrops(). Fixes BUKKIT-3205 2012-12-20 15:06:01 -06:00
Mike Primm
ed2dd31a80 [Bleeding] Fix exception in getChunkSnapshot() - sky light can be null 2012-12-20 14:22:25 -06:00
feildmaster
686807e387 Filter invalid ItemStacks from Packets.
Invalid ItemStacks are causing Fireworks to disconnect players and
prevent them from reconnecting
2012-12-20 10:52:44 -06:00
feildmaster
23b6764374 Update CraftBukkit to Minecraft 1.4.6 2012-12-20 10:43:00 -06:00
mbax
924a46469d [Bleeding] Check visibility API for sounds. Fixes BUKKIT-3114
With 1.4, entity sound tracking changed for the better.
Our previous method additions can now be removed.
All that's left is checking if the source can be seen
by the recipient of the sound packet. Thanks, Mojang!
2012-12-18 19:02:20 -06:00
feildmaster
d9708d032e Fix PotionMeta not applying the correct Id. Fixes BUKKIT-3193 2012-12-18 18:43:53 -06:00
feildmaster
d73e5ab469 Add missing name in PotionEffect for Wither 2012-12-18 18:20:11 -06:00
feildmaster
a2d551fafa Refactor get/setChestPlate to Chestplate. Addresses BUKKIT-3189 2012-12-18 03:46:58 -06:00
Wesley Wolfe
6cec8ba5cb Change enchantment comparisons to isSimilar. Fixes BUKKIT-3183
The purpose of the isSimilar method was designed to consider all NBT
data, not solely enchantments, without the need to have exact stack
size matches. The respective methods in CraftInventory were still
comparing enchantments instead of the ItemMeta.
2012-12-17 16:43:16 -06:00
Wesley Wolfe
d66d3674ea Clarify functionality in CraftInventory. Fixes BUKKIT-3097
Changes some NPEs to IllegalArgumentExceptions for exception consistency.

Contains(ItemStack, int) correctly calculates number of ItemStacks.

Adds a containsAtLeast(ItemStack, int) for finding a combined amount of a
single similar ItemStack.

Makes some utility methods private to prevent ambiguity in use.
2012-12-17 16:39:25 -06:00
Wesley Wolfe
78f48258d8 Implement ItemFactory and ItemMeta values. Adds BUKKIT-15 2012-12-17 01:31:41 -06:00
feildmaster
d20d4dc43a ItemStack.asBukkitStack(null) should return Air. Fixes BUKKIT-3170 2012-12-15 01:52:42 -06:00
deathmarine
53b064ec79 Fix EntityEquipment positions being reversed. Fixes BUKKIT-3157 2012-12-12 22:20:44 -06:00
Travis Watkins
24143ef6a1 Load chunks asynchronously for players.
When a player triggers a chunk load via walking around or teleporting there
is no need to stop everything and get this chunk on the main thread. The
client is used to having to wait some time for this chunk and the server
doesn't immediately do anything with it except send it to the player. At
the same time chunk loading is the last major source of file IO that still
runs on the main thread.

These two facts make it possible to offload chunks loaded for this reason
to another thread. However, not all parts of chunk loading can happen off
the main thread. For this we use the new AsynchronousExecutor system to
split chunk loading in to three pieces. The first is loading data from
disk, decompressing it, and parsing it in to an NBT structure.  The second
piece is creating entities and tile entities in the chunk and adding them
to the world, this is still done on the main thread. The third piece is
informing everyone who requested a chunk load that the load is finished.
For this we register callbacks and then run them on the main thread once
the previous two stages are finished.

There are still cases where a chunk is needed immediately and these will
still trigger chunk loading entirely on the main thread. The most obvious
case is plugins using the API to request a chunk load. We also must load
the chunk immediately when something in the world tries to access it. In
these cases we ignore any possibly pending or in progress chunk loading
that is happening asynchronously as we will have the chunk loaded by the
time they are finished.

The hope is that overall this system will result in less CPU time and
pauses due to blocking file IO on the main thread thus giving more
consistent performance. Testing so far has shown that this also speeds up
chunk loading client side although some of this is likely to be because
we are sending less chunks at once for the client to process.

Thanks for @ammaraskar for help with the implementation of this feature.
2012-12-12 19:35:53 -06:00
Travis Watkins
11593b4592 Add RegionFile from mc-dev for diff visibility 2012-12-12 04:05:47 -06:00
Wesley Wolfe
29d7cc711b Add utility class AsynchronousExecutor
This class is a general purpose task execution system, that uses stages
to separate processing blocks for asynchronous and synchronous
executions.
2012-12-12 04:05:47 -06:00
Travis Watkins
24c04dc784 Don't run mob pickup code on players. Fixes BUKKIT-3150
When a player has canPickUpLoot set to true the code for mob pickup is
triggerd which does not know how to deal with player inventory. Since
players have their own logic for picking up items we simply disable this
code for them.
2012-12-12 03:08:14 -06:00
feildmaster
4e91fbd0db Fix players not being able to pickup items due to default values.
The old flag for picking up loot was default to false, making existing players not able to pickup items. We now use this flag for Players, which gives us the problem we had in 48b46f83.

To fix this, we add an incremental flag that will be cross-examined to check if the data was saved before or after the flag level was introduced.

Addresses BUKKIT-3143
2012-12-11 06:05:54 -06:00
feildmaster
39fdb56200 Players should be able to pick up items by default. Fixes BUKKIT-3143
As an added feature, players defaulted to being able to not pick up items if the flag was false. However, since minecraft doesn't normally use the flag on players, the flag was always false.
2012-12-10 20:27:40 -06:00
feildmaster
3692209fe6 Missed a rename 2012-12-10 19:17:47 -06:00
feildmaster
430d352a5a Add EntityEquipment API. Adds BUKKIT-3103
Adds:
- Getting/Setting equipment
- getting/setting drop rates
- getting/setting ability to pick up items
-- As an added feature, players with this flag start off with a canceled PlayerPickupItemEvent
2012-12-10 19:01:50 -06:00
h31ix
684ba31c39 [Bleeding] Correct getEyeHeight value. Fixes BUKKIT-3130 2012-12-10 01:41:00 -06:00
feildmaster
22b1100001 Only display help aliases when there are aliases. Fixes BUKKIT-1621 2012-12-10 01:40:22 -06:00
feildmaster
dc93da8e34 Pass null help values values as empty strings to HelpTopics
Fixes BUKKIT-2618 and BUKKIT-2561
2012-12-10 01:40:21 -06:00
EdGruberman
f18b3cdc76 [Bleeding] Fix NPE with a null bedSpawnLocation. Fixes BUKKIT-1500 2012-12-10 01:40:20 -06:00
feildmaster
12c7c2f695 Implement FurnaceExtractEvent. Adds BUKKIT-2114 2012-12-08 03:58:34 -06:00
feildmaster
e760d6eb31 Add SlotFurnaceResult for diff visibility 2012-12-08 02:45:50 -06:00
EdGruberman
24abdd556d [Bleeding] Fix NPE in getBedSpawnLocation. Fixes BUKKIT-1949 2012-12-08 02:18:06 -06:00
Dark Arc
090c1a60bd Correctly shoot arrows with the spawnArrow Method. Fixes BUKKIT-3116 2012-12-08 02:15:15 -06:00
Travis Watkins
9973e7cdec Update entity state correctly when marked as persistent. Fixes BUKKIT-3123
When a mob is marked with the persistent flag (animal or anything with
setRemoveWhenFarAway(false)) the entire block of code for checking if they
should be despawned is skipped. However, one part of this code updates the
mob state if a player is close enough to them. It turns out this state is
used by the AI system to decide if the mob should move around randomly or
not. To stop mobs from being frozen in place we now update this state if
the persistent flag is set as well.
2012-12-07 21:18:51 -06:00
Travis Watkins
846a22304c Provide a faster way to get a location. Adds BUKKIT-3120
Currently when a plugin wants to get the location of something it calls
getLocation() which returns a new Location object. In some scenarios this
can cause enough object creation/destruction churn to be a significant
overhead. For this cases we add a method that updates a provided Location
object so there is no object creation done. This allows well written code
to work on several locations with only a single Location object getting
created.

Providing a more efficient way to set a location was also looked at but
the current solution is the fastest we can provide. You are not required
to create a new Location object every time you want to set something's
location so, with proper design, you can set locations with only a single
Location object being created.
2012-12-07 21:15:05 -06:00
feildmaster
c74fd4196f Use shooter constructor for Fireballs. Fixes BUKKIT-3121
Fixes fireballs exploding in the shooter's face and not having a shooter for the projectile. (Two birds with one stone!)
2012-12-07 05:25:20 -06:00
feildmaster
78bc0ad1d5 Add the ability to launch WitherSkulls. Fixes BUKKIT-3106 2012-12-07 05:25:11 -06:00
feildmaster
72ee1f3182 Fix "Commands Only" chat flag. Fixes BUKKIT-2238
Thanks for the commit @mrapple
2012-12-07 05:22:00 -06:00
feildmaster
6a04fd98ad Implement API for wolves collar color. Adds BUKKIT-3109 2012-12-05 18:08:31 -06:00