mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-11-16 23:25:11 +01:00
bug fix with argument reading
This commit is contained in:
parent
e164703740
commit
202ae4ea93
@ -82,14 +82,18 @@ public abstract class IoMCommand extends Command {
|
||||
//State of the automaton, can read word like:
|
||||
//name_here; "name here"
|
||||
int state = 0;
|
||||
StringBuilder s;
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
for (String arg : args) {
|
||||
if (arg.startsWith("http:") || arg.startsWith("https:")) {
|
||||
arguments.add(arg);
|
||||
continue;
|
||||
}
|
||||
s = new StringBuilder();
|
||||
if (state == 0) {
|
||||
s = new StringBuilder();
|
||||
} else {
|
||||
s.append(" ");
|
||||
}
|
||||
for (char c : arg.toCharArray()) {
|
||||
switch (state) {
|
||||
case 0:
|
||||
@ -118,9 +122,10 @@ public abstract class IoMCommand extends Command {
|
||||
throw new IllegalStateException("Unexpected value: " + state);
|
||||
}
|
||||
}
|
||||
if (s.length() > 0) {
|
||||
if (s.length() > 0 && state != 1) {
|
||||
arguments.add(s.toString());
|
||||
}
|
||||
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ public class GiveCommand extends IoMCommand {
|
||||
|
||||
if (args.length < 2) {
|
||||
throwInvalidArgument(I.t("You must give a valid player name and a map name."));
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> arguments = getArgs();
|
||||
@ -103,6 +104,8 @@ public class GiveCommand extends IoMCommand {
|
||||
}
|
||||
}
|
||||
|
||||
final Player sender = playerSender();
|
||||
|
||||
//TODO passer en static
|
||||
ImageOnMap.getPlugin().getCommandWorker().offlineNameFetch(from, uuid -> {
|
||||
if (uuid == null) {
|
||||
@ -121,13 +124,18 @@ public class GiveCommand extends IoMCommand {
|
||||
warning(sender, I.t("The player {0} does not exist.", playerName));
|
||||
return;
|
||||
}
|
||||
if (map.give(Bukkit.getPlayer(uuid2))) {
|
||||
if (Bukkit.getPlayer((uuid2)) != null && Bukkit.getPlayer((uuid2)).isOnline()
|
||||
&& map.give(Bukkit.getPlayer(uuid2))) {
|
||||
info(I.t("The requested map was too big to fit in your inventory."));
|
||||
info(I.t("Use '/maptool getremaining' to get the remaining maps."));
|
||||
}
|
||||
|
||||
} catch (IOException | InterruptedException e) {
|
||||
warning(sender, I.t("The player {0} does not exist.", playerName));
|
||||
try {
|
||||
throwInvalidArgument(I.t("The player {0} does not exist.", playerName));
|
||||
} catch (CommandException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user