Discussion: Oops, I broke your plugins!

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

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

    Drakia

    @NathanWolf Sorry about spelling mistakes, was typing on my iPhone and these forums lag like crazy.
    In onEnable() change the call to intialize to something as such
    Code:
    if (!initialize()) return;
    And then make initialize() return a boolean, false if it can't find Persistence, true otherwise.
     
  2. Offline

    NathanWolf

    I thought I had done that already for most plugins, actually- that's the "early out" I was talking about. They really shouldn't be registering events if they can't find Persistence, but clearly this needs some looking into :)

    Sounds like I set up dependencies in the YML file, though, Bukkit will largely take care of this for me, which is nice.

    Also, re: iPhone- I sure wish they'd update their ForumRunner plugin. I was recommended (by the website, upon visiting with my phone) to get this app- I bought it ($2), and then it tells me bukkit's forum plugin is outdated. Blah!
     
  3. Offline

    Celtic Minstrel

    I think it works something like this:
    Code:
    depend:
     - Permissions
     - Persistance
    Or the more succinct way:
    Code:
    depend: [Permissions, Persistance]
     
    NathanWolf likes this.
  4. Offline

    NathanWolf

    Thank you very much!
     
  5. Offline

    matejdro

    What is the difference? Just name change or is something else changed?
     
  6. Offline

    Celtic Minstrel

    Just the name/signature change, yes.
     
  7. Offline

    xZise

    Did you changed the “onPlayerInteract(PlayerInteractEvent)” so that the “getClickedBlock()” could return null? I'm getting NPEs which I didn't get in builds like 556 only with 612.

    Fabian
     
  8. Offline

    Grum Bukkit Team Member

    Nothing was changed there, and yes obviously it can return null if there was no block clicked.
     
  9. Offline

    xZise

    I converted this code from onRightClicked and there it never returned null… And maybe a little hint in the javadoc would be nice (something like “It returns null if no black was clicked”).

    Fabian
     
  10. Offline

    Steve Member

    For those upgrading their plugins to work with builds after the commits:
    https://github.com/Bukkit/Bukkit/commit/a6a128197c5440603c25a45128f64a99faa4ca2a
    https://github.com/Bukkit/Bukkit/commit/49976e8ef36e565b7a8f550c83308258923131d1
    You need to be aware of the following:-

    Type name constants changed

    org.bukkit.event.Event.Type
    BLOCK_DAMAGED -> BLOCK_DAMAGE
    BLOCK_FLOW -> BLOCK_FROMTO
    BLOCK_RIGHTCLICKED -> removed use PlayerInteractEvent.action
    BLOCK_PLACED -> BLOCK_PLACE
    CHUNK_LOADED -> CHUNK_LOAD
    CHUNK_UNLOADED -> CHUNK_UNLOAD
    WORLD_SAVED -> WORLD_SAVE
    WORLD_LOADED -> WORLD_LOAD
    ENTITY_DAMAGED -> ENTITY_DAMAGE
    EXPLOSION_PRIMED -> EXPLOSION_PRIME
    PLAYER_ITEM removed use PLAYER_INTERACT
    LIQUID_DESTROY removed
    BLOCK_RIGHTCLICK removed use PlayerInteractEvent.action
    BLOCK_INTERACT removed use PlayerInteractEvent

    The following listener event methods have also been renamed:-
    org.bukkit.event.world.WorldListener
    onChunkLoaded -> onChunkLoad
    onChunkUnloaded -> onChunkUnload
    onWorldSaved -> onWorldSave
    onWorldLoaded -> onWorldLoad

    org.bukkit.event.server.ServerListener
    onPluginEnabled -> onPluginEnable
    onPluginDisabled -> onPluginDisable

    org.bukkit.event.entity.EntityListener
    onExplosionPrimed -> onExplosionPrime

    org.bukkit.event.entity
    ExplosionPrimedEvent -> ExplosionPrimeEvent


    org.bukkit.event.block.BlockListener
    onBlockInteract removed use onPlayerInteract
    onBlockRightClick removed use onPlayerInteract

    There is also now a little perl script in DevBukkit which allows plugin developers to quickly check their code for possible Bukkit API issues.
    https://github.com/Bukkit/DevBukkit
     
    Morczor likes this.
  11. Offline

    matejdro

    How to run that script? Do i have to compile it first?
     
  12. Offline

    daemonfire

    If installied perl should run out-of-the-box via Terminal or CMD
     
  13. Offline

    matejdro

    I have a problem with that Perl script. It will return me this:

    I have never worked with perl, so it's probably some dumb error that i did.
     
  14. Offline

    Celtic Minstrel

    Aww, I had a (private) plugin with + signs in the name. :p
     
  15. Offline

    Steve Member

    All you need to do is install the Config::Simple module there matejdo. The easiest way is usually using cpan e.g
    perl -MCPAN -e shell
    cpan> install Config::Simple

    If you havent used cpan before you'll need to go through the setup stage but thats pretty self explanatory.
     
  16. Offline

    Drakia

    In regards to the newest RB, empty slots are now null instead of AIR(0). This means if your plugin does this:
    Code:
    			ItemStack[] items = sChest.getInventory().getContents();
    			boolean overflow = false;
    			for (int cSlot = 0; cSlot < items.length; cSlot++) {
    				ItemStack item = items[cSlot];
    				if (item.getType() == Material.AIR) continue;
    				int slot = event.getPlayer().getInventory().firstEmpty();
    				if (slot == -1) {
    					overflow = true;
    					break;
    				}
    				event.getPlayer().getInventory().setItem(slot, item);
    				sChest.getInventory().clear(cSlot);
    			}
    You will need to change it to:
    Code:
    			ItemStack[] items = sChest.getInventory().getContents();
    			boolean overflow = false;
    			for (int cSlot = 0; cSlot < items.length; cSlot++) {
    				ItemStack item = items[cSlot];
    				if (item == null) continue;
    				if (item.getType() == Material.AIR) continue;
    				int slot = event.getPlayer().getInventory().firstEmpty();
    				if (slot == -1) {
    					overflow = true;
    					break;
    				}
    				event.getPlayer().getInventory().setItem(slot, item);
    				sChest.getInventory().clear(cSlot);
    			}
    That's just the quickloot code from Tombstone, but you can see that change just inside the for loop where I check if item == null. Any time you use an API call to get an ItemStack just make sure to check if it's null before using it.
     
  17. Offline

    matejdro

    Does the same applies for placed blocks?
     
  18. Offline

    Celtic Minstrel

    I think I was checking if(item == null || item.getType() == Material.AIR) in any relevant locations, so I should be fine. (Well, I wasn't sure whether it returned null or AIR!)
     
  19. Offline

    Drakia

    @matejdro I'd recommend just always checking for null before using stuff now :p
     
  20. Offline

    SycoPrime

    Can someone explain to me why onBlockPlace was moved to after PlayerInteract? When it initially broke part of my plugin, I figured there must be a good reason. On three separate occasions now, I've thought I fixed it, and turned out to break if not it, then something else. I'd like to at least know why I have this headache.
     
  21. Offline

    Acrobot

    @SycoPrime
    OnBlockPlace still works o.0

    Code:
    public void onBlockPlace(BlockPlaceEvent event) 
     
  22. Offline

    Zero9195

    Can someone explai to me the new thing with the "PlayerCommandPreProcessEvent"? I don't find anything about it and want to update my plugin...
    Thanks for helping ;)
    EDIT: Nevermind, just found it ;)
     
  23. Offline

    Tahg

    The portal events that have been added for RB 860 are being reworked. It is recommended that you not use them yet (unless you consider revamping events due to API changes a fun experience)
     
  24. Offline

    Dinnerbone Bukkit Team Member

     
  25. Offline

    vcazan

    spawnMinecart(location) now is broken, it spawns a powered minecart :(
     
  26. Offline

    EvilSeph

     
  27. Offline

    matejdro

    Will teleporting occur when you activate that method or at the end when bukkit itself start processing event?
     
  28. Offline

    xZise

    Actually isn't it better, when you break the setNote() thing only in the 2nd recommended build? So that the NoteBlock using plugins don't have to fix this twice?

    Fabian
     
  29. Offline

    sunkid

    This is now fixed. My apologies!

    In addition to what @Dinnerbone and @EvilSeph have documented above, the signature of org.bukkit.event.entity.EntityDamageByProjectileEvent.getProjectile() has changed to return a Projectile instead of a generic Entity. Although Projectile extends Entity, this change will require a re-compile of your plugins if you are using this method.

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

    EvilSeph

    I mistakenly listed this as a break when it isn't. There is still a setNote that takes a byte, it is just deprecated.
     
Thread Status:
Not open for further replies.

Share This Page