Solved Default system encoding may have misread config.yml from plugin jar

Discussion in 'Plugin Development' started by yPedx, May 21, 2017.

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

    yPedx

    The only thing appearing in console is this,
    Code:
    [14:15:14 WARN]: [SB-GUI] Default system encoding may have misread config.yml from plugin jar
    Here's my plugin.yml
    Code:
    main: me.developer.kriss.SB
    version: 5.0.8
    name: SB-GUI
    author: yPedx
    
    commands:
        punish:
            description: Punish a player.
            aliases: [pu]
        suchbans:
            description: Basic command.
            aliases: [sb]
    Main (only class I have) Removed a bit cause it was over 3ok characters.. Removed inventoryClick and most of onCommand.
    Code:
        @SuppressWarnings("deprecation")
        private void page1(Player player) {
            Inventory inv = Bukkit.createInventory(null, 54, ChatColor.RED+"Punishments"+ChatColor.DARK_GRAY+" » Page 1/2");
          
            for(int a = 1; a < 49; a++) {
              
                if(!this.getConfig().contains("GUIs.Page1.Slot"+a)) return;
              
                String name = this.getConfig().getString("GUIs.Page1.Slot"+a+".name");
                List<String> lore = this.getConfig().getStringList("GUIs.Page1.Slot"+a+".lore");
                ItemStack item = new ItemStack(Material.getMaterial(this.getConfig().getString("GUIs.Page1.Slot"+a+".item")));
                ItemMeta itemMeta = item.getItemMeta();
          
            itemMeta.setDisplayName(name);
            itemMeta.setLore(lore);
            item.setItemMeta(itemMeta);
        }
            Player target = Bukkit.getPlayer(targetMap.get(player.getUniqueId()));
            int x = target.getLocation().getBlockX();
            int y = target.getLocation().getBlockY();
            int z = target.getLocation().getBlockZ();
            ItemStack statsItem = new ItemStack (Material.getMaterial(this.getConfig().getString("Configurations.Stats-Item")));
            ItemMeta statsMeta = statsItem.getItemMeta();
          
            if(this.getConfig().getBoolean("Settings.Advanced-Stats") == false){
                ArrayList<String> statsLore = new ArrayList<String>();
                statsLore.add(ChatColor.RED+"Name "+ChatColor.GRAY+"» "+target.getName());
                statsMeta.setLore(statsLore);
            } else {
          
            ArrayList<String> statsLore = new ArrayList<String>();
            statsLore.add(ChatColor.RED+"Name "+ChatColor.GRAY+"» "+target.getName());
            statsLore.add(" ");
            statsLore.add(ChatColor.RED+"UUID "+ChatColor.GRAY+"» "+target.getUniqueId());
            statsLore.add(ChatColor.RED+"IP "+ChatColor.GRAY+"» "+target.getAddress().getAddress().getHostAddress());
            statsLore.add(ChatColor.RED+"World "+ChatColor.GRAY+"» "+target.getWorld().getName());
            statsLore.add(ChatColor.RED+"Location "+ChatColor.GRAY+"» X="+x+" Y="+y+" Z="+z);
            statsLore.add(ChatColor.RED+"Gamemode "+ChatColor.GRAY+"» "+target.getGameMode());
            statsLore.add(ChatColor.RED+"Health "+ChatColor.GRAY+"» ❤"+target.getHealth()+"/20.0");
            statsLore.add(ChatColor.RED+"Food "+ChatColor.GRAY+"» "+target.getFoodLevel()+"/20");
            statsLore.add(ChatColor.RED+"Exp "+ChatColor.GRAY+"» "+target.getTotalExperience());
            statsLore.add(ChatColor.RED+"Hand Item "+ChatColor.GRAY+"» "+ChatColor.GRAY+target.getItemInHand().getType());
            statsMeta.setLore(statsLore);
            }
            statsMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Stats");
            statsItem.setItemMeta(statsMeta);
      
          
            ItemStack pageItem = new ItemStack (Material.getMaterial(this.getConfig().getString("Configurations.Next-Page-Item")));
            ItemMeta pageMeta = pageItem.getItemMeta();
            pageMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Next page");
            pageItem.setItemMeta(pageMeta);
      
            ItemStack optionsPageItem = new ItemStack (Material.getMaterial(this.getConfig().getString("Configurations.Options-Item")));
            ItemMeta optionsPageMeta = optionsPageItem.getItemMeta();
            optionsPageMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Options");
            optionsPageItem.setItemMeta(optionsPageMeta);
      
          
            inv.setItem(48, optionsPageItem);   
            inv.setItem(49, statsItem);
            inv.setItem(53, pageItem);
      
            player.openInventory(inv);
        }
      
    
        @EventHandler
        public void onInventoryClickPage1(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            if(!ChatColor.stripColor(event.getInventory().getName()).equalsIgnoreCase("Punishments » Page 1/2")) return;
            event.setCancelled(true);
          
    if(event.getCurrentItem()==null || event.getCurrentItem().getType()==Material.AIR || !event.getCurrentItem().hasItemMeta() || event.getSlot() == 49) {
                return;
            } else
        if(event.getSlot() == 53 && player.hasPermission("sb.use.page2") || event.getSlot() == 53 && player.hasPermission("sb.use.*")) {
        page2(player);
        return;
    }
        if(event.getSlot() == 53 && !player.hasPermission("sb.use.page2") || event.getSlot() == 53 && !player.hasPermission("sb.use.*")) {
        player.sendMessage(String.format("%s%s[%sSB-GUI%s%s] %sYou are not allowed to use this Item!", ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED, ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.GRAY));
        player.closeInventory();
        return;
    }
        if(event.getSlot() == 48 && player.hasPermission("sb.use.optionspage") || event.getSlot() == 48 && player.hasPermission("sb.use.*")) {
        optionsPage(player);
        return;
    }
        if(event.getSlot() == 48 && !player.hasPermission("sb.use.optionspage") || event.getSlot() == 48 && !player.hasPermission("sb.use.*")) {
        player.sendMessage(String.format("%s%s[%sSB-GUI%s%s] %sYou are not allowed to use this Item!", ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED, ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.GRAY));
        player.closeInventory();
        return;
    }
            List<String> punishmentList = this.getConfig().getStringList("Punishment-Log");
            this.getConfig().set("Punishment-Log", punishmentList);
          
            String permission = this.getConfig().getString("GUIs.Page1.Slot"+(event.getSlot()+1)+".permission");
            if (!player.hasPermission(permission) && !player.hasPermission("sb.use.*")) {
                player.sendMessage(String.format("%s%s[%sSB-GUI%s%s] %sYou are not allowed to use this Item!", ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED, ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.GRAY));
                player.closeInventory();
                return;
           } else {
              if (player.hasPermission(permission) || player.hasPermission("sb.use.*"))
    if(this.getConfig().contains("GUIs.Page1.Slot"+(event.getSlot()+1)+".command")){
              String command = this.getConfig().getString("GUIs.Page1.Slot"+(event.getSlot()+1)+".command").replaceAll("#target", "%target%".replaceAll("%target%", targetMap.get(player.getUniqueId()).toString())).replaceAll("#punisher", "%punisher%".replaceAll("%punisher%", senderMap.get(player.getUniqueId()).toString()).replaceAll("#reason", "%reason%".replaceAll("%reason%", reasonMap.get("reason"))));
              player.performCommand(command);
              punishmentList.add("============== ["+date+"] ==============");
              punishmentList.add("Punisher >> "+player.getName());
              punishmentList.add("Target   >> "+targetMap.get(player.getUniqueId()));
              punishmentList.add("Command >> /"+command);
              punishmentList.add("====================================================");
              punishmentList.add("---");
              saveConfig();
           }}}
    
        @SuppressWarnings("deprecation")
        private void page2(Player player) {
            Inventory inv = Bukkit.createInventory(null, 54, ChatColor.RED+"Punishments"+ChatColor.DARK_GRAY+" » Page 2/2");
          
            for(int a = 1; a < 49; a++) {
              
                if(!this.getConfig().contains("GUIs.Page2.Slot"+a)) continue;
              
                String name = this.getConfig().getString("GUIs.Page2.Slot"+a+".name");
                List<String> lore = this.getConfig().getStringList("GUIs.Page2.Slot"+a+".lore");
                ItemStack item = new ItemStack(Material.getMaterial(this.getConfig().getString("GUIs.Page2.Slot"+a+".item")));
                ItemMeta itemMeta = item.getItemMeta();
          
            itemMeta.setDisplayName(name);
            itemMeta.setLore(lore);
            item.setItemMeta(itemMeta);
        }
            Player target = Bukkit.getPlayer(targetMap.get(player.getUniqueId()));
            int x = target.getLocation().getBlockX();
            int y = target.getLocation().getBlockY();
            int z = target.getLocation().getBlockZ();
            ItemStack statsItem = new ItemStack (Material.getMaterial(this.getConfig().getString("Configurations.Stats-Item")));
            ItemMeta statsMeta = statsItem.getItemMeta();
          
            if(this.getConfig().getBoolean("Settings.Advanced-Stats") == false){
                ArrayList<String> statsLore = new ArrayList<String>();
                statsLore.add(ChatColor.RED+"Name "+ChatColor.GRAY+"» "+target.getName());
                statsMeta.setLore(statsLore);
            } else {
          
            ArrayList<String> statsLore = new ArrayList<String>();
            statsLore.add(ChatColor.RED+"Name "+ChatColor.GRAY+"» "+target.getName());
            statsLore.add(" ");
            statsLore.add(ChatColor.RED+"UUID "+ChatColor.GRAY+"» "+target.getUniqueId());
            statsLore.add(ChatColor.RED+"IP "+ChatColor.GRAY+"» "+target.getAddress().getAddress().getHostAddress());
            statsLore.add(ChatColor.RED+"World "+ChatColor.GRAY+"» "+target.getWorld().getName());
            statsLore.add(ChatColor.RED+"Location "+ChatColor.GRAY+"» X="+x+" Y="+y+" Z="+z);
            statsLore.add(ChatColor.RED+"Gamemode "+ChatColor.GRAY+"» "+target.getGameMode());
            statsLore.add(ChatColor.RED+"Health "+ChatColor.GRAY+"» ❤"+target.getHealth()+"/20.0");
            statsLore.add(ChatColor.RED+"Food "+ChatColor.GRAY+"» "+target.getFoodLevel()+"/20");
            statsLore.add(ChatColor.RED+"Exp "+ChatColor.GRAY+"» "+target.getTotalExperience());
            statsLore.add(ChatColor.RED+"Hand Item "+ChatColor.GRAY+"» "+ChatColor.GRAY+target.getItemInHand().getType());
            statsMeta.setLore(statsLore);
            }
            statsMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Stats");
            statsItem.setItemMeta(statsMeta);
      
          
            ItemStack pageItem = new ItemStack (Material.getMaterial(this.getConfig().getString("Configurations.Next-Page-Item")));
            ItemMeta pageMeta = pageItem.getItemMeta();
            pageMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Previous page");
            pageItem.setItemMeta(pageMeta);
      
            ItemStack optionsPageItem = new ItemStack (Material.getMaterial(this.getConfig().getString("Configurations.Options-Item")));
            ItemMeta optionsPageMeta = optionsPageItem.getItemMeta();
            optionsPageMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Options");
            optionsPageItem.setItemMeta(optionsPageMeta);
      
          
            inv.setItem(48, optionsPageItem);   
            inv.setItem(49, statsItem);
            inv.setItem(45, pageItem);
      
            player.openInventory(inv);
        }
      
      
      
        @SuppressWarnings("deprecation")
        private void optionsPage(Player player) {
            Inventory inv = Bukkit.createInventory(null, 54, ChatColor.RED+"Options"+ChatColor.DARK_GRAY+" » Page 1/1");
          
            for(int a = 1; a < 49; a++) {
              
                if(!this.getConfig().contains("GUIs.OptionsPage.Slot"+a)) continue;
              
                String name = this.getConfig().getString("GUIs.OptionsPage.Slot"+a+".name");
                List<String> lore = this.getConfig().getStringList("GUIs.OptionsPage.Slot"+a+".lore");
                ItemStack item = new ItemStack(Material.getMaterial(this.getConfig().getString("GUIs.OptionsPage.Slot"+a+".item")));
                ItemMeta itemMeta = item.getItemMeta();
          
            itemMeta.setDisplayName(name);
            itemMeta.setLore(lore);
            item.setItemMeta(itemMeta);
        }
            Player target = Bukkit.getPlayer(targetMap.get(player.getUniqueId()));
            int x = target.getLocation().getBlockX();
            int y = target.getLocation().getBlockY();
            int z = target.getLocation().getBlockZ();
            ItemStack statsItem = new ItemStack (Material.getMaterial(this.getConfig().getString("Configurations.Stats-Item")));
            ItemMeta statsMeta = statsItem.getItemMeta();
          
            if(this.getConfig().getBoolean("Settings.Advanced-Stats") == false){
                ArrayList<String> statsLore = new ArrayList<String>();
                statsLore.add(ChatColor.RED+"Name "+ChatColor.GRAY+"» "+target.getName());
                statsMeta.setLore(statsLore);
            } else {
          
            ArrayList<String> statsLore = new ArrayList<String>();
            statsLore.add(ChatColor.RED+"Name "+ChatColor.GRAY+"» "+target.getName());
            statsLore.add(" ");
            statsLore.add(ChatColor.RED+"UUID "+ChatColor.GRAY+"» "+target.getUniqueId());
            statsLore.add(ChatColor.RED+"IP "+ChatColor.GRAY+"» "+target.getAddress().getAddress().getHostAddress());
            statsLore.add(ChatColor.RED+"World "+ChatColor.GRAY+"» "+target.getWorld().getName());
            statsLore.add(ChatColor.RED+"Location "+ChatColor.GRAY+"» X="+x+" Y="+y+" Z="+z);
            statsLore.add(ChatColor.RED+"Gamemode "+ChatColor.GRAY+"» "+target.getGameMode());
            statsLore.add(ChatColor.RED+"Health "+ChatColor.GRAY+"» ❤"+target.getHealth()+"/20.0");
            statsLore.add(ChatColor.RED+"Food "+ChatColor.GRAY+"» "+target.getFoodLevel()+"/20");
            statsLore.add(ChatColor.RED+"Exp "+ChatColor.GRAY+"» "+target.getTotalExperience());
            statsLore.add(ChatColor.RED+"Hand Item "+ChatColor.GRAY+"» "+ChatColor.GRAY+target.getItemInHand().getType());
            statsMeta.setLore(statsLore);
            }
            statsMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Stats");
            statsItem.setItemMeta(statsMeta);
      
          
            ItemStack pageItem = new ItemStack (Material.getMaterial(this.getConfig().getString("Configurations.Next-Page-Item")));
            ItemMeta pageMeta = pageItem.getItemMeta();
            pageMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Go back");
            pageItem.setItemMeta(pageMeta);
      
            
            inv.setItem(49, statsItem);
            inv.setItem(45, pageItem);
      
            player.openInventory(inv);
        }
    
        @SuppressWarnings("deprecation")
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
          
            if (!(sender instanceof Player)) {
                sender.sendMessage(String.format("%s%s[%sSB-GUI%s%s] %sYou have to be a player to do this command.", ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED, ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED));
            }
          
            if (sender instanceof Player) {
                    Player player = (Player) sender;
                  
                    if(cmd.getName().equalsIgnoreCase("punish")) {
                        if (!sender.hasPermission("sb.punish")){
                            sender.sendMessage(String.format("%s%s[%sSB-GUI%s%s] %sYou do not have permission to use this command.", ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED, ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED));
                        }
                        if (sender.hasPermission("sb.punish")) {
                        if (args.length == 0) {
                            sender.sendMessage(String.format("%s%s[%sSB-GUI%s%s] %sUsage: %s/punish <player> <reason>", ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED, ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED, ChatColor.WHITE));
                        }
                        if (args.length >= 1) {
                        Player target = Bukkit.getPlayer(args[0]);
                        if (args.length == 1 && target != null) {
                            sender.sendMessage(String.format("%s%s[%sSB-GUI%s%s] %sPlease specify a reason.", ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED, ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED));
                        }
                        if(target == null && args.length == 1 || target == null && args.length >= 2){
                            sender.sendMessage(String.format("%s%s[%sSB-GUI%s%s] %sThat player is not online.", ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED, ChatColor.DARK_GRAY, ChatColor.BOLD, ChatColor.RED));
                        }
                        if(target != null && args.length >= 2) {
                        targetMap.put(player.getUniqueId(), args[0]);
                        senderMap.put(player.getUniqueId(), sender.getName());
                        StringBuilder str = new StringBuilder();
                        for(int i=1; i<args.length; i++) {
                            str.append(args[i]).append(" ");
                        }
                        String reason = str.toString();
                        reasonMap.put("reason", reason);
                        page1(player);
                    }}}}
    Config.yml
    Code:
    Settings:
        Advanced-Stats: true
      
    Configurations:
        Stats-Item: SIGN
        Next-Page-Item: BOOK
        Options-Item: NETHER_STAR
    
    
    # NOTE: You may NOT make new GUIs! Only modify items inside them.
    GUIs:
        Page1:
            Slot11:
                name: '&8&l[&cHacked Client&8&l]'
                command: "ban #target Hacked Client"
                item: DIAMOND_SWORD
                permssion: sb.use.hackedclient
                lore:
                - '§eOffences:'
                - '§7Killaura'
                - '§7Flight'
                - '§7Jesus'
                - '§7Illegal modifications'
            Slot17:
                name: '&8&l[&cChat Offence&8&l]'
                command: "kick #target Chat Offence"
                item: PAPER
                permssion: sb.use.chatoffence
                lore:
                - '§eOffences:'
                - '§7Rasicm'
                - '§7Spam'
                - '§7IPs, personal information, etc.'
                - '§7Inappropriate words'
        Page2:
            Slot11:
                name: '&8&l[&cAn item&8&l]'
                command: "none"
                item: STONE
                permssion: sb.use.none
                lore:
                - '§eAction:'
                - '§7Configure me.'
            Slot17:
                name: '&8&l[&cAn item&8&l]'
                command: "none"
                item: STONE
                permssion: sb.use.none
                lore:
                - '§eAction:'
                - '§7Configure me.'
        OptionsPage:
            Slot11:
                name: '&8&l[&bTeleport&8&l]'
                command: "tp #target"
                item: FEATHER
                permssion: sb.use.teleport
                lore:
                - '§eAction:'
                - '§7Teleport to the player.'
            Slot17:
                name: '&8&l[&cKick&8&l]'
                command: "kick #target"
                item: IRON_BOOTS
                permssion: sb.use.kick
                lore:
                - '§eAction:'
                - '§7Kick the player.'
    
    # Punishment log
    Punishment-Log: 
    What in the world went wrong? I tried changing from ANSII to UTF-8 and opposite. Nothing seems to change anything. I've used § and & in another plugin, it works fine there.
     
  2. Offline

    Zombie_Striker

    Can you post the Config.yml?
     
  3. Offline

    yPedx

    @Zombie_Striker
     
  4. Offline

    Zombie_Striker

    @yPedx
    The formatting broke. The indentation has been removed.

    Try running the config through Yamllint.com. See if it detects and errors with the file.
     
  5. Offline

    yPedx

  6. Try changing the encoding of your config.yml to UTF-8
     
    Last edited: May 28, 2017
  7. Offline

    yPedx

    @BinaryAlien
    You didn't read I said I already did that :p
    This has already been solved. Sorry for not marking as solved.
     
Thread Status:
Not open for further replies.

Share This Page