Solved Plugin folder name different than actual name

Discussion in 'Plugin Development' started by Kermit_23, Aug 27, 2016.

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

    Kermit_23

    So, i almost finished my plugin so i wanted to test it. When i export it and run my server, i check my console and says "AntiBot-Ultra_Reborn" so i checked the plugins folder, and the plugin folder name is "AntiBot-Ultra_Reborn", it should had been "AntiBot-Ultra Reborn" without "_". I checked the plugin.yml and all of my classes to see why it generates the folder name with _ and nothing found..

    Main class:
    Code:
    public class Main extends JavaPlugin {
        final Calendar currentDate = Calendar.getInstance();
        final SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MMM/dd HH:mm:ss");
        final String dateNow = formatter.format(currentDate.getTime());
       
    
        public static Main r;
        public static FileConfiguration c;
           
    
        public HashMap<String, Integer> Hbot;
        public HashMap<String, Boolean> AntiWhite;
        public HashMap<String, Boolean> Maintenance;
       
        public Main() {
            this.Hbot = new HashMap<String, Integer>();
            this.AntiWhite = new HashMap<String, Boolean>();
            this.Maintenance = new HashMap<String, Boolean>();
        }
       
        public void onEnable() {
            try {
                Main.r = this;
                Main.c = this.getConfig();
                consoleLog(ChatColor.GREEN + "Registering events.");
                registerAllEvents();
                consoleLog(ChatColor.GREEN + "Checking to see if config.yml or whitelist.yml exists, if not we create it!.");
                configsAndMore();
                consoleLog(ChatColor.GREEN + "Checking server ram and comparing it to see if it is < 512mb.");
                checkRam();
                consoleLog(ChatColor.GREEN + "Loading HashMap.");
                saveHashMap();
                consoleLog(ChatColor.GREEN + "Config.yml and Whitelist.yml exists, Ram checked, HashMap loaded");
                mainStuff();
                consoleLog(ChatColor.GREEN + "Enabling protection..");
                consoleLog(ChatColor.GREEN + "Protection enabled.");
            } catch (Throwable ex) {
                consoleLog(ChatColor.RED + "An error occured on loading :(, printing the error!");
                ex.printStackTrace();
                Bukkit.getPluginManager().disablePlugin(this);
            }
        }
        public static void consoleLog(final String message) {
            final ConsoleCommandSender sender = Bukkit.getServer().getConsoleSender();
            sender.sendMessage(ChatColor.GREEN + "[AntiBot-Ultra Reborn] " + message);
        }
       
        public void configsAndMore() {
            Main.c.options().copyDefaults(true);
            ProxyFileHandler.loadConfig();
            WhitelistFileHandler.loadConfig();
        }
       
       
        public void checkRam() {
            final Runtime runtime = Runtime.getRuntime();
            final long l = runtime.totalMemory() / 1048576L;
            if (l < 512L && Main.c.getBoolean("Settings.Check_Proxy")) {
                Main.c.set("Settings.Check_Poxy", false);
                consoleLog("Sorry, you can't use Check_Proxy you ram is < 512 MB");
                this.saveConfig();
                this.reloadConfig();
            }
        }
       
        public void saveHashMap() {
            this.AntiWhite.put("white", false);
            this.Maintenance.put("value", false);
            this.Hbot.put("LoginCount", 1);
            this.saveConfig();
        }
       
        public void registerAllEvents() {
            this.getServer().getPluginManager().registerEvents((Listener)new Counter(), (Plugin)this);
            this.getServer().getPluginManager().registerEvents((Listener)new AutoWhite(), (Plugin)this);
            this.getServer().getPluginManager().registerEvents((Listener)new Maintenance(), (Plugin)this);
            this.getServer().getPluginManager().registerEvents((Listener)new CheckProxy(), (Plugin)this);
            this.getServer().getPluginManager().registerEvents((Listener)new ServerPing(), (Plugin)this);
        }
       
        public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
            final Player player = (Player)sender;
            if (cmd.getName().equalsIgnoreCase("sensibility") && player.hasPermission(new Permission("Antibot.sensibility"))) {
                if (args.length == 0) {
                    player.sendMessage(ChatColor.RED + "/sensibility <Integer>");
                }
                else if (args.length == 1) {
                    final String is = args[0].toString();
                    final int i = Integer.parseInt(is);
                    Main.c.set("Settings.Sensibility:", (Object)i);
                    this.saveConfig();
                    player.sendMessage(ChatColor.GREEN + "[AntiBotUltra] Sensibility set to " + ChatColor.GOLD + i);
                }
            }
            else if (cmd.getName().equalsIgnoreCase("maintenance") && player.hasPermission(new Permission("Antibot.maintenance"))) {
                final Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
                if (!Main.c.getBoolean("Settings.Maintenance_Mode")) {
                    this.Maintenance.put("value", true);
                    Main.c.set("Settings.Maintenance_Mode:", (Object)true);
                    for (int i = 0; i < players.size(); ++i) {
                        if (!player.isOp()) {
                            ((Player) players).kickPlayer(ChatColor.GOLD + Main.c.getString("Messages.Maintenance_Mode_Message"));
                        }
                    }
                    player.sendMessage(ChatColor.GREEN + "[AntiBotUltra] Maintenance Mode " + ChatColor.GOLD + "On");
                }
                else if (Main.c.getBoolean("Settings.Maintenance_Mode")) {
                    this.Maintenance.put("value", false);
                    Main.c.set("Settings.Maintenance_Mode:", (Object)false);
                    player.sendMessage(ChatColor.GREEN + "[AntiBotUltra] Maintenance Mode " + ChatColor.GOLD + "Off");
                }
            }
            return false;
        }
       
        public void mainStuff() {
            this.getServer().getScheduler().runTaskTimerAsynchronously((Plugin)this, (Runnable)new Runnable() {
                @Override
                public void run() {
                    if (Main.this.Hbot.get("LoginCount") < Main.c.getInt("Settings.Sensiblity:")) {
                        Main.this.Hbot.put("LoginCount", 0);
                    }
                    else if (Main.this.Hbot.get("LoginCount") > Main.c.getInt("Settings.Sensibility") && !Main.this.AntiWhite.get("white") && !Main.c.getBoolean("Settings.Whitelist")) {
                        Main.c.set("Settings.Whitelist:", true);
                        Main.this.saveConfig();
                        Main.this.reloadConfig();
                        Log.logToFileAttack("################################\n");
                        Log.logToFileAttack("The server was attacked at " + dateNow + "\n");
                        Log.logToFileAttack("Stopped " + CheckProxy.countproxy + " bots");
                        Log.logToFileAttack("################################\n");
                        Main.this.AntiWhite.put("white", true);
                        Main.this.Hbot.put("LoginCount", 0);
                        for (Player o : Bukkit.getOnlinePlayers()) {
                            if (o.hasPermission(new Permission("Antibot.spy"))) {
                                o.sendMessage(ChatColor.GREEN + "[AntiBotUltra] " + ChatColor.GRAY + "Bot attack detected," + ChatColor.RED + " WHITELIST ON");
                                consoleLog("Bot atack detected, " + ChatColor.RED + "WHITELIST ON");
                            }
                        }
                        Main.this.getServer().getScheduler().runTaskLater((Plugin)Main.r, (Runnable)new Runnable() {
                            @Override
                            public void run() {
                                Main.this.Hbot.put("LoginCount", 0);
                                for (Player o : Bukkit.getOnlinePlayers()) {
                                    if (o.hasPermission(new Permission("Antibot.spy"))) {
                                        o.sendMessage(ChatColor.RED + "[AntiBotUltra] " + ChatColor.YELLOW + "Analize...");
                                    }
                                }
                            }
                        }, 2000L);
                        Main.this.getServer().getScheduler().runTaskLater((Plugin)Main.r, (Runnable)new Runnable() {
                            @Override
                            public void run() {
                                if (Main.this.Hbot.get("LoginCount") < Main.c.getInt("Settings.Sensibility:")) {
                                    Main.this.AntiWhite.put("white", false);
                                    Main.this.Hbot.put("LoginCount", 0);
                                    for (Player o : Bukkit.getOnlinePlayers()) {
                                        if (o.hasPermission(new Permission("Antibot.spy"))) {
                                            o.sendMessage(ChatColor.RED + "[AntiBotUltra] " + ChatColor.GRAY + "Bot attack finished," + ChatColor.GREEN + " Whitelist off.");
                                            o.sendMessage(ChatColor.RED + "[AntiBotUltra] " + ChatColor.GRAY + "Stopped " + CheckProxy.countproxy + " bots!");
                                            Main.c.set("Settings.Whitelist:", false);
                                            Main.this.saveConfig();
                                            Main.this.reloadConfig();
                                        }
                                    }
                                }
                                else {
                                    for (Player o : Bukkit.getOnlinePlayers()) {
                                        if (o.hasPermission(new Permission("Antibot.spy"))) {
                                            o.sendMessage(ChatColor.RED + "[AntiBotUltra] " + ChatColor.GREEN + "Bot attack persist, restart counter...");
                                        }
                                    }
                                    Main.this.AntiWhite.put("white", false);
                                }
                            }
                        }, 3000L);
                    }
                }
            }, 100L, 100L);
        }
    }
    Plugin.yml

    Code:
    name: AntiBot-Ultra Reborn
    main: aname.antibotultra.light.source.Main
    author: AName
    version: 2.0
    description: AntiBot-Ultra Reborn
    commands:
        sensibility:
          description: Set Sensibility.
          permission: Antibot.sensibility
          permission-message: You don't have Antibot.sensibility
        maintenance:
          description: Enable maintenance mode.
          permission: Antibot.maintenance
          permission-message: You don't have Antibot.maintenance
    P.S. if you see the "_" please tell me because im running on ubuntu16.04 and sometimes it doesn't show "_" in eclipse
     
  2. Offline

    thapengwin

    It is not recommended to have spaces in your plugin names, as this will happen. You should see a few lines printed to your console saying this specifically once you boot up your server.
     
    Marti201 likes this.
  3. Offline

    N00BHUN73R

    @Kermit_23
    Bukkit won't let you have spaces in your folder path, so it fills those spaces up with underscores. Why does it matter though? People will still know exactly what it is and for.
     
  4. Offline

    Kermit_23

    well, i removed the space, anyways, thank you guys! :D
     
Thread Status:
Not open for further replies.

Share This Page