Skip to content

Commit

Permalink
Update to Velocity 3.0.1 (resolves #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
MTM123 committed Jul 18, 2021
1 parent 0ad6cb9 commit c0e6032
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fr.xephi</groupId>
<artifactId>authmevelocity</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>

<name>AuthMeVelocity</name>
<description>Velocity addon for AuthMe!</description>
Expand Down Expand Up @@ -232,7 +232,7 @@
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>1.1.3-SNAPSHOT</version>
<version>3.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/fr/xephi/authmevelocity/AuthMeVelocity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import ch.jalu.injector.Injector;
import ch.jalu.injector.InjectorBuilder;
import com.google.inject.Inject;
import com.velocitypowered.api.command.CommandManager;
import com.velocitypowered.api.command.CommandMeta;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Plugin;
Expand Down Expand Up @@ -72,7 +74,11 @@ public void onInit(ProxyInitializeEvent event) {
}

// Register commands
proxy.getCommandManager().register(injector.getSingleton(VelocityReloadCommand.class), "abreloadproxy");
CommandManager commandManager = proxy.getCommandManager();
CommandMeta meta = commandManager.metaBuilder("abreloadproxy")
.aliases("authmevelocityreload", "amvreload", "amvr")
.build();
commandManager.register(meta, new VelocityReloadCommand(settings));

// Registering event listeners
proxy.getChannelRegistrar().register(AUTHME_CHANNEL, LEGACY_AUTHME);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package fr.xephi.authmevelocity.commands;

import ch.jalu.configme.SettingsManager;
import com.velocitypowered.api.command.Command;
import com.velocitypowered.api.command.CommandSource;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import org.checkerframework.checker.nullness.qual.NonNull;
import com.velocitypowered.api.command.RawCommand;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;

import javax.inject.Inject;
import java.util.List;

public class VelocityReloadCommand implements Command {
public class VelocityReloadCommand implements RawCommand {

private SettingsManager settings;

Expand All @@ -20,21 +17,16 @@ public VelocityReloadCommand(SettingsManager settings) {
}

@Override
public void execute(CommandSource commandSource, @NonNull String[] strings) {
public void execute(Invocation invocation) {
settings.reload();
commandSource.sendMessage(
TextComponent.of("AuthMeVelocity configuration reloaded!").color(TextColor.GREEN)
invocation.source().sendMessage(
Component.text("AuthMeVelocity configuration reloaded!").color(NamedTextColor.GREEN)
);
}

@Override
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) {
return null;
}

@Override
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
return source.hasPermission("authmevelocity.reload");
public boolean hasPermission(Invocation invocation) {
return invocation.source().hasPermission("authmevelocity.reload");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import fr.xephi.authmevelocity.config.VelocityConfigProperties;
import fr.xephi.authmevelocity.data.AuthPlayer;
import fr.xephi.authmevelocity.services.AuthPlayerManager;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;

import javax.inject.Inject;
import java.util.ArrayList;
Expand Down Expand Up @@ -173,7 +173,7 @@ public void onPlayerConnectingToServer(final ServerPreConnectEvent event) {
if (isServerSwitchRequiresAuth) {
event.setResult(ServerPreConnectEvent.ServerResult.denied());

final TextComponent reasonMessage = TextComponent.of(requiresAuthKickMessage).color(TextColor.RED);
final Component reasonMessage = Component.text(requiresAuthKickMessage).color(NamedTextColor.RED);

if (player.getCurrentServer().isPresent()) {
player.sendMessage(reasonMessage);
Expand Down

0 comments on commit c0e6032

Please sign in to comment.