Skip to content

Commit

Permalink
refactor: adapt to ll develop
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Oct 2, 2024
1 parent c6a003e commit 55b5827
Show file tree
Hide file tree
Showing 26 changed files with 128 additions and 325 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ body:
- type: input
attributes:
label: Version
description: The version of the plugin you are using. (e.g. 1.0.0)
description: The version of the mod you are using. (e.g. 1.0.0)

- type: textarea
attributes:
Expand Down
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "${pluginName}",
"entry": "${pluginFile}",
"version": "${pluginVersion}",
"name": "${modName}",
"entry": "${modFile}",
"version": "${modVersion}",
"type": "native",
"dependencies": [
{
Expand Down
118 changes: 0 additions & 118 deletions scripts/after_build.lua

This file was deleted.

26 changes: 26 additions & 0 deletions src/command/Commands.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "command/Commands.h"
#include "worldedit/WorldEdit.h"

namespace we {

std::vector<std::pair<std::string, std::function<void()>>> setupCommandFunctions;

void setupCommands() {
for (auto& [name, fn] : setupCommandFunctions) {
WEDEBUG("setup command {}", name);
try {
fn();
} catch (...) {
logger().error("threw from setup command {}", name);
ll::error_utils::printCurrentException(logger());
}
WEDEBUG("setup command {} done", name);
}
}

bool addSetup(std::string name, std::function<void()> fn) noexcept {
setupCommandFunctions.emplace_back(std::move(name), std::move(fn));
return true;
}

} // namespace we
14 changes: 6 additions & 8 deletions src/command/Commands.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#pragma once

#include "command/region/RegionCommands.h"
#include "worldedit/Global.h"

namespace we {
// void setupTick();
// void setupbrush();
void setupCommands() {
setupRegionCommands();
// setupTick();
// setupbrush();
}

void setupCommands();

bool addSetup(std::string name, std::function<void()>) noexcept;

} // namespace we
5 changes: 3 additions & 2 deletions src/command/region/Chunk.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "command/Commands.h"
#include "data/PlayerStateManager.h"
#include "region/LoftRegion.h"
#include "worldedit/WorldEdit.h"

namespace we {
void setupChunk() {
static bool _ = addSetup("chunk", [] {
auto& config = WorldEdit::getInstance().getConfig().commands.region.chunk;
if (!config.enabled) {
return;
Expand Down Expand Up @@ -37,5 +38,5 @@ void setupChunk() {
state->regionType = RegionType::Cuboid;
output.success("chunk selected"_tr());
});
}
});
} // namespace we
5 changes: 3 additions & 2 deletions src/command/region/Hpos1.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "command/Commands.h"
#include "data/PlayerStateManager.h"
#include "region/LoftRegion.h"
#include "worldedit/WorldEdit.h"

namespace we {
void setupHpos1() {
static bool _ = addSetup("hpos1", [] {
auto& config = WorldEdit::getInstance().getConfig().commands.region.hpos1;
if (!config.enabled) {
return;
Expand Down Expand Up @@ -44,5 +45,5 @@ void setupHpos1() {
output.error("can't set main position at {0}"_tr(hitResult.mBlockPos));
}
});
}
});
} // namespace we
5 changes: 3 additions & 2 deletions src/command/region/Hpos2.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "data/PlayerStateManager.h"
#include "region/LoftRegion.h"
#include "command/Commands.h"
#include "worldedit/WorldEdit.h"

namespace we {
void setupHpos2() {
static bool _ = addSetup("hpos2", [] {
auto& config = WorldEdit::getInstance().getConfig().commands.region.hpos2;
if (!config.enabled) {
return;
Expand Down Expand Up @@ -44,5 +45,5 @@ void setupHpos2() {
output.error("can't set off position at {0}"_tr(hitResult.mBlockPos));
}
});
}
});
} // namespace we
5 changes: 3 additions & 2 deletions src/command/region/Loftcycle.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "command/Commands.h"
#include "data/PlayerStateManager.h"
#include "region/LoftRegion.h"
#include "worldedit/WorldEdit.h"
Expand All @@ -8,7 +9,7 @@ struct Params {
bool cycle;
};

