Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rnhws-Team/ToolDelta-PhoenixBuilder
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.1
Choose a base ref
...
head repository: rnhws-Team/ToolDelta-PhoenixBuilder
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 20 commits
  • 19 files changed
  • 2 contributors

Commits on Oct 26, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    88763f4 View commit details
  2. Fix error print (#353)

    Liliya233 authored and Happy2018new committed Oct 26, 2023

    Partially verified

    This commit is signed with the committer’s verified signature.
    Happy2018new’s contribution has been verified via GPG key.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    a50f751 View commit details
  3. bump version to 1.1.2

    Happy2018new committed Oct 26, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    98a07a7 View commit details

Commits on Nov 5, 2023

  1. allows users to install from scripts

    Happy2018new committed Nov 5, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    fb63f2a View commit details

Commits on Dec 3, 2023

  1. a possible fix on external problems

    Happy2018new committed Dec 3, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    746ac1f View commit details
  2. bump version to 1.1.3

    Happy2018new committed Dec 3, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    1d1d8f7 View commit details

Commits on Dec 5, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    7f7646a View commit details
  2. disable ping before login to avoid panic

    This may be a change by NetEase to circumvent the server attack software.
    
    Co-Authored-By: Liliya233 <[email protected]>
    Happy2018new and Liliya233 committed Dec 5, 2023

    Partially verified

    This commit is signed with the committer’s verified signature.
    Happy2018new’s contribution has been verified via GPG key.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    6176fd9 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    adf9ae1 View commit details
  4. bump version to 1.1.4

    Happy2018new committed Dec 5, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    c972472 View commit details

Commits on Dec 10, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    cdafb0c View commit details
  2. bump version to 1.1.5

    Happy2018new committed Dec 10, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    667a6ef View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    2a8be61 View commit details
  4. bump version to 1.1.6

    Happy2018new committed Dec 10, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    31456ff View commit details

Commits on Feb 6, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    3694bc0 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    0de17a4 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    e23927f View commit details
  4. Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    34ee5c2 View commit details
  5. bug fix on omega component named 记录坐标改动日志

    Happy2018new committed Feb 6, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    ad5c6f5 View commit details
  6. bump version to 1.1.7

    Happy2018new committed Feb 6, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    Happy2018new Eternal Crystal
    Copy the full SHA
    728dc77 View commit details
87 changes: 71 additions & 16 deletions fastbuilder/core/core.go
Original file line number Diff line number Diff line change
@@ -320,6 +320,7 @@ func EstablishConnectionAndInitEnv(env *environment.PBEnvironment) {
env.ClientOptions.RespondUserOverride = args.CustomGameName
env.FBAuthClient = fbauth.CreateClient(env.ClientOptions)
}
env.MCPCheckChallengeSolveDown = make(chan struct{}, 1)
pterm.Println(pterm.Yellow(fmt.Sprintf("%s: %s", I18n.T(I18n.ServerCodeTrans), env.LoginInfo.ServerCode)))

if args.ExternalListenAddress != "" {
@@ -461,28 +462,82 @@ func onPyRpc(p *packet.PyRpc, env *environment.PBEnvironment) {
}
}

func SolveMCPCheckChallenges(env *environment.PBEnvironment) {
readPkt := env.Connection.(*minecraft.Conn).ReadPacketAndBytes
channel := make(chan CachedPacket, 32767)
timer := time.NewTimer(time.Second * 30)
func WaitMCPCheckChallengesDown(
env *environment.PBEnvironment,
command_output chan packet.CommandOutput,
) {
ticker := time.NewTicker(time.Millisecond * 50)
defer ticker.Stop()
for {
pk, data, err := readPkt()
err := env.Connection.(*minecraft.Conn).WritePacket(&packet.CommandRequest{
CommandLine: "WaitMCPCheckChallengesDown",
CommandOrigin: protocol.CommandOrigin{
Origin: protocol.CommandOriginAutomationPlayer,
UUID: ResourcesControl.GenerateUUID(),
RequestID: "96045347-a6a3-4114-94c0-1bc4cc561694",
},
Internal: false,
UnLimited: false,
})
if err != nil {
panic(err)
panic(fmt.Sprintf("WaitMCPCheckChallengesDown: %v", err))
}
select {
case channel <- CachedPacket{pk, data}:
if pyRpcPkt, success := pk.(*packet.PyRpc); success {
onPyRpc(pyRpcPkt, env)
if env.GetCheckNumEverPassed {
env.CachedPacket = (<-chan CachedPacket)(channel)
return
}
if len(command_output) > 0 {
<-command_output
close(command_output)
break
}
<-ticker.C
}
}

func SolveMCPCheckChallenges(env *environment.PBEnvironment) {
challengeTimeout := false
challengeSolved := make(chan struct{}, 1)
cachedPkt := make(chan CachedPacket, 32767)
commandOutput := make(chan packet.CommandOutput, 1)
timer := time.NewTimer(time.Second * 30)
// prepare
go func() {
for {
if challengeTimeout {
return
}
// challenge timeout
pk, data, err := env.Connection.(*minecraft.Conn).ReadPacketAndBytes()
if err != nil {
panic(fmt.Sprintf("SolveMCPCheckChallenges: %v", err))
}
case <-timer.C:
panic(fmt.Sprintf("SolveMCPCheckChallenges: Failed to pass the MCPCheck challenges, please try again later"))
// read packet
cachedPkt <- CachedPacket{pk, data}
// cache the current packet
switch p := pk.(type) {
case *packet.PyRpc:
onPyRpc(p, env)
case *packet.CommandOutput:
commandOutput <- *p
return
}
if len(challengeSolved) == 0 && env.GetCheckNumEverPassed {
challengeSolved <- struct{}{}
}
// process the current packet
}
}()
// read packet and process
select {
case <-challengeSolved:
WaitMCPCheckChallengesDown(env, commandOutput)
env.MCPCheckChallengeSolveDown <- struct{}{}
close(challengeSolved)
close(cachedPkt)
env.CachedPacket = (<-chan CachedPacket)(cachedPkt)
return
case <-timer.C:
challengeTimeout = true
panic("SolveMCPCheckChallenges: Failed to pass the MCPC check challenges, please try again later")
}
// wait for the challenge to end
}

func getUserInputMD5() (string, error) {
138 changes: 138 additions & 0 deletions fastbuilder/database/bucket.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package DB

import (
"fmt"
Mapping "phoenixbuilder/fastbuilder/database/mapping"
"sync"
)

// 刷新存储桶中对已有键的统计结果
func (b *Bucket) RefreshMapping() {
b.mapping.Reset()
if b.b == nil {
return
}
b.b.ForEach(func(k, v []byte) error {
b.mapping.Put(k)
return nil
})
}

// 返回存储桶中已有的键的名称的集合。
// 它是 b.mapping 经过处理后的深拷贝形式,
// 因此其生命周期不存在截止日期,
// 即始终有效且与 b.mapping 独立
func (b *Bucket) GetMapping() (mapping [][]byte) {
mapping = make([][]byte, 0)
b.mapping.ForEach(func(key []byte) error {
mapping = append(mapping, key)
return nil
})
return
}

// 确定存储桶中是否存在名为 name 的键
func (b *Bucket) HasKey(key []byte) (has bool) {
return b.mapping.HasKey(key)
}

// 向名为 key 的键处放置数据 data
func (b *Bucket) PutData(key []byte, data []byte) error {
err := b.b.Put(key, data)
if err != nil {
return fmt.Errorf("PutData: %v", err)
}
b.mapping.Put(key)
return nil
}

// 删除名为 key 的键处所存放的数据
func (b *Bucket) DeleteData(key []byte) error {
err := b.b.Delete(key)
if err != nil {
return fmt.Errorf("DeleteData: %v", err)
}
b.mapping.Delete(key)
return nil
}

// 在当前存储桶中创建名为 name 的子存储桶
func (b *Bucket) CreateSubBucket(name []byte) error {
_, err := b.b.CreateBucket(name)
if err != nil {
return fmt.Errorf("CreateSubBucket: %v", err)
}
b.mapping.Put(name)
return nil
}

// 删除该存储桶中名为 name 的子存储桶
func (b *Bucket) DeleteSubBucket(name []byte) error {
err := b.b.DeleteBucket(name)
if err != nil {
return fmt.Errorf("CreateSubBucket: %v", err)
}
b.mapping.Delete(name)
return nil
}

// 从该存储桶取得名为 name 的子存储桶。
// 你可以同时打开若干个子存储桶,
// 它们互相独立,可以同时操作。
// 在子存储桶使用完毕后,
// 你必须将其释放,否则可能会造成阻塞
func (b *Bucket) GetSubBucketByName(name []byte) (result *Bucket) {
b.subBucket.Add(1)
sub_bucket_got := make(chan struct{}, 1)
sub_bucket_use_down := make(chan struct{}, 1)
// prepare
go func() {
result = &Bucket{
b: b.b.Bucket(name),
mapping: Mapping.GetNewMapping(),
terminate: make(chan struct{}, 1),
subBucket: &sync.WaitGroup{},
use_down: sub_bucket_use_down,
}
result.RefreshMapping()
sub_bucket_got <- struct{}{}
select {
case <-sub_bucket_use_down:
b.subBucket.Add(-1)
case <-b.terminate:
result.UseDown()
b.subBucket.Add(-1)
if len(b.terminate) == 0 {
b.terminate <- struct{}{}
}
}
}()
<-sub_bucket_got
close(sub_bucket_got)
// get bucket
return
// return
}

// 取得名为 key 的键处所放置的数据。
// 返回值仅在存储桶被释放前有效
func (b *Bucket) GetDataByKey(key []byte) (result []byte) {
return b.b.Get(key)
}

// 安全地释放存储桶及已打开的所有子存储桶
func (b *Bucket) UseDown() error {
if len(b.terminate) == 0 {
b.terminate <- struct{}{}
}
b.subBucket.Wait()
// 等待所有已打开的子存储桶被关闭
b.b = nil
b.mapping.Reset()
// 释放当前存储桶
b.use_down <- struct{}{}
close(b.use_down)
// 向上层实现发送已完成释放的信号
return nil
// 返回值
}
148 changes: 148 additions & 0 deletions fastbuilder/database/database.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package DB

import (
"fmt"
Mapping "phoenixbuilder/fastbuilder/database/mapping"
"sync"

"go.etcd.io/bbolt"
)

// 打开 path 处的数据库。
// 当数据库不存在时将创建一个这样的文件
func OpenOrCreateDatabase(path string) (
database *Database,
err error,
) {
db, err := bbolt.Open(
path,
0600,
&bbolt.Options{
Timeout: 0,
NoGrowSync: false,
FreelistType: bbolt.FreelistMapType,
},
)
if err != nil {
return nil, fmt.Errorf("OpenOrCreateDatabase: %v", err)
}
database = &Database{
db: db,
mapping: Mapping.GetNewMapping(),
terminate: make(chan struct{}, 1),
openedBucket: &sync.WaitGroup{},
}
// open database
database.RefreshMapping()
// list all keys
return
// return
}

// 刷新数据库中对已有存储桶的统计结果
func (d *Database) RefreshMapping() {
d.mapping.Reset()
d.db.View(func(tx *bbolt.Tx) error {
tx.ForEach(func(name []byte, b *bbolt.Bucket) error {
d.mapping.Put(name)
return nil
})
return nil
})
}

// 返回数据库中已有的存储桶的名称的集合。
// 它是 d.mapping 经过处理后的深拷贝形式,
// 因此其生命周期不存在截止日期,
// 即始终有效且与 d.mapping 独立
func (d *Database) GetMapping() (mapping [][]byte) {
mapping = make([][]byte, 0)
d.mapping.ForEach(func(key []byte) error {
mapping = append(mapping, key)
return nil
})
return
}

// 确定数据库中是否存在名为 name 的存储桶
func (d *Database) HasBucket(name []byte) (has bool) {
return d.mapping.HasKey(name)
}

// 创建名为 name 的存储桶
func (d *Database) CreateBucket(name []byte) error {
err := d.db.Update(func(tx *bbolt.Tx) error {
_, err := tx.CreateBucket(name)
return err
})
if err != nil {
return fmt.Errorf("CreateBucket: %v", err)
}
d.mapping.Put(name)
return nil
}

// 删除名为 name 的存储桶
func (d *Database) DeleteBucket(name []byte) error {
err := d.db.Update(func(tx *bbolt.Tx) error {
return tx.DeleteBucket(name)
})
if err != nil {
return fmt.Errorf("CreateBucket: %v", err)
}
d.mapping.Delete(name)
return nil
}

// 从数据库中取得名为 name 的存储桶。
// 此后,在进行任何数据库操作前须关闭存储桶,
// 否则任何新增的操作都将被阻塞,
// 直到被(强制)释放
func (d *Database) GetBucketByName(name []byte) (result *Bucket) {
d.openedBucket.Add(1)
bucket_got := make(chan struct{}, 1)
bucket_use_down := make(chan struct{}, 1)
// prepare
go d.db.Update(func(tx *bbolt.Tx) error {
result = &Bucket{
b: tx.Bucket(name),
mapping: Mapping.GetNewMapping(),
terminate: make(chan struct{}, 1),
subBucket: &sync.WaitGroup{},
use_down: bucket_use_down,
}
result.RefreshMapping()
bucket_got <- struct{}{}
select {
case <-bucket_use_down:
d.openedBucket.Add(-1)
case <-d.terminate:
result.UseDown()
d.openedBucket.Add(-1)
d.terminate <- struct{}{}
}
return nil
})
<-bucket_got
close(bucket_got)
// get bucket
return
// return
}

// 安全地关闭数据库
func (d *Database) CloseDatabase() error {
if len(d.terminate) == 0 {
d.terminate <- struct{}{}
}
d.openedBucket.Wait()
// 等待所有已打开的存储桶被关闭
d.mapping.Reset()
err := d.db.Close()
// 关闭数据库
if err != nil {
return fmt.Errorf("CloseDatabase: %v", err)
}
return nil
// 返回值
}
Loading