├── VERSION
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
└── .gitignore
├── config
├── spotbugs
│ └── suppressions.xml
└── checkstyle
│ ├── suppressions.xml
│ └── checkstyle.xml
├── HEADER.txt
├── src
└── main
│ ├── templates
│ └── net
│ │ └── elytrium
│ │ └── fastmotd
│ │ └── BuildConstants.java
│ └── java
│ └── net
│ └── elytrium
│ └── fastmotd
│ ├── command
│ ├── ReloadCommand.java
│ └── MaintenanceCommand.java
│ ├── listener
│ ├── ShutdownOnZeroPlayersListener.java
│ └── CompatPingListener.java
│ ├── utils
│ ├── ByteBufCopyThreadLocal.java
│ └── MOTDGenerator.java
│ ├── holder
│ ├── MOTDHolder.java
│ └── MOTDBytesHolder.java
│ ├── injection
│ ├── ServerChannelInitializerHook.java
│ └── HandshakeSessionHandlerHook.java
│ ├── Settings.java
│ └── FastMOTD.java
├── README.md
├── .gitignore
├── .github
└── workflows
│ ├── release.yml
│ └── build.yml
├── gradlew.bat
├── gradlew
└── LICENSE
/VERSION:
--------------------------------------------------------------------------------
1 | 1.0.9
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'FastMOTD'
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Elytrium/FastMOTD/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/config/spotbugs/suppressions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/HEADER.txt:
--------------------------------------------------------------------------------
1 | Copyright (C) 2022 - 2025 Elytrium
2 |
3 | This program is free software: you can redistribute it and/or modify
4 | it under the terms of the GNU Affero General Public License as published by
5 | the Free Software Foundation, either version 3 of the License, or
6 | (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU Affero General Public License for more details.
12 |
13 | You should have received a copy of the GNU Affero General Public License
14 | along with this program. If not, see .
15 |
--------------------------------------------------------------------------------
/src/main/templates/net/elytrium/fastmotd/BuildConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd;
19 |
20 | // The constants are replaced before compilation
21 | public class BuildConstants {
22 |
23 | public static final String VERSION = "${version}";
24 | }
25 |
--------------------------------------------------------------------------------
/config/checkstyle/suppressions.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/command/ReloadCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd.command;
19 |
20 | import com.velocitypowered.api.command.SimpleCommand;
21 | import com.velocitypowered.api.permission.Tristate;
22 | import net.elytrium.fastmotd.FastMOTD;
23 |
24 | public class ReloadCommand implements SimpleCommand {
25 |
26 | private final FastMOTD plugin;
27 |
28 | public ReloadCommand(FastMOTD plugin) {
29 | this.plugin = plugin;
30 | }
31 |
32 |
33 | @Override
34 | public void execute(Invocation invocation) {
35 | this.plugin.reload();
36 | }
37 |
38 | @Override
39 | public boolean hasPermission(Invocation invocation) {
40 | return invocation.source().getPermissionValue("fastmotd.reload") == Tristate.TRUE;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/listener/ShutdownOnZeroPlayersListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd.listener;
19 |
20 | import com.velocitypowered.api.event.Subscribe;
21 | import com.velocitypowered.api.event.connection.DisconnectEvent;
22 | import net.elytrium.fastmotd.FastMOTD;
23 | import net.kyori.adventure.text.Component;
24 |
25 | public class ShutdownOnZeroPlayersListener {
26 |
27 | private final FastMOTD plugin;
28 |
29 | public ShutdownOnZeroPlayersListener(FastMOTD plugin) {
30 | this.plugin = plugin;
31 | }
32 |
33 | @Subscribe
34 | public void onDisconnect(DisconnectEvent event) {
35 | if (this.plugin.getServer().getAllPlayers().isEmpty()) {
36 | this.plugin.getServer().shutdown(Component.text("FastMOTD -> shutdown on zero players"));
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # FastMOTD
4 |
5 | [](https://ely.su/discord)
6 | [](https://bstats.org/plugin/velocity/FastMOTD/15640)
7 | [](https://bstats.org/plugin/velocity/FastMOTD/15640)
8 |
9 | A MOTD plugin for Velocity that caches network packets. This helps it be the fastest one of the MOTD plugins.
10 | Test server: [``ely.su``](https://hotmc.ru/minecraft-server-203216)
11 |
12 | ## Features
13 |
14 | - Fake online (percent + static sum)
15 | - Multiple descriptions/favicons support
16 | - Set information (custom text in the player list)
17 | - Caching of network packets
18 | - Max count "just add up" support
19 | - PNG built-in compression
20 |
21 | ## Comparison with other MOTD plugins
22 |
23 | Intel Core i9-9700K, DDR4 (a server that is not running any programs):
24 |
25 | | Plugin | Pings per second count |
26 | | - | - |
27 | | FastMOTD | 1 700 000 - 2 000 000 pings per second |
28 | | Without MOTD plugins | 900 000 - 1 100 000 pings per second |
29 | | MiniMOTD | 480 000 - 580 000 pings per second |
30 |
31 | Intel Xeon E3-1270, DDR3 (a PC with several applications running):
32 | | Plugin | Pings per second count |
33 | | - | - |
34 | | FastMOTD | 840 000 - 1 000 000 pings per second |
35 | | Without MOTD plugins | 330 000 - 430 000 pings per second |
36 | | MiniMOTD | 150 000 - 200 000 pings per second |
37 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/listener/CompatPingListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd.listener;
19 |
20 | import com.velocitypowered.api.event.Subscribe;
21 | import com.velocitypowered.api.event.proxy.ProxyPingEvent;
22 | import com.velocitypowered.api.proxy.InboundConnection;
23 | import net.elytrium.fastmotd.FastMOTD;
24 |
25 | public class CompatPingListener {
26 |
27 | private final FastMOTD plugin;
28 |
29 | public CompatPingListener(FastMOTD plugin) {
30 | this.plugin = plugin;
31 | }
32 |
33 | @Subscribe
34 | public void onPing(ProxyPingEvent event) {
35 | InboundConnection connection = event.getConnection();
36 | event.setPing(this.plugin.getNextCompat(
37 | connection.getProtocolVersion(),
38 | connection.getVirtualHost()
39 | .map(address -> address.getHostName() + ":" + address.getPort())
40 | .orElse(null)));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/utils/ByteBufCopyThreadLocal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd.utils;
19 |
20 | import io.netty.buffer.ByteBuf;
21 | import java.util.LinkedList;
22 | import java.util.List;
23 | import java.util.ListIterator;
24 |
25 | public class ByteBufCopyThreadLocal extends ThreadLocal {
26 |
27 | private final List byteBuffers = new LinkedList<>();
28 | private final ListIterator byteBufferIterator;
29 |
30 | public ByteBufCopyThreadLocal(ByteBuf from) {
31 | super();
32 |
33 | for (int i = 0; i < Runtime.getRuntime().availableProcessors(); ++i) {
34 | this.byteBuffers.add(from.copy());
35 | }
36 |
37 | this.byteBufferIterator = this.byteBuffers.listIterator();
38 | }
39 |
40 | protected ByteBuf initialValue() {
41 | return this.byteBufferIterator.next();
42 | }
43 |
44 | public void release() {
45 | for (ByteBuf byteBuffer : this.byteBuffers) {
46 | if (byteBuffer.refCnt() != 0) {
47 | byteBuffer.release();
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # IntelliJ user-specific stuff
2 | .idea/
3 | *.iml
4 |
5 | # Compiled class file
6 | *.class
7 |
8 | # Log file
9 | *.log
10 |
11 | # Package Files
12 | *.jar
13 | *.zip
14 | *.tar.gz
15 | *.rar
16 |
17 | # Virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
18 | hs_err_pid*
19 |
20 | *~
21 |
22 | # Temporary files which can be created if a process still has a handle open of a deleted file
23 | .fuse_hidden*
24 |
25 | # KDE directory preferences
26 | .directory
27 |
28 | # Linux trash folder which might appear on any partition or disk
29 | .Trash-*
30 |
31 | # .nfs files are created when an open file is removed but is still being accessed
32 | .nfs*
33 |
34 | # General
35 | .DS_Store
36 | .AppleDouble
37 | .LSOverride
38 |
39 | # Icon must end with two \r
40 | Icon
41 |
42 | # Thumbnails
43 | ._*
44 |
45 | # Files that might appear in the root of a volume
46 | .DocumentRevisions-V100
47 | .fseventsd
48 | .Spotlight-V100
49 | .TemporaryItems
50 | .Trashes
51 | .VolumeIcon.icns
52 | .com.apple.timemachine.donotpresent
53 |
54 | # Directories potentially created on remote AFP share
55 | .AppleDB
56 | .AppleDesktop
57 | Network Trash Folder
58 | Temporary Items
59 | .apdisk
60 |
61 | # Windows thumbnail cache files
62 | Thumbs.db
63 | Thumbs.db:encryptable
64 | ehthumbs.db
65 | ehthumbs_vista.db
66 |
67 | # Dump file
68 | *.stackdump
69 |
70 | # Folder config file
71 | [Dd]esktop.ini
72 |
73 | # Recycle Bin used on file shares
74 | $RECYCLE.BIN/
75 |
76 | # Windows Installer files
77 | *.cab
78 | *.msi
79 | *.msix
80 | *.msm
81 | *.msp
82 |
83 | # Windows shortcuts
84 | *.lnk
85 |
86 | # Gradle
87 | .gradle
88 | build/
89 |
90 | # Gradle Patch
91 | **/build/
92 |
93 | # Common working directory
94 | run/
95 |
96 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
97 | !gradle-wrapper.jar
98 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Java CI with Gradle
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - name: Checkout
12 | uses: actions/checkout@v4.2.2
13 | - name: Set up JDK
14 | uses: actions/setup-java@v4.7.0
15 | with:
16 | distribution: adopt
17 | java-version: 17
18 | - name: Build FastMOTD
19 | run: ./gradlew build
20 | - name: Upload FastMOTD
21 | uses: actions/upload-artifact@v4.6.2
22 | with:
23 | name: FastMOTD
24 | path: "build/libs/FastMOTD*.jar"
25 | - name: Find correct JAR
26 | id: find-jar
27 | run: |
28 | output="$(find build/libs/ ! -name "*-javadoc.jar" ! -name "*-sources.jar" -type f -printf "%f\n")"
29 | echo "::set-output name=jarname::$output"
30 | - name: Upload to the GitHub release
31 | uses: actions/upload-release-asset@v1
32 | env:
33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 | with:
35 | upload_url: ${{ github.event.release.upload_url }}
36 | asset_path: build/libs/${{ steps.find-jar.outputs.jarname }}
37 | asset_name: ${{ steps.find-jar.outputs.jarname }}
38 | asset_content_type: application/java-archive
39 | - name: Upload to Modrinth
40 | uses: RubixDev/modrinth-upload@v1.0.0
41 | with:
42 | token: ${{ secrets.MODRINTH_TOKEN }}
43 | file_path: build/libs/${{ steps.find-jar.outputs.jarname }}
44 | name: Release ${{ github.event.release.tag_name }}
45 | version: ${{ github.event.release.tag_name }}
46 | changelog: ${{ github.event.release.body }}
47 | game_versions: 1.7.2
48 | release_type: release
49 | loaders: velocity
50 | featured: false
51 | project_id: OfMfkdiO
52 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Java CI with Gradle
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | branches:
9 | - master
10 |
11 | jobs:
12 | build:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v4.2.2
17 | - name: Set up JDK
18 | uses: actions/setup-java@v4.7.0
19 | with:
20 | distribution: adopt
21 | java-version: 17
22 | - name: Build FastMOTD
23 | run: ./gradlew build
24 | - name: Upload FastMOTD
25 | uses: actions/upload-artifact@v4.6.2
26 | with:
27 | name: FastMOTD
28 | path: "build/libs/FastMOTD*.jar"
29 | - uses: dev-drprasad/delete-tag-and-release@v0.2.1
30 | if: ${{ github.event_name == 'push' }}
31 | with:
32 | delete_release: true
33 | tag_name: dev-build
34 | env:
35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 | - name: Find git version
37 | id: git-version
38 | run: echo "id=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
39 | - name: Find correct JAR
40 | if: ${{ github.event_name == 'push' }}
41 | id: find-jar
42 | run: |
43 | output="$(find build/libs/ ! -name "*-javadoc.jar" ! -name "*-sources.jar" -type f -printf "%f\n")"
44 | echo "::set-output name=jarname::$output"
45 | - name: Release the build
46 | if: ${{ github.event_name == 'push' }}
47 | uses: ncipollo/release-action@v1
48 | with:
49 | artifacts: build/libs/${{ steps.find-jar.outputs.jarname }}
50 | body: ${{ join(github.event.commits.*.message, '\n') }}
51 | prerelease: true
52 | name: Dev-build ${{ steps.git-version.outputs.id }}
53 | tag: dev-build
54 | - name: Upload to Modrinth
55 | if: ${{ github.event_name == 'push' }}
56 | uses: RubixDev/modrinth-upload@v1.0.0
57 | with:
58 | token: ${{ secrets.MODRINTH_TOKEN }}
59 | file_path: build/libs/${{ steps.find-jar.outputs.jarname }}
60 | name: Dev-build ${{ steps.git-version.outputs.id }}
61 | version: ${{ steps.git-version.outputs.id }}
62 | changelog: ${{ join(github.event.commits.*.message, '\n') }}
63 | game_versions: 1.7.2
64 | release_type: beta
65 | loaders: velocity
66 | featured: false
67 | project_id: OfMfkdiO
68 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/command/MaintenanceCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd.command;
19 |
20 | import com.google.common.collect.ImmutableList;
21 | import com.velocitypowered.api.command.CommandSource;
22 | import com.velocitypowered.api.command.SimpleCommand;
23 | import com.velocitypowered.api.permission.Tristate;
24 | import java.util.List;
25 | import net.elytrium.fastmotd.FastMOTD;
26 | import net.elytrium.fastmotd.Settings;
27 | import net.kyori.adventure.text.Component;
28 |
29 | public class MaintenanceCommand implements SimpleCommand {
30 |
31 | private final FastMOTD plugin;
32 | private final Component usage;
33 |
34 | public MaintenanceCommand(FastMOTD plugin, Component usage) {
35 | this.plugin = plugin;
36 | this.usage = usage;
37 | }
38 |
39 | @Override
40 | public List suggest(Invocation invocation) {
41 | return ImmutableList.of("off", "on", "toggle");
42 | }
43 |
44 | @Override
45 | public void execute(Invocation invocation) {
46 | String[] args = invocation.arguments();
47 | CommandSource source = invocation.source();
48 |
49 | if (args.length < 1) {
50 | source.sendMessage(this.usage);
51 | return;
52 | }
53 |
54 | switch (args[0]) {
55 | case "off":
56 | Settings.IMP.MAINTENANCE.MAINTENANCE_ENABLED = false;
57 | break;
58 |
59 | case "on":
60 | Settings.IMP.MAINTENANCE.MAINTENANCE_ENABLED = true;
61 | break;
62 |
63 | case "toggle":
64 | Settings.IMP.MAINTENANCE.MAINTENANCE_ENABLED ^= true;
65 | break;
66 |
67 | default:
68 | source.sendMessage(this.usage);
69 | return;
70 | }
71 |
72 | Settings.IMP.save(this.plugin.getConfigPath());
73 | }
74 |
75 | @Override
76 | public boolean hasPermission(Invocation invocation) {
77 | return invocation.source().getPermissionValue("fastmotd.maintenance") == Tristate.TRUE;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/holder/MOTDHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd.holder;
19 |
20 | import com.velocitypowered.api.network.ProtocolVersion;
21 | import com.velocitypowered.api.proxy.server.ServerPing;
22 | import com.velocitypowered.proxy.protocol.ProtocolUtils;
23 | import io.netty.buffer.ByteBuf;
24 | import java.util.List;
25 | import net.kyori.adventure.text.Component;
26 | import net.kyori.adventure.text.serializer.ComponentSerializer;
27 |
28 | public class MOTDHolder {
29 |
30 | private final MOTDBytesHolder legacyHolder;
31 | private final MOTDBytesHolder modernHolder;
32 |
33 | public MOTDHolder(ComponentSerializer serializer, String versionName,
34 | String descriptionSerialized, String favicon, List information) {
35 | String name = versionName.replace("\"", "\\\"");
36 | Component description = serializer.deserialize(descriptionSerialized.replace("{NL}", "\n"));
37 |
38 | this.legacyHolder =
39 | new MOTDBytesHolder(serializer, ProtocolUtils.getJsonChatSerializer(ProtocolVersion.MINECRAFT_1_15_2), name, description, favicon, information);
40 | this.modernHolder =
41 | new MOTDBytesHolder(serializer, ProtocolUtils.getJsonChatSerializer(ProtocolVersion.MINECRAFT_1_16), name, description, favicon, information);
42 | }
43 |
44 | public void replaceOnline(int max, int online) {
45 | this.legacyHolder.replaceOnline(max, online);
46 | this.modernHolder.replaceOnline(max, online);
47 | }
48 |
49 | public ByteBuf getByteBuf(ProtocolVersion version, boolean replaceProtocol) {
50 | if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
51 | return this.modernHolder.getByteBuf(version, replaceProtocol);
52 | } else {
53 | return this.legacyHolder.getByteBuf(version, replaceProtocol);
54 | }
55 | }
56 |
57 | public ServerPing getCompatPingInfo(ProtocolVersion version, boolean replaceProtocol) {
58 | if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
59 | return this.modernHolder.getCompatPingInfo(version, replaceProtocol);
60 | } else {
61 | return this.legacyHolder.getCompatPingInfo(version, replaceProtocol);
62 | }
63 | }
64 |
65 | public void dispose() {
66 | this.legacyHolder.dispose();
67 | this.modernHolder.dispose();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/injection/ServerChannelInitializerHook.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd.injection;
19 |
20 | import com.velocitypowered.proxy.connection.MinecraftConnection;
21 | import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler;
22 | import com.velocitypowered.proxy.network.Connections;
23 | import io.netty.channel.Channel;
24 | import io.netty.channel.ChannelInitializer;
25 | import java.lang.invoke.MethodHandle;
26 | import java.lang.invoke.MethodHandles;
27 | import java.lang.invoke.MethodType;
28 | import java.net.InetSocketAddress;
29 | import net.elytrium.commons.utils.reflection.ReflectionException;
30 | import net.elytrium.fastmotd.FastMOTD;
31 | import net.elytrium.fastmotd.Settings;
32 | import org.jetbrains.annotations.NotNull;
33 |
34 | public class ServerChannelInitializerHook extends ChannelInitializer {
35 |
36 | private static final MethodHandle initChannel;
37 | private final FastMOTD plugin;
38 | private final ChannelInitializer> original;
39 |
40 | static {
41 | try {
42 | initChannel = MethodHandles.privateLookupIn(ChannelInitializer.class, MethodHandles.lookup())
43 | .findVirtual(ChannelInitializer.class, "initChannel", MethodType.methodType(void.class, Channel.class));
44 | } catch (NoSuchMethodException | IllegalAccessException e) {
45 | throw new ReflectionException(e);
46 | }
47 | }
48 |
49 | public ServerChannelInitializerHook(FastMOTD plugin, ChannelInitializer> original) {
50 | this.plugin = plugin;
51 | this.original = original;
52 | }
53 |
54 | @Override
55 | protected void initChannel(@NotNull Channel ch) {
56 | if (Settings.IMP.SHUTDOWN_SCHEDULER.SHUTDOWN_SCHEDULER_ENABLED) {
57 | if (!Settings.IMP.SHUTDOWN_SCHEDULER.WHITELIST.contains(((InetSocketAddress) ch.remoteAddress()).getAddress().getHostAddress())) {
58 | ch.close();
59 | return;
60 | }
61 | }
62 |
63 | try {
64 | initChannel.invokeExact(this.original, ch);
65 | } catch (Throwable e) {
66 | throw new ReflectionException(e);
67 | }
68 |
69 | MinecraftConnection connection = (MinecraftConnection) ch.pipeline().get(Connections.HANDLER);
70 | connection.setActiveSessionHandler(connection.getState(), new HandshakeSessionHandlerHook(
71 | this.plugin, connection, ch, (HandshakeSessionHandler) connection.getActiveSessionHandler()));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/utils/MOTDGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd.utils;
19 |
20 | import com.velocitypowered.api.network.ProtocolVersion;
21 | import com.velocitypowered.api.proxy.server.ServerPing;
22 | import io.netty.buffer.ByteBuf;
23 | import java.awt.image.BufferedImage;
24 | import java.io.ByteArrayOutputStream;
25 | import java.io.IOException;
26 | import java.nio.file.Files;
27 | import java.nio.file.Path;
28 | import java.nio.file.Paths;
29 | import java.util.Base64;
30 | import java.util.List;
31 | import java.util.concurrent.ThreadLocalRandom;
32 | import javax.imageio.IIOImage;
33 | import javax.imageio.ImageIO;
34 | import javax.imageio.ImageTypeSpecifier;
35 | import javax.imageio.ImageWriteParam;
36 | import javax.imageio.ImageWriter;
37 | import javax.imageio.stream.ImageOutputStream;
38 | import net.elytrium.fastmotd.FastMOTD;
39 | import net.elytrium.fastmotd.Settings;
40 | import net.elytrium.fastmotd.holder.MOTDHolder;
41 | import net.kyori.adventure.text.Component;
42 | import net.kyori.adventure.text.serializer.ComponentSerializer;
43 |
44 | public class MOTDGenerator {
45 |
46 | private final FastMOTD plugin;
47 | private final ComponentSerializer serializer;
48 | private final String versionName;
49 | private final List descriptions;
50 | private final List favicons;
51 | private final List information;
52 | private final int holdersAmount;
53 | private final MOTDHolder[] holders;
54 |
55 | public MOTDGenerator(FastMOTD plugin, ComponentSerializer serializer,
56 | String versionName, List descriptions, List favicons, List information) {
57 | this.plugin = plugin;
58 | this.serializer = serializer;
59 | this.versionName = versionName;
60 | this.descriptions = descriptions;
61 | this.favicons = favicons;
62 | this.information = information;
63 | this.holdersAmount = this.descriptions.size() * Math.max(1, this.favicons.size());
64 | this.holders = new MOTDHolder[this.holdersAmount];
65 | }
66 |
67 | public void generate() {
68 | int faviconsSize = this.favicons.size();
69 |
70 | if (faviconsSize == 0) {
71 | this.generate(0, null);
72 | }
73 |
74 | for (int i = 0; i < faviconsSize; i++) {
75 | String faviconLocation = this.favicons.get(i);
76 | try {
77 | String base64Favicon = this.getFavicon(Paths.get(faviconLocation));
78 | this.generate(i, base64Favicon);
79 | } catch (IOException e) {
80 | this.plugin.getLogger().warn("Failed to load favicon {}. Ensure that the file exists or modify config.yml", faviconLocation);
81 | this.generate(i, null);
82 | }
83 | }
84 | }
85 |
86 | private void generate(int i, String favicon) {
87 | for (int j = 0, descriptionsSize = this.descriptions.size(); j < descriptionsSize; j++) {
88 | String description = this.descriptions.get(j);
89 | this.holders[i * descriptionsSize + j] = new MOTDHolder(this.serializer, this.versionName, description, favicon, this.information);
90 | }
91 | }
92 |
93 | private String getFavicon(Path faviconLocation) throws IOException {
94 | byte[] imageBytes;
95 |
96 | if (Settings.IMP.MAIN.PNG_QUALITY < 0) {
97 | imageBytes = Files.readAllBytes(faviconLocation);
98 | } else {
99 | BufferedImage image = ImageIO.read(Files.newInputStream(faviconLocation));
100 | ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
101 | try (ImageOutputStream out = ImageIO.createImageOutputStream(outBytes)) {
102 | ImageTypeSpecifier type = ImageTypeSpecifier.createFromRenderedImage(image);
103 | ImageWriter writer = ImageIO.getImageWriters(type, "png").next();
104 |
105 | ImageWriteParam param = writer.getDefaultWriteParam();
106 | if (param.canWriteCompressed()) {
107 | param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
108 | param.setCompressionQuality((float) Settings.IMP.MAIN.PNG_QUALITY);
109 | }
110 |
111 | writer.setOutput(out);
112 | writer.write(null, new IIOImage(image, null, null), param);
113 | writer.dispose();
114 | }
115 |
116 | imageBytes = outBytes.toByteArray();
117 | outBytes.close();
118 | }
119 |
120 | return "data:image/png;base64," + Base64.getEncoder().encodeToString(imageBytes);
121 | }
122 |
123 | public void update(int max, int online) {
124 | for (MOTDHolder holder : this.holders) {
125 | holder.replaceOnline(max, online);
126 | }
127 | }
128 |
129 | public ByteBuf getNext(ProtocolVersion version, boolean replaceProtocol) {
130 | return this.holders[ThreadLocalRandom.current().nextInt(this.holdersAmount)].getByteBuf(version, replaceProtocol);
131 | }
132 |
133 | public ServerPing getNextCompat(ProtocolVersion version, boolean replaceProtocol) {
134 | return this.holders[ThreadLocalRandom.current().nextInt(this.holdersAmount)].getCompatPingInfo(version, replaceProtocol);
135 | }
136 |
137 | public void dispose() {
138 | for (MOTDHolder holder : this.holders) {
139 | if (holder != null) {
140 | holder.dispose();
141 | }
142 | }
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/holder/MOTDBytesHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd.holder;
19 |
20 | import com.google.common.primitives.Bytes;
21 | import com.velocitypowered.api.network.ProtocolVersion;
22 | import com.velocitypowered.api.proxy.server.ServerPing;
23 | import com.velocitypowered.api.util.Favicon;
24 | import com.velocitypowered.proxy.protocol.ProtocolUtils;
25 | import io.netty.buffer.ByteBuf;
26 | import io.netty.buffer.Unpooled;
27 | import java.nio.charset.StandardCharsets;
28 | import java.util.List;
29 | import java.util.UUID;
30 | import net.elytrium.fastmotd.utils.ByteBufCopyThreadLocal;
31 | import net.kyori.adventure.text.Component;
32 | import net.kyori.adventure.text.serializer.ComponentSerializer;
33 | import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
34 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
35 |
36 | public class MOTDBytesHolder {
37 |
38 | private final ByteBuf byteBuf;
39 | private final ComponentSerializer inputSerializer;
40 | private final int maxOnlineDigit;
41 | private final int onlineDigit;
42 | private final int protocolDigit;
43 | private ByteBufCopyThreadLocal localByteBuf;
44 | private ServerPing compatPingInfo;
45 |
46 | public MOTDBytesHolder(ComponentSerializer inputSerializer, GsonComponentSerializer outputSerializer,
47 | String name, Component description, String favicon, List information) {
48 | this.inputSerializer = inputSerializer;
49 | ServerPing.Builder compatServerPingBuilder = ServerPing.builder();
50 |
51 | StringBuilder motd = new StringBuilder("{\"players\":{\"max\": 0,\"online\": 1,\"sample\":[");
52 |
53 | compatServerPingBuilder.maximumPlayers(0);
54 | compatServerPingBuilder.onlinePlayers(1);
55 |
56 | int lastIdx = information.size() - 1;
57 | if (lastIdx != -1) {
58 | if (lastIdx > 9) {
59 | lastIdx = 9;
60 | }
61 |
62 | for (int i = 0; i < lastIdx; i++) {
63 | String e = information.get(i);
64 | motd.append("{\"id\":\"00000000-0000-0000-0000-00000000000").append(i).append("\",\"name\":\"").append(this.toLegacy(e)).append("\"},");
65 | }
66 |
67 | motd.append("{\"id\":\"00000000-0000-0000-0000-000000000009\",\"name\":\"")
68 | .append(this.toLegacy(information.get(lastIdx)))
69 | .append("\"}");
70 |
71 | compatServerPingBuilder.samplePlayers(information.stream()
72 | .map(e -> new ServerPing.SamplePlayer(this.toLegacy(e), UUID.randomUUID()))
73 | .toArray(ServerPing.SamplePlayer[]::new));
74 | }
75 |
76 | motd.append("]},\"description\":")
77 | .append(outputSerializer.serialize(description))
78 | .append(",\"version\":{\"name\":\"")
79 | .append(name)
80 | .append("\",\"protocol\": 1}");
81 |
82 | compatServerPingBuilder.description(description);
83 | compatServerPingBuilder.version(new ServerPing.Version(1, name));
84 |
85 | if (favicon != null && !favicon.isEmpty()) {
86 | motd.append(",\"favicon\":\"")
87 | .append(favicon)
88 | .append("\"");
89 |
90 | compatServerPingBuilder.favicon(new Favicon(favicon));
91 | }
92 |
93 | motd.append("}");
94 |
95 | byte[] bytes = motd.toString().getBytes(StandardCharsets.UTF_8);
96 | int varIntLength = ProtocolUtils.varIntBytes(bytes.length);
97 | int length = bytes.length + varIntLength + 1;
98 | int lengthOfLength = ProtocolUtils.varIntBytes(length);
99 | varIntLength += lengthOfLength;
100 |
101 | this.maxOnlineDigit = Bytes.indexOf(bytes, " 0".getBytes(StandardCharsets.UTF_8)) + 1 + varIntLength;
102 | this.onlineDigit = Bytes.indexOf(bytes, " 1".getBytes(StandardCharsets.UTF_8)) + 1 + varIntLength;
103 | this.protocolDigit = Bytes.indexOf(bytes, "protocol\": 1}".getBytes(StandardCharsets.UTF_8)) + 19 + varIntLength;
104 |
105 | this.byteBuf = Unpooled.directBuffer(length + lengthOfLength);
106 | ProtocolUtils.writeVarInt(this.byteBuf, length);
107 | this.byteBuf.writeByte(0);
108 | ProtocolUtils.writeVarInt(this.byteBuf, bytes.length);
109 | this.byteBuf.writeBytes(bytes);
110 |
111 | this.localByteBuf = new ByteBufCopyThreadLocal(this.byteBuf);
112 | this.compatPingInfo = compatServerPingBuilder.build();
113 | }
114 |
115 | public void replaceOnline(int max, int online) {
116 | this.localReplaceOnline(this.maxOnlineDigit, max);
117 | this.localReplaceOnline(this.onlineDigit, online);
118 |
119 | ByteBufCopyThreadLocal previousLocalBuffer = this.localByteBuf;
120 | this.localByteBuf = new ByteBufCopyThreadLocal(this.byteBuf);
121 | previousLocalBuffer.release();
122 |
123 | this.compatPingInfo = this.compatPingInfo.asBuilder()
124 | .maximumPlayers(max)
125 | .onlinePlayers(online)
126 | .build();
127 | }
128 |
129 | private void localReplaceOnline(int digit, int to) {
130 | this.byteBuf.setByte(digit + 0, to >= 10000000 ? (to / 10000000 % 10) + '0' : ' ');
131 | this.byteBuf.setByte(digit + 1, to >= 1000000 ? (to / 1000000 % 10) + '0' : ' ');
132 | this.byteBuf.setByte(digit + 2, to >= 100000 ? (to / 100000 % 10) + '0' : ' ');
133 | this.byteBuf.setByte(digit + 3, to >= 10000 ? (to / 10000 % 10) + '0' : ' ');
134 | this.byteBuf.setByte(digit + 4, to >= 1000 ? (to / 1000 % 10) + '0' : ' ');
135 | this.byteBuf.setByte(digit + 5, to >= 100 ? (to / 100 % 10) + '0' : ' ');
136 | this.byteBuf.setByte(digit + 6, to >= 10 ? (to / 10 % 10) + '0' : ' ');
137 | this.byteBuf.setByte(digit + 7, (to % 10) + '0');
138 | }
139 |
140 | public ServerPing getCompatPingInfo(ProtocolVersion version, boolean replaceProtocol) {
141 | if (replaceProtocol) {
142 | return this.compatPingInfo.asBuilder()
143 | .version(new ServerPing.Version(version.getProtocol(), this.compatPingInfo.getVersion().getName()))
144 | .build();
145 | } else {
146 | return this.compatPingInfo;
147 | }
148 | }
149 |
150 | public ByteBuf getByteBuf(ProtocolVersion version, boolean replaceProtocol) {
151 | ByteBuf buf = this.localByteBuf.get();
152 |
153 | if (replaceProtocol) {
154 | int protocol = version.getProtocol();
155 | this.replaceStrInt(buf, this.protocolDigit, this.protocolDigit - 9, protocol);
156 | }
157 |
158 | return buf.retain();
159 | }
160 |
161 | private void replaceStrInt(ByteBuf buf, int startIndex, int endIndex, int toSet) {
162 | while (toSet > 0) {
163 | buf.setByte(startIndex--, (toSet % 10) + '0');
164 | toSet /= 10;
165 | }
166 |
167 | while (startIndex != endIndex) {
168 | buf.setByte(startIndex--, ' ');
169 | }
170 | }
171 |
172 | private String toLegacy(String from) {
173 | return LegacyComponentSerializer.legacySection().serialize(this.inputSerializer.deserialize(from));
174 | }
175 |
176 | public void dispose() {
177 | if (this.byteBuf.refCnt() != 0) {
178 | this.byteBuf.release();
179 | }
180 |
181 | this.localByteBuf.release();
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/Settings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd;
19 |
20 | import java.util.List;
21 | import java.util.Map;
22 | import net.elytrium.commons.kyori.serialization.Serializers;
23 | import net.elytrium.serializer.annotations.Comment;
24 | import net.elytrium.serializer.annotations.CommentValue;
25 | import net.elytrium.serializer.annotations.Final;
26 | import net.elytrium.serializer.language.object.YamlSerializable;
27 |
28 | public class Settings extends YamlSerializable {
29 |
30 | public static final Settings IMP = new Settings();
31 |
32 | @Final
33 | public String VERSION = BuildConstants.VERSION;
34 |
35 | @Comment({
36 | @CommentValue("Available serializers:"),
37 | @CommentValue("LEGACY_AMPERSAND - \"&c&lExample &c&9Text\"."),
38 | @CommentValue("LEGACY_SECTION - \"§c§lExample §c§9Text\"."),
39 | @CommentValue("MINIMESSAGE - \"Example Text\". (https://webui.adventure.kyori.net/)"),
40 | @CommentValue("GSON - \"[{\"text\":\"Example\",\"bold\":true,\"color\":\"red\"},{\"text\":\" \",\"bold\":true},{\"text\":\"Text\",\"bold\":true,\"color\":\"blue\"}]\". (https://minecraft.tools/en/json_text.php/)"),
41 | @CommentValue("GSON_COLOR_DOWNSAMPLING - Same as GSON, but uses downsampling."),
42 | })
43 | public Serializers SERIALIZER = Serializers.MINIMESSAGE;
44 |
45 | public MAIN MAIN = new MAIN();
46 |
47 | public static class MAIN {
48 | public boolean ENABLE_UPDATES = true;
49 | public String VERSION_NAME = "Elytrium";
50 | public List DESCRIPTIONS = List.of("FastMOTD{NL} -> Really fast.");
51 | public List FAVICONS = List.of("server-icon.png");
52 | public List INFORMATION = List.of("This is the", "best server", "made ever", "trust me");
53 | @Comment(@CommentValue("How frequently online player count will be updated (in ms)"))
54 | public long UPDATE_RATE = 3000;
55 | @Comment({
56 | @CommentValue("VARIABLE - from max-count parameter"),
57 | @CommentValue("ADD_SOME - will add up the number from max-count parameter to current online players amount")
58 | })
59 | public FastMOTD.MaxCountType MAX_COUNT_TYPE = FastMOTD.MaxCountType.VARIABLE;
60 | public int MAX_COUNT = 4444;
61 | public int FAKE_ONLINE_ADD_SINGLE = 5;
62 | public int FAKE_ONLINE_ADD_PERCENT = 20;
63 | @Comment({
64 | @CommentValue("Accepted values: from 0.0 to 1.0."),
65 | @CommentValue("Keep this value as low as possible"),
66 | @CommentValue("Set -1 to disable PNG recompression")
67 | })
68 | public double PNG_QUALITY = 0.0;
69 | @Comment(@CommentValue("Write packets outside of Netty pipeline to avoid plugins that modify packets (e.g. PacketEvents)"))
70 | public boolean DIRECT_WRITE = false;
71 | public boolean LOG_PINGS = false;
72 | public boolean LOG_IMPROPER_PINGS = false;
73 | @Comment({
74 | @CommentValue("Enabling this will allow non-vanilla ping packets sequence,"),
75 | @CommentValue("but will open your server to nullping attacks")
76 | })
77 | public boolean ALLOW_IMPROPER_PINGS = false;
78 |
79 | public VERSIONS VERSIONS = new VERSIONS();
80 |
81 | @Comment({
82 | @CommentValue("Separate MOTDs/favicons/information for different protocol versions"),
83 | @CommentValue("See https://wiki.vg/Protocol_version_numbers"),
84 | })
85 | public static class VERSIONS {
86 | @Comment(@CommentValue("{} = disabled"))
87 | public Map> DESCRIPTIONS = Map.of("757-759", List.of("FastMOTD{NL} -> Supports separate MOTDs for different versions."));
88 | @Comment(@CommentValue("{} = disabled"))
89 | public Map> FAVICONS = Map.of("756-758", List.of("second-server-icon.png"));
90 | @Comment(@CommentValue("{} = disabled"))
91 | public Map> INFORMATION = Map.of("757-758", List.of("Your", "protocol", "version", "is 757 or 758"));
92 | }
93 |
94 | public Map DOMAINS = Map.of("example.com:25565", new DOMAIN_MOTD_NODE());
95 | }
96 |
97 | public MAINTENANCE MAINTENANCE = new MAINTENANCE();
98 |
99 | public static class MAINTENANCE {
100 | public boolean MAINTENANCE_ENABLED = false;
101 | public boolean SHOW_VERSION = true;
102 | public boolean SHOULD_KICK_ON_JOIN = true;
103 | public List KICK_WHITELIST = List.of("127.0.0.1");
104 | public String KICK_MESSAGE = "Try to join the server later";
105 | public String VERSION_NAME = "MAINTENANCE MODE ENABLED!!";
106 | public List DESCRIPTIONS = List.of("FastMOTD{NL} -> Really fast. (in maintenance mode too)");
107 | public List FAVICONS = List.of("server-icon.png");
108 | public List INFORMATION = List.of("Contact support: https://elytrium.net/discord");
109 | @Comment(@CommentValue("-1 = disabled"))
110 | public int OVERRIDE_ONLINE = -1;
111 | @Comment(@CommentValue("-1 = disabled"))
112 | public int OVERRIDE_MAX_ONLINE = -1;
113 |
114 | public VERSIONS VERSIONS = new VERSIONS();
115 |
116 | @Comment({
117 | @CommentValue("Separate MOTDs/favicons/information for different protocol versions"),
118 | @CommentValue("See https://wiki.vg/Protocol_version_numbers"),
119 | })
120 | public static class VERSIONS {
121 | @Comment(@CommentValue("{} = disabled"))
122 | public Map> DESCRIPTIONS = Map.of("757-759", List.of("FastMOTD{NL} -> Really Fast."));
123 | @Comment(@CommentValue("{} = disabled"))
124 | public Map> FAVICONS = Map.of("758-758", List.of("second-server-icon.png"));
125 | @Comment(@CommentValue("{} = disabled"))
126 | public Map> INFORMATION = Map.of("756-759", List.of("Server is", "under", "maintenance"));
127 | }
128 |
129 | public Map DOMAINS = Map.of("example.com:25565", new DOMAIN_MOTD_NODE());
130 |
131 | public COMMAND COMMAND = new COMMAND();
132 |
133 | public static class COMMAND {
134 | public String USAGE = "FastMOTD >> Usage: /maintenance ";
135 | }
136 | }
137 |
138 | public SHUTDOWN_SCHEDULER SHUTDOWN_SCHEDULER = new SHUTDOWN_SCHEDULER();
139 |
140 | public static class SHUTDOWN_SCHEDULER {
141 | @Comment(@CommentValue("Server will stop accepting new connections"))
142 | public boolean SHUTDOWN_SCHEDULER_ENABLED = false;
143 | @Comment(@CommentValue("Server will shut down after everyone has left the server"))
144 | public boolean SHUTDOWN_ON_ZERO_PLAYERS = false;
145 | public List WHITELIST = List.of("127.0.0.1");
146 | }
147 |
148 | public static class DOMAIN_MOTD_NODE {
149 |
150 | public List DESCRIPTION = List.of("Description for example.com");
151 | public List FAVICON = List.of("example-com-server-icon.png");
152 | public List INFORMATION = List.of("Information for example.com");
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/injection/HandshakeSessionHandlerHook.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd.injection;
19 |
20 | import com.velocitypowered.api.network.ProtocolVersion;
21 | import com.velocitypowered.proxy.connection.MinecraftConnection;
22 | import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler;
23 | import com.velocitypowered.proxy.network.Connections;
24 | import com.velocitypowered.proxy.protocol.MinecraftPacket;
25 | import com.velocitypowered.proxy.protocol.StateRegistry;
26 | import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
27 | import com.velocitypowered.proxy.protocol.netty.MinecraftVarintFrameDecoder;
28 | import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
29 | import com.velocitypowered.proxy.protocol.packet.LegacyHandshakePacket;
30 | import com.velocitypowered.proxy.protocol.packet.LegacyPingPacket;
31 | import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
32 | import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
33 | import com.velocitypowered.proxy.util.except.QuietRuntimeException;
34 | import io.netty.buffer.ByteBuf;
35 | import io.netty.buffer.Unpooled;
36 | import io.netty.channel.Channel;
37 | import io.netty.channel.ChannelOutboundBuffer;
38 | import io.netty.channel.ChannelPipeline;
39 | import java.net.InetSocketAddress;
40 | import net.elytrium.fastmotd.FastMOTD;
41 | import net.elytrium.fastmotd.Settings;
42 |
43 | public class HandshakeSessionHandlerHook extends HandshakeSessionHandler {
44 |
45 | private static final QuietRuntimeException UNEXPECTED_STATE =
46 | new QuietRuntimeException("unexpected state");
47 |
48 | private enum State {
49 | REQUEST, PING, DONE
50 | }
51 |
52 | private final FastMOTD plugin;
53 | private final MinecraftConnection connection;
54 | private final Channel channel;
55 | private final HandshakeSessionHandler original;
56 | private ProtocolVersion protocolVersion;
57 | private String serverAddress;
58 | private State state = State.REQUEST;
59 |
60 | public HandshakeSessionHandlerHook(FastMOTD plugin, MinecraftConnection connection, Channel channel, HandshakeSessionHandler original) {
61 | super(connection, plugin.getServer());
62 | this.plugin = plugin;
63 | this.connection = connection;
64 | this.channel = channel;
65 | this.original = original;
66 | }
67 |
68 | private static String cleanHost(String hostname) {
69 | String cleaned = hostname;
70 | int zeroIdx = cleaned.indexOf(0);
71 | if (zeroIdx > -1) {
72 | cleaned = hostname.substring(0, zeroIdx);
73 | }
74 |
75 | if (!cleaned.isEmpty() && cleaned.charAt(cleaned.length() - 1) == '.') {
76 | cleaned = cleaned.substring(0, cleaned.length() - 1);
77 | }
78 |
79 | return cleaned;
80 | }
81 |
82 | private void switchState(State oldState, State newState) {
83 | if (Settings.IMP.MAIN.ALLOW_IMPROPER_PINGS) {
84 | return;
85 | }
86 |
87 | if (this.state != oldState) {
88 | if (Settings.IMP.MAIN.LOG_IMPROPER_PINGS) {
89 | this.plugin.getLogger().warn("{} has failed to ping this proxy due to improper packet order: from {} to {}->{}",
90 | this.connection.getRemoteAddress(), this.state, oldState, newState);
91 | }
92 |
93 | throw UNEXPECTED_STATE;
94 | }
95 |
96 | this.state = newState;
97 | }
98 |
99 | private void sendPacket(ByteBuf packet, boolean constant) {
100 | if (Settings.IMP.MAIN.DIRECT_WRITE) {
101 | ChannelOutboundBuffer buffer = this.channel.unsafe().outboundBuffer();
102 | if (buffer == null) {
103 | packet.release(); // connection was closed already, no need to send the packet.
104 | } else {
105 | // .slice() constant packet to ensure that Netty do not modify its readerIndex
106 | if (constant) {
107 | packet = packet.slice();
108 | }
109 |
110 | // Send the packet
111 | buffer.addMessage(packet, packet.readableBytes(), this.channel.voidPromise());
112 | this.channel.flush();
113 | }
114 | } else {
115 | this.channel.writeAndFlush(packet);
116 | }
117 | }
118 |
119 | @Override
120 | public boolean handle(LegacyPingPacket packet) {
121 | this.connection.close();
122 | return true;
123 | }
124 |
125 | @Override
126 | public boolean handle(LegacyHandshakePacket packet) {
127 | this.connection.close();
128 | return true;
129 | }
130 |
131 | @Override
132 | public boolean handle(HandshakePacket handshake) {
133 | if (handshake.getNextStatus() == StateRegistry.STATUS_ID) {
134 | if (handshake.getProtocolVersion() == null || handshake.getProtocolVersion() == ProtocolVersion.UNKNOWN) {
135 | handshake.setProtocolVersion(ProtocolVersion.MAXIMUM_VERSION);
136 |
137 | if (Settings.IMP.MAIN.LOG_PINGS) {
138 | this.plugin.getLogger().info(
139 | "Unknown protocol version detected from {}, replaced with version {}",
140 | this.connection.getRemoteAddress(),
141 | ProtocolVersion.MAXIMUM_VERSION
142 | );
143 | }
144 | }
145 |
146 | this.protocolVersion = handshake.getProtocolVersion();
147 | this.serverAddress = cleanHost(handshake.getServerAddress()) + ":" + handshake.getPort();
148 |
149 | ChannelPipeline pipeline = this.channel.pipeline();
150 | pipeline.remove(Connections.FRAME_ENCODER);
151 | pipeline.get(MinecraftDecoder.class).setState(StateRegistry.STATUS);
152 | MinecraftVarintFrameDecoder frameDecoder = pipeline.get(MinecraftVarintFrameDecoder.class);
153 | if (frameDecoder != null) {
154 | frameDecoder.setState(StateRegistry.STATUS);
155 | }
156 |
157 | if (Settings.IMP.MAIN.LOG_PINGS) {
158 | this.plugin.getLogger().info("{} is pinging the server with version {}", this.connection.getRemoteAddress(), this.protocolVersion);
159 | }
160 | return true;
161 | } else if (handshake.getNextStatus() == StateRegistry.LOGIN_ID
162 | && Settings.IMP.MAINTENANCE.MAINTENANCE_ENABLED && Settings.IMP.MAINTENANCE.SHOULD_KICK_ON_JOIN
163 | && !this.plugin.checkKickWhitelist(((InetSocketAddress) this.connection.getRemoteAddress()).getAddress())) {
164 | this.connection.setProtocolVersion(handshake.getProtocolVersion());
165 | this.channel.pipeline().remove(Connections.FRAME_ENCODER);
166 | this.plugin.inject(this.connection, this.channel.pipeline());
167 | this.connection.closeWith(this.plugin.getKickReason());
168 | }
169 |
170 | return this.original.handle(handshake);
171 | }
172 |
173 | @Override
174 | public void handleGeneric(MinecraftPacket packet) {
175 | if (packet instanceof StatusPingPacket) {
176 | this.switchState(State.PING, State.DONE);
177 | if (Settings.IMP.MAINTENANCE.MAINTENANCE_ENABLED) {
178 | this.connection.close();
179 | return;
180 | }
181 |
182 | ByteBuf buf = Unpooled.directBuffer(11);
183 | buf.writeByte(9);
184 | buf.writeByte(1);
185 | packet.encode(buf, null, null);
186 | this.sendPacket(buf, false);
187 | this.connection.close();
188 | } else if (packet instanceof StatusRequestPacket) {
189 | this.switchState(State.REQUEST, State.PING);
190 | this.sendPacket(this.plugin.getNext(this.protocolVersion, this.serverAddress), true);
191 | } else {
192 | this.original.handleGeneric(packet);
193 | }
194 | }
195 |
196 | @Override
197 | public void handleUnknown(ByteBuf buf) {
198 | this.original.handleUnknown(buf);
199 | }
200 | }
201 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/src/main/java/net/elytrium/fastmotd/FastMOTD.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2022 - 2025 Elytrium
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | package net.elytrium.fastmotd;
19 |
20 | import com.google.inject.Inject;
21 | import com.velocitypowered.api.command.CommandManager;
22 | import com.velocitypowered.api.event.EventManager;
23 | import com.velocitypowered.api.event.Subscribe;
24 | import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
25 | import com.velocitypowered.api.network.ProtocolVersion;
26 | import com.velocitypowered.api.plugin.Plugin;
27 | import com.velocitypowered.api.plugin.annotation.DataDirectory;
28 | import com.velocitypowered.api.proxy.ProxyServer;
29 | import com.velocitypowered.api.proxy.server.ServerPing;
30 | import com.velocitypowered.api.scheduler.ScheduledTask;
31 | import com.velocitypowered.proxy.VelocityServer;
32 | import com.velocitypowered.proxy.connection.MinecraftConnection;
33 | import com.velocitypowered.proxy.network.ConnectionManager;
34 | import com.velocitypowered.proxy.network.ServerChannelInitializerHolder;
35 | import com.velocitypowered.proxy.protocol.StateRegistry;
36 | import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
37 | import io.netty.buffer.ByteBuf;
38 | import io.netty.channel.ChannelInitializer;
39 | import io.netty.channel.ChannelPipeline;
40 | import it.unimi.dsi.fastutil.ints.Int2IntMap;
41 | import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
42 | import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
43 | import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
44 | import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
45 | import it.unimi.dsi.fastutil.ints.IntSet;
46 | import java.lang.reflect.Field;
47 | import java.net.InetAddress;
48 | import java.net.UnknownHostException;
49 | import java.nio.file.Path;
50 | import java.util.ArrayList;
51 | import java.util.Collections;
52 | import java.util.HashMap;
53 | import java.util.List;
54 | import java.util.Map;
55 | import java.util.Objects;
56 | import java.util.Set;
57 | import java.util.concurrent.TimeUnit;
58 | import java.util.stream.Collectors;
59 | import java.util.stream.IntStream;
60 | import net.elytrium.commons.utils.reflection.ReflectionException;
61 | import net.elytrium.commons.utils.updates.UpdatesChecker;
62 | import net.elytrium.fastmotd.command.MaintenanceCommand;
63 | import net.elytrium.fastmotd.command.ReloadCommand;
64 | import net.elytrium.fastmotd.injection.ServerChannelInitializerHook;
65 | import net.elytrium.fastmotd.listener.CompatPingListener;
66 | import net.elytrium.fastmotd.listener.ShutdownOnZeroPlayersListener;
67 | import net.elytrium.fastmotd.utils.MOTDGenerator;
68 | import net.elytrium.fastprepare.PreparedPacket;
69 | import net.elytrium.fastprepare.PreparedPacketFactory;
70 | import net.kyori.adventure.text.Component;
71 | import net.kyori.adventure.text.serializer.ComponentSerializer;
72 | import org.bstats.velocity.Metrics;
73 | import org.slf4j.Logger;
74 |
75 | @Plugin(
76 | id = "fastmotd",
77 | name = "FastMOTD",
78 | version = BuildConstants.VERSION,
79 | description = "MOTD plugin that uses FastPrepareAPI.",
80 | url = "https://elytrium.net/",
81 | authors = {
82 | "Elytrium (https://elytrium.net/)",
83 | }
84 | )
85 | public class FastMOTD {
86 |
87 | private static final Field connectionManager;
88 | private static final Field initializer;
89 |
90 | private final Logger logger;
91 | private final VelocityServer server;
92 | private final Metrics.Factory metricsFactory;
93 | private final Path configPath;
94 | private final List motdGenerators = new ArrayList<>();
95 | private final List maintenanceMOTDGenerators = new ArrayList<>();
96 | private final Int2IntMap protocolPointers = new Int2IntOpenHashMap();
97 | private final Int2IntMap maintenanceProtocolPointers = new Int2IntOpenHashMap();
98 | private final Map domainMOTD = new HashMap<>();
99 | private final Map domainMaintenanceMOTD = new HashMap<>();
100 | private PreparedPacketFactory preparedPacketFactory;
101 | private ScheduledTask updater;
102 | private PreparedPacket kickReason;
103 | private Set kickWhitelist;
104 |
105 | static {
106 | try {
107 | connectionManager = VelocityServer.class.getDeclaredField("cm");
108 | connectionManager.setAccessible(true);
109 |
110 | initializer = ServerChannelInitializerHolder.class.getDeclaredField("initializer");
111 | initializer.setAccessible(true);
112 | } catch (NoSuchFieldException e) {
113 | throw new ReflectionException(e);
114 | }
115 | }
116 |
117 | @Inject
118 | public FastMOTD(Logger logger, ProxyServer server, Metrics.Factory metricsFactory, @DataDirectory Path dataDirectory) {
119 | this.logger = logger;
120 | this.server = (VelocityServer) server;
121 | this.metricsFactory = metricsFactory;
122 | this.configPath = dataDirectory.resolve("config.yml");
123 | }
124 |
125 | @Subscribe
126 | public void onProxyInitialization(ProxyInitializeEvent event) {
127 | try {
128 | ConnectionManager cm = (ConnectionManager) connectionManager.get(this.server);
129 | ChannelInitializer> oldHook = (ChannelInitializer>) initializer.get(cm.serverChannelInitializer);
130 | initializer.set(cm.serverChannelInitializer, new ServerChannelInitializerHook(this, oldHook));
131 | this.logger.info("Hooked into ServerChannelInitializer");
132 | } catch (IllegalAccessException e) {
133 | this.logger.info("Error while hooking into ServerChannelInitializer");
134 | throw new ReflectionException(e);
135 | }
136 |
137 | this.preparedPacketFactory =
138 | new PreparedPacketFactory(PreparedPacket::new, StateRegistry.LOGIN, false, 1, 1, false, true, false);
139 |
140 | this.reload();
141 | }
142 |
143 | public void reload() {
144 | Settings.IMP.reload(this.configPath);
145 |
146 | if (Settings.IMP.MAIN.ENABLE_UPDATES) {
147 | this.server.getScheduler().buildTask(this, () -> {
148 | if (!UpdatesChecker.checkVersionByURL("https://raw.githubusercontent.com/Elytrium/FastMOTD/master/VERSION", Settings.IMP.VERSION)) {
149 | this.logger.error("****************************************");
150 | this.logger.warn("The new FastMOTD update was found, please update.");
151 | this.logger.error("https://github.com/Elytrium/FastMOTD/releases/");
152 | this.logger.error("****************************************");
153 | }
154 | }).schedule();
155 | }
156 | this.metricsFactory.make(this, 15640);
157 |
158 | ComponentSerializer serializer = Settings.IMP.SERIALIZER.getSerializer();
159 | if (serializer == null) {
160 | this.logger.error("Incorrect serializer set: {}", Settings.IMP.SERIALIZER);
161 | return;
162 | }
163 |
164 | this.motdGenerators.forEach(MOTDGenerator::dispose);
165 | this.maintenanceMOTDGenerators.forEach(MOTDGenerator::dispose);
166 | this.domainMOTD.values().forEach(MOTDGenerator::dispose);
167 | this.domainMaintenanceMOTD.values().forEach(MOTDGenerator::dispose);
168 |
169 | this.protocolPointers.clear();
170 | this.motdGenerators.clear();
171 | this.domainMOTD.clear();
172 |
173 | this.maintenanceProtocolPointers.clear();
174 | this.maintenanceMOTDGenerators.clear();
175 | this.domainMaintenanceMOTD.clear();
176 |
177 | CommandManager commandManager = this.server.getCommandManager();
178 | commandManager.unregister("fastmotdreload");
179 | commandManager.unregister("maintenance");
180 |
181 | commandManager.register("fastmotdreload", new ReloadCommand(this));
182 | commandManager.register("maintenance",
183 | new MaintenanceCommand(this, serializer.deserialize(Settings.IMP.MAINTENANCE.COMMAND.USAGE)));
184 |
185 | EventManager eventManager = this.server.getEventManager();
186 | eventManager.unregisterListeners(this);
187 | eventManager.register(this, new CompatPingListener(this));
188 |
189 | if (Settings.IMP.SHUTDOWN_SCHEDULER.SHUTDOWN_SCHEDULER_ENABLED && Settings.IMP.SHUTDOWN_SCHEDULER.SHUTDOWN_ON_ZERO_PLAYERS) {
190 | eventManager.register(this, new ShutdownOnZeroPlayersListener(this));
191 | }
192 |
193 | if (this.updater != null) {
194 | this.updater.cancel();
195 | }
196 |
197 | if (this.kickReason != null) {
198 | this.kickReason.release();
199 | }
200 |
201 | Component kickReasonComponent = serializer.deserialize(Settings.IMP.MAINTENANCE.KICK_MESSAGE.replace("{NL}", "\n"));
202 | this.kickReason = this.preparedPacketFactory
203 | .createPreparedPacket(ProtocolVersion.MINIMUM_VERSION, ProtocolVersion.MAXIMUM_VERSION)
204 | .prepare(version -> DisconnectPacket.create(kickReasonComponent, version, StateRegistry.LOGIN))
205 | .build();
206 |
207 | this.kickWhitelist = Settings.IMP.MAINTENANCE.KICK_WHITELIST.stream().map((String host) -> {
208 | try {
209 | return InetAddress.getByName(host);
210 | } catch (UnknownHostException e) {
211 | throw new IllegalArgumentException(e);
212 | }
213 | }).collect(Collectors.toSet());
214 |
215 | this.generateMOTDGenerators(serializer, Settings.IMP.MAIN.VERSION_NAME, Settings.IMP.MAIN.DESCRIPTIONS,
216 | Settings.IMP.MAIN.FAVICONS, Settings.IMP.MAIN.INFORMATION, this.motdGenerators, this.protocolPointers,
217 | Settings.IMP.MAIN.VERSIONS.DESCRIPTIONS, Settings.IMP.MAIN.VERSIONS.FAVICONS, Settings.IMP.MAIN.VERSIONS.INFORMATION,
218 | Settings.IMP.MAIN.DOMAINS, this.domainMOTD);
219 |
220 | this.generateMOTDGenerators(serializer, Settings.IMP.MAINTENANCE.VERSION_NAME, Settings.IMP.MAINTENANCE.DESCRIPTIONS,
221 | Settings.IMP.MAINTENANCE.FAVICONS, Settings.IMP.MAINTENANCE.INFORMATION, this.maintenanceMOTDGenerators,
222 | this.maintenanceProtocolPointers, Settings.IMP.MAINTENANCE.VERSIONS.DESCRIPTIONS,
223 | Settings.IMP.MAINTENANCE.VERSIONS.FAVICONS, Settings.IMP.MAINTENANCE.VERSIONS.INFORMATION,
224 | Settings.IMP.MAINTENANCE.DOMAINS, this.domainMaintenanceMOTD);
225 |
226 | this.updater = this.server.getScheduler()
227 | .buildTask(this, this::updateMOTD)
228 | .repeat(Settings.IMP.MAIN.UPDATE_RATE, TimeUnit.MILLISECONDS)
229 | .schedule();
230 | }
231 |
232 | private void generateMOTDGenerators(
233 | ComponentSerializer serializer,
234 | String versionName, List defaultDescriptions, List defaultFavicons,
235 | List defaultInformation, List dest, Int2IntMap destPointers,
236 | Map> descriptionVersions, Map> faviconVersions,
237 | Map> informationVersions, Map domainMotd,
238 | Map domainDest) {
239 | descriptionVersions = Objects.requireNonNullElseGet(descriptionVersions, HashMap::new);
240 | faviconVersions = Objects.requireNonNullElseGet(faviconVersions, HashMap::new);
241 | informationVersions = Objects.requireNonNullElseGet(informationVersions, HashMap::new);
242 | List nonNullDefaultDescriptions = Objects.requireNonNullElseGet(defaultDescriptions, Collections::emptyList);
243 | List nonNullDefaultFavicons = Objects.requireNonNullElseGet(defaultFavicons, Collections::emptyList);
244 | List nonNullDefaultInformation = Objects.requireNonNullElseGet(defaultInformation, Collections::emptyList);
245 |
246 | MOTDGenerator defaultMotdGenerator =
247 | new MOTDGenerator(this, serializer, versionName, nonNullDefaultDescriptions, nonNullDefaultFavicons, nonNullDefaultInformation);
248 | defaultMotdGenerator.generate();
249 | dest.add(defaultMotdGenerator);
250 |
251 | Int2ObjectMap> protocolDescriptions = new Int2ObjectOpenHashMap<>();
252 | Int2ObjectMap> protocolIcons = new Int2ObjectOpenHashMap<>();
253 | Int2ObjectMap> protocolInformation = new Int2ObjectOpenHashMap<>();
254 |
255 | this.sortByProtocolVersion(descriptionVersions, protocolDescriptions);
256 | this.sortByProtocolVersion(faviconVersions, protocolIcons);
257 | this.sortByProtocolVersion(informationVersions, protocolInformation);
258 |
259 | IntSet allProtocols = new IntOpenHashSet();
260 | allProtocols.addAll(protocolDescriptions.keySet());
261 | allProtocols.addAll(protocolIcons.keySet());
262 | allProtocols.addAll(protocolInformation.keySet());
263 |
264 | Map, IntSet> protocolsByData = new HashMap<>();
265 |
266 | allProtocols.forEach(protocol -> {
267 | List key = new ArrayList<>();
268 | key.addAll(protocolDescriptions.getOrDefault(protocol, nonNullDefaultDescriptions));
269 | key.addAll(protocolIcons.getOrDefault(protocol, nonNullDefaultFavicons));
270 | key.addAll(protocolInformation.getOrDefault(protocol, nonNullDefaultInformation));
271 | protocolsByData.computeIfAbsent(key, k -> new IntOpenHashSet()).add(protocol);
272 | });
273 |
274 | protocolsByData.values().forEach(identical -> {
275 | final int idx = dest.size();
276 | final int key = identical.iterator().nextInt();
277 | MOTDGenerator motdGenerator = new MOTDGenerator(this, serializer, versionName,
278 | protocolDescriptions.getOrDefault(key, nonNullDefaultDescriptions),
279 | protocolIcons.getOrDefault(key, nonNullDefaultFavicons),
280 | protocolInformation.getOrDefault(key, nonNullDefaultInformation));
281 | motdGenerator.generate();
282 | dest.add(motdGenerator);
283 | identical.forEach(p -> destPointers.put(p, idx));
284 | });
285 |
286 | domainMotd.forEach((domain, motdNode) -> {
287 | MOTDGenerator motdGenerator = new MOTDGenerator(this, serializer, versionName,
288 | motdNode.DESCRIPTION, motdNode.FAVICON, motdNode.INFORMATION);
289 | motdGenerator.generate();
290 | domainDest.put(domain, motdGenerator);
291 | });
292 | }
293 |
294 | private void sortByProtocolVersion(Map> src, Int2ObjectMap> dest) {
295 | src.forEach((key, value) -> {
296 | IntStream range;
297 | if (key.contains("-")) {
298 | String[] parts = key.split("-");
299 | range = IntStream.rangeClosed(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]));
300 | } else {
301 | range = IntStream.of(Integer.parseInt(key));
302 | }
303 | range.forEach(protocol -> dest.computeIfAbsent(protocol, p -> new ArrayList<>()).addAll(value));
304 | });
305 | }
306 |
307 | private void updateMOTD() {
308 | int online = this.getOnline();
309 | int max = this.getMax(online);
310 |
311 | for (MOTDGenerator generator : this.motdGenerators) {
312 | generator.update(max, online);
313 | }
314 |
315 | for (MOTDGenerator generator : this.domainMOTD.values()) {
316 | generator.update(max, online);
317 | }
318 |
319 | if (Settings.IMP.MAINTENANCE.OVERRIDE_MAX_ONLINE != -1) {
320 | max = Settings.IMP.MAINTENANCE.OVERRIDE_MAX_ONLINE;
321 | }
322 |
323 | if (Settings.IMP.MAINTENANCE.OVERRIDE_ONLINE != -1) {
324 | online = Settings.IMP.MAINTENANCE.OVERRIDE_ONLINE;
325 | }
326 |
327 | for (MOTDGenerator generator : this.maintenanceMOTDGenerators) {
328 | generator.update(max, online);
329 | }
330 |
331 | for (MOTDGenerator generator : this.domainMaintenanceMOTD.values()) {
332 | generator.update(max, online);
333 | }
334 | }
335 |
336 | private int getOnline() {
337 | int online = this.server.getPlayerCount() + Settings.IMP.MAIN.FAKE_ONLINE_ADD_SINGLE;
338 | return online * (Settings.IMP.MAIN.FAKE_ONLINE_ADD_PERCENT + 100) / 100;
339 | }
340 |
341 | private int getMax(int online) {
342 | int max;
343 | MaxCountType type = Settings.IMP.MAIN.MAX_COUNT_TYPE;
344 | max = switch (type) {
345 | case ADD_SOME -> online + Settings.IMP.MAIN.MAX_COUNT;
346 | case VARIABLE -> Settings.IMP.MAIN.MAX_COUNT;
347 | };
348 |
349 | return max;
350 | }
351 |
352 | public ByteBuf getNext(ProtocolVersion version, String serverAddress) {
353 | if (Settings.IMP.MAINTENANCE.MAINTENANCE_ENABLED) {
354 | return this.domainMaintenanceMOTD.getOrDefault(serverAddress, this.maintenanceMOTDGenerators.get(
355 | this.maintenanceProtocolPointers.getOrDefault(version.getProtocol(), 0)))
356 | .getNext(version, !Settings.IMP.MAINTENANCE.SHOW_VERSION);
357 | } else {
358 | return this.domainMOTD.getOrDefault(serverAddress, this.motdGenerators.get(
359 | this.protocolPointers.getOrDefault(version.getProtocol(), 0)))
360 | .getNext(version, true);
361 | }
362 | }
363 |
364 | public ServerPing getNextCompat(ProtocolVersion version, String serverAddress) {
365 | if (Settings.IMP.MAINTENANCE.MAINTENANCE_ENABLED) {
366 | return this.domainMaintenanceMOTD.getOrDefault(serverAddress, this.maintenanceMOTDGenerators.get(
367 | this.maintenanceProtocolPointers.getOrDefault(version.getProtocol(), 0)))
368 | .getNextCompat(version, !Settings.IMP.MAINTENANCE.SHOW_VERSION);
369 | } else {
370 | return this.domainMOTD.getOrDefault(serverAddress, this.motdGenerators.get(
371 | this.protocolPointers.getOrDefault(version.getProtocol(), 0)))
372 | .getNextCompat(version, true);
373 | }
374 | }
375 |
376 | public void inject(MinecraftConnection connection, ChannelPipeline pipeline) {
377 | this.preparedPacketFactory.inject(false, connection, pipeline);
378 | }
379 |
380 | public boolean checkKickWhitelist(InetAddress inetAddress) {
381 | return this.kickWhitelist.contains(inetAddress);
382 | }
383 |
384 | public VelocityServer getServer() {
385 | return this.server;
386 | }
387 |
388 | public Logger getLogger() {
389 | return this.logger;
390 | }
391 |
392 | public PreparedPacket getKickReason() {
393 | return this.kickReason;
394 | }
395 |
396 | public Path getConfigPath() {
397 | return this.configPath;
398 | }
399 |
400 | public enum MaxCountType {
401 |
402 | VARIABLE,
403 | ADD_SOME
404 | }
405 | }
406 |
--------------------------------------------------------------------------------
/config/checkstyle/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
59 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
76 |
77 |
78 |
80 |
81 |
82 |
88 |
89 |
90 |
91 |
94 |
95 |
96 |
97 |
98 |
102 |
103 |
104 |
105 |
106 |
108 |
109 |
110 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
129 |
131 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
179 |
180 |
181 |
183 |
185 |
186 |
187 |
188 |
190 |
191 |
192 |
193 |
195 |
196 |
197 |
198 |
200 |
201 |
202 |
203 |
205 |
206 |
207 |
208 |
210 |
211 |
212 |
213 |
215 |
216 |
217 |
218 |
220 |
221 |
222 |
223 |
225 |
226 |
227 |
228 |
230 |
231 |
232 |
233 |
235 |
236 |
237 |
238 |
240 |
241 |
242 |
243 |
245 |
247 |
249 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
281 |
282 |
283 |
286 |
287 |
288 |
289 |
295 |
296 |
297 |
298 |
302 |
303 |
304 |
305 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
320 |
321 |
322 |
323 |
324 |
325 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
341 |
342 |
343 |
344 |
347 |
348 |
349 |
350 |
351 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
365 |
366 |
367 |
368 |
369 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 |
633 | Copyright (C)
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published
637 | by the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
662 |
--------------------------------------------------------------------------------