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