Java doesn’t really have a startsWith
that ignores capital letters and minuscules as it has for the equals
, which is the equalsIgnoreCase
.
However it is easy to find a logic that can do this by converting to uppercase or minuscule before comparing:
String msgMinuscula = e.getMessage().toLowerCase();
if(msgMinuscula.startsWith("/reciclar") || msgMinuscula .startsWith("/ereciclar")){
e.setCancelled(true);
p.sendMessage("§cComando Bloqueado/Em Manutenção!");
}
It is necessary however to ensure that what is placed on the startsWith
is in minuscules as well, otherwise it will be necessary to convert manually if it is a String
hand-held or calling the method toLowerCase
if it is a variable.
You want to check if the beginning of a string starts with
/reciclar
, independent of the text case, that’s it?– user28595
Yes, because if I put myself equalsIgnoreCase would have way to add a space after the command and would work the same way
– Barry Allen
It is not very clear your doubts, please edit the question and explain a little more
– user28595
I think I solved it, I put it up for every time someone tries to use a command it automatically decreases the letters
– Barry Allen
You can answer with the solution below then :)
– user28595