Lol_marcus Posted May 18, 2020 Share Posted May 18, 2020 I got the error "The method replace(char char) is undefined for the type Player". How should I go about removing the space from the name? Inb4 super easy fix and I feel like a complete noob. ^^ public void sendRequest() throws InterruptedException { Player Name = getPlayers().closest("Example Name"); Name = Name.replace(' ', '_'); if (Name != null && Name.isVisible()) { Name.interact("Trade with"); sleep(random(2000, 3000)); new ConditionalSleep(5000, 500) { @Override public boolean condition() throws InterruptedException { return getTrade().isCurrentlyTrading(); } }.sleep(); } } Quote Link to comment Share on other sites More sharing options...
Camaro Posted May 18, 2020 Share Posted May 18, 2020 need double quotes Name.replace(" ", "_"); Quote Link to comment Share on other sites More sharing options...
Lol_marcus Posted May 18, 2020 Author Share Posted May 18, 2020 6 minutes ago, Camaro said: need double quotes Name.replace(" ", "_"); Still getting the same error. Quote Link to comment Share on other sites More sharing options...
Camaro Posted May 18, 2020 Share Posted May 18, 2020 1 minute ago, Lol_marcus said: Still getting the same error. Just realized what youre trying to do Player Name = getPlayers().closest("Example Name"); Name = Name.replace(' ', '_'); Name is a Player instance. Youre trying to call a String function Player player = getPlayers().closest("Example Name"); String name = player.getName().replace(' ', '_'); also forget what I said above, single quotes work fine 1 Quote Link to comment Share on other sites More sharing options...
Lol_marcus Posted May 18, 2020 Author Share Posted May 18, 2020 1 hour ago, Camaro said: Just realized what youre trying to do Player Name = getPlayers().closest("Example Name"); Name = Name.replace(' ', '_'); Name is a Player instance. Youre trying to call a String function Player player = getPlayers().closest("Example Name"); String name = player.getName().replace(' ', '_'); also forget what I said above, single quotes work fine I've tried that now, and I'm getting a different error. "The method interact(String) is undefined for the type String" It has something to do with name.interact, because if I change that to "player.interact", it doesn't give an error, but it doesn't trade my player. public void sendRequest() throws InterruptedException { Player player = getPlayers().closest("Example Name"); String name = player.getName().replace(' ', '_'); if (name != null && player.isVisible()) { name.interact("Trade with"); sleep(random(2000, 3000)); new ConditionalSleep(5000, 500) { @Override public boolean condition() throws InterruptedException { return getTrade().isCurrentlyTrading(); } }.sleep(); } } Quote Link to comment Share on other sites More sharing options...
Camaro Posted May 18, 2020 Share Posted May 18, 2020 6 minutes ago, Lol_marcus said: I've tried that now, and I'm getting a different error. "The method interact(String) is undefined for the type String" It has something to do with name.interact, because if I change that to "player.interact", it doesn't give an error, but it doesn't trade my player. public void sendRequest() throws InterruptedException { Player player = getPlayers().closest("Example Name"); String name = player.getName().replace(' ', '_'); if (name != null && player.isVisible()) { name.interact("Trade with"); sleep(random(2000, 3000)); new ConditionalSleep(5000, 500) { @Override public boolean condition() throws InterruptedException { return getTrade().isCurrentlyTrading(); } }.sleep(); } } Why do you need to take the spaces out in the first place? Quote Link to comment Share on other sites More sharing options...
Lol_marcus Posted May 18, 2020 Author Share Posted May 18, 2020 13 minutes ago, Camaro said: Why do you need to take the spaces out in the first place? I read on another posts that if you have a space in your name you have to remove it, otherwise the bot won't recognize your name/won't trade you. Quote Link to comment Share on other sites More sharing options...
Camaro Posted May 18, 2020 Share Posted May 18, 2020 (edited) 11 minutes ago, Lol_marcus said: I read on another posts that if you have a space in your name you have to remove it, otherwise the bot won't recognize your name/won't trade you. Not sure exactly how that works, but this might Player p = getPlayers().singleFilter(p -> p != null && p.getName().replace(" ", "").equals("namewithoutspaces")) Edited May 18, 2020 by Camaro Quote Link to comment Share on other sites More sharing options...
Chris Posted May 18, 2020 Share Posted May 18, 2020 45 minutes ago, Lol_marcus said: I've tried that now, and I'm getting a different error. "The method interact(String) is undefined for the type String" It has something to do with name.interact, because if I change that to "player.interact", it doesn't give an error, but it doesn't trade my player. public void sendRequest() throws InterruptedException { Player player = getPlayers().closest("Example Name"); String name = player.getName().replace(' ', '_'); if (name != null && player.isVisible()) { name.interact("Trade with"); sleep(random(2000, 3000)); new ConditionalSleep(5000, 500) { @Override public boolean condition() throws InterruptedException { return getTrade().isCurrentlyTrading(); } }.sleep(); } } "The method interact(String) is undefined for the type String" Read your logic. name is now type of String It is not type of Player anymore. You now need to do player.interact("trade with") or whatever Quote Link to comment Share on other sites More sharing options...
Chris Posted May 18, 2020 Share Posted May 18, 2020 also rs using a different space character .replace(' ', '\u00A0') 1 Quote Link to comment Share on other sites More sharing options...
Lol_marcus Posted May 18, 2020 Author Share Posted May 18, 2020 (edited) I finally f*cking got it to work! xD Thanks guys Edited May 18, 2020 by Lol_marcus Quote Link to comment Share on other sites More sharing options...