PrepareCraftEvent isRepair always false

Discussion in 'Plugin Development' started by Skylong_, Mar 28, 2021.

  1. Offline


    I am new in bukkit plugins development so this is probably a dumb question but i don know why this code always set my variable as false. So i hope that somebody here may help me to understand.
        private boolean repairFlag;
        public void isRepair(PrepareItemCraftEvent event) {
            if(event.isRepair()) {
                repairFlag = true;
            }else {
                repairFlag = false;
            Bukkit.broadcastMessage("repairFlag set to "+repairFlag);
  2. Offline


    @Skylong_ PrepareItemCraftEvent#isRepair() is returning false, so it goes to your else statement and sets the field to false.

    Btw, instead of this:
    1. if (event.isRepair()) {
    2. repairFlag = true;
    3. } else {
    4. repairFlag = false;
    5. }

    You can do this:
    1. repairFlag = event.isRepair();
    Skylong_ likes this.
  3. Offline


    Ok but when i made something like this (even after to use your code implements, btw thank you).


    The return still holds as false. What i actually want to is know why.

    But thank you for your help anyway! ;)

Share This Page