fix: don't run seen (track players' IPs) when it doesn't exist (for ayunboom)
This commit is contained in:
@@ -83,6 +83,8 @@ public class PlayersPlugin implements Listener {
|
||||
final CompletableFuture<String> future = getPlayerIP(target, true);
|
||||
|
||||
future.thenApply(ip -> {
|
||||
if (ip == null) return null;
|
||||
|
||||
target.persistingData.ip = ip;
|
||||
|
||||
bot.listener.dispatch(listener -> listener.onQueriedPlayerIP(target, ip));
|
||||
@@ -106,7 +108,13 @@ public class PlayersPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (!bot.serverFeatures.hasEssentials) {
|
||||
if (
|
||||
!bot.serverFeatures.hasEssentials ||
|
||||
(
|
||||
!bot.serverFeatures.serverHasCommand("essentials:seen")
|
||||
&& !bot.serverFeatures.serverHasCommand("seen")
|
||||
)
|
||||
) {
|
||||
outputFuture.complete(null);
|
||||
return;
|
||||
}
|
||||
@@ -154,6 +162,7 @@ public class PlayersPlugin implements Listener {
|
||||
}
|
||||
|
||||
public final PlayerEntry getEntry (final String username) { return getEntry(username, true, true); }
|
||||
|
||||
public final PlayerEntry getEntry (final String username, final boolean checkUUID, final boolean checkPastUsernames) {
|
||||
synchronized (list) {
|
||||
for (final PlayerEntry candidate : list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.chayapak1.chomens_bot.plugins;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import me.chayapak1.chomens_bot.Bot;
|
||||
import me.chayapak1.chomens_bot.data.listener.Listener;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
@@ -9,9 +10,13 @@ import org.geysermc.mcprotocollib.protocol.data.game.command.CommandNode;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.command.CommandType;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundCommandsPacket;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ServerFeaturesPlugin implements Listener {
|
||||
private final Bot bot;
|
||||
|
||||
private final List<String> commands = new ObjectArrayList<>();
|
||||
|
||||
public boolean hasNamespaces = false;
|
||||
|
||||
public boolean hasEssentials = false;
|
||||
@@ -31,6 +36,8 @@ public class ServerFeaturesPlugin implements Listener {
|
||||
}
|
||||
|
||||
private void packetReceived (final ClientboundCommandsPacket packet) {
|
||||
commands.clear();
|
||||
|
||||
for (final CommandNode node : packet.getNodes()) {
|
||||
if (!node.isExecutable() || node.getType() != CommandType.LITERAL) continue;
|
||||
|
||||
@@ -38,6 +45,8 @@ public class ServerFeaturesPlugin implements Listener {
|
||||
|
||||
if (name == null) continue;
|
||||
|
||||
commands.add(name);
|
||||
|
||||
if (name.contains(":")) hasNamespaces = true;
|
||||
|
||||
if (!name.contains(":")) continue;
|
||||
@@ -65,10 +74,16 @@ public class ServerFeaturesPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean serverHasCommand (final String command) {
|
||||
return commands.contains(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected (final DisconnectedEvent event) {
|
||||
hasNamespaces = false;
|
||||
hasEssentials = false;
|
||||
hasExtras = false;
|
||||
hasIControlU = false;
|
||||
hasCommandSpy = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user