From 12099a28475afb9e903ddb13a888ba665a4a50c7 Mon Sep 17 00:00:00 2001 From: Joseph Manley Date: Fri, 25 Dec 2020 21:22:45 -0500 Subject: [PATCH] Initial types and interfaces --- README.md | 2 +- datastore/skinstore.go | 9 +++++++++ datastore/userstore.go | 9 +++++++++ datatypes/character.go | 7 +++++++ datatypes/skin.go | 11 +++++++++++ datatypes/user.go | 7 +++++++ go.mod | 3 +++ 7 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 datastore/skinstore.go create mode 100644 datastore/userstore.go create mode 100644 datatypes/character.go create mode 100644 datatypes/skin.go create mode 100644 datatypes/user.go create mode 100644 go.mod diff --git a/README.md b/README.md index d891581..1eb587e 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# OpenSkins-PluginInterface \ No newline at end of file +# OpenSkins-Common \ No newline at end of file diff --git a/datastore/skinstore.go b/datastore/skinstore.go new file mode 100644 index 0000000..316d8d1 --- /dev/null +++ b/datastore/skinstore.go @@ -0,0 +1,9 @@ +package datastore + +import "github.com/josephbmanley/OpenSkins-Common/datatypes" + +type Skinstore interface { + Initialize() error + GetSkin(string) (datatypes.Skin, error) + AddSkin(string, []byte) error +} diff --git a/datastore/userstore.go b/datastore/userstore.go new file mode 100644 index 0000000..51e3ceb --- /dev/null +++ b/datastore/userstore.go @@ -0,0 +1,9 @@ +package datastore + +import "github.com/josephbmanley/OpenSkins-Common/datatypes" + +type Userstore interface { + Initialize() error + GetUser(uid string) (datatypes.User, error) + SetUser(datatypes.User) error +} diff --git a/datatypes/character.go b/datatypes/character.go new file mode 100644 index 0000000..d8d6481 --- /dev/null +++ b/datatypes/character.go @@ -0,0 +1,7 @@ +package datatypes + +// Character represents something that can be skinned +type Character struct { + Name string `json:"name"` + Skin Skin `json:"skin"` +} diff --git a/datatypes/skin.go b/datatypes/skin.go new file mode 100644 index 0000000..7ff65d9 --- /dev/null +++ b/datatypes/skin.go @@ -0,0 +1,11 @@ +package datatypes + +// Skin struct holds the +type Skin struct { + Name string `json:"name"` + Location string `json:"location"` + Metadata map[string]string `json:"metadata"` +} + +// Skins are an array of Skin +type Skins []Skin diff --git a/datatypes/user.go b/datatypes/user.go new file mode 100644 index 0000000..51eb889 --- /dev/null +++ b/datatypes/user.go @@ -0,0 +1,7 @@ +package datatypes + +// User is an object representing a user +type User struct { + UID string `json:"uid"` + OwnedSkins Skins `json:"skins"` +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..73f8a56 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/josephbmanley/OpenSkins-Common + +go 1.13