Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //In commands
- if(original.toLowerCase().trim().equals("!del")){
- new CustomComs().delCom(contexty.getContext_MOON());
- return "";
- }
- //In CustomComs
- public void delCom(Context con){
- context = con;
- final File commands = new File(Environment.getExternalStorageDirectory().toString() + "/Command_files/commands.txt");
- final File commands2 = new File(Environment.getExternalStorageDirectory().toString() + "/Command_files/commands2.txt");
- final String[] list = readFile(commands2).split(" ");
- final String comsList = readFile(commands);
- if(comsList.trim().equals("")){
- toasty.toast("No commands to delete");
- return;
- }
- AlertDialog.Builder b = new AlertDialog.Builder(context)
- .setTitle("Choose a command to delete")
- .setItems(list, new DialogInterface.OnClickListener(){
- public void onClick(DialogInterface di, int which){
- int x = 0;
- String newComs2="";
- for(int i = 0; i < list.length; i++){
- if(i == which){
- }
- else{
- newComs2 += list[i] + " ";
- }
- }
- String newComs = comsList.replaceAll("(" + Pattern.quote("~&." + list[which]) + " )+([\\w\\s])+(\n)", "");
- try{
- FileOutputStream os = new FileOutputStream(commands);
- FileOutputStream os2 = new FileOutputStream(commands2);
- OutputStreamWriter wr = new OutputStreamWriter(os);
- OutputStreamWriter wr2 = new OutputStreamWriter(os2);
- wr.write(newComs);
- wr2.write(newComs2);
- wr.close();
- wr2.close();
- os.close();
- os2.close();
- }catch(IOException e){
- RandomUtils.dialogIt("fuk", e.toString() + "\n\nPlease contact @British with this error and give an explanation of how it happened if possible.");
- }
- }
- });
- b.create().show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement