Skip to content

Commit

Permalink
sync with sakura-ryoko/servux
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Aug 30, 2024
1 parent 433768d commit 663c321
Show file tree
Hide file tree
Showing 46 changed files with 1,496 additions and 421 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ publisher {
setChangelog(file("CHANGELOG.md").getText("UTF-8"))
setVersion("${project.version}")
setDisplayName("${project.version}")
setGameVersions(libs.versions.minecraft.range.get())
setGameVersions("1.21", "1.21.1")
setLoaders(loom.platform.get().id())
setCurseEnvironment("server")
setArtifact(remapJar)
Expand Down
13 changes: 5 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
[versions]

minecraft-range="1.21"

# Base properties
minecraft_version="1.21"
yarn_mappings="1.21+build.2"
minecraft_version="1.21.1"
yarn_mappings="1.21.1+build.3"
mappings_patch="1.21+build.4"
neoforge="21.0.60-beta"
neoforge="21.1.31"

# Mod properties
version="0.1.2"
maven-group="org.thinkingstudio"
version="0.1.3"
maven-group="org.thinkingstudio.servuxforged"
archives-name="ServuxForged"

# Publish properties
Expand Down
24 changes: 8 additions & 16 deletions src/main/java/fi/dy/masa/servux/Servux.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,21 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import fi.dy.masa.servux.dataproviders.*;
import fi.dy.masa.servux.event.PlayerHandler;
import fi.dy.masa.servux.servux.PlayerListener;
import fi.dy.masa.servux.event.ServerHandler;
import fi.dy.masa.servux.servux.ServerListener;
import fi.dy.masa.servux.commands.CommandProvider;
import fi.dy.masa.servux.commands.ServuxCommand;
import fi.dy.masa.servux.dataproviders.ServuxConfigProvider;
import fi.dy.masa.servux.event.ServerInitHandler;
import fi.dy.masa.servux.servux.ServuxInitHandler;

public class Servux
{
public static final Logger logger = LogManager.getLogger(Reference.MOD_ID);

public static void onInitialize()
{
DataProviderManager.INSTANCE.registerDataProvider(ServuxConfigProvider.INSTANCE);
DataProviderManager.INSTANCE.registerDataProvider(LitematicsDataProvider.INSTANCE);
DataProviderManager.INSTANCE.registerDataProvider(EntitiesDataProvider.INSTANCE);
DataProviderManager.INSTANCE.registerDataProvider(StructureDataProvider.INSTANCE);
//DataProviderManager.INSTANCE.registerDataProvider(TweaksDataProvider.INSTANCE);

ServerListener serverListener = new ServerListener();
ServerHandler.getInstance().registerServerHandler(serverListener);

PlayerListener playerListener = new PlayerListener();
PlayerHandler.getInstance().registerPlayerHandler(playerListener);
ServerInitHandler.getInstance().registerServerInitHandler(new ServuxInitHandler());
CommandProvider.getInstance().registerCommand(new ServuxCommand());
// Command Manager gets called before the Init Manager onServerInit()
}

public static void debugLog(String msg, Object... args)
Expand Down
30 changes: 24 additions & 6 deletions src/main/java/fi/dy/masa/servux/commands/CommandProvider.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
package fi.dy.masa.servux.commands;

import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.ApiStatus;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import fi.dy.masa.servux.interfaces.IServerCommand;

public class CommandProvider
public class CommandProvider implements ICommandProvider
{
private static final CommandProvider INSTANCE = new CommandProvider();
public static CommandProvider getInstance() { return INSTANCE; }
private final List<IServerCommand> commands = new ArrayList<>();
public static ICommandProvider getInstance() { return INSTANCE; }

/**
* The idea here is to eventually create a more Robust Command Provider, using an interface
*/
@Override
public void registerCommand(IServerCommand command)
{
if (!this.commands.contains(command))
{
this.commands.add(command);
}
}

@Override
public void unregisterCommand(IServerCommand command)
{
this.commands.remove(command);
}

@ApiStatus.Internal
public void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher,
CommandRegistryAccess registryAccess,
CommandManager.RegistrationEnvironment environment)
{
ServuxCommand.register(dispatcher);
this.commands.forEach((command) -> command.register(dispatcher, registryAccess, environment));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package fi.dy.masa.servux.commands;

import fi.dy.masa.servux.interfaces.IServerCommand;

public interface ICommandProvider
{
void registerCommand(IServerCommand command);
void unregisterCommand(IServerCommand command);
}
Loading

0 comments on commit 663c321

Please sign in to comment.