Filter duplicates, handle permissions in multicommand, support more commands
This commit is contained in:
parent
8b1fe8302e
commit
7c829f8712
@ -15,7 +15,7 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
||||
{
|
||||
public BoosterCommand(BoosterManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "amplifier", "booster");
|
||||
super(plugin, Rank.ALL, "amplifier");
|
||||
|
||||
AddCommand(new AddCommand(plugin));
|
||||
AddCommand(new GuiCommand(plugin));
|
||||
|
@ -170,7 +170,7 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> results = new ArrayList<>();
|
||||
Set<String> results = new HashSet<>();
|
||||
|
||||
String commandName = message.substring(1);
|
||||
String[] args = new String[0];
|
||||
@ -192,7 +192,7 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
|
||||
if (command != null)
|
||||
{
|
||||
if (ClientManager.Get(packetInfo.getPlayer()).GetRank().has(packetInfo.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true)
|
||||
if (ClientManager.Get(packetInfo.getPlayer()).GetRank().has(packetInfo.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), false)
|
||||
|| UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase()))
|
||||
{
|
||||
List<String> tmpres = command.onTabComplete(packetInfo.getPlayer(), commandName.toLowerCase(), args);
|
||||
@ -207,7 +207,6 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
else
|
||||
{
|
||||
// System.out.println("Path 2");
|
||||
Set<String> commands = new HashSet<>();
|
||||
for (ICommand command : Commands.values())
|
||||
{
|
||||
if (ClientManager.Get(packetInfo.getPlayer()).GetRank().has(packetInfo.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), false)
|
||||
@ -217,12 +216,11 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
{
|
||||
if (alias.startsWith(commandName))
|
||||
{
|
||||
commands.add("/" + alias.toLowerCase());
|
||||
results.add("/" + alias.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
results.addAll(commands);
|
||||
}
|
||||
|
||||
// System.out.println("Final results: " + results);
|
||||
|
@ -3,6 +3,7 @@ package mineplex.core.command;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -101,7 +102,12 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
|
||||
}
|
||||
else if (args.length == 1)
|
||||
{
|
||||
return getMatches(args[0], Commands.values().stream().map(ICommand::Aliases).flatMap(Collection::stream));
|
||||
Stream<ICommand> stream = Commands.values().stream();
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
stream = stream.filter(command -> _commandCenter.GetClientManager().Get((Player) sender).GetRank().has((Player) sender, command.GetRequiredRank(), command.GetSpecificRanks(), false));
|
||||
}
|
||||
return getMatches(args[0], stream.map(ICommand::Aliases).flatMap(Collection::stream));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -12,7 +12,7 @@ public class ResendAdminCommand extends CommandBase<MessageManager>
|
||||
{
|
||||
public ResendAdminCommand(MessageManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "ra");
|
||||
super(plugin, Rank.HELPER, "ra");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -24,9 +24,6 @@ public class ResendAdminCommand extends CommandBase<MessageManager>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Plugin.GetClientManager().Get(caller).GetRank().has(caller, Rank.HELPER, true))
|
||||
return;
|
||||
|
||||
String lastTo = Plugin.Get(caller).LastAdminTo;
|
||||
|
||||
// Get To
|
||||
|
@ -1,11 +1,15 @@
|
||||
package mineplex.core.party.command.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.party.InviteData;
|
||||
import mineplex.core.party.PartyManager;
|
||||
|
||||
public class PartyGUIAcceptInviteCommand extends CommandBase<PartyManager>
|
||||
@ -26,4 +30,20 @@ public class PartyGUIAcceptInviteCommand extends CommandBase<PartyManager>
|
||||
|
||||
Plugin.acceptInviteBySender(caller, args[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
Player player = (Player) sender;
|
||||
|
||||
return getMatches(args[0], Plugin.getInviteManager().getAllInvites(player).stream().map(InviteData::getInviterName));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
package mineplex.core.party.command.gui;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.party.InviteData;
|
||||
import mineplex.core.party.PartyManager;
|
||||
|
||||
public class PartyGUIDenyInviteCommand extends CommandBase<PartyManager>
|
||||
@ -25,4 +30,19 @@ public class PartyGUIDenyInviteCommand extends CommandBase<PartyManager>
|
||||
}
|
||||
Plugin.denyInviteBySender(caller, args[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
Player player = (Player) sender;
|
||||
return getMatches(args[0], Plugin.getInviteManager().getAllInvites(player).stream().map(InviteData::getInviterName).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user