Skip to content

Commit

Permalink
fix NoSuchMethodError while tabcompleting /cw on spigot
Browse files Browse the repository at this point in the history
  • Loading branch information
YouHaveTrouble committed Mar 13, 2022
1 parent cacc093 commit fd5bccc
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
8 changes: 4 additions & 4 deletions CommandWhitelistBukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
</parent>

<artifactId>Bukkit</artifactId>
Expand Down Expand Up @@ -34,7 +34,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -92,7 +92,7 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -110,7 +110,7 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>2.2.1</version>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.help.HelpTopic;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class MainCommandExecutor implements TabExecutor {
Expand Down Expand Up @@ -72,7 +74,18 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
List<String> serverCommands = new ArrayList<>(Bukkit.getCommandMap().getKnownCommands().keySet());
List<String> serverCommands;
try {
serverCommands = new ArrayList<>(Bukkit.getCommandMap().getKnownCommands().keySet());
} catch (NoSuchMethodError error) {
HashSet<String> commands = new HashSet<>();
for (HelpTopic topic : Bukkit.getHelpMap().getHelpTopics()) {
String cmd = topic.getName();
if (Character.isUpperCase(cmd.charAt(0))) continue;
commands.add(topic.getName());
}
serverCommands = new ArrayList<>(commands);
}
return CWCommand.commandSuggestions(CommandWhitelistBukkit.getConfigCache(), serverCommands, args, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission()), CWCommand.ImplementationType.BUKKIT);
}
}
2 changes: 1 addition & 1 deletion CommandWhitelistCommon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
</parent>

<artifactId>Common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion CommandWhitelistVelocity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
</parent>

<artifactId>Velocity</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions CommandWhitelistWaterfall/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
</parent>

<artifactId>Waterfall</artifactId>
Expand Down Expand Up @@ -94,13 +94,13 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bungeecord</artifactId>
<version>2.2.1</version>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
<modules>
<module>CommandWhitelistCommon</module>
<module>CommandWhitelistBukkit</module>
Expand Down

0 comments on commit fd5bccc

Please sign in to comment.