This commit is contained in:
2025-09-23 18:20:14 +02:00
parent 8373cacc5f
commit 1a1243d467
2 changed files with 33 additions and 15 deletions

View File

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

View File

@@ -2,10 +2,8 @@ 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;
@@ -134,10 +132,11 @@ public class WorldReset {
private boolean createFfaWorld(String worldName) {
try {
WorldCreator creator = new WorldCreator(worldName)
.environment(World.Environment.NORMAL)
.generator(new VoidGenerator());
.environment(World.Environment.NORMAL);
World world = creator.createWorld();
if (world != null) {
world.setKeepSpawnInMemory(false);
world.setSpawnFlags(false, false);
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
world.setStorm(false);
@@ -147,11 +146,12 @@ public class WorldReset {
border.setCenter(0, 0);
border.setSize(300);
plugin.isFfaResetting = false;
pregenerate(world, 150);
return true;
} else {
}
plugin.getLogger().severe("Failed to create arena world!");
return false;
}
} catch (Exception e) {
plugin.getLogger().severe("Error creating arena world: " + e.getMessage());
e.printStackTrace();
@@ -159,6 +159,31 @@ public class WorldReset {
}
}
private void pregenerate(World world, int radius) {
Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
int x = -radius >> 4;
int z = -radius >> 4;
final int max = radius >> 4;
@Override
public void run() {
for (int i = 0; i < 5; i++) {
if (x > max) {
x = -max;
z++;
}
if (z > max) {
Bukkit.getScheduler().cancelTask(this.hashCode());
plugin.getLogger().info("FFA pregeneration done!");
return;
}
world.getChunkAtAsync(x, z);
x++;
}
}
}, 1L, 1L);
}
private boolean deleteDirectory(File directory) {
if (directory.exists()) {
File[] files = directory.listFiles();
@@ -174,11 +199,4 @@ 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);
}
}
}