Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
1.7.0更新,新增大量监听,新增minVersionRequire函数,摒弃getVersion函数,修复新增监听逻辑出错问题,去除了不…
Browse files Browse the repository at this point in the history
…必要的声明
  • Loading branch information
twoone3l committed Aug 19, 2021
1 parent a8edae3 commit bb11751
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 141 deletions.
6 changes: 3 additions & 3 deletions BDSpyrunner/Header File/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ struct Actor {
bool removeTag(const std::string& str);
//获取标签
span<std::string> getTags();
//自杀
bool kill();
//杀死实体
void kill();
};
struct Mob : Actor {};
struct Player : Mob {
Expand Down Expand Up @@ -112,7 +112,7 @@ struct Player : Mob {
//刷新区块
void resendAllChunks();
//崩溃客户端
bool crash();
void crash();
//发送数据包
void sendPacket(uintptr_t pkt);
unsigned sendModalFormRequestPacket(const std::string& str);
Expand Down
1 change: 0 additions & 1 deletion BDSpyrunner/Header File/Event.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#include <unordered_map>
#include <string>
#include <stdint.h>

enum class EventCode {
None,
Expand Down
93 changes: 2 additions & 91 deletions BDSpyrunner/Header File/PyEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,104 +15,15 @@
Py_END_ALLOW_THREADS;\
if (!_has_gil)PyGILState_Release(_gil_state)

//转换std::string为PyUnicode
PyObject* toPyUnicode(const std::string&);
struct Actor;
struct Player;
// 实体类型
struct PyEntity {
PyObject_HEAD;
Actor* actor;
};

Actor* PyEntity_AsActor(PyObject* self);
Player* PyEntity_AsPlayer(PyObject* self);

//初始化
PyObject* PyEntity_New(PyTypeObject* type, PyObject*, PyObject*);
//构造函数
int PyEntity_Init(PyObject* self, PyObject* args, PyObject*);
//回收
void PyEntity_Dealloc(PyObject* obj);
//转字符串
PyObject* PyEntity_Str(PyObject* self);
//哈希
Py_hash_t PyEntity_Hash(PyObject* self);
//比较
PyObject* PyEntity_RichCompare(PyObject* self, PyObject* other, int op);

//获取名字
PyObject* PyEntity_GetName(PyObject* self, void*);
int PyEntity_SetName(PyObject* self, PyObject* arg, void*);
//获取UUID
PyObject* PyEntity_GetUuid(PyObject* self, void*);
//获取XUID
PyObject* PyEntity_GetXuid(PyObject* self, void*);
//获取坐标
PyObject* PyEntity_GetPos(PyObject* self, void*);
//获取维度ID
PyObject* PyEntity_GetDimensionId(PyObject* self, void*);
//是否着地
PyObject* PyEntity_GetIsStand(PyObject* self, void*);
//是否潜行
PyObject* PyEntity_GetIsSneaking(PyObject* self, void*);
//获取类型
PyObject* PyEntity_GetTypeID(PyObject* self, void*);
//获取类型字符串
PyObject* PyEntity_GetTypeName(PyObject* self, void*);
//获取nbt数据
PyObject* PyEntity_GetNBTInfo(PyObject* self, void*);
//获取生命值
PyObject* PyEntity_GetHealth(PyObject* self, void*);
int PyEntity_SetHealth(PyObject* self, PyObject* arg, void*);
//获取最大生命值
PyObject* PyEntity_GetMaxHealth(PyObject* self, void*);
int PyEntity_SetMaxHealth(PyObject* self, PyObject* arg, void*);
//获取权限
PyObject* PyEntity_GetPermissions(PyObject* self, void*);
int PyEntity_SetPermissions(PyObject* self, PyObject* arg, void*);
//获取设备id
PyObject* PyEntity_GetDeviceId(PyObject* self, void*);
//获取设备类型
PyObject* PyEntity_GetDeviceOS(PyObject* self, void*);
//获取IP
PyObject* PyEntity_GetIP(PyObject* self, void*);

//获取/设置玩家所有物品
PyObject* PyEntity_GetAllItem(PyObject* self, PyObject*);
PyObject* PyEntity_SetAllItem(PyObject* self, PyObject* args);
PyObject* PyEntity_SetHand(PyObject* self, PyObject* args);
//增加/移除物品
PyObject* PyEntity_AddItem(PyObject* self, PyObject* args);
PyObject* PyEntity_RemoveItem(PyObject* self, PyObject* args);
//传送
PyObject* PyEntity_Teleport(PyObject* self, PyObject* args);
//发送数据包
PyObject* PyEntity_SendTextPacket(PyObject* self, PyObject* args);
PyObject* PyEntity_SendCommandPacket(PyObject* self, PyObject* args);
PyObject* PyEntity_ResendAllChunks(PyObject* self, PyObject*);
PyObject* PyEntity_Disconnect(PyObject* self, PyObject* args);
//计分板操作
PyObject* PyEntity_GetScore(PyObject* self, PyObject* args);
PyObject* PyEntity_ModifyScore(PyObject* self, PyObject* args);
//增加等级
PyObject* PyEntity_AddLevel(PyObject* self, PyObject* args);
//跨服传送
PyObject* PyEntity_TransferServer(PyObject* self, PyObject* args);
//发送表单
PyObject* PyEntity_SendCustomForm(PyObject* self, PyObject* args);
PyObject* PyEntity_SendSimpleForm(PyObject* self, PyObject* args);
PyObject* PyEntity_SendModalForm(PyObject* self, PyObject* args);
//设置侧边栏
PyObject* PyEntity_SetSidebar(PyObject* self, PyObject* args);
PyObject* PyEntity_RemoveSidebar(PyObject* self, PyObject*);
//Boss栏
PyObject* PyEntity_SetBossbar(PyObject* self, PyObject* args);
PyObject* PyEntity_RemoveBossbar(PyObject* self, PyObject*);
//标签
PyObject* PyEntity_AddTag(PyObject* self, PyObject* args);
PyObject* PyEntity_RemoveTag(PyObject* self, PyObject* args);
PyObject* PyEntity_GetTags(PyObject* self, PyObject*);
//转换std::string为PyUnicode
PyObject* toPyUnicode(const std::string&);

PyObject* PyEntity_FromEntity(Actor* ptr);

Expand Down
15 changes: 5 additions & 10 deletions BDSpyrunner/Source File/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,17 @@ span<string> Actor::getTags() {
return tags;
}

void Actor::kill() {
SymCall("?kill@Mob@@UEAAXXZ", this);
}

string Player::getUuid() {//IDA ServerNetworkHandler::_createNewPlayer 222
string p;
SymCall<string&>("?asString@UUID@mce@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ",
this + 3000, &p);
return p;
}

//发送数据包

//根据地图信息获取玩家xuid

string& Player::getXuid() {
Expand Down Expand Up @@ -342,19 +344,12 @@ void Player::sendPacket(uintptr_t pkt) {
}

//使玩家客户端崩溃
bool Player::crash() {
void Player::crash() {
uintptr_t pkt = createPacket(58);
FETCH(int, pkt + 14) = 0;
FETCH(int, pkt + 15) = 0;
FETCH(bool, pkt + 48) = 1;
sendPacket(pkt);
return true;
}

//杀死实体
bool Actor::kill() {
SymCall("?kill@Mob@@UEAAXXZ", this);
return true;
}

unsigned Player::sendModalFormRequestPacket(const string& str) {
Expand Down
11 changes: 6 additions & 5 deletions BDSpyrunner/Source File/PyEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,15 +613,17 @@ PyObject* PyEntity_Crash(PyObject* self, PyObject*) {
Player* p = PyEntity_AsPlayer(self);
if (!p)
return nullptr;
return PyBool_FromLong(p->crash());
p->crash();
Py_RETURN_NONE;
}

//杀死实体
PyObject* PyEntity_Kill(PyObject* self, PyObject*) {
Actor* a = PyEntity_AsActor(self);
if (!a)
return nullptr;
return PyBool_FromLong(a->kill());
a->kill();
Py_RETURN_NONE;
}

PyObject* PyEntity_FromEntity(Actor* ptr) {
Expand All @@ -633,7 +635,6 @@ PyObject* PyEntity_FromEntity(Actor* ptr) {
return obj;
}


//获取属性方法
PyGetSetDef PyEntity_GetSet[]{
{"name", PyEntity_GetName, PyEntity_SetName, nullptr},
Expand Down Expand Up @@ -680,8 +681,8 @@ PyMethodDef PyEntity_Methods[]{
{"addTag", PyEntity_AddTag, METH_VARARGS, nullptr},
{"removeTag", PyEntity_RemoveTag, METH_VARARGS, nullptr},
{"getTags", PyEntity_GetTags, METH_NOARGS, nullptr},
{"crash",PyEntity_Crash,METH_NOARGS,nullptr},
{"kill",PyEntity_Kill,METH_NOARGS,nullptr},
{"crash", PyEntity_Crash, METH_NOARGS, nullptr},
{"kill", PyEntity_Kill, METH_NOARGS, nullptr},
{nullptr}
};
//Entity类型
Expand Down
Loading

0 comments on commit bb11751

Please sign in to comment.