Don't parse player name as count in /csgive (Fixes #355)

This commit is contained in:
Phoenix616 2020-09-14 14:36:10 +01:00
parent 282c39c975
commit de14a1affb
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
1 changed files with 5 additions and 5 deletions

View File

@ -5,7 +5,6 @@ import com.Acrobot.Breeze.Utils.MaterialUtil;
import com.Acrobot.Breeze.Utils.NumberUtil;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Events.ItemParseEvent;
import com.Acrobot.ChestShop.Permission;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -13,8 +12,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author Acrobot
@ -30,7 +30,7 @@ public class Give implements CommandExecutor {
Player receiver = (sender instanceof Player ? (Player) sender : null);
int quantity = 1;
List<Integer> disregardedIndexes = new ArrayList<Integer>();
Set<Integer> disregardedIndexes = new HashSet<>();
if (args.length > 1) {
for (int index = args.length - 1; index >= 0; --index) {
@ -46,7 +46,7 @@ public class Give implements CommandExecutor {
}
for (int index = args.length - 1; index >= 0; --index) {
if (!NumberUtil.isInteger(args[index]) || Integer.parseInt(args[index]) < 0) {
if (disregardedIndexes.contains(index) || !NumberUtil.isInteger(args[index]) || Integer.parseInt(args[index]) < 0) {
continue;
}
@ -77,7 +77,7 @@ public class Give implements CommandExecutor {
return true;
}
private static ItemStack getItem(String[] arguments, List<Integer> disregardedElements) {
private static ItemStack getItem(String[] arguments, Set<Integer> disregardedElements) {
StringBuilder builder = new StringBuilder(arguments.length * 5);
for (int index = 0; index < arguments.length; ++index) {