Solved Switch table giving null error

Discussion in 'Spigot Plugin Development' started by fer112233, May 12, 2016.

  1. My current code:
    Code (Text):
         
    private static /* synthetic */ int[] $SWITCH_TABLE$org$bukkit$block$BlockFace;


    switch ($SWITCH_TABLE$org$bukkit$block$BlockFace()[blockFace.ordinal()]) {
              case 5: etc......
    The code object of the table:
    Code (Text):
      static /* synthetic */ int[] $SWITCH_TABLE$org$bukkit$block$BlockFace() {
          int[] arrn;
          int[] arrn2 = $SWITCH_TABLE$org$bukkit$block$BlockFace;
          if (arrn2 != null) {
              return arrn2;
          }
          arrn = new int[BlockFace.values().length];
          try {
              arrn[BlockFace.DOWN.ordinal()] = 6;
          }
          catch (NoSuchFieldError v1) {}
          try {
              arrn[BlockFace.EAST.ordinal()] = 2;
          }
          catch (NoSuchFieldError v2) {}
          try {
              arrn[BlockFace.EAST_NORTH_EAST.ordinal()] = 14;
          }
          catch (NoSuchFieldError v3) {}
          try {
              arrn[BlockFace.EAST_SOUTH_EAST.ordinal()] = 15;
          }
          catch (NoSuchFieldError v4) {}
          try {
              arrn[BlockFace.NORTH.ordinal()] = 1;
          }
          catch (NoSuchFieldError v5) {}
          try {
              arrn[BlockFace.NORTH_EAST.ordinal()] = 7;
          }
          catch (NoSuchFieldError v6) {}
          try {
              arrn[BlockFace.NORTH_NORTH_EAST.ordinal()] = 13;
          }
          catch (NoSuchFieldError v7) {}
          try {
              arrn[BlockFace.NORTH_NORTH_WEST.ordinal()] = 12;
          }
          catch (NoSuchFieldError v8) {}
          try {
              arrn[BlockFace.NORTH_WEST.ordinal()] = 8;
          }
          catch (NoSuchFieldError v9) {}
          try {
              arrn[BlockFace.SELF.ordinal()] = 19;
          }
          catch (NoSuchFieldError v10) {}
          try {
              arrn[BlockFace.SOUTH.ordinal()] = 3;
          }
          catch (NoSuchFieldError v11) {}
          try {
              arrn[BlockFace.SOUTH_EAST.ordinal()] = 9;
          }
          catch (NoSuchFieldError v12) {}
          try {
              arrn[BlockFace.SOUTH_SOUTH_EAST.ordinal()] = 16;
          }
          catch (NoSuchFieldError v13) {}
          try {
              arrn[BlockFace.SOUTH_SOUTH_WEST.ordinal()] = 17;
          }
          catch (NoSuchFieldError v14) {}
          try {
              arrn[BlockFace.SOUTH_WEST.ordinal()] = 10;
          }
          catch (NoSuchFieldError v15) {}
          try {
              arrn[BlockFace.UP.ordinal()] = 5;
          }
          catch (NoSuchFieldError v16) {}
          try {
              arrn[BlockFace.WEST.ordinal()] = 4;
          }
          catch (NoSuchFieldError v17) {}
          try {
              arrn[BlockFace.WEST_NORTH_WEST.ordinal()] = 11;
          }
          catch (NoSuchFieldError v18) {}
          try {
              arrn[BlockFace.WEST_SOUTH_WEST.ordinal()] = 18;
          }
          catch (NoSuchFieldError v19) {}
          $SWITCH_TABLE$org$bukkit$block$BlockFace = arrn;
          return $SWITCH_TABLE$org$bukkit$block$BlockFace;
      }
    The console gives me the nullPointerException on line 1117, it is this line:
    Code (Text):
    switch ($SWITCH_TABLE$org$bukkit$block$BlockFace()[blockFace.ordinal()]) {
     
  2. LOL don't decompile Plugins to then ask for help because decompilers tend to use strange switch cases for enums.
    Or why do you comment an int[] /*synthetic*/?
    A systhetic int array will never appear in your code because syntheic fields/methods in java are compiler-generated help-fields.
     
  3. MiniDigger

    Supporter

    if you decompile a plugin using a realy crappy decompiler (my bets are on jd) and you can't fix it yourself you can't expect any help here.
    Try using a real decompiler like fernflower or procyon
     
  4. Oh boy, you got caught red-handed, fool.
     
  5. Fernflower FTW :p BTW this is a really simple fix. I would help you, but without knowing your intentions I am not sure I should.
     
    • Agree Agree x 1
  6. Thanks