mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 04:26:42 +00:00
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!!
78 lines
2.1 KiB
Java
78 lines
2.1 KiB
Java
package me.totalfreedom.totalfreedommod.freeze;
|
|
|
|
import java.util.Objects;
|
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import org.bukkit.GameMode;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
import org.bukkit.scheduler.BukkitTask;
|
|
import static me.totalfreedom.totalfreedommod.TotalFreedomMod.plugin;
|
|
import static me.totalfreedom.totalfreedommod.player.FPlayer.AUTO_PURGE_TICKS;
|
|
|
|
public class FreezeData
|
|
{
|
|
|
|
private final FPlayer fPlayer;
|
|
//
|
|
private Location location = null;
|
|
private BukkitTask unfreeze = null;
|
|
|
|
public FreezeData(FPlayer fPlayer)
|
|
{
|
|
this.fPlayer = fPlayer;
|
|
}
|
|
|
|
public boolean isFrozen()
|
|
{
|
|
return unfreeze != null;
|
|
}
|
|
|
|
public void setFrozen(boolean freeze)
|
|
{
|
|
final Player player = fPlayer.getPlayer();
|
|
if (player == null)
|
|
{
|
|
FLog.info("Could not freeze that player as they are not online!");
|
|
return;
|
|
}
|
|
|
|
FUtil.cancel(unfreeze);
|
|
unfreeze = null;
|
|
location = null;
|
|
|
|
if (!freeze)
|
|
{
|
|
if (fPlayer.getPlayer().getGameMode() != GameMode.CREATIVE)
|
|
{
|
|
FUtil.setFlying(player, false);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
location = player.getLocation(); // Blockify location
|
|
FUtil.setFlying(player, true); // Avoid infinite falling
|
|
|
|
unfreeze = new BukkitRunnable()
|
|
{
|
|
@Override
|
|
public void run()
|
|
{
|
|
if (!Objects.requireNonNull(plugin()).al.isAdminImpostor(player) && Objects.requireNonNull(plugin()).pl.isPlayerImpostor(player))
|
|
{
|
|
FUtil.adminAction("TotalFreedom", "Unfreezing " + player.getName(), false);
|
|
setFrozen(false);
|
|
}
|
|
}
|
|
|
|
}.runTaskLater(Objects.requireNonNull(plugin()), AUTO_PURGE_TICKS);
|
|
}
|
|
|
|
public Location getLocation()
|
|
{
|
|
return location;
|
|
}
|
|
} |