API has been added to interface with Horses and to modify their inventories. A new event, HorseJumpEvent, has been added to be fired whenever a horse jumps.
This commit fixes BUKKIT-4393.
By: h31ix <zero_gravity@outlook.com>
Through a miscalculation, team display names were being created via
command ignoring the first word in the submitted display names.
By: mbax <github@phozop.net>
This commit brings the InventoryClickEvent up to date with the new Minecraft
changes in 1.5.
InventoryDragEvent (thanks to @YLivay for his PR) is added to represent the
new "dragging" or "painting" functionality, where if you hold an itemstack and
click-drag over several slots, the items will be split evenly (left click) or
1 each (right click).
The ClickType enum is used to represent what the client did to trigger the
event.
The InventoryAction enum is reserved for future expansion, but will be used to
indicate the approximate result of the action.
Additionally, handling of creative inventory editing is improved with the new
InventoryCreativeEvent, and handling of numberkey presses is also improved
within InventoryClickEvent and CraftItemEvent.
Also, cancelling a creative click now displays properly on the client.
Adresses BUKKIT-3692, BUKKIT-4035, BUKKIT-3859 (new 1.5 events),
BUKKIT-2659, BUKKIT-3043, BUKKIT-2659, and BUKKIT-2897 (creative click events).
By: riking <rikingcoding@gmail.com>
Two checks to argument length were changed to properly consider if the
sender is a player instead of an off-by-one logical error.
By: Wesley Wolfe <weswolf@aol.com>
The method to make a string from a collection of strings already exists
and should be used when adding multiple players to a team.
By: Wesley Wolfe <weswolf@aol.com>
Metadata values keep strong reference to plugins and they are not
cleared out when plugins are unloaded. This system adds weak reference
logic to allow these values to fall out of scope. In addition we get
some operations turning to O(1) "for free."
By: crast <contact@jamescrasta.com>
The metadata system generates unique keys for metadata entries based on
the subject metadata is being applied to and the name of the metadata
being applied. It was assumed this would be an expensive operation so a
cache was put in place to ensure this was done as little as possible.
In reality this cache only has a benefit when you have a hit rate above
~90% and is otherwise much slower. As the implementation of the cache is
a hashmap of hashmaps it also uses a significant amount of memory which
is not worth it even for the performance increase with a high hit rate.
This commit simply removes the cache which results in speedups for most
cases and large memory savings.
By: crast <contact@jamescrasta.com>
FixedMetadataValue currently just extends LazyMetadataValue with a value
that never changes. While this works it is a lot of unneeded overhead
that causes FixedMetadataValue to be a lot slower and use a lot more
memory than one would expect. To correct this we store the value directly
in FixedMetadataValue and override the the appropriate methods to use it.
Ideally we would modify FixedMetadataValue to no longer extend
LazyMetadataValue as this would give a very large memory savings. However,
this is not currently done for backwards compatibility reasons.
By: crast <contact@jamescrasta.com>
Implementing the MetadataValue interface is significant work due to
having to provide a large amount of conversion stub methods. This commit
adds a new optional abstract base class to aid in implementation.
By: crast <contact@jamescrasta.com>
The implementation is designed around having both a main scoreboard and
numberous plugin managed scoreboards that can be displayed to specific
players.
Plugin managed scoreboards are active so long as a reference is kept by a
plugin, or it has been registered as a player's active scoreboard. Objects
specific to a scoreboard remain active until unregistered (which remove a
reference to the owning scoreboard), but quickly fail if accessed
post-unregistration.
By: mbax <github@phozop.net>
This event is being called whenever a block or entity (e.g. hopper) tries to
move an item from one inventory to another inventory (one inventory may be
the hopper itself).
By: Dennis Bliefernicht <dennis.bliefernicht@triphoenix.de>
This change is breaking for the new API for 1.5, including the interfaces for
the three new Minecart types and the name of the previously TNT_MINECART
material.
This change also deprecates the two previous specific minecart types located
in the org.bukkit.entity package. This deprecation is not a breaking change
and will still be internally supported.
Each minecart type has new javadoc to be slightly more descriptive. Included
with this are specific references to the interface for each respective
EntityType entry. Another package-info.java file has been included as well.
All specific minecart types extend minecart, each with a more descriptive
name. The naming will also follow the old convention. In addition, the
minecart with no specific designation is now more closely referred to as a
rideable minecart.
By: Wesley Wolfe <weswolf@aol.com>
The permission attachment interface provides two methods each for setting
and unsetting permissions. Each one also provides an extra call to the
recalculatePermissions() method on the permissible, which degrades
performance.
This commit removes the duplicate call to recalculate permissions.
By: Jeffrey Wardian <krinsdeath@hotmail.com>
Permissions are stored as lower case names and referenced as such in all
appropriate methods but removePermission. This changes removePermission
to also convert names to lower case to be consistent with the rest of
the API.
By: Max A <maximilian.ammann@googlemail.com>
Static methods are death to testability. However, irrelevant static
methods can be negotiated with until a later time in which they can be
removed. When instantiating a new Permission object, static calls are
made to the Bukkit class during a recalculatePermissibles logic path.
This recalculatePermissibles call should probably be moved
appropriately, but until the time such testing can be accomplished
itself, these tests work around that situation by simply verifying the
static Bukkit server references are satisfied since what is called as
a result is irrelevant currently.
This commit also updates a few other tests for PluginManagerTest to
work towards the standard of using the Hamcrest unit testing library.
By: EdGruberman <ed@rjump.com>
If the plugin.yml gets loaded but wasn't in the form of a map, the
server would crash. This safely checks to see if it can be cast,
throwing invalid description if it cannot.
By: Wesley Wolfe <weswolf@aol.com>
getInteger returns min value on illegal number formats, so we change
behavior to throw an exception when requested.
By: feildmaster <admin@feildmaster.com>
EntityPortalEvent is called when an entity is about to portal to a
new location. This event is cancellable on top of being able to
change the exit location.
EntityPortalExitEvent is called when exiting the portal, allowing
for adjustment of the exit velocity.
By: EdGruberman <ed@rjump.com>
Negative id values would try to access the array out of bounds and throw an java.lang.ArrayIndexOutOfBoundsException.
By: MikeMatrix <m.braun92@gmail.com>
DyeColor used the wool data for getData(), which is very misleading based
on class name. The old method has been deprecated and replaced with
getWoolData() and getDyeData() for the appropriate types of data values.
The MaterialData classes Dye and Wool were updated appropriately,
especially Dye innapropriately using a DyeColor data value compensation.
Unit tests were added for the new methods, as well as the getColor on Dye
and Wool.
By: Wesley Wolfe <weswolf@aol.com>
The default leather color is already used internally in place of null. The
javadocs were updated appropriately to indicate as such.
By: Wesley Wolfe <weswolf@aol.com>
The warning message printed with the stack traces on the deprecated
methods mistakingly use the wrong method signature in the description.
By: Wesley Wolfe <weswolf@aol.com>
This fixes the Maven generated site so the paths are relative. This is
required so that multiple generations of the javadocs can be hosted at once,
and so no cross-linking occurs.
By: Luke GB <git@lukegb.com>
Books can 'store' enchantments that can be applied to other items later.
These enchantments exist seperately of enchantments that actually effect the
item, and are as stated 'stored' in the book instead of the book being
enchanted. The meta is generically named as the concept could be applied to
other item types later, such as a enchantment scroll.
All of the methods mimic those in the base meta, but instead specify
'stored' in each method name.
By: Wesley Wolfe <weswolf@aol.com>
FireworkEffect is an immutable class that requires the builder pattern
to construct, to reduce ambiguity and help make code uses more readable.
FireworkMeta contains a list of effects, as well as a flight height.
FireworkEffectMeta contains a single effect for charges.
By: Wesley Wolfe <weswolf@aol.com>
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.
By: Wojciech Stryjewski <thvortex@gmail.com>
Prior to 49690f9, BlockFaces were mostly correct in their respective
MaterialData classes. However, a lot of things were not updated since
implementation and broke without being addressed.
This fixes any discrepancies with Block data.
By: feildmaster <admin@feildmaster.com>
These methods are unnecessarily exposed. They are specific to a type of
implementation for the class loaders, and should have no external use.
Because these methods are exposed, it limits the versatility to change
how the internal class loading system works, including an inherent class
loader leak for some situations.
They are now replaced with internal, package-private methods. The public
facing methods will print a stack trace the first time one is activated.
Extending the classes also produces a stack trace, to indicate that
extension is not actively supported.
By: Wesley Wolfe <weswolf@aol.com>
Mainly javadoc changes to be specific in functionality and outcomes. This is
mixed with specifying that null Material should throw IllegalArgumentException
instead of the previous undefined NullPointerException.
Included is a clarification on how contains(ItemStack, int) works, and a new
method containsAtLeast(ItemStack, int) for counting the number of a specific
item.
By: Wesley Wolfe <weswolf@aol.com>
BUKKIT-3164
This adds an isFlammable method, to indicate if a block can catch fire.
This adds an isTransparent method, to check if light can pass through.
This adds an isOccluding method, to check if it fully blocks vision.
This adds an isBurnable method, to indicate if a block can burn away.
By: Wesley Wolfe <weswolf@aol.com>
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.
By: Travis Watkins <amaranth@ubuntu.com>
The name is misleading, as it can be misconstrued to mean "a sync"
instead of properly understanding it as "an async"
By: Wesley Wolfe <weswolf@aol.com>
Non-living entities can change blocks, specifically falling blocks. This change is a small source break, but mainly a byte-code break (requires plugins to recompile).
By: Wesley Wolfe <weswolf@aol.com>
If you use BlockFace in any way, to compensate the directionals being incorrect, you can still have backwards compatibility if you add in the handling in your plugin:
boolean legacyBlockFace = BlockFace.NORTH().getModX() == -1; (and then handle it accordingly)
If you didn't special case your directions to fix what's being fixed here... Hurray! Your plugin should now work.
By: feildmaster <admin@feildmaster.com>
Reobtaining a constructor is not a trivial operation, this change makes the Material enum store the respective constructors for each MaterialData.
Additionally 'fixed' the material tests to use proper generics.
By: Darth Android <darthandroid@gmail.com>
These methods were never intended to be overwritten, and bukkit relies
on their internal functionality. Additionally, the methods were inlined
in JavaPlugin, but the finality maintains intention.
By: Wesley Wolfe <weswolf@aol.com>
EXPLOSION is used when a hanging entity is removed by an explosion.
DEFAULT is used when a hanging entity is removed by an uncategorised
cause.
By: EvilSeph <evilseph@gmail.com>
These numbers are mirrored in vanilla code as the coordinate limits for
a world. Replaced usages to a static final member for code readability.
By: Wesley Wolfe <weswolf@aol.com>
Two potion types were missing from the 1.4.2 update. Invisibility and
night vision are now in the potion type enum.
Fixes an erroneous use of PotionEffectType.SPEED where it should have
been WEAKNESS.
Removed deprecation for the PotionEffectType relating to certain effects
that are now active in 1.4.2.
Fixes BUKKIT-2677, BUKKIT-2758.
By: Wesley Wolfe <weswolf@aol.com>
As well as adding methods for ItemFrames, this moves some methods
previously contained in Painting to Hanging, as they are shared by both
classes.
An enum was added that represents rotations, similar to a clock-face.
This is needed as a contrast to cardinal direction based rotations.
By: h31ix <effectsdude@gmail.com>
Overriding the toString() method provides more human-readable feedback
when a problem occurs, including the version of the plugin if
applicable.
By: Wesley Wolfe <weswolf@aol.com>
This implementation provides access to a (mutable) list and the base
message. Also provided is a convenience method for getting the last
'token' in the provided string.
By: Wesley Wolfe <weswolf@aol.com>
CommandMap contains a method that will auto-complete commands
appropriately. Before the first space, it searches for commands of which
the sender has permission. After the first space, it delegates to the
individual command.
Vanilla commands contain implementations to mimic vanilla
implementation. Exception would be give, that allows for name matching;
a feature we already allowed as part of the command is now supported for
auto-complete as well.
Plugin commands can get a tab completer set to delegate the completion
for. If no tab completer is set, it can check the executor to see if it
implements the tab completion interface. It will also attempt to chain
calls if null gets returned from these interfaces. Plugins also
implement the new TabCompleter interface, to add ease-of-use for plugin
developers, similar to the onCommand() method.
The default command implementation simply searches for player names.
To help facilitate command completion, a utility class was added with
two functions. One checks two strings, to see if the specified string
starts with (ignoring case) the second. The other method uses the first
to selectively copy elements from one collection to another.
By: Score_Under <seejay.11@gmail.com>
PlayerPreLoginEvent was originally implemented with the intention that
putting synchronized blocks on the plugin manager made it thread safe.
Unintentionally, this causes the event to be executed when a plugin
would otherwise expect no events to be firing. It is now deprecated.
By: Wesley Wolfe <weswolf@aol.com>
The new methods return the actual task that gets created from the
scheduler. They are also named such that auto-complete puts the
asynchronous methods after the normal ones. These two additions are
simply semantic.
Tasks now have a method to cancel themselves using their task id. This
is provided as a convenience.
A new class called SimpleRunnable was added. It is an abstract Runnable
such that anonymous classes may subclass it. It provides six convenience
methods for scheduling as appropriate. It also provides a cancel method
for convenience. The functionality of SimpleRunnable only stores an
integer representing the task id. A SimpleRunnable can only be scheduled
once; attempting to reschedule results in IllegalStateException.
By: Wesley Wolfe <weswolf@aol.com>
When an exception occurs, the version of the plugin is not included.
Having this information would be beneficial to plugin authors performing
debug.
The list of authors for NagAuthorException verbose (although unused)
would be more appropriate to simply include all authors, as opposed to
the first appearing.
By: Wesley Wolfe <weswolf@aol.com>
If no plugin is found with the given name, the version command will
search all loaded plugins to find a case insensitive partial match for
the specified name and print to the sender all matches.
By: Wesley Wolfe <weswolf@aol.com>
Previously, the method could be called with a null MetadataStore and stored.
In later execution null pointer exceptions would be generated when checking
for the plugin that the set Metadata belongs to.
Additionally, places where a plugin is referenced will now throw an
IllegalArgumentException if specified plugin is null. Using null would be an
obvious logical flaw, and in some cases produce additional exceptions later
in execution.
By: mbax <github@phozop.net>
This change lets JavaPluginLoader use a temporary HashSet to store
methods that could possibly have the EventHandler annotation. Duplicates
are prevented by the nature of a Set.
Registering parent listeners is a breaking change for any listener
extending another listener and expecting parent listeners to not be
called. Changing this is justified by the ease-of-use and proper object
inheritance design. If this is undesired behavior, the method may be
overridden without reapplying the method with the EventHandler notation.
By: Wesley Wolfe <weswolf@aol.com>