Skip to content

Commit

Permalink
Merge pull request #3 from n15421/main
Browse files Browse the repository at this point in the history
adapt: adapt GMLIB-0.13.10
  • Loading branch information
killcerr authored Feb 2, 2025
2 parents ee97ffa + f699af1 commit 4161d52
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 311 deletions.
19 changes: 19 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@ Diagnostics:
- "-Wc++11-narrowing"
- "-Wc++2b-extensions"
- "-Wmicrosoft-cast"
- "-Wcxx20_deducing_this"
- "-Wundefined_internal_type"
- "-Wincomplete_member_access"
- "-Wsizeof_alignof_incomplete_or_sizeless_type"
- "-Wexplicit_spec_non_template"
- "-Wundeclared_var_use"
- "-Wno_member"
- "-Wovl_no_viable_function_in_init"
- "-Wunknown_typename"
- "-Wqualified_param_declarator"
- "-Wtrailing_return_without_auto"
- "-Wexpected"
CompileFlags:
Add:
- "-Xclang"
- "-triple=x86_64-windows-msvc"
- "-ferror-limit=0"
- '-D__FUNCTION__="dummy"'
- "-Dnsel_CONFIG_SELECT_EXPECTED=nsel_EXPECTED_NONSTD"
- "-Xclang"
- "-std=c++23"
Remove:
- "-std"
12 changes: 2 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
uses: actions/checkout@v2

- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@master

- run: |
xmake repo -u
Expand All @@ -23,14 +21,8 @@ jobs:
- run: |
xmake -w -y
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
path: |
bin/DLL/
- uses: actions/upload-artifact@v3
with:
name: PDB
path: |
bin/PDB/
bin/
33 changes: 8 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
uses: actions/checkout@v2

- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@master

- run: |
xmake repo -u
Expand All @@ -23,17 +21,11 @@ jobs:
- run: |
xmake -w -y
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
path: |
bin/DLL/
- uses: actions/upload-artifact@v3
with:
name: PDB
path: |
bin/PDB/
bin/
upload-to-release:
needs:
Expand All @@ -45,32 +37,23 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Download Plugin
uses: actions/download-artifact@v3
- name: Download Mod
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
path: release/Plugin/

- name: Download PDB
uses: actions/download-artifact@v3
with:
name: PDB
path: release/PDB/
path: artifact

- name: Copy additional files
run: |
cp LICENSE README.md release/Plugin/
cp -v LICENSE README.md artifact/
- name: Archive release
run: |
cd release/Plugin
zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
cd ..
working-directory: artifact

- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: |
release/${{ github.event.repository.name }}-windows-x64.zip
release/PDB/${{ github.event.repository.name }}.pdb
${{ github.event.repository.name }}-windows-x64.zip
15 changes: 8 additions & 7 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "${pluginName}",
"entry": "${pluginFile}",
"name": "DynamicLights",
"entry": "DynamicLights.dll",
"type": "native",
"author": "author",
"description": "Dynamic Lights for BDS",
"version": "0.2.0",
"version": "0.2.1",
"dependencies": [
{
"name": "GMLIB"
}
{
"name": "GMLIB"
}
]
}
}

119 changes: 0 additions & 119 deletions scripts/after_build.lua

This file was deleted.

