TheScrub Posted October 7, 2013 Share Posted October 7, 2013 well i finished it and decided to share because I'm nice took like 20 mins to write this shit down!!! enum Spells { HomeTeleport("Lunar Home Teleport", 0, 16), BakePie("Bake Pie", 65, 15), CurePlant("Cure Plant", 66, 31), MonsterExamine("Monster Examine", 66, 6), NpcContact("NPC Contact", 67, 4), CureOther("Cure Other", 68, 1), Humidify("Humidify", 68, 7), MoonClanTeleport("Moonclan Teleport", 69,20), TeleGroupMoonclan("Tele Group Moonclan", 70, 32), CureMe("Cure Me", 71, 23), HunterKit("Hunter Kit", 71, 8), WaterbirthTeleport("Waterbirth Teleport", 72, 24), TeleGroupWaterbirth("Tele Group Waterbirth",73,33), CureGroup("Cure Group",74,3), StatSpy("Stat Spy",75,9), BarbarianTeleport("Barbarian Teleport",75,0), TeleGroupBarbarian("Tele Group Barbarian",76,34), SuperglassMake("Superglass Make",77,25), KhazardTeleport("Khazard Teleport",78,18), TeleGroupKhazard("Tele Group Khazard",79,35), Dream("Dream",79,10), StringJewellery("String Jewellery",80,22), StatRestorePotShare("Stat Restore Pot Share",81,27), MagicImbue("Magic Imbue",82,13), FertileSoil("Fertile Soil",83,2), BoostPotionShare("Boost Potion Share",84,26), FishingGuildTeleport("Fishing Guild Teleport",85,17), TeleGroupFishingGuild("Tele Group Fishing Guild",86,36), PlankMake("Plank Make",86,11), CatherbyTeleport("Catherby Teleport",87,21), TeleGroupCatherby("Tele Group Catherby",88,37), IcePlateauTeleport("Ice Plateau Teleport",89,28), TeleGroupIcePlateau("Tele Group Ice Plateau",90,38), EnergyTransfer("Energy Transfer",91,5), HealOther("Heal Other",92,29), VengeanceOther("Vengance Other",93,19), Vengance("Vengance",94,14), HealGroup("Heal Group",95,30), SpellbookSwap("Spellbook Swap",96,12); private final int level; private final int childid; private final String name; Spells(String name, int level, int childid) { this.name = name; this.level = level; this.childid = childid; } public String getName() { return name; } public int getLevel() { return level; } public int getChild() { return childid; } public int getParent() { return 430; } } 2 Link to comment Share on other sites More sharing options...
Rodgerwilco Posted October 7, 2013 Share Posted October 7, 2013 Enums suck. :P gj though Link to comment Share on other sites More sharing options...
TheScrub Posted October 7, 2013 Author Share Posted October 7, 2013 Enums suck. gj though how so? Link to comment Share on other sites More sharing options...
Neodork Posted October 7, 2013 Share Posted October 7, 2013 Enums suck. gj though how so? Looks good. You could try adding in an id value as first argument so the enum can be easily used in combination with a comboBox. Link to comment Share on other sites More sharing options...
Cyro Posted October 7, 2013 Share Posted October 7, 2013 (edited) good work looks nice tho enum instances should be uppercase and separated by "_" underscore as they are static final anyway you should override toString() to return the name rather than the instance name for those who will use this with ComboBox Enums suck. gj though how so? Looks good. You could try adding in an id value as first argument so the enum can be easily used in combination with a comboBox. why isn't the name better? the users wont know what the id mean or did i misunderstood you? Edited October 7, 2013 by Cyro Link to comment Share on other sites More sharing options...
Zuup Posted October 7, 2013 Share Posted October 7, 2013 (edited) good work looks nice tho enum instances should be uppercase and separated by "_" underscore as they are static final anyway you should override toString() to return the name rather than the instance name for those who will use this with ComboBox Enums suck. gj though how so? Looks good. You could try adding in an id value as first argument so the enum can be easily used in combination with a comboBox. why isn't the name better? the users wont know what the id mean or did i misunderstood you? Yes, you misunderstood him. Theese ID's he's talking about, is the ID's from the ComboBoxes from the Swing class (for generating GUI's). I can't explain this much further, but I hope I helped. You can still have the name. enum Spells { HOMETELEPORT("Lunar Home Teleport", 0, 0, 16), BAKEPIE("Bake Pie", 1, 65, 15), CUREPLANT("Cure Plant", 2, 66, 31); private final String name; private final int comboBoxPos; private final int level; private final int childid; Spells(String name, int comboBoxPos, int level, int childid) { this.name = name; this.combo = comboBoxPos; this.level = level; this.childid = childid; } public String getName() { return name; } public int getLevel() { return level; } public int getChild() { return childid; } public int getParent() { return 430; } } Something like that if I remember correct . PS. Enums are written in case-letters :P. (I don't know the right word here..) Edited October 7, 2013 by Zuup Link to comment Share on other sites More sharing options...
TheScrub Posted October 7, 2013 Author Share Posted October 7, 2013 Thanks guys i understand that there meant to be upper case like the oracle doc example "MONDAY","TUESDAY" etc just forgot idk what you guy's are meaning by the id's as it's the interface child id and should be used in you're casting method as such just a quick example i wrote up private void castSpell(Spells i) throws InterruptedException { if (!mageTabIsOpen()) { magicTab.open(); sleep(300); } else if (mageTabIsOpen()) { if (client.getInterface(i.getParent()) != null) { RS2InterfaceChild s = client.getInterface(430).getChild(i.getChild()); if (s.isVisible() && s != null) { s.interact("Cast"); sleep(300); } } } } as you can see i used static sleeps as this is only an example but you see how it works also with the name i thought you had to have the name to use the spell but you don't but you can use it like other people said for combo boxs etc really nice idea! Link to comment Share on other sites More sharing options...
Anon Posted October 7, 2013 Share Posted October 7, 2013 Nice job man. I sure will use this. tho enum instances should be uppercase and separated by "_" underscore as they are static final You don't truly need to do that..... Honestly no one gives a shit about that 1 Link to comment Share on other sites More sharing options...
Cyro Posted October 7, 2013 Share Posted October 7, 2013 good work looks nice tho enum instances should be uppercase and separated by "_" underscore as they are static final anyway you should override toString() to return the name rather than the instance name for those who will use this with ComboBox Enums suck. gj though how so? Looks good. You could try adding in an id value as first argument so the enum can be easily used in combination with a comboBox. why isn't the name better? the users wont know what the id mean or did i misunderstood you? Yes, you misunderstood him. Theese ID's he's talking about, is the ID's from the ComboBoxes from the Swing class (for generating GUI's). I can't explain this much further, but I hope I helped. You can still have the name. enum Spells { HOMETELEPORT("Lunar Home Teleport", 0, 0, 16), BAKEPIE("Bake Pie", 1, 65, 15), CUREPLANT("Cure Plant", 2, 66, 31); private final String name; private final int comboBoxPos; private final int level; private final int childid; Spells(String name, int comboBoxPos, int level, int childid) { this.name = name; this.combo = comboBoxPos; this.level = level; this.childid = childid; } public String getName() { return name; } public int getLevel() { return level; } public int getChild() { return childid; } public int getParent() { return 430; } } Something like that if I remember correct . PS. Enums are written in case-letters . (I don't know the right word here..) idk they way i do it is add the enum instances as items of the combobox JComboBox<Spells> combo = new JComboBox<Spells>(Spells.values()); and also there is Spells#BAKEPIE#ordinal(); which returns 1 (the position of the constant in the enum) Link to comment Share on other sites More sharing options...
Cyro Posted October 7, 2013 Share Posted October 7, 2013 Nice job man. I sure will use this. tho enum instances should be uppercase and separated by "_" underscore as they are static final You don't truly need to do that..... Honestly no one gives a shit about that well it was just a tip idc really and that wasnt the cause at one of the forums i posted a similar code contains enum and some things were off like conventions of the enum instances and people were annoying due to that Link to comment Share on other sites More sharing options...
Boots Posted October 7, 2013 Share Posted October 7, 2013 enums are all caps by default 1 Link to comment Share on other sites More sharing options...
Mr Asshole Posted October 8, 2013 Share Posted October 8, 2013 the instances of an enum must be all caps with underscores seperating words. Instances of an enum are public static final so that's why the naming convention applys. You should also show user how to use it with a jcombobox in a gui with action listener. JComboBox<Spells> spell = new JComboBox<>(Spells.values()) addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final Spells selected = (Spells) getSelectedItem(); } }); Link to comment Share on other sites More sharing options...