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 {
|
public class PlayerJumpEvent extends PlayerEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
|
|
||||||
public PlayerJumpEvent(Player player) {
|
public PlayerJumpEvent(Player player) {
|
||||||
|
@ -44,6 +45,12 @@ public class PlayerJumpEvent extends PlayerEvent implements Cancellable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
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.length < 1) return null;
|
||||||
if (args[0].equals("stats") && args.length == 2) {
|
if (args[0].equals("stats") && args.length == 2) {
|
||||||
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
||||||
|
if (info == null) return placeholderNoData;
|
||||||
return getValue(info, args[1]);
|
return getValue(info, args[1]);
|
||||||
} else if (args[0].equals("stats") && args.length == 3) {
|
} else if (args[0].equals("stats") && args.length == 3) {
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
|
@ -62,6 +63,7 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
||||||
} else if (args[0].equals("rank-place") && args.length == 2) {
|
} else if (args[0].equals("rank-place") && args.length == 2) {
|
||||||
if (getRanking(args[1]) == null) { return placeholderError; }
|
if (getRanking(args[1]) == null) { return placeholderError; }
|
||||||
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
||||||
|
if (info == null) return placeholderNoData;
|
||||||
if (getValue(info, args[1]).equals("0")) { return "-"; }
|
if (getValue(info, args[1]).equals("0")) { return "-"; }
|
||||||
Integer count = database.getGameData().getRanking(getRanking(args[1]), player.getUniqueId());
|
Integer count = database.getGameData().getRanking(getRanking(args[1]), player.getUniqueId());
|
||||||
if (count == null) { return placeholderNoData; }
|
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; }
|
try { uuid = Main.getInstance().getServer().getOfflinePlayer(args[2]).getUniqueId(); } catch (Exception e) { return placeholderError; }
|
||||||
if (getRanking(args[1]) == null) { return placeholderError; }
|
if (getRanking(args[1]) == null) { return placeholderError; }
|
||||||
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
||||||
|
if (info == null) return placeholderNoData;
|
||||||
if (getValue(info, args[1]).equals("0")) { return "-"; }
|
if (getValue(info, args[1]).equals("0")) { return "-"; }
|
||||||
Integer count = database.getGameData().getRanking(getRanking(args[1]), uuid);
|
Integer count = database.getGameData().getRanking(getRanking(args[1]), uuid);
|
||||||
if (count == null) { return placeholderNoData; }
|
if (count == null) { return placeholderNoData; }
|
||||||
|
|
|
@ -78,28 +78,28 @@ public class WorldLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String save() {
|
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);
|
File current = new File(Main.getInstance().getWorldContainer()+File.separator+ mapName);
|
||||||
if (current.exists()) {
|
if (current.exists()) {
|
||||||
try {
|
try {
|
||||||
File destenation = new File(Main.getInstance().getWorldContainer()+File.separator+ saveName);
|
File destination = new File(Main.getInstance().getWorldContainer()+File.separator+ saveName);
|
||||||
File temp_destenation = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ saveName);
|
File temp_destination = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ saveName);
|
||||||
copyFileFolder("region",true);
|
copyFileFolder("region",true);
|
||||||
copyFileFolder("entities",true);
|
copyFileFolder("entities",true);
|
||||||
copyFileFolder("datapacks",false);
|
copyFileFolder("datapacks",false);
|
||||||
|
copyFileFolder("data",false);
|
||||||
File srcFile = new File(current, "level.dat");
|
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);
|
copyFile(srcFile,destFile);
|
||||||
if (destenation.exists()) {
|
if (destination.exists()) {
|
||||||
deleteDirectory(destenation);
|
deleteDirectory(destination);
|
||||||
if (!destenation.mkdir()) {
|
|
||||||
throw new RuntimeException("Failed to create directory: "+destenation.getPath());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(!destenation.delete()){
|
|
||||||
throw new RuntimeException("Unable to delete folder: "+destenation.getPath());
|
if (!temp_destination.renameTo(destination)) {
|
||||||
}
|
throw new RuntimeException("Failed to rename directory: "+temp_destination.getPath());
|
||||||
if (!temp_destenation.renameTo(destenation)) {
|
|
||||||
throw new RuntimeException("Failed to rename directory: "+temp_destenation.getPath());
|
|
||||||
}
|
}
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in a new issue