40 changes: 20 additions & 20 deletions src/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ void registerAdminCommand() {
.text("set")
.required("item")
.required("lightLevel")
.execute<[](CommandOrigin const& origin, CommandOutput& output, ManageCommand const& param) {
.execute([](CommandOrigin const& origin, CommandOutput& output, ManageCommand const& param) {
if (auto item = param.item.createInstance(1, 0, output, false)) {
DynamicLights::Entry::getInstance()->getLightsManager().setItemLightInfo(
DynamicLights::Entry::getInstance().getLightsManager().setItemLightInfo(
item->getTypeName(),
param.lightLevel
);
Expand All @@ -30,15 +30,15 @@ void registerAdminCommand() {
);
}
return output.error(tr("command.dynamiclightsmanager.invalidItem"));
}>();
});
cmd.overload<ManageCommand>()
.text("items")
.text("delete")
.required("item")
.execute<[](CommandOrigin const& origin, CommandOutput& output, ManageCommand const& param) {
.execute([](CommandOrigin const& origin, CommandOutput& output, ManageCommand const& param) {
if (auto item = param.item.createInstance(1, 0, output, false)) {
auto result =
DynamicLights::Entry::getInstance()->getLightsManager().deleteItemLightInfo(item->getTypeName());
DynamicLights::Entry::getInstance().getLightsManager().deleteItemLightInfo(item->getTypeName());
return result ? output.success(
tr("command.dynamiclightsmanager.deleteItem.success", {item->getDescriptionName()})
)
Expand All @@ -47,19 +47,19 @@ void registerAdminCommand() {
);
}
return output.error(tr("command.dynamiclightsmanager.invalidItem"));
}>();
});
cmd.overload<ManageCommand>()
.text("offhand")
.required("action")
.required("item")
.execute<[](CommandOrigin const& origin, CommandOutput& output, ManageCommand const& param) {
.execute([](CommandOrigin const& origin, CommandOutput& output, ManageCommand const& param) {
if (auto item = param.item.createInstance(1, 0, output, false)) {
auto& itemList = DynamicLights::Entry::getInstance()->getConfig().offhandItems;
auto& itemList = DynamicLights::Entry::getInstance().getConfig().offhandItems;
auto typeName = item->getTypeName();
if (param.action == ManageCommand::Action::add) {
if (!itemList.contains(typeName)) {
itemList.insert(typeName);
DynamicLights::Entry::getInstance()->saveConfig();
DynamicLights::Entry::getInstance().saveConfig();
return output.success(
tr("command.dynamiclightsmanager.offhand.add.success", {item->getDescriptionName()})
);
Expand All @@ -70,7 +70,7 @@ void registerAdminCommand() {
} else {
if (itemList.contains(typeName)) {
itemList.erase(typeName);
DynamicLights::Entry::getInstance()->saveConfig();
DynamicLights::Entry::getInstance().saveConfig();
return output.success(
tr("command.dynamiclightsmanager.offhand.remove.success", {item->getDescriptionName()})
);
Expand All @@ -81,35 +81,35 @@ void registerAdminCommand() {
}
}
return output.error(tr("command.dynamiclightsmanager.invalidItem"));
}>();
});
cmd.overload<ManageCommand>()
.text("reload")
.execute<[](CommandOrigin const& origin, CommandOutput& output, ManageCommand const& param) {
DynamicLights::Entry::getInstance()->loadConfig();
DynamicLights::Entry::getInstance()->getI18n().loadAllLanguages();
DynamicLights::Entry::getInstance()->getLightsManager().readConfig();
.execute([](CommandOrigin const& origin, CommandOutput& output, ManageCommand const& param) {
DynamicLights::Entry::getInstance().loadConfig();
DynamicLights::Entry::getInstance().getI18n().loadAllLanguages();
DynamicLights::Entry::getInstance().getLightsManager().readConfig();
return output.success(tr("command.dynamiclightsmanager.reload"));
}>();
});
}

void registerPlayerCommand() {
auto& cmd = ll::command::CommandRegistrar::getInstance()
.getOrCreateCommand("dynamiclights", tr("command.dynamiclights.desc"), CommandPermissionLevel::Any);
cmd.alias("dl");
cmd.overload<ManageCommand>()
.execute<[](CommandOrigin const& origin, CommandOutput& output, ManageCommand const& param) {
.execute([](CommandOrigin const& origin, CommandOutput& output, ManageCommand const& param) {
if (origin.getOriginType() == CommandOriginType::Player) {
auto player = (Player*)origin.getEntity();
auto& manager = DynamicLights::Entry::getInstance()->getLightsManager();
manager.remove(player->getOrCreateUniqueID().id);
auto& manager = DynamicLights::Entry::getInstance().getLightsManager();
manager.remove(player->getOrCreateUniqueID().rawID);
auto enable = !manager.getPlayerConfig(player->getUuid());
manager.setPlayerConfig(player->getUuid(), enable);
enable ? manager.sendLightsTo(*player) : manager.removeLightsFrom(*player);
return enable ? output.success(tr("command.dynamiclights.enabled"))
: output.success(tr("command.dynamiclights.disabled"));
}
return output.error(tr("command.dynamiclights.invalidCommandOrigin"));
}>();
});
}

void registerCommands() {
Expand Down
3 changes: 3 additions & 0 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <unordered_map>
#include <unordered_set>

namespace DynamicLights {

struct Config {
int version = 1;

Expand All @@ -14,3 +16,4 @@ struct Config {
{"minecraft:torch", 14}
};
};
} // namespace DynamicLights
Loading

0 comments on commit 4161d52

Please sign in to comment.