My give command shows up the item's display name based on the language the player is using. Right when I output the success of the command, the server crashes.
func (t Give) Run(source cmd.Source, output *cmd.Output) {
targets := t.Player
itemName := t.ItemName
data, dataUsed := t.Data.Load()
if !dataUsed {
data = 0
}
name := string(itemName)
if !strings.Contains(name, ":") {
name = "minecraft:" + name
}
itemType, isItem := world.ItemByName(name, data)
if !isItem || name == "air" {
output.Errorf("Unknown item identifier provided %s", name)
return
}
amount16, amountUsed := t.Amount.Load()
amount := 0
if !amountUsed {
amount = 1
} else {
amount = int(math.Max(1, float64(amount16)))
}
langTag := language.English
if p, ok := source.(*player.Player); ok {
langTag = p.Locale()
}
var players = make([]*player.Player, 0)
for _, target := range targets {
plr, ok := target.(*player.Player)
if !ok || plr == nil {
continue
}
players = append(players, plr)
}
for _, p := range players {
if p == nil {
continue
}
given := giveItem(p, itemType, data, amount)
output.Printf("Gave %s x%d to %s", item.DisplayName(itemType, langTag), given, p.Name())
}
}
My give command shows up the item's display name based on the language the player is using. Right when I output the success of the command, the server crashes.