java - Should be returning true but returns false instead? -
code:
bukkit.getserver().broadcastmessage("check " + chatcolor.stripcolor(i)); bukkit.getserver().broadcastmessage("that starts " + chatcolor.stripcolor(chatcolor.translatealternatecolorcodes('&', guishop.instance.getconfig().getstring("messages." + type + "label")))); bukkit.getserver().broadcastmessage(chatcolor.stripcolor(i).startswith(chatcolor.stripcolor(chatcolor.translatealternatecolorcodes('&', guishop.instance.getconfig().getstring("messages." + type + "label")))) + "");
and image of returning false instead of true:
could me being stupid.. not sure
edit1: ok eckes pointed out being stupid.. how check if "buy: 50.0" started "buy: price". if %price%
false correct, "buy: 50.0
" not start "buy: %price%
". , should not mix color logic translation logic business logic.
make code readable, helps find problem yourself.
if want remove %price% use:
string check = chatcolor.stripcolor(i); string pattern = chatcolor.stripcolor(chatcolor.translatealternatecolorcodes('&', guishop.instance.getconfig().getstring("messages." + type + "label"))); pattern = pattern.replace(" %price%", ""); boolean isbuy = check.startswith(pattern);
i cant make more readable without more background details.
Comments
Post a Comment