Code cleanup.

This commit is contained in:
Tastybento 2018-02-07 21:33:36 -08:00
parent fc8876cf80
commit b253ff5c64
4 changed files with 26 additions and 22 deletions

View File

@ -31,5 +31,4 @@ public class Constants {
// Admin command
public static final String ADMINCOMMAND = "bsadmin";
}

View File

@ -9,6 +9,12 @@ import us.tastybento.bskyblock.BSkyBlock;
public class IslandWorld {
private static final String MULTIVERSE_SET_GENERATOR = "mv modify set generator ";
private static final String MULTIVERSE_IMPORT = "mv import ";
private static final String NETHER = "_nether";
private static final String THE_END = "_the_end";
private static final String CREATING = "Creating ";
private BSkyBlock plugin;
private static World islandWorld;
private static World netherWorld;
@ -24,32 +30,32 @@ public class IslandWorld {
return;
}
if (plugin.getServer().getWorld(plugin.getSettings().getWorldName()) == null) {
Bukkit.getLogger().info("Creating " + plugin.getName() + "'s Island World...");
Bukkit.getLogger().info(CREATING + plugin.getName() + "'s Island World...");
}
// Create the world if it does not exist
islandWorld = WorldCreator.name(plugin.getSettings().getWorldName()).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new ChunkGeneratorWorld(plugin))
.createWorld();
// Make the nether if it does not exist
if (plugin.getSettings().isNetherGenerate()) {
if (plugin.getServer().getWorld(plugin.getSettings().getWorldName() + "_nether") == null) {
Bukkit.getLogger().info("Creating " + plugin.getName() + "'s Nether...");
if (plugin.getServer().getWorld(plugin.getSettings().getWorldName() + NETHER) == null) {
Bukkit.getLogger().info(CREATING + plugin.getName() + "'s Nether...");
}
if (!plugin.getSettings().isNetherIslands()) {
netherWorld = WorldCreator.name(plugin.getSettings().getWorldName() + "_nether").type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
netherWorld = WorldCreator.name(plugin.getSettings().getWorldName() + NETHER).type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
} else {
netherWorld = WorldCreator.name(plugin.getSettings().getWorldName() + "_nether").type(WorldType.FLAT).generator(new ChunkGeneratorWorld(plugin))
netherWorld = WorldCreator.name(plugin.getSettings().getWorldName() + NETHER).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(plugin))
.environment(World.Environment.NETHER).createWorld();
}
}
// Make the end if it does not exist
if (plugin.getSettings().isEndGenerate()) {
if (plugin.getServer().getWorld(plugin.getSettings().getWorldName() + "_the_end") == null) {
Bukkit.getLogger().info("Creating " + plugin.getName() + "'s End World...");
if (plugin.getServer().getWorld(plugin.getSettings().getWorldName() + THE_END) == null) {
Bukkit.getLogger().info(CREATING + plugin.getName() + "'s End World...");
}
if (!plugin.getSettings().isEndIslands()) {
endWorld = WorldCreator.name(plugin.getSettings().getWorldName() + "_the_end").type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld();
endWorld = WorldCreator.name(plugin.getSettings().getWorldName() + THE_END).type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld();
} else {
endWorld = WorldCreator.name(plugin.getSettings().getWorldName() + "_the_end").type(WorldType.FLAT).generator(new ChunkGeneratorWorld(plugin))
endWorld = WorldCreator.name(plugin.getSettings().getWorldName() + THE_END).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(plugin))
.environment(World.Environment.THE_END).createWorld();
}
}
@ -62,22 +68,22 @@ public class IslandWorld {
Bukkit.getLogger().info("Trying to register generator with Multiverse ");
try {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mv import " + plugin.getSettings().getWorldName() + " normal -g " + plugin.getName());
MULTIVERSE_IMPORT + plugin.getSettings().getWorldName() + " normal -g " + plugin.getName());
if (!Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mv modify set generator " + plugin.getName() + " " + plugin.getSettings().getWorldName())) {
MULTIVERSE_SET_GENERATOR + plugin.getName() + " " + plugin.getSettings().getWorldName())) {
Bukkit.getLogger().severe("Multiverse is out of date! - Upgrade to latest version!");
}
if (netherWorld != null && plugin.getSettings().isNetherGenerate() && plugin.getSettings().isNetherIslands()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mv import " + plugin.getSettings().getWorldName() + "_nether nether -g " + plugin.getName());
MULTIVERSE_IMPORT + plugin.getSettings().getWorldName() + "_nether nether -g " + plugin.getName());
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mv modify set generator " + plugin.getName() + " " + plugin.getSettings().getWorldName() + "_nether");
MULTIVERSE_SET_GENERATOR + plugin.getName() + " " + plugin.getSettings().getWorldName() + NETHER);
}
if (endWorld != null && plugin.getSettings().isEndGenerate() && plugin.getSettings().isEndIslands()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mv import " + plugin.getSettings().getWorldName() + "_the_end end -g " + plugin.getName());
MULTIVERSE_IMPORT + plugin.getSettings().getWorldName() + "_the_end end -g " + plugin.getName());
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mv modify set generator " + plugin.getName() + " " + plugin.getSettings().getWorldName() + "_the_end");
MULTIVERSE_SET_GENERATOR + plugin.getName() + " " + plugin.getSettings().getWorldName() + THE_END);
}
} catch (Exception e) {
Bukkit.getLogger().severe("Not successfull! Disabling " + plugin.getName() + "!");
@ -103,7 +109,7 @@ public class IslandWorld {
*/
public World getNetherWorld() {
if (plugin.getSettings().isUseOwnGenerator()) {
return Bukkit.getServer().getWorld(plugin.getSettings().getWorldName() + "_nether");
return Bukkit.getServer().getWorld(plugin.getSettings().getWorldName() + NETHER);
}
return netherWorld;
}
@ -113,7 +119,7 @@ public class IslandWorld {
*/
public World getEndWorld() {
if (plugin.getSettings().isUseOwnGenerator()) {
return Bukkit.getServer().getWorld(plugin.getSettings().getWorldName() + "_the_end");
return Bukkit.getServer().getWorld(plugin.getSettings().getWorldName() + THE_END);
}
return endWorld;
}

View File

@ -124,8 +124,7 @@ public final class AddonsManager {
File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER + File.separator + addon.getDescription().getName());
// Obtain any locale files and save them
for (String localeFile : listJarYamlFiles(jar, "locales")) {
//plugin.getLogger().info("DEBUG: saving " + localeFile + " from jar");
for (String localeFile : listJarYamlFiles(jar, LOCALE_FOLDER)) {
addon.saveResource(localeFile, localeDir, false, true);
}
plugin.getLocalesManager().loadLocales(addon.getDescription().getName());

View File

@ -23,8 +23,6 @@ import us.tastybento.bskyblock.database.objects.Island;
*/
public class SafeSpotTeleport {
//private NMSAbstraction nms;
//private BSkyBlock plugin;
/**
* Teleport to a safe place and if it fails, show a failure message
* @param plugin
@ -58,6 +56,8 @@ public class SafeSpotTeleport {
}
/**
* Teleport to a safe spot on an island
*
* TODO: REFACTOR THIS!
* @param plugin
* @param entity