Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Add support for SignedVelocity
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Oct 17, 2023
1 parent f8dde2e commit f1ce19c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ org.gradle.parallel=true
org.gradle.daemon=true
javaVersion=16

plugin_version=2.6.2
plugin_version=2.6.3
plugin_archive=huskchat
plugin_description=A simple & customizable no-frills Minecraft chat system
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public VelocityHuskChat(@NotNull ProxyServer server, @NotNull org.slf4j.Logger l

@Subscribe
public void onProxyInitialization(@NotNull ProxyInitializeEvent event) {
// Check plugin compat
if (!isSigningPluginInstalled()) {
return;
}

// Load config and locale files
this.loadConfig();
this.eventDispatcher = new VelocityEventDispatcher(server);
Expand Down Expand Up @@ -137,6 +142,26 @@ public void onProxyInitialization(@NotNull ProxyInitializeEvent event) {
log(Level.INFO, "Enabled HuskChat version " + getVersion());
}

// Ensures a signing plugin is installed
private boolean isSigningPluginInstalled() {
boolean usvPresent = isPluginPresent("unsignedvelocity");
boolean svPresent = isPluginPresent("signedvelocity");
if (usvPresent && svPresent) {
log(Level.SEVERE, "Both UnsignedVelocity and SignedVelocity are present!\n" +
"Please uninstall UnsignedVelocity. HuskChat will now be disabled."
);
return false;
}
if (!(usvPresent || svPresent)) {
log(Level.WARNING, "Neither UnsignedVelocity nor SignedVelocity are present!\n" +
"Install SignedVelocity (https://modrinth.com/plugin/signedvelocity) for 1.19+ support.");
} else if (usvPresent) {
log(Level.WARNING, "UnsignedVelocity is deprecated; please install SignedVelocity " +
" (https://modrinth.com/plugin/signedvelocity) instead for better support.");
}
return true;
}

@NotNull
@Override
public Locales getLocales() {
Expand Down Expand Up @@ -259,7 +284,7 @@ public Optional<Player> findPlayer(@NotNull String username) {
} else {
final List<com.velocitypowered.api.proxy.Player> matchedPlayers = getProxyServer().matchPlayer(username)
.stream().filter(val -> val.getUsername().startsWith(username)).sorted().toList();
if (matchedPlayers.size() > 0) {
if (!matchedPlayers.isEmpty()) {
optionalPlayer = Optional.of(VelocityPlayer.adapt(matchedPlayers.get(0)));
} else {
optionalPlayer = Optional.empty();
Expand Down
6 changes: 5 additions & 1 deletion velocity/src/main/resources/velocity-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
"dependencies": [
{
"id": "unsignedvelocity",
"optional": false
"optional": true
},
{
"id": "signedvelocity",
"optional": true
},
{
"id": "luckperms",
Expand Down

0 comments on commit f1ce19c

Please sign in to comment.