Initializing Legacy Material Support causing a problem with material enum?

Discussion in 'Plugin Development' started by Frank kodra, Mar 24, 2020.

  1. Offline

    Frank kodra

    I'm working on a part on my plugin that scans the current chunk your in and returns the numbers of all the blocks in that chunk. it works perfectly except it doesn't differentiate between stone, diorite, granite, and andesite. but the material enum should separate them. I think the problem is when I load the server it says "Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!" so it's loading the legacy version that doesn't differentiate between the blocks but I'm using the exact same spigot jar file from my server. I literally downloaded the jar from my server.

    java class:
    Code:
    package me.frankkodra.OreGen.commands;
    
    import java.util.ArrayList;
    
    import org.bukkit.Chunk;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    
    public class BlockScanner implements CommandExecutor{
      
        public BlockScanner(JavaPlugin plugin) {
            plugin.getCommand("scan").setExecutor(this);
          
        }
    
      
        public boolean onCommand( CommandSender sender,  Command cdm, String label, String[] args) {
            if(sender instanceof Player ) {
                Player p = (Player)sender;
                p.sendMessage("working on it");
                if(args.length==0) {
                    scanCurrentChunk(p);
                }
              
              
              
              
            }
          
          
            sender.sendMessage("finished command");
            return false;
        }
      
      
        public void scanCurrentChunk(Player p) {
            Material m;
            boolean exists = false;
            Chunk chunk = p.getLocation().getChunk();
            ArrayList<Material> blockIds = new ArrayList<Material>();
            ArrayList<Integer> blockNum = new ArrayList<Integer>();      
            for (int y=0;y<255;y++) {
                for (int x=0;x<15;x++){
                    for (int z=0;z<15;z++) {
                        m = chunk.getBlock(x, y, z).getType();
                        for (int i=0;i<blockIds.size();i++) {
                            exists = false;
                            if(blockIds.get(i)==m) {
                                blockNum.set(i,blockNum.get(i)+1);
                                exists = true;
                                break;
                            }
                        }
                        if(!exists) {
                            blockIds.add(m);
                            blockNum.add(1);
                        }
                    }
                }
            }
            for(int i=0;i<blockIds.size();i++) {
                p.sendMessage(blockIds.get(i).toString()+" : "+blockNum.get(i));
            }
        }
    }
    

    yml:
    Code:
    main: me.frankkodra.OreGen.Main
    author: Frank Kodra
    name: oreGen
    version: 1.0
    description: customize ore generation
    api-version: 1.15
    
    commands:
      scan:
     
  2. Offline

    timtower Moderator Moderator

  3. Offline

    Frank kodra

    @timtower no it's not the only one. LMFAO of I just realized that the warning was about another plugin, THAT I MADE LOL. problem fixed lol. it's my second day of developing plugins I'm a big noob.

    (edit) I removed the first plugin that I was using to test stuff and now it works perfectly.
     

Share This Page