-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathBedrockPlugin.cpp
More file actions
91 lines (75 loc) · 2.17 KB
/
Copy pathBedrockPlugin.cpp
File metadata and controls
91 lines (75 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <libstuff/libstuff.h>
#include "BedrockPlugin.h"
#include "BedrockServer.h"
map<string, function<BedrockPlugin* (BedrockServer&)>> BedrockPlugin::g_registeredPluginList;
BedrockPlugin::BedrockPlugin(BedrockServer& s) : server(s)
{
}
BedrockPlugin::~BedrockPlugin()
{
}
bool BedrockPlugin::isValidDate(const string& date)
{
return SREMatch("^(19|2[0-9])\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])( \\d{2}:\\d{2}:\\d{2})?$", date);
}
void BedrockPlugin::verifyAttributeInt64(const SData& request, const string& name, size_t minSize)
{
if (request[name].size() < minSize) {
STHROW("402 Missing " + name);
}
if (!request[name].empty() && request[name] != SToStr(SToInt64(request[name]))) {
STHROW("402 Malformed " + name);
}
}
void BedrockPlugin::verifyAttributeSize(const SData& request, const string& name, size_t minSize, size_t maxSize)
{
if (request[name].size() < minSize) {
STHROW("402 Missing " + name);
}
if (request[name].size() > maxSize) {
STHROW("402 Malformed " + name);
}
}
void BedrockPlugin::verifyAttributeBool(const SData& request, const string& name, bool require)
{
if (require && !request[name].size()) {
STHROW("402 Missing " + name);
}
if (!request[name].empty() && !SIEquals(request[name], "true") && !SIEquals(request[name], "false")) {
STHROW("402 Malformed " + name);
}
}
void BedrockPlugin::verifyAttributeDate(const SData& request, const char* key, bool require)
{
if (require && request[key].empty()) {
STHROW("402 Missing " + string(key));
}
if (!request[key].empty() && !isValidDate(request[key])) {
STHROW("402 Malformed " + string(key));
}
}
STable BedrockPlugin::getInfo()
{
return STable();
}
const string& BedrockPlugin::getName() const
{
SERROR("No name defined by this plugin, aborting.");
}
bool BedrockPlugin::preventAttach()
{
return false;
}
void BedrockPlugin::timerFired(SStopwatch* timer)
{
}
void BedrockPlugin::upgradeDatabase(SQLite& db)
{
}
void BedrockPlugin::initializeFromDB(SQLite& db)
{
}
bool BedrockPlugin::shouldLockCommitPageOnConflict(const string& conflictLocation) const
{
return true;
}