diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandForce.java b/src/main/java/com/songoda/epicvouchers/commands/CommandForce.java index 650c294..a909a65 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandForce.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandForce.java @@ -5,13 +5,11 @@ import com.songoda.epicvouchers.EpicVouchers; import com.songoda.epicvouchers.voucher.Voucher; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; -import java.util.Arrays; +import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; public class CommandForce extends AbstractCommand { final EpicVouchers instance; @@ -49,14 +47,23 @@ public class CommandForce extends AbstractCommand { @Override protected List onTab(CommandSender sender, String... args) { + List result = new ArrayList<>(); + if (args.length == 1) { - return Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).collect(Collectors.toList()); + for (Player online : Bukkit.getOnlinePlayers()) { + result.add(online.getName()); + } } else if (args.length == 2) { - return instance.getVoucherManager().getVouchers().stream().map(Voucher::getKey).collect(Collectors.toList()); + for (Voucher voucher : instance.getVoucherManager().getVouchers()) { + result.add(voucher.getKey()); + } } else if (args.length == 3) { - return Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"); + for (int i = 0; i < 10; ++i) { + result.add(String.valueOf(i + 1)); + } } - return null; + + return result; } @Override diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandForceAll.java b/src/main/java/com/songoda/epicvouchers/commands/CommandForceAll.java index fc9e713..9ee6edd 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandForceAll.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandForceAll.java @@ -7,9 +7,7 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; public class CommandForceAll extends AbstractCommand { final EpicVouchers instance; @@ -41,12 +39,19 @@ public class CommandForceAll extends AbstractCommand { @Override protected List onTab(CommandSender sender, String... args) { + List result = new ArrayList<>(); + if (args.length == 1) { - return instance.getVoucherManager().getVouchers().stream().map(Voucher::getKey).collect(Collectors.toList()); + for (Voucher voucher : instance.getVoucherManager().getVouchers()) { + result.add(voucher.getKey()); + } } else if (args.length == 2) { - return Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"); + for (int i = 0; i < 10; ++i) { + result.add(String.valueOf(i + 1)); + } } - return null; + + return result; } @Override diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandGive.java b/src/main/java/com/songoda/epicvouchers/commands/CommandGive.java index b000dd6..c7a6144 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandGive.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandGive.java @@ -5,13 +5,11 @@ import com.songoda.epicvouchers.EpicVouchers; import com.songoda.epicvouchers.voucher.Voucher; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; -import java.util.Arrays; +import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; public class CommandGive extends AbstractCommand { final EpicVouchers instance; @@ -44,14 +42,23 @@ public class CommandGive extends AbstractCommand { @Override protected List onTab(CommandSender sender, String... args) { + List result = new ArrayList<>(); + if (args.length == 1) { - return Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).collect(Collectors.toList()); + for (Player online : Bukkit.getOnlinePlayers()) { + result.add(online.getName()); + } } else if (args.length == 2) { - return instance.getVoucherManager().getVouchers().stream().map(Voucher::getKey).collect(Collectors.toList()); + for (Voucher voucher : instance.getVoucherManager().getVouchers()) { + result.add(voucher.getKey()); + } } else if (args.length == 3) { - return Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"); + for (int i = 0; i < 10; ++i) { + result.add(String.valueOf(i + 1)); + } } - return null; + + return result; } @Override diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandGiveAll.java b/src/main/java/com/songoda/epicvouchers/commands/CommandGiveAll.java index fd23c1a..51250be 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandGiveAll.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandGiveAll.java @@ -5,9 +5,8 @@ import com.songoda.epicvouchers.EpicVouchers; import com.songoda.epicvouchers.voucher.Voucher; import org.bukkit.command.CommandSender; -import java.util.Arrays; +import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; public class CommandGiveAll extends AbstractCommand { final EpicVouchers instance; @@ -34,12 +33,19 @@ public class CommandGiveAll extends AbstractCommand { @Override protected List onTab(CommandSender sender, String... args) { + List result = new ArrayList<>(); + if (args.length == 1) { - return instance.getVoucherManager().getVouchers().stream().map(Voucher::getKey).collect(Collectors.toList()); + for (Voucher voucher : instance.getVoucherManager().getVouchers()) { + result.add(voucher.getKey()); + } } else if (args.length == 2) { - return Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"); + for (int i = 0; i < 10; ++i) { + result.add(String.valueOf(i + 1)); + } } - return null; + + return result; } @Override diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandList.java b/src/main/java/com/songoda/epicvouchers/commands/CommandList.java index ac7f62d..deea3f5 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandList.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandList.java @@ -6,7 +6,7 @@ import com.songoda.epicvouchers.voucher.Voucher; import org.bukkit.command.CommandSender; import java.util.List; -import java.util.stream.Collectors; +import java.util.StringJoiner; public class CommandList extends AbstractCommand { final EpicVouchers instance; @@ -18,10 +18,15 @@ public class CommandList extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { + StringJoiner joiner = new StringJoiner(", "); + for (Voucher voucher : instance.getVoucherManager().getVouchers()) { + joiner.add(voucher.getKey()); + } + instance.getLocale().getMessage("command.list.list") - .processPlaceholder("list", - instance.getVoucherManager().getVouchers().stream().map(Voucher::getKey).collect(Collectors.joining(", "))) + .processPlaceholder("list", joiner.toString()) .sendPrefixedMessage(sender); + return ReturnType.SUCCESS; }