RuneScape 2 Development > Snippets

[PI] RuneCrafting - My first enum-based skill.

<<< (2/4) >>>

sspoke:
a good server wouldn't even have

--- Code: ---public static int PURE_ESS = 7936;
public static int RUNE_ESS = 1436;

--- End code ---

since in the future if you wish to update to a newer revision of the game and lets say jagex decides to change all item id's it will be a big hassle to change the item id's in all classes for all skills, better make all items like


--- Code: ---public static int RUNE_ESSENSE= 7936;

--- End code ---
etc..

in one big ItemConstants.java or something then you just do

ItemConstants.RUNE_ESSENSE

so in the long run you just have to modify one file to fix all item id's up.
same should be applied to ObjectConstants.java

ObjectsConstants.NORMAL_TREE
ObjectsConstants.DOOR
ObjectsConstnats.IRON_ORE

etc..

Ashi:

--- Quote from: sspoke on December 12, 2013, 12:36:31 PM ---a good server wouldn't even have

--- Code: ---public static int PURE_ESS = 7936;
public static int RUNE_ESS = 1436;

--- End code ---

since in the future if you wish to update to a newer revision of the game and lets say jagex decides to change all item id's it will be a big hassle to change the item id's in all classes for all skills, better make all items like


--- Code: ---public static int RUNE_ESSENSE= 7936;

--- End code ---
etc..

in one big ItemConstants.java or something then you just do

ItemConstants.RUNE_ESSENSE

so in the long run you just have to modify one file to fix all item id's up.
same should be applied to ObjectConstants.java

ObjectsConstants.NORMAL_TREE
ObjectsConstants.DOOR
ObjectsConstnats.IRON_ORE

etc..

--- End quote ---
That is just as bad.

I rather do
Item: if(item.equalsIgnoreCase("rune essence") { /* do something * /}
Objects: if (object.equalsIgnoreCase("tree") { /* do something * / }

That way you're using less memory and are not creating any unneeded objects.

Edit:
public static int PURE_ESS = 7936;
public static int RUNE_ESS = 1436;

Those are not even constants, why is everything static?
       

Dan0194:
Constants are static because they don't need to belong to the class. When you use a constant It applies for everything. So the item id of a pot is 1976 for all the players.

sk8rdude461:

--- Quote from: Arcik on December 12, 2013, 01:11:04 PM ---Those are not even constants, why is everything static?

--- End quote ---

Essentially all skills should be static as nothing changes besides what item(s) you're using.

Edit:

--- Quote from: sspoke on December 12, 2013, 12:36:31 PM ---a good server wouldn't even have

--- Code: ---public static int PURE_ESS = 7936;
public static int RUNE_ESS = 1436;

--- End code ---

since in the future if you wish to update to a newer revision of the game and lets say jagex decides to change all item id's it will be a big hassle to change the item id's in all classes for all skills, better make all items like


--- Code: ---public static int RUNE_ESSENSE= 7936;

--- End code ---
etc..

in one big ItemConstants.java or something then you just do

ItemConstants.RUNE_ESSENSE

so in the long run you just have to modify one file to fix all item id's up.
same should be applied to ObjectConstants.java

ObjectsConstants.NORMAL_TREE
ObjectsConstants.DOOR
ObjectsConstnats.IRON_ORE

etc..

--- End quote ---

I used what I did because I wrote this generally for most PI servers, and most PI's do not have a feature as such. So even if I were to have some class like that, I wouldn't of put that in this snippet.

sspoke:

--- Quote from: Arcik on December 12, 2013, 01:11:04 PM ---
--- Quote from: sspoke on December 12, 2013, 12:36:31 PM ---a good server wouldn't even have

--- Code: ---public static int PURE_ESS = 7936;
public static int RUNE_ESS = 1436;

--- End code ---

since in the future if you wish to update to a newer revision of the game and lets say jagex decides to change all item id's it will be a big hassle to change the item id's in all classes for all skills, better make all items like


--- Code: ---public static int RUNE_ESSENSE= 7936;

--- End code ---
etc..

in one big ItemConstants.java or something then you just do

ItemConstants.RUNE_ESSENSE

so in the long run you just have to modify one file to fix all item id's up.
same should be applied to ObjectConstants.java

ObjectsConstants.NORMAL_TREE
ObjectsConstants.DOOR
ObjectsConstnats.IRON_ORE

etc..

--- End quote ---
That is just as bad.

I rather do
Item: if(item.equalsIgnoreCase("rune essence") { /* do something * /}
Objects: if (object.equalsIgnoreCase("tree") { /* do something * / }

That way you're using less memory and are not creating any unneeded objects.

Edit:
public static int PURE_ESS = 7936;
public static int RUNE_ESS = 1436;

Those are not even constants, why is everything static?
       

--- End quote ---

Haha even

--- Code: ---item.equalsIgnoreCase("rune essence")

--- End code ---

what if they change the name of the item/object in the future lol, but thats just going crazy lol.
But yeah I also did it the string way to include all the doors/ladders without including all id's for making the changing depth work, but still even though it's simple it will create problems which you will either patch by adding a quick fix patch like a array of doors/ladders that won't work without having some quest complete or something etc.. when the right way of doing this is making definitions for each item/object in one area so you can see all the triggers/purposes of all items in one file whether its xml file or whatever, even runescape does this in their cache each item has properties such as stackable/price etc.. not as much as serverside has but same thing.

ya as for constants they should be with a final modifier so you can't alter them but really no one would edit them anyways who cares in the long run.

@sk8rdude461: ya i'm just writing some criticism i know you did a good job anyways, maybe someone reading this will incorporate what i said into their servers etc.. and other good ideas people write and everything will just get better. 

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version
Powered by SMFPacks SEO Pro Mod |