format repo with "gofumpt" tool
This commit is contained in:
@ -17,7 +17,7 @@ import (
|
||||
const (
|
||||
version = "1.17"
|
||||
infoURL = "https://raw.githubusercontent.com/PrismarineJS/minecraft-data/master/data/pc/" + version + "/entities.json"
|
||||
//language=gohtml
|
||||
// language=gohtml
|
||||
entityTmpl = `// Code generated by gen_entity.go DO NOT EDIT.
|
||||
// Package entity stores information about entities in Minecraft.
|
||||
package entity
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
const (
|
||||
version = "1.17"
|
||||
infoURL = "https://raw.githubusercontent.com/PrismarineJS/minecraft-data/master/data/pc/" + version + "/items.json"
|
||||
//language=gohtml
|
||||
// language=gohtml
|
||||
itemTmpl = `// Code generated by gen_item.go DO NOT EDIT.
|
||||
// Package item stores information about items in Minecraft.
|
||||
package item
|
||||
|
@ -1,4 +1,5 @@
|
||||
//+build generate
|
||||
//go:build generate
|
||||
// +build generate
|
||||
|
||||
// This program can automatically download language.json file and convert into .go
|
||||
package main
|
||||
@ -17,9 +18,8 @@ import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var (
|
||||
//language=gohtml
|
||||
langTmpl = `// Code generated by downloader.go; DO NOT EDIT.
|
||||
// language=gohtml
|
||||
var langTmpl = `// Code generated by downloader.go; DO NOT EDIT.
|
||||
package {{.Name}}
|
||||
{{if ne .Name "en_us"}}
|
||||
import "github.com/Tnze/go-mc/chat"
|
||||
@ -28,7 +28,6 @@ func init() { chat.SetLanguage(Map) }
|
||||
{{end}}
|
||||
var Map = {{.LangMap | printf "%#v"}}
|
||||
`
|
||||
)
|
||||
|
||||
//go:generate go run $GOFILE
|
||||
//go:generate go fmt ./...
|
||||
@ -90,7 +89,7 @@ func main() {
|
||||
}
|
||||
|
||||
func lang(name, hash string) {
|
||||
//download language
|
||||
// download language
|
||||
LangURL := "http://resources.download.minecraft.net/" + hash[:2] + "/" + hash
|
||||
resp, err := http.Get(LangURL)
|
||||
if err != nil {
|
||||
@ -112,12 +111,12 @@ func readLang(name string, r io.Reader) {
|
||||
pName := strings.ReplaceAll(name, "_", "-")
|
||||
|
||||
// mkdir
|
||||
err = os.Mkdir(pName, 0777)
|
||||
err = os.Mkdir(pName, 0o777)
|
||||
if err != nil && !os.IsExist(err) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
f, err := os.OpenFile(filepath.Join(pName, name+".go"), os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0666)
|
||||
f, err := os.OpenFile(filepath.Join(pName, name+".go"), os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o666)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -143,7 +142,7 @@ var javaN = regexp.MustCompile(`%[0-9]\$s`)
|
||||
|
||||
// Java use %2$s to refer to the second arg, but Golang use %2s, so we need this
|
||||
func trans(m map[string]string) {
|
||||
//replace "%[0-9]\$s" with "%[0-9]s"
|
||||
// replace "%[0-9]\$s" with "%[0-9]s"
|
||||
for i := range m {
|
||||
c := m[i]
|
||||
if javaN.MatchString(c) {
|
||||
@ -169,8 +168,8 @@ func assetIndexURL() (string, error) {
|
||||
Latest struct {
|
||||
Release string `json:"release"`
|
||||
} `json:"latest"`
|
||||
Versions []struct{
|
||||
ID string `json:"id"`
|
||||
Versions []struct {
|
||||
ID string `json:"id"`
|
||||
URL string `json:"url"`
|
||||
} `json:"versions"`
|
||||
}
|
||||
@ -196,8 +195,8 @@ func assetIndexURL() (string, error) {
|
||||
return "", errors.New("could not determine versionURL")
|
||||
}
|
||||
|
||||
var version struct{
|
||||
AssetIndex struct{
|
||||
var version struct {
|
||||
AssetIndex struct {
|
||||
URL string `json:"url"`
|
||||
} `json:"assetIndex"`
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ package packetid
|
||||
|
||||
//go:generate stringer -type ClientboundPacketID
|
||||
//go:generate stringer -type ServerboundPacketID
|
||||
|
||||
type ClientboundPacketID int32
|
||||
type ServerboundPacketID int32
|
||||
type (
|
||||
ClientboundPacketID int32
|
||||
ServerboundPacketID int32
|
||||
)
|
||||
|
||||
// Login Clientbound
|
||||
const (
|
||||
|
@ -71,7 +71,7 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = os.WriteFile("blockentitytype/blockentitytype.go", formattedSource, 0666)
|
||||
err = os.WriteFile("blockentitytype/blockentitytype.go", formattedSource, 0o666)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
const (
|
||||
version = "1.17.1"
|
||||
protocolURL = "https://pokechu22.github.io/Burger/" + version + ".json"
|
||||
//language=gohtml
|
||||
// language=gohtml
|
||||
soundTmpl = `// Code generated by gen_soundid.go. DO NOT EDIT.
|
||||
|
||||
package soundid
|
||||
|
Reference in New Issue
Block a user