Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
oq-x committed Nov 2, 2023
1 parent 8e5146d commit f017b38
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 48 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/dynamitemc/dynamite

go 1.21.0

toolchain go1.21.1
toolchain go1.21.3

require (
github.com/fatih/color v1.15.0
Expand Down
26 changes: 0 additions & 26 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
github.com/aimjel/minecraft v0.0.0-20231028170116-bbc6313c6f03 h1:3jnZcNJMpIeByMpEF1tNiOVlEc5P/2tBhGLRxDG79kg=
github.com/aimjel/minecraft v0.0.0-20231028170116-bbc6313c6f03/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231030201831-917b999163ca h1:dtWBwSsz0nTOiFdKfvNeaXNI3tXl+wlXQMGYuUuYG0Q=
github.com/aimjel/minecraft v0.0.0-20231030201831-917b999163ca/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231030202041-875be095db7a h1:hJDw0XnPKyAn1m/I/8zRp9KEy2Yntc/bhXypsFvVQmI=
github.com/aimjel/minecraft v0.0.0-20231030202041-875be095db7a/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231030202301-d7d7ac8ebf69 h1:mEe4c303TylYkj5fhiJOQG/daw/dn1Khu0oAfzpAT/4=
github.com/aimjel/minecraft v0.0.0-20231030202301-d7d7ac8ebf69/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231031091621-62b6a935f089 h1:RA2SbVYSZI57wAR8FKsooz7fx3ltd0gnU0SPHJxdS0E=
github.com/aimjel/minecraft v0.0.0-20231031091621-62b6a935f089/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231031091705-dcb93e675faa h1:FwoDn9E7rNC8bB1CA8XQtvviFI4gscj3dJb7JdWLlrs=
github.com/aimjel/minecraft v0.0.0-20231031091705-dcb93e675faa/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231031091752-b9236c2f7e52 h1:USkbso5+pjukxp3eWkctJreOj0R2Rsi5jHn0YZluS8U=
github.com/aimjel/minecraft v0.0.0-20231031091752-b9236c2f7e52/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231031230053-9525ec4eb44a h1:XZEJ/JaHMWryNzMA2VQiHGfFgcz1i72kuehLx37g5q0=
github.com/aimjel/minecraft v0.0.0-20231031230053-9525ec4eb44a/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231031231932-9e39f32c137a h1:4vkjJWBaAaax/szXkEfrxaoqv1jLUzsOm5QxBNOtxck=
github.com/aimjel/minecraft v0.0.0-20231031231932-9e39f32c137a/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231031232045-6750cf6b8e76 h1:YpFDbUyKKXNblBF2qAFdKzjrQ96QP/c+1D7B5Ack1Qw=
github.com/aimjel/minecraft v0.0.0-20231031232045-6750cf6b8e76/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231031232739-f5ae0ea098bf h1:GyFajIECds2FC0afodLh1QbntwTouoSEJeT8yc9S+lU=
github.com/aimjel/minecraft v0.0.0-20231031232739-f5ae0ea098bf/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231101152058-f0b9e194f4c8 h1:LCGleodAB81H6IekIae/31uqU/oH4tISub/Fx0RvTE8=
github.com/aimjel/minecraft v0.0.0-20231101152058-f0b9e194f4c8/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/aimjel/minecraft v0.0.0-20231102074502-922c6e0af42d h1:12teyvLFC7LHPDB3hJ717kH2rA8avI/azuC3LJrXwCg=
github.com/aimjel/minecraft v0.0.0-20231102074502-922c6e0af42d/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -51,8 +27,6 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
Expand Down
41 changes: 32 additions & 9 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Logger struct {
c chan Message
messages []Message
file *os.File
done bool
}

func getDateString() string {
Expand Down Expand Up @@ -98,7 +99,9 @@ func (logger *Logger) Print(msg chat.Message) {
Message: msg.String(),
})
fmt.Println("\r" + ParseChat(msg))
fmt.Print("\r> ")
if !logger.done {
fmt.Print("\r> ")
}
}

