1.15.2 What is happening?

Discussion in 'Spigot Plugin Development' started by Voidane, Jan 13, 2020.

  1. When im using my plugin Deep Storage Units it works perfectly for 1.15.1 , however my the users using it for 1.15.1 try to add the same block type into the unit and it doesn't add it or something but when I'm testing it does for me?

    Here is the method im using, I loaded the hell out of it with saves purposely. Not sure if this is the solution yet since I don't experience the problem.

    Code (Java):
    @SuppressWarnings("deprecation")
        @EventHandler
        public void exportItems(InventoryClickEvent event) {
         
            if (event.getCurrentItem() == null) {
                return;
            }
         
            if (!event.getView().getTitle().contains("Deep Storage Unit")) {
                return;
            }
         
            Player player = (Player) event.getWhoClicked();
            YamlConfiguration getLastInteractionConfiguration = new FileConfiguration().getInteractionChestConfig();
            YamlConfiguration getChestOwnerConfiguration = new FileConfiguration().getChestOwnerConfig();
         
            String getChest = getLastInteractionConfiguration.getString(player.getUniqueId().toString()+".Recent Chest Interaction");
         
            if (getChestOwnerConfiguration.getBoolean(getChest+".Disallow Usage")) {
                player.closeInventory();
                return;
            }
         
            if (event.getSlot() == 40) {
                 
                 
                    int stored = getChestOwnerConfiguration.getInt(getChest+".Stored");
                        if (event.getClick().toString().equalsIgnoreCase("LEFT")) {
                            if (stored > 63) {
                            for (int i = 0; i < player.getInventory().getSize() ; i++ ) {
                            if (player.getInventory().getItem(i) == null) {
                            player.getInventory().setItem(i, new ItemStack(Material.getMaterial(getChestOwnerConfiguration.getString(getChest+".Material Used")),
                                    64,  (byte) getChestOwnerConfiguration.getInt(getChest+".Material ID")));
                            int subtract = stored-64;
                            getChestOwnerConfiguration.set(getChest+".Stored", subtract);
                            try {
                                getChestOwnerConfiguration.save(new File(plugin.getDataFolder(), "Chest Owners.yml"));
                            } catch (IOException e) {
                                e.printStackTrace();
                        }
                            break;
                        }
                                if (i == player.getInventory().getSize()-1) {
                                        player.closeInventory();
                                        player.sendMessage(plugin.translateChatColor("&c[Deep Storage Unit] &bNo room in inventory"));
                                }
                            }
                        } else {
                            if (stored == 0) {
                                return;
                            }
                            for (int i = 0; i < player.getInventory().getSize() ; i++ ) {
                                if (player.getInventory().getItem(i) == null) {
                                    int restore = 64-stored;
                                player.getInventory().setItem(i, new ItemStack(Material.getMaterial(getChestOwnerConfiguration.getString(getChest+".Material Used")),
                                        64-restore,  (byte) getChestOwnerConfiguration.getInt(getChest+".Material ID")));

                                getChestOwnerConfiguration.set(getChest+".Stored", 0);
                             
                                try {
                                    getChestOwnerConfiguration.save(new File(plugin.getDataFolder(), "Chest Owners.yml"));
                                } catch (IOException e) {
                                    e.printStackTrace();
                            }
                             
                                break;
                            }
                                    if (i == player.getInventory().getSize()-1) {
                                            player.closeInventory();
                                            player.sendMessage(plugin.translateChatColor("&c[Deep Storage Unit] &bNo room in inventory"));
                                }
                            }
                        }
                    } else if (event.getClick().toString().equalsIgnoreCase("SHIFT_LEFT")) {
                        int countAmountOfEmptySpaces = 0;
                        for (int i = 0; i < player.getInventory().getSize() ; i++ ) {
                         
                        if (player.getInventory().getItem(i) == null) {
                            countAmountOfEmptySpaces++;
                         
                            if (player.getInventory().getSize()-1 == i) {
                             
                             
                            }
                        }
                        }
                        if (countAmountOfEmptySpaces == 0) {
                            player.sendMessage(plugin.translateChatColor("&c[Deep Storage Unit] &bNo room in inventory"));
                        }
                        countAmountOfEmptySpaces = countAmountOfEmptySpaces*64;
                 
                                if (countAmountOfEmptySpaces <= getChestOwnerConfiguration.getInt(getChest+".Stored")) {
                                    if (stored == 0) {
                                        return;
                                    }
                                        player.getInventory().addItem(new ItemStack(Material.getMaterial(getChestOwnerConfiguration.getString(getChest+".Material Used")),
                                        countAmountOfEmptySpaces, (byte) getChestOwnerConfiguration.getInt(getChest+".Material ID")));
                     
                                        countAmountOfEmptySpaces=stored-countAmountOfEmptySpaces;
                                        getChestOwnerConfiguration.set(getChest+".Stored", countAmountOfEmptySpaces);
                                     
                                        try {
                                            getChestOwnerConfiguration.save(new File(plugin.getDataFolder(), "Chest Owners.yml"));
                                        } catch (IOException e) {
                                            e.printStackTrace();
                                    }
                                     
                    } else {
                     
                        if (stored < 64) {
                            if (stored == 0) {
                                return;
                            }
                            int lowerThan64=64-stored;
                         
                            player.getInventory().addItem(new ItemStack(Material.getMaterial(getChestOwnerConfiguration.getString(getChest+".Material Used")),
                            64-lowerThan64, (byte) getChestOwnerConfiguration.getInt(getChest+".Material ID")));
                         
                            getChestOwnerConfiguration.set(getChest+".Stored", 0);
                         
                            try {
                                getChestOwnerConfiguration.save(new File(plugin.getDataFolder(), "Chest Owners.yml"));
                            } catch (IOException e) {
                                e.printStackTrace();
                        }
                         
                        } else {
                            if (stored == 0) {
                                return;
                            }
                            player.getInventory().addItem(new ItemStack(Material.getMaterial(getChestOwnerConfiguration.getString(getChest+".Material Used")),
                                getChestOwnerConfiguration.getInt(getChest+".Stored"), (byte) getChestOwnerConfiguration.getInt(getChest+".Material ID")));
                         
                            getChestOwnerConfiguration.set(getChest+".Stored", 0);
                         
                            try {
                                getChestOwnerConfiguration.save(new File(plugin.getDataFolder(), "Chest Owners.yml"));
                            } catch (IOException e) {
                                e.printStackTrace();
                        }
                            }
                         
                        }
                    }
                    try {
                        getChestOwnerConfiguration.save(new File(plugin.getDataFolder(), "Chest Owners.yml"));
                    } catch (IOException e) {
                        e.printStackTrace();
                }
        }
    }
    This is my library
    C:\Program Files\Java\jre1.8.0_211\lib\resources.jar
    C:\Program Files\Java\jre1.8.0_211\lib\rt.jar
    C:\Program Files\Java\jre1.8.0_211\lib\jsse.jar
    C:\Program Files\Java\jre1.8.0_211\lib\jce.jar
    C:\Program Files\Java\jre1.8.0_211\lib\charsets.jar
    C:\Program Files\Java\jre1.8.0_211\lib\jfr.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\access-bridge-64.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\cldrdata.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\dnsns.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\jaccess.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\jfxrt.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\localedata.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\nashorn.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\sunec.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\sunjce_provider.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\sunmscapi.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\sunpkcs11.jar
    C:\Program Files\Java\jre1.8.0_211\lib\ext\zipfs.jar

    Referenced.
    Desktop\Minecraft Server\craftbukkit-1.8.jar
    Also use all other spigot api versions, just one at a time. Only during tests.
    No maven.
     
  2. I`m dosn`t understood what you do in code.

    Player click in inventory and something was changing at config?
    And problem is: config doesn`t save? Or what?
     
  3. I get the amount of items that are being exported from the unit. However it does save, and it does work for me a lone on 1.15.1 but the problem is its diffirent for others and I have no needed plugins for this to work. I have the same download same everything and yet I dont get the problem of items not being added to unit.
     
  4. Your problem coud be caused by the space in your file name. You're using Windows but I suppose "others" tried your plugin on a Linux server. I may be wrong, but it doesn't hurt to verify this point.

    Also, quickly read your code: You should keep a single pointer to your File object instead of creating a new one each time: For example, init a field of type File in your class when the plugin starts and reuse it when you read/write.
     
  5. This is old code I do that now, but I would have to change that later.

    I'll try the plugin on my mac soon then, but doubt that's it but I do know it does'nt auto update when kept open and you have to re-open. So I'll have to see.