Skip to content

Commit

Permalink
Add project files
Browse files Browse the repository at this point in the history
  • Loading branch information
radek203 committed May 11, 2024
0 parents commit 340a7bc
Show file tree
Hide file tree
Showing 102 changed files with 7,140 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "maven" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"

35 changes: 35 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'corretto'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/*
target/
dependency-reduced-pom.xml
210 changes: 210 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
KMLightSpigot
===========

Warning: I do not take responsibility for the usage of this project in a production environment! It is only the public version of this project. You bear full responsibility for securing and configuring your lobby server, proxy server, etc.

## What is this project?

This server is built to handle thousands of players all in one server, Initially for guilds kwadratowamasakra.pl project.

It's crafted as a lightweight server, designed for handling tasks like logging in, verifying accounts, and more, without the overhead of managing worlds, etc.

Specifically designed for players playing Minecraft version 1.8.x, it also lets you make custom plugins with custom commands and listeners.

## How to run

-Install latest Java 21 version, and screen for your linux

-Create a directory and place the server jar file in it

-Create a run script:

-For testing on Windows, create a .bat file with the following content: java -jar server.jar.

-However, I strongly recommend running it on Linux, where you can utilize screen and scripts for auto-updating plugins, etc.

For example:

start.sh

```bash
screen -S Server1 ./restart.sh
```

restart.sh

```bash
#!/bin/bash
while true; do

FILE=./plugins/yourPluginNew.jar
if test -f "$FILE"; then
cp -f ./plugins/yourPluginNew.jar ./plugins/yourPlugin.jar
rm ./plugins/yourPluginNew.jar
fi
java -Xms768M -Xmx768M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Djdk.http.auth.tunneling.disabledSchemes="" -jar server.jar nogui
sleep 5s

done
```

Learn more about screen (how to run etc.) here: https://www.geeksforgeeks.org/screen-command-in-linux-with-examples/

## How to create a plugin? (Maven)

You can see the example (!!!) below with one command and one listener:

pom.xml

```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>SamplePlugin</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jar.finalName>${project.name}New</jar.finalName>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<archive>
<manifest>
<mainClass>org.example.Main</mainClass>
</manifest>
<manifestEntries>
<Plugin-Name>SamplePlugin</Plugin-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<dependencies>
<dependency>
<groupId>pl.kwadratowamasakra</groupId>
<artifactId>lightspigot</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>
C:/.../server.jar
</systemPath>
</dependency>
</dependencies>

</project>
```

Main.java

```java
package org.example;

import pl.kwadratowamasakra.lightspigot.LightSpigotServer;
import pl.kwadratowamasakra.lightspigot.config.Configuration;

public class Main {

public final void onEnable(final LightSpigotServer server, final Configuration conf) {
new PlayerLoginListener(server);
new SampleCommand(server);
}

public final void onDisable() {

}
}
```

SampleCommand.java

```java
package org.example;

import pl.kwadratowamasakra.lightspigot.LightSpigotServer;
import pl.kwadratowamasakra.lightspigot.command.Command;
import pl.kwadratowamasakra.lightspigot.command.CommandSender;

import java.util.List;

public class SampleCommand extends Command {

public SampleCommand(final LightSpigotServer server) {
super("sample", List.of("sample1", "sample2"));

server.getCommandManager().addCommand(this);
}

@Override
public final void handle(final CommandSender sender, final String[] args) {
// handle command
}

}
```

PlayerLoginListener.java

```java
package org.example;

import pl.kwadratowamasakra.lightspigot.LightSpigotServer;
import pl.kwadratowamasakra.lightspigot.event.EventListener;
import pl.kwadratowamasakra.lightspigot.event.PlayerLoginEvent;

public class PlayerLoginListener implements EventListener<PlayerLoginEvent> {

public PlayerLoginListener(final LightSpigotServer server) {
server.getEventManager().addEvent(PlayerLoginEvent.class, this);
}

@Override
public final void handle(final PlayerLoginEvent e) {
// handle event
}
}
```
93 changes: 93 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>pl.kwadratowamasakra.lightspigot</groupId>
<artifactId>KMLightSpigot</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<archive>
<manifest>
<mainClass>pl.kwadratowamasakra.lightspigot.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.109.Final</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.4.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit 340a7bc

Please sign in to comment.