Hi,
I’m begginer in sponge plugin development and i don’t find in the net how to compare a String argument.
My code:
` @Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
ArrayList axeLoc = new ArrayList<>();
ArrayList allieLoc = new ArrayList<>();
Random r = new Random();
if(!(src instanceof Player)) {
src.sendMessage(Text.of("§cLa console ou les commandes blocs ne peuvent pas utiliser cette commande!"));
CommandResult.success();
}
Player p = (Player) src;
String team = args.<String>getOne("team").get();
//That's here
if(team.equals(Text.of("axe"))) {
p.sendMessage(Text.of("§aVous avez choisis la team§c§l Axe§a."));
axeLoc.add(new Location<>(p.getWorld(), -1694, 5, 505));
axeLoc.add(new Location<>(p.getWorld(), -1622, 5, 503));
axeLoc.add(new Location<>(p.getWorld(), -1648, 5, 507));
axeLoc.add(new Location<>(p.getWorld(), -1631, 5, 505));
axeLoc.add(new Location<>(p.getWorld(), -1615, 5, 503));
axeLoc.add(new Location<>(p.getWorld(), -1602, 5, 527));
axeLoc.add(new Location<>(p.getWorld(), -1612, 5, 522));
axeLoc.add(new Location<>(p.getWorld(), -1622, 5, 527));
axeLoc.add(new Location<>(p.getWorld(), -1656, 5, 530));
axeLoc.add(new Location<>(p.getWorld(), -1676, 5, 526));
axeLoc.add(new Location<>(p.getWorld(), -1692, 5, 528));
p.setLocation(axeLoc.get(r.nextInt(axeLoc.size())));
}
if(team.equals(Text.of("allie"))) {
p.sendMessage(Text.of("§aVous avez choisis la team§2§l Allié§a."));
allieLoc.add(new Location<>(p.getWorld(), -1609, 19, 643));
allieLoc.add(new Location<>(p.getWorld(), -1676, 19, 643));
allieLoc.add(new Location<>(p.getWorld(), -1637, 19, 643));
allieLoc.add(new Location<>(p.getWorld(), -1603, 19, 643));
p.setLocation(allieLoc.get(r.nextInt(allieLoc.size())));
}
return CommandResult.success();
}`
I want to get the String argument /join , if this argument equals to “allie” of “axe” i want to do things.
Thank’s you,
maxou54200.