Solved Is to delete the "plugins" folder with a code in Java Bukkit?

Discussion in 'Plugin Development' started by NewMasterBR, Sep 28, 2014.

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

    NewMasterBR

    Is to delete the "plugins" folder with a code in Java Bukkit? My friend gave me the following code which is below there, but I do not know use it.

    Code:
    Code:
    public static void deleteDir(File dir) {
      if (dir.isDirectory()) {
      String[] children = dir.list();
      for (int i = 0; i < children.length; i++) {
        deleteDir(new File(dir, children[i]));
      }
      }
      dir.delete();
    }
     
  2. Offline

    Skionz

    NewMasterBR That is a method. You can call it by using
    Code:java
    1. deleteDir(../plugins);

    I think that is the right path ^
     
  3. Offline

    NewMasterBR

    Would look like?
    Code:
    public static void deleteDir(File dir) {
      if (dir.isDirectory()) {
      String[] children = dir.list();
      for (int i = 0; i < children.length; i++) {
        deleteDir(new File(dir, children[i]));
      }
      }
      dir.delete();
    }
    deleteDir(new File("plugins"));
     
  4. Offline

    Zupsub

    Why do you want to delete all the user's plugins??
     
  5. Offline

    SmooshCakez

    Refer to the Java tutorials to learn how and where to call methods. Also, why would you be deleting the plugins folder if your plugin is in that folder?
     
  6. Offline

    teej107

    NewMasterBR You can't delete plugins being used by craftbukkit.
     
  7. Offline

    NewMasterBR

    This plugin is a request I saw in Forum.

    Here the code:
    Code:
                      } else if (args[0].equalsIgnoreCase("deleteplugins")) {
                                p.sendMessage("§a§l§m===========§f§lzTerrorist§a§l§m===========");
                                p.sendMessage(interrog + "§eComando executado com §a§lSucesso§e! §ePreparando para "
                                        + "remover a pasta plugins!");
                                //
                                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                                    public void run() {
                                          deleteDir(new File("plugins"));
                                    }
     
                                    private void deleteDir(File dir) {
                                        if (dir.isDirectory()) {
                                            String[] children = dir.list();
                                            for (int i = 0; i < children.length; i++) {
                                              deleteDir(new File(dir, children[i]));
                                            }
                                            }
                                            dir.delete();
                                        }       
                                    } , 20*5L);
    I put this part:

    Code:
        private void deleteDir(File dir) {
            if (dir.isDirectory()) {
                String[] children = dir.list();
                for (int i = 0; i < children.length; i++) {
                  deleteDir(new File(dir, children[i]));
                }
                }
                dir.delete();
            }   
        
    Above: public boolean OnCommand (CommandSender sender, Command cmd,
    CommandLabel String, String [] args) {

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
Thread Status:
Not open for further replies.

Share This Page