mirror of https://github.com/plexusorg/Plex.git
Update WhoHasCMD.java
Added functionality that clears all players with a specified item
This commit is contained in:
parent
6ce4843829
commit
582feb3bc2
|
@ -36,12 +36,30 @@ public class WhoHasCMD extends PlexCommand
|
||||||
return messageComponent("materialNotFound", args[0]);
|
return messageComponent("materialNotFound", args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<TextComponent> players = Bukkit.getOnlinePlayers().stream().filter(player ->
|
boolean clearInventory = args.length > 1 && args[1].equalsIgnoreCase("clear");
|
||||||
player.getInventory().contains(material)).map(player -> Component.text(player.getName())).toList();
|
|
||||||
|
|
||||||
return players.isEmpty() ? messageComponent("nobodyHasThatMaterial") :
|
if (clearInventory && !sender.hasPermission("plex.whohas.clear"))
|
||||||
messageComponent("playersWithMaterial", Component.text(material.name()),
|
{
|
||||||
Component.join(JoinConfiguration.commas(true), players));
|
return messageComponent("noPermissionNode", "plex.whohas.clear");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TextComponent> players = Bukkit.getOnlinePlayers().stream().filter(player ->
|
||||||
|
player.getInventory().contains(material)).map(player -> {
|
||||||
|
if (clearInventory)
|
||||||
|
{
|
||||||
|
player.getInventory().remove(material);
|
||||||
|
player.updateInventory();
|
||||||
|
}
|
||||||
|
return Component.text(player.getName());
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
return players.isEmpty() ?
|
||||||
|
messageComponent("nobodyHasThatMaterial") :
|
||||||
|
(clearInventory ?
|
||||||
|
messageComponent("playersMaterialCleared", Component.text(material.name()),
|
||||||
|
Component.join(JoinConfiguration.commas(true), players)) :
|
||||||
|
messageComponent("playersWithMaterial", Component.text(material.name()),
|
||||||
|
Component.join(JoinConfiguration.commas(true), players)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue