This repository was archived by the owner on Mar 6, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathmain.go
More file actions
151 lines (135 loc) · 3.97 KB
/
Copy pathmain.go
File metadata and controls
151 lines (135 loc) · 3.97 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package main
import (
"bufio"
"fmt"
"github.com/TheTitanrain/w32"
"github.com/kbinani/win"
"github.com/logrusorgru/aurora"
"github.com/mattn/go-colorable"
"github.com/restartfu/empty-client/command"
"github.com/restartfu/empty-client/empty"
"golang.org/x/sys/windows"
"log"
"os"
"os/signal"
"strconv"
"strings"
"syscall"
"time"
)
func init() {
log.SetOutput(colorable.NewColorableStdout())
}
var (
c = make(chan os.Signal)
)
func main() {
signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGTERM)
go scan(handler())
<-c
for _, c := range command.All() {
c.Close()
}
}
func scan(h *empty.Handler) {
for {
fmt.Print(aurora.Yellow("-> "))
if cmd := command.ByName(scanInput()); cmd != nil {
if len(cmd.Runnables()) > 1 {
var formattedRunnables []string
for n, c := range cmd.Runnables() {
formattedRunnables = append(formattedRunnables, fmt.Sprintf("[%v] %s - %s", n+1, c.Name(), c.Description()))
}
fmt.Println(strings.Join(formattedRunnables, "\n") + "\n")
}
r := scanRunnable(cmd)
if !r.HasInput() {
_ = r.Run(h)
continue
}
fmt.Print(aurora.Yellow(fmt.Sprintf("%s -> ", strings.ToUpper(r.Name()))))
err := r.Run(h, strings.Split(scanInput(), " ")...)
for err != nil {
fmt.Println(aurora.Red(fmt.Sprintf("%s", err.Error())))
fmt.Print(aurora.Yellow(fmt.Sprintf("%s -> ", strings.ToUpper(r.Name()))))
err = r.Run(h, strings.Split(scanInput(), " ")...)
}
continue
}
fmt.Println(aurora.Red("Unknown command, try help"))
}
}
func scanIndex(cmd *command.Command) int {
scan := func() (int, error) {
fmt.Print(aurora.Yellow(fmt.Sprintf("%s -> ", strings.ToUpper(cmd.Name()))))
input := scanInput()
return strconv.Atoi(input)
}
index, err := scan()
for err != nil {
fmt.Println(aurora.Red("Invalid prompt"))
index, err = scan()
}
return index
}
func scanRunnable(cmd *command.Command) command.Runnable {
if len(cmd.Runnables()) == 1 {
return cmd.Runnables()[0]
}
scan := func() (command.Runnable, error) {
r, err := cmd.Runnable(scanIndex(cmd) - 1)
return r, err
}
r, err := scan()
for err != nil {
fmt.Println(aurora.Yellow(fmt.Sprintf("[ERROR] %s", err.Error())))
r, err = scan()
}
return r
}
func scanInput() string {
s := bufio.NewScanner(os.Stdin)
s.Scan()
for strings.TrimSpace(s.Text()) == "" {
s.Scan()
}
return strings.Split(strings.TrimSpace(s.Text()), " ")[0]
}
func handler() *empty.Handler {
open := func() bool {
return w32.FindWindowW(nil, windows.StringToUTF16Ptr("Minecraft")) != 0
}
for !open() {
fmt.Println(aurora.Yellow("Game window not found. Please open minecraft\n"))
for !open() {
time.Sleep(time.Second)
}
time.Sleep(time.Second * 5)
}
h := empty.New()
welcome(h)
return h
}
func registerCommands(h *empty.Handler) {
for _, c := range []*command.Command{
command.New(h, "help", "See the list of available commands and cheats.", command.Help{}),
command.New(h, "reach", "Hurt entities from a distance.", command.Reach{}),
command.New(h, "timer", "Increase the speed of your games.", command.Timer{}),
} {
command.Register(c)
}
}
func welcome(h *empty.Handler) {
win.SetConsoleTitle("Empty - By RestartFU <3")
win.SetConsoleIcon(win.HICON(h.Handle()))
registerCommands(h)
fmt.Println(aurora.Yellow(`Empty v0.2
███████╗███╗ ███╗██████╗ ████████╗██╗ ██╗
██╔════╝████╗ ████║██╔══██╗╚══██╔══╝╚██╗ ██╔╝
█████╗ ██╔████╔██║██████╔╝ ██║ ╚████╔╝
██╔══╝ ██║╚██╔╝██║██╔═══╝ ██║ ╚██╔╝
███████╗██║ ╚═╝ ██║██║ ██║ ██║
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
Type 'help' to see the list of available commands and cheats.
`))
}