Skip to content

Commit

Permalink
feat: ColorFormatAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
engsr6982 committed Jan 17, 2025
1 parent 12b8795 commit 8fec128
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/dts/api/ColorFormat.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference path="../index.d.ts"/>

declare class ColorFormat {
static get Escape(): string;
static get Black(): string;
static get DarkBlue(): string;
static get DarkGreen(): string;
static get DarkAqua(): string;
static get DarkRed(): string;
static get DarkPurple(): string;
static get Gold(): string;
static get Gray(): string;
static get DarkGray(): string;
static get Blue(): string;
static get Green(): string;
static get Aqua(): string;
static get Red(): string;
static get LightPurple(): string;
static get Yellow(): string;
static get White(): string;
static get MinecoinGold(): string;
static get MaterialQuartz(): string;
static get MaterialIron(): string;
static get MaterialNetherite(): string;
static get MaterialRedstone(): string;
static get MaterialCopper(): string;
static get MaterialGold(): string;
static get MaterialEmerald(): string;
static get MaterialDiamond(): string;
static get MaterialLapis(): string;
static get MaterialAmethyst(): string;
static get MaterialResin(): string;
static get Obfuscated(): string;
static get Bold(): string;
static get Italic(): string;
static get Reset(): string;
}
3 changes: 3 additions & 0 deletions lib/dts/api/Server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,7 @@ declare class Server {
// getBanList(): any;

// getIpBanList(): any;

static get BroadcastChannelAdmin(): string;
static get BroadcastChannelUser(): string;
}
47 changes: 47 additions & 0 deletions src/api/ColorFormatAPI.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "api/ColorFormatAPI.h"
#include "endstone/color_format.h"
#include "utils/Convert.h"
#include "utils/Using.h"

namespace jse {


ClassDefine<void> ColorFormatAPI::builder =
defineClass("ColorFormat")
.property("Escape", []() { return ConvertToScriptX(endstone::ColorFormat::Escape); })
.property("Black", []() { return ConvertToScriptX(endstone::ColorFormat::Black); })
.property("DarkBlue", []() { return ConvertToScriptX(endstone::ColorFormat::DarkBlue); })
.property("DarkGreen", []() { return ConvertToScriptX(endstone::ColorFormat::DarkGreen); })
.property("DarkAqua", []() { return ConvertToScriptX(endstone::ColorFormat::DarkAqua); })
.property("DarkRed", []() { return ConvertToScriptX(endstone::ColorFormat::DarkRed); })
.property("DarkPurple", []() { return ConvertToScriptX(endstone::ColorFormat::DarkPurple); })
.property("Gold", []() { return ConvertToScriptX(endstone::ColorFormat::Gold); })
.property("Gray", []() { return ConvertToScriptX(endstone::ColorFormat::Gray); })
.property("DarkGray", []() { return ConvertToScriptX(endstone::ColorFormat::DarkGray); })
.property("Blue", []() { return ConvertToScriptX(endstone::ColorFormat::Blue); })
.property("Green", []() { return ConvertToScriptX(endstone::ColorFormat::Green); })
.property("Aqua", []() { return ConvertToScriptX(endstone::ColorFormat::Aqua); })
.property("Red", []() { return ConvertToScriptX(endstone::ColorFormat::Red); })
.property("LightPurple", []() { return ConvertToScriptX(endstone::ColorFormat::LightPurple); })
.property("Yellow", []() { return ConvertToScriptX(endstone::ColorFormat::Yellow); })
.property("White", []() { return ConvertToScriptX(endstone::ColorFormat::White); })
.property("MinecoinGold", []() { return ConvertToScriptX(endstone::ColorFormat::MinecoinGold); })
.property("MaterialQuartz", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialQuartz); })
.property("MaterialIron", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialIron); })
.property("MaterialNetherite", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialNetherite); })
.property("MaterialRedstone", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialRedstone); })
.property("MaterialCopper", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialCopper); })
.property("MaterialGold", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialGold); })
.property("MaterialEmerald", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialEmerald); })
.property("MaterialDiamond", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialDiamond); })
.property("MaterialLapis", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialLapis); })
.property("MaterialAmethyst", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialAmethyst); })
.property("MaterialResin", []() { return ConvertToScriptX(endstone::ColorFormat::MaterialResin); })
.property("Obfuscated", []() { return ConvertToScriptX(endstone::ColorFormat::Obfuscated); })
.property("Bold", []() { return ConvertToScriptX(endstone::ColorFormat::Bold); })
.property("Italic", []() { return ConvertToScriptX(endstone::ColorFormat::Italic); })
.property("Reset", []() { return ConvertToScriptX(endstone::ColorFormat::Reset); })
.build();


} // namespace jse
13 changes: 13 additions & 0 deletions src/api/ColorFormatAPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once
#include "utils/Using.h"

namespace jse {


class ColorFormatAPI {
public:
static ClassDefine<void> builder;
};


} // namespace jse
2 changes: 2 additions & 0 deletions src/manager/BindAPI.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "api/ColorFormatAPI.h"
#include "api/LoggerAPI.h"
#include "api/PlayerAPI.h"
#include "api/ServerAPI.h"
Expand Down Expand Up @@ -28,6 +29,7 @@ inline void BindAPI(ScriptEngine* engine) {
// static class
engine->registerNativeClass(JSEAPI::builder);
engine->registerNativeClass(FileAPI::builder);
engine->registerNativeClass(ColorFormatAPI::builder);

// instance class
#define REGISTER_CLASS(CLASS) engine->registerNativeClass<CLASS>(CLASS::builder)
Expand Down

0 comments on commit 8fec128

Please sign in to comment.