[Runescape Private Servers] [RS Private Server] [Runescape PS]
Recommond Runescape Private Server
Server Name
Ip Address
Open Time
Description
Client Download
Webclient
Admin contact
Version
LcScape
69.163.142.129
2010/03/17
1000x exp,full member area,easy for pk,party hat
Click Here
317
Rs3runescape
58.22.101.138
2009/06/17
1000x exp,full member area,easy for pk,party hat
Click Here
317
Runescape 7
www.rs3server.com
2009/03/17
1000x exp,full member area,easy for pk,party hat
Click Here
317
Free Runescape Private Server List
Server Name
Ip Address
Open Time
Description
Client Download
Webclient
Admin contact
Version
Runelife
Unknown
2010/05/21
Runelife The New Revolution.New NPC's New Items and allot more!
317
Orca Scape
Unknown
2009/04/26
Working stances All specs Working dfs GODSWORD SPECS!...
See The Site
508
BlazeScape
Unknown
2009/06/17
Empty
See The Site
Unknown
Death By DNA
Unknown
2009/12/12
KING BLACK DRAGON/REAL GS STANCES & SPECIALS/WEBCLIENT/PETS
Click Here
See The Site
Unknown
EvoPro
Unknown
2010/03/16
Empty
317
Dynamic-scape
c3dscape.no-ip.biz
2009/12/22
More spots will be open once we get more players!
317
V0idAg3
v0idag3pwn.no-ip.biz
2009/04/03
Full WOrking SHops!custom items! full working d-claws and plate!..
Visit
See the game
Unknown
zgspk
Zgspk.no-ip.org
2010/04/01
Have Great experience in Skilling, Pking, Exploring Never seen before Arenas!
See the site
317
R-uneCheck
Unknown
2010/03/29
Gigantic Updates coming - You will be AMAZED!
Visit
See the game
562
BrutalPalace
Unknown
2010/03/29
Gigantic Updates coming - You will be AMAZED!
Visit
562

Skip to content


The Basics of Java

Table of Contents

(Orange hasn’t been added, yet)

  1. Introduction
  2. Quick Reference
  3. Fields/Variables
  4. Methods
  5. Arrays
  6. Strings
  7. Flow and Control
  8. Classes
  9. Object Oriented Design
  10. Generics
  11. Data Structures
  12. Efficiency, Big-O
  13. Multi-Threading
  14. Basic Bytecode
  15. How this tutorial applies to RSPS
  16. Practice and project ideas
  17. Links

Introduction

Java is a object oriented programming language that was originally developed by James Gosling at Sun Micro-systems. The language is a interpreted language that is compiled into Bytecode. The JVM then interprets the Bytecode at runtime. This is a very powerful feature, giving Java the ability to live up the phrase “Write once, run anywhere”, and is the foundation of Java’s portability. Any good Java programmer should definently understand at least some basic bytecode, as knowing what your code actually compiles down to is a very powerful bit of knowledge that will help you understand how sometimes 4 lines of code can be better than 3 lines of code when compiled, or how one way of doing something is better than another. Java’s syntax is very similar to C’s. It is a very powerful language that is still one of the top languages in use today (along side C, C++, and .NET languages).


^ http://www.tiobe.com/index.php/conte…pci/index.html

It is a simpler language unless you venture to some of its lower level aspects, and is a great language to learn as your first experience in programming.

(will be expanded)

Quick Reference

Primitive Data Types:

Data Type – Value Range – Default Value – Memory Size

int – -2,147,483,648 to 2,147,483,647 – 0 – 32 bits (4 bytes)
short – -32,768 to 32,767 – 0 – 16 bits (2 bytes)
byte – -128 to 127 – 0 – 8 bits (1 byte)
long – -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 – 0 – 64 bits (8 bytes)
float – ~1.4 E -45 to 3.4028235 E 38 – 0.0 – 32 bits(4 bytes)
double – ~1.79769313486231570 E 308 to 4.94065645841246544 E -324 – 0.0 – 64 bits (8 bytes)
boolean – true/false – false – not precisely defined but it reprsents 1 bit
char – \u0000 to \uffff (0 to 65,535) – \u0000 (0) – 16 bits (2 bytes)

Remember that Objects have a default value of null.

Uses:

int: The default numeric primitive
short: Numeric primitive that is more compact within large arrays
byte: Smallest numeric primitive, useful for compactness within large arrays
long: Large numeric primitive used to represent very large numbers
float: Decimal primitive that uses less space than double, useful for large arrays
double: Default decimal primitive
char: represents a single character in unicode
boolean: represents true or false values

Special Escape Sequences: (Used in String literals)

\n new line
\t tab
\\ backslash
\” double quote
\’ single quote
\r carriage return
\b back space
\f form feed

Access modifiers:

modifier – effect – use

public This field/method can be referred to inside of the class and outside of the class.
private This field/method can only be accessed inside of this class.
protected This field/method can be accessed inside of this class, and any of its subclasses.(REMEMBER, protected access also gives it package access).

No access modifier at all when declared in a global context gives the field/method package access. Packaged access means it can be accessed inside of that class, and by any class inside the same folder as that class.
(will be expanded)

Operators

Arithmetic Operators

+ – Addition, also used to append Strings
- – Subtraction
/ – Division
* – Multiplication
% – Modulus (Remainder operator) returns the remainder through division

Incremental Operators

++ – increments by 1
– decrements by 1

Equality Operators

== – returns true if the values on either side are equal
>= – returns true if the value on the left is greater than or equal to the value on the right
<= – returns true if the value on the left is less than or equal to the value on the right
> – returns true if the value on the left is greater than the value on the right
< – returns true if the value on the left is less than the value on the right
!= – returns true if the values on either side are not equal

Conditional Operators

&& – condition “and”
|| – condition “or”

Bitwise/Bit Shift Operators

& – bitwise “and”
^ – bitwise exclusive “or”
| – bitwise inclusive “or”
>> – shifts the pattern to the right
<< – shifts the pattern to the left
>>> – shifts a 0 into the leftmost position

Other Operators

instanceof – type comparison, returns true of the object on the left is of the same type of the value on the right
? : – condition operator, shortcut for “if – else”.

Conventions

Conventions are severely lacking in this community. PLEASE USE THEM!

Classes:
the first letter in each word in a classname should be capitalized. Class names should be nouns and should be relevant to the job they perform/represent. The code within the class should be organized in this order:

  1. package
  2. imports
  3. class or interface declaration
  4. static fields
  5. instance fields
  6. constructors
  7. methods

Classes and methods should be well commented.

The code itself should also be clean. Method names should be verbs, first letter of the first word lowercase, the first letter of words following should be capitalized. Field should follow the same capitalization pattern of method names, except the names should be nouns. Final field should have capitalized names. You should indent for each block of brackets, indention should traditionally be 4 spaces (most people use tab for simplicity).

for more information on conventions see this link:
Conventions

Example of conventioned class:

Code:
package test;

import java.io.File;

public class Test {

    private final int FILE_COUNT = 5;
    private boolean isDone = false;

    public Test(String[] files) {
        for (int i = 0; i < files.length; i++) {
            closeFile(files[i]);
        }
    }

    private void closeFile(String fileName) {
        new File(fileName).close();
    }
}

Note that the code above is pointless. Also, notice that even though the brackets used after the for loop in the constructor are not needed, its good habit to use them anyone to prevent errors.

Encapsulation is also a very good technique to follow in class design, we will cover that when we get the classes though.

(will be expanded)

Fields/Variables

In Java, both the terms variable and field are used, in the tutorial we will use both terms. A field is essentially a variable that holds a saved value. There are 4 types of fields:

  • Instance Fields

    An instance field is a field that has a global scope within a class, they are called instance fields as they are non-static and each instance of that particular class has a separate “version”, or value, of this field.

  • Class Fields

    Class variables, like instance fields, also have a global scope in a class. The difference being that Class Fields are static, meaning that each instance of that class all shares that same “version” or value of the class field.

  • Local Fields

    Local Fields have a scope ONLY inside of the method that it is declared it. As a result, Local Fields do not have access modifiers as they are not global. You treat them like any other field, its just that they typically hold temporary values that only can be found in that method.

  • Parameters

    Parameters are not fields, they are variables, this is one of the few cases where the terms differ. A parameter is essentially like a local field. Parameters in Java work through call by value (for the most part), and are used to “send” a method a value when called.

Just remember the general differences for now, I will show a couple examples.

Alright, declaring a field is very simple:

TYPE NAME (= VALUE)*;

Example:

Code:
int number = 5;

*being optional, if you don’t declare a variable with a value the compiler will assign it a default value listed in the data section of the tutorial.

This basically tells the computer to break off a chunk of memory depending on the type, and assign it the value of 5. Assuming this is in a method, it has no access modifier.

The syntax is the same for all types:

Code:
int iNumber = 5;
byte bByte =5;
char cChar = 'f';
float fFloat = 5.7;

They all have the same syntax. Now creating a new instance of a class is a bit different but we can explain that later.

Now, we know how to declare a field. Lets put it to some use. Math in Java (or pretty much all languages that have a C based syntax) is fairly obvious:

Code:
int a = 5;
int b = 3;
int c = a + b;

Makes sense? the value of c is the values of a and b added together. The same syntax for any math operator.

Code:
int a = 5;
int b = 3;
int c = a / b;
c = a * b;
c = a - b;

Notice that I didn’t include the type in front of c the second and third times I assigned it values. You only include the fields type when you declare it, after that the compiler knows the type and name of the variable, so you just refer to it by its name to reassign values or use its value.

This is a general overview of Fields/variables, I’ll explain in more detail as far as different access modifiers etc when we get to that point.

Methods

Think of a method as something that you throw values into (or at least can), it performs some sort of task, and then returns a value (if its return type isn’t void at least). Its hard to come up with good metaphors =P. All in all, a method is a series of statements. Statements always end in a semicolon, if you remember from the examples having to do with fields.

If you also remember parameters, a parameter is a value that is given to the method as an argument when it is called, that value is usually required for that method to do its task (why have parameters for no reason?). Multiple methods can have the same name if they have parameters that are different, this is called overloading.

A methods declaration syntax is a bit different:

