Skip to content

Commit

Permalink
Merge pull request #283 from RSPSApp/plugin-system
Browse files Browse the repository at this point in the history
Plugin System
  • Loading branch information
tobywisener authored Nov 4, 2023
2 parents 2b60ed8 + e3e4134 commit 478e656
Show file tree
Hide file tree
Showing 557 changed files with 9,054 additions and 8,444 deletions.
3 changes: 2 additions & 1 deletion ElvargServer/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/target/
/build/
/game/build/
/plugin/build/
.gradle/
.classpath
.settings/org.eclipse.jdt.core.prefs
Expand Down
96 changes: 60 additions & 36 deletions ElvargServer/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,48 +1,72 @@
/*
* This file was generated by the Gradle 'init' task.
*/

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
java
application
alias(libs.plugins.kotlin.jvm) apply true
alias(libs.plugins.kotlin.serialization)
idea
}

repositories {
mavenLocal()
maven {
url = uri("https://repo.maven.apache.org/maven2/")
allprojects {
apply(plugin = "idea")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")

group = "com.elvarg"
version = "0.0.1"

repositories {
mavenLocal()
mavenCentral()
}
}

dependencies {
implementation("io.netty:netty-all:4.1.72.Final")
implementation("com.google.code.gson:gson:2.8.9")
implementation("com.google.guava:guava:31.0.1-jre")
implementation("commons-lang:commons-lang:2.6")
implementation("com.password4j:password4j:1.6.0")
implementation("software.amazon.awssdk:dynamodb:2.17.237")
implementation("software.amazon.awssdk:dynamodb-enhanced:2.17.237")
val lib = rootProject.project.libs
dependencies {
with(lib) {
implementation(gson)
implementation(guava)
implementation(progress.bar)
implementation(inline.loggerr)
implementation(kotlin.logging)
implementation(kotlinx.coroutines)
implementation(kotlin.script.runtime)
implementation(kotlin.scripting)
implementation(kotlin.reflect)
implementation("org.litote.kmongo:kmongo-coroutine-serialization:4.5.0")
}
}

implementation(platform("com.squareup.okhttp3:okhttp-bom:4.10.0"))
// define any required OkHttp artifacts without version
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
kotlin{
jvmToolchain{
languageVersion.set(JavaLanguageVersion.of(17))
}
}

}
idea {
module {
inheritOutputDirs = false
outputDir = file("${project.buildDir}/classes/kotlin/main")
testOutputDir = file("${project.buildDir}/classes/kotlin/test")
}
}

application {
mainClass.set("com.elvarg.Server")
}
tasks.compileJava {
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
}

tasks.withType<ShadowJar> {
archiveFileName.set("app.jar")
tasks.withType<KotlinCompile>().all {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = listOf(
"-Xallow-any-scripts-in-source-roots" ,
)
}
}
}

group = "Elvarg"
version = "1.0-SNAPSHOT"
description = "Elvarg-Game-Server"
java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = JavaVersion.VERSION_17

49 changes: 49 additions & 0 deletions ElvargServer/game/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
application
}

application {
apply(plugin = "maven-publish")
mainClass.set("com.elvarg.Server")
}

val lib = rootProject.project.libs
dependencies {
with(lib) {
implementation(commons)
implementation(commons.lang)
implementation(classgraph)
implementation(slf4j.api)
implementation(okhttp3)
implementation(password4J)
implementation(dynamodb)
implementation(joda)
implementation(dynamodb.enhanced)
implementation(netty.all)
}
runtimeOnly(project(":plugin"))
}

tasks.named<Jar>("jar") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType<ProcessResources> {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

tasks {

build {
this.finalizedBy(project(":plugin").tasks.getByName("build"))
}

buildNeeded {
this.finalizedBy(project(":plugin").tasks.getByName("buildNeeded"))
}

compileKotlin {
this.finalizedBy(project(":plugin").tasks.getByName("build"))
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.elvarg.game.GameConstants;
import com.elvarg.net.NetworkBuilder;
import com.elvarg.net.NetworkConstants;
import com.elvarg.plugin.event.EventManager;
import com.elvarg.plugin.event.impl.ServerBootEvent;
import com.elvarg.plugin.event.impl.ServerStartedEvent;
import com.elvarg.util.ShutdownHook;
import com.elvarg.util.flood.Flooder;

Expand Down Expand Up @@ -56,9 +59,10 @@ public static void main(String[] args) {

logger.info("Initializing " + GameConstants.NAME + " in " + (PRODUCTION ? "production" : "non-production") + " mode..");
new GameBuilder().initialize();
EventManager.INSTANCE.postAndWait(new ServerBootEvent());
new NetworkBuilder().initialize(NetworkConstants.GAME_PORT);
logger.info(GameConstants.NAME + " is now online!");

EventManager.INSTANCE.post(new ServerStartedEvent());
} catch (Exception e) {
logger.log(Level.SEVERE, "An error occurred while binding the Bootstrap!", e);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.elvarg.game.content.minigames.MinigameHandler;
import com.elvarg.game.definition.loader.impl.*;
import com.elvarg.game.task.impl.CombatPoisonEffect.CombatPoisonData;
import com.elvarg.plugin.PluginManager;
import com.elvarg.util.BackgroundLoader;
import com.elvarg.util.PlayerPunishment;

Expand Down Expand Up @@ -41,6 +42,8 @@ public void initialize() throws Exception {
// Start background tasks..
backgroundLoader.init(createBackgroundTasks());

PluginManager.INSTANCE.init();

// Start global tasks..

// Start game engine..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public class GameConstants {
/**
* The directory of the definition files.
*/
public static final String DEFINITIONS_DIRECTORY = "./data/definitions/";
public static final String DEFINITIONS_DIRECTORY = "../data/definitions/";

/**
* The directory of the clipping files.
*/
public static final String CLIPPING_DIRECTORY = "./data/clipping/";
public static final String CLIPPING_DIRECTORY = "../data/clipping/";

/**
* The method used to save/load players.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static FlowersData forObject(int object) {
}

public static FlowersData generate() {
double RANDOM = (java.lang.Math.random() * 100);
double RANDOM = (Math.random() * 100);
if (RANDOM >= 1) {
return values()[Misc.getRandom(6)];
} else {
Expand Down
Loading

0 comments on commit 478e656

Please sign in to comment.