Removal of Lombok

Lombok implementation removal.

I have also gone through and replaced things with inline methods and variables, lambdas, and simplified loops down, removed unnecessary guard clauses, and overall cleaned up every single class. This took a long time, please do remember to follow proper naming conventions, don't include unnecessary guard clauses, follow exception rules and comment rules, and please PLEASE remember to use the DIAMOND OPERATOR rather than just inferring RAW TYPES!!!

Thank you!!
This commit is contained in:
Paldiu
2020-12-25 14:46:43 -05:00
parent 210b0f8b43
commit 5c0f77c7c5
170 changed files with 3302 additions and 2383 deletions

View File

@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.world;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Bukkit;
@ -38,6 +39,7 @@ public final class AdminWorld extends CustomWorld
super.sendToWorld(player);
}
@SuppressWarnings("deprecation")
@Override
protected World generateWorld()
{
@ -49,6 +51,7 @@ public final class AdminWorld extends CustomWorld
final World world = Bukkit.getServer().createWorld(worldCreator);
assert world != null;
world.setSpawnFlags(false, false);
world.setSpawnLocation(0, 50, 0);
@ -81,7 +84,7 @@ public final class AdminWorld extends CustomWorld
return true;
}
if (world == null || !event.getTo().getWorld().equals(world))
if (world == null || !Objects.equals(Objects.requireNonNull(event.getTo()).getWorld(), world))
{
return true;
}
@ -113,7 +116,7 @@ public final class AdminWorld extends CustomWorld
{
weatherMode.setWorldToWeather(getWorld());
}
catch (Exception ex)
catch (Exception ignored)
{
}
}
@ -131,7 +134,7 @@ public final class AdminWorld extends CustomWorld
{
timeOfDay.setWorldToTime(getWorld());
}
catch (Exception ex)
catch (Exception ignored)
{
}
}

View File

@ -25,11 +25,12 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;
import static java.lang.System.arraycopy;
public class CleanroomChunkGenerator extends ChunkGenerator
{
private Logger log = Logger.getLogger("Minecraft");
private final Logger log = Logger.getLogger("Minecraft");
private Material[] materials;
@ -51,7 +52,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator
if (id.length() > 0)
{
String tokens[] = id.split("[,]");
String[] tokens = id.split("[,]");
if ((tokens.length % 2) != 0)
{
@ -67,7 +68,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator
height = 64;
}
String materialTokens[] = tokens[i + 1].split("[:]", 2);
String[] materialTokens = tokens[i + 1].split("[:]", 2);
if (materialTokens.length == 2)
{
@ -127,7 +128,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator
}
@Override
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
public @NotNull ChunkData generateChunkData(World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome)
{
int maxHeight = world.getMaxHeight();
if (materials.length > maxHeight)
@ -149,7 +150,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator
}
@Override
public Location getFixedSpawnLocation(World world, Random random)
public Location getFixedSpawnLocation(World world, @NotNull Random random)
{
if (!world.isChunkLoaded(0, 0))
{

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.world;
import io.papermc.lib.PaperLib;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Bukkit;
@ -10,8 +9,6 @@ import org.bukkit.entity.Player;
public abstract class CustomWorld extends FreedomService
{
@Getter
private final String name;
//
private World world;
@ -59,4 +56,9 @@ public abstract class CustomWorld extends FreedomService
}
protected abstract World generateWorld();
public String getName()
{
return name;
}
}

View File

@ -23,6 +23,7 @@ public class Flatlands extends CustomWorld
super("flatlands");
}
@SuppressWarnings("deprecation")
@Override
protected World generateWorld()
{
@ -41,6 +42,7 @@ public class Flatlands extends CustomWorld
final World world = Bukkit.getServer().createWorld(worldCreator);
assert world != null;
world.setSpawnFlags(false, false);
world.setSpawnLocation(0, 50, 0);
@ -70,7 +72,7 @@ public class Flatlands extends CustomWorld
{
doFlatlandsWipe = plugin.sf.getSavedFlag("do_wipe_flatlands");
}
catch (Exception ex)
catch (Exception ignored)
{
}

View File

@ -29,6 +29,8 @@ public final class HubWorld extends CustomWorld
super.sendToWorld(player);
}
// TODO: Replace instances of org.bukkit.Sign with a non deprecated version. This might include more boilerplate.
@SuppressWarnings("deprecation")
@Override
protected World generateWorld()
{
@ -40,6 +42,7 @@ public final class HubWorld extends CustomWorld
final World world = server.createWorld(worldCreator);
assert world != null;
world.setSpawnFlags(false, false);
world.setSpawnLocation(0, 50, 0);
@ -73,7 +76,7 @@ public final class HubWorld extends CustomWorld
{
weatherMode.setWorldToWeather(getWorld());
}
catch (Exception ex)
catch (Exception ignored)
{
}
}
@ -91,7 +94,7 @@ public final class HubWorld extends CustomWorld
{
timeOfDay.setWorldToTime(getWorld());
}
catch (Exception ex)
catch (Exception ignored)
{
}
}

View File

@ -29,6 +29,8 @@ public final class MasterBuilderWorld extends CustomWorld
super.sendToWorld(player);
}
// TODO: Replace org.bukkit.Sign with a non deprecated version. This may require extra boilerplate.
@SuppressWarnings("deprecation")
@Override
protected World generateWorld()
{
@ -40,6 +42,7 @@ public final class MasterBuilderWorld extends CustomWorld
final World world = server.createWorld(worldCreator);
assert world != null;
world.setSpawnFlags(false, false);
world.setSpawnLocation(0, 50, 0);
@ -73,7 +76,7 @@ public final class MasterBuilderWorld extends CustomWorld
{
weatherMode.setWorldToWeather(getWorld());
}
catch (Exception ex)
catch (Exception ignored)
{
}
}
@ -91,7 +94,7 @@ public final class MasterBuilderWorld extends CustomWorld
{
timeOfDay.setWorldToTime(getWorld());
}
catch (Exception ex)
catch (Exception ignored)
{
}
}

