1.0.5 • Published 5 years ago
themepark-api v1.0.5
ThemePark API
With this API, you can easily read things out of the MYSQL database connected to the ThemePark plugin for Spigot servers.
Todo List:
- Prepared statements
- Get ridecount in getRide function and the count of today
- Updated getrCount to getRideCounts
- Use join in querys
- Cleaning code
- Get regions
- Get shows
Installation
npm install themepark-api
Connecting with the database:
Before you can use it, you have to connect to your database (the same as who is connected to the ThemePark plugin).
For example:
const tpAPI = require("themepark-api");
let tp = new tpAPI({host: "DBHOST", username: "DBUSER", password: "DBPASSWORD", database: "DBNAME"})
Usage
Ride information:
One ride:
tp.getRide("AttractionID", function (data) {
console.log(data);
});
Example output:
{ id: 'lumberjack',
name: 'free fall',
region_id: 'flatride',
region_name: 'Flatrides',
status: 'CLOSED',
status_name: 'Gesloten',
count_today: 13,
count: 17
}
All the rides:
tp.getRides(function (data) {
console.log(data)
});
Example output:
[ RowDataPacket {
id:'ff',
name:'free fall',
region_id:'flatride',
type:'RIDE',
status:'CLOSED'
}, RowDataPacket {
id:'test',
name:'test',
region_id:'test',
type:'test',
status:'OPEN'
}]
Ridecounts:
This function name is changed to getRideCounts in v1.0.3!
You can add multiple optional options to this function.
username: Your Minecraft name
rideId: The rideID of the ride in the server
tp.getRideCounts({username: "mcusername", rideId: "rideID"}, function(data) {
console.log(data)
});
Example output:
4
Status names:
tp.getStatus("StatusID", function(data) {
console.log(data)
});
Example output:
{
status:'CLOSED',
status_name:'Gesloten'
}
Region names:
tp.getRegion("RegionID", function(data) {
console.log(data)
});
Example output:
{
region: 'flatride',
region_name: 'Flatrides'
}
Shows:
tp.getShow("ShowID", function (data) {
console.log(data);
});
Example output:
{
showId: 'testid',
showName: 'testname',
showDescription: 'test desc',
showPrice: '€1,20',
vaultPrice: '1.20',
showImage: '{URL}',
showSeats: 20,
buyedSeats: 2,
showDate: '13:21 02-11-19'
}