wlwanpan / minecraft-wrapper Goto Github PK
View Code? Open in Web Editor NEWA Go package for your Minecraft Server
License: MIT License
A Go package for your Minecraft Server
License: MIT License
Dear author, I see that you have not updated in the last 2 years. Could you give me the library of snbt for maintenance? I am a novice, and I will try to adapt to the parsing of the lower version of snbt format
Currently, commands are being defined with functions that typically end up calling processCmdToEvent(Arr). As the functions are private methods, there are no options for commands to be defined for mods and datapacks in other packages while still using this package. A fork would be required.
Consider instead of defining a function for each command, define a struct fro each command that satisfies a Command interface which is passes to a Command function, which handles stringing the command to pass to the console, and reading/handling the events associated with that command. For example:
type Command interface {
Command() string
Events() []events.Event
}
type ExperienceAdd struct {
Target string
XP int32
XPType ExperienceType
}
func (c ExperienceAdd) Command() string {
return fmt.Sprintf(experience add %s &d %s, c.target, c.xp, c.xpType)
}
func (c ExperienceAdd) Events() []events.Event {
return []events.Event{
events.ExperienceAdd,
events.NoPlayerFound.
}
}
func (w *Wrapper) ExecuteCommand(c Command) error {
ev, err := w.processCmdToEvent(c.Command(), time.Second, c.Events()...)
if err != nil {
return err
}
if ev.Is(events.NoPlayerFoundEvent) {
return ErrPlayerNotFound
}
return nil
}
Please note this is not a real implementation, I just adapted the ExperienceAdd function to what it could look like in this Command interface format.
If this is an idea you are open to, I would be happy to work with you on a full implementation before switching from the current function approach.
Rn we need to look at the implementation logparser.go
to figure out what Data
each event holds. Might be worth having concrete event struct per events:
type PlayerJoinedEvent struct {
Name string
Time time.Time
...
}
type PlayerSayEvent struct {
Name string
Message string
...
}
then on the receiver side:
ev := <-wpr.GameEvents()
if ev.Type == events.PlayerSayEvent {
playerSayEv := ev.(events.PlayerSayEvent)
}
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.