Attempting to Update FishingPlus (1.7.9b to 1.9.4)

Discussion in 'Plugin Development' started by theMrLG, Oct 10, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    theMrLG

    First off, thanks for taking the time. As the title suggests, I'm attempting to update FishingPlus to 1.9.4. The top comment on there leads me to believe it is possible, but regrettably that user seems to no longer be active as of July of this year. This was my first real delving into the world of coding minecraft plugins, and my knowledge of Java was more than a bit rusty. In spite of that, I was able to reduce the errors in the extracted files (FishingPlus, FPListener, and FPCommands) to zero, or at least get rid of all the red and serious errors. Now, however, I'm a bit stuck. The config file regrettably shows a number of WARN's which leads me to believe the lists aren't populating.

    Config:
    Config File (open)
    Code:
    # FishingPlus Configuration: see http://dev.bukkit.org/bukkit-plugins/fishingplus/pages/configuration/ for more details.
    ClownfishBait: false
    FishingMessages: false
    CatchMissMessage: "Darn, that one got away."
    TotalCatchOdds:
        Fish: 85
        Treasure: 5
        Junk: 10
        Mobs: 0
    Fish:
      RAW_FISH:
        - 60
        - ""
      RAW_FISH/1:
        - 25
        - ""
      RAW_FISH/2:
        - 2
        - ""
      RAW_FISH/3:
        - 13
        - ""
    Treasure:
      BOW:
        - 1
        - "&6You found an old bow. Some poor adventurer must have lost it."
        - ""
        - ""
      ENCHANTED_BOOK:
        - 1
        - "&6There's a soaked book on your hook."
        - ""
        - ""
      FISHING_ROD/15:
        - 1
        - "&6You found a discarded fishing rod. Luckily, it's still in good shape!"
        - ""
        - ""
      NAME_TAG:
        - 1
        - "&6You caught a name tag.  It appears to be unused!"
        - ""
        - ""
      SADDLE:
        - 1
        - "&6You discovered a waterlogged saddle. Awesome!"
        - ""
        - ""
      WATER_LILY:
        - 1
        - "&6You pulled a lily pad from the water."
        - ""
        - ""
      CHEST:
        - 0
        - "&6You drag up an old chest up from the depths. What could be inside?"
        - ""
        - ""
    Junk:
      BOWL:
        - 10
        - "&bYou found a wooden bowl. Nothing was inside though..."
        - ""
        - ""
      FISHING_ROD/22:
        - 2
        - "&bA worn fishing rod was tangled up with your own."
        - ""
        - ""
      LEATHER:
        - 10
        - "&bYou caught a piece of soggy leather."
        - ""
        - ""
      LEATHER_BOOTS/23:
        - 10
        - "&bYou reel in some old boots."
        - ""
        - ""
      ROTTEN_FLESH:
        - 10
        - "&bYou caught a chunk of soggy flesh."
        - ""
        - ""
      STICK:
        - 5
        - "&bA twig is caught on your hook."
        - ""
        - ""
      STRING:
        - 5
        - "&bSome string got caught in your fishing line."
        - ""
        - ""
      POTION:
        - 10
        - "&bYou caught a glass bottle."
        - ""
        - ""
      BONE:
        - 10
        - "&bYou caught an old, slimy bone. Eww..."
        - ""
        - ""
      INK_SACK:
        - 1
        - "&bA sack of ink from some poor squid was stuck to your hook."
        - ""
        - ""
      TRIPWIRE_HOOK:
        - 10
        - "&bThere's a tripwire hook on your hook."
        - ""
        - ""
    Mobs:
      PIG:
        - 65
        - "&aUm, you saved a pig from drowning..."
        - ""
      SQUID:
        - 20
        - "&aYou snagged a squid."
        - ""
      SKELETON:
        - 5
        - "&cHoly crap! A skeleton!!!"
        - ""
      SILVERFISH:
        - 10
        - "&cARG! A silverfish!"
        - ""
    TreasureChest:
      RECORD_3: 1
        - ""
        - ""
      SADDLE: 5
        - ""
        - ""
      RECORD_4:
        - 1
        - ""
        - ""
      EMERALD: 5
      RECORD_5: 1
      DOUBLE_PLANT/4: 10
      NAME_TAG: 5
      RECORD_6: 1
      SULPHUR: 15
      RECORD_7: 1
      ENDER_PEARL: 5
      RECORD_8: 2
      IRON_INGOT: 10
      RECORD_9: 1
      CAKE: 8
      RECORD_10: 1
      BREAD: 15
      RECORD_11: 1
      REDSTONE_WIRE: 12
      RECORD_12: 1
      STRING: 15
      GOLD_INGOT: 8
      SKULL_ITEM: 1
    FishingEnchants:
      UNENCHANTED: 0
      LUCK: 1
      LURE: 1
      DURABILITY: 1
    BowEnchants:
      UNENCHANTED: 0
      ARROW_DAMAGE: 1
      ARROW_FIRE: 1
      ARROW_INFINITE: 1
      ARROW_KNOCKBACK: 1
      DURABILITY: 1
    BookEnchants:
      ARROW_DAMAGE: 1
      ARROW_FIRE: 1
      ARROW_INFINITE: 1
      ARROW_KNOCKBACK: 1
      DAMAGE_ALL: 1
      DAMAGE_ARTHROPODS: 1
      DAMAGE_UNDEAD: 1
      DIG_SPEED: 1
      DURABILITY: 1
      FIRE_ASPECT: 1
      KNOCKBACK: 1
      LOOT_BONUS_BLOCKS: 1
      LOOT_BONUS_MOBS: 1
      OXYGEN: 1
      PROTECTION_ENVIRONMENTAL: 1
      PROTECTION_EXPLOSIONS: 1
      PROTECTION_FALL: 1
      PROTECTION_FIRE: 1
      PROTECTION_PROJECTILE: 1
      SILK_TOUCH: 1
      THORNS: 1
      WATER_WORKER: 1
    CustomPlayerHeads: false
    PlayerHeads:
        - Aeyther


    Main File:
    Main Class (open)
    Code:
        /*     */   public void onEnable()
        /*     */   {
        /*  40 */     saveDefaultConfig();
        /*  41 */     getServer().getPluginManager().registerEvents(new FPListener(this), this);
        /*  42 */     getCommand("fp").setExecutor(new FPCommands(this));
        /*  43 */     if (getConfig().getBoolean("ClownfishBait")) {
        /*  44 */       getServer().addRecipe(baitedRod());
        /*     */     }
        /*  46 */     loadValues();
        /*     */   }
        /*     */
        /*     */   public void onDisable()
        /*     */   {
        /*  51 */     totalCatchOdds.clear();
        /*  52 */     fishCatches.clear();
        /*  53 */     treasureCatches.clear();
        /*  54 */     junkCatches.clear();
        /*  55 */     treasureChestItems.clear();
        /*  56 */     fishingEnchants.clear();
        /*  57 */     bowEnchants.clear();
        /*  58 */     bookEnchants.clear();
        /*     */   }
        /*     */
        /*     */   void reload() {
        /*  62 */     reloadConfig();
        /*  63 */     onDisable();
        /*  64 */     loadValues();
        /*     */   }
        /*     */
        /*     */   String getCatchType(int chance) {
        /*  68 */     return (String)totalCatchOdds.get(chance);
        /*     */   }
        /*     */
        /*     */   String getFishingMessage(String caught) {
        /*  72 */     return (String)fishingMessages.get(caught);
        /*     */   }
        /*     */
        /*     */   private ShapelessRecipe baitedRod() {
        /*  76 */     ItemStack baitedRod = new ItemStack(Material.FISHING_ROD);
        /*  77 */     baitedRod.addEnchantment(Enchantment.LURE, 1);
        /*  78 */     ShapelessRecipe baitedRodRecipe = new ShapelessRecipe(baitedRod);
        /*  79 */     baitedRodRecipe.addIngredient(Material.FISHING_ROD);
        /*  80 */     baitedRodRecipe.addIngredient(2, Material.RAW_FISH);
        /*  81 */     return baitedRodRecipe;
        /*     */   }
        /*     */
        /*     */   private void checkConfig() {
        /*  85 */     if (fishCatches.isEmpty()) {
        /*  86 */       getLogger().log(Level.WARNING, "Error, invalid configuration values in section Fish");
        /*  87 */       configError("Fish");
        /*     */     }
        /*  89 */     if ((treasureCatches.isEmpty()) || (treasureChestItems.isEmpty())) {
        /*  90 */       getLogger().log(Level.WARNING, "Error, invalid configuration values in section Treasure or Treasure Chest");
        /*  91 */       configError("Treasure");
        /*     */     }
        /*  93 */     if (junkCatches.isEmpty()) {
        /*  94 */       getLogger().log(Level.WARNING, "Error, invalid configuration values in section Junk");
        /*  95 */       configError("Junk");
        /*     */     }
        /*  97 */     if (mobCatches.isEmpty()) {
        /*  98 */       getLogger().log(Level.WARNING, "Error, invalid configuration values in section Mobs");
        /*  99 */       configError("Mobs");
        /*     */     }
        /* 101 */     if ((fishingEnchants.isEmpty()) || (bowEnchants.isEmpty()) || (bookEnchants.isEmpty())) {
        /* 102 */       getLogger().log(Level.WARNING, "Error, invalid configuration values in section Enchants");
        /* 103 */       configError("Treasure");
        /*     */     }
        /*     */   }
        /*     */
        /*     */   private void configError(String string) {
        /* 108 */     getConfig().getConfigurationSection("TotalCatchOdds").set(string, Integer.valueOf(0));
        /* 109 */     saveConfig();
        /*     */   }
        /*     */
        /*     */   private void loadValues()
        /*     */   {
        /* 114 */     loadCatchList(fishCatches, "Fish");
        /*     */  
        /*     */
        /* 117 */     loadCatchList(treasureCatches, "Treasure");
        /*     */  
        /*     */
        /* 120 */     loadCatchList(junkCatches, "Junk");
        /*     */  
        /*     */
        /* 123 */     loadCatchList(treasureChestItems, "TreasureChest");
        /*     */  
        /*     */
        /* 126 */     loadMobList(mobCatches, "Mobs");
        /*     */  
        /*     */
        /* 129 */     loadEnchantList(fishingEnchants, "FishingEnchants");
        /*     */  
        /*     */
        /* 132 */     loadEnchantList(bowEnchants, "BowEnchants");
        /*     */  
        /*     */
        /* 135 */     loadEnchantList(bookEnchants, "BookEnchants");
        /*     */  
        /*     */
        /* 138 */     checkConfig();
        /*     */  
        /*     */
        /* 141 */     for (String value : getConfig().getConfigurationSection("TotalCatchOdds").getKeys(false)) {
        /* 142 */       int chance = getConfig().getInt("TotalCatchOdds." + value);
        /* 143 */       getLogger().log(Level.WARNING, "{0}{1}", new Object[] { String.valueOf(chance), value });
        /* 144 */       if (chance > 0) {
        /* 145 */         for (int i = 0; i < chance; i++) {
        /* 146 */           totalCatchOdds.add(value);
        /*     */         }
        /*     */       }
        /*     */     }
        /*     */   }
        /*     */
        /*     */   private void loadCatchList(List list, String config) {
        /* 153 */     String configSection = config.concat(".");
        /*     */  
        /* 155 */     for (String value : getConfig().getConfigurationSection(config).getKeys(false)) {
        /* 156 */       getLogger().log(Level.WARNING, value);
        /* 157 */       List<String> values = getConfig().getStringList(configSection + value);
        /*     */    
        /* 159 */       String itemString = value;
        /* 160 */       if (value.contains("/")) {
        /* 161 */         String[] splitTemp = value.split("/");
        /* 162 */         value = splitTemp[0]; }
        /*     */       int chance;
        /* 164 */       if (values.isEmpty()) {
        /* 165 */         chance = getConfig().getInt(configSection + value);
        /*     */       } else {
        /* 167 */         chance = Integer.parseInt((String)values.get(0));
        /* 168 */         fishingMessages.put(itemString, values.get(1));
        /*     */       }
        /* 170 */       if (chance > 0) {
        /* 171 */         if (chance > 100) {
        /* 172 */           getLogger().log(Level.WARNING, "Found config value greater than 100, decreasing it to 100...");
        /* 173 */           chance = 100;
        /* 174 */           getConfig().getConfigurationSection(configSection).set(value, Integer.valueOf(chance));
        /* 175 */           saveConfig();
        /*     */         }
        /*     */         try {
        /* 178 */           Material.getMaterial(value);
        /*     */         } catch (NullPointerException e) {
        /* 180 */           getLogger().log(Level.WARNING, "Invalid item name in section {0}", config); }
        /* 181 */         continue;
        /*     */      
        /* 183 */         //for (int i = 0; i < chance; i++) {
        /* 184 */      //     list.add(itemString);
        /*     */      //   }
        /*     */       }
        /*     */     }
        /*     */   }
        /*     */
        /*     */   private void loadEnchantList(List list, String config) {
        /* 191 */     String configSection = config.concat(".");
        /*     */  
        /* 193 */     for (String value : getConfig().getConfigurationSection(config).getKeys(false)) {
        /* 194 */       if (value != null) {
        /* 195 */         int chance = getConfig().getInt(configSection + value);
        /* 196 */         if (chance > 0) {
        /* 197 */           if (chance > 100) {
        /* 198 */             getLogger().log(Level.WARNING, "Found config value greater than 100, decreasing it to 100...");
        /* 199 */             chance = 100;
        /* 200 */             getConfig().getConfigurationSection(configSection).set(value, Integer.valueOf(chance));
        /* 201 */             saveConfig();
        /*     */           }
        /* 203 */           if (value.equalsIgnoreCase("UNENCHANTED")) {
        /* 204 */             value = null;
        /*     */           }
        /*     */           try {
        /* 207 */             Enchantment.getByName(value);
        /*     */           } catch (NullPointerException e) {
        /* 209 */             getLogger().log(Level.WARNING, "Invalid item name in section ", config); }
        /* 210 */           continue;
        /*     */        
        /* 212 */         //  int i = chance; for (;;) { i--; if (i < 0) break;
        /* 213 */        //     list.add(value);
        /*     */        //   }
        /*     */         }
        /*     */       }
        /*     */     }
        /*     */   }
        /*     */
        /*     */   private void loadMobList(List list, String config) {
        /* 221 */     String configSection = config.concat(".");
        /*     */  
        /* 223 */     for (String value : getConfig().getConfigurationSection(config).getKeys(false)) {
        /* 224 */       if (!value.isEmpty()) {
        /* 225 */         List<String> values = getConfig().getStringList(configSection + value);
        /*     */         int chance;
        /* 227 */         if (values.isEmpty()) {
        /* 228 */           chance = getConfig().getInt(configSection + value);
        /*     */         } else {
        /* 230 */           chance = Integer.parseInt((String)values.get(0));
        /* 231 */           fishingMessages.put(value, values.get(1));
        /*     */         }
        /* 233 */         if (chance > 0) {
        /* 234 */           if (chance > 100) {
        /* 235 */             getLogger().log(Level.WARNING, "Found config value greater than 100, decreasing it to 100...");
        /* 236 */             chance = 100;
        /* 237 */             getConfig().getConfigurationSection(configSection).set(value, Integer.valueOf(chance));
        /* 238 */             saveConfig();
        /*     */           }
        /*     */           try {
        /* 241 */             org.bukkit.entity.EntityType.valueOf(value);
        /*     */           } catch (NullPointerException e) {
        /* 243 */             getLogger().log(Level.WARNING, "Invalid mob name in section Mobs"); }
        /* 244 */           continue;
        /*     */        
        /* 246 */           //int i = chance; for (;;) { i--; if (i < 0) break;
        /* 247 */         //    list.add(value);
        /*     */           }
        /*     */         }
        /*     */       }
        /*     */     }
        /*     */   }


    Now for the console logs: [​IMG]

    Here's what happens. As visible in the logs, you get plenty of WARN's from the plugin loading up, including some logs from the main class. As it doesn't prevent the game from loading, when you actually try to fish it will simply fail to reel anything in. You click to do it, and the hook/bobber stays in the water. My guess for this, combining what I know from the errors, is that the Lists are failing to get populated. Thus, when you try to reel in a catch, it gives you nothing. I've tried fiddling with some of the spacing in the config file thinking that might be the problem, but regrettably it has proven ineffective. I also double checked against the original class files to make sure that I didn't change anything that I wasn't supposed to aside from taking out deprecated forms.

    I have also heard some things about Bukkit not updating their fishing-related methods much since 1.7. Maybe that's most of the problem, but I wasn't able to find anything definite regarding that. Any points in the right direction would be much appreciated.

    EDIT by Moderator: Fixed image
     
    Last edited by a moderator: Oct 10, 2016
  2. Offline

    Zombie_Striker

    @theMrLG
    Your console image either has been taken down or was not set correctly. Please re-add the log as text to either a reply or to the main post.
    Have you actually checked this? Have you checked the list's size? Have you nullchecked/ instanceof checked all the items in the list?
     
Thread Status:
Not open for further replies.

Share This Page