refactor: general improvements, fix spacing inconsistencies
This commit is contained in:
parent
cd0f60bd13
commit
2f4ca0d0f9
39 changed files with 498 additions and 498 deletions
|
@ -20,8 +20,7 @@
|
|||
package net.tylermurphy.hideAndSeek.util;
|
||||
|
||||
public enum Status {
|
||||
STANDBY,
|
||||
STARTING,
|
||||
PLAYING,
|
||||
ENDING
|
||||
|
||||
STANDBY, STARTING, PLAYING, ENDING
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package net.tylermurphy.hideAndSeek.util;
|
||||
|
||||
public enum WinType {
|
||||
HIDER_WIN,
|
||||
SEEKER_WIN,
|
||||
NONE
|
||||
|
||||
HIDER_WIN, SEEKER_WIN, NONE
|
||||
|
||||
}
|
||||
|
|
|
@ -25,42 +25,43 @@ import org.bukkit.World;
|
|||
import org.bukkit.WorldCreator;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||
|
||||
public class WorldLoader {
|
||||
|
||||
final String mapname;
|
||||
final String savename;
|
||||
final String mapName;
|
||||
final String saveName;
|
||||
|
||||
public WorldLoader(String mapname) {
|
||||
this.mapname = mapname;
|
||||
this.savename = "hideandseek_"+mapname;
|
||||
public WorldLoader(String mapName) {
|
||||
this.mapName = mapName;
|
||||
this.saveName = "hideandseek_"+ mapName;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return Bukkit.getServer().getWorld(savename);
|
||||
return Bukkit.getServer().getWorld(saveName);
|
||||
}
|
||||
|
||||
public void unloadMap() {
|
||||
World world = Bukkit.getServer().getWorld(savename);
|
||||
World world = Bukkit.getServer().getWorld(saveName);
|
||||
if (world == null) {
|
||||
Main.plugin.getLogger().warning(savename + " already unloaded.");
|
||||
Main.plugin.getLogger().warning(saveName + " already unloaded.");
|
||||
return;
|
||||
}
|
||||
if (Bukkit.getServer().unloadWorld(world, false)) {
|
||||
Main.plugin.getLogger().info("Successfully unloaded " + savename);
|
||||
Main.plugin.getLogger().info("Successfully unloaded " + saveName);
|
||||
}else{
|
||||
Main.plugin.getLogger().severe("COULD NOT UNLOAD " + savename);
|
||||
Main.plugin.getLogger().severe("COULD NOT UNLOAD " + saveName);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadMap() {
|
||||
Bukkit.getServer().createWorld(new WorldCreator(savename).generator(new VoidGenerator()));
|
||||
World world = Bukkit.getServer().getWorld(savename);
|
||||
Bukkit.getServer().createWorld(new WorldCreator(saveName).generator(new VoidGenerator()));
|
||||
World world = Bukkit.getServer().getWorld(saveName);
|
||||
if (world == null) {
|
||||
Main.plugin.getLogger().severe("COULD NOT LOAD " + savename);
|
||||
Main.plugin.getLogger().severe("COULD NOT LOAD " + saveName);
|
||||
return;
|
||||
}
|
||||
world.setAutoSave(false);
|
||||
|
@ -72,11 +73,11 @@ public class WorldLoader {
|
|||
}
|
||||
|
||||
public String save() {
|
||||
File current = new File(Main.root+File.separator+mapname);
|
||||
File current = new File(Main.root+File.separator+ mapName);
|
||||
if (current.exists()) {
|
||||
try {
|
||||
File destenation = new File(Main.root+File.separator+savename);
|
||||
File temp_destenation = new File(Main.root+File.separator+"temp_"+savename);
|
||||
File destenation = new File(Main.root+File.separator+ saveName);
|
||||
File temp_destenation = new File(Main.root+File.separator+"temp_"+ saveName);
|
||||
copyFileFolder("region",true);
|
||||
copyFileFolder("entities",true);
|
||||
copyFileFolder("datapacks",false);
|
||||
|
@ -103,8 +104,8 @@ public class WorldLoader {
|
|||
}
|
||||
|
||||
private void copyFileFolder(String name, Boolean isMca) throws IOException {
|
||||
File region = new File(Main.root+File.separator+mapname+File.separator+name);
|
||||
File temp = new File(Main.root+File.separator+"temp_"+savename+File.separator+name);
|
||||
File region = new File(Main.root+File.separator+ mapName +File.separator+name);
|
||||
File temp = new File(Main.root+File.separator+"temp_"+ saveName +File.separator+name);
|
||||
System.out.println(region.getAbsolutePath());
|
||||
System.out.println(temp.getAbsolutePath());
|
||||
if (region.exists() && region.isDirectory()) {
|
||||
|
@ -145,8 +146,8 @@ public class WorldLoader {
|
|||
}
|
||||
|
||||
private void copyFile(File source, File target) throws IOException {
|
||||
InputStream in = new FileInputStream(source);
|
||||
OutputStream out = new FileOutputStream(target);
|
||||
InputStream in = Files.newInputStream(source.toPath());
|
||||
OutputStream out = Files.newOutputStream(target.toPath());
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = in.read(buffer)) > 0)
|
||||
|
|
Loading…
Reference in a new issue