Can someone tell the code problem.

Discussion in 'Spigot Plugin Help' started by blank826, Jul 5, 2021.

  1. Code (Text):
    //
    // Source code recreated from a .class file by IntelliJ IDEA
    // (powered by Fernflower decompiler)
    //

    package com.vanishedd.blockregen;

    import com.vanishedd.blockregen.file.CustomFile;
    import com.vanishedd.blockregen.file.FileManager;
    import com.vanishedd.blockregen.listeners.PlayerActivity;
    import com.vanishedd.blockregen.util.Lang;
    import java.util.Iterator;
    import java.util.List;
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    public class BlockRegen extends JavaPlugin {
        private static BlockRegen instance;
        public FileManager fileManager = new FileManager();

        public BlockRegen() {
        }

        public void onEnable() {
            instance = this;
            this.registerConfig();
            this.fixWorldNames();
            this.registerListeners();
            this.registerBlocks();
        }

        public void onDisable() {
            instance = null;
        }

        public static BlockRegen getInstance() {
            return instance;
        }

        private void registerConfig() {
            CustomFile langFile = new CustomFile("lang");
            CustomFile dataFile = new CustomFile("data");
            this.saveDefaultConfig();
            langFile.saveDefaultConfig();
            dataFile.saveDefaultConfig();
            Lang.setFile(langFile.getCustomConfig());
            this.fileManager.registerFile(langFile);
            this.fileManager.registerFile(dataFile);
        }

        private void registerListeners() {
            PluginManager pluginManager = Bukkit.getPluginManager();
            pluginManager.registerEvents(new PlayerActivity(), this);
        }

        private void registerBlocks() {
            Iterator var1 = this.fileManager.getFile("data").getCustomConfig().getStringList("Regenerating").iterator();

            label40:
            while(var1.hasNext()) {
                String blockInfo = (String)var1.next();
                String[] split = blockInfo.split(";");
                Location location = new Location(Bukkit.getWorld(split[0]), (double)Integer.parseInt(split[1]), (double)Integer.parseInt(split[2]), (double)Integer.parseInt(split[3]));
                Long startTime = Long.parseLong(split[4]);
                Material material = Material.valueOf(split[5]);
                Byte data = Byte.parseByte(split[6]);
                Block block = location.getBlock();
                Long regenTime = 0L;
                Iterator var10 = this.getConfig().getConfigurationSection("Blocks").getKeys(false).iterator();

                while(true) {
                    String world;
                    do {
                        if (!var10.hasNext()) {
                            Long endTime = startTime + regenTime;
                            Long difference = endTime - System.currentTimeMillis();
                            if (difference <= 0L) {
                                block.setType(material);
                                block.setData(data);
                                return;
                            }

                            Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                                List<String> regenerating = this.fileManager.getFile("data").getCustomConfig().getStringList("Regenerating");
                                if (this.getConfig().getBoolean("Random-Regen")) {
                                    block.setType(Material.valueOf(this.getRandomRegenType(location.getWorld().getName().toLowerCase())));
                                } else {
                                    block.setType(material);
                                    block.setData(data);
                                }

                                regenerating.remove(blockInfo);
                                this.fileManager.getFile("data").getCustomConfig().set("Regenerating", regenerating);
                                this.fileManager.getFile("data").saveCustomConfig();
                            }, difference / 1000L * 20L);
                            continue label40;
                        }

                        world = (String)var10.next();
                    } while(!world.equalsIgnoreCase(location.getWorld().getName()));

                    Iterator var12 = this.getConfig().getConfigurationSection("Blocks." + world).getKeys(false).iterator();

                    while(var12.hasNext()) {
                        String blockType = (String)var12.next();
                        if (blockType.equalsIgnoreCase(material.name())) {
                            regenTime = (long)this.getConfig().getInt("Blocks." + world + "." + blockType, 30) * 1000L;
                        }
                    }
                }
            }

        }

        private String getRandomRegenType(String world) {
            String[] randomBlocks = (String[])this.getConfig().getConfigurationSection("Regen-Blocks." + world).getKeys(false).toArray(new String[this.getConfig().getConfigurationSection("Regen-Blocks." + world).getKeys(false).size()]);
            double totalWeight = 0.0D;
            String[] var5 = randomBlocks;
            int var6 = randomBlocks.length;

            for(int var7 = 0; var7 < var6; ++var7) {
                String blockType = var5[var7];
                totalWeight += this.getConfig().getDouble("Regen-Blocks." + world + "." + blockType);
            }

            double random = Math.random() * totalWeight;
            String[] var12 = randomBlocks;
            int var13 = randomBlocks.length;

            for(int var9 = 0; var9 < var13; ++var9) {
                String blockType = var12[var9];
                random -= this.getConfig().getDouble("Regen-Blocks." + world + "." + blockType);
                if (random <= 0.0D) {
                    return blockType;
                }
            }

            return "COBBLESTONE";
        }

        private void fixWorldNames() {
            Iterator var1 = this.getConfig().getConfigurationSection("Blocks").getKeys(false).iterator();

            while(var1.hasNext()) {
                String key = (String)var1.next();
                if (!key.equals(key.toLowerCase())) {
                    this.getConfig().set(key.toLowerCase(), this.getConfig().getConfigurationSection("Blocks." + key));
                }
            }

            this.saveConfig();
        }
    }
     
    Why the private void registerBlocks() doesnt work in
    public void onEnable() ?
     
  2. What's the error?
     
  3. SteelPhoenix

    Moderator

    Maybe ask the author instead of working on someone else's (decompiled) code?
     
  4. The author not work three years.
    Moderator help me.
     
  5. When i start the server,the private void registerBlocks() doesn't work.
     
  6. define doesnt work? whats it supposed to do? and I highly doubt you can work off decompiled code, since its usually messier compared to actual code
     
  7. The plugin so good.But it has a bug.Then the author doesnt work three years.I want to fix the plugin.
    When the server start ,it should do private void registerBlocks().
    But when i start server ,registerBlocks() doesnt work.
     
  8. That doesnt awnser my question at all? how doesnt it work?
     
  9. When i start server,registerBlocks() doesnt run.
    Because the data.yml data always exist.