servertap-js
Version:
A TypeScript library for working with the ServerTap API
3 lines (2 loc) • 4.17 kB
JavaScript
function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=/*#__PURE__*/t(require("isomorphic-unfetch"));function r(){return r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},r.apply(this,arguments)}function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},o(t,e)}var i,u=/*#__PURE__*/function(){function t(t){this.apiKey=void 0,this.baseUrl=void 0,this.apiKey=t.apiKey,this.baseUrl=t.baseUrl||"https://dev.to/api/"}return t.prototype.request=function(t,n,o){void 0===o&&(o="application/json");var i=this.baseUrl+"/v1"+t,u=r({},n,{headers:{"Content-type":o,"api-key":this.apiKey}});return e.default(i,u).then(function(t){if(t.ok)return t.json();switch(t.status){case 404:throw new Error("Not found");case 400:throw new Error("Bad request")}})},t}(),s=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var r=e.prototype;return r.getAllPlayers=function(){return this.request("/players/all")},r.getPlayers=function(){return this.request("/players")},r.getOps=function(){return this.request("/server/ops")},r.addOp=function(t){return this.request("/server/ops",{method:"POST",body:"playerUuid="+t},"application/x-www-form-urlencoded")},r.removeOp=function(t){return this.request("/server/ops",{method:"DELETE",body:"playerUuid="+t},"application/x-www-form-urlencoded")},r.getPlayer=function(t){return this.request("/players/"+t)},r.getPlayerInventory=function(t,e){return this.request("/players/"+t+"/"+e+"/inventory")},e}(u),c=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var r=e.prototype;return r.ping=function(){return this.request("/ping")},r.getServer=function(){return this.request("/server")},r.execCommand=function(t){return t.startsWith("/")&&(t=t.substring(1)),this.request("/server/exec",{method:"POST",body:"command="+t},"application/x-www-form-urlencoded")},r.getWhitelist=function(){return this.request("/server/whitelist")},r.addWhitelist=function(t,e){return this.request("/server/whitelist",{method:"POST",body:"uuid="+t+"&name="+e},"application/x-www-form-urlencoded")},r.getWorlds=function(){return this.request("/worlds")},r.saveWorld=function(t){return this.request("/worlds/"+t+"/save",{method:"POST"})},r.getScoreBoards=function(){return this.request("/scoreboard")},r.getScoreBoard=function(t){return this.request("/scoreboard/"+t)},e}(u),a=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var r=e.prototype;return r.broadcast=function(t){return this.request("/chat/broadcast",{method:"POST",body:"message="+t},"application/x-www-form-urlencoded")},r.tell=function(t,e){return this.request("/chat/tell",{method:"POST",body:"playerUuid="+t+"&message="+e},"application/x-www-form-urlencoded")},e}(u),p=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var r=e.prototype;return r.pay=function(t,e){return this.request("/economy/pay",{method:"POST",body:"uuid="+t+"&amount="+e},"application/x-www-form-urlencoded")},r.debit=function(t,e){return this.request("/economy/debit",{method:"POST",body:"uuid="+t+"&amount="+e},"application/x-www-form-urlencoded")},r.economy=function(){return this.request("/economy")},e}(u),d=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e.prototype.replace=function(t,e){return this.request("/placeholder/replace",{method:"POST",body:"message="+t+",uuid="+e},"application/x-www-form-urlencoded")},e}(u),h=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e.prototype.getPlugins=function(){return this.request("/plugins")},e}(u),f=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e}(u);i=f,[s,c,a,p,d,h].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(i.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})}),module.exports=f;
//# sourceMappingURL=index.cjs.map