Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by HorrendousEntity, Jul 28, 2018.
Yes, those are all words...
If you knew a little bit of SpigotAPI you would knew that those are 2 classes there.
where or how can I find this mythical
I also need this so as not to use ChatColor on console
Let's review what we know: you want to know if you should choose
ConsoleCommandSender or ColouredConsoleSender. SHOW YOUR CODE
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?
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
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
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.
"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
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.
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
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.
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)
answers in black.
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.