Question Bukkit Deprecation

Discussion in 'Bukkit Help' started by BlackLight2633, Jun 3, 2015.

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

    BlackLight2633

    I have been coding with Bukkit for a couple months, and I have encountered deprecation errors multiple times. A lot of the action methods are deprecated, making some stuff really hard. I wouldn't mind the warnings, but sometimes it doesn't work at all. Some of the ones that I have found so far are:
    Inside Action Method
    Bukket.getPlayer(name);

    Inside Event Listener
    e.getMessage(); - For PlayerChatEvent
    e.setCancelled(); - For PlayerChatEvent

    I was wondering is there are other ways of doing these actions that I just don't know about, or if they don't want you to be able to ban people, or get the message that somebody said in chat. Any help would be appreciated.
     
  2. Offline

    bakersoft

    Maybe post some code blocks rather than just the individual methods being invoked. Could help provide some more context.
     
  3. Offline

    Boomer

    you can just ignore most of it - a lot of the time deprication was used to call attention to key changes and differences and were going to be de-depricated after some time, other times was a deprication because they were going to drop that feature in an upcoming version -- but since bukkit is end-of-life, 'upcoming versions' means little.

    In some other cases, playerchatevent becomes playerasynchchatevent instead, and results that look up /get players by name are 'marked' because they are now the slow, intensive lookups compared to the get by uuid lookup.
    But when you have to do something the way you have to do it, just go ahead and do it.
     
  4. Offline

    BlackLight2633

    This is where I got most of the warnings.
    Code:
    @EventHandler
    public void onPlayerChat(PlayerChatEvent e)
    {
        Player p = e.getPlayer();
        String str = e.getMessage();
        e.setCancelled(true);
        Bukkit.getServer().broadcastMessage(p.getDisplayName + ": "  + str);
    }
    I got warning for deprecation in that block for the following:
    PlayerChatEvent
    e.getMessage
    e.setCancelled

    Thanks.

    To get around the Bukkit.getPlayer() problem, I created a method that got all of the offline players, then it scanned through them with a for loop, looking for one whose name matched the string you gave it. Once it found one, it returned the player. Whenever I used this it said 'An internal error occurred while attempting to perform this command.'

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
Thread Status:
Not open for further replies.

Share This Page