How to make sure your plugin won't break in 1.2

Discussion in 'Plugin Development' started by Dinnerbone, Feb 15, 2012.

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

    Dinnerbone Bukkit Team Member

    Do you use the world height anywhere?

    Bukkit has a method "getMaxHeight()" that will guarantee your plugin will work with either the current height, 1.2's height, or the height five years from now. Please use that instead of hardcoding 127! Also, if you use the sea level - don't just hardcode 64 or height/2, use world.getSeaLevel()!

    Do you use net.minecraft.server stuff, or build for CraftBukkit?

    Please don't! This is a *guaranteed* way that your plugin will break, and we can't help you when it does. Please review every use of you using that code and ask yourself if it's still needed - we've added a lot of cool new API lately that should remove the need for anyone to depend on CraftBukkit!

    Do you use any deprecated methods?

    We're planning to remove all deprecated methods (apart from Player.updateInventory()) in R5. Save yourself a lot of time and effort by making sure you're up to date with the latest code!

    Are you building with an old version of Bukkit?

    We may have changed some API around or deprecated some things since you last downloaded Bukkit. Go download the latest version now, compile and make sure it's all fine. If you're using maven, the latest <version> is "1.1-R4".

    Do you access any of Minecraft's save files directly?

    They're all changing in 1.2, so your plugin likely won't work correctly. Please make absolute sure that you still need to use these files, because we've added a lot of API recently which may be exactly what you need!

    Have a look at the latest specifics on what to change!

    It's just a few pages later in this topic!
     
    dadaemon, Juze, RROD and 7 others like this.
  2. Offline

    turt2live Retired Staff

    You mentioned deprecated methods being removed, as far as I am aware player.updateInventory() is still deprecated, is there a different method or a fix planned for this?
     
  3. Offline

    Fyre

    Is there an alternative to player.updateInventory()? It's been deprecated but I don't know of any other way to update a player's inventory.

    EDIT: I started writing this before turt2live posted, so it seems somewhat pointless now. Crazy coincidence...
     
  4. Offline

    Dinnerbone Bukkit Team Member

    That'll probably be an exception.
     
  5. Offline

    Fyre

    On another note, is there any purpose in keeping it deprecated? Seeing as there's no better alternative right now.
     
  6. Offline

    Dinnerbone Bukkit Team Member

    Probably not. But that's a discussion for another time and place! :D
     
  7. Offline

    Fyre

    Fair enough.
     
  8. Offline

    Don Redhorse

    hmm was there a new method for: player.updateInventory?
    are you removing the old event methods?

    DwarfForge uses a Method from net.minecraft.server.BlockFurnace,

    Code:
            BlockFurnace.a(flag, world.getHandle(),
                    loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    which will set the furnace ON or OFF.

    I can't find bukkit method directly, only via an event

    LOL... 2 times ninja edited... still two to go though :)
     
  9. Offline

    Fyre

    You can always take advantage of the fact that the burning furnace has its own id, and then set it back to that id whenever the block updates. Unless of course you're actually talking about being able to smelt in the furnace. I guess you could just ninja-splice lava buckets in when needed.
     
  10. Offline

    Quick_Wango

    What about renamed stuff from net.minecraft?
    I need to access ServerConfigurationManager.players in my HideMe plugin
     
  11. Offline

    Dinnerbone Bukkit Team Member

    Access it for what? As I said, we've added a lot of new API and it's extremely possible you don't need to use CraftBukkit/nms anymore - we really don't want you to use volatile code.
     
  12. Offline

    Quick_Wango

    To remove and re-add players from the list
     
  13. Offline

    Don Redhorse

    well that code starts the furnace and disables it... dwarfforges are furnaces which run ON lava (honestly) and they don't need fuel (you can also let the use fuel but you don't have to).

    So I have a NOT burning furnace which I need to toggle on or off.

    Dinnerbone is there already an API for that, is it coming, or should I just keep disecting nms code?
     
  14. Offline

    Fyre

    Well personally I took one look at the new PotionEffects API and decided to keep doing it my way, it's so much easier when I just have a simple setEffect(player, id, duration, amplifier), removeEffect(player, id), and hasEffect(player, id). I feel the same way about the Block Drops API, having to find the entities yourself with only the ItemStacks to go by is a real pain.
     
  15. Offline

    samp20

    How soon do you think you'll be removing the depricated Event handling system after 1.2? That's still quite a new feature tbh.

    The API isn't that much more complicated tbh. The way you would do it with the API is:
    Code:
    player.addPotionEffect(new PotionEffect(type,duration,amplifier));
    Where type is just an enumeration, e.g. PotionEffectType.SPEED

    You can also use PotionEffectType.getByName(String name) if for example you want to get a potion effect type from a command argument

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

    Fyre

    I know how it works, I'm just saying I preferred the relative simplicity of my method.
     
  17. Offline

    samp20

    It just won't be simple when the code behind the bukkit API changes and you have to figure out how to work with the new system. I guess it's up to you though:)
     
  18. Offline

    xZise

  19. Offline

    samp20

    Would be nice if the vanish API could vanish players in the map, but not from the playerlist. I'm sure it'll be an easy feature to add. I'll pop this suggesgion on leaky too so it can be managed from there
     
  20. Offline

    Fyre

    The new Configuration system is much better, it's as simple as
    Code:
    FileConfiguration config = getConfig();
    getDataFolder().mkdir();
    File configFile = new File(getDataFolder() + File.separator + "config.yml");
    try{
        configFile.createNewFile();
    } catch(IOException e) {
        e.printStackTrace();
    }
    config.set("path.blah.blah", blahblah);
    saveConfig();
    And getting info is just config.get("path.blah.blah");. Couldn't be easier.
     
  21. Offline

    samp20

    I think you mean "config.yml" not "plugin.yml"
     
  22. Offline

    Don Redhorse

    well it could... for example dumping a map into the configuration doesn't allow you to retrieve that map with .get as it will be a memory section
     
  23. Offline

    KaBob

    Off the top of my head, I know I had to go into the minecraft code for my powered minecart code (I wanted to be able to refuel powered minecarts when they passed over certain blocks). So an API for that would be nice.
     
  24. Offline

    Fyre

    Actually you can use config.getMapList(path).
     
  25. Offline

    Don Redhorse

    I know, but in this case I need to use the config.get first and do a try catch around it because I'm casting it to a Map.

    Or I need to do a check of instance of to figure out if I'm casting to a map and than change the way I read the object.

    My problem is that I don't know the kind of object before.
     
  26. Offline

    rolf_smit

    Bukkit gets the sea level like this:

    this.seaLevel=this.height/2-1;
    in net.minecraft.server World.java

    I know the sea level won't chance depending on the seed so why should we as developers don't just do the same (Because it's not object orientated)? But what about custom world generators? If i build a generator that generates the sea level at 30 blocks high than this isn't going to work. And is the byte array in the chunk generator going to change in size? I think it should be twice as big.

    Rolf
     
  27. Offline

    Dinnerbone Bukkit Team Member

    You will be able to change the sea level, and in 1.2 the default is not worldheight/2.
     
  28. Offline

    rolf_smit

    Oke, thanks!
     
  29. Offline

    Acrobot

    Hey, it's nice to hear that Bukkit is now changing rapidly :)

    I have 2 questions:
    - are the old Configurations going to be removed in 1.2? On Bukkit+ you can see a discussion about wiping configs, so I don't want to switch yet if that's not fixed
    - what about the inventory API? I can see that it's being worked on, but will it be included in 1.2, or will I still need to access NMS?
    EDIT: Or, at least, an API to open a new chest inventory window.

    Also, if I can squeeze some little questions in here:
    - we've got a new event system, but is it possible to register a method in other way that adding an @EventHandler? (For example, if I want to make my code platform-portable, so it will be easy to port to Spout)
    - when (and if) the dynamic command registering is going to be in Bukkit.
     
  30. Pretty sure EvilSeph said yes on that one, but don't quote me on it.
    @celticminstrel is working on something and I believe that is a feature..I heard it will be included in 1.1 or 1.2
    Spout uses the same system, with some optimization :)

    Can't help you on the last one, but hoped this helped a little!
     
    Acrobot and Fyre like this.
Thread Status:
Not open for further replies.

Share This Page