Why version number in package?

Discussion in 'Plugin Development' started by javaguy78, Jun 19, 2013.

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

    javaguy78

    <rage>
    Why is the version number included in the package for net.server.minecraft.* packages?
    </rage>

    I know Mojang did this, not CraftBukkit. It just makes it very VERY difficult to do many things with bukkit and make your plugin compatible with multiple versions of bukkit.

    Case in point: NBT Tags: Why isn't there a wrapper for NBT Tags? To add a tag to an item, I must reference the specific version of Minecraft. Then when I compile, my Plugin only works with that version. So I have to maintain dozens of versions of my plugins for each version of CraftBukkit..

    Sigh...
     
  2. Offline

    DarkBladee12

    javaguy78 You could learn how to use reflection to use that methods without having to update your plugin when a new craftbukkit comes out! ;)
     
  3. Offline

    CubieX

    This was done to "force" developers to have a look at their plugins that use CraftBukkit or NMS code at least on every major update.
    It was meant as kind of a "safeguard" for the server owners. So they (in theory) can assume, that plugins which use methods outside of the official Bukki API are thoroughly verified by the developer to be 100% compatible with a certain CraftBukkit game server version.
    Seach in the news for the original thread. The intention was explained there in detail.
     
  4. Offline

    Wingzzz

  5. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Check out the ItemMeta system. ;)
     
  6. Offline

    javaguy78

    That's fine, but that still makes it difficult for a developer to support both the recommended build and a snapshot build. I guess I'll only have 2 versions of my plugins: 1 that is old and is compatible with the recommended build, and one that is cutting-edge, but only available against the snapshot.

    Makes my users upset though to not have both, and it's a pain in the neck to find/replace all the .v1_5_R1 with v1_5_R2 every time I want to compile...


    I haven't found out a way to use the ItemMeta system to add a glow effect to an item without adding an enchantment. :\

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  7. Offline

    ZeusAllMighty11

    You can easily use reflection to get around it.

    Example:
    Code:java
    1.  
    2.  
    3. package me.zeus.test;
    4.  
    5.  
    6. import java.lang.reflect.Method;
    7.  
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10.  
    11.  
    12. public class Test extends JavaPlugin
    13. {
    14.  
    15.  
    16. @Override
    17. public void onEnable()
    18. {
    19. ClassLoader cl = ClassLoader.getSystemClassLoader();
    20.  
    21. try
    22. {
    23. Class<?> village = cl.loadClass("net.minecraft.server." + getVersion() + ".Village");
    24. for (Method m : village.getMethods())
    25. {
    26. System.out.println(m.getName() + "\n");
    27. }
    28. }
    29. {
    30. e.printStackTrace();
    31. }
    32.  
    33. }
    34.  
    35.  
    36.  
    37. public String getVersion()
    38. {
    39. String ver = getServer().getClass().getPackage().getName();
    40. return ver.substring(ver.lastIndexOf('.') + 1);
    41. }
    42. }
    43.  
     
  8. You can make your own enchantment like I did in backpacks++ or you can use packets or ... Comphenix knows, he is the packet master of bukkit so...
     
    TheGreenGamerHD likes this.
  9. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    That is, as far as we can tell, a bug and not something we would support because of how easily it could disappear.
     
  10. Offline

    Comphenix

    Why, thank you. :p

    This is how I would do it with ProtocolLib:
    Code:java
    1. public class ExamplePlugin extends JavaPlugin {
    2. @Override
    3. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    4. if (!(sender instanceof Player)) {
    5. sender.sendMessage(ChatColor.RED + "Must be a player.");
    6. }
    7. Player player = (Player) sender;
    8.  
    9. ItemStack goldenAxe = MinecraftReflection.getBukkitItemStack(new ItemStack(Material.GOLD_AXE));
    10. NbtCompound compound = (NbtCompound) NbtFactory.fromItemTag(goldenAxe);
    11. compound.put(NbtFactory.ofList("ench"));
    12.  
    13. player.getInventory().addItem(goldenAxe);
    14. return true;
    15. }
    16. }

    And yes, you can do it without depending on ProtocolLib. I leave that as an exercise to the reader.

    EDIT: And yes, as mbaxter mentioned, this effect can easily disappear, usually if some other plugin uses the ItemMeta system on the same stack. That occurs even if the plugin leaves the enchantment list alone.
     
  11. Why? 1: You made protocollib, 2: You mostly help on packet stuff and 3: You are the only one here who seems to exactly know what he's doing with packets...
    Thats why sir.
     
    Wingzzz likes this.
  12. Offline

    javaguy78


    Also, BUKKIT needs to get their naming conventions down. The current Recommended build is version 1.5.2 R1.0, but in the package path, it says v1_5_R3... Now, tell me how that's not going to confuse my users?
     
  13. Offline

    ShadowDog007


    How would that confuse your users? Just tell them which version it supports. They don't need to know and don't care which imports you used...
     
  14. Offline

    javaguy78

    so, you're saying it doesn't matter if internal version numbers don't match external version numbers? What's the point of putting r3 internally if externally the file says R1.0?
     
  15. Offline

    desht

    The "3" there means that this is the third obfuscation revision since Minecraft 1.5 was released. Whenever the MC server's obfuscation changes, the package number is bumped by one. This is actually better for plugin devs than tracking Minecraft's major/minor version directly, since the minor version can increase (and has increased) without an obfuscation change. No point in changing the package version if the obfuscation hasn't changed.

    As ShadowDog007 correctly pointed out, the internal package name used by CraftBukkit is of absolutely no concern to plugin users, who only need to know which version(s) of CraftBukkit (e.g. 1.5.2-R1.0) your plugin works with, and that's something you should be stating on your plugin download page anyway.
     
    ShadowDog007 and Wingzzz like this.
Thread Status:
Not open for further replies.

Share This Page