mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-29 19:46:42 +00:00
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:
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
@ -47,15 +48,11 @@ import org.bukkit.util.Vector;
|
||||
public class ItemFun extends FreedomService
|
||||
{
|
||||
|
||||
public List<Player> explosivePlayers = new ArrayList<>();
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
private final Map<String, List<String>> cooldownTracker = new HashMap<>();
|
||||
|
||||
private final Map<Player, Float> orientationTracker = new HashMap<>();
|
||||
|
||||
private final List<UUID> FIRE_BALL_UUIDS = new ArrayList<>();
|
||||
public List<Player> explosivePlayers = new ArrayList<>();
|
||||
|
||||
private void cooldown(Player player, ShopItem item, int seconds)
|
||||
{
|
||||
@ -282,7 +279,7 @@ public class ItemFun extends FreedomService
|
||||
didHit = true;
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
catch (IllegalArgumentException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -294,7 +291,7 @@ public class ItemFun extends FreedomService
|
||||
{
|
||||
if (sound.toString().contains("HIT"))
|
||||
{
|
||||
playerLoc.getWorld().playSound(randomOffset(playerLoc, 5.0), sound, 20f, randomDoubleRange(0.5, 2.0).floatValue());
|
||||
Objects.requireNonNull(playerLoc.getWorld()).playSound(randomOffset(playerLoc), sound, 20f, randomDoubleRange(0.5, 2.0).floatValue());
|
||||
}
|
||||
}
|
||||
cooldown(player, ShopItem.CLOWN_FISH, 30);
|
||||
@ -329,9 +326,10 @@ public class ItemFun extends FreedomService
|
||||
}
|
||||
if (arrow != null && (arrow.getShooter() instanceof Player))
|
||||
{
|
||||
if (explosivePlayers.contains((Player)arrow.getShooter()))
|
||||
//Redundant Player cast is required to avoid suspicious method calls.
|
||||
if (explosivePlayers.contains(arrow.getShooter()))
|
||||
{
|
||||
arrow.getLocation().getWorld().createExplosion(arrow.getLocation().getX(), arrow.getLocation().getY(), arrow.getLocation().getZ(), ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue(), false, ConfigEntry.ALLOW_EXPLOSIONS.getBoolean());
|
||||
Objects.requireNonNull(arrow.getLocation().getWorld()).createExplosion(arrow.getLocation().getX(), arrow.getLocation().getY(), arrow.getLocation().getZ(), ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue(), false, ConfigEntry.ALLOW_EXPLOSIONS.getBoolean());
|
||||
arrow.remove();
|
||||
}
|
||||
}
|
||||
@ -355,9 +353,9 @@ public class ItemFun extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
private Location randomOffset(Location a, double magnitude)
|
||||
private Location randomOffset(Location a)
|
||||
{
|
||||
return a.clone().add(randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude);
|
||||
return a.clone().add(randomDoubleRange(-1.0, 1.0) * 5.0, randomDoubleRange(-1.0, 1.0) * 5.0, randomDoubleRange(-1.0, 1.0) * 5.0);
|
||||
}
|
||||
|
||||
private Double randomDoubleRange(double min, double max)
|
||||
|
@ -3,8 +3,7 @@ package me.totalfreedom.totalfreedommod.fun;
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import org.bukkit.block.Block;
|
||||
@ -20,11 +19,14 @@ public class Jumppads extends FreedomService
|
||||
public static final double DAMPING_COEFFICIENT = 0.8;
|
||||
//
|
||||
private final Map<Player, Boolean> pushMap = Maps.newHashMap();
|
||||
//
|
||||
@Getter
|
||||
@Setter
|
||||
private double strength = 1 + 0.1F;
|
||||
public HashMap<Player, JumpPadMode> players = new HashMap<>();
|
||||
//
|
||||
private final double strength = 1 + 0.1F;
|
||||
|
||||
public static double getDampingCoefficient()
|
||||
{
|
||||
return DAMPING_COEFFICIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
@ -56,7 +58,7 @@ public class Jumppads extends FreedomService
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final Block block = event.getTo().getBlock();
|
||||
final Block block = Objects.requireNonNull(event.getTo()).getBlock();
|
||||
final Vector velocity = player.getVelocity().clone();
|
||||
|
||||
if (players.get(event.getPlayer()) == JumpPadMode.MADGEEK)
|
||||
@ -118,7 +120,27 @@ public class Jumppads extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
public static enum JumpPadMode
|
||||
public Map<Player, Boolean> getPushMap()
|
||||
{
|
||||
return pushMap;
|
||||
}
|
||||
|
||||
public double getStrength()
|
||||
{
|
||||
return strength;
|
||||
}
|
||||
|
||||
public HashMap<Player, JumpPadMode> getPlayers()
|
||||
{
|
||||
return players;
|
||||
}
|
||||
|
||||
public void setPlayers(HashMap<Player, JumpPadMode> players)
|
||||
{
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
public enum JumpPadMode
|
||||
{
|
||||
|
||||
OFF(false), NORMAL_AND_SIDEWAYS(true), MADGEEK(true);
|
||||
|
@ -18,8 +18,6 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class Landminer extends FreedomService
|
||||
{
|
||||
|
||||
@Getter
|
||||
private final List<Landmine> landmines = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
@ -43,6 +41,7 @@ public class Landminer extends FreedomService
|
||||
landmines.remove(landmine);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
@ -95,6 +94,11 @@ public class Landminer extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
public List<Landmine> getLandmines()
|
||||
{
|
||||
return landmines;
|
||||
}
|
||||
|
||||
public static class Landmine
|
||||
{
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.fun;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
@ -53,7 +54,7 @@ public class Trailer extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
Block toBlock = event.getTo().getBlock();
|
||||
Block toBlock = Objects.requireNonNull(event.getTo()).getBlock();
|
||||
if (fromBlock.equals(toBlock))
|
||||
{
|
||||
return;
|
||||
|
Reference in New Issue
Block a user