forked from ChomeNS/chomens-bot-java
many owner names....
This commit is contained in:
parent
91c61a2aa7
commit
487b828c62
5 changed files with 39 additions and 15 deletions
|
@ -25,7 +25,7 @@ public class Configuration {
|
||||||
|
|
||||||
public ColorPalette colorPalette = new ColorPalette();
|
public ColorPalette colorPalette = new ColorPalette();
|
||||||
|
|
||||||
public String ownerName = "chayapak"; // mabe mabe
|
public List<String> ownerNames = new ArrayList<>();
|
||||||
|
|
||||||
public OwnerAuthentication ownerAuthentication = new OwnerAuthentication();
|
public OwnerAuthentication ownerAuthentication = new OwnerAuthentication();
|
||||||
|
|
||||||
|
|
|
@ -41,13 +41,20 @@ public class AuthPlugin extends PlayersPlugin.Listener {
|
||||||
bot.executor.scheduleAtFixedRate(this::check, 0, 1, TimeUnit.SECONDS);
|
bot.executor.scheduleAtFixedRate(this::check, 0, 1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSanitizedOwnerName() {
|
private List<String> getSanitizedOwnerName() {
|
||||||
return bot.config.ownerName.replaceAll("§[a-f0-9rlonmk]", "");
|
return bot.config.ownerNames.stream().map(each -> each.replaceAll("§[a-f0-9rlonmk]", "")).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playerJoined(PlayerEntry target) {
|
public void playerJoined(PlayerEntry target) {
|
||||||
if (!target.profile.getName().equals(getSanitizedOwnerName()) || !bot.options.useCore) return;
|
boolean has = false;
|
||||||
|
for (String name : getSanitizedOwnerName()) {
|
||||||
|
if (!target.profile.getName().equals(name) || !bot.options.useCore) continue;
|
||||||
|
|
||||||
|
has = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!has) return;
|
||||||
|
|
||||||
bot.executor.schedule(() -> sendVerificationMessage(target, true), 2, TimeUnit.SECONDS);
|
bot.executor.schedule(() -> sendVerificationMessage(target, true), 2, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +84,14 @@ public class AuthPlugin extends PlayersPlugin.Listener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playerLeft(PlayerEntry target) {
|
public void playerLeft(PlayerEntry target) {
|
||||||
if (!target.profile.getName().equals(getSanitizedOwnerName())) return;
|
boolean has = false;
|
||||||
|
for (String name : getSanitizedOwnerName()) {
|
||||||
|
if (!target.profile.getName().equals(name) || !bot.options.useCore) continue;
|
||||||
|
|
||||||
|
has = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!has) return;
|
||||||
|
|
||||||
hasCorrectHash = false;
|
hasCorrectHash = false;
|
||||||
started = false;
|
started = false;
|
||||||
|
@ -110,7 +124,8 @@ public class AuthPlugin extends PlayersPlugin.Listener {
|
||||||
private void check() {
|
private void check() {
|
||||||
if (!started) return;
|
if (!started) return;
|
||||||
|
|
||||||
final PlayerEntry entry = bot.players.getEntry(getSanitizedOwnerName());
|
for (String name : getSanitizedOwnerName()) {
|
||||||
|
final PlayerEntry entry = bot.players.getEntry(name);
|
||||||
|
|
||||||
if (entry == null) return;
|
if (entry == null) return;
|
||||||
|
|
||||||
|
@ -123,4 +138,5 @@ public class AuthPlugin extends PlayersPlugin.Listener {
|
||||||
bot.filter.deOp(entry);
|
bot.filter.deOp(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class ConsolePlugin implements Completer {
|
||||||
Component.translatable(
|
Component.translatable(
|
||||||
"[%s] %s › %s",
|
"[%s] %s › %s",
|
||||||
Component.text(bot.username + " Console").color(NamedTextColor.GRAY),
|
Component.text(bot.username + " Console").color(NamedTextColor.GRAY),
|
||||||
Component.text(bot.config.ownerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName)),
|
Component.text(bot.config.ownerNames.get(0)).color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName)),
|
||||||
Component.text(line).color(NamedTextColor.GRAY)
|
Component.text(line).color(NamedTextColor.GRAY)
|
||||||
).color(NamedTextColor.DARK_GRAY)
|
).color(NamedTextColor.DARK_GRAY)
|
||||||
);
|
);
|
||||||
|
|
|
@ -56,9 +56,14 @@ public class TrustedPlugin extends PlayersPlugin.Listener {
|
||||||
public void playerJoined (PlayerEntry target) {
|
public void playerJoined (PlayerEntry target) {
|
||||||
if (!list.contains(target.profile.getName())) return;
|
if (!list.contains(target.profile.getName())) return;
|
||||||
|
|
||||||
|
boolean doesntHaveOwner = true;
|
||||||
|
for (String name : bot.config.ownerNames) {
|
||||||
|
if (target.profile.getName().equals(name)) doesntHaveOwner = false;
|
||||||
|
}
|
||||||
|
|
||||||
// based (VERY)
|
// based (VERY)
|
||||||
Component component;
|
Component component;
|
||||||
if (!target.profile.getName().equals(bot.config.ownerName)) {
|
if (doesntHaveOwner) {
|
||||||
component = Component.translatable(
|
component = Component.translatable(
|
||||||
"Hello, %s!",
|
"Hello, %s!",
|
||||||
Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
|
Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
|
||||||
|
|
|
@ -49,7 +49,10 @@ colorPalette:
|
||||||
number: 'gold'
|
number: 'gold'
|
||||||
ownerName: 'green'
|
ownerName: 'green'
|
||||||
|
|
||||||
ownerName: 'chayapak' # currently this is only used in the console
|
# currently this is only used in the console
|
||||||
|
ownerNames:
|
||||||
|
# don't leave this array blank or it can cause errors
|
||||||
|
- 'chayapak'
|
||||||
|
|
||||||
ownerAuthentication:
|
ownerAuthentication:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
Loading…
Reference in a new issue