Solved ConsoleCommandSender or ColouredConsoleSender? WTF

Discussion in 'Spigot Plugin Development' started by HorrendousEntity, Jul 28, 2018.

Thread Status:
Not open for further replies.
  1. title.
     
    • Optimistic Optimistic x 1
  2. Uhh...
    Yes, those are all words...

    [​IMG]
     
    • Funny Funny x 1
  3. If you knew a little bit of SpigotAPI you would knew that those are 2 classes there.
     
    • Funny Funny x 1
    • Friendly Friendly x 1
    • Optimistic Optimistic x 1
  4. where or how can I find this mythical
    ColouredConsoleSender

    I also need this so as not to use ChatColor on console
     
    • Like Like x 1
  5. bump
     
    • Optimistic Optimistic x 1
  6. Let's review what we know: you want to know if you should choose
    ConsoleCommandSender or ColouredConsoleSender. SHOW YOUR CODE
     
  7. nope I won't show my code cuz it's not relevant, these are 2 bukkitapi objects and all I wanted to know is the difference between them. I wanna know all about them that's why I had made a comparison.
    for most straightforward exmaple - when they are being used(sender instanceof wut of them?) etc.

    I wanna know all about them that's why I had made a comparison?
     
    #7 HorrendousEntity, Jul 29, 2018
    Last edited by a moderator: Jul 29, 2018
  8. electronicboy

    IRC Staff

    ColoredConsoleSender is an implementation detail, not API detail

    ColoredConsoleSender is not available in some implementations of the API (and you'd be unwise to rely on implementation detail when there is an API version which is compatible). getConsoleSender will return a ColoredConsoleSender on spigot, which is an implementation of
    ConsoleCommandSender
     
  9. Thanks in advance for your descriptive comment, kill me but I don't really understand what you mean by "implementation detail",
    the weird thing that happens to me is that sometimes in method onCommand(.....) the check if the sender is console(instanceof ConsoleCommandSender) might return false even though it was indeed sent from the console; when I output(using reflection) the class name -
    it says "ColouredConsoleSender"..

    I don't understand what is this object, It's obfuscated so I dunno if it extends ConsoleCommandSender.. dang
     
  10. Firstly, your post is very poorly worded. If you wanted to clarify the difference between the two, you should have said so. In general, if you're asking for some sort of help or input, it wouldn't hurt to be a little courteous.

    Implementation detail I imagine means that the class isn't part of the API, but rather it's a class that's in the server implementation. So you could presumably access it if you used the server implementation classes, just a guess.

    I think electronicboy more or less answered the poorly implied thread question. As to why instanceof ConsoleCommandSender wouldn't work, that's probably something worth debating.
     
    • Like Like x 1
    • Agree Agree x 1
  11. electronicboy

    IRC Staff

    "implementation detail" means that this class is not inside of the API nor should it be used inside of your plugins, ColoredConsoleSender is a CraftConsoleCommandSender, which is an implementation of ConsoleCommandSender.

    It's impossible that an instanceof on ConsoleCommandSender will fail if it returns oloredConsoleSender and thousands of plugins rely on this behavior daily.

    relying on ColoredConsoleSender will also break on some forks of the server software, as well as being a craftbukkit class, means that you'd also lock your plugin to only working on a specific version of the server software, it's not obfuscated, but is relocated into a version specific package
     
    • Like Like x 1
  12. I still don't understand how can I be capable of "predicting?" ColouredConsoleSender's appearance.
    Ever before I've encountered this issue I checking if sender instanceof ConsoleCommandSender.
     
  13. electronicboy

    IRC Staff

    instanceof ConsoleCommandSender should do the trick, if it's not, that would be a major bug in the java vm itself
    More than likely your issue isn't that the instanceof is failing to work properly, but there is either an issue in your code around that check, or, if you're getting reports from others, that there is something weird with their server/installed plugins
     
    • Agree Agree x 1
  14. He's saying that you don't need to predict it, and that 'sender isntanceof ConsoleCommandSender' should always be true if it's either ConsoleCommandSender or ColouredConsoleSender (Coloured variant implements ConsoleCommandSender somehow presumably)

    If that is the case and you haven't unearthed a bug, then it's possible that your code is, in fact, relevant. It would help to see how you've gotten your results.
     
  15. we have a lovely fella here peeps
    you can't show the people who try to help you any respect and personally believe you don't deserve it :/ you act the same way on most of your threads
    though I don't see why you'd check that a sender instanceof ConsoleCommandSender when you can check !(sender instanceof Player)
     
    • Agree Agree x 2
  16. answers in black.
     
    • Optimistic Optimistic x 1
  17.  
  18. Ladies take a chill pill. If you don't think OP is any worth helping, then take a cup of tea and move on. There's no need to mess up a thread that may potentially help future scavengers here. The thread is more than likely to have been resolved, so move on please.
     
    • Agree Agree x 1
Thread Status:
Not open for further replies.