Code Monkey home page Code Monkey logo

openmod.economy's Introduction

OpenMod Discord

OpenMod is a plugin framework for .NET.

It supports authorization, plugin configurations, internalization, command handling and much more. OpenMod can be used for games, bot frameworks, web servers or anything else and has official implementations for Unturned, Rust (WIP) and a standalone console.

For a list of available plugins, visit openmod-plugins.

Features

OpenMod is based on modern C# code and best practices.

  • Modern API for plugin development with C# and Unity best practices
  • Plugin installation with NuGet
  • Can self update with NuGet
  • Based on .NET Generic Host
  • IoC and Dependency Injection using Autofac
  • Configure OpenMod and plugins with yaml configurations, environment variables, commandline arguments, etc.
  • Serilog for logging, including rich configuration options via logging.yml

Getting Started

To get started, visit the OpenMod Documentation.

If you would like to install OpenMod, installation guides for the following platforms are available:

If you want to make plugins for OpenMod, you can get started by reading the Making your first plugin page.

Supported Games

Currently Unturned is the only supported game. More games might follow in the future. OpenMod can work side-by-side with RocketMod.

License

See LICENSE file for more information.

Build Status

Framework

OpenMod.API OpenMod.Bootstrapper OpenMod.NuGet OpenMod.Core OpenMod.Runtime OpenMod.Analyzers OpenMod.Templates OpenMod.EntityFrameworkCore

Extensions

OpenMod.Extensions.Games.Abstractions OpenMod.Extensions.Economy.Abstractions

Standalone

OpenMod.Standalone

UnityEngine

OpenMod.UnityEngine.Redist OpenMod.UniTask OpenMod.UnityEngine

Unturned

OpenMod.Unturned.Redist OpenMod.Unturned OpenMod.Unturned.Module

Rust

OpenMod.Rust.Redist OpenMod.Rust OpenMod.Rust.Oxide.Redist OpenMod.Rust.Oxide OpenMod.Rust.Oxide.Extension OpenMod.Rust.Oxide.PermissionLink

Code of Conduct

This project uses the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.

openmod.economy's People

Contributors

dependabot[bot] avatar diffoz avatar iamsilk avatar lgtm-migrator avatar rube200 avatar trojaner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

openmod.economy's Issues

Update to v1.1

There are some important changes made to this latest commit:
Thread lock cause by TaskCompletionSource
Check missing dependencies at load instead of EconomyProvider execution.
Update translations (breaking changes, users need to delete old one).

Missing:
-> Need more test (will do some basic tests tomorrow)

If any one test pls comment here

Thrown exceptions don't return to calling method

For actions sent to the Dispatcher, if an exception is thrown, the calling task will never continue as no result is set.

Here's my modified code for DataStoreDatabase.UpdateBalanceAsync:

            m_EconomyDispatcher.Enqueue(async () =>
            {
                Console.WriteLine("Updating balance");
                var data = await m_DataStore.LoadAsync<AccountsCollection>(TableName) ??
                           Activator.CreateInstance<AccountsCollection>();
                if (!data.Accounts.TryGetValue(uniqueId, out var balance)) balance = DefaultBalance;
                Console.WriteLine("Balance: " + balance);

                Console.WriteLine("Amount: " + amount);
                balance += amount;
                Console.WriteLine("New Balance: " + balance);
                if (balance < 0)
                    throw new NotEnoughBalanceException(StringLocalizer["economy:fail:not_enough_balance", balance]);

                Console.WriteLine("Saving");
                data.Accounts[uniqueId] = balance;
                await m_DataStore.SaveAsync(TableName, data);

                tcs.SetResult(balance);
            });

Example output:

Updating balance
Balance: 0.00
Amount: -100.00
New Balance: -100.00

As the new balance is below zero, we know the exception is being thrown.

I'm calling UpdateBalanceAsync from a UnturnedCommand's execute method which means NotEnoughBalanceException should be caught and handled properly, outputting to the user they can't afford this. This output never happens.

I tried encapsulating UpdateBalanceAsync within a try/catch statement and was able to further confirm the code never continues past calling await m_EconomyProvider.UpdateBalanceAsync where m_EconomyProvider is an instance of DataStoreDatabase.

MySqlConnector DisposeAsync not found

Fresh install

[17:23:29 ERR][OpenMod.Core.Plugins.PluginActivator] Failed to load plugin: OpenMod.Economy v1.3.9
System.MissingMethodException: Method not found: System.Threading.Tasks.Task MySqlConnector.MySqlCommand.DisposeAsync()
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x0002c] in <47fc8c70fa834cbf8141d7c1a7589125>:0
  at OpenMod.Economy.DataBase.MySqlDatabase.ExecuteMySqlAsync (System.Func`2[T,TResult] task) [0x00024] in <aaacb6021d924fdab5cd45e62af6adaf>:0
  at OpenMod.Economy.DataBase.MySqlDatabase.CheckShemasAsync () [0x00000] in <aaacb6021d924fdab5cd45e62af6adaf>:0
  at OpenMod.Economy.Controllers.EconomyDatabaseController.CreateDatabaseProvider () [0x0009d] in <aaacb6021d924fdab5cd45e62af6adaf>:0
  at OpenMod.Economy.Controllers.EconomyDatabaseController.LoadControllerAsync () [0x00000] in <aaacb6021d924fdab5cd45e62af6adaf>:0
  at OpenMod.Economy.Controllers.DatabaseController.LoadControllerBaseAsync () [0x00006] in <aaacb6021d924fdab5cd45e62af6adaf>:0
  at OpenMod.Economy.Controllers.DatabaseController.InjectAndLoad (Autofac.ILifetimeScope lifetimeScope) [0x00037] in <aaacb6021d924fdab5cd45e62af6adaf>:0
  at OpenMod.Economy.Economy.OnLoadAsync () [0x00044] in <aaacb6021d924fdab5cd45e62af6adaf>:0
  at OpenMod.Core.Plugins.OpenModUniversalPlugin.LoadAsync () [0x00112] in /_/framework/OpenMod.Core/Plugins/OpenModUniversalPlugin.cs:29
  at OpenMod.Core.Plugins.PluginActivator.TryActivatePluginAsync (System.Reflection.Assembly assembly) [0x00365] in /_/framework/OpenMod.Core/Plugins/PluginActivator.cs:230

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.