void setupLoftcycle() {
static bool _ = addSetup("loftcycle", [] {
auto& config = WorldEdit::getInstance().getConfig().commands.region.loftcycle;
if (!config.enabled) {
return;
Expand All @@ -34,5 +35,5 @@ void setupLoftcycle() {
output.success("set loft region cycle to {0}"_tr(params.cycle));
}
);
}
});
} // namespace we
5 changes: 3 additions & 2 deletions src/command/region/Pos1.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "command/Commands.h"
#include "data/PlayerStateManager.h"
#include "region/LoftRegion.h"
#include "worldedit/WorldEdit.h"
Expand All @@ -6,7 +7,7 @@ namespace we {
struct Params {
ll::command::Optional<CommandPositionFloat> pos;
};
void setupPos1() {
static bool _ = addSetup("pos1", [] {
auto& config = WorldEdit::getInstance().getConfig().commands.region.pos1;
if (!config.enabled) {
return;
Expand Down Expand Up @@ -43,5 +44,5 @@ void setupPos1() {
output.error("can't set main position at {0}"_tr(pos));
}
});
}
});
} // namespace we
5 changes: 3 additions & 2 deletions src/command/region/Pos2.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "command/Commands.h"
#include "data/PlayerStateManager.h"
#include "region/LoftRegion.h"
#include "worldedit/WorldEdit.h"
Expand All @@ -6,7 +7,7 @@ namespace we {
struct Params {
ll::command::Optional<CommandPositionFloat> pos;
};
void setupPos2() {
static bool _ = addSetup("pos2", [] {
auto& config = WorldEdit::getInstance().getConfig().commands.region.pos2;
if (!config.enabled) {
return;
Expand Down Expand Up @@ -43,5 +44,5 @@ void setupPos2() {
output.error("can't set off position at {0}"_tr(pos));
}
});
}
});
} // namespace we
21 changes: 0 additions & 21 deletions src/command/region/RegionCommands.h

This file was deleted.

5 changes: 3 additions & 2 deletions src/command/region/Sel.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "command/Commands.h"
#include "data/PlayerStateManager.h"
#include "region/Region.h"
#include "worldedit/WorldEdit.h"
Expand All @@ -15,7 +16,7 @@ struct SelRm {
SelRemoveType type;
};

void setupSel() {
static bool _ = addSetup("sel", [] {
auto& config = WorldEdit::getInstance().getConfig().commands.region.sel;
if (!config.enabled) {
return;
Expand Down Expand Up @@ -86,5 +87,5 @@ void setupSel() {
state->offPos.reset();
output.success("region switch to {0}"_tr(params.type));
});
}
});
} // namespace we
4 changes: 2 additions & 2 deletions src/data/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ struct Config {
int minimum_response_tick = 3;
} player_state;
struct {
int player_log_level = 3;
ll::io::LogLevel player_log_level{ll::io::LogLevel::Warn};
} log;

struct PlayerConfig {
RegionType default_region_type{RegionType::Cuboid};
RegionType default_region_type{RegionType::Expand};
HashedString wand = VanillaItemNames::WoodenAxe;
} player_default_config;
};
Expand Down
4 changes: 2 additions & 2 deletions src/data/PlayerState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void PlayerState::setMainPosInternal() {
auto& we = WorldEdit::getInstance();
mainPos->geo = we.getGeo().box(
mainPos->data.dim,
AABB{mainPos->data.pos}.shrink(-0.07),
AABB{mainPos->data.pos}.shrink(-0.07f),
we.getConfig().colors.main_hand_color
);
}
Expand All @@ -24,7 +24,7 @@ void PlayerState::setOffPosInternal() {
auto& we = WorldEdit::getInstance();
offPos->geo = we.getGeo().box(
offPos->data.dim,
AABB{offPos->data.pos}.shrink(-0.06),
AABB{offPos->data.pos}.shrink(-0.06f),
we.getConfig().colors.off_hand_color
);
}
Expand Down
Loading

0 comments on commit 55b5827

Please sign in to comment.