TotalFreedomMod Electrum

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
This commit is contained in:
Jerom van der Sar
2016-05-12 21:40:39 +02:00
parent 924f718d5a
commit aca3398d21
109 changed files with 2112 additions and 2036 deletions

View File

@ -57,7 +57,6 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
final StringBuilder output = new StringBuilder();
output.append("Admin: ").append(name).append("\n")
.append("- Last Login Name: ").append(name).append("\n")
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
.append("- Custom Login Message: ").append(loginMessage).append("\n")

View File

@ -12,20 +12,15 @@ import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.Command_logs;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.ServicePriority;
public class AdminList extends FreedomService
@ -47,7 +42,7 @@ public class AdminList extends FreedomService
{
super(plugin);
this.config = new YamlConfig(TotalFreedomMod.plugin, CONFIG_FILENAME, true);
this.config = new YamlConfig(plugin, CONFIG_FILENAME, true);
}
@Override
@ -100,7 +95,7 @@ public class AdminList extends FreedomService
}
updateTables();
FLog.info("Loaded " + nameTable.size() + " admins (" + nameTable.size() + " active) and " + ipTable.size() + " IPs.");
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
}
public void save()
@ -119,17 +114,6 @@ public class AdminList extends FreedomService
config.save();
}
public void save(Admin admin)
{
if (!allAdmins.values().contains(admin))
{ // Ensure admin is present
addAdmin(admin, false);
}
admin.saveTo(config.createSection(admin.getConfigKey()));
config.save();
}
public synchronized boolean isAdminSync(CommandSender sender)
{
return isAdmin(sender);
@ -142,7 +126,9 @@ public class AdminList extends FreedomService
return true;
}
return getAdmin((Player) sender) != null;
Admin admin = getAdmin((Player) sender);
return admin != null && admin.isActive();
}
public boolean isSeniorAdmin(CommandSender sender)
@ -168,22 +154,41 @@ public class AdminList extends FreedomService
public Admin getAdmin(Player player)
{
// Find admin
String ip = Ips.getIp(player);
Admin admin = getEntryByIp(ip, true);
Admin admin = getEntryByName(player.getName());
if (admin == null && Bukkit.getOnlineMode())
// Admin by name
if (admin != null)
{
admin = getEntryByName(player.getName());
// Add new IP
if (admin != null)
// Check if we're in online mode,
// Or the players IP is in the admin entry
if (Bukkit.getOnlineMode() || admin.getIps().contains(ip))
{
admin.addIp(ip);
save(admin);
if (!admin.getIps().contains(ip))
{
// Add the new IP if we have to
admin.addIp(ip);
save();
updateTables();
}
return admin;
}
// Impostor
}
return admin;
// Admin by ip
admin = getEntryByIp(ip);
if (admin != null)
{
// Set the new username
admin.setName(player.getName());
save();
updateTables();
}
return null;
}
public Admin getEntryByName(String name)
@ -193,16 +198,15 @@ public class AdminList extends FreedomService
public Admin getEntryByIp(String ip)
{
return getEntryByIp(ip, false);
return ipTable.get(ip);
}
public Admin getEntryByIp(String needleIp, boolean fuzzy)
public Admin getEntryByIpFuzzy(String needleIp)
{
Admin admin = ipTable.get(needleIp);
if (admin != null || !fuzzy)
final Admin directAdmin = getEntryByIp(needleIp);
if (directAdmin != null)
{
return admin;
return directAdmin;
}
for (String ip : ipTable.keySet())
@ -212,7 +216,8 @@ public class AdminList extends FreedomService
return ipTable.get(ip);
}
}
return admin;
return null;
}
public void updateLastLogin(Player player)
@ -225,7 +230,7 @@ public class AdminList extends FreedomService
admin.setLastLogin(new Date());
admin.setName(player.getName());
save(admin);
save();
}
public boolean isAdminImpostor(Player player)
@ -245,11 +250,6 @@ public class AdminList extends FreedomService
}
public boolean addAdmin(Admin admin)
{
return addAdmin(admin, false);
}
public boolean addAdmin(Admin admin, boolean overwrite)
{
if (!admin.isValid())
{
@ -259,11 +259,6 @@ public class AdminList extends FreedomService
final String key = admin.getConfigKey();
if (!overwrite && allAdmins.containsKey(key))
{
return false;
}
// Store admin, update views
allAdmins.put(key, admin);
updateTables();
@ -327,28 +322,6 @@ public class AdminList extends FreedomService
return ipTable.keySet();
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
final Player player = event.getPlayer();
final FPlayer fPlayer = plugin.pl.getPlayer(player);
if (plugin.al.isAdmin(player))
{
// Verify strict IP match
if (plugin.al.isIdentityMatched(player))
{
fPlayer.setSuperadminIdVerified(true);
plugin.al.updateLastLogin(player);
}
else
{
fPlayer.setSuperadminIdVerified(false);
FUtil.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
}
}
}
public void deactivateOldEntries(boolean verbose)
{
for (Admin admin : allAdmins.values())
@ -372,7 +345,7 @@ public class AdminList extends FreedomService
}
admin.setActive(false);
Command_logs.deactivateSuperadmin(admin);
plugin.lv.deactivateSuperadmin(admin);
}
save();