Removed deprecated methods from custom world and fixed a missing Jedis check

This commit is contained in:
Focusvity 2022-03-19 20:38:09 +11:00
parent d669da9f28
commit 159ed046cb
No known key found for this signature in database
GPG Key ID: 85AD157561ABE94B
5 changed files with 36 additions and 32 deletions

View File

@ -175,28 +175,31 @@ public class PunishmentManager extends PlexBase
public List<Punishment> getActiveBans()
{
List<Punishment> punishments = Lists.newArrayList();
Jedis jedis = Plex.get().getRedisConnection().getJedis();
jedis.keys("*").forEach(key ->
{
try
{
UUID uuid = UUID.fromString(key);
String jsonPunishmentString = jedis.get(uuid.toString());
JSONObject object = new JSONObject(jsonPunishmentString);
object.getJSONObject(uuid.toString()).getJSONArray("punishments").forEach(json ->
{
Punishment punishment = Punishment.fromJson(json.toString());
if (punishment.isActive() && punishment.getType() == PunishmentType.BAN)
{
punishments.add(punishment);
}
});
}
catch (IllegalArgumentException ignored)
{
}
});
if (Plex.get().getRedisConnection().isEnabled())
{
Jedis jedis = Plex.get().getRedisConnection().getJedis();
jedis.keys("*").forEach(key ->
{
try
{
UUID uuid = UUID.fromString(key);
String jsonPunishmentString = jedis.get(uuid.toString());
JSONObject object = new JSONObject(jsonPunishmentString);
object.getJSONObject(uuid.toString()).getJSONArray("punishments").forEach(json ->
{
Punishment punishment = Punishment.fromJson(json.toString());
if (punishment.isActive() && punishment.getType() == PunishmentType.BAN)
{
punishments.add(punishment);
}
});
}
catch (IllegalArgumentException ignored)
{
}
});
}
return punishments;
}

View File

@ -17,6 +17,7 @@ public abstract class CustomChunkGenerator extends ChunkGenerator
this.populators = Arrays.asList(populators);
}
@Override
public List<BlockPopulator> getDefaultPopulators(World world)
{
return populators;

View File

@ -3,6 +3,8 @@ package dev.plex.world;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.WorldInfo;
import org.jetbrains.annotations.NotNull;
public abstract class FlatChunkGenerator extends CustomChunkGenerator
{
@ -12,9 +14,8 @@ public abstract class FlatChunkGenerator extends CustomChunkGenerator
}
@Override
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
public void generateSurface(WorldInfo worldInfo, Random random, int x, int z, ChunkData chunk)
{
ChunkData chunk = this.createChunkData(world);
for (int xx = 0; xx < 16; xx++)
{
for (int zz = 0; zz < 16; zz++)
@ -22,7 +23,6 @@ public abstract class FlatChunkGenerator extends CustomChunkGenerator
createLoopChunkData(xx, height, zz, chunk);
}
}
return chunk;
}
public abstract void createLoopChunkData(int x, int y, int z, ChunkData chunk);

View File

@ -3,7 +3,9 @@ package dev.plex.world;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.WorldInfo;
import org.bukkit.util.noise.PerlinNoiseGenerator;
import org.jetbrains.annotations.NotNull;
public abstract class NoiseChunkGenerator extends CustomChunkGenerator
{
@ -16,10 +18,9 @@ public abstract class NoiseChunkGenerator extends CustomChunkGenerator
}
@Override
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
public void generateNoise(WorldInfo worldInfo, Random random, int x, int z, ChunkData chunk)
{
ChunkData chunk = this.createChunkData(world);
PerlinNoiseGenerator generator = new PerlinNoiseGenerator(new Random(world.getSeed()));
PerlinNoiseGenerator generator = new PerlinNoiseGenerator(new Random(worldInfo.getSeed()));
for (int xx = 0; xx < 16; xx++)
{
for (int zz = 0; zz < 16; zz++)
@ -28,7 +29,6 @@ public abstract class NoiseChunkGenerator extends CustomChunkGenerator
createLoopChunkData(xx, height, zz, chunk);
}
}
return chunk;
}
public abstract void createLoopChunkData(int x, int y, int z, ChunkData chunk);

View File

@ -3,7 +3,9 @@ package dev.plex.world;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.WorldInfo;
import org.bukkit.util.noise.PerlinOctaveGenerator;
import org.jetbrains.annotations.NotNull;
public abstract class OctaveChunkGenerator extends CustomChunkGenerator
{
@ -16,10 +18,9 @@ public abstract class OctaveChunkGenerator extends CustomChunkGenerator
}
@Override
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkData chunk)
{
ChunkData chunk = this.createChunkData(world);
PerlinOctaveGenerator generator = new PerlinOctaveGenerator(new Random(world.getSeed()), options.getOctaves());
PerlinOctaveGenerator generator = new PerlinOctaveGenerator(new Random(worldInfo.getSeed()), options.getOctaves());
for (int xx = 0; xx < 16; xx++)
{
for (int zz = 0; zz < 16; zz++)
@ -28,7 +29,6 @@ public abstract class OctaveChunkGenerator extends CustomChunkGenerator
createLoopChunkData(xx, height, zz, chunk);
}
}
return chunk;
}
public abstract void createLoopChunkData(int x, int y, int z, ChunkData chunk);