ACCESS MODIFIER* SPECIAL MODIFIER* TYPE NAME (PARAMETERS) { STATEMENTS }

*being optional once again.

Example:

Code:
public int getDouble(int a) {
    int b = a * 2;
    return b;
}

Now you may be thinking, “WHAT THE FFUUU-”, but don’t worry! It’s simple!

I’ll explain this in order. This method is public, meaning it can be access within and outside of its class/object. This method is also of type int, meaning this method returns an int value. It takes a single parameter of type int, meaning that when this method is called, it must be given an int as an argument. The brackets enclose the body of the Method, for every { you need a }, its a very simple rule that when not followed can lead to unhappy time wasted searching and counting brackets.

A return statement exits the method with the value specified, any code beyond a return statement will not be called and usually you will get an error about unreachable code at compile-time. If the method is of type void (which has no value remember), then you use an empty return statement by just using the word return. You can use a return statement to exit a method early as well.

As of now, this method does nothing. It is just declared and exists. The method doesn’t actually “perform” until it is called. Example of how to call this method:

Code:
getDouble(5);

Notice, that like fields, we only need to use the method name. Once the method is declared you just access it through its name. Notice also that within the parenthesis we included the number 5. Remember our method having a single parameter of int? There’s the argument to fulfill the methods parameters.

If a method has parameters, you MUST provide them when called, meaning the following call would not compile:

Code:
getDouble();

or

Code:
getDouble(5, 5, 5);

Your arguments when you call the method must match the methods parameters.

Now, remember how we said the method is of type int? That means the method returns an int value, meaning the method call itself can be treated as an int. In a method, if it is not of type void, you MUST return a value. The return type void essentially means that the method doesn’t have a return value, in which case the return statement isn’t required.

To return a value, you just use the keyword “return” followed by the value.

For example:

Code:
int a = getDouble(5);

The value of a is now 10. Make sense?

You can also create a method of ANY type. Meaning any primitive type, or any object (as long as the class exists, we will explain that later).

Here is a second example:

Code:
private double divide(double f, double g) {
    return f / g;
}

This may look more complicated than the previous example, but it’s not! This method is private, meaning it can only be called within its class. It is of type double, meaning it returns a double value. It also takes 2 parameters, both of type double. Now the return may look a bit different, it is essentially the same thing as

Code:
private double divide(double f, double g) {
    double result = f / g;
    return result;
}

Both are the exact same thing, the first just being more compact. It would be called like this:

Code:
double hey = divide(6.0, 3.0);

hey now being 2.0.

Now, we will learn our first standard library method (YAY!). It being System.out.println. Now for now, ignore the System.out., just focus on what the method does. It basically prints whatever argument you give it to the command prompt.

Example:

Code:
System.out.println("Hello world!");

Now to combine what we have done so far:

Code:
private void getDouble(double f) {
    return f * 2.0;
}

private void test() {
    System.out.println(divide(getDouble(5.0), 2.0));
}

Woah, thats complicated right? Nope! Lets review. This method is private, meaning it can only be called in its class. It is of type void, meaning it has no return value. It has no parameters, meaning it doesn’t need any arguments, but you still need to include the parenthesis when you call it. Now this part make look kind of crazy to you right now, but its simple. Basically, this will print the value returned by divide when we pass it arguments of the value of getDouble given the argument of 5.0, and the second argument of 2.0.

That may sound complicated, but lets step through call by call:

getDouble(5.0) returns 10.0, so we are essentially calling divide(10.0, 2.0), which in turn returns 5.0, so System.out.println is given the value of 5.0 to print to the command prompt. Just think of it this way, the computer just treats the method calls as the values they return in this situation.

We will get more in depth with methods later on when we discuss classes, (that’s going to be the fun part of the tutorial).

Arrays

Alright, up to this point we know how to declare some basic values, do some basic math, and understand the over all basics of methods. Now we can discuss arrays! Arrays are essentially a section of memory statically allocated so that values of the same type can be organized in sequence. Put simpler, an array basically holds multiple values of the same type in a multiple “slots”.

The general syntax for an array uses [ ].

Code:
int oneToFive[] = { 1, 2, 3, 4, 5 };

That would be an array of int’s. Arrays are very useful for storing values in an organized value. You can get the length of an array by using the arrays length field:

Code:
int oneToFive[] = { 1, 2, 3, 4, 5 };
System.out.println(oneToFive.length);

That would print the number 5 because there are 5 slots in that array. Now you can also declare an empty array:

Code:
int[] oneToFive = new int[5];

Notice the square brackets, they are now after int, and notice the number within the square brackets at the end, that is the length of the array. Ignore the new operator for now, that will be explained later on.

Accessing specific values in an array is just as easy:

Code:
int[] oneToFive = new int[5];
oneToFive[0] = 1;
oneToFive[1] = 2;
oneToFive[2] = 3;
oneToFive[3] = 4;
oneToFive[4] = 5;

Now you may be wondering why I only went up to four, remember, the index to the first slot in an array is always the number 0. So in an array that has the length of 5, the slots would be 0, 1, 2, 3, 4. Arrays work hand in hand with loops, which will be explained soon.

You can create an array of any type, primitive or object:

Code:
double nums[] = {0.0, 2.3, 4.4};
System.out.println(nums[2]);

That would print the number 4.4, as the arrays lenght is 3, so the last slot in the array has an index of 2.

Strings

Since Strings are essentially the most common object used in Java, I decided I might as well dedicate an entire section to them.

A string basically represents a string of characters. Strings are implicitly created meaning you won’t have to use the new operator unless you’re converting a byte array or something else into a String.

Code:
String hello = "Hello!";

There are plenty of nifty String methods that make strings very easy to use.

The equals(String) method, very self explanatory, its case sensitive, and checks to see if 2 strings are equal.

Code:
if ("hello".equals("hello"))

Remember, Strings are implicitly created, meaning that “hello” is literally treated like a String object, which is why the above code is legal.

Another version of the equals method is equalsIgnoreCase(String), it does the same thing but without case sensitivity.

Here are some common string methods:

toLowerCase() – returns a lower case version of the string
toUpperCase() – returns a upper case version of the string
charAt(int) – returns the character at the specified index in the string, after all, a string is an array of characters at its core.
substring(int), substring(int, int) – returns a string based off of the given index’s.
indexOf(String) – returns the index of the first occurrence of the specified string.
lastIndexOf(String) – returns the index of the last occurrence of the specified string.
startsWith(String) – returns whether or not the string begins with the specified string.
endsWith(String) – returns whether or not the string ends with the specified string.
split(String) – returns an array of string resulting from splitting the current string at every occurrence of the specified string, similar to the StringTokenizer.
toCharArray() – returns a character array created from the string.
getBytes() – returns an array of bytes from the string.

Flow and Control

Now we get to the more logic part of programming. Without control and flow, it is impossible to write a program.

Coniditional Statements

We will start of with the if statement:

Code:
int f = 4;
if (f == 4) {
    System.out.println("F is four");
}

Remember those curly brackets from methods? Well here they are again. Brackets are used to enclose blocks of code. For instance, the above code prints “F is four”. The if statement simply checks if the condition specified is true, if so it will execute the code within its block, if not it will continue, ignoring the code in its block.

If we have a conditional statement followed by only a single statement to execute, brackets are not needed. If a conditional statement is not followed by no brackets it will only execute the first statement after the condition. The same is true for loops.

Now for some logical operators, they are defined in the very beginning of this tutorial if you need to look back. Like in the above example, == is used in checking for values, = is the ASSIGNMENT operator, it is not the same as == and cannot be used to generate the same effect. Now in addition to ==, we have !=, &&, and ||, meaning equals, not equals, and, and or respectively.

An example of the and:

Code:
int f = 4;
if (f > 3 && f < 5) {
    System.out.println("F is four");
}

This code will also print “F is four”, and is fairly self explanatory. If f is greater than 3, and f is less than 5…. is how it should be read, picture it like that in your head and it will make more sense. The || operator can be used in a similar way to mean “or”.

Code:
int f = 4;
if (f == 3 || f == 4) {
    System.out.println("F is four or three");
}

This code will print “F is four or three”, as f has the value of 4. I suggest going to the top of this page and reviewing the operators used with conditional statements to make sure you know them.

Now working along side if the if statement, are the else if statement and the else statement.

They work as would be expected:

Code:
int f = 3;
if (f == 4) {
    System.out.println("F is four");
} else if (f != 4) {
    System.out.println("F is not four");
}

This code would print “F is not four”. Read it can be pictured like this: “If f equals 4 … else if f does not equal four…”. Now we also have the else statement, which stands alone as a “last resort”.

Code:
int f = 2;
if (f == 4) {
    System.out.println("F is four");
} else if (f == 3) {
    System.out.println("F is three");
} else {
    System.out.println("F is not four or three");
}

This code would print “F is not four or three”, and Read it can be pictured as “If f equals 4 … else if f equals 3 … else”. The else block is executed if none of the other conditions are true.

We also have a sort of shortcut, called the conditional(ternary) operator. Its syntax may look weird but its very simple:

Code:
CONDITION ? IF TRUE : IF FASE

Example:

Code:
boolean ass = true;
System.out.println(ass ? "ass" : "no ass");

That code would print “ass”, as ass is true. Notice how we used it to represent a value, this would do the same without the shortcut:

