#459 Add other accounts command + Update config docs
This commit is contained in:
@@ -223,7 +223,11 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
player.setNoDamageTicks(0);
|
||||
|
||||
service.send(player, MessageKey.LOGIN_SUCCESS);
|
||||
displayOtherAccounts(auth, player);
|
||||
|
||||
// Other auths
|
||||
List<String> auths = dataSource.getAllAuthsByIp(auth.getIp());
|
||||
runCommandOtherAccounts(auths, player, auth.getIp());
|
||||
displayOtherAccounts(auths, player);
|
||||
|
||||
final String email = auth.getEmail();
|
||||
if (service.getProperty(EmailSettings.RECALL_PLAYERS)
|
||||
@@ -251,12 +255,29 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
}
|
||||
}
|
||||
|
||||
private void displayOtherAccounts(PlayerAuth auth, Player player) {
|
||||
if (!service.getProperty(RestrictionSettings.DISPLAY_OTHER_ACCOUNTS) || auth == null) {
|
||||
private void runCommandOtherAccounts(List<String> auths, Player player, String ip) {
|
||||
int threshold = service.getProperty(RestrictionSettings.OTHER_ACCOUNTS_CMD_THRESHOLD);
|
||||
String command = service.getProperty(RestrictionSettings.OTHER_ACCOUNTS_CMD);
|
||||
|
||||
if(threshold <= 1 || command.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (auths.size() >= threshold) {
|
||||
return;
|
||||
}
|
||||
|
||||
bukkitService.dispatchConsoleCommand(command
|
||||
.replaceAll("%playername%", player.getName())
|
||||
.replaceAll("%playerip%", ip)
|
||||
);
|
||||
}
|
||||
|
||||
private void displayOtherAccounts(List<String> auths, Player player) {
|
||||
if (!service.getProperty(RestrictionSettings.DISPLAY_OTHER_ACCOUNTS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> auths = dataSource.getAllAuthsByIp(auth.getIp());
|
||||
if (auths.size() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -308,4 +308,12 @@ public class BukkitService implements SettingsDependent {
|
||||
return Bukkit.getServer().getBanList(BanList.Type.IP).addBan(ip, reason, expires, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a command as console
|
||||
*
|
||||
* @param command the command
|
||||
*/
|
||||
public void dispatchConsoleCommand(String command) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.github.authme.configme.Comment;
|
||||
import com.github.authme.configme.SettingsHolder;
|
||||
import com.github.authme.configme.properties.Property;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
import static com.github.authme.configme.properties.PropertyInitializer.newListProperty;
|
||||
@@ -187,6 +188,14 @@ public class RestrictionSettings implements SettingsHolder {
|
||||
public static final Property<List<String>> UNRESTRICTED_NAMES =
|
||||
newLowercaseListProperty("settings.unrestrictions.UnrestrictedName");
|
||||
|
||||
@Comment("Threshold of the other accounts command, a value less than 1 means disabled.")
|
||||
public static final Property<Integer> OTHER_ACCOUNTS_CMD_THRESHOLD =
|
||||
newProperty("settings.restrictions.otherAccountsCmdThreshold", 0);
|
||||
|
||||
@Comment("The other accounts command, available variables: %playername%, %playerip%")
|
||||
public static final Property<String> OTHER_ACCOUNTS_CMD =
|
||||
newProperty("settings.restrictions.otherAccountsCmd",
|
||||
"say The player %playername% with ip %playerip% has multiple accounts!");
|
||||
|
||||
private RestrictionSettings() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user