angushtlam / embarker Goto Github PK
View Code? Open in Web Editor NEWoh look angus is trying to make another minecraft server
Home Page: https://embarker.raeic.com/
oh look angus is trying to make another minecraft server
Home Page: https://embarker.raeic.com/
To set up Embarker on a new world, the op places a block when represents town center. That whole chunk becomes claimed under no one's name, so only ops can modify it. Perhaps level it off with cobblestone or some structure so it's nicely accessible.
Players can interact with the town center block to see their current number of staked chunks, the price of the next chunk, and to trade emeralds for a chunk token. While holding this token, the chunk borders are highlighted. When they use the token, they claim that chunk.
Due to differences per-player in chunk prices, chunk tokens are bound to a player. If the owning player drops it, the token gets destroyed and they get their emeralds back (or it turns into that many emeralds on the ground).
Right now, the caching code is hard to follow and buggy. There's also some strange irregularities in the model classes (eg. what's the difference between creating a StakedChunk vs. finding one, setting the owner, then saving?) The encapsulation is such that the user of the model still needs to understand details of the model in DB, such as when to create a model, find then update a model, or delete a model--rather than only focusing on the state they are trying to persist.
I propose the following pattern, which will make working with models easier to reason about and hopefully we can eliminate some bugs/toil.
The model class has:
get
, detailed below)save()
which performs any updates to the model (such as setting the last updated timestamp) then calls the manager's save(model)
clear()
which takes place of delete. To delete a model, clear then save it....and a nested Manager
class (nested so it has access to the private constructor) which extends CachedModel
, and has:
get(key...)
which retrieves from cache, else from DB, else constructs a model with that keyprivate save(model)
which is called by the model's save
and includes the actual SQL to persist to cache and DBThen in Globals
we keep an instance of each model's manager class.
For example, the model class for StakedChunk would have:
public class StakedChunk {
private StakedChunk(int coordX, int coordZ, String worldName, String ownerUniqueId, Timestamp firstStaked, Timestamp lastUpdated, Manager manager) { ... }
public static class Manager extends CachedModel<StakedChunk> {
public StakedChunk get(int coordX, int coordZ, String worldName) {...}
private void save(StakedChunk stakedChunk) {...}
}
public void save() {...}
public void clear() {...}
// getters and setters for ownerUniqueId, firstStaked, lastUpdated
}
Chest inventory should only be accessible to chunk owner/party
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.