forked from QuiltServerTools/HeyThatsMine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTM.java
More file actions
48 lines (42 loc) · 2.23 KB
/
HTM.java
File metadata and controls
48 lines (42 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
package com.github.fabricservertools.htm;
import com.github.fabricservertools.htm.api.Lock;
import com.github.fabricservertools.htm.command.HTMCommand;
import com.github.fabricservertools.htm.command.subcommands.*;
import com.github.fabricservertools.htm.config.HTMConfig;
import com.github.fabricservertools.htm.interactions.InteractionManager;
import com.github.fabricservertools.htm.listeners.PlayerEventListener;
import com.github.fabricservertools.htm.listeners.LevelEventListener;
import com.mojang.brigadier.CommandDispatcher;
import eu.pb4.common.protection.api.CommonProtection;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.resources.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class HTM implements ModInitializer {
public static final Logger LOGGER = LogManager.getLogger("HTM");
@Override
public void onInitialize() {
// For some reason, the Lock class has to be loaded before the HTMConfig class for the codecs to be initialised properly
// Calling a method of the class loads it. Removing the line below results in an NPE when launching Minecraft
Lock.bootstrap();
HTMConfig.load();
CommandRegistrationCallback.EVENT.register(((dispatcher, environment, registryAccess) -> registerCommands(dispatcher)));
CommonProtection.register(Identifier.fromNamespaceAndPath("htm", "containers"), new InteractionManager());
PlayerEventListener.init();
LevelEventListener.init();
}
private void registerCommands(CommandDispatcher<CommandSourceStack> dispatcher) {
HTMCommand.registerSubCommand(new SetCommand());
HTMCommand.registerSubCommand(new RemoveCommand());
HTMCommand.registerSubCommand(new TrustCommand());
HTMCommand.registerSubCommand(new UntrustCommand());
HTMCommand.registerSubCommand(new InfoCommand());
HTMCommand.registerSubCommand(new TransferCommand());
HTMCommand.registerSubCommand(new FlagCommand());
HTMCommand.registerSubCommand(new PersistCommand());
HTMCommand.registerSubCommand(new QuietCommand());
HTMCommand.register(dispatcher);
}
}