refactoring and code cleanup
All checks were successful
Build / build (push) Successful in 1m27s

This commit is contained in:
unurled 2024-02-29 15:44:28 +01:00
parent 7cc9395cbc
commit 1380e7479a
Signed by: unurled
GPG key ID: FDBC9CBE1F82423F
11 changed files with 45 additions and 77 deletions

View file

@ -4,6 +4,7 @@ import me.unurled.sacredrealms.sr.SR;
import me.unurled.sacredrealms.sr.commands.admin.AttributeCommand;
import me.unurled.sacredrealms.sr.commands.player.ResetAdventureCommand;
import me.unurled.sacredrealms.sr.managers.Manager;
import org.bukkit.command.PluginCommand;
public class CommandManager extends Manager {
@ -11,10 +12,17 @@ public class CommandManager extends Manager {
@Override
public void load() {
super.load();
SR.getInstance().getCommand("attributes").setExecutor(new AttributeCommand());
SR.getInstance().getCommand("attributes").setTabCompleter(new AttributeCommand());
SR instance = SR.getInstance();
PluginCommand attributes = instance.getCommand("attributes");
if (attributes != null) {
attributes.setExecutor(new AttributeCommand());
attributes.setTabCompleter(new AttributeCommand());
}
SR.getInstance().getCommand("resetadventure").setExecutor(new ResetAdventureCommand());
SR.getInstance().getCommand("resetadventure").setTabCompleter(new ResetAdventureCommand());
PluginCommand resetadventure = instance.getCommand("resetadventure");
if (resetadventure != null) {
resetadventure.setExecutor(new ResetAdventureCommand());
resetadventure.setTabCompleter(new ResetAdventureCommand());
}
}
}

View file

@ -133,12 +133,19 @@ public class ResetAdventureCommand implements TabExecutor {
if (args[0].isBlank()) {
return Arrays.stream(Bukkit.getOfflinePlayers())
.map(OfflinePlayer::getName)
.toList().stream().limit(10).toList();
.toList()
.stream()
.limit(10)
.toList();
}
return Arrays.stream(Bukkit.getOfflinePlayers())
.map(OfflinePlayer::getName).filter(Objects::nonNull)
.map(OfflinePlayer::getName)
.filter(Objects::nonNull)
.filter(name -> name.toLowerCase().startsWith(args[0].toLowerCase()))
.toList().stream().limit(10).toList();
.toList()
.stream()
.limit(10)
.toList();
}
return null;
}