diff --git a/Core/src/main/java/com/plotsquared/core/command/Dislike.java b/Core/src/main/java/com/plotsquared/core/command/Dislike.java index 3e4db188c..b69ebac2e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Dislike.java +++ b/Core/src/main/java/com/plotsquared/core/command/Dislike.java @@ -26,9 +26,17 @@ package com.plotsquared.core.command; import com.google.inject.Inject; +import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; +import com.plotsquared.core.util.Permissions; +import com.plotsquared.core.util.TabCompletions; import javax.annotation.Nonnull; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; @CommandDeclaration(command = "dislike", permission = "plots.dislike", @@ -47,4 +55,22 @@ public class Dislike extends SubCommand { return this.like.handleLike(player, args, false); } + @Override + public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { + if (args.length == 1) { + final List completions = new LinkedList<>(); + if (Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS)) { + completions.add("purge"); + } + final List commands = completions.stream().filter(completion -> completion.toLowerCase().startsWith(args[0].toLowerCase())) + .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) { + }).collect(Collectors.toCollection(LinkedList::new)); + if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) { + commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); + } + return commands; + } + return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); + } + } diff --git a/Core/src/main/java/com/plotsquared/core/command/Like.java b/Core/src/main/java/com/plotsquared/core/command/Like.java index f4b91a0a0..05d250ce2 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Like.java +++ b/Core/src/main/java/com/plotsquared/core/command/Like.java @@ -38,15 +38,19 @@ import com.plotsquared.core.plot.Rating; import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.Permissions; +import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.task.TaskManager; import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; @CommandDeclaration(command = "like", permission = "plots.like", @@ -126,7 +130,7 @@ public class Like extends SubCommand { if (oldRating != null) { player.sendMessage( TranslatableCaption.of("ratings.rating_already_exists"), - Template.of("value", plot.getId().toString()) + Template.of("plot", plot.getId().toString()) ); return; } @@ -199,4 +203,22 @@ public class Like extends SubCommand { return handleLike(player, args, true); } + @Override + public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { + if (args.length == 1) { + final List completions = new LinkedList<>(); + if (Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS)) { + completions.add("purge"); + } + final List commands = completions.stream().filter(completion -> completion.toLowerCase().startsWith(args[0].toLowerCase())) + .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) { + }).collect(Collectors.toCollection(LinkedList::new)); + if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) { + commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); + } + return commands; + } + return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); + } + } diff --git a/Core/src/main/java/com/plotsquared/core/command/Rate.java b/Core/src/main/java/com/plotsquared/core/command/Rate.java index 583e05921..8bb2907be 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Rate.java +++ b/Core/src/main/java/com/plotsquared/core/command/Rate.java @@ -48,7 +48,6 @@ import com.plotsquared.core.util.task.TaskManager; import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -236,7 +235,7 @@ public class Rate extends SubCommand { if (plot.getRatings().containsKey(uuid)) { player.sendMessage( TranslatableCaption.of("ratings.rating_already_exists"), - Template.of("value", plot.getId().toString()) + Template.of("plot", plot.getId().toString()) ); return; }