-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
3,967 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ var Commands = &commands.Graph{ | |
reload_cmd, | ||
gamemode_cmd, | ||
restart_cmd, | ||
ram_cmd, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package core_commands | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
|
||
"github.com/dynamitemc/dynamite/server/commands" | ||
) | ||
|
||
var ram_cmd = &commands.Command{ | ||
Name: "ram", | ||
Aliases: []string{"mem"}, | ||
Execute: func(ctx commands.CommandContext) { | ||
var m runtime.MemStats | ||
runtime.ReadMemStats(&m) | ||
ctx.Reply(fmt.Sprintf("Allocated: %v MiB, Total Allocated: %v MiB, Heap in Use: %v MiB", bToMb(m.Alloc), bToMb(m.TotalAlloc), bToMb(m.HeapInuse))) | ||
}, | ||
} | ||
|
||
func bToMb(b uint64) uint64 { | ||
return b / 1024 / 1024 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package item | ||
|
||
import ( | ||
_ "embed" | ||
"encoding/json" | ||
) | ||
|
||
//go:embed items.json | ||
var it []byte | ||
|
||
type Item struct { | ||
ProtocolID int32 `json:"protocol_id"` | ||
} | ||
|
||
var items map[string]Item | ||
|
||
func loadItems() { | ||
var itemData struct { | ||
Item struct { | ||
Default string `json:"default"` | ||
Entries map[string]Item `json:"entries"` | ||
ProtocolID int32 `json:"protocol_id"` | ||
} `json:"minecraft:item"` | ||
} | ||
json.Unmarshal(it, &itemData) | ||
items = itemData.Item.Entries | ||
} | ||
|
||
func GetItem(name string) (item Item, ok bool) { | ||
if items == nil { | ||
loadItems() | ||
} | ||
it, ok := items[name] | ||
return it, ok | ||
} |
Oops, something went wrong.