Skip to content
This repository was archived by the owner on Oct 28, 2023. It is now read-only.

Commit 2282280

Browse files
committed
Add plugin ServerSettings
Update headers & lib
1 parent a3a8856 commit 2282280

File tree

9 files changed

+317
-0
lines changed

9 files changed

+317
-0
lines changed

LiteLoaderMOD.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Transfer", "Transfer\Transf
1717
EndProject
1818
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AntiToolbox", "AntiToolbox\AntiToolbox.vcxproj", "{2DE40108-C956-489B-9956-B7D0F5D1AC8F}"
1919
EndProject
20+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerSettings", "ServerSettings\ServerSettings.vcxproj", "{F86BE2C4-FF2E-40FD-9D99-9266102F3ACE}"
21+
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2224
Debug|x64 = Debug|x64
@@ -81,6 +83,14 @@ Global
8183
{2DE40108-C956-489B-9956-B7D0F5D1AC8F}.Release|x64.Build.0 = Release|x64
8284
{2DE40108-C956-489B-9956-B7D0F5D1AC8F}.Release|x86.ActiveCfg = Release|Win32
8385
{2DE40108-C956-489B-9956-B7D0F5D1AC8F}.Release|x86.Build.0 = Release|Win32
86+
{F86BE2C4-FF2E-40FD-9D99-9266102F3ACE}.Debug|x64.ActiveCfg = Debug|x64
87+
{F86BE2C4-FF2E-40FD-9D99-9266102F3ACE}.Debug|x64.Build.0 = Debug|x64
88+
{F86BE2C4-FF2E-40FD-9D99-9266102F3ACE}.Debug|x86.ActiveCfg = Debug|Win32
89+
{F86BE2C4-FF2E-40FD-9D99-9266102F3ACE}.Debug|x86.Build.0 = Debug|Win32
90+
{F86BE2C4-FF2E-40FD-9D99-9266102F3ACE}.Release|x64.ActiveCfg = Release|x64
91+
{F86BE2C4-FF2E-40FD-9D99-9266102F3ACE}.Release|x64.Build.0 = Release|x64
92+
{F86BE2C4-FF2E-40FD-9D99-9266102F3ACE}.Release|x86.ActiveCfg = Release|Win32
93+
{F86BE2C4-FF2E-40FD-9D99-9266102F3ACE}.Release|x86.Build.0 = Release|Win32
8494
EndGlobalSection
8595
GlobalSection(SolutionProperties) = preSolution
8696
HideSolutionNode = FALSE

