#459 Add other accounts command + Update config docs

This commit is contained in:
Gabriele C 2016-10-30 13:01:22 +01:00
parent 46af922fba
commit 2651786456
4 changed files with 55 additions and 11 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Sun Oct 23 21:08:57 CEST 2016. See docs/config/config.tpl.md -->
<!-- File auto-generated on Sun Oct 30 12:57:15 CET 2016. See docs/config/config.tpl.md -->
## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
@ -124,7 +124,7 @@ settings:
# The value 0 means an unlimited number of registrations!
maxRegPerIp: 1
# Minimum allowed username length
minNicknameLength: 4
minNicknameLength: 3
# Maximum allowed username length
maxNicknameLength: 16
# When this setting is enabled, online players can't be kicked out
@ -199,6 +199,10 @@ settings:
noTeleport: false
# Regex syntax for allowed chars in passwords
allowedPasswordCharacters: '[\x21-\x7E]*'
# Threshold of the other accounts command, a value less than 1 means disabled.
otherAccountsCmdThreshold: 0
# The other accounts command, available variables: %playername%, %playerip%
otherAccountsCmd: 'say The player %playername% with ip %playerip% has multiple accounts!'
# Log level: INFO, FINE, DEBUG. Use INFO for general messages,
# FINE for some additional detailed ones (like password failed),
# and DEBUG for debugging
@ -246,9 +250,11 @@ settings:
# AuthMe will update the password to the new password hash
supportOldPasswordHash: false
# Prevent unsafe passwords from being used; put them in lowercase!
# You should always set 'help' as unsafePassword due to possible conflicts.
# unsafePasswords:
# - '123456'
# - 'password'
# - 'help'
unsafePasswords:
- '123456'
- 'password'
@ -256,6 +262,7 @@ settings:
- '12345'
- '54321'
- '123456789'
- 'help'
registration:
# Enable registration on the server?
enabled: true
@ -378,7 +385,9 @@ Protection:
- 'A1'
# Do we need to enable automatic antibot system?
enableAntiBot: true
# Max number of players allowed to login in 5 secs
# The interval in seconds
antiBotInterval: 5
# Max number of players allowed to login in the interval
# before the AntiBot system is enabled automatically
antiBotSensibility: 10
# Duration in minutes of the antibot automatic system
@ -408,9 +417,6 @@ Security:
# Take care with this, if you set this to false,
# AuthMe will automatically disable and the server won't be protected!
stopServer: true
ReloadCommand:
# /reload support
useReloadCommandSupport: true
console:
# Remove passwords from console?
removePassword: true
@ -455,4 +461,4 @@ To change settings on a running server, save your changes to config.yml and use
---
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Oct 23 21:08:57 CEST 2016
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Oct 30 12:57:15 CET 2016

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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() {
}