Use tab indentation in Java plugin
This commit is contained in:
parent
54785a3b02
commit
571b5b9ef4
@ -23,107 +23,107 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.dynmap.DynmapAPI;
|
||||
|
||||
public class LiveAtlasMain extends JavaPlugin {
|
||||
private static Logger log;
|
||||
Plugin dynmap;
|
||||
DynmapAPI api;
|
||||
FileConfiguration cfg;
|
||||
private static Logger log;
|
||||
Plugin dynmap;
|
||||
DynmapAPI api;
|
||||
FileConfiguration cfg;
|
||||
|
||||
int updates_per_tick = 20;
|
||||
int vupdates_per_tick = 20;
|
||||
int updates_per_tick = 20;
|
||||
int vupdates_per_tick = 20;
|
||||
|
||||
HashMap<String, Integer> lookup_cache = new HashMap<String, Integer>();
|
||||
HashMap<String, Integer> vlookup_cache = new HashMap<String, Integer>();
|
||||
HashMap<String, Integer> lookup_cache = new HashMap<String, Integer>();
|
||||
HashMap<String, Integer> vlookup_cache = new HashMap<String, Integer>();
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
log = this.getLogger();
|
||||
}
|
||||
@Override
|
||||
public void onLoad() {
|
||||
log = this.getLogger();
|
||||
}
|
||||
|
||||
public static void info(String msg) {
|
||||
log.log(Level.INFO, msg);
|
||||
}
|
||||
public static void severe(String msg) {
|
||||
log.log(Level.SEVERE, msg);
|
||||
}
|
||||
public static void info(String msg) {
|
||||
log.log(Level.INFO, msg);
|
||||
}
|
||||
public static void severe(String msg) {
|
||||
log.log(Level.SEVERE, msg);
|
||||
}
|
||||
|
||||
private class LiveAtlasServierListener implements Listener {
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
Plugin p = event.getPlugin();
|
||||
String name = p.getDescription().getName();
|
||||
if (name.equals("dynmap")) {
|
||||
activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
private class LiveAtlasServierListener implements Listener {
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
Plugin p = event.getPlugin();
|
||||
String name = p.getDescription().getName();
|
||||
if (name.equals("dynmap")) {
|
||||
activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
info("initializing");
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
/* Get dynmap */
|
||||
dynmap = pm.getPlugin("dynmap");
|
||||
if (dynmap == null) {
|
||||
severe("Cannot find dynmap!");
|
||||
return;
|
||||
}
|
||||
public void onEnable() {
|
||||
info("initializing");
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
/* Get dynmap */
|
||||
dynmap = pm.getPlugin("dynmap");
|
||||
if (dynmap == null) {
|
||||
severe("Cannot find dynmap!");
|
||||
return;
|
||||
}
|
||||
|
||||
getServer().getPluginManager().registerEvents(new LiveAtlasServierListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new LiveAtlasServierListener(), this);
|
||||
|
||||
/* If enabled, activate */
|
||||
if (dynmap.isEnabled())
|
||||
activate();
|
||||
}
|
||||
/* If enabled, activate */
|
||||
if (dynmap.isEnabled())
|
||||
activate();
|
||||
}
|
||||
|
||||
private void activate() {
|
||||
private void activate() {
|
||||
String version = this.getDescription().getVersion();
|
||||
|
||||
try {
|
||||
Path dynmapWebFolderPath = Paths.get(dynmap.getDataFolder().toURI()).resolve("web");
|
||||
File sourceDirectory = Paths.get(this.getDataFolder().toURI()).toFile();
|
||||
File destinationDirectory = dynmapWebFolderPath.toFile();
|
||||
copyDirectory(sourceDirectory, destinationDirectory);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Material Dynmap v" + version + " installation failed", e);
|
||||
}
|
||||
Path dynmapWebFolderPath = Paths.get(dynmap.getDataFolder().toURI()).resolve("web");
|
||||
File sourceDirectory = Paths.get(this.getDataFolder().toURI()).toFile();
|
||||
File destinationDirectory = dynmapWebFolderPath.toFile();
|
||||
copyDirectory(sourceDirectory, destinationDirectory);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Material Dynmap v" + version + " installation failed", e);
|
||||
}
|
||||
|
||||
info("Material Dynmap v" + version + " installation succeeded");
|
||||
}
|
||||
info("Material Dynmap v" + version + " installation succeeded");
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
}
|
||||
public void onDisable() {
|
||||
}
|
||||
|
||||
private static void copyDirectory(File sourceDirectory, File destinationDirectory) throws IOException {
|
||||
if (!destinationDirectory.exists()) {
|
||||
destinationDirectory.mkdir();
|
||||
}
|
||||
for (String f : sourceDirectory.list()) {
|
||||
copyDirectoryCompatibityMode(new File(sourceDirectory, f), new File(destinationDirectory, f));
|
||||
}
|
||||
}
|
||||
private static void copyDirectory(File sourceDirectory, File destinationDirectory) throws IOException {
|
||||
if (!destinationDirectory.exists()) {
|
||||
destinationDirectory.mkdir();
|
||||
}
|
||||
for (String f : sourceDirectory.list()) {
|
||||
copyDirectoryCompatibityMode(new File(sourceDirectory, f), new File(destinationDirectory, f));
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyDirectoryCompatibityMode(File sourceDirectory, File destinationDirectory) throws IOException {
|
||||
if (sourceDirectory.getName() == "io" || sourceDirectory.getName() == "META-INF") {
|
||||
return;
|
||||
}
|
||||
if (sourceDirectory.isDirectory()) {
|
||||
copyDirectory(sourceDirectory, destinationDirectory);
|
||||
} else {
|
||||
copyFile(sourceDirectory, destinationDirectory);
|
||||
}
|
||||
}
|
||||
public static void copyDirectoryCompatibityMode(File sourceDirectory, File destinationDirectory) throws IOException {
|
||||
if (sourceDirectory.getName() == "io" || sourceDirectory.getName() == "META-INF") {
|
||||
return;
|
||||
}
|
||||
if (sourceDirectory.isDirectory()) {
|
||||
copyDirectory(sourceDirectory, destinationDirectory);
|
||||
} else {
|
||||
copyFile(sourceDirectory, destinationDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyFile(File sourceFile, File destinationFile) throws IOException {
|
||||
if (sourceFile.getName() == "plugin.yml") {
|
||||
return;
|
||||
}
|
||||
try (InputStream in = new FileInputStream(sourceFile);
|
||||
OutputStream out = new FileOutputStream(destinationFile)) {
|
||||
byte[] buf = new byte[1024];
|
||||
int length;
|
||||
while ((length = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void copyFile(File sourceFile, File destinationFile) throws IOException {
|
||||
if (sourceFile.getName() == "plugin.yml") {
|
||||
return;
|
||||
}
|
||||
try (InputStream in = new FileInputStream(sourceFile);
|
||||
OutputStream out = new FileOutputStream(destinationFile)) {
|
||||
byte[] buf = new byte[1024];
|
||||
int length;
|
||||
while ((length = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user