Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //source
- package com.tips48.restartNow;
- import java.io.*;
- import java.util.jar.JarFile;
- import java.util.logging.Logger;
- import java.util.zip.ZipEntry;
- class RestartNowExtractor {
- private RestartNow restartNow;
- File path = new File(".");
- File restartNowMain = new File(path + File.separator + "restartNowMain.jar");
- File windowsOnly = new File(path + File.separator + "windowsonly.bat");
- public RestartNowExtractor(RestartNow restartNow){
- this.restartNow = restartNow;
- }
- protected void extractFile(String file, String destination){
- try {
- String home = getClass().getProtectionDomain().getCodeSource().getLocation().toString().substring(6);
- JarFile jar = new JarFile(home);
- ZipEntry entry = jar.getEntry(file);
- File newFile = new File(destination, entry.getName());
- InputStream in =
- new BufferedInputStream(getClass().getClassLoader().getResourceAsStream(file));
- OutputStream out =
- new BufferedOutputStream(new FileOutputStream(newFile));
- byte[] buffer = new byte[2048];
- for (;;) {
- int nBytes = in.read(buffer);
- if (nBytes <= 0) break;
- out.write(buffer, 0, nBytes);
- }
- out.flush();
- out.close();
- in.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- protected boolean checkRestartNowMain(){
- if(restartNowMain.exists()){
- return false;
- }
- else{
- return true;
- }
- }
- protected boolean checkWindowsOnly(){
- if(windowsOnly.exists() && RestartNow.getOSName().toLowerCase().contains("window")){
- return false;
- }
- else{
- return true;
- }
- }
- }
- //error
- 19:34:05 [SEVERE] java.io.FileNotFoundException: \windowsonly.bat (Access is den
- ied)
- 19:34:05 [SEVERE] at java.io.FileOutputStream.open(Native Method)
- 19:34:05 [SEVERE] at java.io.FileOutputStream.<init>(Unknown Source)
- 19:34:05 [SEVERE] at java.io.FileOutputStream.<init>(Unknown Source)
- 19:34:05 [SEVERE] at com.tips48.restartNow.RestartNowExtractor.extractFile
- (RestartNowExtractor.java:28)
- 19:34:05 [SEVERE] at com.tips48.restartNow.RestartNow.onEnable(RestartNow.
- java:182)
- 19:34:05 [SEVERE] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlug
- in.java:125)
- 19:34:05 [SEVERE] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(
- JavaPluginLoader.java:750)
- 19:34:05 [SEVERE] at org.bukkit.plugin.SimplePluginManager.enablePlugin(Si
- mplePluginManager.java:253)
- 19:34:05 [SEVERE] at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftSe
- rver.java:134)
- 19:34:05 [SEVERE] at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftS
- erver.java:112)
- 19:34:05 [SEVERE] at org.bukkit.craftbukkit.CraftServer.reload(CraftServer
- .java:339)
- 19:34:05 [SEVERE] at org.bukkit.command.SimpleCommandMap$ReloadCommand.exe
- cute(SimpleCommandMap.java:247)
- 19:34:05 [SEVERE] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCo
- mmandMap.java:128)
- 19:34:05 [SEVERE] at org.bukkit.craftbukkit.CraftServer.dispatchCommand(Cr
- aftServer.java:273)
- 19:34:05 [SEVERE] at net.minecraft.server.MinecraftServer.b(MinecraftServe
- r.java:430)
- 19:34:05 [SEVERE] at net.minecraft.server.MinecraftServer.h(MinecraftServe
- r.java:415)
- 19:34:05 [SEVERE] at net.minecraft.server.MinecraftServer.run(MinecraftSer
- ver.java:311)
- 19:34:05 [SEVERE] at net.minecraft.server.ThreadServerApplication.run(Sour
- ceFile:422)
Add Comment
Please, Sign In to add comment