Solved How to remove the first value from a array.

Discussion in 'Spigot Plugin Development' started by Mr.Midnight, Jun 11, 2016.

  1. Code (Text):
        public void onCommand(PlayerCommandPreprocessEvent event) {
            event.getMessage().split(" ");
    Basically my goal is to get just the arguments of the command.
  2. kottalizer


    One idea is to get the index of the first space and then use substring() to shorten the string by that many characters.
    • Creative Creative x 1
  3. Code (Text):

    List<String> args = new ArrayList<>(Arrays.asList(event.getMessage().split(" ")));
    Of if you want the traditional array:

    Code (Text):

    String[] args = event.getMessage().split(" ");
    args = Arrays.copyOfRange(args,1, args.length);
    • Like Like x 2
    • Informative Informative x 1
  4. Is there a way to keep it in array form?
  5. I just showed you...
  6. Sorry didn't see it :p Thank you so much :3
  7. kottalizer


    Please consider complexity before spoon-feeding.
    • Funny Funny x 1
  8. Its apparent you don't know what spoon feeding is.
    • Agree Agree x 2
    • Like Like x 1
  9. Omnivion


    or list List<String> args = Lists.newArrayList(event.getMessage().split(" ")); -- also, that won't split on ALL whitespace (if for some reason there was multiple somehow. You could do event.getMessage().split("\\s+") to handle that).
    • Like Like x 1
    • Useful Useful x 1
  10. kottalizer


    You gave the opening poster a few lines of code ready to be copy and pasted, without requiring the user of the code to actually understand what it does. That is spoon-feeding. The problem with spoon-feeding is that no reflection has to be made as to whether the solution is suitable or not. In this case, my proposed solution would -- implemented correctly -- be much more efricicient in terms of complexity. I could say it is apparent you don't know what complexity is, but I'm not going to say that, because that would drag me down to your low level of personal attacking.
    • Funny Funny x 1
  11. The code given is a basic concept. Its not like I wrote him an entire plugin.. its one fucking line of basic beginner level code. If that needs explaining then something is very wrong. This is a technical forum, after all. Basic code doesn't require explanation or example use cases. Now, if it was something more complex, yes, I would explain things like I always do. I am very against spoonfeeding, trust me. This is not spoonfeeding...

    And your proposed solution will give him a string. Not an array of args, which is what he asked for. I was going to leave your answer alone until you wanted to pick a fight.

    Nowhere did I attack anyone... You did, though.. Come on man..
    #11 BillyGalbreath, Jun 11, 2016
    Last edited: Jun 11, 2016
    • Like Like x 1
  12. kottalizer


    It is apparent you don't know what complexity is, in terms of code.
  13. I don't I've a flying fuck what it is. You offered your solution. I offered mine with relevant information pertaining more in line to the question. Then you attacked me. What the fuck is wrong with you?
  14. kottalizer


    I advised you not to spoon-feed, or at least to state how terrible your solution would be, complexity-wise, compared to the one I proposed. If you don't believe me I suggest you scroll up and read the previous posts.
  15. Again, I didnt spoonfeed him. I can't even fathom how you see it as spoonfeeding. And I have read your solution many times. It yields a string. How does that answer his question? He asked how to remove the first index in an array... he wants the arguments of the command... not a string... ffs man. I'm done arguing with you. His question has been answered. Thread solved.
  16. kottalizer


    It is obvious that my solution, just like yours, require some sort of splitting of the string. That is however not the essential part of the solution, and I presented only the essence. If you don't give a flying fuck about complexity when programming I suggest you go elsewhere, or at least refrain from helping people. As you said, this is a technical forum.
  17. My bad dude. I underestimated the importance of a few nano seconds it takes to make a single calculation once every once in a blue moon. I didn't realize it was so god damn important to you that you felt he need to attack someone and erroneously call them a spoon feeder. See, that's something I take over personal. Spoon feeding is a huge pet peeve of mine, almost as much as lying. And you want to accuse me of that? I don't fucking think so. I looked over your profile and you seem to berate people quite often, perhaps to try and make yourself feel like a better person? Well, its doing the complete fucking opposite. You look like an ass. All over nothing. A few nanoseconds of saved time every 5minutes? Its not like this code is going to run a few hundred thousand times per second... I've already stated I was going to leave your multiline solution alone, but then you started attacking. So yes, I'm going to attack back until you stop. Ass.
  18. kottalizer


  19. @kottalizer, well its a new day now. I just woke up. I can keep this up all day now. Ass.