#432 #547 Remove public IP cache map; make processes use ProcessService

- Create IP address manager for handling and caching IP addresses -> outside of the manager I do not want to care about caching details
- Make more processes use the ProcessService in favor of statically injected objects
This commit is contained in:
ljacqu
2016-03-01 22:41:32 +01:00
parent 86042070e9
commit aeb8307a46
20 changed files with 330 additions and 296 deletions
@@ -3,6 +3,7 @@ package fr.xephi.authme.command;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.help.HelpProvider;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.manager.IpAddressManager;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.PermissionsManager;
@@ -28,6 +29,7 @@ public class CommandService {
private final PasswordSecurity passwordSecurity;
private final PermissionsManager permissionsManager;
private final NewSetting settings;
private final IpAddressManager ipAddressManager;
/**
* Constructor.
@@ -41,8 +43,8 @@ public class CommandService {
* @param settings The settings manager
*/
public CommandService(AuthMe authMe, CommandMapper commandMapper, HelpProvider helpProvider, Messages messages,
PasswordSecurity passwordSecurity, PermissionsManager permissionsManager,
NewSetting settings) {
PasswordSecurity passwordSecurity, PermissionsManager permissionsManager, NewSetting settings,
IpAddressManager ipAddressManager) {
this.authMe = authMe;
this.messages = messages;
this.helpProvider = helpProvider;
@@ -50,6 +52,7 @@ public class CommandService {
this.passwordSecurity = passwordSecurity;
this.permissionsManager = permissionsManager;
this.settings = settings;
this.ipAddressManager = ipAddressManager;
}
/**
@@ -192,4 +195,8 @@ public class CommandService {
return settings;
}
public IpAddressManager getIpAddressManager() {
return ipAddressManager;
}
}
@@ -1,21 +1,18 @@
package fr.xephi.authme.command.executable.authme;
import java.util.List;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.util.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.util.Utils;
import java.util.List;
public class GetIpCommand implements ExecutableCommand {
@Override
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
final AuthMe plugin = AuthMe.getInstance();
// Get the player query
String playerName = (arguments.size() >= 1) ? arguments.get(0) : sender.getName();
@@ -25,9 +22,12 @@ public class GetIpCommand implements ExecutableCommand {
return;
}
// TODO ljacqu 20151212: Revise the messages (actual IP vs. real IP...?)
sender.sendMessage(player.getName() + "'s actual IP is : " + player.getAddress().getAddress().getHostAddress()
sender.sendMessage(player.getName() + "'s IP is: " + player.getAddress().getAddress().getHostAddress()
+ ":" + player.getAddress().getPort());
sender.sendMessage(player.getName() + "'s real IP is : " + plugin.getIP(player));
if (commandService.getProperty(HooksSettings.ENABLE_VERYGAMES_IP_CHECK)) {
sender.sendMessage(player.getName() + "'s real IP is: "
+ commandService.getIpAddressManager().getPlayerIp(player));
}
}
}