HELP!

Discussion in 'Spigot Plugin Development' started by CristianoTRS, Jul 4, 2018.

  1. Whats the problem
     

    Attached Files:

  2. We need the full code to solve your problem.
     
  3. DavidDevelops

    Supporter

    Once again, If you want us to put effort into helping put effort to ask, Whats the problem? Whats the errors? When does the error happen? What have you tried? What even is the problem,
     
    • Agree Agree x 4
  4. You're comparing a material (e.getBlock().getType()) with an item stack(Mq1), that could possibly be the problem.

    Maybe you should google "garbage in, garbage out"
    Or if you don't want to, you can just click here.
    (Referring to your horrible input to us, so we couldn't help much)
     
  5. Code (Text):
    if e.getBlock().getType().equals(MQ1);
    should be
    Code (Text):
    if e.getBlock().equals(MQ1);
     
  6. If a block equals an itemstack? You realise they are not comparable right? You can however do this:
    Code (Java):
    if e.getBlock().getType().equals(MQ1.getType());
     
  7. No.
    Code (Text):
    if (e.getBlock().getType() == decentItemStackVariableName.getType()) {
     
    • Funny Funny x 3
    • Like Like x 1
  8. @AgainstTheNight I don't see why you rate this funny while your own suggestions incudes leaving out the braces of if statements, ending the line with a semicolon, comparing constants with equals() and breaking naming conventions -
    [​IMG]
    That makes four mistakes in a single line.
     
    • Winner Winner x 7
  9. Someone doesn't know what pseudocode is...
     
    • Funny Funny x 2
  10. Arrogance is never a good thing, even if you are the greatest coder out there not everyone is in your intellectual level. There is a big difference between helping another because you want to help and helping another because your just too annoyed because they do not understand the language better as you do. We all have been there to the place where we cannot differentiate a field from an enum. Or cannot understand how to check null pointers.

    Understand that some of the people here did not even get a proper education on coding and just here because it is their hobby Or is anyone going to say this forum is just for the knowledgeable. Being a noob is a stage in learning not a curse you say to every mistake a person does.

    BTW when you said that my approach is messy on adding a new event so as to remove the durability bar but still fire an event when an item is damage event if the item has unbreakable nms tag. I succeeded. (with only 3 lines of code appended on the api and another generic event class) thinking of pushing it in JIRA.

    BTW THIS IS JUST MY OWN OPINION

    To the poster. What they are saying is true but the way they say it is very offending lol. Lighten up. Dont give up.

    Terms that they said that may help:

    GARBAGE IN, GARBAGE OUT this means to your code that when comparing 2 or more objects, objects must be of the same type
    Example you cannot compare an ItemStack interface to a method

    if (e.getBlock().getType().equals(MQ1) {

    do this
    get the the block type of the object "e" then compare it to the object type of Mq1
    if (e.getBlock().getType() == Mq1.getType()) {

    now your are comparing 2 enums

    NAMING CONVENTIONS this means in your code that you should use proper variable naming.
    In PACKAGES name must start at lowercase then the consecutive significant word must start in uppercase
    Example myPackage.samplePackage

    In CLASSES all significant names must start with a uppercase letter
    Example public class MyClass () {}

    In Variable name must start at lowercase then the consecutive significant word must start in uppercase same as packages
    Example instead of using Mq1 you should use mQ1
    ItemStack mq1 = new ItemStack(Material.DIRT, 1);

    The significance of naming your variable reference longer or as they say decent is for making your code easily readable which is good practice in the long run when writing a ton of code also commenting your code block is nice too.

    If you can follow your code then name it wath ever you want
    or you can name it longer

    int myPrimitiveIntegerThatSignifiesTheLevelOfAPlayerThatTheMethodGetLevelOfTheClassLevelManagerThenPassesItToTheMethodInsideTheSameClassThenConcatenatesItToTheVariableStringMyMessageThenOutPutsItInConsoleViaTheClassBukkitMethodGetServerMethodGetLoggerMethodInfo = 1;

    lol I have too much time in my hands
     
    • Agree Agree x 1
  11. Save level:
     
  12. Thats not even a pseudocode..
     
  13. ... I knew it was supposed to be == but I tried keeping it as close as possible to what he had without changing much
     
  14. I'm assuming you're trying to handle some kind of special blocks or something similar. Since blocks don't have custom display names or anything, you'll have to manually store the position data of these custom blocks you're trying to manipulate.
     
  15. Yh it is. Maybe consider googling it.
     
  16. You're (Those trying to help) litterly trying to help someone solve an issue you still don't know. The OP never shared the issue with us nor a stacktrace or even a small piece of error.

    As for the OP, please define what doesn't work as you thought it would. Any stacktrace would also be nice.

    Lastly, if you are going to fight over what pseudo code is better, then you should consider not giving any code and instead give examples/links/javadocs that will guide him into solving the issue.
     
  17. The OP posted a code snippet. And Sataniel has already posted the solution.
     
  18. No need to Google it when i see mistakes in the code.
     
  19. This is stupid enough already. From the code seen, only 1 line is needed actually.
    Code (Java):



    ItemStack item = new ItemStack(Material.COAL_BLOCK);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName("Some name");
    meta.removeFlags();
    item.setItemMeta(meta);

    if (e.getBlock.getType() == item.getType()) {
    e.getPlayer().sendMessage("mined blocks name: " + meta.getDisplayName());
    }
     
    So basically the OP created a new itemstack gave it a name and then checked if the blocked mined is a coal block he then proceeds to send a message that contains the name of that custom item stack.

    Unless the OP has some more code beyond that, this is useless.
    Code (Java):
    if (e.getBlock.getType() == Material.COAL_BLOCK) e.getPlayer().sendMessage("mined block's name: Some name");
     
  20. What? So you don't need to google a definition of pseudocode cause you see mistakes in the pseudocode? You realise that makes no sense right? Pseudocode doesn't follow rules. Its just a rough representation of code that doesn't follow any language inherently.