holic 231 Share Posted September 5, 2020 Thought some of you might find this useful, here's a slightly less bot-like random username generator. I threw it together real quick with just a random assortment of common partial usernames (Blade, Iron, Pure, etc). They ain't great names but they're sure as shit better than what I've been seeing in game. You'll definitely run into names that have already been taken by other players but at least you're not using names like 31223131133 It generates names 8 to 12 characters in length, changes the variable "nameLen" should you want a different length. private String generateUsername() { String[] names = {"420", "Bane", "Bear", "Behemoth", "Big", "Black", "Blade", "Bleed", "Blood", "Blow", "Boar", "Boi", "Bolt", "Boulder", "Boy", "Break", "Brow", "Challenger", "Chaser", "Colossal", "Colossus", "Corrupter", "Crow", "Danger", "Dark", "Dead", "pelt", "Death", "Deceiver", "Die", "Dire", "Doom", "Dragon", "Dwarf", "Dwarven", "Fang", "Fierce", "Fist", "Flurry", "Freak", "Fury", "Fuse", "Giant", "Girl", "Gold", "Great", "Grim", "Grotesque", "Guthix", "Hallow", "Helm", "Hit", "Hollow", "Homie", "Hunter", "Insane", "Invincible", "Iron", "Ironfist", "Ironman", "Kill", "Killa", "Lion", "Lone", "Mammoth", "Man", "Mane", "Me", "Might", "Mighty", "Mithril", "Molten", "Myth", "Mythic", "Night", "Night", "owl", "One", "PK", "Paragon", "Pelt", "Poison", "Proud", "Pur3", "Pure", "Rage", "Raven", "Rebel", "Rock", "Rumble", "Savage", "Scar", "Sexy", "Shade", "Shield", "Shout", "Silent", "Silver", "Sk1ll", "Skill", "Skull", "Slayer", "Spirit", "Spook", "Steel", "Storm", "Stout", "Strong", "Swift", "Tempest", "The", "Thirst", "Thunder", "Tower", "True", "Voidmane", "White", "Wild", "Wildfist", "Wolf", "Zam", "Zammy", "Zero", "_", "axe", "bolt", "bow", "bronze", "brow", "chaser", "cleaver", "cold", "earth", "fang", "fierce", "fire", "flayer", "gaze", "hero", "hot", "ice", "killa", "knight", "mage", "man", "metal", "might", "rage", "scar", "snarl", "song", "sorrow", "stride", "strike", "strong", "sword", "sworn", "thorn", "throw", "tongue", "warrior", "wind", "wizard", "xX", "xox", "xxx"}; int nameCount = Calculations.random(2, 3), nameLen = Calculations.random(8, 12); String name = ""; for (int i = 0; i < nameCount; i++) { String tmpName = names[Calculations.random(0, names.length - 1)]; switch (Calculations.random(0, 4)) { case 0: tmpName = tmpName.toLowerCase(); break; case 1: tmpName = tmpName.toUpperCase(); break; case 2 - 3: tmpName = toTitleCase(tmpName); break; } if (name.length() + tmpName.length() <= nameLen) { name += tmpName; } else { String tmprName; if (Calculations.random(0, 1) == 1) { tmprName = (name + tmpName).substring(0, nameLen); } else { int r = Calculations.random(9, nameLen); tmprName = (name + tmpName).substring(0, r); for (int ri = r; ri < 12; ri++) { if (Calculations.random(0, 1) == 1) { tmprName += Calculations.random(0, 9); } else { tmprName = Calculations.random(0, 9) + tmprName; } } } name = tmprName; } } return name; } Sample names: STRONGsnarl DoomBleed brow420 stormSteelF4 FuryNight STOUTSTRIDE 141Bould Goldmanwind BLADEkil 7711mageSi98 78Hunterg bleedmage chaserTheI GOLDChase blackgirlHo Rebelsk1l baneSONG 2Challenge99 WILDSavageD7 50IRONMANHo9 FuryZerow PUR3DARK RumbleBo 16ShadeCorV0 BreakTower owlfierceDA metalFURY killaThe GrimWildfi Deceiver_Fi9 Irondrag 7MythlionIR1 BoulderWild dienightSlay Grotesqu STRIDEIro 05strongW COLDspirit Ironfist mecoldMYTH SCARBloodpel xoxFreakbr93 5Zerorebel84 rockLone 1fangBoyDw38 1GuthixFIE75 ZambrowZer 6FUSEStoutT9 fiercexxxPur ScarFangDe08 MithrilIron KNIGHTBoltC swornmetalsn Behemothmy 8BoulderSt12 Furycoloss TOWERLoneBoa FURYbrow 4SK1LLstron0 wizardBlow 5MAMMOTHth31 metalRage Bolttongue 6DECEIVERK63 helmcrow MythicHel KillRavenb blowColossal 209strikepuh gazescar PeltZAMMY BROWXXRAGE Link to comment Share on other sites More sharing options...
Realistic 20 Share Posted September 6, 2020 Awesome! I was thinking about making one of these. Thank you for saving all of us a bunch of time! Link to comment Share on other sites More sharing options...
holic 231 Author Share Posted September 6, 2020 1 minute ago, Realistic said: Awesome! I was thinking about making one of these. Thank you for saving all of us a bunch of time! No problem! I just realized I forgot to include toTitleCase so here it is: public static String toTitleCase(String text) { if (text == null || text.isEmpty()) { return text; } StringBuilder converted = new StringBuilder(); boolean convertNext = true; for (char ch : text.toCharArray()) { if (Character.isSpaceChar(ch)) { convertNext = true; } else if (convertNext) { ch = Character.toTitleCase(ch); convertNext = false; } else { ch = Character.toLowerCase(ch); } converted.append(ch); } return converted.toString(); } And if you want to run it stand alone (eg not in a script), just throw this in there too: private static class Calculations { public static int random(double min, double max) { int x = (int) ((Math.random() * ((max - min) + 1)) + min); return x; } } So that you don't need to create a random number generator nor change any code. Link to comment Share on other sites More sharing options...
Realistic 20 Share Posted September 6, 2020 Perfect. If it is ok with you, I will put this in a DB3 tutorial Island script that I should have finished in the next couple of days. I am planning on open sourcing it to get some feedback and as an example for people moving to the DB3 api. I am planning on add a comment and section in the read me giving you credit for the snip it and linking the post. Is that ok with you? Link to comment Share on other sites More sharing options...
holic 231 Author Share Posted September 6, 2020 1 minute ago, Realistic said: Perfect. If it is ok with you, I will put this in a DB3 tutorial Island script that I should have finished in the next couple of days. I am planning on open sourcing it to get some feedback and as an example for people moving to the DB3 api. I am planning on add a comment and section in the read me giving you credit for the snip it and linking the post. Is that ok with you? Go right ahead, my friend. Thank you for asking! I posted it with the intention of others using it so it's all yours. Link to comment Share on other sites More sharing options...
Realistic 20 Share Posted September 9, 2020 On 9/5/2020 at 6:35 PM, holic said: Go right ahead, my friend. Thank you for asking! I posted it with the intention of others using it so it's all yours. I finally finished it. Here is the topic with the source code. Thank you for your snippet! Link to comment Share on other sites More sharing options...
holic 231 Author Share Posted September 9, 2020 17 hours ago, Realistic said: I finally finished it. Here is the topic with the source code. Thank you for your snippet! Great work! You're very welcome, thanks for the contribution! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.