0.1.0 • Published 2 years ago
bedrock-server-api v0.1.0
Bedrock Game API
Importing
Module
import {GameAPI} from 'bedrock-game-api';
CommonJS
const GameAPI = require('bedrock-game-api');
HyperLands
Creating server instance
const hyperLandsServer = HyperLands.Server.getInstance();
Methods
Fetch Player
hyperLandsServer.fetchPlayer("player_name").then(async player => {
if (!player) return console.log("Player not found :(");
console.log(player.getName() + " has been found!");
const extraTags = player.getExtraTags(); // returns an array filled with strings that are extra tags of player
const rank = player.getRank(); // returns a string that is the rank name of the player
const plusColor = player.getRankPlusColor(); // returns a string that is the rank's plus' color of the player
const rankExpiry = player.getRankExpiry(); // returns a number that is the rank's expiry of the player
const lastLogout = player.getLastLogoutTimestamp(); // returns a number that is the last logout timestamp of the player
const levelProgress = player.getLevelProgress(); // returns a number that is the level progress of the player
const levelProgressPercent = player.getLevelProgressPercent(); // returns a number that is the level progress percent of the player
const tag = player.getTag(); // returns a string that is the tag of the player
const lastServer = player.getLastServer(); // returns a string that is the last server name of the player
const isOnline = player.isOnline(); // returns a boolean that is true if the player is online
const level = player.getLevel(); // returns a number that is the level of the player
const head = await player.getHead(); // returns an array filled with Buffer which is player's head
const levelMaxProgress = player.getLevelMaxProgress(); // returns a number that is the level max progress of the player
const bedWarsData = player.getBedWarsData(); // returns a BedWarsData instance that is the player's BedWars data
const bedWarsKills = bedWarsData.getKills(); // returns a number that is the bedwars kills of the player
const bedWarsFinalKills = bedWarsData.getFinalKills(); // returns a number that is the bedwars final kills of the player
const bedWarsBrokenBeds = bedWarsData.getBrokenBeds(); // returns a number that is the bedwars broken beds of the player
const bedWarsCurrentWinStreak = bedWarsData.getCurrentWinStreak(); // returns a number that is the bedwars current win streak of the player
const bedWarsBestWinStreak = bedWarsData.getBestWinStreak(); // returns a number that is the bedwars best win streak of the player
const bedWarsWins = bedWarsData.getWins(); // returns a number that is the bedwars wins of the player
const duelsData = player.getDuelsData(); // returns a DuelsData instance that is the player's Duels data
const duelsBuildUhcWins = duelsData.getBuildUhcWins(); // returns a number that is the duels build uhc wins of the player
const duelsPotWins = duelsData.getPotWins(); // returns a number that is the duels pot wins of the player
const duelsIronWins = duelsData.getIronWins(); // returns a number that is the duels iron wins of the player
const duelsArcherWins = duelsData.getArcherWins(); // returns a number that is the duels archer wins of the player
const duelsSumoWins = duelsData.getSumoWins(); // returns a number that is the duels sumo wins of the player
const duelsElo = duelsData.getElo(); // returns a number that is the duels elo of the player
const duelsCurrentWinStreak = duelsData.getCurrentWinStreak(); // returns a number that is the duels current win streak of the player
const duelsBestWinStreak = duelsData.getBestWinStreak(); // returns a number that is the duels best win streak of the player
const skyWarsData = player.getSkyWarsData(); // returns a HyperLandsSkyWarsData instance that is the player's SkyWars data
const skyWarsKills = skyWarsData.getKills(); // returns a number that is the player's kills in skywars
const skyWarsWins = skyWarsData.getWins(); // returns a number that is the player's wins in skywars
const theBridgeData = player.getTheBridgeData(); // returns a HyperLandsTheBridgeData instance that is the player's The Bridge data
const theBridgeWins = theBridgeData.getWins(); // returns a number that is the player's wins in the bridge
const theBridgeGoals = theBridgeData.getGoals(); // returns a number that is the player's goals in the bridge
const theBridgeCurrentWinStreak = theBridgeData.getCurrentWinStreak(); // returns a number that is the player's current win streak in the bridge
const theBridgeBestWinStreak = theBridgeData.getBestWinStreak(); // returns a number that is the player's best win streak in the bridge
const uhcMeetupData = player.getUhcMeetupData(); // returns a HyperLandsUhcMeetupData instance that is the player's UHC Meetup data
const uhcMeetupWins = uhcMeetupData.getWins(); // returns a number that is the player's wins in UHC Meetup
const uhcMeetupKills = uhcMeetupData.getKills(); // returns a number that is the player's kills in UHC Meetup
const skin = await player.getSkin(); // returns a Skin instance that is the skin of the player
const file = await skin.createTemporarily(); // creates a png file and puts the skin in it
}); // if you are in an async function you can use await
Using player cache
// second argument is case-sensitive and must be a boolean, true by default
hyperLandsServer.getPlayerExact("player_name", true).then(player => {
if (!player) return console.log("Player not found :(");
console.log(player.getName() + " has been found!");
});
// second argument is case-sensitive and must be a boolean, false by default
hyperLandsServer.getPlayerByPrefix("player_name", true).then(player => {
if (!player) return console.log("Player not found :(");
console.log(player.getName() + " has been found!");
});
// second argument is case-sensitive and must be a boolean, false by default
hyperLandsServer.getPlayerBySuffix("player_name", true).then(player => {
if (!player) return console.log("Player not found :(");
console.log(player.getName() + " has been found!");
});
Getting leaderboard
// HyperLands mini games: "bwbeds" | "bwcurrentwinstreaks" | "bwfinalkills" | "bwkills" | "bwtopwinstreaks" | "bwwins" | "duelscurrentwinstreaks" | "duelselo" | "duelstopwinstreaks" | "duelswins" | "levels" | "spleefcurrentwinstreaks" | "spleeftopwinstreaks" | "spleefwins" | "swkills" | "swwins" | "tbcurrentwinstreaks" | "tbgoals" | "tbtopwinstreaks" | "tbwins" | "totalkills" | "totalwins" | "uhcmkills" | "uhcmwins"
// first parameter is the name of the hyperlands mini game
// second parameter is if it should force to fetch the leaderboard from api
hyperLandsServer.getLeaderboard("bwbeds", true).then(leaderboard => {
console.log(leaderboard);
leaderboard.getPlayerIndexByPrefix("player_name"); // returns a number that is the index of the row in the leaderboard
leaderboard.getPlayerValueByPrefix("player_name"); // returns a number that is the value of the row in the leaderboard
leaderboard.getPlayerIndexBySuffix("player_name"); // returns a number that is the index of the row in the leaderboard
leaderboard.getPlayerValueBySuffix("player_name"); // returns a number that is the value of the row in the leaderboard
leaderboard.getPlayerIndexExact("player_name"); // returns a number that is the index of the row in the leaderboard
leaderboard.getPlayerValueExact("player_name"); // returns a number that is the value of the row in the leaderboard
leaderboard.getValueByIndex(0); // returns a number that is the value of the row at the index 0
leaderboard.getPlayerNameByIndex(0); // returns a string that is the name of the player at the index 0
});
HiveMC
Creating server instance
const hiveServer = Hive.Server.getInstance();
Methods
Fetch Player
// Hive mini games: "dr" | "hide" | "murder" | "sky" | "sg" | "wars"
// dr: Death Run, hide: Hide and Seek, murder: Murder Mystery, sky: Sky Wars,
// sg: Survival Games, wars: Treasure Wars
// first parameter is the name of the player
// second parameter is the name of the mini game
hiveServer.fetchPlayer("player_name", "dr", {
monthly: true, // optional, default: false
year: 2020, // optional, default: null, monthly has to be true for this to work
month: 1 // optional, default: null, monthly has to be true for this to work
}).then(async player => {
if (!player) return console.log("Player not found :(");
console.log(player.getName() + " has been found!");
const deathRunData = await player.getDeathRunData(true, 2020, 1); // returns a DeathRunData instance that is the player's Death Run data
deathRunData.getKills(); // returns a number that is the player's kills in Death Run
deathRunData.getActivatedAmount(); // returns a number that is the player's activated amount in Death Run
deathRunData.getCheckpointAmount(); // returns a number that is the player's checkpoint amount in Death Run
deathRunData.getDeaths(); // returns a number that is the player's deaths in Death Run
deathRunData.getVictories(); // returns a number that is the player's victories in Death Run
deathRunData.getXPRequirement(); // returns a number that is the player's XP requirement in Death Run
deathRunData.getLevel(); // returns a number that is the player's level in Death Run
deathRunData.getFirstPlayed(); // returns a number that is the player's first played in Death Run
deathRunData.getLevelProgress(); // returns a number that is the player's level progress in Death Run
deathRunData.getPlayed(); // returns a number that is the player's played in Death Run
deathRunData.getXP(); // returns a number that is the player's XP in Death Run
});
Using player cache
// Hive mini games: "dr" | "hide" | "murder" | "sky" | "sg" | "wars"
// dr: Death Run, hide: Hide and Seek, murder: Murder Mystery, sky: Sky Wars,
// sg: Survival Games, wars: Treasure Wars
// first parameter is the name of the player
// second parameter is the name of the mini game
hiveServer.getPlayerExact("player_name", "dr", {
monthly: true, // optional, default: false
year: 2020, // optional, default: null, monthly has to be true for this to work
month: 1 // optional, default: null, monthly has to be true for this to work
// fourth argument is case-sensitive and must be a boolean, true by default
}, true).then(async player => {
if (!player) return console.log("Player not found :(");
console.log(player.getName() + " has been found!");
const deathRunData = await player.getDeathRunData(true, 2020, 1); // returns a DeathRunData instance that is the player's Death Run data
deathRunData.getKills(); // returns a number that is the player's kills in Death Run
deathRunData.getActivatedAmount(); // returns a number that is the player's activated amount in Death Run
deathRunData.getCheckpointAmount(); // returns a number that is the player's checkpoint amount in Death Run
deathRunData.getDeaths(); // returns a number that is the player's deaths in Death Run
deathRunData.getVictories(); // returns a number that is the player's victories in Death Run
deathRunData.getXPRequirement(); // returns a number that is the player's XP requirement in Death Run
deathRunData.getLevel(); // returns a number that is the player's level in Death Run
deathRunData.getFirstPlayed(); // returns a number that is the player's first played in Death Run
deathRunData.getLevelProgress(); // returns a number that is the player's level progress in Death Run
deathRunData.getPlayed(); // returns a number that is the player's played in Death Run
deathRunData.getXP(); // returns a number that is the player's XP in Death Run
});
All game data methods
await (async () => {
// Fetching all game modes from player
const player = await hiveServer.fetchPlayer("player_name", "dr");
await hiveServer.fetchPlayer("player_name", "hide");
await hiveServer.fetchPlayer("player_name", "murder");
await hiveServer.fetchPlayer("player_name", "sky");
await hiveServer.fetchPlayer("player_name", "sg");
await hiveServer.fetchPlayer("player_name", "wars");
const deathRunData = await player.getDeathRunData(); // returns a DeathRunData instance that is the player's Death Run data
deathRunData.getVictories(); // returns a number that is the player's victories in Death Run
deathRunData.getKills(); // returns a number that is the player's kills in Death Run
deathRunData.getDeaths(); // returns a number that is the player's deaths in Death Run
deathRunData.getActivatedAmount(); // returns a number that is the player's activated amount in Death Run
deathRunData.getCheckpointAmount(); // returns a number that is the player's checkpoint amount in Death Run
// You can use these in all game modes
deathRunData.getXP(); // returns a number that is the player's XP in Death Run
deathRunData.getLevel(); // returns a number that is the player's level in Death Run
deathRunData.getXPRequirement(); // returns a number that is the player's XP requirement in Death Run
deathRunData.getLevelProgress(); // returns a number that is the player's level progress in Death Run
deathRunData.getPlayed(); // returns a number that is the player's played in Death Run
deathRunData.getFirstPlayed(); // returns a number that is the player's first played in Death Run
const hideAndSeekData = await player.getHideNSeekData(); // returns a HideAndSeekData instance that is the player's Hide and Seek data
hideAndSeekData.getVictories(); // returns a number that is the player's victories in Hide and Seek
hideAndSeekData.getDeaths(); // returns a number that is the player's deaths in Hide and Seek
hideAndSeekData.getHiderKills(); // returns a number that is the player's hider kills in Hide and Seek
hideAndSeekData.getSeekerKills(); // returns a number that is the player's seeker kills in Hide and Seek
const murderMysteryData = await player.getMurderMysteryData(); // returns a MurderMysteryData instance that is the player's
murderMysteryData.getVictories(); // returns a number that is the player's victories in Murder Mystery
murderMysteryData.getDeaths(); // returns a number that is the player's deaths in Murder Mystery
murderMysteryData.getCoins(); // returns a number that is the player's coins in Murder Mystery
murderMysteryData.getMurders(); // returns a number that is the player's murders in Murder Mystery
murderMysteryData.getMurdererEliminations(); // returns a number that is the player's murderer eliminations in Murder Mystery
murderMysteryData.getUncappedXPs(); // returns a number that is the player's uncapped xps in Murder Mystery
const skyWarsData = await player.getSkyWarsData(); // returns a SkyWarsData instance that is the player's Sky Wars data
skyWarsData.getVictories(); // returns a number that is the player's victories in Sky Wars
skyWarsData.getKills(); // returns a number that is the player's kills in Sky Wars
skyWarsData.getMysteryChestsDestroyed(); // returns a number that is the player's mystery chests destroyed in Sky Wars
skyWarsData.getOresMined(); // returns a number that is the player's ores mined in Sky Wars
skyWarsData.getSpellsUsed(); // returns a number that is the player's spells used in Sky Wars
const survivalGamesData = await player.getSurvivalGamesData(); // returns a SurvivalGamesData instance that is the player's Survival Games data
survivalGamesData.getVictories(); // returns a number that is the player's victories in Survival Games
survivalGamesData.getOpenedCrates(); // returns a number that is the player's opened crates in Survival Games
survivalGamesData.getDeathMatches(); // returns a number that is the player's death matches in Survival Games
survivalGamesData.getCowsKilled(); // returns a number that is the player's cows killed in Survival Games
survivalGamesData.getKills(); // returns a number that is the player's kills in Survival Games
const treasureWarsData = await player.getTreasureWarsData(); // returns a TreasureWarsData instance that is the player's Treasure Wars data
treasureWarsData.getVictories(); // returns a number that is the player's victories in Treasure Wars
treasureWarsData.getFinalKills(); // returns a number that is the player's final kills in Treasure Wars
treasureWarsData.getKills(); // returns a number that is the player's kills in Treasure Wars
treasureWarsData.getDestroyedTreasures(); // returns a number that is the player's destroyed treasures in Treasure Wars
treasureWarsData.getDeaths(); // returns a number that is the player's deaths in Treasure Wars
treasureWarsData.getPrestiges(); // returns a number that is the player's prestiges in Treasure Wars
})();
Getting leaderboard
// Hive mini games: "dr" | "hide" | "murder" | "sky" | "sg" | "wars"
// first parameter is the name of the hive mini game
// second parameter is if it should force to fetch the leaderboard from api
hiveServer.getLeaderboard("dr", {
monthly: true, // optional, default: false
year: 2020, // optional, default: null, monthly has to be true for this to work
month: 1, // optional, default: null, monthly has to be true for this to work
fetch: true // optional, default: true, if false, the promise will resolve with the cached data
}).then(leaderboard => {
leaderboard.getPlayerIndexByPrefix("player_name"); // returns a number that is the index of the row in the leaderboard
leaderboard.getPlayerValueByPrefix("player_name"); // returns a number that is the value of the row in the leaderboard
leaderboard.getPlayerIndexBySuffix("player_name"); // returns a number that is the index of the row in the leaderboard
leaderboard.getPlayerValueBySuffix("player_name"); // returns a number that is the value of the row in the leaderboard
leaderboard.getPlayerIndexExact("player_name"); // returns a number that is the index of the row in the leaderboard
leaderboard.getPlayerValueExact("player_name"); // returns a number that is the value of the row in the leaderboard
leaderboard.getValueByIndex(0); // returns a number that is the value of the row at the index 0
leaderboard.getPlayerNameByIndex(0); // returns a string that is the name of the player at the index 0
});