Code:
boolean ass = true;
if (ass) {
    System.out.println("ass");
} else {
    System.out.println("no ass");

The operator doesn’t really provide much other than simplicity and cleaner (sometimes) code.

You can also “shortcut” it on booleans, if you noticed in the above example rather than having:

Code:
if (ass == true)

I simply used:

Code:
if (ass)

Reason being that a coniditional statement always evaluates to either true or false, so having ass == true is similar to having true == true or false == true (depending if ass is true or false), which is basically pointless. Since we can use

Code:
if (ass)

You may be wondering how we would “shortcut” check if ass is false, that’s when we use the ! operator, which simply represents “not”:

Code:
if (!ass)

Meaning if ass is false.

Now for more control, next we will explain loops.

Loops

Now, at this point what we have covered has been very procedural and tedious. Loops are a very powerful tool in any programming language and another fundamental part of control flow. A loop cycles until the specified condition is no longer true, they have a couple different styles though. Exiting a loop early can be done by using the break keyword, if you wish to end a specific cycle early but not entirely exit the loop you would use the continue keyword.

There are a couple types of loops.

For Loop

This is the most commonly used loop. Loops are very simple to understand and use. First I will show the syntax of the for loop:

Code:
for(int i = 0; i < 20; i++)

Lets explain each part of the loop:

Code:
for(INITIALIZATION ; CONIDITION ; INCREMENTATION)

Simply put, the first “slot” in the for loop is executed before the loop begins, it is usually used for declaring your index variable. The second “slot” in the for loop is the conidition, the loop will continue to cycle until that conidition is false. The last “slot” in the for loop is the incrementation, this is called after each time the loops cycles and is usually used to control the condition (or the amount of times the loop cycles).

Example:

Code:
for(int i = 0; i < 20; i++) {
    System.out.println(i);
}

The above code will print i until i is no longer less than 20. This idea of looping using an index is very useful when used with arrays:

Code:
int nums[] = {3, 5, 2, 3};
for (int i = 0; i < nums.length; i++) {
    System.out.println(nums[i]);
}

This loops through every slot in the array and prints its value. Remember that the first slot in an array is 0, so the last slot in an array is the arrays length – 1.

The “slots” in a for loop don’t always have to be meet, meaning this would result in an infinite loop:

Code:
for (;;)

You can fill in virtually any conidition, initialization, and post-cycle statement that you wish:

Code:
String a ="";
for(;a.length() != 5; a += "a")

Is fairly self explanatory, appends the letter “a” as long as the strings length is 5.

While Loop

This loop is probably even simpler than a for loop:

Code:
while(CONIDION)

This basically continues to run until the conidition is false. It can be set up for comparison to a for loop:

Code:
int i = 0;
while (i < 20) {
    //do stuff
    i++;
}

This essentially would work like a for loop. Now you may have noticed the 2 forward slashes. That is called a comment. You can place comments into your code and the compiler will ignore that line.

// comments an entire line

/* */ comments everything between the asterics.

The while loop is useful when you don’t have to loop with a numeric value. It also is useful for infinite loops, which are used more with threads which will be explained later on. But since coniditions always evaluate to true or false, the following syntax is legal and will create a never ending loop:

Code:
while (true)


Do While Loop

The do while is very similar to a while loop. The only real difference is that it gaurentees at least 1 cycle of the loop as the conidition is checked at the end of the loop rather than the beginning like a while loop.

Code:
int i = 5;
do {
    System.out.println("looped");
} while (i != 5);

That would print “looped” once, as the conidition isn’t checked until the end of the loop. Note that the syntax is a little different.

For Each Loop

This loops was essentially designed as a sort of shortcut replacement for iterators, which are used with data structures, which we won’t talk about until later. We won’t use the for each loop until later when we discuss data structures, but we might as well cover here as it fits in.

here is the syntax for a for each loop:

Code:
for (TYPE NAME : ITERABLE)

It basically loops through every value in a structure or array, assigning each value to the specified variable each cycle until there are no more values left.

Code:
int nums[] = {3, 4, 3, 2 };
for (int i : nums) {
    System.out.println(i);
}

This will loop through each value in the array and print it.

This loop is really meant to be used with a collection of some sort, and really shouldn’t be used in any other way.

Lets compare:

Code:
class a {
    int nums[] = {2, 4, 6, 2, 3, 3, 3, 3, 3};

    void b() {
        for (int i = 0; i < nums.length; i++);
    }

    void c() {
        for (int i : nums);
    }
}

Now lets look at the bytecode generated:

Code:
void b();
  Code:
   0:    iconst_0
   1:    istore_1
   2:    iload_1
   3:    aload_0
   4:    getfield    #2; //Field nums:[I
   7:    arraylength
   8:    if_icmpge    17
   11:    iinc    1, 1
   14:    goto    2
   17:    return

void c();
  Code:
   0:    aload_0
   1:    getfield    #2; //Field nums:[I
   4:    astore_1
   5:    aload_1
   6:    arraylength
   7:    istore_2
   8:    iconst_0
   9:    istore_3
   10:    iload_3
   11:    iload_2
   12:    if_icmpge    26
   15:    aload_1
   16:    iload_3
   17:    iaload
   18:    istore    4
   20:    iinc    3, 1
   23:    goto    10
   26:    return

Notice the difference? Only use the for each loop when working with something that can't get iterated through using an index.

Error Checking

Java's error checking is excellent compared to C's, (or even C++'s though they have a similar concept) in my opinion. Error checking has a couple routes. First off, basic error checking (which really isn't much of error checking, more like invalid input checking) is fairly simple:

Code:
int doubleNumber(int num) {
    if (num < 1)
        return;
    return num * 2;
}

The line checking to make sure that num is positive would be an example of basic input checking. Java has a feature for runtime errors called exceptions, exceptions when caught and dealt with are very simple to manage and make solving problems much easier. When ignored however, searching for runtime errors can become tedious and painstaking. Catching an exception is very simple using the try-catch clause:

try {
/*statements that may produce exceptions */
} catch (EXCEPTION) {
/* code to execute if an exception exception occured
}

Example:

Code:
String number = "wut";
try {
    int a = Integer.parseInt(number);
} catch(NumberFormatException e) {
    e.printStackTrace();
}

When compiled, this code has no issues, but once ran its a different story. When the program tries to parse "wut" from a String to an integer and exception is thrown for obvious reasons, but the exception is caught and the a trace of calls up until the exception is printed making the cause easier to find. Then the program will continue. Now if we didn't catch that exception, the program would run and then crash once the exception is thrown without being caught.

All exceptions in Java are subclasses of the Exception class, so if you have a block of code that could possibly throw multiple exceptions, if you don't have a specific task for each exception you could just catch Exception:

Code:
try {
    /* code */
} catch(Exception e) {
    /* code */
}

That would catch any exception thrown in that block. Sometimes, a try-catch statement is required though, and this a good practice. You simple just add a "throws" statement along side the method declaration:

Code:
public int parse(String a) throws NumberFormatException {
    Integer.parseInt(a);
}

This would force you to check for the exception NumberFormatException when calling the parse method:

Code:
try {
    parse("25353");
} catch(NumberFormatException e) {
    System.out.println("Error parsing String to Int");
}

We can also forcely throw exceptions within our code using the "throw" statement:

Code:
public int parse(String a) {
    if (a.length() < 1)
        throw new NumberFormatException();
    else
        Integer.parseInt(a);
}

Notice that we used the new operator, Exceptions are objects.

There is also a balance between exiting a method early if a problem occurs, which is sometimes not forceful enough and the user may not even know that an error occurred, and throwing an exception, which is sometimes to forceful. This is called asserting.

Code:
public int parse(String a) {
    assert a.length() > 0;
    Integer.parseInt(a);
}

If the length of a is less than 1 than an AssertionError is thrown. This assures that from any point after the assert statement that the asserted condition is true.

Switch Statement

A switch statement is used for testing a variable for multiple numeric values. You can switch types other than just integer primitives (byte, int, long, short) like char's and enum's, but in reality chars and enums are actually numerical at the core.

A switch statement is generally a pimped out series of goto statements used for checking the value of a variable, it is generally faster and cleaner than using a series of coniditional statements and this community severely lacks the use of the switch.

The syntax is fairly simple:
switch (VARIABLE) {
case VALUE:
//code
}

of course with as many cases as you need. You can also use the break keyword in switch statements to exit the switch, a common mistake is to not use the switch statement, since in reality a switch is a complex series of goto statements and labels, the code will not stop executing after that specific case is over unless you break:

Code:
int num = 1;
switch(num) {
    case 1:
        System.out.println("one");
    case 2:
        System.out.println("two");
    case 3:
        System.out.println("three");
}

The above code would print "one", "two", and "three" as the program would jump to case 1 and execute from there onward. To prevent this, we use the break statement:

Code:
int num = 1;
switch(num) {
    case 1:
        System.out.println("one");
        break;
    case 2:
        System.out.println("two");
        break;
    case 3:
        System.out.println("three");
        break;
}

This would print only "one" as it would break out of the switch at the end of the case. Not using break statements can also be a good trick, for example:

Code:
int num = 3;
if (num == 3 || num == 2)
    System.out.println("Num is two or three");
else
    System.out.println("Num is not two or three");

would be the same as:

Code:
int num = 3;
switch (num) {
    case 2:
    case 3:
        System.out.println("Num is two or three");
        break;
    default:
        System.out.println("Num is not two or three");
        break;
}

Now if num is 2, it would jump to case 2 and continue to run until it hits a break, the same being with case 3. You may be wondering what the default statement is. Default is jumped to if the value of the variable doesn't match any other cases, meaning if num wasn't 2 or 3 it would jump to the default case.

Classes

Here's the fun part of the tutorial. A class is basically a template that defines the data and actions that specific objects derived from that class can use. It is probably the most important aspect of Java, and it goes hand in hand with object oriented design.

Every java program must include at least a single class. It is required, unlike other languages that allow stand-alone procedural code, java is entirely object oriented.

declaring a class is fairly simple:
(ACCESS MODIFIER)* class NAME

*being optional

example:

Code:
public class Test {
    //methods etc.
}

If you read my description of a class, you probably noticed the word object, and you may have noticed when we discussed the String. An object is a specific instance of a class. Unless static, every object has its own "version" of the classes data (or public field). This is the difference between static and non-static fields and methods. Non-static fields and methods must be accessed and called on a specific object, while static methods are not called on a specific object and therefore cannot directly modify non-static data.

Example:

Code:
public class Test {
    public int number = 5;
}

It would be illegal code to attempt this:

Code:
Test.number = 3;

Because number is non-static, therefore we must access it through a specific instance of that class (object).

Creating an instance of an class is fairly simple also, this is where the "new" operator comes in.

Every class has a constructor, whether you define it or not. A constructor is called when you create a new instance of a class. Constructors are usually used for the purpose of giving that instance specific data that it needs in order to be used.

A constructor is declared just like a method except that it has no type and its name is the same name of the class.

Example:

Code:
public class Test {
    public int number;

    public Test() {
        number = 5;
    }
}

Now we can create a new instance of that class using the "new" operator:

Code:
public Test test = new Test();

Like that. Now we can also access non-static number:

Code:
test.number;

like so.

Accessing data/methods from a class/object is done using a period (.). Now constructors can also take parameters, just like any other method:

Code:
public class Test {
    public int number;

    public Test(int i) {
        number = i;
    }
}
Code:
public Test test = new Test(5);

Like that.

AVOID STATIC. Static is typically used for mathematical operations where calling on a specific object isn't necessary, or if the class is abstract and therefore cannot be initialized (we will get into that later). Other than that it is bad practice and causes spaghetti code and bad design.

Classes are also where usability, practicality, and efficiency all clash. Faster is not always better, and neither is prettier. Using a stable and effective combination of both, while keeping your code reusable and easy to understand is only gained through planning and practice. This the point in programming where structure becomes more important, and in order to avoid "glue code", you should plan and think things out before jumping into a project. An example would be when I wrote my basic chat system/instant messaging thing. I rewrote the same project 3 separate times, as I would get half way through and realize that I could have done something better, or that my code was ugly and I found myself creating more and more spaghetti code. Unfortunately, I learned how and why to plan by messing up many times, and I'm a fond believer in the concept of learning though trial and error (though tutorials always help too ).

Spaghetti code is when you have unorganized code that is very difficult to follow and understand. As beginners, this is a very common thing to encounter as people tend to just "write whatever works" without caring about its overall design. This may be fine for simple tasks, or even small pieces of work, but in the long run it is a very error prone and pain staking habit. This kind of code is known to produce "interesting" errors that are very difficult to find, as tracing through your code in a logical manner is very difficult without it being properly designed.

Glue code is usually a result of both bad design/lack of design and spaghetti code. It is when you end having to write, well, crappy code to fix or extend onto your project. If you find yourself having to go back and rewrite half your methods, add methods that are basically copy and pasted from another place in your project and modifying a few lines, or are forced to overuse static, then you're most likely dealing with glue code.

But, for now you're probably just thinking "I don't care, I just want my free runescapes to have more players!", that's great, and I realize that the majority of people won't hesitate to add more glue code and spaghetti code into their massive piles of static and illogical code even after reading this tutorial, but I hope my rambling helps at least one person who is reading this tutorial to actually learn something, and not just figure out "how to ad dem ints".

Anyway, back on topic. Similar to the concept of static being used for mathematical operations, it is also used in what is called a utility class.

You can divide classes into 3 unofficial categories:

Utility Classes

A purely static class, has static fields and methods. An example would be the Math class from java's library, or the misc class from the majority of RSPS bases.

These typically are used for storing methods that perform some sort of algorithm and don't need to be called on a specific object.

Actor Classes

These typically perform some sort of job. This is one of the more common classes, an example being the StringTokenizer class. Usually the name ends in -er or -or. Good for more complex jobs than something like a method that can handle along and that may need to be done multiple times.

Representative Classes

Sort of an unofficial category I just added. Used to represent something, for instance the Player or Client classes in RSPS. Or the String class. These are the most common type of class, and is a wide category as they typically take concepts from the other two.

Inheritance

Inheritance is the foundation of object oriented design. We will start of with simple superclass - subclass relations. When you extend a class, you inherit that classes methods and fields. You then have the ability to override them, add methods and fields specific to the subclass, or call the superclasses methods or access its fields.

Up til this point, we haven't mentioned the keywords this or super. This is an implicit parameter added by the compiler, it is a reference to the object that owns the method that is being called. As for inheritance, when you extend a class, the subclass is also now type of the superclass, which is why in error checking we can catch just the Exception class as all the specific exceptions are subclasses of Exception, thus making them all type of Exception also. Parent classes should be more general than subclasses, here is a simple example:

Code:
class Vehicle {

}

class Truck extends Vehicle {

}

class Car extends Vehicle {

}

Now, we could create a method that takes a parameter of type Vehicle, and be able to use objects of all three of these classes and have it work. This concept is called polymorphism, as the compiler doesn't know what specific class the object originated from until compile time.

Code:
public void drive(Vehicle v) {

}

drive(new Car());
drive(new Truck());
drive(new Vehicle());

Remember, you can always go from more specific to less specific, but never the other way around, meaning the following example would not compile:

Code:
public void drive(Car c) {

}

drive(new Car());
drive(new Truck());
drive(new Vehicle());

Even know Car is of type Vehicle, we can't go from less specific to more specific.

We will fill in some shit code just to use for out example:

Code:
class Vehicle {
    public int tires;
    public Vehicle(int tires) {
        this.tires = tires;
    }

    public void drive() {
    }

    public void park() {
    }
}

class Car extends Vehicle {
    public Car() {
        this(4);
    }

    public Car(int i) {
        super(i);
    }

    public int getTires() {
        return super.tires;
    }
}

class Truck extends Vehicle {
    public Truck() {
        this(4);
    }

    public Truck(int i) {
        super(i);
    }
    public int getTires() {
        return super.tires;
    }
}

First of all, lets look at the constructor of Vehicle. Notice the use of the implicit parameter this. Both the parameter and the instance field have the same name, but in Java, the local variable always wins over the global. If we had done tires = tires it would have set the parameters value to itself, in other words not doing really anything, but used the implicit parameter this to refer to the objects global variable.

Look at the constructor of both Car and Truck, you can use the word super to refer to the superclass's constructor, so we can explicitly class the superclass's constructor using the word super like a method call. Calls to super's constructor must always be the first line in the subclasses constructor though. Notice the other constructors for Car and Truck, they use the implicit parameter this to call the other constructor of this object, meaning that it essentially calls the other constructor of the same object. Now take a look at the getTires method for both Car and Truck, they use the word super again, but this time in a similar way that we originally used the implicit parameter. Since the constructor called supers constructor, which in turn set tires value, we can use super.tires to refer to that value.

Using this concept, we can require subclasses to implement their own version of methods using a concept known as abstraction. When you declare an abstract method, you must make the class itself abstract. You cannot "new" an abstract class. Abstract methods do not have a body, they are simply the declarations, and as a result the subclasses must implement the code for the method themselves, which is why you cannot new an abstract class as all of the code doesn't exist for that class.

Code:
abstract class Vehicle {
    public abstract void drive();
    public abstract void park();
}

class Car extends Vehicle {
    public void drive() {

    }

    public void park() {

    }
}

class Truck extends Vehicle {
    public void drive() {

    }

    public void park() {

    }
}

This is also a powerful concept as it allows you to create "requirements" for the subclasses, if the subclasses do not have the methods that where declared abstract in the parent then you will receive a compile error.

In java, a class can only extend a single class. In languages like C++ there is a feature of multiple inheritance, so the designers of Java made up for this lack by adding interfaces. Think of an interface as a purely abstract class (sort of). The difference being that in an abstract class, you can still have regular fields and methods, but in an interface, everything is abstract and public. You don't need to declare methods in an interface abstract as they already are by default, and just like an abstract class, you cannot new an interface. You can realize (technical term for implement) as many interfaces as you wish. Rather than using the word extends, you use the word implements.

Code:
interface Vehicle {
    void drive();
    void park();
}

class Car implements Vehicle {
    public void drive() {

    }

    public void park() {

    }
}

class Truck implements Vehicle {
    public void drive() {

    }

    public void park() {

    }
}

And just like abstract classes, interfaces can be treated as a type so you can use it for method parameters etc.

Efficiency

Up to this point, coming from a RSPS background, the majority of you probably don't care to much about, or know to much about, efficiency. A key rule; speed does not equal efficiency, and neither does less code. While in a majority of cases, those two things are the ultimate goal, efficiency in itself is typically measured using big-O.

Big-O is a algorithm used to measure efficiency of code to complete a specific task.
There are multiple types of big-O algorithms:

Constant

O(1)

Logarithmic

O(log N)

Linear

O(N)

Exponential

O(2^N)

Quadratic

O(N^2)

Cubic

O(N^3)

These all have their meanings. N representing the number of operations in relation to the size of data. Meaning constant, being O(1), will always be the same number of processes and speed no matter what data size, and example being opening a file. No matter how large a file is, creating a stream to read/write to that file will always take the same amount of time. Linear is O(N), meaning that the number of processes and time taken is directly proportional to the amount of data, O(N) is usually seen as a single loop. Quadratic, being O(N^2), is usually seen as a nested loop (A loop inside of a loop).

This general notation is used for efficiency. Learn it, embrace it, and use it. big-O is fairly simple to understand once you think about it, the more common algorithms being O(1), O(N), O(N^2), and O(N^3).

Example of O(N):

Code:
private void printData() {
    int data[] = {2, 3, 4, 5, 7, 2, 3};
    for (int i = 0; i < data.length; i++)
        System.out.println(data[i]);
}

Example of O(N^2):

Code:
private void printData() {
    int data[] = {2, 3, 4, 5, 7, 2, 3};
    for(int i = 0; i < data.length; i++)
        for(int k = i; k < data.length; k++)
            System.out.println(data[k]);
}

Links

Use the javadocs! They will answer a lot of your questions:
http://java.sun.com/javase/6/docs/api/

This will also be very useful on specific topics:
http://java.sun.com/javase/6/docs/

This video is good for learning about memory, and pointers:
http://www.youtube.com/watch?v=W8nNd…A56BC7F4A1F852
^ The entire series of all 30 videos is quiet good as well.

Critic all you want, I tend to word things weird when trying to explain things, that or I might have just simply made a mistake

Sphere: Related Content

Posted in Uncategorized. Tagged with , , .

Portforwarding Guide

Step 1: Find your routers gateway IP

Windows 7

1. Click the Windows Orb (Start button)
2. In the search bar at the bottom type CMD.
3. Click the application CMD
4. Type IPCONFIG
5. Find your adapter and then find the gateway IP information, it should look something like: Gateway IP . . . . . . . 192.168.0.1

Step 2:
Set your PC to a static IP address…

Windows 7

1. Click the wireless icon in the right hand sector of the taskbar.
2. Select the bottom link ‘Open network and Sharing Center’
3. In the left hand menu click ‘Change adapter settings’
4. Find your adapter (Should be ‘Wireless Network Conenction’ for WiFi users and ‘Local Area Connection’ for ethernet users)
5. Right click your adapter and select properties
6. Select ‘Internet Protocol Version 4 (TCP/IPv4) and then click the properties button.
7. Click the ‘Use the following IP address:’ ratio button
8. Enter the required information, usually the following:

IP Address: 192.168.*.117
Subnet mask: 255.255.255.0
Default gateway: 192.168.*.1

Preferred DNS server: 192.168.*.1
Alternate DNS server: *leave blank*

*Replace the * with the routers third IP digit so if the gateway IP was 192.168.0.1 you would replace the * with 0.

Windows XP

1. Navigate to control panel, make sure it’s on classic view.
2. Click network connections
3. Right click your adapter and select properties
4. Follow steps 6-8 for Windows 7 (above)

Step 3: Configuring your router

1. Open your preferred browser
2. Enter http:// in the address bar followed by the routers gateway IP so in my example I would type http://192.168.0.1
3. You may be asked for a username and password, most of the time it’s one of the following:

Username: admin
Password: admin or password

4. This is where it gets tricky depending on your router, most routers use similar interfaces so I’ll do a NETGEAR guide and people using different routers can PM me with their router model and I can assist from there.

5. For this guide I’ll be using the NETGEAR DG834GT. Once you logon to the routers remote configuration page select ‘services’ from the menu on the left hand side. This part often isn’t required for most other routers, just NETGEARS.

6. Click ‘Add custom service’

7. In the first box enter the name of the service for example: RSPS. In the second box select TCP/UDP. In the third box enter the port you wish to forward (43594) enter this value into the forth box also.

8. Select ‘Firewall Rules’ from the left menu.

9. You should see two tables, Outbound services and Inbound services.

10. Under outbound services select ‘Add’

11. In the first drop down menu select the service you created before (RSPS).

12. In the second drop down menu select Always allow.

13. Leave both the LAN IP options as Any and the the the Log as always.

14. Click Apply.

15. Click ‘add’ under Inbound services

16. Do what you did for outbound accept you will have a ‘Send to LAN’ textbox now. Enter the static IP you set earlier.

17. Your portforwarding is now complete, finally!

Hope you found this guide useful and remember if you need help PM me the router name/model and I’ll get back to you as soon as I can.

Sphere: Related Content

Posted in Runescape Private Server. Tagged with , , .

How To Make Your Own RuneScape Private Server?

NO! This is not HOW to make a server……

Purpose = To Put All Tutorials Into One, I Know There Have Been A Lot Of These Before But You Still Get People Asking Questions On Really Basic Things So I Will Try To Explain Them Here. Dont Post If You Think This Is Just Another Nooby Tutorial. I Wont Go Into Detail In Coding A Server, But This Should Explain How To Add NPC’s, Add Objects, Add Item On Item, Item on Object, Cases, Adding Menus, Adding Requirements To Things, Chests Giving Random Items, Npc Drops. Therefore, If You Know All This Dont Post If You Think Its Rubbish. Hopefully It Will Actually Help Someone. This isn’t a Copy & Past Tutorial As I Will Explain What Things Happen

—– Adding Npc’s —–
All Current Servers Have A File Called Autospawn.cfg. This Is Where All NPC’s Are Stored In Your Server Therefore Open This And You Should See A List Of Npc’s Like The One Below. Example;

Code:
spawn = 461	2844	3351	0	0	0	0	0	1	Rune Store

Now I Will Explain Each Part Of This

Code:
spawn = 461

This Is Telling You What Npc You Want To Spawn, In This Case It Would Be The Npc 461. To Check All The Other Npc ID’s Go Into Your NPC.Cfg File, Hit Ctrl+F and Type In The Name Of The Npc Your Looking For Then Just Copy Their ID.

Code:
2844 3351

These Are The X And Y Coordinates Of Where You Want The Npc To Spawn In Your Server, Some Servers Should Have A Command Already In Them Such As ::mypos Or Have Your Coordinates Displayed In The Emotes Menu.

Code:
0	0	0	0	0	1

This Is More Difficult In Explaining, This Code Tells You Where Or If You Want The Npc To Move Around. At The Moment The Npc Would Not Move Because There Are No Coordinates Entered And “Walktype” Is Set To 1 Which Is Stationary. I Have Added An Example To Show You What A Moving NPC Should Have

Code:
spawn = 1156	3497	9505	0	3490	9500	3500	9520	2	Kalph Worker

If You Want The NPC To Move Then Change “Walktype” Into 2 And Then Change The X And Y Positions To How Far You Want The Npc To Walk. The First X and Y Positions Are ALWAYS Smaller Than The Set Coordinates, The Other 2 X and Y Positions Are ALWAYS Bigger.

—– Adding Objects —–
If You Want To Delete Or Add New Global Objects Then You Should Open Your Client.java file. This Will Only Work If Your Server Already Has Global Objects Added, Which All Newly Posted Servers Should Have. Hit Ctrl + F And Find This;

Code:
NewObjects() {

Under This You Should See One Of These Two;

Code:
	       makeGlobalObject(XXXX, YYYY, ID, DIRECTION, 10)
Code:
	       addGlobalObject(XXXX, YYYY, ID, DIRECTION, 10)

Example;

Code:
	       makeGlobalObject(2853, 3348, 6552, -1, 10);//altar

Explenation;

Code:
(XXXX, YYYY

These Are Simply Just The X and Y Coordinates Of Where You Want Your Globalobject To Be Placed.

Code:
, ID,

Go Find The ID Of The Object You Want To Add And Put It In Here.

Code:
, DIRECTION,

This will determine which way your object will face.

Code:
10)

This tells you what the thing you are adding, if your only adding Objects Then DO NOT change it otherwise it wont work.

—– Deleting Objects —–
To Delete Global Objects Go Into Client.java, Hit Ctrl + F And Search For This

Code:
Deleteobjects() {

Then Scroll Down And You Should See Something Like This

Code:
  	       deletethatobject(2785, 3175); //plant

This Is Much Simpler Than Adding Objects As All You Need To Do Is Enter The X & Y Coordinates Of The Object You Want To Delete. NOTE: If You Delete An Object You Will Not Be Able To Place A New Object In The Position Of The Deleted Object, If You Want To Place A New Object Simply Add That Object As It Will Automatically Change The Object Thats In Its Place.

—– Item On Item —–
Item On Item Is Simply What It Is, You Use A Certain Item On Another Item And That Can Give Anything From Money, Any Other Item, Exp, Messages etc. Go Into Your Client.java (If Your Server Has A Text File With Item on Items Then Open That) And Under Any Command You Can Add This

Code:
				else if(itemUsed == 243 && useWith == 233) {
					deleteItem(243, getItemSlot(243), 1);
					addItem(241, 1);
				}

Explenation;

Code:
			else if(itemUsed == 243 && useWith == 233) {

This Is Just Telling Which Items Will Be Used Together. However, This Will Only Go One Way. You Will Need To Create Another One Of These If You Wanted The Item 233 To Be Used With Item 243. At This Time Only 243 Can Be Used With 233.

Code:
					deleteItem(243, getItemSlot(243),

1);
This Is Telling You That When You Use The Two Items That The Item 243 Will Be Deleted From Your Inventory.

Code:
					addItem(241, 1);

When You Use The Two Items Together You Will Receive The Item 241. If Your Wondering, I Used This For Herblore When Your Adding Herbs To The Vial Of Water.

This Is As Simple As It Gets, If You Want Anything Else You Should Try It On Your Own, All I Have Done Is Just Explained What Will Happen When You Use Two Items. You Can Also Add Messages, Requirements And Much More. Just So You Know What It Looks Like I Have Posted An Example Of A Much Complicated Item On Item Below:

Code:
				else if(itemUsed == 99 && useWith == 231) {
					if(playerLevel[15] >= 28) {
						deleteItem(99, getItemSlot(99), 1);
						deleteItem(231, getItemSlot(231), 1);
						addItem(139, 1);
						addSkillXP(20000, 15);
					} else {
						sendMessage("You need a higher herblore level to make this potion.");
					}

—– Item On Object —–
This Is Also Simple, You Use A Certain Item On A Certain Object And That Can Teleport You, Give You Items, Exp, Open Interfaces etc. First, Go Into Your Client.java, Hit Ctrl + F And Find This

Code:
+atObjectID+" atObjectY: "+atObjectY+" itemS

IF When You Searched For The Code Above And You Couldn’t Find Anything Like It Then Try Find This

Code:
atObjectID ==

You Should Find Something Like This

Code:
                                if (useItemID == ITEMID && atObjectID == OBJECTID)
                                {
				teleportToX = XXXX;
				teleportToY = YYYY;
                                sendMessage("---- YOUR MESSAGE -----");
                                sendMessage("---- YOUR MESSAGE 2 ---");
                                }

This Is A Simple Item On Object, Again, You Can Make It Much More Complex By Adding Things Such As Exp, Level Requirements etc. Its Telling You That When You Use That Item On That Object You Will Be Teleported And Then You Will Get Two Messages On Your Chat Box.

—– Cases for Objects —–
Cases Represent Objects That Work On Their Own i.e. Portals. Again, You Can Make A Case Very Simple By Adding Certain Messages Or Make It More Complicated. Go Into Your Client.java and Find This

Code:
//QUEST_1 OBJECTS

If You Cannot Find It In Your Server Then Simply Find A Object That Makes You Do Something i.e. Haystacks And Search For Their Case. So Haystacks Would Be Case 300; Because The Object ID Of The Haystack Is 300.
Underneath What You have Just Found You Should See A Lot Of Cases, Find The Object ID You Want To Use (Make Sure The Object Is Usable) And Then Simply Name it “Case OBJECTID;”. Example;

Code:
case 4499:
break;

You Should always add a “break;” to show that you are ending that code. Thats it, nothing is added yet so lets add a teleport to this case.

Code:
case 4499:
teleportToX = XXXX;
teleportToY = YYYY;
break;

This will teleport you to those coordinates when you click on that object. This is at its simplest and it can be used for a ladder or portal. I have coded in a custom castle wars minigame and i used cases for my portals. This is an example of what i coded.

Code:
case 4388: // zammy home
if (playerHasItem(4513) == true && playerHasItem(4514) == true){
sendMessage("You cannot enter with other god items.");
sendMessage("They have been removed.");
deleteItem(4513, getItemSlot(4513), 1);
deleteItem(4514, getItemSlot(4514), 1);
teleportToX = 2441;
teleportToY = 3090;
} else {
if (playerEquipment[playerCape] == 4514 && playerEquipment[playerHat] == 4513) {
sendMessage("You cannot enter with zammy items.");
sendMessage("Please use the bankbooth and store them safely.");
} else {
if (playerEquipment[playerCape] == 4516 && playerEquipment[playerHat] == 4515) {
teleportToX = 2422;
teleportToY = 9526;
sendMessage("You are teleported to the waiting arena.");
sendMessage("Use the portal to begin castle wars.");
} else {
if (playerHasItem(4516) == true && playerHasItem(4515) == true){
sendMessage("Please put on your cape and hat.");
} else {
if (playerHasItem(4516) == false && playerHasItem(4515) == false){
addItem(4515, 1);
addItem(4516, 1);
sendMessage("You get your hat and cape.");
}
}
}
}
}
break;

Feel free to use this, to explain what this does. If The Other Player Has The Opposing God Items On Or In Their Inventory They Will Be Removed. If The Player Does Not Have A Cape Or Hood They Will Get One And By Only Allowed To Enter If They Wear It. Like I Said You Can Add Anything To Cases .

—– Adding Menus —–
In This Part I Will Only Show You How To Add A Menu When You Click On The Skill Icon. Feel Free To Use This If You Need To But I Wont Tell You All Of The Menus. To add a menu so when you click on a skill icon it opens go into your client.java and find

Code:
case 21234: // Burst Of Strength

Above that you should see a line and then above that line you can add all the cases for skill menus.

Code:
case 2161: // attackskillmenu
{
Attackskillmenu();
}
break;

This is just an example of one, the attack skill menu. To add a working menu find this

Code:
public void updatePlayers()

If you using a prviously coded server then when you scroll down you should see already made menus. Then just add this one under the last }.

Code:
	public void Attackskillmenu()
	{

					sendQuest("", 8144);  //Title
					clearQuestInterface();
					sendQuest("", 8145);
					sendQuest("", 8149);
					sendQuest("", 8151);
				        sendQuest("", 8152);
					sendQuest("", 8153);
					sendQuestSomething(8143);
					showInterface(8134);
					flushOutStream();
				}

In the title box enter the name of the skill menu.

Code:
					sendQuest("", 8145);

This is the title of the page.

Code:
					sendQuest("", 8145);
					sendQuest("", 8149);
					sendQuest("", 8151);
				        sendQuest("", 8152);
					sendQuest("", 8153);

Here you just put in what you want your menu to have. If it has a gap in number that means that there is a space between lines. Just add more numbers if you want to have a bigger menu. If you wanted to have a menu open by command then you could use something like this below;

Code:
if (command.startsWith("Attackskillmenu")) {
Attackskillmenu();
}

—– Item Requirements —–
Here I Will Explain How to Add Item Requirements i.e. 80 attack for d bow. First of all go into your client.java and find this.

Code:
public int GetCLRanged(int ItemID) {

When you search this underneath you should see a lot of these;

Code:
:
			if (ItemID == 10713) {
			return 99;
	}

This outlines The Item ID (10713) and then the return 99; tells you what level you need to be able to wear it. As this is under Range it means that you need 99 range to be able to wear that specific item. You can find more underneath or above that one for all different levels. ( This may be different on other sources, im using Czar)

—– Chests Giving Random Items —–
Here we can add a chest that will give random items when the person clicks on it. We will need to modify/add two files, item2 and client.java. First of all go into your item2 and search for

Code:
public static int runerock

under the whole thing you should see.

Code:
public static int runerock[] = {451,451,451,451,451,451,451};

    public static int randomRuneRock()
    {
    	return runerock[(int)(Math.random()*runerock.length)];
    }

This tells you that when you click on this particular rock that you will only get the item 451 (rune ore). Dont use this as a base for mining because it sucks.

Code:
public static int runerock[] = {451,451,451,451,451,451,451};

This is showing what you are declaring, you have to rename runerock to anything that you want. Where you have the 451 items you should also delete them. The item on the left hand side will be the most likely item received from the rock and the item furthest right will be the least likely item recieved from the rock.

Code:
    public static int randomRuneRock()
    {
    	return runerock[(int)(Math.random()*runerock.length)];

Where you have runerock you would have to change to what you named it in the first code. Heres an example of what a barrows chest would look like.

Code:
public static int Barrows[] = {4708,4710,4712,4714,4716,4718,4720,4722,4724,4726,4728,4730,4732,4734,4736,4738,4743,4745,4747,4749,4751,4753,4755,4757,4759};

    public static int randomBarrows()
    {
    		return Barrows[(int)(Math.random()*Barrows.length)];
    }

This is showing you that the item 4708 will be the most likely item received from the chest and that item 4759 will be the least likely.
To add this to a chest go into your client.java and find a case for that chest (look at cases at the top for help)

Code:
case 10284:
addItem(Item2.randomBarrows(), 1);
teleportToX = XXXX;
teleportToY = YYYY;
break;

This would give the person an item from the barrowschest and then teleport them outside.

—– Npc Drops —–
Npc Drops are kind of similar to random chests but Npc Drops aren’t added in client.java. First of all, go into your item2 and do thesame thing that you did in random chests. Just copy + paste an already done code and rename it to what you want. You can use this if you want but its just an example.

Code:
public static int NAME[] = {ID,ID,ID,ID,ID,ID,ID,ID};

    public static int randomNAME()
    {
    	return NAME[(int)(Math.random()*NAME.length)];
    }

Where you can see NAME change it to what ever you like but it has to be kept the same. Where you can see ID then add item ID’s that you want, the one on the left will be the most likely to drop and the one on the right will be the least likely to drop. When you have done that go into your NPChandler and find this.

Code:
npcs[NPCID].absX, npcs[NPCID].absY, 1, GetNpcKiller

Keep searching until you find something similar to this:

Code:
if(npcs[NPCID].npcType == NPCID) {
ItemHandler.addItem(Item2.randomNAME(), npcs[NPCID].absX, npcs[NPCID].absY, 1, GetNpcKiller(NPCID), false);

Here where you can see NPCID just enter the NPC that when you kill will drop those items. Where You Can see NAME enter the name you entered earlier in item2 so that it can load it here when they die. Thats IT!

And There You Have it. I Hoped This Helped With Any Problems That You Were Having. If You Still Have Problems Post Them Here. NO FLAMING PLS TY!

Sphere: Related Content

Posted in Runescape Private Server. Tagged with , .

Runescape Private Server Webclient Tutorial Version 317

This is a basic webclient tutorial for 317 clients.

Last Updated: *Check the Revision History*
Difficulty: Medium (Based on the poll above)
Purpose: To turn your 317 client into a webclient for your rsps.
Browser’s Tested on: Google Chrome, Internet Explorer, Mozilla Firefox, Opera.
Client’s Tested on: Should work on all 317 clients
Classes Modified: Signlink.java, Client.java, Class30_Sub2_Sub1_Sub1.java
Table of Contents:

Quote:
Section 1 – Updates/Requirements
1.1 – Revision History
1.2 – Requirements
1.3 – Files Needed
Section 2 – Tutorial
2.1 – Step 1 – Signlink.java
2.2 – Step 2 – Client.java
2.3 – Step 3 – Class30_Sub2_Sub1_Sub1.java(Sprites)
2.4 – Jarring and Signing
2.5 – Webclient Web Page
2.6 – End of tutorial details
Section 3 – Extra
3.1 – Frequently Asked Questions
3.2 – Credits

————————————————————————————————————–

Section 1 – Updates/Requirements

1.1 – Revision History:

Code:
1/2/09 - Downloading cache percentage will appear in the client(no more jframe)
1/3/09 - Downloads cache faster.
4/1/09 - Tutorial re-written.
4/2/09 - Uploaded "Cache + Sprites Zipping" video to youtube.
4/25/09 - Tutorial updated.
4/28/09 - Step 2.6 was updated.
5/3/09 - Step 2.3 was updated.
8/22/09 - New FAQ question and updated browser's tested on list.
10/16/09 - Tutorial updated.

1.2 – Requirements
1. Regular Web host or VPS(Virtual Private Server) or Dedi(Dedicated Server) – For the webclient page, client.jar(Should be around 600kb), cache.zip(usually is around 16mb)
2. Jar maker – Download below
3. A 317 client
4. Patience and Time

1.3 – Files to download:
Jar Maker: http://www.goldenstudios.or.id/produ…r/JARMaker.zip

Section 2 – Tutorial:
A video on what to do. I know it’s not very well made but it might help in some way.
Webclient tutorial video: http://www.youtube.com/watch?v=l7o4uNTrdEQ&fmt=22
You can subscribe if you want. Maybe someday I will decide to re-make a better explained webclient tutorial video.
————————————————————————————————————–

2.1 – Step 1 – Signlink.java
Open up Signlink.java and search for findcachedir(). In that method you will see something like this:

Quote:
s = “”;
s1 = “./cache/”;

highlight those 2 lines and replace it with the following:

Quote:
s = “C:/.yourclientname_file_store_32/”;
s1 = “”;

replace yourclientname with the name of your client – no spaces. For example: C:/.ricscape_file_store_32/
Save signlink.java and close it.

————————————————————————————————————–

2.2 – Step 2 – Client.java
Open up client.java and search for Class44 method67 and replace it with this one:

Code:
private Class44 method67(int i, String s, String s1, int j, byte byte0, int k)
	  {
	    byte abyte0[] = null;
	    int l = 5;
	    try
	    {
	      if(aClass14Array970[0] != null)
	      {
	        abyte0 = aClass14Array970[0].method233(true, i);
	      }
	      if(abyte0 == null)
						      {
							method13(15, (byte)4, "Downloading Cache");
downloadcache("YOUR CACHE URL LINK HERE", "cache.zip", "", "cache");
}
if(aClass14Array970[0] != null)
	      {
	        abyte0 = aClass14Array970[0].method233(true, i);
	      }
	    }
	    catch(Exception exception) { }
	    if(abyte0 != null);
	    if(abyte0 != null)
	    {
	      Class44 class44 = new Class44(44820, abyte0);
	      return class44;
	    }
	    int i1 = 0;
	    do
	    {
	      if(abyte0 != null)
	      {
	        break;
	      }
	      String s2 = "Unknown error";
	      method13(k, (byte)4, "Client updated - please reload client");
	      //method13(k, (byte)4, (new StringBuilder()).append("Requesting ").append(s).toString());
	      Object obj = null;
	      try
	      {
	        int j1 = 0;
	        DataInputStream datainputstream = method132((new StringBuilder()).append(s1).append(j).toString());
	        byte abyte1[] = new byte[6];
	        datainputstream.readFully(abyte1, 0, 6);
	        Class30_Sub2_Sub2 class30_sub2_sub2 = new Class30_Sub2_Sub2(abyte1, 891);
	        class30_sub2_sub2.anInt1406 = 3;
	        int l1 = class30_sub2_sub2.method412() + 6;
	        int i2 = 6;
	        abyte0 = new byte[l1];
	        for(int j2 = 0; j2 < 6; j2++)
	        {
	          abyte0[j2] = abyte1[j2];
	        }

	        while(i2 < l1)
	        {
	          int k2 = l1 - i2;
	          if(k2 > 1000)
	          {
	            k2 = 1000;
	          }
	          int l2 = datainputstream.read(abyte0, i2, k2);
	          if(l2 < 0)
	          {
	            s2 = (new StringBuilder()).append("Length error: ").append(i2).append("/").append(l1).toString();
	            throw new IOException("EOF");
	          }
	          i2 += l2;
	          int i3 = (i2 * 100) / l1;
	          if(i3 != j1)
	          {
	            method13(k, (byte)4, (new StringBuilder()).append("Loading ").append(s).append(" - ").append(i3).append("%").toString());
	          }
	          j1 = i3;
	        }
	        datainputstream.close();
	        try
	        {
	          if(aClass14Array970[0] != null)
	          {
	            aClass14Array970[0].method234(abyte0.length, abyte0, (byte)2, i);
	          }
	        }
	        catch(Exception exception3)
	        {
	          aClass14Array970[0] = null;
	        }
	      }
	      catch(IOException ioexception)
	      {
	        if(s2.equals("Unknown error"))
	        {
	          s2 = "Connection error";
	        }
	        abyte0 = null;
	      }
	      catch(NullPointerException nullpointerexception)
	      {
	        s2 = "Null error";
	        abyte0 = null;
	        if(!signlink.reporterror)
	        {
	          return null;
	        }
	      }
	      catch(ArrayIndexOutOfBoundsException arrayindexoutofboundsexception)
	      {
	        s2 = "Bounds error";
	        abyte0 = null;
	        if(!signlink.reporterror)
	        {
	          return null;
	        }
	      }
	      catch(Exception exception1)
	      {
	        s2 = "Unexpected error";
	        abyte0 = null;
	        if(!signlink.reporterror)
	        {
	          return null;
	        }
	      }
	      if(abyte0 == null)
	      {
	        for(int k1 = l; k1 > 0; k1--)
	        {
	          if(i1 >= 3)
	          {
	            method13(k, (byte)4, "Game updated - please reload page");
	            k1 = 10;
	          } else
	          {
	            method13(k, (byte)4, (new StringBuilder()).append(s2).append(" - Retrying in ").append(k1).toString());
	          }
	          try
	          {
	            Thread.sleep(1000L);
	          }
	          catch(Exception exception2) { }
	        }

	        l *= 2;
	        if(l > 60)
	        {
	          l = 60;
	        }
	        aBoolean872 = !aBoolean872;
	      }
	    } while(true);
	    Class44 class44_1 = new Class44(44820, abyte0);
	    if(byte0 != -41)
	    {
	      throw new NullPointerException();
	    } else
	    {
	      return class44_1;
	    }
  }

Replace the following:
YOUR CACHE URL LINK HERE
cache.zip
which is in this line:
downloadcache(“YOUR CACHE URL LINK HERE”, “cache.zip”, “”, “cache”);
You only replace what’s in the first 2 quotes.

The first quote is your link.
Your cache link must end with .zip
For example:
http://yoursite.com/cache.zip

The second quote is the extraction, so it would like this:
“cache.zip”
Unless your zip file has a different name. If it does then you would put:
“zipfilename.zip”

This is the most important method and without it your webclient will not work.
On top of Class44 method67 put this:

Code:
    public String name;
    public String dir;

public void downloadcache(String url, String name1, String dir1, String type)
    {
        dir = dir1;
        name = name1;
        try
        {
            URLConnection connection = (new URL(url)).openConnection();
            String f[] = url.split("/");
            File file = new File(f[f.length - 1]);
            int length = connection.getContentLength();
            InputStream instream = connection.getInputStream();
            try{new File(signlink.findcachedir()+dir).mkdir();}catch(Exception e){}
            FileOutputStream outstream = new FileOutputStream(signlink.findcachedir()+dir+file);
            int size = 0;
            int copy;
            byte[] buffer = new byte[4096];
            while((copy = instream.read(buffer)) != -1)
            {
                outstream.write(buffer, 0, copy);
                size+= copy;
                int percentage = (int)(((double)size / (double)length) * 100D);
                method13(percentage, (byte)4, "Downloading Cache - "+percentage+"%");
            }
            if(length != size)
            {
                instream.close();
                outstream.close();
            } else
            {
                method13(5, (byte)4, "Unpacking files...");
                instream.close();
                outstream.close();
                unZipFile();
                deleteFile();
                method13(10, (byte)4, "Unpacking was complete");
            }
        }
        catch(Exception e)
        {
            System.err.println("Error connecting to server.");
            e.printStackTrace();
        }
    }
    public void writeStream(InputStream In, OutputStream Out) throws IOException
    {
        byte Buffer[] = new byte[4096];
        int Len;
        while((Len = In.read(Buffer)) >= 0)
        {
            Out.write(Buffer, 0, Len);
        }
        In.close();
        Out.close();
    }

    public void unZipFile()
    {
        try
        {
            ZipFile ZipFile = new ZipFile(signlink.findcachedir()+dir+name);
            for(Enumeration Entries = ZipFile.entries(); Entries.hasMoreElements();)
            {
                ZipEntry Entry = (ZipEntry)Entries.nextElement();
                if(Entry.isDirectory())
                {
                    (new File(signlink.findcachedir()+dir+Entry.getName())).mkdir();
                } else
                {
                    writeStream(ZipFile.getInputStream(Entry), new BufferedOutputStream(new FileOutputStream(signlink.findcachedir()+dir+Entry.getName())));
                }
            }
            ZipFile.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public void deleteFile()
    {
        try
        {
            File file = new File(signlink.findcachedir()+dir+name);
            file.delete();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

Once you have added those method’s in your client.java, scroll all the way up still you see import’s then add the following under the rest of them.

Code:
import java.awt.Dimension;
import java.net.URL;
import java.net.URLConnection;
import javax.swing.*;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

————————————————————————————————————–

2.3 – Step 3 – Class30_Sub2_Sub1_Sub1.java(Sprites)
Now for the sprite part. Which most people don’t do right. I don’t know why. =\
Open up Class30_Sub2_Sub1_Sub1.java and replace all:

Quote:
./Sprites/

with this

Quote:
C:/.yourclientname_file_store_32/Sprites/

Like this:

Do the same for the background

Once you have changed the location your client reads the sprites from, save the file and close it.

————————————————————————————————————–

2.4 – Jarring and Signing
Before we start make sure you have downloaded the jar maker(located above).
Note: When you jar your client the cache and sprites folder can not be in the client folder. Move or delete them.
If you have already downloaded the jar maker then run the jar maker and watch the following video.

Jarring and signing video: http://www.youtube.com/watch?v=9obXgxm_9qY&fmt=18

Once you have jarred and signed the client, Put the cache files(Everything inside the cache folder) and sprite “folder” in a zip file.

To understand what I mean watch this video:
http://www.youtube.com/watch?v=KUPvCEObZuk

————————————————————————————————————–

2.5 – Webclient Web Page
Create a new html or php page with the following (This is an example of how it should be):

Quote:
<HTML>
<HEAD>
<TITLE>Your Webclient</TITLE>
<META HTTP-EQUIV=”PRAGMA” CONTENT=”NO-CACHE”>
</HEAD>

<BODY>

<applet name=”yourclientname” width=”765″ height=”503″ archive=”client.jar” code=”client.class”>
<param name=”java_arguments” value=”-Xmx1024m”>
</applet>

</BODY>
</HTML>

Replace yourclientname with the name of your client.

————————————————————————————————————–

2.6 – End of tutorial details
This is what your webclient should do if you did this tutorial right:
http://www.youtube.com/watch?v=4wzI6JJP-Ds&fmt=22

————————————————————————————————————–

Section 3 – Extra
3.1 – Frequently Asked Questions
Question: What’s a good free file host for my cache.zip?
Answer: You can use any host that allows direct linking. I personally use this site:
http://www.fileden.com/

Question: Ric, it’s too hard. Can you make it for me?
Answer: No, I don’t do this for people anymore. You gotta learn how to make a webclient for when you update your client.

Question: I get a blank page with a red X on it. What do I do?
Answer: Right click and press Java Console and read the error.

Question: The java console says it cannot find client.class, What should I do?
Answer: I recommend deleting all the class files and recompile your client.

Question: I get the 1,2,3,4,5 error. What do I do?
Answer: Something is missing, corrupted or done wrong.

Question: I get a java heap space error, What do I do?
Answer: Make sure you have <param name=”java_arguments” value=”-Xmx1024m”> in your applet code.
————————————————————————————————————–

Sphere: Related Content

Posted in Runescape Private Server. Tagged with , , , .

How to make a Runescape Webclient for Version 525

Purpose: Webclient on 525
Difficulty: 5/10
Tested On: Any 525 base.

Step 1: Open client2 and remove this part or quote it out

Code:
 this.frame = new JFrame("Client name");
    this.frame.setLayout(new BorderLayout());
    this.frame.setResizable(true);
      this.jp.setLayout(new BorderLayout());
      this.jp.add(this);
      this.jp.setPreferredSize(new Dimension(765, 503));
      this.frame.getContentPane().add(this.jp, "Center");
      this.frame.pack();
      this.frame.setVisible(true);

That removes the frame so it instead is embedded into the page.
Step 2:
go to class73 and change the cache Directory to C:/cache525

Step 3: (IF you want an IP changer, otherwise skip this)
put this at the top below the public class client2

Code:
  public String IPaddr = "";

Then under;

Code:
 props.put("worldid", "2");
      props.put("members", "1");
      props.put("modewhat", "0");
      props.put("modewhere", "0");
      props.put("safemode", "0");
      props.put("game", "0");
      props.put("js", "1");
      props.put("lang", "0");
      props.put("affid", "0");
      props.put("highmem", "1");

Put;

Code:
IPaddr = JOptionPane.showInputDialog(null,"Please enter IP address:");

Finally replace the “Getcodebase” Method with this if your using IP changer

Code:
  public URL getCodeBase() {
    try {
      return new URL("http://"+IPaddr);
    } catch (Exception localException) {
      localException.printStackTrace();
      return null;
    }
  }

Step 4: Compile, Then Assuming you have JAR maker, (if you don’t, its found here: http://www.goldenstudios.or.id/produ…r/JARMaker.zip)
JAR the Client, Set the manifest template to client2 as main class
Then Sign it by Generating the Keystore And signing as Usual, if you don’t know how, find another webclient tutorial (this is a fast one) And Upload to your website, the HTML file is this:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html style="width:100%;height:100%;">
<head>
<title>525 Webclient</title></head>

<center>
<body BGCOLOR="#000000"><applet name=RuneScape id=game width=765 height=503 archive='rs2_525.jar' code='client2.class' mayscript>
<param name=worldid value=60>
<param name=members value=1>
<param name=modewhat value=0>
<param name=modewhere value=0>
<param name=safemode value=0>
<param name=lang value=0>
<param name=affid value=0>
<param name=settings value=stringpassedtoserverwhenconnecting>
<param name=cookieprefix value=>
<param name=cookiehost value=.google.com>
<param name=plug value=0>
<param name=js value=1>
<param name=game value=0>
</applet>
</body>

Sphere: Related Content

Posted in Runescape Private Server. Tagged with , , .

How to make a server ? (RuneScape private server tutorial)

This is the most known RuneScape private server tutorial/guide ever created according to many statistics made by major search engines like Google, Yahoo and such.
In this tutorial you will learn how to make a simple RuneScape private server yourself.

» Chapter 1

Downloading JDK

First we will need to download Java Sun’s JDK.
You can download it at this page.
Click on the most recent JDK version (At the time this has been written: JDK 6 Update 7).
On this page you will have to select your platform, in this guide we will be using Windows as default platform.
Select ‘Multi-Language’ and check the ‘I agree’ box.
Check the box ‘I agree’ and click on one of the 2 downloads you can choose and install it.

We prefer the Offline Installation.

This chapter has been finished. Click here to hide this chapter if you want to, you can simply reactivate this chapter by clicking on it again.

» Chapter 2

Downloading & Installing No-IP

If you do not have your own domain name for your server, you might want to make it easier for people to find your server instead of telling them your whole IP address with all the numbers.
You can do this by using No-IP, No-IP allows you to register a sort of sub-domain redirecting to your IP.

You will be able connect to your server through that No-IP address, there are many extensions available such as the default YourServer.no-ip.org, more information about that later in this chapter.

First of all, go to the official No-IP site by clicking here and start filling in the details it is asking for.
Make sure you are filling in the right details.
They will not use this to contact you, but if you’re hosting something illegal while you do not know it, it is better for the police to have these details about you, instead of having them to get you into big troubles.

Once you have completed your registration please go to the Download page.
Select your operating system, in this tutorial we will be using Windows as default, and has therefore been selected in the picture below.

After that you will have to click on “Download”, which will lead you to the download.com website where the download will start automatically.

After the download is completed, install the program and start it up.
If you did everything right, you will now have this screen:

On this menu everything will happen.
Click on “Add” on the bottom of the menu, as highlighted in the picture.
This will open your browser and bring you to the No-IP website.
On the navigation click “Add host” and if right, you will receive this form:

In the hostname field fill in your server name, and select the domain you’d like to have as I said above.
Default is no-ip.org/biz/com.
Host Type should be DNS Host (A) and the IP address is already filled in.
Scroll down and click Create Host.

If done, g

o back to the main menu of No-IP and click the “Refresh” on the bottom, and your No-IP is configured completely!

This chapter has been finished. Click here to hide this chapter if you want to, you can simply reactivate this chapter by clicking on it again.

» Chapter 3

Opening 43594 Usage

This will be easy, so we’ll be going through this a bit fast to skip some unnecessary time.
Open Network & Internet Connections on your computer.
Right click on the connection you’re using to connect to the internet and click properties.
Now open the Advanced tab and click on firewall settings.
Open the Exceptions tab and at the bottom you should see a button “Add Port”.
Click on it, and add your server name or whatever you want it to be at the Name field.

At the Port number fill in: 43594
43594 is the default port of RuneScape (Private) Servers.
And make sure the TCP box has been checked.

This chapter has been finished. Click here to hide this chapter if you want to, you can simply reactivate this chapter by clicking on it again.

» Chapter 4

Port forwarding (Based on Linksys)

This chapter can be skipped if you do not have a router.
Otherwise, we wish you good luck on this because this will probably be one of the most difficult chapters in the tutorial.

There are many kind of routers, although the Linksys router is the most used router, and therefore we will base this tutorial on a Linksys router.
If you do not have a Linksys router but use another, we advise you to visit the Port Forward site where you can find your router, and follow their tutorial basing it on port 43594

.

Ok, open your browser and connect to http://192.168.1.1.
If you did everything right, you will now get this login screen:


Enter your username and password now. By default the username is blank, and the password is admin.

Click the Ok button to log in to your router.
If you cannot login with that, we cannot longer help you port forward, either the person that setup your router did not use the default password and username, or configured something wrong.

Once logged in you will come on a webpage with some settings.
Click on the “Applications and Gaming” tab and if right you will now see something like:


On an empty row start filling in this:

Application Name: RSPS
Start – End Port: 43594-43594
Protocol: Both
To IP Address: Local IP address (Read below).
Enabled: Checked/Yes

How do I find my local IP address?
Go to Start -> Run and type cmd and in the black box type ‘ipconfig’. You will see your local IP address there.

Save the settings and you are done.

This chapter has been finished. Click here to hide this chapter if you want to, you can simply reactivate this chapter by clicking on it again.

» Chapter 5

Downloading a server source

Alright, this is not really difficult
Every server has been programmed, and we assume you do not want to spend months writing a complete server from scratch, therefore people release sources of their server.

This means they are giving you the files of their server and you can just use them for your server.
You can download sources at our forums by clicking here.

This chapter has been finished. Click hereto hide this chapter if you want to, you can simply reactivate this chapter by clicking on it again.

» Chapter 6

The error ‘The system could not find the path specified.’ error.

Open up “My Computer”.

Click “View System information”

Click “Advanced”.

Click “Environment Variables”.

Under “User Variables” click “New”.

Name it “CLASSPATH” and for the “Variable Value” (only if you have JDK 6u1) put this in: CLASSPATH=C:\Program Files\Java\jdk1.6.0_01\bin;%CLASSPATH%; If you have JDK 6u2, you must enter CLASSPATH=C:\Program Files\Java\jdk1.6.0_02\bin;%CLASSPATH%; for the variable value.

Under “User Variables” click “New”.

Name it “PATH” and for the “Variable Value” (only if you have JDK 6u1) put this in: C:\Program Files\Java\jdk1.6.0_01\bin If you have JDK 6u2, you must enter C:\Program Files\Java\jdk1.6.0_02\bin for the variable value.

Click “OK”.

Click “OK”.

Your computer now recognizes Java.

This chapter has been finished. Click hereto hide this chapter if you want to, you can simply reactivate this chapter by clicking on it again.

» Chapter 7

Edit sources; Examples

Making yourself an Administrator in-game
Testscape & Many other sources

Open your client.java and press Ctrl + F.
You will now get an search box, fill in:

Code:
//start of moderator/admin list, 1 = mod, 2 = staff, 3 = admin

You willl see something like this

Code:
if (playerName.equalsIgnoreCase("admin"))
                {
                    playerRights = 3;
                }

If you look at it instead of just directly editing it and not learning something you know what this is.
Its just like ‘If the name of the player is: admin give him playerrights 3 (Owner rights)’
Player Rights 4 = Hidden Admin
Player Rights 3 = Server Owner
Player Rights 2 = Server Admin
Player Rights 1 = Server Player Moderator

In Jorsa PK (Pimpscape) based servers you can just open the data folder and open admins/administrators/staff.txt and add a new player to it.

Adding NPC’s
To add NPC’s you work in autospawn.cfg, not client.java.

Open it and you will see many things looking like eachother.
Now add this somewhere

Code:
spawn = NpcID    CoordX    CoordY    0    0    0    0    0    2    NPC Name

Change NpcID to the ID of the npc.
Change CoordX and CoordY to the coords where you want the npc to be.
If you don’t know how to get the coords press F4 (Moparscape client).

Also, no your not a ub3r good coder when you made a command or added a npc.

Compiling
After every update in the .java files you have to compile it.
Compiling will make .class files off them and your server runs on them.
For just an easy compiler make a new text file with notepad.
Add this to it:

Code:
@echo off
title Server Compiler
"C:\Program Files\Java\YOURJAVAVERSION\bin\javac.exe" -cp . *.java
pause

Now open My Computer, head to C:/Program Files/Java and find the ‘jre’ folder.
Copy the folder name and replace ‘YOURJAVAVERSION’ with the folder name.

Click Save As and save it as a batch file.
To save it as a batch file you can either make it end with .bat or clicking ‘All files’ at filetype, and adding ‘.bat’ at the end.

Sphere: Related Content

Posted in Runescape Private Server. Tagged with , .