Update to Minecraft 1.21.8, add checkstyle, fix compilation errors

- Update Paper API: 1.20.1 -> 1.21.4
- Update plugin version: 1.5.5-1.20.1 -> 1.5.5-1.21.8
- Add checkstyle plugin with reasonable rules
- Fix Enchantment.LUCK -> Enchantment.UNBREAKING
- Fix EntityType.FIREWORK -> EntityType.FIREWORK_ROCKET
- Remove unused imports
- Add temp_*/ to .gitignore
- 118 files changed, 1633 insertions(+), 1301 deletions(-)
This commit is contained in:
loki5512344 2026-02-24 00:04:03 +01:00
parent 6a4c8a7886
commit e78d8a2de4
121 changed files with 1792 additions and 1301 deletions

View file

@ -1,5 +1,6 @@
plugins {
java
checkstyle
}
repositories {
@ -12,7 +13,7 @@ dependencies {
compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
implementation("com.google.code.gson:gson:2.10.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.10.0")
@ -23,3 +24,17 @@ tasks.jar {
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
checkstyle {
toolVersion = "10.12.5"
configFile = file("${rootProject.rootDir}/config/checkstyle/checkstyle.xml")
isIgnoreFailures = false
maxWarnings = 0
}
tasks.withType<Checkstyle> {
reports {
xml.required.set(false)
html.required.set(true)
}
}

View file

@ -13,52 +13,52 @@ import org.slf4j.Logger;
import java.nio.file.Path;
@Plugin(
id = "lovelocity",
name = "LoVelocity",
version = "1.5.5",
description = "Velocity integration for LoNetwork",
authors = {"loki"}
id = "lovelocity",
name = "LoVelocity",
version = "1.5.5",
description = "Velocity integration for LoNetwork",
authors = {"loki"}
)
public class LoVelocity {
private final ProxyServer server;
private final Logger logger;
private final Path dataDirectory;
@Inject
public LoVelocity(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
this.server = server;
this.logger = logger;
this.dataDirectory = dataDirectory;
}
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
logger.info("LoVelocity loaded!");
logger.info("Version: 1.5.5");
registerCommands();
}
private void registerCommands() {
CommandMeta hubMeta = server.getCommandManager().metaBuilder("hub")
.aliases("lobby")
.plugin(this)
.build();
.aliases("lobby")
.plugin(this)
.build();
server.getCommandManager().register(hubMeta, new HubCommand(this));
logger.info("Commands registered: /hub, /lobby");
}
public ProxyServer getServer() {
return server;
}
public Logger getLogger() {
return logger;
}
public Path getDataDirectory() {
return dataDirectory;
}

View file

@ -12,66 +12,66 @@ import java.util.Optional;
import java.util.concurrent.CompletableFuture;
public class HubCommand implements SimpleCommand {
private final LoVelocity plugin;
private final List<String> hubServers = List.of("hub", "lobby");
public HubCommand(LoVelocity plugin) {
this.plugin = plugin;
}
@Override
public void execute(Invocation invocation) {
if (!(invocation.source() instanceof Player player)) {
invocation.source().sendMessage(Component.text("This command is only for players!", NamedTextColor.RED));
return;
}
Optional<RegisteredServer> currentServer = player.getCurrentServer().map(s -> s.getServer());
if (currentServer.isEmpty()) {
player.sendMessage(Component.text("Failed to determine current server!", NamedTextColor.RED));
return;
}
String currentServerName = currentServer.get().getServerInfo().getName().toLowerCase();
if (isHubServer(currentServerName)) {
player.sendMessage(Component.text("You are already on the hub!", NamedTextColor.YELLOW));
return;
}
Optional<RegisteredServer> hubServer = findHubServer();
if (hubServer.isEmpty()) {
player.sendMessage(Component.text("Hub server not found!", NamedTextColor.RED));
plugin.getLogger().warn("Hub server not found! Available servers: " +
plugin.getServer().getAllServers().stream()
.map(s -> s.getServerInfo().getName())
.toList());
plugin.getLogger().warn("Hub server not found! Available servers: " +
plugin.getServer().getAllServers().stream()
.map(s -> s.getServerInfo().getName())
.toList());
return;
}
player.sendMessage(Component.text("Teleporting to hub...", NamedTextColor.GREEN));
player.createConnectionRequest(hubServer.get()).fireAndForget();
}
private boolean isHubServer(String serverName) {
return hubServers.stream().anyMatch(hub -> serverName.contains(hub));
}
private Optional<RegisteredServer> findHubServer() {
return plugin.getServer().getAllServers().stream()
.filter(server -> isHubServer(server.getServerInfo().getName().toLowerCase()))
.findFirst();
.filter(server -> isHubServer(server.getServerInfo().getName().toLowerCase()))
.findFirst();
}
@Override
public CompletableFuture<List<String>> suggestAsync(Invocation invocation) {
return CompletableFuture.completedFuture(List.of());
}
@Override
public boolean hasPermission(Invocation invocation) {
return invocation.source().hasPermission("lovelocity.hub");