mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-23 18:45:39 +01:00
Made the spawner size optional & Fixed spawner tyoe suggestions.
This commit is contained in:
parent
ea027616a4
commit
49aa0e6f30
@ -9,15 +9,20 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CommandGive extends AbstractCommand {
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public CommandGive(AbstractCommand abstractCommand) {
|
||||
super("givespawner", abstractCommand, false);
|
||||
public class CommandGiveSpawner extends AbstractCommand {
|
||||
|
||||
public CommandGiveSpawner(AbstractCommand abstractCommand) {
|
||||
super(abstractCommand, false, "givespawner");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateStacker instance, CommandSender sender, String... args) {
|
||||
if (args.length != 4) return ReturnType.SYNTAX_ERROR;
|
||||
if (args.length < 3) return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
if (Bukkit.getPlayer(args[1]) == null && !args[1].trim().toLowerCase().equals("all")) {
|
||||
sender.sendMessage("Not a player...");
|
||||
@ -37,12 +42,13 @@ public class CommandGive extends AbstractCommand {
|
||||
StringBuilder list = new StringBuilder();
|
||||
|
||||
for (EntityType types : EntityType.values()) {
|
||||
list.append(types.name().toUpperCase().replace(" ", "_")).append("&7, &6");
|
||||
if (types.isSpawnable() && types.isAlive() && !types.toString().contains("ARMOR"))
|
||||
list.append(types.name().toUpperCase().replace(" ", "_")).append("&7, &6");
|
||||
}
|
||||
sender.sendMessage(Methods.formatText("&6" + list));
|
||||
} else {
|
||||
|
||||
int amt = Integer.parseInt(args[3]);
|
||||
int amt = args.length == 4 ? Integer.parseInt(args[3]) : 1;
|
||||
ItemStack itemStack = Methods.getSpawnerItem(type, amt);
|
||||
if (!args[1].trim().toLowerCase().equals("all")) {
|
||||
Player player = Bukkit.getOfflinePlayer(args[1]).getPlayer();
|
||||
@ -62,6 +68,23 @@ public class CommandGive extends AbstractCommand {
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateStacker instance, CommandSender sender, String... args) {
|
||||
if (args.length == 2) {
|
||||
List<String> players = new ArrayList<>();
|
||||
players.add("all");
|
||||
players.addAll(Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()));
|
||||
return players;
|
||||
} else if (args.length == 3) {
|
||||
return Arrays.stream(EntityType.values())
|
||||
.filter(types -> types.isSpawnable() && types.isAlive() && !types.toString().contains("ARMOR"))
|
||||
.map(Enum::name).collect(Collectors.toList());
|
||||
} else if (args.length == 4) {
|
||||
return Arrays.asList("1", "2", "3", "4", "5");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "ultimatestacker.admin";
|
||||
@ -69,7 +92,7 @@ public class CommandGive extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/us givespawner <player/all> <type> <level>";
|
||||
return "/us givespawner <player/all> <type> [size]";
|
||||
}
|
||||
|
||||
@Override
|
Loading…
Reference in New Issue
Block a user