Oops, I broke your plugins!

Discussion in 'Plugin Development' started by EvilSeph, Jan 15, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    EvilSeph

    We've had to change the JavaPlugin constructor to accommodate the addition of configuration support, as a result ALL plugins need to be updated or you'll get an InvalidPluginException. The below applies as of build Bukkit 21+ and CraftBukkit 20+.

    The constructor was changed from:
    Code:java
    1. public JavaPlugin(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader)


    To:
    Code:java
    1. public JavaPlugin(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader)


    So, you need to update your plugin accordingly, for example:
    Code:java
    1. public Fillr(PluginLoader pluginLoader, Server instance,
    2. PluginDescriptionFile desc, File folder, File plugin,
    3. ClassLoader cLoader) {
    4. super(pluginLoader, instance, desc, folder, plugin, cLoader);
    5. }
     
  2. Offline

    Dinnerbone Bukkit Team Member

    Sorry, it had to be done!

    Changes:

    All methods containing "ID" in the name are now "Id" - Grum's working on this, will be done very

    For example: getTypeID is now getTypeId


    BlockState.getData now returns a MaterialData. You can use it like this:

    Code:java
    1.  
    2. BlockState state = someBlock.getState();
    3. MaterialData data = state.getData();
    4.  
    5. if (data instanceof Wool) {
    6. Wool wool = (Wool)data;
    7. player.sendMessage("You have a " + wool.getColor() + " wool!");
    8. }
    9.  


    BlockFace now matches enum code standards

    For example, NorthWest is now NORTH_WEST
     
    CoolGamerXD, Dragon707 and JMEYER like this.
  3. Offline

    Afforess

    Fixed my plugin already.
     
  4. Offline

    Dinnerbone Bukkit Team Member

    Added another change.

    Packages have been changed around; all entity stuff are now in org.bukkit.entity and all inventory stuff are in org.bukkit.inventory
    --- merged: Jan 15, 2011 9:41 PM ---
    Also, block is now in the org.bukkit.block package

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 8, 2016
    Rayzr522 likes this.
  5. Offline

    sk89q

    org.bukkit.Vector moved to org.bukkit.util.Vector
     
  6. Offline

    lostaris

    You forgot to mention that material enums have also been updated to enum standards, eg GoldAxe is now GOLD_AXE ;)
     
  7. Offline

    Dinnerbone Bukkit Team Member

    That was done a few days ago, but yeah I should have mentioned that sorry
     
    TheDevZone likes this.
  8. Offline

    sk89q

    New change:
    Methods in BlockListener are now present tense.

    Event class for onFlow changed; breaks plugins that use that event

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 8, 2016
  9. Offline

    EvilSeph

    The command itself is no longer included in "args" for commands as the method parameters are:
    public boolean onCommand(Player player, Command command, String commandLabel, String[] args)

    Therefore making the command being in "args" redundant.
     
  10. Offline

    EvilSeph

     
  11. Offline

    EvilSeph

     
  12. Offline

    Dinnerbone Bukkit Team Member

    REDSTONE_CHANGE now takes a BlockRedstoneEvent, which no longer extends BlockFromToEvent. A simple recompile should fix any brekages.
     
  13. Offline

    Cogito

    In 1 week from this message, we will remove the enum MobType, and the block interface MobSpawner. These have already been replaced with CreatureType and CreatureSpawner, which you should use instead.

    Additionally, PlayerEggThrowEvent uses MobType for setting its hatchType. Methods using CreatureType exist (where possible - functions that return MobType can not be changed without breaking them) and you should use them where needed. The existing methods will be removed at the same time as the other removals. Anything using
    Code:
    public MobType getHatchType();
    will break in 1 week. At that time you will need to change to
    Code:
    public CreatureType getHatchType();
     
  14. Offline

    Dinnerbone Bukkit Team Member

    I'm about to break all damage events (and hopefully fix them while I'm at it... :p)

    Currently you have:
    • onEntityDamage (ENTITY_DAMAGED)
    • onEntityDamageByProjectile (ENTITY_DAMAGEDBY_PROJECTILE)
    • onEntityDamageByEntity (ENTITY_DAMAGEDBY_ENTITY)
    • onEntityDamageByBlock (ENTITY_DAMAGEDBY_BLOCK)
    After this fix (very shortly, tonight) you'll have:
    • onEntityDamage (ENTITY_DAMAGED)

    This event will be fired for all types of damage. If you need to know the specifics of the damage, you just check and cast the event object to something. For example:

    Code:
        public void onEntityDamage(EntityDamageEvent event) {
            if (event instanceof EntityDamageByEntityEvent) {
                EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event;
                // Do something with sub
            }
        }
    
     
  15. Offline

    EvilSeph

    On the topic of TSLPC (That Stupidly Long Plugin Constructor) check:
    We now include a check for people using the plugin constructor:
    Code:java
    1. public JavaPlugin(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {


    You can usually solve this issue by removing your plugin constructor and moving whatever was in it into onEnable.

    For example:
    Code:java
    1. public Fillr(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
    2. super(pluginLoader, instance, desc, folder, plugin, cLoader);
    3. }

    Just remove it.

    If you get an error like:
    Make sure to update your Bukkit reference.

    For further information, see this thread:
    http://forums.bukkit.org/threads/too-long-constructor.5032/
    --- merged: Feb 21, 2011 8:50 PM ---
    While this isn't a "plugin break" per se, this thread wasn't really just meant as a warning against plugin breaks. It's a thread that gives developers a heads up on changes coming that will most likely affect them.

    That being said, as per http://forums.bukkit.org/threads/introducing-recommended-builds.5137/, we'll be expecting plugin developers to keep up with Recommended builds at the very least. In the near future, we may even make it a plugin submissions/releases requirement.

    To give you an idea of where the builds are at:
    With Jenkins, I believe http://ci.bukkit.org/job/dev-CraftBukkit/45/ is the first build to implement the TSLPC (That Stupidly Long Plugin Constructor) check.

    While the latest build http://ci.bukkit.org/job/dev-CraftBukkit/403/ corresponding to this change in CraftBukkit:
    https://github.com/Bukkit/CraftBukkit/commit/c18627d99ef1d19db663fae77cc495e0677a073d

    And this change in Bukkit:
    https://github.com/Bukkit/Bukkit/commit/112a04a08cb187f2befb3ad422215a0a7a728ca4
     
  16. Offline

    Dinnerbone Bukkit Team Member

    ConsoleCommandSender no longer has a default constructor, use ConsoleCommandSender(server)
    --- merged: Feb 24, 2011 12:21 PM ---
    Support for the previous constructor and disabled event registration will be removed tomorrow. Any plugins which still use it will be broken.

    (Basically: If you receive a nag in your console, it means update it or it'll break this time tomorrow.)
     
  17. Offline

    Dinnerbone Bukkit Team Member

    onPlayerCommand and PLAYER_COMMAND are now removed, they have been deprecated for a month.
     
  18. Offline

    EvilSeph

    As you can probably see above, the next Recommended Build will break your plugins if you haven't already prepared to address the issues in this thread.

    The following changes (and possibly more, if I've missed any) will break any outdated plugins:
    • Using the The Stupidly Long Plugin Constructor will result in an exception being thrown.
    • onPlayerCommand and PLAYER_COMMAND have been removed.
    • Commands HAVE to be handled in onCommand which HAS to be in the plugin class or you can set an executor.
    • The *.bukkit namespace has been sealed. This includes namespaces like com.bukkit.org, not com.thevoxelbox.bukkit.
    • Mob -> Creature (See this post for more information).
    • Damage events have been condensed into one, all encompassing event.

    Please make sure you're prepared for the next recommended build which will happen sometime this week!
     
    Hafnium likes this.
  19. Offline

    Tahg

    PlayerInteractEvent is replacing the following events:
    PlayerItemEvent, BlockPlaceEvent, BlockInteractEvent, BlockRightClickEvent
     
  20. Offline

    Dinnerbone Bukkit Team Member

    Note that any plugin that registers events when it is not enabled will be broken in a few hours. Basically if your plugin prints the following nag then it will no longer work:

     
  21. Offline

    Grum Bukkit Team Member

    As earlier announced by Tahg, here is major breakage :)

    The most recent set of commits (which made build 561) quite some plugins:

    The changes:
    • Renamed events/constants (from past to future tense)
    • Added PlayerBucketFill, PlayerBucketEmpty and PlayerInteract events
    • Removed: BlockRightClick, BlockInteract and PlayerItem events
    • Updated: BlockDamage and BlockPlace events
    PlayerInteract:

    The biggest change is how Bukkit handles player interaction.

    The PlayerInteract event has eaten: BlockRightClick, BlockInteract and PlayerItem and will get called for nearly every interaction a player tries to do.

    There are 5 different actions defined:
    • LEFT_CLICK_BLOCK; for left clicking on a block (digging)
    • LEFT_CLICK_AIR; for left clicking in the air (flailing your arm)
    • RIGHT_CLICK_BLOCK; for right clicking on a block (interacting/using item)
    • RIGHT_CLICK_AIR; for right clicking in the air (using item)
    • PHYSICAL; for 'ass pressure' (only used for pressure plates)
    The event has an optional Block and ItemStack with it, (depending on if you targeted a block and/or had something in your hand). All actions should be triggered based on the packets we get from the client. This also means that some actions will not do anything, I believe at this moment only a 'certain range' of air-left-clicking (same error-range as bucket-use, less than half a block) and empty-handed air-right-clicks. This simply because the client either doesn't send the data, or is really inaccurate.

    Depending on the context you can prevent either the 'use of the block' or the 'use of the item'.

    BlockDamage:

    The BlockDamage event has been redesigned so it now works properly with the 1.3 changes Mojang did. Before; each gametick while digging would send a packet, and you could thus assign damage per tick. This is changed now and along with the changes where the client stopped sending 'StopDigging' packets, the event has lost its DamageType. It now has an instaBreak boolean which can be used to instantly destroy a block rather than manually setting the damage of a tool per swing. If you missed the the 'BlockBreak' DamageType functionality look at the BlockBreakEvent.

    BlockPlace:

    Many item uses will now call a 'BlockPlace event when used and 'leaving a block behind'. The items include: Cake, Diode, Reed, Redstone, Door (iron/wood), Bed, Redstone Dust etc.
    For the multi-block items, only one block is 'placed'. You should be able to figure out where the second one is from the data (the bottom block of a door, and the 'foot end' of a bed).

    All items/blocks should be working 'properly', let me know if something was missed somehow.
     
  22. Offline

    Grum Bukkit Team Member

    Some little changes done to prevent breaks changing api in the future:

    Code:
    onPlayerCommandPreprocess(PlayerChatEvent event) -> onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
    onBlockFlow(BlockFromToEvent event)     -> onBlockFromTo(BlockFromToEvent event)
    onPlayerJoin(PlayerEvent event)         -> onPlayerJoin(PlayerJoinEvent event)
    onPlayerQuit(PlayerEvent event)         -> onPlayerQuit(PlayerQuitEvent event)
    onPlayerTeleport(PlayerMoveEvent event) -> onPlayerTeleport(PlayerTeleportEvent event)
    onPluginDisable(PluginEvent event)      -> onPluginDisable(PluginDisableEvent event)
    onPluginEnable(PluginEvent event)       -> onPluginEnable(PluginEnableEvent event)
    onVehicleUpdate(VehicleEvent event)     -> onVehicleUpdate(VehicleUpdateEvent event)
    onWorldLoad(WorldEvent event)           -> onWorldLoad(WorldLoadEvent event)
    onWorldSave(WorldEvent event)           -> onWorldSave(WorldSaveEvent event)
     
    Phil2812, Tazzernator and sharkale like this.
  23. Offline

    EvilSeph

    As you can probably see above, the next Recommended Build will break your plugins if you haven't already prepared to address the issues in this thread.

    The following changes (and possibly more, if I've missed any) will likely break any outdated plugins:
    • PlayerInteractEvent replaces: BlockRightClickEvent, BlockInteractEvent and PlayerItemEvent
    • Renamed events/constants (from past to future tense)
    • Added PlayerBucketFill, PlayerBucketEmpty and PlayerInteract events
    • Updated: BlockDamage and BlockPlace events
    • Refactored many event signatures.
    • Replaced void teleportTo(Location) with boolean teleport(Location).
    • World.spawnCreature now returns LivingEntity instead of Creature.
    While this list looks small, the changes made will break a large number of plugins. Please make sure you're prepared for the next recommended build which will happen SOON - most likely later today!
     
    meguy26 likes this.
  24. Offline

    Grum Bukkit Team Member

    With the next recommended build the name of your plugin (as given in the plugin.yml) can only consist of:
    A-Z, a-z, 0-9, _ (underscore), . (dot), - (hyphen) and spaces (no tabs).

    In the future (not in a near RB) this will likely change to dropping spaces as well, when we do this a 'description' or similar attribute will be added to allow for a 'nice name'.
     
  25. Offline

    EvilSeph

  26. Offline

    Grum Bukkit Team Member

    This change will also change the name of the folder the plugins will use to store their data in. Instead of the 'jar name' (without .jar) it will now use name defined in the plugin.yml (yes containing spaces, see the last part of the quote). Bukkit will try and rename any 'old' folder it finds to the new one and you will be informed about this on the console/logs.

    If Bukkit for some reason cannot rename and or create the folder, it will prevent the plugin from loading at the start and say this in the console/logs.

    People having guides on where configuration might be found and GSP's might be influenced by this!
     
  27. Offline

    EvilSeph

     
  28. Offline

    Dinnerbone Bukkit Team Member

    The following deprecated methods have been removed:

    Coal.setSpecies - deprecated in April

    Crops.setSpecies - deprecated in April
    Crops.getSpecies - deprecated in April

    Entity.teleportTo(Location) - deprecated in March
    Entity.teleportTo(Entity) - deprecated in March

    PlayerListener.onPlayerQuit(PlayerEvent) - deprecated in March
    PlayerListener.onPlayerCommandPreprocess(PlayerChatEvent) - deprecated in March
    PlayerListener.onPlayerTeleport(PlayerMoveEvent) - deprecated in March
    PlayerListener.onPlayerJoin(PlayerEvent) - deprecated in March

    ServerListener.onPluginDisable(PluginEvent) - deprecated in March
    ServerListener.onPluginEnable(PluginEvent) - deprecated in March

    VehicleListener.onVehicleUpdate(VehicleEvent) - deprecated in March

    WorldListener.onWorldLoad(WorldEvent) - deprecated in March
    WorldListener.onWorldSave(WorldEvent) - deprecated in March

    See this commit for more information:
    https://github.com/Bukkit/Bukkit/commit/a329cf151b50de2d06e26fcc53ab24d634f3c732
     
  29. Offline

    EvilSeph

    The upcoming RB will contain a few breaks:
    • Plugins that teleport players within the PlayerMove event will need to switch to just using event.setTo() as this now handles teleporting. This means that event.setTo() can now handle multi-world too.
    After the upcoming RB, the following API changes will occur:
    • onSnowForm will be replaced with onBlockForm.
    • NoteBlock.getNote() that returns a byte will be changed to getRawNote()
    • NoteBlock.getNote() will then be changed to return a Note instead.
    We're still working on this RB so there might be more to add to this list, but mostly it is the Portal event revamping we're doing.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 8, 2016
  30. Offline

    Dinnerbone Bukkit Team Member

    The initialize method of plugins will now be called before the first world is created, instead of after. This is to accommodate a new option to select if your plugin should be enabled before or after the world is created.

    Nothing in the initialize method should actually touch the world, so this shouldn't break any smart plugins.
     
Thread Status:
Not open for further replies.

Share This Page