Looks a bit like my runescape server i sent you :P (ajscape)
PHP Code:
/********************************************\
* ##########################################
* # RageScape 508 Server
* ##########################################
* # Copyright (c) 2006 - 2009 TheAJP
* # http://theajp.com/ <truebrown@live.ca>
* # ---------------------------------------
* # @class | Server
* # @version | 2.0.4
* ##########################################
\********************************************/
package ajscape;
import java.io.*;
import ajscape.net.SocketListener;
import ajscape.net.*;
import ajscape.players.PlayerSave;
import ajscape.util.Misc;
import java.sql.*;
import ajscape.io.MySQL;
import ajscape.world.Shop;
import ajscape.web.UpdateTaskManager;
import ajscape.quests.Quest;
public class Server
{
/**
* MySQL Settings
*/
public static String dbuser = "yourmoms";
public static String dbpass = "pussy";
public static String dbname = "fosho";
public static Connection DBConnection = null;
public static String motw = "..";
/**
* The engine used to update almost everything, such as players, items, and NPCs.
*/
public static Engine engine;
public static UpdateTaskManager taskmgr;
/**
* Listens for incoming connections and accepts them.
*/
public static SocketListener socketListener;
/**
* Save character files.
*/
private static PlayerSave playerSave;
/**
* Banned accounts list.
*/
public static String[] bannedUsers = new String[100];
/**
* Main method for running the server.
*/
public static void main(String[] args)
{
Misc.println("##########################################");
Misc.println("# RaGESCAPE Dedicated Server #");
Misc.println("#----------------------------------------#");
Misc.println("# Version: 2.0 - Core MySQL #");
Misc.println("#----------------------------------------#");
Misc.println("# CopyRight(C) TheAJP.com (2006-2009) #");
Misc.println("##########################################");
Misc.println(" ");
Misc.println(" ");
int port = Integer.parseInt(args[0]);
if (AutoRestarter.autoRestart)
{
new AutoRestarter();
}
/**
* MySQL server connection
*/
try
{
Misc.println("[MySQL] Connecting to MySQL Server on 127.0.0.1:3306 using JDBC..");
Class.forName("com.mysql.jdbc.Driver").newInstance();
DBConnection = DriverManager.getConnection("jdbc:mysql:///" + dbname, dbuser, dbpass);
if(!DBConnection.isClosed())
{
Misc.println("[MySQL] Connected to MySQL Server. Database is '" + dbname + "'.");
}
else
{
Misc.println("[MySQL] Could not connect to MySQL Server. Unknown error occured.");
while(true){ }
}
}
catch(Exception e)
{
e.printStackTrace();
Misc.println("Could not connect to MySQL Server! For details see error above.");
while(true){ }
}
finally
{
Misc.println(" ");
Misc.println("[MySQL] Performing initial database tasks..");
MySQL.executeUpdate("UPDATE users SET online = '0'");
MySQL.executeUpdate("UPDATE server_dump SET users_online = '0', online = '1' LIMIT 1");
MySQL.executeUpdate("DELETE FROM tasks");
Misc.println("[MySQL] ..OK!");
ResultSet RS = MySQL.executeQuery("SELECT motw FROM settings LIMIT 1");
try
{
if(RS.next())
{
motw = RS.getString(1);
}
else
{
motw = "No message is currently set";
}
}
catch(SQLException e)
{
Misc.println("Could not load Message of the Week!");
}
Misc.println(" ");
}
loadBannedUsers();
loadQuests();
loadShops();
Misc.println(" ");
try
{
Misc.println("[UpdateTaskManager] Now Initializing..");
taskmgr = new UpdateTaskManager();
}
catch(Exception e)
{
e.printStackTrace();
}
Misc.println(" ");
try
{
Misc.println("[SERVER] Attempting to set up socket listener on port " + port + "..");
socketListener = new SocketListener(port);
}
catch(Exception e)
{
e.printStackTrace();
Misc.println("Could not set up server on port " + port + ". For details see error above.");
while(true){ }
}
engine = new Engine();
playerSave = new PlayerSave();
socketListener.run();
}
/**
* Loads all banned users
*/
public static void loadBannedUsers()
{
bannedUsers = new String[50];
SocketListener.bannedHosts = new String[50];
int counter = 0;
int counter2 = 0;
ResultSet RS = MySQL.executeQuery("SELECT name FROM bannedusers ORDER BY id DESC");
try
{
while(RS.next())
{
counter++;
bannedUsers[counter] = RS.getString(1);
}
}
catch(SQLException e)
{
Misc.println("Error loading banned users");
}
ResultSet RS2 = MySQL.executeQuery("SELECT ip FROM bannedips ORDER BY id DESC");
try
{
while(RS2.next())
{
counter2++;
SocketListener.bannedHosts[counter] = RS2.getString(1);
}
}
catch(SQLException e)
{
Misc.println("Error loading banned ips");
}
Misc.println("[SERVER] Loaded " + counter + " banned user(s) and " + counter2 + " IP ban(s).");
}
/**
* Loads all quests
*/
public static void loadQuests()
{
int counter = 0;
ResultSet RS = MySQL.executeQuery("SELECT id,name,finalStage,points FROM quests ORDER BY id ASC");
try
{
while(RS.next())
{
counter++;
int id = RS.getInt(1);
String name = RS.getString(2);
int finalStage = RS.getInt(3);
int qPoints = RS.getInt(4);
Engine.quests[id] = new Quest(id, name, finalStage, qPoints);
}
}
catch(Exception e)
{
Misc.println("Error loading quests:");
e.printStackTrace();
}
Misc.println("[SERVER] Loaded " + counter + " quest(s).");
}
/**
* Load shop data
*/
public static void loadShops()
{
int counter = 0;
ResultSet RS = MySQL.executeQuery("SELECT id,name,items,itemCosts FROM shops ORDER BY id DESC");
try
{
while(RS.next())
{
counter++;
int id = RS.getInt(1);
String name = RS.getString(2);
String items = RS.getString(3);
String ammounts = RS.getString(4);
String costs = RS.getString(4);
Engine.shops[id] = new Shop(id, items, costs, name);
}
}
catch(SQLException e)
{
Misc.println("Error loading shops:");
e.printStackTrace();
}
Misc.println("[SERVER] Loaded " + counter + " shop(s).");
}
}
Nice job though