ServerSettings/ServerSettings.vcxproj

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<ProjectGuid>{F86BE2C4-FF2E-40FD-9D99-9266102F3ACE}</ProjectGuid>
24+
<Keyword>Win32Proj</Keyword>
25+
<RootNamespace>ServerSettings</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>DynamicLibrary</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v142</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>DynamicLibrary</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v142</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>DynamicLibrary</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v142</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>DynamicLibrary</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v142</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
74+
<LinkIncremental>false</LinkIncremental>
75+
<IncludePath>$(SolutionDir)headers;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
78+
<LinkIncremental>true</LinkIncremental>
79+
</PropertyGroup>
80+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
81+
<LinkIncremental>true</LinkIncremental>
82+
</PropertyGroup>
83+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
84+
<LinkIncremental>false</LinkIncremental>
85+
</PropertyGroup>
86+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
87+
<ClCompile>
88+
<PrecompiledHeader>Use</PrecompiledHeader>
89+
<WarningLevel>Level3</WarningLevel>
90+
<FunctionLevelLinking>true</FunctionLevelLinking>
91+
<IntrinsicFunctions>true</IntrinsicFunctions>
92+
<SDLCheck>true</SDLCheck>
93+
<PreprocessorDefinitions>NDEBUG;SERVERSETTINGS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
94+
<ConformanceMode>true</ConformanceMode>
95+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
96+
<LanguageStandard>stdcpp17</LanguageStandard>
97+
</ClCompile>
98+
<Link>
99+
<SubSystem>Windows</SubSystem>
100+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
101+
<OptimizeReferences>true</OptimizeReferences>
102+
<GenerateDebugInformation>true</GenerateDebugInformation>
103+
<EnableUAC>false</EnableUAC>
104+
</Link>
105+
</ItemDefinitionGroup>
106+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
107+
<ClCompile>
108+
<PrecompiledHeader>Use</PrecompiledHeader>
109+
<WarningLevel>Level3</WarningLevel>
110+
<SDLCheck>true</SDLCheck>
111+
<PreprocessorDefinitions>WIN32;_DEBUG;SERVERSETTINGS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
112+
<ConformanceMode>true</ConformanceMode>
113+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
114+
</ClCompile>
115+
<Link>
116+
<SubSystem>Windows</SubSystem>
117+
<GenerateDebugInformation>true</GenerateDebugInformation>
118+
<EnableUAC>false</EnableUAC>
119+
</Link>
120+
</ItemDefinitionGroup>
121+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
122+
<ClCompile>
123+
<PrecompiledHeader>Use</PrecompiledHeader>
124+
<WarningLevel>Level3</WarningLevel>
125+
<SDLCheck>true</SDLCheck>
126+
<PreprocessorDefinitions>_DEBUG;SERVERSETTINGS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
127+
<ConformanceMode>true</ConformanceMode>
128+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
129+
</ClCompile>
130+
<Link>
131+
<SubSystem>Windows</SubSystem>
132+
<GenerateDebugInformation>true</GenerateDebugInformation>
133+
<EnableUAC>false</EnableUAC>
134+
</Link>
135+
</ItemDefinitionGroup>
136+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
137+
<ClCompile>
138+
<PrecompiledHeader>Use</PrecompiledHeader>
139+
<WarningLevel>Level3</WarningLevel>
140+
<FunctionLevelLinking>true</FunctionLevelLinking>
141+
<IntrinsicFunctions>true</IntrinsicFunctions>
142+
<SDLCheck>true</SDLCheck>
143+
<PreprocessorDefinitions>WIN32;NDEBUG;SERVERSETTINGS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
144+
<ConformanceMode>true</ConformanceMode>
145+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
146+
</ClCompile>
147+
<Link>
148+
<SubSystem>Windows</SubSystem>
149+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
150+
<OptimizeReferences>true</OptimizeReferences>
151+
<GenerateDebugInformation>true</GenerateDebugInformation>
152+
<EnableUAC>false</EnableUAC>
153+
</Link>
154+
</ItemDefinitionGroup>
155+
<ItemGroup>
156+
<ClInclude Include="framework.h" />
157+
<ClInclude Include="pch.h" />
158+
</ItemGroup>
159+
<ItemGroup>
160+
<ClCompile Include="dllmain.cpp" />
161+
<ClCompile Include="pch.cpp">
162+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
163+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
164+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
165+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
166+
</ClCompile>
167+
</ItemGroup>
168+
<ItemGroup>
169+
<Library Include="..\lib\LiteLoader.lib" />
170+
</ItemGroup>
171+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
172+
<ImportGroup Label="ExtensionTargets">
173+
</ImportGroup>
174+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="源文件">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="头文件">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="资源文件">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClInclude Include="framework.h">
19+
<Filter>头文件</Filter>
20+
</ClInclude>
21+
<ClInclude Include="pch.h">
22+
<Filter>头文件</Filter>
23+
</ClInclude>
24+
</ItemGroup>
25+
<ItemGroup>
26+
<ClCompile Include="dllmain.cpp">
27+
<Filter>源文件</Filter>
28+
</ClCompile>
29+
<ClCompile Include="pch.cpp">
30+
<Filter>源文件</Filter>
31+
</ClCompile>
32+
</ItemGroup>
33+
<ItemGroup>
34+
<Library Include="..\lib\LiteLoader.lib" />
35+
</ItemGroup>
36+
</Project>

