This commit is contained in:
2025-09-23 18:05:45 +02:00
parent fa093731df
commit 8373cacc5f
2 changed files with 17 additions and 27 deletions

View File

@@ -218,7 +218,11 @@ public class PlayerDeathListener implements Listener {
} else if (plugin.playersInFfa.contains(player)) {
plugin.tpToSpawn(player);
plugin.playersInFfa.remove(player);
e.setDeathMessage("§c" + player.getName() + " §7meghalt §c" + e.getEntity().getKiller() + " §7által");
if (player.getKiller() != null) {
e.setDeathMessage("§c" + player.getName() + " §7meghalt §c" + player.getKiller() + " §7által");
} else {
e.setDeathMessage("");
}
} else {
e.setCancelled(true);
plugin.tpToSpawn(player);

View File

@@ -2,8 +2,10 @@ package hu.jgj52.pvpcore.Utils;
import hu.jgj52.pvpcore.Main;
import org.bukkit.*;
import org.bukkit.generator.ChunkGenerator;
import java.io.File;
import java.util.Random;
public class WorldReset {
private Main plugin;
@@ -14,16 +16,12 @@ public class WorldReset {
public boolean recreateArenaWorld() {
String worldName = "arenas";
try {
removeArenaWorld(worldName);
Bukkit.getScheduler().runTaskLater(plugin, () -> {
createArenaWorld(worldName);
}, 20L);
return true;
} catch (Exception e) {
plugin.getLogger().severe("Error recreating arena world: " + e.getMessage());
e.printStackTrace();
@@ -34,22 +32,17 @@ public class WorldReset {
private boolean removeArenaWorld(String worldName) {
try {
World world = Bukkit.getWorld(worldName);
if (world != null) {
world.getPlayers().forEach(player -> {
plugin.tpToSpawn(player);
player.sendMessage("§cszia resetel a map szoval tunes");
});
boolean unloaded = Bukkit.unloadWorld(world, false);
if (unloaded) {
File worldFolder = new File(Bukkit.getWorldContainer(), worldName);
if (worldFolder.exists()) {
deleteDirectory(worldFolder);
}
return true;
} else {
plugin.getLogger().warning("Failed to unload arena world.");
@@ -71,9 +64,7 @@ public class WorldReset {
.environment(World.Environment.NORMAL)
.generateStructures(false)
.generatorSettings("{\"layers\":[{\"block\":\"air\",\"height\":1}],\"biome\":\"plains\"}");
World world = creator.createWorld();
if (world != null) {
world.setSpawnFlags(false, false);
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
@@ -86,7 +77,6 @@ public class WorldReset {
plugin.getLogger().severe("Failed to create arena world!");
return false;
}
} catch (Exception e) {
plugin.getLogger().severe("Error creating arena world: " + e.getMessage());
e.printStackTrace();
@@ -96,7 +86,6 @@ public class WorldReset {
public boolean recreateFfaWorld() {
String worldName = "ffa";
try {
if (!removeFfaWorld(worldName)) {
plugin.getLogger().warning("Failed to remove FFA world!");
@@ -106,9 +95,7 @@ public class WorldReset {
Bukkit.getScheduler().runTaskLater(plugin, () -> {
createFfaWorld(worldName);
}, 100L);
return true;
} catch (Exception e) {
plugin.getLogger().severe("Error recreating FFA world: " + e.getMessage());
e.printStackTrace();
@@ -116,26 +103,20 @@ public class WorldReset {
}
}
private boolean removeFfaWorld(String worldName) {
try {
World world = Bukkit.getWorld(worldName);
if (world != null) {
world.getPlayers().forEach(player -> {
plugin.tpToSpawn(player);
player.sendMessage("§cszia resetel a map szoval tunes");
});
boolean unloaded = Bukkit.unloadWorld(world, false);
if (unloaded) {
File worldFolder = new File(Bukkit.getWorldContainer(), worldName);
if (worldFolder.exists()) {
deleteDirectory(worldFolder);
}
return true;
} else {
plugin.getLogger().warning("Failed to unload arena world.");
@@ -153,10 +134,9 @@ public class WorldReset {
private boolean createFfaWorld(String worldName) {
try {
WorldCreator creator = new WorldCreator(worldName)
.environment(World.Environment.NORMAL);
.environment(World.Environment.NORMAL)
.generator(new VoidGenerator());
World world = creator.createWorld();
if (world != null) {
world.setSpawnFlags(false, false);
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
@@ -172,7 +152,6 @@ public class WorldReset {
plugin.getLogger().severe("Failed to create arena world!");
return false;
}
} catch (Exception e) {
plugin.getLogger().severe("Error creating arena world: " + e.getMessage());
e.printStackTrace();
@@ -195,4 +174,11 @@ public class WorldReset {
}
return directory.delete();
}
}
public static class VoidGenerator extends ChunkGenerator {
@Override
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
return createChunkData(world);
}
}
}