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