func (logger *Logger) Info(format string, a ...interface{}) {
Expand All @@ -110,8 +113,12 @@ func (logger *Logger) Info(format string, a ...interface{}) {
Time: time,
Message: str,
})
fmt.Printf("\r%s %s: %s\n", GB(time), BB("INFO "), str)
fmt.Print("\r> ")
if !logger.done {
fmt.Printf("\r%s %s: %s\n", GB(time), BB("INFO "), str)
fmt.Print("\r> ")
} else {
fmt.Printf("\r%s %s: %s", GB(time), BB("INFO "), str)
}
}

func (logger *Logger) Debug(format string, a ...interface{}) {
Expand All @@ -126,8 +133,12 @@ func (logger *Logger) Debug(format string, a ...interface{}) {
Time: time,
Message: str,
})
fmt.Printf("\r%s %s: %s\n", GB(time), CB("DEBUG"), str)
fmt.Print("\r> ")
if !logger.done {
fmt.Printf("\r%s %s: %s\n", GB(time), CB("INFO "), str)
fmt.Print("\r> ")
} else {
fmt.Printf("\r%s %s: %s", GB(time), CB("INFO "), str)
}
}

func (logger *Logger) Error(format string, a ...interface{}) {
Expand All @@ -139,8 +150,12 @@ func (logger *Logger) Error(format string, a ...interface{}) {
Time: time,
Message: str,
})
fmt.Fprintf(os.Stderr, "\r%s %s: %s\n", GB(time), RB("ERROR"), str)
fmt.Print("\r> ")
if !logger.done {
fmt.Fprintf(os.Stderr, "\r%s %s: %s\n", GB(time), RB("ERROR"), str)
fmt.Print("\r> ")
} else {
fmt.Fprintf(os.Stderr, "\r%s %s: %s", GB(time), RB("ERROR"), str)
}
}

func (logger *Logger) Warn(format string, a ...interface{}) {
Expand All @@ -152,8 +167,12 @@ func (logger *Logger) Warn(format string, a ...interface{}) {
Time: time,
Message: str,
})
fmt.Printf("%s %s: %s\n", GB(time), YB("WARN "), str)
fmt.Print("\r> ")
if !logger.done {
fmt.Printf("\r%s %s: %s\n", GB(time), YB("INFO "), str)
fmt.Print("\r> ")
} else {
fmt.Printf("\r%s %s: %s", GB(time), YB("INFO "), str)
}
}

func (logger *Logger) EnableChannel() {
Expand All @@ -173,6 +192,10 @@ func (logger *Logger) send(message Message) {
}
}

func (logger *Logger) Done() {
logger.done = true
}

func (logger *Logger) write(str string) {
logger.mu.Lock()
defer logger.mu.Unlock()
Expand Down
11 changes: 0 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ func start(cfg *server.Config) {
os.Exit(1)
}
log.Info("Done! (%v)", time.Since(startTime))
//c := make(chan os.Signal, 1)
//signal.Notify(c, os.Interrupt)

/*go func() {
<-c
if util.HasArg("-prof") {
stopProfile()
}
fmt.Print("\r> ")
srv.ConsoleCommand("stop")
}()*/

go scanConsole(srv)
err = srv.Start()
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,12 @@ func (srv *Server) Close() {
p.Disconnect(srv.Translate("disconnect.server_shutdown", nil))
p.Player.Save()
}
srv.Logger.Done()
srv.Logger.Info("Saving world...")
srv.World.Save()

f, _ := os.OpenFile("config.toml", os.O_RDWR|os.O_CREATE, 0666)
_ = toml.NewEncoder(f).Encode(srv.Config)
fmt.Print("\r")
os.Exit(0)
}

Expand Down

0 comments on commit f017b38

Please sign in to comment.