Prepare for Velocity 3.0.0 support
To so do, drop Velocity 1.0.x support.
This commit is contained in:
1 parent
669c8a769e
commit
616d25683f
4 files changed
+25
-29
No files matched your search
@@ -5,8 +5,8 @@ blossom {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "com.velocitypowered:velocity-api:1.0.0-SNAPSHOT"
|
||||
annotationProcessor "com.velocitypowered:velocity-api:1.0.0-SNAPSHOT"
|
||||
compileOnly "com.velocitypowered:velocity-api:1.1.0-SNAPSHOT"
|
||||
annotationProcessor "com.velocitypowered:velocity-api:1.1.0-SNAPSHOT"
|
||||
implementation project(":nuvotifier-api")
|
||||
implementation project(":nuvotifier-common")
|
||||
}
|
||||
@@ -254,8 +254,8 @@ public class VotifierPlugin implements VoteHandler, ProxyVotifierPlugin {
|
||||
this.scheduler = new VelocityScheduler(server, this);
|
||||
this.loggingAdapter = new SLF4JLogger(logger);
|
||||
|
||||
this.getServer().getCommandManager().register(new NVReloadCmd(this), "pnvreload");
|
||||
this.getServer().getCommandManager().register(new TestVoteCmd(this), "ptestvote");
|
||||
this.getServer().getCommandManager().register("pnvreload", new NVReloadCmd(this));
|
||||
this.getServer().getCommandManager().register("ptestvote", new TestVoteCmd(this));
|
||||
|
||||
if (!loadAndBind())
|
||||
gracefulExit();
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.vexsoftware.votifier.velocity.cmd;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.vexsoftware.votifier.velocity.VotifierPlugin;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class NVReloadCmd implements Command {
|
||||
public class NVReloadCmd implements SimpleCommand {
|
||||
|
||||
private final VotifierPlugin plugin;
|
||||
|
||||
@@ -16,17 +14,17 @@ public class NVReloadCmd implements Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, @NonNull String[] args) {
|
||||
sender.sendMessage(TextComponent.of("Reloading NuVotifier...").color(TextColor.GRAY));
|
||||
public void execute(SimpleCommand.Invocation invocation) {
|
||||
invocation.source().sendMessage(Component.text("Reloading NuVotifier...", NamedTextColor.GRAY));
|
||||
if (plugin.reload()) {
|
||||
sender.sendMessage(TextComponent.of("NuVotifier has been reloaded!").color(TextColor.DARK_GREEN));
|
||||
invocation.source().sendMessage(Component.text("NuVotifier has been reloaded!", NamedTextColor.DARK_GREEN));
|
||||
} else {
|
||||
sender.sendMessage(TextComponent.of("Looks like there was a problem reloading NuVotifier, check the console!").color(TextColor.DARK_RED));
|
||||
invocation.source().sendMessage(Component.text("Looks like there was a problem reloading NuVotifier, check the console!", NamedTextColor.DARK_RED));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSource sender, @NonNull String[] args) {
|
||||
return sender.hasPermission("nuvotifier.reload");
|
||||
public boolean hasPermission(SimpleCommand.Invocation invocation) {
|
||||
return invocation.source().hasPermission("nuvotifier.reload");
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.vexsoftware.votifier.velocity.cmd;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.net.VotifierSession;
|
||||
import com.vexsoftware.votifier.util.ArgsToVote;
|
||||
import com.vexsoftware.votifier.velocity.VotifierPlugin;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class TestVoteCmd implements Command {
|
||||
public class TestVoteCmd implements SimpleCommand {
|
||||
|
||||
private final VotifierPlugin plugin;
|
||||
|
||||
@@ -19,22 +17,22 @@ public class TestVoteCmd implements Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, @NonNull String[] args) {
|
||||
public void execute(SimpleCommand.Invocation invocation) {
|
||||
Vote v;
|
||||
try {
|
||||
v = ArgsToVote.parse(args);
|
||||
v = ArgsToVote.parse(invocation.arguments());
|
||||
} catch (IllegalArgumentException e) {
|
||||
sender.sendMessage(TextComponent.of("Error while parsing arguments to create test vote: " + e.getMessage()).color(TextColor.DARK_RED));
|
||||
sender.sendMessage(TextComponent.of("Usage hint: /testvote [username] [serviceName=?] [username=?] [address=?] [localTimestamp=?] [timestamp=?]").color(TextColor.GRAY));
|
||||
invocation.source().sendMessage(Component.text("Error while parsing arguments to create test vote: " + e.getMessage(), NamedTextColor.DARK_RED));
|
||||
invocation.source().sendMessage(Component.text("Usage hint: /testvote [username] [serviceName=?] [username=?] [address=?] [localTimestamp=?] [timestamp=?]", NamedTextColor.GRAY));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.onVoteReceived(v, VotifierSession.ProtocolVersion.TEST, "localhost.test");
|
||||
sender.sendMessage(TextComponent.of("Test vote executed: " + v.toString()).color(TextColor.GREEN));
|
||||
invocation.source().sendMessage(Component.text("Test vote executed: " + v.toString(), NamedTextColor.GREEN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
|
||||
return source.hasPermission("nuvotifier.testvote");
|
||||
public boolean hasPermission(SimpleCommand.Invocation invocation) {
|
||||
return invocation.source().hasPermission("nuvotifier.testvote");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user