Last active
October 16, 2016 08:26
-
-
Save GenbuHase/c686e7bc3663e27f845c to your computer and use it in GitHub Desktop.
Example Codes For Data Helper Release 1.05 [Last Updated: 2016/04/02]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/ | |
* [games/com.mojang/]フォルダ内に[Spam0.vvv]~[Spam499.vvv]を生成 | |
/*/ | |
function newLevel () { | |
with (new DataHelper()) { | |
for (var i = 0; i < 500; i++) { | |
//File.CreateFile(ファイルパス); [戻り値:無し] | |
File.CreateFile(File.SpecialFolder.MCPE + "Spam" + i + ".vvv"); | |
} | |
} | |
} | |
var DataHelper=function(){this.File={SpecialFolder:{SDCard:android.os.Environment.getExternalStorageDirectory(),Alarms:android.os.Environment.DIRECTORY_ALARMS,DCIM:android.os.Environment.DIRECTORY_DCIM,Downloads:android.os.Environment.DIRECTORY_DOWNLOADS,Movies:android.os.Environment.DIRECTORY_MOVIES,Music:android.os.Environment.DIRECTORY_MUSIC,Notifications:android.os.Environment.DIRECTORY_NOTIFICATIONS,Pictures:android.os.Environment.DIRECTORY_PICTURES,Podcasts:android.os.Environment.DIRECTORY_PODCASTS,Ringtones:android.os.Environment.DIRECTORY_RINGTONES,MCPE:android.os.Environment.getExternalStorageDirectory()+"/games/com.mojang/"},CreateFile:function(Path){with(JavaImporter(java.io)){try{if(!new File(Path).getParentFile().exists()){new File(Path).getParentFile().mkdirs()}else{}new File(Path).createNewFile()}catch(Error){clientMessage(Error)}}},CreateFolder:function(Path){with(JavaImporter(java.io)){try{new File(Path).mkdirs()}catch(Error){clientMessage(Error)}}},ReadFile:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileLine:function(Path,Line){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text}}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileFromTexturePack:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new InputStreamReader(ModPE.openInputStreamFromTexturePack(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},WriteFile:function(Path,Data){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));Writer.write(Data);Writer.close()}catch(Error){clientMessage(Error)}}},GetFileLine:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Line=0;for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Line++}Reader.close();return Line}catch(Error){clientMessage(Error)}}},GetFileNames:function(Path){with(JavaImporter(java.io)){try{return new File(Path).listFiles()}catch(Error){clientMessage(Error)}}}};this.DB={SaveDB:function(Path,Data,SplitWord){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));var Lines=0;for(var i=0;i<Data.length;i++){Lines++;Writer.write(Data[i][0]+SplitWord+Data[i][1]);if(Lines!=Data.length){Writer.newLine()}}Writer.close()}catch(Error){clientMessage(Error)}}},LoadDB:function(Path,Line,SplitWord){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text.split(SplitWord)}}Reader.close();return Data}catch(Error){clientMessage(Error)}}}};this.Json={SaveJSON:function(Path,Data){with(new DataHelper()){try{File.CreateFile(Path);File.WriteFile(Path,JSON.stringify(Data,null,"\t"))}catch(Error){clientMessage(Error)}}},LoadJSON:function(Data){with(new DataHelper()){try{return JSON.parse(Data.replace("\n",""))}catch(Error){clientMessage(Error)}}}};this.Network={GetFileText:function(URL){new java.lang.Thread(new java.lang.Runnable({run:function(){with(JavaImporter(java.io,java.net)){try{var Reader=new BufferedReader(new ImputStreamReader(new URL(URL).getInputStream()));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}}})).start()}}}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/ | |
* [games/com.mojang/]内に[SpamFolder]が生成され、その中に[Spam0.vvv]~[Spam499.vvv]が生成される | |
/*/ | |
function newLevel () { | |
with (new DataHelper()) { | |
//File.CreateFolder(フォルダパス); [戻り値:無し] | |
File.CreateFolder(File.SpecialFolder.MCPE + "SpamFolder"); | |
for (var i = 0; i < 500; i++) { | |
File.CreateFile(File.SpecialFolder.MCPE + "SpamFolder/Spam" + i + ".vvv"); | |
} | |
} | |
} | |
var DataHelper=function(){this.File={SpecialFolder:{SDCard:android.os.Environment.getExternalStorageDirectory(),Alarms:android.os.Environment.DIRECTORY_ALARMS,DCIM:android.os.Environment.DIRECTORY_DCIM,Downloads:android.os.Environment.DIRECTORY_DOWNLOADS,Movies:android.os.Environment.DIRECTORY_MOVIES,Music:android.os.Environment.DIRECTORY_MUSIC,Notifications:android.os.Environment.DIRECTORY_NOTIFICATIONS,Pictures:android.os.Environment.DIRECTORY_PICTURES,Podcasts:android.os.Environment.DIRECTORY_PODCASTS,Ringtones:android.os.Environment.DIRECTORY_RINGTONES,MCPE:android.os.Environment.getExternalStorageDirectory()+"/games/com.mojang/"},CreateFile:function(Path){with(JavaImporter(java.io)){try{if(!new File(Path).getParentFile().exists()){new File(Path).getParentFile().mkdirs()}else{}new File(Path).createNewFile()}catch(Error){clientMessage(Error)}}},CreateFolder:function(Path){with(JavaImporter(java.io)){try{new File(Path).mkdirs()}catch(Error){clientMessage(Error)}}},ReadFile:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileLine:function(Path,Line){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text}}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileFromTexturePack:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new InputStreamReader(ModPE.openInputStreamFromTexturePack(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},WriteFile:function(Path,Data){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));Writer.write(Data);Writer.close()}catch(Error){clientMessage(Error)}}},GetFileLine:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Line=0;for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Line++}Reader.close();return Line}catch(Error){clientMessage(Error)}}},GetFileNames:function(Path){with(JavaImporter(java.io)){try{return new File(Path).listFiles()}catch(Error){clientMessage(Error)}}}};this.DB={SaveDB:function(Path,Data,SplitWord){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));var Lines=0;for(var i=0;i<Data.length;i++){Lines++;Writer.write(Data[i][0]+SplitWord+Data[i][1]);if(Lines!=Data.length){Writer.newLine()}}Writer.close()}catch(Error){clientMessage(Error)}}},LoadDB:function(Path,Line,SplitWord){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text.split(SplitWord)}}Reader.close();return Data}catch(Error){clientMessage(Error)}}}};this.Json={SaveJSON:function(Path,Data){with(new DataHelper()){try{File.CreateFile(Path);File.WriteFile(Path,JSON.stringify(Data,null,"\t"))}catch(Error){clientMessage(Error)}}},LoadJSON:function(Data){with(new DataHelper()){try{return JSON.parse(Data.replace("\n",""))}catch(Error){clientMessage(Error)}}}};this.Network={GetFileText:function(URL){new java.lang.Thread(new java.lang.Runnable({run:function(){with(JavaImporter(java.io,java.net)){try{var Reader=new BufferedReader(new ImputStreamReader(new URL(URL).getInputStream()));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}}})).start()}}}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/ | |
* [games/com.mojang/Test.txt]のデータを読み込んで出力する | |
/*/ | |
function newLevel () { | |
with (new DataHelper()) { | |
//File.ReadFile(ファイルパス); [戻り値:ファイルのデータ<String型>] | |
clientMessage(File.ReadFile(File.SpecialFolder.MCPE + "Test.txt")); | |
} | |
} | |
var DataHelper=function(){this.File={SpecialFolder:{SDCard:android.os.Environment.getExternalStorageDirectory(),Alarms:android.os.Environment.DIRECTORY_ALARMS,DCIM:android.os.Environment.DIRECTORY_DCIM,Downloads:android.os.Environment.DIRECTORY_DOWNLOADS,Movies:android.os.Environment.DIRECTORY_MOVIES,Music:android.os.Environment.DIRECTORY_MUSIC,Notifications:android.os.Environment.DIRECTORY_NOTIFICATIONS,Pictures:android.os.Environment.DIRECTORY_PICTURES,Podcasts:android.os.Environment.DIRECTORY_PODCASTS,Ringtones:android.os.Environment.DIRECTORY_RINGTONES,MCPE:android.os.Environment.getExternalStorageDirectory()+"/games/com.mojang/"},CreateFile:function(Path){with(JavaImporter(java.io)){try{if(!new File(Path).getParentFile().exists()){new File(Path).getParentFile().mkdirs()}else{}new File(Path).createNewFile()}catch(Error){clientMessage(Error)}}},CreateFolder:function(Path){with(JavaImporter(java.io)){try{new File(Path).mkdirs()}catch(Error){clientMessage(Error)}}},ReadFile:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileLine:function(Path,Line){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text}}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileFromTexturePack:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new InputStreamReader(ModPE.openInputStreamFromTexturePack(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},WriteFile:function(Path,Data){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));Writer.write(Data);Writer.close()}catch(Error){clientMessage(Error)}}},GetFileLine:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Line=0;for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Line++}Reader.close();return Line}catch(Error){clientMessage(Error)}}},GetFileNames:function(Path){with(JavaImporter(java.io)){try{return new File(Path).listFiles()}catch(Error){clientMessage(Error)}}}};this.DB={SaveDB:function(Path,Data,SplitWord){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));var Lines=0;for(var i=0;i<Data.length;i++){Lines++;Writer.write(Data[i][0]+SplitWord+Data[i][1]);if(Lines!=Data.length){Writer.newLine()}}Writer.close()}catch(Error){clientMessage(Error)}}},LoadDB:function(Path,Line,SplitWord){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text.split(SplitWord)}}Reader.close();return Data}catch(Error){clientMessage(Error)}}}};this.Json={SaveJSON:function(Path,Data){with(new DataHelper()){try{File.CreateFile(Path);File.WriteFile(Path,JSON.stringify(Data,null,"\t"))}catch(Error){clientMessage(Error)}}},LoadJSON:function(Data){with(new DataHelper()){try{return JSON.parse(Data.replace("\n",""))}catch(Error){clientMessage(Error)}}}};this.Network={GetFileText:function(URL){new java.lang.Thread(new java.lang.Runnable({run:function(){with(JavaImporter(java.io,java.net)){try{var Reader=new BufferedReader(new ImputStreamReader(new URL(URL).getInputStream()));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}}})).start()}}}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/ | |
* | |
/*/ | |
function newLevel () { | |
with (new DataHelper()) { | |
//File.ReadFileFromTexturePack(ファイルパス); [戻り値:ファイルのデータ<String型>] | |
} | |
} | |
var DataHelper=function(){this.File={SpecialFolder:{SDCard:android.os.Environment.getExternalStorageDirectory(),Alarms:android.os.Environment.DIRECTORY_ALARMS,DCIM:android.os.Environment.DIRECTORY_DCIM,Downloads:android.os.Environment.DIRECTORY_DOWNLOADS,Movies:android.os.Environment.DIRECTORY_MOVIES,Music:android.os.Environment.DIRECTORY_MUSIC,Notifications:android.os.Environment.DIRECTORY_NOTIFICATIONS,Pictures:android.os.Environment.DIRECTORY_PICTURES,Podcasts:android.os.Environment.DIRECTORY_PODCASTS,Ringtones:android.os.Environment.DIRECTORY_RINGTONES,MCPE:android.os.Environment.getExternalStorageDirectory()+"/games/com.mojang/"},CreateFile:function(Path){with(JavaImporter(java.io)){try{if(!new File(Path).getParentFile().exists()){new File(Path).getParentFile().mkdirs()}else{}new File(Path).createNewFile()}catch(Error){clientMessage(Error)}}},CreateFolder:function(Path){with(JavaImporter(java.io)){try{new File(Path).mkdirs()}catch(Error){clientMessage(Error)}}},ReadFile:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileLine:function(Path,Line){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text}}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileFromTexturePack:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new InputStreamReader(ModPE.openInputStreamFromTexturePack(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},WriteFile:function(Path,Data){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));Writer.write(Data);Writer.close()}catch(Error){clientMessage(Error)}}},GetFileLine:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Line=0;for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Line++}Reader.close();return Line}catch(Error){clientMessage(Error)}}},GetFileNames:function(Path){with(JavaImporter(java.io)){try{return new File(Path).listFiles()}catch(Error){clientMessage(Error)}}}};this.DB={SaveDB:function(Path,Data,SplitWord){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));var Lines=0;for(var i=0;i<Data.length;i++){Lines++;Writer.write(Data[i][0]+SplitWord+Data[i][1]);if(Lines!=Data.length){Writer.newLine()}}Writer.close()}catch(Error){clientMessage(Error)}}},LoadDB:function(Path,Line,SplitWord){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text.split(SplitWord)}}Reader.close();return Data}catch(Error){clientMessage(Error)}}}};this.Json={SaveJSON:function(Path,Data){with(new DataHelper()){try{File.CreateFile(Path);File.WriteFile(Path,JSON.stringify(Data,null,"\t"))}catch(Error){clientMessage(Error)}}},LoadJSON:function(Data){with(new DataHelper()){try{return JSON.parse(Data.replace("\n",""))}catch(Error){clientMessage(Error)}}}};this.Network={GetFileText:function(URL){new java.lang.Thread(new java.lang.Runnable({run:function(){with(JavaImporter(java.io,java.net)){try{var Reader=new BufferedReader(new ImputStreamReader(new URL(URL).getInputStream()));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}}})).start()}}}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/ | |
* [games/com.mojang/Test.txt]の114514行目を読み込んで出力する | |
/*/ | |
function newLevel () { | |
with (new DataHelper()) { | |
//File.ReadFileLine(ファイルパス, n行目); [戻り値:ファイルのn行目のデータ<String型>] | |
clientMessage(File.ReadFileLine(File.SpecialFolder.MCPE + "Test.txt", 114514)); | |
} | |
} | |
var DataHelper=function(){this.File={SpecialFolder:{SDCard:android.os.Environment.getExternalStorageDirectory(),Alarms:android.os.Environment.DIRECTORY_ALARMS,DCIM:android.os.Environment.DIRECTORY_DCIM,Downloads:android.os.Environment.DIRECTORY_DOWNLOADS,Movies:android.os.Environment.DIRECTORY_MOVIES,Music:android.os.Environment.DIRECTORY_MUSIC,Notifications:android.os.Environment.DIRECTORY_NOTIFICATIONS,Pictures:android.os.Environment.DIRECTORY_PICTURES,Podcasts:android.os.Environment.DIRECTORY_PODCASTS,Ringtones:android.os.Environment.DIRECTORY_RINGTONES,MCPE:android.os.Environment.getExternalStorageDirectory()+"/games/com.mojang/"},CreateFile:function(Path){with(JavaImporter(java.io)){try{if(!new File(Path).getParentFile().exists()){new File(Path).getParentFile().mkdirs()}else{}new File(Path).createNewFile()}catch(Error){clientMessage(Error)}}},CreateFolder:function(Path){with(JavaImporter(java.io)){try{new File(Path).mkdirs()}catch(Error){clientMessage(Error)}}},ReadFile:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileLine:function(Path,Line){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text}}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileFromTexturePack:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new InputStreamReader(ModPE.openInputStreamFromTexturePack(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},WriteFile:function(Path,Data){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));Writer.write(Data);Writer.close()}catch(Error){clientMessage(Error)}}},GetFileLine:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Line=0;for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Line++}Reader.close();return Line}catch(Error){clientMessage(Error)}}},GetFileNames:function(Path){with(JavaImporter(java.io)){try{return new File(Path).listFiles()}catch(Error){clientMessage(Error)}}}};this.DB={SaveDB:function(Path,Data,SplitWord){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));var Lines=0;for(var i=0;i<Data.length;i++){Lines++;Writer.write(Data[i][0]+SplitWord+Data[i][1]);if(Lines!=Data.length){Writer.newLine()}}Writer.close()}catch(Error){clientMessage(Error)}}},LoadDB:function(Path,Line,SplitWord){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text.split(SplitWord)}}Reader.close();return Data}catch(Error){clientMessage(Error)}}}};this.Json={SaveJSON:function(Path,Data){with(new DataHelper()){try{File.CreateFile(Path);File.WriteFile(Path,JSON.stringify(Data,null,"\t"))}catch(Error){clientMessage(Error)}}},LoadJSON:function(Data){with(new DataHelper()){try{return JSON.parse(Data.replace("\n",""))}catch(Error){clientMessage(Error)}}}};this.Network={GetFileText:function(URL){new java.lang.Thread(new java.lang.Runnable({run:function(){with(JavaImporter(java.io,java.net)){try{var Reader=new BufferedReader(new ImputStreamReader(new URL(URL).getInputStream()));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}}})).start()}}}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/ | |
* | |
/*/ | |
var Position; | |
function newLevel () { | |
with (new DataHelper()) { | |
if (!File.IsVaild(File.SpecialFolder.MCPE + "minecraftpe/Test.txt")) { | |
File.CreateFile(File.SpecialFolder.MCPE + "minecraftpe/Test.txt"); | |
Position = [Player.getX(), Player.getY(), Player.getZ()]; | |
Json.SaveJSON(File.SpecialFolder.MCPE + "minecraftpe/Test.txt", Position); | |
} else { | |
Position = Json.LoadJSON(File.ReadFile(File.SpecialFolder.MCPE + "minecraftpe/Test.txt")); | |
} | |
} | |
} | |
function leaveGame () { | |
with (new DataHelper()) { | |
Position = [Player.getX(), Player.getY(), Player.getZ()]; | |
Json.SaveJSON(File.SpecialFolder.MCPE + "minecraftpe/Test.txt", Position); | |
} | |
} | |
var DataHelper=function(){this.File={SpecialFolder:{SDCard:android.os.Environment.getExternalStorageDirectory(),Alarms:android.os.Environment.DIRECTORY_ALARMS,DCIM:android.os.Environment.DIRECTORY_DCIM,Downloads:android.os.Environment.DIRECTORY_DOWNLOADS,Movies:android.os.Environment.DIRECTORY_MOVIES,Music:android.os.Environment.DIRECTORY_MUSIC,Notifications:android.os.Environment.DIRECTORY_NOTIFICATIONS,Pictures:android.os.Environment.DIRECTORY_PICTURES,Podcasts:android.os.Environment.DIRECTORY_PODCASTS,Ringtones:android.os.Environment.DIRECTORY_RINGTONES,MCPE:android.os.Environment.getExternalStorageDirectory()+"/games/com.mojang/"},CreateFile:function(Path){with(JavaImporter(java.io)){try{if(!new File(Path).getParentFile().exists()){new File(Path).getParentFile().mkdirs()}else{}new File(Path).createNewFile()}catch(Error){clientMessage(Error)}}},CreateFolder:function(Path){with(JavaImporter(java.io)){try{new File(Path).mkdirs()}catch(Error){clientMessage(Error)}}},ReadFile:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileLine:function(Path,Line){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text}}Reader.close();return Data}catch(Error){clientMessage(Error)}}},ReadFileFromTexturePack:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new InputStreamReader(ModPE.openInputStreamFromTexturePack(Path)));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}},WriteFile:function(Path,Data){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));Writer.write(Data);Writer.close()}catch(Error){clientMessage(Error)}}},GetFileLine:function(Path){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Line=0;for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Line++}Reader.close();return Line}catch(Error){clientMessage(Error)}}},GetFileNames:function(Path){with(JavaImporter(java.io)){try{return new File(Path).listFiles()}catch(Error){clientMessage(Error)}}}};this.DB={SaveDB:function(Path,Data,SplitWord){with(JavaImporter(java.io)){try{var Writer=new BufferedWriter(new FileWriter(new File(Path)));var Lines=0;for(var i=0;i<Data.length;i++){Lines++;Writer.write(Data[i][0]+SplitWord+Data[i][1]);if(Lines!=Data.length){Writer.newLine()}}Writer.close()}catch(Error){clientMessage(Error)}}},LoadDB:function(Path,Line,SplitWord){with(JavaImporter(java.io)){try{var Reader=new BufferedReader(new FileReader(new File(Path)));var Data="";for(var Text=Reader.readLine(),LineNumber=1;Text!=null;Text=Reader.readLine(),LineNumber++){if(LineNumber==Line){Data=Text.split(SplitWord)}}Reader.close();return Data}catch(Error){clientMessage(Error)}}}};this.Json={SaveJSON:function(Path,Data){with(new DataHelper()){try{File.CreateFile(Path);File.WriteFile(Path,JSON.stringify(Data,null,"\t"))}catch(Error){clientMessage(Error)}}},LoadJSON:function(Data){with(new DataHelper()){try{return JSON.parse(Data.replace("\n",""))}catch(Error){clientMessage(Error)}}}};this.Network={GetFileText:function(URL){new java.lang.Thread(new java.lang.Runnable({run:function(){with(JavaImporter(java.io,java.net)){try{var Reader=new BufferedReader(new ImputStreamReader(new URL(URL).getInputStream()));var Data="";for(var Text=Reader.readLine();Text!=null;Text=Reader.readLine()){Data+=Text+"\n"}Reader.close();return Data}catch(Error){clientMessage(Error)}}}})).start()}}}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These codes were written by Genbu Hase for any people.