View File

@ -78,7 +78,7 @@ public class WorldManager extends FreedomService
return;
}
}
catch (Exception ex)
catch (Exception ignored)
{
}
@ -106,7 +106,7 @@ public class WorldManager extends FreedomService
return;
}
}
catch (Exception ex)
catch (Exception ignored)
{
}

View File

@ -53,7 +53,7 @@ public class WorldRestrictions extends FreedomService
public boolean doRestrict(Player player)
{
if (!plugin.pl.getData(player).isMasterBuilder() && !plugin.pl.canManageMasterBuilders(player.getName()))
if (!plugin.pl.getData(player).isMasterBuilder() && plugin.pl.canManageMasterBuilders(player.getName()))
{
if (player.getWorld().equals(plugin.wm.masterBuilderWorld.getWorld()) || player.getWorld().equals(plugin.wm.hubworld.getWorld()))
{

View File

@ -29,18 +29,6 @@ public enum WorldTime
this.aliases = Arrays.asList(StringUtils.split(aliases, ","));
}
public int getTimeTicks()
{
return timeTicks;
}
public void setWorldToTime(World world)
{
long time = world.getTime();
time -= time % 24000;
world.setTime(time + 24000 + getTimeTicks());
}
public static WorldTime getByAlias(String needle)
{
needle = needle.toLowerCase();
@ -53,4 +41,16 @@ public enum WorldTime
}
return null;
}
public int getTimeTicks()
{
return timeTicks;
}
public void setWorldToTime(World world)
{
long time = world.getTime();
time -= time % 24000;
world.setTime(time + 24000 + getTimeTicks());
}
}

View File

@ -19,15 +19,6 @@ public enum WorldWeather
this.aliases = Arrays.asList(StringUtils.split(aliases, ","));
}
public void setWorldToWeather(World world)
{
world.setStorm(this == RAIN || this == STORM);
world.setWeatherDuration(this == RAIN || this == STORM ? 20 * 60 * 5 : 0);
world.setThundering(this == STORM);
world.setThunderDuration(this == STORM ? 20 * 60 * 5 : 0);
}
public static WorldWeather getByAlias(String needle)
{
needle = needle.toLowerCase();
@ -40,4 +31,13 @@ public enum WorldWeather
}
return null;
}
public void setWorldToWeather(World world)
{
world.setStorm(this == RAIN || this == STORM);
world.setWeatherDuration(this == RAIN || this == STORM ? 20 * 60 * 5 : 0);
world.setThundering(this == STORM);
world.setThunderDuration(this == STORM ? 20 * 60 * 5 : 0);
}
}