scarpet v1.2
This commit is contained in:
1 parent
723f863d98
commit
885f579d6c
34 files changed
+8786
-18
No files matched your search
@@ -0,0 +1,45 @@
|
||||
package carpet.script.bundled;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FileModule implements ModuleInterface
|
||||
{
|
||||
private String name;
|
||||
private String code;
|
||||
public FileModule(File sourceFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
name = sourceFile.getName().replaceFirst("\\.sc","").toLowerCase(Locale.ROOT);
|
||||
code = new String(Files.readAllBytes(sourceFile.toPath()));
|
||||
}
|
||||
catch ( IOException e)
|
||||
{
|
||||
name = null;
|
||||
code = null;
|
||||
}
|
||||
}
|
||||
public FileModule fromName(String name)
|
||||
{
|
||||
File sourceFile = CarpetServer.minecraft_server.getLevelStorage().resolveFile(
|
||||
CarpetServer.minecraft_server.getLevelName(), "scripts/"+name+".sc");
|
||||
return new FileModule(sourceFile);
|
||||
}
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user