Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/build-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build Nightly

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: '9.6.1'

- name: Build
run: gradle build

- name: Get current date
id: date
run: echo "timestamp=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT

- name: Upload nightly release
uses: softprops/action-gh-release@v2
with:
tag_name: nightly
name: "Nightly build"
body: |
Unstable build of Tokyo.
```txt
${{ steps.date.outputs.timestamp }}
```
files: |
Tokyo/build/libs/*.jar
TokyoAPI/build/libs/*.jar
TokyoTest/build/libs/*.jar
allow_updates: true
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: '8.5'
gradle-version: '9.6.1'

- name: Build
run: gradle build

- name: Upload
uses: actions/upload-artifact@v4
with:
name: CherryBuild
name: TokyoBuild
path: |
Tokyo/build/libs/*.jar
TokyoAPI/build/libs/*.jar
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

```txt
Простой майнкрафт сервер, над которым я работаю.
Базируется на Minestom, версии 1.21.4
Базируется на Minestom, версии 26.2
(Для версии новее нужна более новая IDE
(Нууу вообще нет, но IDE моей версии не поддерживает 9 Gradle нативно))

Expand Down Expand Up @@ -56,7 +56,7 @@ Lavender
(Идея реализации Bukkit API & Spigot API)
(Само ядро их содержать не будет, но будет модуль совместимости)
Оригинальный репо: https://github.com/wildmaster84/Lavender
Реализация: https://github.com/DestroyTokyo/DeBukkit
Реализация: https://github.com/DestroyTokyo/DeBukkit
```


Expand Down
3 changes: 1 addition & 2 deletions Tokyo/src/main/java/delta/cion/tokyo/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import delta.cion.tokyo.api.plugin.Plugin;
import delta.cion.tokyo.api.ServerBranding;
import delta.cion.tokyo.api.locales.Localize;
import delta.cion.tokyo.api.online.WhiteList;
import delta.cion.tokyo.api.online.lists.WhiteList;
import delta.cion.tokyo.api.permission.PermissionHandler;
import delta.cion.tokyo.server.command.*;
import delta.cion.tokyo.server.command.*;
import delta.cion.tokyo.server.config.property.PropertiesHandler;
import delta.cion.tokyo.server.console.ConsoleHandler;
import delta.cion.tokyo.server.console.DeExceptionManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import delta.cion.tokyo.api.command.DeltaCommand;
import delta.cion.tokyo.api.locales.Localize;
import delta.cion.tokyo.api.online.WhiteList;
import delta.cion.tokyo.api.online.lists.WhiteList;
import delta.cion.tokyo.api.permission.PermissionManager;
import net.minestom.server.command.CommandSender;
import net.minestom.server.command.builder.Command;
Expand Down
44 changes: 26 additions & 18 deletions Tokyo/src/main/java/delta/cion/tokyo/server/motd/MOTDHandler.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package delta.cion.tokyo.server.motd;

import delta.cion.tokyo.api.ServerBranding;
import delta.cion.tokyo.api.online.ServerMOTD;
import delta.cion.tokyo.server.Server;
import net.minestom.server.MinecraftServer;
import net.minestom.server.entity.Player;
import net.minestom.server.event.server.ServerListPingEvent;
import net.minestom.server.network.player.PlayerConnection;
import net.minestom.server.ping.ResponseData;
import delta.cion.tokyo.api.event.DeltaEvent;
import net.minestom.server.utils.identity.NamedAndIdentified;
import net.minestom.server.ping.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -18,7 +18,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Consumer;

Expand All @@ -36,32 +36,40 @@ public class MOTDHandler {

Collection<Player> players = MinecraftServer.getConnectionManager().getOnlinePlayers();

ResponseData response = new ServerMOTD()
.setMOTDVersion(ServerBranding.getBrandName() + " 1.21.4")
.setMOTDDescription(ServerBranding.getBrandName() + " Server")
.setMOTDMaxPlayer(players.size())
.setMOTDOnline(-1)
.get();
String serverDescription = ServerBranding.getBrandName() + " Server";

Status.Builder rawResponse = new ServerMOTD()
.setMOTDVersion(ServerBranding.getBrandName() + " " + MinecraftServer.VERSION_NAME)
.setMOTDDescription(serverDescription)
.getRaw();

for (Player player : players)
response.addEntry(NamedAndIdentified.of(player.getName(), player.getUuid()));
if (buildServerIcon() != null) response.setFavicon(buildServerIcon());
event.setResponseData(response);
rawResponse.playerInfo(Status.PlayerInfo.builder()
.onlinePlayers(players.size())
.maxPlayers(-1)
.sample(new ArrayList<>(players))
.build()
);

if (buildServerIcon() != null)
rawResponse.favicon(buildServerIcon());

Status response = rawResponse.build();

event.setStatus(response);
};

private static String buildServerIcon() {
private static byte[] buildServerIcon() {
if (!SERVER_ICON.toFile().exists()) return null;

try {
byte[] data = Files.readAllBytes(SERVER_ICON);
BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));

if (image == null) return null;
if (image.getWidth() != image.getHeight()
|| image.getHeight() > 64) return null;
if (image.getWidth() > 64) return null;
if (image.getWidth() != image.getHeight()) return null;

String base64 = Base64.getEncoder().encodeToString(data);
return "data:image/png;base64," + base64;
return data;
} catch (IOException e) {
LOGGER.warn("Incorrect image {}", SERVER_ICON);
return null;
Expand Down
49 changes: 0 additions & 49 deletions Tokyo/src/main/java/delta/cion/tokyo/server/motd/ServerMOTD.java

This file was deleted.

3 changes: 2 additions & 1 deletion TokyoAPI/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ group = "delta.cion.tokyo.api"
version = projectVersion

dependencies {
implementation("net.minestom:minestom-snapshots:$minestomVersion")
// net.minestom:minestom-snapshots =< 26.2
implementation("net.minestom:minestom:$minestomVersion")
implementation("ch.qos.logback:logback-classic:${logbackVersion}")
implementation("com.github.luben:zstd-jni:${zstdVersion}")
implementation("org.json:json:${jsonVersion}")
Expand Down

This file was deleted.

This file was deleted.

58 changes: 58 additions & 0 deletions TokyoAPI/src/main/java/delta/cion/tokyo/api/online/ServerMOTD.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package delta.cion.tokyo.api.online;

import net.kyori.adventure.text.Component;
import net.minestom.server.ping.Status;

public class ServerMOTD {

private final Status.Builder RESPONSE;

public ServerMOTD() {
this.RESPONSE = Status.builder();
}

public ServerMOTD setMOTDFavicon(byte[] b) {
this.RESPONSE.favicon(b);
return this;
}

public ServerMOTD setMOTDOnline(int online, int max) {
this.RESPONSE.playerInfo(online, max);
return this;
}

public ServerMOTD setMOTDPlayerInfo(Status.PlayerInfo playerInfo) {
this.RESPONSE.playerInfo(playerInfo);
return this;
}

public ServerMOTD setMOTDVersion(String s) {
this.RESPONSE.versionInfo(new Status.VersionInfo(s, Status.VersionInfo.DEFAULT.protocolVersion()));
return this;
}

public ServerMOTD setMOTDVersion(String s, int protocolVersion) {
this.RESPONSE.versionInfo(new Status.VersionInfo(s, protocolVersion));
return this;
}

@SuppressWarnings("deprecation")
public ServerMOTD setMOTDDescription(String s) {
this.RESPONSE.description(Component.text(s));
return this;
}

public ServerMOTD setMOTDDescription(Component c) {
this.RESPONSE.description(c);
return this;
}

public Status get() {
return this.RESPONSE.build();
}

public Status.Builder getRaw() {
return this.RESPONSE;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package delta.cion.tokyo.api.online.lists;

public class BanList {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package delta.cion.tokyo.api.online.lists;

public class OpsList {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package delta.cion.tokyo.api.online;
package delta.cion.tokyo.api.online.lists;

import java.time.LocalDateTime;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package delta.cion.tokyo.api.online;
package delta.cion.tokyo.api.online.lists;

import net.minestom.server.MinecraftServer;
import net.minestom.server.entity.Player;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Util package. I think I can move it to core
* Contain online handlers.
* like motd or ban-/ops-/white-lists
*/

package delta.cion.tokyo.api.online;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package delta.cion.tokyo.test_plugin.event;

import delta.cion.tokyo.api.locales.Localize;
import delta.cion.tokyo.api.online.WhiteList;
import delta.cion.tokyo.api.online.lists.WhiteList;
import delta.cion.tokyo.api.event.DeltaEvent;
import delta.cion.tokyo.test_plugin.TestPlugin;
import delta.cion.tokyo.test_plugin.util.InfoBook;
Expand Down
Loading
Loading