diff --git a/src/main/java/de/fanta/challenges/Challenges.java b/src/main/java/de/fanta/challenges/Challenges.java index 50453f9..505fbf2 100644 --- a/src/main/java/de/fanta/challenges/Challenges.java +++ b/src/main/java/de/fanta/challenges/Challenges.java @@ -73,7 +73,6 @@ private BackpackGui backpack; private ScoreBoardManager sbManager; private ScoreManager scoreManager; - private UUID texturepackid = null; private Player currentEditor; private OfflinePlayer firstEditor; @@ -192,22 +191,28 @@ if (plugin.getServerType() == ServerType.ADVENTURE) { File texturepack = new File("world/resources.zip"); if (texturepack.exists()) { - texturepackid = UUID.randomUUID(); - File texturepackdownload = new File("/home/web/fanta/AdventureMap-TexturePacks/" + texturepackid + "/"); - File temp = new File(texturepackid.toString()); - try { - FileUtils.forceMkdir(temp); - FileUtils.copyFileToDirectory(texturepack, temp, false); - File renameTP = new File(texturepackid.toString() + "/" + "resources.zip"); - File renamedTP = new File(texturepackid.toString() + "/" + texturepackid + ".zip"); - renameTP.renameTo(renamedTP); - if (temp.isDirectory()) { - FileUtils.moveDirectory(temp, texturepackdownload); - } else { - Bukkit.getLogger().info("Ordner nicht da!"); - } + File mapConfigFile = new File("plugins/Challenges/serverconfig.yml"); + YamlConfiguration mapConfig = YamlConfiguration.loadConfiguration(mapConfigFile); + String texturepackname = mapConfig.getString("displayItem.name"); + String textureID = texturepackname != null ? texturepackname.replace("ยง", "").replace(" ", "_") : UUID.randomUUID().toString(); - texturepacklink = "https://fantacs.de/AdventureMap-TexturePacks/" + texturepackid + "/" + texturepackid + ".zip"; + File texturepackdownload = new File("/home/web/fanta/AdventureMap-TexturePacks/" + textureID + "/"); + File temp = new File(textureID); + + try { + if (!texturepackdownload.isDirectory()) { + FileUtils.forceMkdir(temp); + FileUtils.copyFileToDirectory(texturepack, temp, false); + File renameTP = new File(textureID + "/" + "resources.zip"); + File renamedTP = new File(textureID + "/" + textureID + ".zip"); + renameTP.renameTo(renamedTP); + if (temp.isDirectory()) { + FileUtils.moveDirectory(temp, texturepackdownload); + } else { + Bukkit.getLogger().info("Ordner nicht da!"); + } + } + texturepacklink = "https://fantacs.de/AdventureMap-TexturePacks/" + textureID + "/" + textureID + ".zip"; } catch (IOException e) { e.printStackTrace(); } @@ -292,12 +297,6 @@ Bukkit.getPluginManager().callEvent(new ChallengeEventStatusChangedEvent(false)); getScoreManager().saveScores(null); } - if (texturepackid != null) { - File temp = new File(texturepackid.toString()); - if (temp.isDirectory()) { - temp.delete(); - } - } saveConfig(); getLogger().info("Plugin unloaded"); @@ -469,22 +468,6 @@ reset = false; } - public void delteTexturePack() { - if (texturepackid != null) { - File texturepackdownload = new File("/home/web/fanta/AdventureMap-TexturePacks/" + texturepackid); - if (texturepackdownload.isDirectory()) { - try { - FileUtils.deleteDirectory(texturepackdownload); - getLogger().info("Adventure TexturePack deleted. " + texturepackdownload.getAbsolutePath()); - } catch (IOException e) { - throw new RuntimeException(e); - } - - } - } - - } - public void setPvP(Boolean value) { for (World w : plugin.getServer().getWorlds()) { if (w != null) { diff --git a/src/main/java/de/fanta/challenges/commands/reset/ResetConfirmCommand.java b/src/main/java/de/fanta/challenges/commands/reset/ResetConfirmCommand.java index dd33da3..55f7e3e 100644 --- a/src/main/java/de/fanta/challenges/commands/reset/ResetConfirmCommand.java +++ b/src/main/java/de/fanta/challenges/commands/reset/ResetConfirmCommand.java @@ -54,9 +54,6 @@ } plugin.portPlayerToLobby(p); } - if (plugin.getServerType() == ServerType.ADVENTURE) { - plugin.delteTexturePack(); - } Config.setValue("World_Reset", true); for (String key : Config.getConfigurationSection("Saved_Locations").getKeys(false)) {