ServerSettings/dllmain.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// dllmain.cpp : 定义 DLL 应用程序的入口点。
2+
#include "pch.h"
3+
#include "framework.h"
4+
5+
BOOL APIENTRY DllMain(HMODULE hModule,
6+
DWORD ul_reason_for_call,
7+
LPVOID lpReserved
8+
)
9+
{
10+
switch (ul_reason_for_call)
11+
{
12+
case DLL_PROCESS_ATTACH:
13+
case DLL_THREAD_ATTACH:
14+
case DLL_THREAD_DETACH:
15+
case DLL_PROCESS_DETACH:
16+
break;
17+
}
18+
return TRUE;
19+
}
20+
21+
static Logger LOG(stdio_commit{ "[ServerSettings] " });
22+
std::string form = "";
23+
24+
void entry() {
25+
LOG("Loaded");
26+
std::ifstream fs;
27+
fs.open("plugins/ServerSettings/config.json", std::ios::in);
28+
if (fs) {
29+
char buf[1024];
30+
while (fs.getline(buf, 1024)) {
31+
form.append(buf);
32+
}
33+
}
34+
else {
35+
LOG("Read config.json failed");
36+
form = "{\"type\":\"custom_form\",\"title\":\"LiteLoaderBDS Settings\",\"icon\":{\"type\":\"url\",\"data\":\"https://forum.litebds.com/assets/logo-6pndg21x.png\"},\"content\":[{\"type\":\"label\",\"text\":\"Hello Bedrock Dedicated Server\\nHello LiteLoaderBDS!\"}]}";
37+
}
38+
}
39+
40+
THook(void, "?handle@?$PacketHandlerDispatcherInstance@VServerSettingsRequestPacket@@$0A@@@UEBAXAEBVNetworkIdentifier@@AEAVNetEventCallback@@AEAV?$shared_ptr@VPacket@@@std@@@Z", void* a0, NetworkIdentifier ni, void* a1, void* a2) {
41+
WBStream wb;
42+
wb.apply((VarInts<int>)5928, (MCString)form);
43+
MyPkt<MinecraftPacketIds(0x67)> pkt(wb);
44+
Handler::schedule(DelayedTask([pkt]() {
45+
for (Player* pl : liteloader::getAllPlayers()) {
46+
ServerPlayer* sp = (ServerPlayer*)pl;
47+
sp->sendNetworkPacket((Packet&)pkt);
48+
}
49+
}, 20));
50+
return original(a0, ni, a1, a2);
51+
}
52+
53+
extern "C" {
54+
_declspec(dllexport) void onPostInit() {
55+
std::ios::sync_with_stdio(false);
56+
entry();
57+
}
58+
}
59+

ServerSettings/framework.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma once
2+
3+
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
4+
// Windows 头文件
5+
#include <windows.h>

ServerSettings/pch.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// pch.cpp: 与预编译标头对应的源文件
2+
3+
#include "pch.h"
4+
5+
// 当使用预编译的头时,需要使用此源文件,编译才能成功。

ServerSettings/pch.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// pch.h: 这是预编译标头文件。
2+
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
3+
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
4+
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
5+
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
6+
7+
#ifndef PCH_H
8+
#define PCH_H
9+
10+
// 添加要在此处预编译的标头
11+
#include <iostream>
12+
#include <stl/Logger.h>
13+
#include <stl\Bstream.h>
14+
#include <stl\varint.h>
15+
#include <api\myPacket.h>
16+
#include <api/scheduler/scheduler.h>
17+
#include <mc/Player.h>
18+
19+
#endif //PCH_H

headers/api/packetApi.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
#include <api\myPacket.h>
3+
#include <api\types\types.h>
4+
#include <mc/Player.h>
5+
6+
namespace packetapi {
7+
LIAPI MyPkt<MinecraftPacketIds(0x09)> CreateTextPacket(TextType tp, std::string text);
8+
LIAPI MyPkt<MinecraftPacketIds(0x55), false> CreateTransferPacket(std::string address, int port);
9+
}

lib/LiteLoader.lib

1.49 KB
Binary file not shown.

0 commit comments

Comments
 (0)