Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. //In commands
  2. if(original.toLowerCase().trim().equals("!del")){
  3.     new CustomComs().delCom(contexty.getContext_MOON());
  4.     return "";
  5. }
  6.  
  7. //In CustomComs
  8. public void delCom(Context con){
  9.         context = con;
  10.         final File commands = new File(Environment.getExternalStorageDirectory().toString() + "/Command_files/commands.txt");
  11.         final File commands2 = new File(Environment.getExternalStorageDirectory().toString() + "/Command_files/commands2.txt");
  12.         final String[] list = readFile(commands2).split(" ");
  13.         final String comsList = readFile(commands);
  14.         if(comsList.trim().equals("")){
  15.             toasty.toast("No commands to delete");
  16.             return;
  17.         }
  18.         AlertDialog.Builder b = new AlertDialog.Builder(context)
  19.             .setTitle("Choose a command to delete")
  20.             .setItems(list, new DialogInterface.OnClickListener(){
  21.                 public void onClick(DialogInterface di, int which){
  22.                     int x = 0;
  23.                     String newComs2="";
  24.                     for(int i = 0; i < list.length; i++){
  25.                         if(i == which){
  26.  
  27.                         }
  28.                         else{
  29.                             newComs2 += list[i] + " ";
  30.                         }
  31.                     }
  32.  
  33.                     String newComs = comsList.replaceAll("(" + Pattern.quote("~&." + list[which]) + " )+([\\w\\s])+(\n)", "");
  34.                     try{
  35.                         FileOutputStream os = new FileOutputStream(commands);
  36.                         FileOutputStream os2 = new FileOutputStream(commands2);
  37.                         OutputStreamWriter wr = new OutputStreamWriter(os);
  38.                         OutputStreamWriter wr2 = new OutputStreamWriter(os2);
  39.                         wr.write(newComs);
  40.                         wr2.write(newComs2);
  41.                         wr.close();
  42.                         wr2.close();
  43.                         os.close();
  44.                         os2.close();
  45.                     }catch(IOException e){
  46.                         RandomUtils.dialogIt("fuk", e.toString() + "\n\nPlease contact @British with this error and give an explanation of how it happened if possible.");
  47.                     }
  48.  
  49.  
  50.                 }
  51.             });
  52.         b.create().show();
  53.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement