mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-06-10 02:04:55 +00:00
aca3398d21
Version 5.0 This TotalFreedomMod release implements many changes. Most notably, the internals have been completely revamped. TotalFreedomMod now relies on the Aero library for core mechanics such as command handling and services. Another important change is the UUID system. In TotalFreedomMod Electrum, it has been completely removed. The core reason for this is that the system as a whole was very bugged. Additionally, it did not solve the primary reason for its conception: preserving player data when the player changes their username. This is because TotalFreedomMod servers usually run in offline-mode. This meaning that some of the players joining do not have a registerd Mojang UUID whatsoever. All in all, the UUID system was buggy, and it did not fix the reason it was implemented, so it has been completely removed. The admin list and the ban list now use usernames and IPs again. Lastly, many smaller changes have been implemented. Due to the amount of changes, they have not been named individualy. Please refer to the issues below for more details. Fixes #342 Fixes #350 Fixes #380 Fixes #684 Fixes #704 Fixes #716 Fixes #735 Fixes #745 Fixes #784 Fixes #765 Fixes #791 Fixes #805 Fixes #826 Fixes #883 Fixes #1524 Fixes #1534 Fixes #1536 Fixes #1538 Fixes #1545 Fixes #1546 Fixes #1568 Fixes #1627 Resolves #403 Resolves #435 Resolves #597 Resolves #603 Resolves #628 Resolves #690 Resolves #708 Resolves #747 Resolves #748 Resolves #749 Resolves #764 Resolves #767 Resolves #782 Resolves #809 Resolves #803 Resolves #811 Resolves #813 Resolves #830 Resolves #848 Resolves #856 Resolves #876 Resolves #908 Resolves #992 Resolves #1018 Resolves #1432 Resolves #1446 Resolves #1494 Resolves #1501 Resolves #1526 Resolves #1540 Resolves #1550 Resolves #1560 Resolves #1561 Resolves #1578 Resolves #1613
412 lines
9.1 KiB
Java
412 lines
9.1 KiB
Java
package me.totalfreedom.totalfreedommod.player;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import lombok.Getter;
|
|
import lombok.Setter;
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
import me.totalfreedom.totalfreedommod.caging.CageData;
|
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import net.pravian.aero.util.Ips;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.entity.Arrow;
|
|
import org.bukkit.entity.EntityType;
|
|
import org.bukkit.entity.LivingEntity;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
import org.bukkit.scheduler.BukkitTask;
|
|
|
|
public class FPlayer
|
|
{
|
|
|
|
public static final long AUTO_PURGE_TICKS = 5L * 60L * 20L;
|
|
|
|
@Getter
|
|
private final TotalFreedomMod plugin;
|
|
@Getter
|
|
private final String name;
|
|
@Getter
|
|
private final String ip;
|
|
//
|
|
@Setter
|
|
private Player player;
|
|
//
|
|
private BukkitTask unmuteTask;
|
|
@Getter
|
|
private final FreezeData freezeData = new FreezeData(this);
|
|
@Getter
|
|
private double fuckoffRadius = 0;
|
|
private int messageCount = 0;
|
|
private int totalBlockDestroy = 0;
|
|
private int totalBlockPlace = 0;
|
|
private int freecamDestroyCount = 0;
|
|
private int freecamPlaceCount = 0;
|
|
@Getter
|
|
private final CageData cageData = new CageData(this);
|
|
private boolean isOrbiting = false;
|
|
private double orbitStrength = 10.0;
|
|
private boolean mobThrowerEnabled = false;
|
|
private EntityType mobThrowerEntity = EntityType.PIG;
|
|
private double mobThrowerSpeed = 4.0;
|
|
private final List<LivingEntity> mobThrowerQueue = new ArrayList<>();
|
|
private BukkitTask mp44ScheduleTask = null;
|
|
private boolean mp44Armed = false;
|
|
private boolean mp44Firing = false;
|
|
private BukkitTask lockupScheduleTask = null;
|
|
private String lastMessage = "";
|
|
private boolean inAdminchat = false;
|
|
private boolean allCommandsBlocked = false;
|
|
@Getter
|
|
@Setter
|
|
private boolean superadminIdVerified = false;
|
|
private String lastCommand = "";
|
|
private boolean cmdspyEnabled = false;
|
|
private String tag = null;
|
|
private int warningCount = 0;
|
|
|
|
public FPlayer(TotalFreedomMod plugin, Player player)
|
|
{
|
|
this(plugin, player.getName(), Ips.getIp(player));
|
|
}
|
|
|
|
private FPlayer(TotalFreedomMod plugin, String name, String ip)
|
|
{
|
|
this.plugin = plugin;
|
|
this.name = name;
|
|
this.ip = ip;
|
|
}
|
|
|
|
public Player getPlayer()
|
|
{
|
|
if (player != null && !player.isOnline())
|
|
{
|
|
player = null;
|
|
}
|
|
|
|
if (player == null)
|
|
{
|
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers())
|
|
{
|
|
if (Ips.getIp(onlinePlayer).equals(ip))
|
|
{
|
|
player = onlinePlayer;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return player;
|
|
}
|
|
|
|
public boolean isOrbiting()
|
|
{
|
|
return isOrbiting;
|
|
}
|
|
|
|
public void startOrbiting(double strength)
|
|
{
|
|
this.isOrbiting = true;
|
|
this.orbitStrength = strength;
|
|
}
|
|
|
|
public void stopOrbiting()
|
|
{
|
|
this.isOrbiting = false;
|
|
}
|
|
|
|
public double orbitStrength()
|
|
{
|
|
return orbitStrength;
|
|
}
|
|
|
|
public boolean isFuckOff()
|
|
{
|
|
return fuckoffRadius > 0;
|
|
}
|
|
|
|
public void setFuckoff(double radius)
|
|
{
|
|
this.fuckoffRadius = radius;
|
|
}
|
|
|
|
public void disableFuckoff()
|
|
{
|
|
this.fuckoffRadius = 0;
|
|
}
|
|
|
|
public void resetMsgCount()
|
|
{
|
|
this.messageCount = 0;
|
|
}
|
|
|
|
public int incrementAndGetMsgCount()
|
|
{
|
|
return this.messageCount++;
|
|
}
|
|
|
|
public int incrementAndGetBlockDestroyCount()
|
|
{
|
|
return this.totalBlockDestroy++;
|
|
}
|
|
|
|
public void resetBlockDestroyCount()
|
|
{
|
|
this.totalBlockDestroy = 0;
|
|
}
|
|
|
|
public int incrementAndGetBlockPlaceCount()
|
|
{
|
|
return this.totalBlockPlace++;
|
|
}
|
|
|
|
public void resetBlockPlaceCount()
|
|
{
|
|
this.totalBlockPlace = 0;
|
|
}
|
|
|
|
public int incrementAndGetFreecamDestroyCount()
|
|
{
|
|
return this.freecamDestroyCount++;
|
|
}
|
|
|
|
public void resetFreecamDestroyCount()
|
|
{
|
|
this.freecamDestroyCount = 0;
|
|
}
|
|
|
|
public int incrementAndGetFreecamPlaceCount()
|
|
{
|
|
return this.freecamPlaceCount++;
|
|
}
|
|
|
|
public void resetFreecamPlaceCount()
|
|
{
|
|
this.freecamPlaceCount = 0;
|
|
}
|
|
|
|
public void enableMobThrower(EntityType mobThrowerCreature, double mobThrowerSpeed)
|
|
{
|
|
this.mobThrowerEnabled = true;
|
|
this.mobThrowerEntity = mobThrowerCreature;
|
|
this.mobThrowerSpeed = mobThrowerSpeed;
|
|
}
|
|
|
|
public void disableMobThrower()
|
|
{
|
|
this.mobThrowerEnabled = false;
|
|
}
|
|
|
|
public EntityType mobThrowerCreature()
|
|
{
|
|
return this.mobThrowerEntity;
|
|
}
|
|
|
|
public double mobThrowerSpeed()
|
|
{
|
|
return this.mobThrowerSpeed;
|
|
}
|
|
|
|
public boolean mobThrowerEnabled()
|
|
{
|
|
return this.mobThrowerEnabled;
|
|
}
|
|
|
|
public void enqueueMob(LivingEntity mob)
|
|
{
|
|
mobThrowerQueue.add(mob);
|
|
if (mobThrowerQueue.size() > 4)
|
|
{
|
|
LivingEntity oldmob = mobThrowerQueue.remove(0);
|
|
if (oldmob != null)
|
|
{
|
|
oldmob.damage(500.0);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void startArrowShooter(TotalFreedomMod plugin)
|
|
{
|
|
this.stopArrowShooter();
|
|
this.mp44ScheduleTask = new ArrowShooter(this.player).runTaskTimer(plugin, 1L, 1L);
|
|
this.mp44Firing = true;
|
|
}
|
|
|
|
public void stopArrowShooter()
|
|
{
|
|
if (this.mp44ScheduleTask != null)
|
|
{
|
|
this.mp44ScheduleTask.cancel();
|
|
this.mp44ScheduleTask = null;
|
|
}
|
|
this.mp44Firing = false;
|
|
}
|
|
|
|
public void armMP44()
|
|
{
|
|
this.mp44Armed = true;
|
|
this.stopArrowShooter();
|
|
}
|
|
|
|
public void disarmMP44()
|
|
{
|
|
this.mp44Armed = false;
|
|
this.stopArrowShooter();
|
|
}
|
|
|
|
public boolean isMP44Armed()
|
|
{
|
|
return this.mp44Armed;
|
|
}
|
|
|
|
public boolean toggleMP44Firing()
|
|
{
|
|
this.mp44Firing = !this.mp44Firing;
|
|
return mp44Firing;
|
|
}
|
|
|
|
public boolean isMuted()
|
|
{
|
|
return unmuteTask != null;
|
|
}
|
|
|
|
public void setMuted(boolean muted)
|
|
{
|
|
FUtil.cancel(unmuteTask);
|
|
unmuteTask = null;
|
|
|
|
if (!muted)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (getPlayer() == null)
|
|
{
|
|
return;
|
|
}
|
|
unmuteTask = new BukkitRunnable()
|
|
{
|
|
@Override
|
|
public void run()
|
|
{
|
|
FUtil.adminAction("TotalFreedom", "Unmuting " + getPlayer().getName(), false);
|
|
setMuted(false);
|
|
}
|
|
}.runTaskLater(plugin, AUTO_PURGE_TICKS);
|
|
}
|
|
|
|
public BukkitTask getLockupScheduleID()
|
|
{
|
|
return this.lockupScheduleTask;
|
|
}
|
|
|
|
public void setLockupScheduleId(BukkitTask id)
|
|
{
|
|
this.lockupScheduleTask = id;
|
|
}
|
|
|
|
public void setLastMessage(String message)
|
|
{
|
|
this.lastMessage = message;
|
|
}
|
|
|
|
public String getLastMessage()
|
|
{
|
|
return lastMessage;
|
|
}
|
|
|
|
public void setAdminChat(boolean inAdminchat)
|
|
{
|
|
this.inAdminchat = inAdminchat;
|
|
}
|
|
|
|
public boolean inAdminChat()
|
|
{
|
|
return this.inAdminchat;
|
|
}
|
|
|
|
public boolean allCommandsBlocked()
|
|
{
|
|
return this.allCommandsBlocked;
|
|
}
|
|
|
|
public void setCommandsBlocked(boolean commandsBlocked)
|
|
{
|
|
this.allCommandsBlocked = commandsBlocked;
|
|
}
|
|
|
|
public String getLastCommand()
|
|
{
|
|
return lastCommand;
|
|
}
|
|
|
|
public void setLastCommand(String lastCommand)
|
|
{
|
|
this.lastCommand = lastCommand;
|
|
}
|
|
|
|
public void setCommandSpy(boolean enabled)
|
|
{
|
|
this.cmdspyEnabled = enabled;
|
|
}
|
|
|
|
public boolean cmdspyEnabled()
|
|
{
|
|
return cmdspyEnabled;
|
|
}
|
|
|
|
public void setTag(String tag)
|
|
{
|
|
if (tag == null)
|
|
{
|
|
this.tag = null;
|
|
}
|
|
else
|
|
{
|
|
this.tag = FUtil.colorize(tag) + ChatColor.WHITE;
|
|
}
|
|
}
|
|
|
|
public String getTag()
|
|
{
|
|
return this.tag;
|
|
}
|
|
|
|
public int getWarningCount()
|
|
{
|
|
return this.warningCount;
|
|
}
|
|
|
|
public void incrementWarnings()
|
|
{
|
|
this.warningCount++;
|
|
|
|
if (this.warningCount % 2 == 0)
|
|
{
|
|
Player p = getPlayer();
|
|
p.getWorld().strikeLightning(p.getLocation());
|
|
FUtil.playerMsg(p, ChatColor.RED + "You have been warned at least twice now, make sure to read the rules at " + ConfigEntry.SERVER_BAN_URL.getString());
|
|
}
|
|
}
|
|
|
|
private class ArrowShooter extends BukkitRunnable
|
|
{
|
|
|
|
private final Player player;
|
|
|
|
private ArrowShooter(Player player)
|
|
{
|
|
this.player = player;
|
|
}
|
|
|
|
@Override
|
|
public void run()
|
|
{
|
|
Arrow shot = player.launchProjectile(Arrow.class);
|
|
shot.setVelocity(shot.getVelocity().multiply(2.0));
|
|
}
|
|
}
|
|
}
|