commit
a3f25f214c
|
@ -0,0 +1,2 @@
|
||||||
|
/target
|
||||||
|
.idea
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Geoffrey Architecture
|
||||||
|
|
||||||
|
**Note: Geoffrey V3 is in early development, and its design is likely to change.**
|
||||||
|
|
||||||
|
![Geoffry Architecture](figures/arch.svg)
|
||||||
|
|
||||||
|
## Database
|
||||||
|
The database is the core storage of Geoffrey. All models will be stored here. It is tightly
|
||||||
|
coupled with the GeoffreyAPI.
|
||||||
|
|
||||||
|
## Geoffrey API
|
||||||
|
The API provides the main logic to how models are manipulated in the Database. It is split
|
||||||
|
into two parts, the Command API and Model API.
|
||||||
|
|
||||||
|
### Command API
|
||||||
|
This API will expose a set of commands that can be run to preform tasks in Geoffrey. The goal
|
||||||
|
is to keep all the command logic here so the command front-end are simpler to create.
|
||||||
|
|
||||||
|
### Model API
|
||||||
|
The Model API will provide a strict access to the underlying models of Geoffrey. It is
|
||||||
|
more suited for web interfaces or operations that do not need to be constrained by commands.
|
||||||
|
|
||||||
|
## Front Ends
|
||||||
|
The currently planned front ends are a Bukkit Plugin, a Discord Bot and the Web Interface.
|
|
@ -0,0 +1,172 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chrono"
|
||||||
|
version = "0.4.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
"serde",
|
||||||
|
"time",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "geoffrey_models"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "0.4.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.88"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-integer"
|
||||||
|
version = "0.1.44"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.123"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.123"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.64"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.61"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ed22b90a0e734a23a7610f4283ac9e5acfb96cbb30dfefa540d66f866f1c09c5"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time"
|
||||||
|
version = "0.1.44"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"wasi",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.10.0+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|
@ -0,0 +1,4 @@
|
||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
"geoffrey_models"
|
||||||
|
]
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021 Joey Hines
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Geoffrey: A Location Database for Minecraft Servers
|
||||||
|
|
||||||
|
Geoffrey was created to be an information source for base and shop locations on Minecraft severs. Geoffrey can track
|
||||||
|
bases, shops, items for sale, tunnels, towns, public farms and more!
|
||||||
|
|
||||||
|
This is the third ~~complete rewrite~~ version of Geoffrey. V3 focuses on improving the API,
|
||||||
|
adding new features, and moving to Rust.
|
||||||
|
|
||||||
|
This version is still very early in development and things are very likely to change.
|
||||||
|
|
||||||
|
## Project Layout
|
||||||
|
* [`geoffrey_models`](./geoffrey_models): Models used throughout Geoffrey, split into their
|
||||||
|
own library for reuse.
|
||||||
|
|
||||||
|
## License
|
||||||
|
[License](LICENSE)
|
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 10 KiB |
|
@ -0,0 +1,12 @@
|
||||||
|
[package]
|
||||||
|
name = "geoffrey_models"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Joey Hines <joey@ahines.net>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = "1.0"
|
||||||
|
chrono = { version = "0.4.19", features = ["serde"] }
|
|
@ -0,0 +1,3 @@
|
||||||
|
#[allow(dead_code)]
|
||||||
|
|
||||||
|
pub mod models;
|
|
@ -0,0 +1,7 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct Item {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use crate::models::player::Player;
|
||||||
|
use crate::models::shop::ShopData;
|
||||||
|
|
||||||
|
pub mod player;
|
||||||
|
pub mod shop;
|
||||||
|
pub mod item;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub enum LocationData {
|
||||||
|
Base,
|
||||||
|
Shop(ShopData),
|
||||||
|
Town,
|
||||||
|
Market,
|
||||||
|
Attraction,
|
||||||
|
PublicFarm,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Copy, Clone)]
|
||||||
|
pub enum Dimension {
|
||||||
|
Overworld,
|
||||||
|
Nether,
|
||||||
|
TheEnd
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Dimension {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Overworld
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Copy, Clone)]
|
||||||
|
pub enum Direction {
|
||||||
|
North,
|
||||||
|
East,
|
||||||
|
South,
|
||||||
|
West,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Debug, Copy, Clone)]
|
||||||
|
pub struct Position {
|
||||||
|
pub x: i64,
|
||||||
|
pub y: i64,
|
||||||
|
dimension: Dimension,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct Tunnel {
|
||||||
|
direction: Direction,
|
||||||
|
number: i64
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct Location {
|
||||||
|
id: u64,
|
||||||
|
name: String,
|
||||||
|
position: Position,
|
||||||
|
owners: Vec<Player>,
|
||||||
|
tunnel: Option<Tunnel>,
|
||||||
|
loc_data: LocationData,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
impl Location {
|
||||||
|
fn new (id: u64, name: &str, position: Position, owners: Vec<Player>, tunnel: Option<Tunnel>, loc_data: LocationData) -> Self {
|
||||||
|
Location {
|
||||||
|
id,
|
||||||
|
name: name.to_string(),
|
||||||
|
position,
|
||||||
|
owners,
|
||||||
|
tunnel,
|
||||||
|
loc_data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::models::{Location, Position, Dimension, LocationData};
|
||||||
|
use crate::models::player::{Player, UserID};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_new_base() {
|
||||||
|
let player = Player {name: "CoolZero123".to_string(), user_ids: vec![UserID::DiscordUUID(0)]};
|
||||||
|
Location::new(0, "test", Position {x: 0, y: 0, dimension: Dimension::Overworld}, vec![player], None, LocationData::Base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub enum UserID {
|
||||||
|
DiscordUUID(u64),
|
||||||
|
MinecraftUUID(String),
|
||||||
|
GeoffreyID(u64)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct Player {
|
||||||
|
pub name: String,
|
||||||
|
pub user_ids: Vec<UserID>
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
|
use crate::models::item::Item;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct ItemListing {
|
||||||
|
pub item: Item,
|
||||||
|
pub price: u64,
|
||||||
|
pub count_per_price: u64,
|
||||||
|
pub restocked_time: DateTime<Utc>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ItemListing {
|
||||||
|
fn new(item: &str, price: u64, count_per_price: u64, restocked_time: DateTime<Utc>) -> Self {
|
||||||
|
Self {
|
||||||
|
item: Item {name: item.to_string()},
|
||||||
|
price,
|
||||||
|
count_per_price,
|
||||||
|
restocked_time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct ShopData {
|
||||||
|
pub item_listings: Vec<ItemListing>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ShopData {
|
||||||
|
fn add_item(&mut self, item_listing: ItemListing) {
|
||||||
|
self.item_listings.push(item_listing);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn filter_items<F>(&self, filter: F) -> Vec<ItemListing> where F: FnMut(&&ItemListing) -> bool {
|
||||||
|
self.item_listings.iter().filter(filter).cloned().collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remove_item(&mut self, item_name: &str) {
|
||||||
|
self.item_listings.retain(|listing| &listing.item.name != item_name)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue