Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Merge pull request #176 from Crypnotic/master
Add matchPlayer and matchServer
Dieser Commit ist enthalten in:
Commit
e2fa06fa17
@ -76,6 +76,22 @@ public interface ProxyServer {
|
|||||||
*/
|
*/
|
||||||
Collection<RegisteredServer> getAllServers();
|
Collection<RegisteredServer> getAllServers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matches all {@link Player}s whose names start with the provided partial name.
|
||||||
|
*
|
||||||
|
* @param partialName the partial name to check for
|
||||||
|
* @return a collection of mathed {@link Player}s
|
||||||
|
*/
|
||||||
|
Collection<Player> matchPlayer(String partialName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matches all {@link RegisteredServer}s whose names start with the provided partial name.
|
||||||
|
*
|
||||||
|
* @param partialName the partial name to check for
|
||||||
|
* @return a collection of mathed {@link RegisteredServer}s
|
||||||
|
*/
|
||||||
|
Collection<RegisteredServer> matchServer(String partialName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a server with this proxy. A server with this name should not already exist.
|
* Registers a server with this proxy. A server with this name should not already exist.
|
||||||
*
|
*
|
||||||
|
@ -50,13 +50,16 @@ import java.nio.file.Paths;
|
|||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.serializer.GsonComponentSerializer;
|
import net.kyori.text.serializer.GsonComponentSerializer;
|
||||||
@ -443,6 +446,34 @@ public class VelocityServer implements ProxyServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Player> matchPlayer(String partialName) {
|
||||||
|
Objects.requireNonNull(partialName);
|
||||||
|
|
||||||
|
Optional<Player> exactMatch = getPlayer(partialName);
|
||||||
|
if (exactMatch.isPresent()) {
|
||||||
|
return Collections.singleton(exactMatch.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
return getAllPlayers().stream().filter(p -> p.getUsername()
|
||||||
|
.regionMatches(true, 0, partialName, 0, partialName.length()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<RegisteredServer> matchServer(String partialName) {
|
||||||
|
Objects.requireNonNull(partialName);
|
||||||
|
|
||||||
|
Optional<RegisteredServer> exactMatch = getServer(partialName);
|
||||||
|
if (exactMatch.isPresent()) {
|
||||||
|
return Collections.singleton(exactMatch.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
return getAllServers().stream().filter(s -> s.getServerInfo().getName()
|
||||||
|
.regionMatches(true, 0, partialName, 0, partialName.length()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Player> getAllPlayers() {
|
public Collection<Player> getAllPlayers() {
|
||||||
return ImmutableList.copyOf(connectionsByUuid.values());
|
return ImmutableList.copyOf(connectionsByUuid.values());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren