mapsave bug fixes for windows servers
This commit is contained in:
parent
416e459af2
commit
491e426ce9
3 changed files with 24 additions and 14 deletions
|
@ -26,6 +26,7 @@ import org.bukkit.event.player.PlayerEvent;
|
|||
|
||||
public class PlayerJumpEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancel = false;
|
||||
|
||||
public PlayerJumpEvent(Player player) {
|
||||
|
@ -44,6 +45,12 @@ public class PlayerJumpEvent extends PlayerEvent implements Cancellable {
|
|||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return null;
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
|||
if (args.length < 1) return null;
|
||||
if (args[0].equals("stats") && args.length == 2) {
|
||||
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
||||
if (info == null) return placeholderNoData;
|
||||
return getValue(info, args[1]);
|
||||
} else if (args[0].equals("stats") && args.length == 3) {
|
||||
UUID uuid;
|
||||
|
@ -62,6 +63,7 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
|||
} else if (args[0].equals("rank-place") && args.length == 2) {
|
||||
if (getRanking(args[1]) == null) { return placeholderError; }
|
||||
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
||||
if (info == null) return placeholderNoData;
|
||||
if (getValue(info, args[1]).equals("0")) { return "-"; }
|
||||
Integer count = database.getGameData().getRanking(getRanking(args[1]), player.getUniqueId());
|
||||
if (count == null) { return placeholderNoData; }
|
||||
|
@ -71,6 +73,7 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
|||
try { uuid = Main.getInstance().getServer().getOfflinePlayer(args[2]).getUniqueId(); } catch (Exception e) { return placeholderError; }
|
||||
if (getRanking(args[1]) == null) { return placeholderError; }
|
||||
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
||||
if (info == null) return placeholderNoData;
|
||||
if (getValue(info, args[1]).equals("0")) { return "-"; }
|
||||
Integer count = database.getGameData().getRanking(getRanking(args[1]), uuid);
|
||||
if (count == null) { return placeholderNoData; }
|
||||
|
|
|
@ -78,28 +78,28 @@ public class WorldLoader {
|
|||
}
|
||||
|
||||
public String save() {
|
||||
World world = Bukkit.getServer().getWorld(mapName);
|
||||
if(world == null){
|
||||
throw new RuntimeException("Invalid world to save: " + mapName);
|
||||
}
|
||||
File current = new File(Main.getInstance().getWorldContainer()+File.separator+ mapName);
|
||||
if (current.exists()) {
|
||||
try {
|
||||
File destenation = new File(Main.getInstance().getWorldContainer()+File.separator+ saveName);
|
||||
File temp_destenation = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ saveName);
|
||||
File destination = new File(Main.getInstance().getWorldContainer()+File.separator+ saveName);
|
||||
File temp_destination = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ saveName);
|
||||
copyFileFolder("region",true);
|
||||
copyFileFolder("entities",true);
|
||||
copyFileFolder("datapacks",false);
|
||||
copyFileFolder("data",false);
|
||||
File srcFile = new File(current, "level.dat");
|
||||
File destFile = new File(temp_destenation, "level.dat");
|
||||
File destFile = new File(temp_destination, "level.dat");
|
||||
copyFile(srcFile,destFile);
|
||||
if (destenation.exists()) {
|
||||
deleteDirectory(destenation);
|
||||
if (!destenation.mkdir()) {
|
||||
throw new RuntimeException("Failed to create directory: "+destenation.getPath());
|
||||
}
|
||||
if (destination.exists()) {
|
||||
deleteDirectory(destination);
|
||||
}
|
||||
if(!destenation.delete()){
|
||||
throw new RuntimeException("Unable to delete folder: "+destenation.getPath());
|
||||
}
|
||||
if (!temp_destenation.renameTo(destenation)) {
|
||||
throw new RuntimeException("Failed to rename directory: "+temp_destenation.getPath());
|
||||
|
||||
if (!temp_destination.renameTo(destination)) {
|
||||
throw new RuntimeException("Failed to rename directory: "+temp_destination.getPath());
|
||||
}
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in a new issue