Created
January 19, 2016 06:59
-
-
Save Dark32/836e2dd554bcd5bdaff5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final private static Pattern rollPatern = Pattern.compile("\\*(.+?)\\*"); | |
final private static Random rand = new Random(); | |
public static String randomRoll(String message ) { | |
Matcher mt = rollPatern.matcher(message); | |
ChatColor.getLastColors(message); | |
while (mt.find()) { | |
message = message.replaceFirst("\\*(.+?)\\*", "$1 " + (rand.nextInt(100) > chance ? luck : unluck)); | |
} | |
message = message.replaceAll("\\*(.+?)\\Z", "$1 " + (rand.nextInt(100) > chance ? luck : unluck)); | |
return message; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment