Repairing old plugin

Discussion in 'Plugin Development' started by Jurre1996, Feb 2, 2014.

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

    Jurre1996

    Hello,

    I'm no Hero in Java, I have a basic understanding and that's all. I'm trying to fix a old plugin, which used a feature from a other plugin. This other plugin has been broken for a very long time, can anyone help me update this part of the code to be working with 1.7?

    This is the part of the code where I'm having troubles, cause I have no clue what I need to replace with the changed made to Bukkit.

    Code:java
    1. @EventHandler
    2. public void onBreak(BlockBreakEvent e){
    3.  
    4. Player p = e.getPlayer();
    5.  
    6. if(p.getInventory().getHelmet() != null){
    7. if(p.getInventory().getHelmet().getType().name().equals("SKULL_ITEM")){
    8. boolean canBreak = PreciousStones.API().canBreak(p, e.getBlock().getLocation());
    9.  
    10. if(!canBreak){
    11. Skull skull = new Skull(p.getInventory().getHelmet());
    12. if(plugin.getServer().getOnlinePlayers().toString().contains(skull.skullOwner)){
    13. //player online
    14. Player t = plugin.getServer().getPlayer(skull.skullOwner);
    15. boolean cantBreak = PreciousStones.API().canBreak(t, e.getBlock().getLocation());
    16. if(cantBreak){
    17. if(!PreciousStones.API().isPStone(e.getBlock().getLocation())){
    18. e.getBlock().breakNaturally();
    19. e.setCancelled(true);
    20. }else{
    21. p.sendMessage(ChatColor.AQUA + "You cant break pstone blocks");
    22. e.setCancelled(true);
    23. }
    24. }
    25.  
    26. }else{
    27. //player offline
    28. OfflinePlayer t = plugin.getServer().getOfflinePlayer(skull.skullOwner);
    29. boolean cantBreak = canBreak(t, e.getBlock().getLocation());
    30. if(cantBreak){
    31. if(!PreciousStones.API().isPStone(e.getBlock().getLocation())){
    32. e.getBlock().breakNaturally();
    33. e.setCancelled(true);
    34. }else{
    35. p.sendMessage(ChatColor.AQUA + "You cant break pstone blocks");
    36. e.setCancelled(true);
    37. }
    38. }
    39. }
    40.  
    41. }
    42. }
    43. }
    44.  
    45. }


    This is the part of the other plugin that is called by Skull, on line 11

    Code:java
    1. public static boolean addHead(Player player, String skullOwner) {
    2. PlayerInventory inv = player.getInventory();
    3. int firstEmpty = inv.firstEmpty();
    4. if (firstEmpty == -1) {
    5. return false;
    6. } else {
    7. inv.setItem(firstEmpty, new Skull(skullOwner).getItemStack());
    8. return true;
    9. }
    10. }




    I hope you can understand me:p

    Regards Jurre
     
  2. Skull seems to be a plugin specific class it's not bukkit related so there's no way we could know what you should replace it with. Look at the old source and try to replicate what it should represent, we can't do anything more.
     
  3. Offline

    Jurre1996

    Yhea that was what I was afraid for, the oldest version I could find on dev.bukkit was still to new.

    Edit: I have managed to get the correct version via The Way Back Machine
     
Thread Status:
Not open for further replies.

Share This Page