Giter VIP home page Giter VIP logo

pyron-server's Introduction

Xeros

Based on Ascend.

Setup

  • Enable annotation processing for Lombok.
  • Create a config.yaml in the working directory with the server state: server_state: DEBUG. Debug will give you the developer rank on login and fill your bank with various items. It will also give you printouts by default.

Commands

  • ::debug to toggle debug messages.
  • ::combatstats to toggle combat statistic messages.

SQL Queries

SqlQuery is the class you use to execute all sql statements and queries.

// Anonymous class
new SqlQuery<Object>() {
    @Override
    public Object execute(DatabaseManager context, Connection connection) throws SQLException {
        // do queries on connection here
        return null;
    }
}

// Functional interface
(context, connection) -> {
    return null;
});

To actually execute the query you created you call the Server's DatabaseManager: Server.getDatabaseManager().execute(DatabaseCredentials, SqlQuery). The database credentials are usually stored in the config.yaml (ServerConfiguration): Server.getConfiguration().getLocalDatabase(). To use the embedded database (which doesn't require a local sql server, it runs in memory) you can call: Server.getEmbeddedDatabase().

Say you wanted to execute a query and use the returned data on a player in some fashion, you would do this:

// As of July 10th 2021 you can use execute alone to access the local 
// (non-embedded) sql database which is configured in config.yaml as 
// a DatabaseConfiguration named local_database
Server.getDatabaseManager().execute((context, connection) -> {
    // Notice here we call another sql query, this will share the connection
    List<String> myStrings = new SqlQueryImplementation().execute(context, connection);

    // We have to queue this because we aren't on the main thread and the player
    // will throw an exception for packets sent from outside that thread.
    // Note: this will sometimes require a locking mechanism to prevent the player from moving or leaving
    // that isn't always neccesary though.
    player.addQueuedAction(plr -> {
        myStrings.forEach(it -> plr.sendMessage(it));
    });
}));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.