A powerful and modern web library for allods online servers
npm install allods-web-library/jars folder into your gameServer/server_bin/jars (make a backup of those files before just in case).
allods-web-library package
bash
npm i -s allods-web-library
`
Now create your .env file in your project with servers data variables :
(this web library save these data into process.env, using dotenv package.)
`dotenv
ACCOUNT_SERVER_HOST=127.0.0.1
ACCOUNT_SERVER_PORT=9337
BILLING_SERVER_HOST=127.0.0.1
BILLING_SERVER_PORT=9336
...
`
Now you can call API Collection that you want like it :
`javascript
const { Account, Billing, Item, GameTool, LogServer } = require('allods-web-library');
let user = new Account('username');
...
`
You also have access to the NetworkManager class of the library that allows you to make your own request to the api servers, useful if you want to create your own JAVA API endpoints or methods.
`javascript
const { NetworkManager } = require('allods-web-library');
(async () => {
let Request = new NetworkManager('Account');
let avatars = Request
.changeEndpoint('myOwnEndPoint-getAvatars')
.get({ username: '' });
})();
`
API Collection
Here is the web API Collection of an Allods Game Server, with code examples to get those data with this web library (if not implemented, will shows request form data).
$3
- POST - /createAccount
`javascript
let Account = new Account('Username');
Account.create({
password,
accessLevel,
accountStatus
});
`
- POST - /accountDetails
`javascript
let Account = new Account('Username');
Account.get().then(accountData => accountData);
`
- POST - /accountStatus
`javascript
let Account = new Account('Username');
Account.status().then(accountData => accountData);
`
- POST - /accountInfo
`json
{
"userName": "userName"
}
`
- POST - /checkPassword
`javascript
let Account = new Account('Username');
Account.checkPassword('password').then(result => result);
`
Returns : {"status":"SUCCESS","reason":"OK"} or {"status":"FAILED","reason":"wrong password"}
- PUT - /changePassword
`javascript
let Account = new Account('Username');
Account.changePassword('newPassword').then(result => result);
`
- PUT - /accountStatus
`javascript
let Account = new Account('Username');
// Active or Inactive
Account.setStatus('Active').then(result => result);
`
- PUT - /baseAccessLevel
`javascript
let Account = new Account('Username');
// User, Master or Developer
Account.setBaseAccess('User').then(result => result);
`
- PUT - /currentAccessLevel
`javascript
let Account = new Account('Username');
// User, Master or Developer
Account.setCurrentAccess('User').then(result => result);
`
$3
- POST - /sanctions
`javascript
let Account = new Account('Username');
Account.Sanction().get().then(sanctions => sanctions);
//
`
Returns: {"status":"SUCCESS","reason":"OK","sanctions":[]}
- PUT - /sanctions
`javascript
let Account = new Account('Username');
Account.Sanction().set({
type: 'Ban', // Ban, Silence, PlayerTradeBan, TotalTradeBan
reason: 'Sanction Reason',
gmName: 'Game Master Nickname',
expireTime: 'timestamp'
}).then(result => {
console.log(result);
Account.Sanction().get().then(sanctions => sanctions);
});
// {"status":"SUCCESS","reason":"OK"}
// {"status":"SUCCESS","reason":"OK","sanctions":[{"login":"Username","sanctionType":"Ban","isOn":true,"expireTime":1586965256,"reason":"Sanction Reason","gmName":"Game Master Nickname"}]}
`
- DELETE - /sanctions
`javascript
// NOTE : this will not hard delete the row in the db. It will updates the sanction with the new values you set below and with the flag column at 0
let Account = new Account('Username');
Account.Sanction().delete({
type: 'Ban', // Which sanction type to remove ?
reason: 'Sanction Removal Reason', // Reason of the deletion of the sanction
gmName: 'Game Master who removed sanction', // name of the GM who delete the sanction
}).then(result => {
console.log(result);
Account.Sanction().get().then(sanctions => sanctions);
});
// {"status":"SUCCESS","reason":"OK"}
// {"status":"SUCCESS","reason":"OK","sanctions":[{"login":"Username","sanctionType":"Ban","isOn":false,"expireTime":1586965256,"reason":"Sanction Reason","gmName":"Game Master Nickname"}]}
``