Skip to content
This repository was archived by the owner on Nov 24, 2022. It is now read-only.

Commit 516ebea

Browse files
authored
Merge pull request #101 from DrexHD/Beta
1.16 Pre7 and Command reworks
2 parents 4a42a9b + fd11b07 commit 516ebea

41 files changed

Lines changed: 179 additions & 180 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ org.gradle.jvmargs=-Xmx2G
33

44
# Fabric Properties
55
# check these on https://fabricmc.net/use or on https://modmuss50.me/fabric.html
6-
minecraft_version=1.16-pre3
7-
yarn_mappings=1.16-pre3+build.1
6+
minecraft_version=1.16-pre7
7+
yarn_mappings=1.16-pre7+build.1
88
loader_version=0.8.7+build.201
99

1010
# Mod Properties
11-
mod_version = 1.9.8.6
12-
mod_version_nick = NearTheEnd
11+
mod_version = 1.9.9.0
12+
mod_version_nick = TheFutureIsOurs
1313
maven_group = org.kilocraft.essentials
1414
archives_base_name = kilo_essentials
1515
build = 0

src/main/java/org/kilocraft/essentials/KiloCommands.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import org.kilocraft.essentials.api.command.EssentialCommand;
3030
import org.kilocraft.essentials.api.command.IEssentialCommand;
3131
import org.kilocraft.essentials.api.event.commands.OnCommandExecutionEvent;
32+
import org.kilocraft.essentials.api.feature.ConfigurableFeatures;
33+
import org.kilocraft.essentials.api.server.Server;
3234
import org.kilocraft.essentials.api.user.CommandSourceUser;
3335
import org.kilocraft.essentials.chat.KiloChat;
3436
import org.kilocraft.essentials.chat.LangText;
@@ -59,8 +61,15 @@
5961
import org.kilocraft.essentials.commands.world.TimeCommand;
6062
import org.kilocraft.essentials.config.KiloConfig;
6163
import org.kilocraft.essentials.events.commands.OnCommandExecutionEventImpl;
64+
import org.kilocraft.essentials.extensions.betterchairs.SeatManager;
65+
import org.kilocraft.essentials.extensions.customcommands.CustomCommands;
66+
import org.kilocraft.essentials.extensions.magicalparticles.ParticleAnimationManager;
67+
import org.kilocraft.essentials.extensions.playtimecommands.PlaytimeCommands;
68+
import org.kilocraft.essentials.extensions.warps.playerwarps.PlayerWarpsManager;
69+
import org.kilocraft.essentials.extensions.warps.serverwidewarps.ServerWarpManager;
6270
import org.kilocraft.essentials.simplecommand.SimpleCommand;
6371
import org.kilocraft.essentials.simplecommand.SimpleCommandManager;
72+
import org.kilocraft.essentials.user.UserHomeHandler;
6473
import org.kilocraft.essentials.util.messages.nodes.ArgExceptionMessageNode;
6574
import org.kilocraft.essentials.util.messages.nodes.ExceptionMessageNode;
6675
import org.kilocraft.essentials.util.text.Texter;
@@ -79,15 +88,32 @@
7988
public class KiloCommands {
8089
private final List<IEssentialCommand> commands;
8190
private final CommandDispatcher<ServerCommandSource> dispatcher;
82-
private final SimpleCommandManager simpleCommandManager;
91+
private SimpleCommandManager simpleCommandManager;
8392
private static LiteralCommandNode<ServerCommandSource> rootNode;
93+
private static KiloCommands instance;
94+
8495

8596
public KiloCommands() {
97+
KiloCommands.instance = this;
8698
this.dispatcher = KiloEssentialsImpl.commandDispatcher;
87-
this.simpleCommandManager = new SimpleCommandManager(KiloServer.getServer(), this.dispatcher);
8899
this.commands = new ArrayList<>();
89100
KiloCommands.rootNode = literal("essentials").executes(this::sendInfo).build();
101+
this.simpleCommandManager = new SimpleCommandManager();
90102
registerDefaults();
103+
registerFeatures();
104+
}
105+
106+
public void registerFeatures() {
107+
ConfigurableFeatures FEATURES = new ConfigurableFeatures();
108+
FEATURES.tryToRegister(new UserHomeHandler(), "playerHomes");
109+
FEATURES.tryToRegister(new ServerWarpManager(), "serverWideWarps");
110+
FEATURES.tryToRegister(new PlayerWarpsManager(), "playerWarps");
111+
FEATURES.tryToRegister(new SeatManager(), "betterChairs");
112+
FEATURES.tryToRegister(new CustomCommands(), "customCommands");
113+
FEATURES.tryToRegister(new ParticleAnimationManager(), "magicalParticles");
114+
FEATURES.tryToRegister(new DiscordCommand(), "discordCommand");
115+
FEATURES.tryToRegister(new VoteCommand(), "voteCommand");
116+
FEATURES.tryToRegister(new PlaytimeCommands(), "playtimeCommands");
91117
}
92118

93119
public static boolean hasPermission(final ServerCommandSource src, final CommandPermission perm) {
@@ -503,6 +529,13 @@ public static CommandDispatcher<ServerCommandSource> getDispatcher() {
503529
return KiloEssentialsImpl.commandDispatcher;
504530
}
505531

532+
public static KiloCommands getInstance() {
533+
if (KiloCommands.instance != null) {
534+
return KiloCommands.instance;
535+
}
536+
throw new RuntimeException("Its too early to get a static instance of KiloCommands!");
537+
}
538+
506539
private boolean isCommand(final String literal) {
507540
return this.dispatcher.getRoot().getChild(literal) != null;
508541
}

src/main/java/org/kilocraft/essentials/KiloEssentialsImpl.java

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
import org.kilocraft.essentials.api.KiloEssentials;
1313
import org.kilocraft.essentials.api.KiloServer;
1414
import org.kilocraft.essentials.api.ModConstants;
15+
import org.kilocraft.essentials.api.feature.ConfigurableFeature;
1516
import org.kilocraft.essentials.api.feature.ConfigurableFeatures;
1617
import org.kilocraft.essentials.api.server.Server;
1718
import org.kilocraft.essentials.api.user.CommandSourceUser;
1819
import org.kilocraft.essentials.api.user.NeverJoinedUser;
1920
import org.kilocraft.essentials.api.user.OnlineUser;
2021
import org.kilocraft.essentials.api.user.User;
21-
import org.kilocraft.essentials.api.util.Litebans2Vanilla;
2222
import org.kilocraft.essentials.chat.ServerChat;
2323
import org.kilocraft.essentials.commands.CommandUtils;
2424
import org.kilocraft.essentials.commands.misc.DiscordCommand;
@@ -32,13 +32,11 @@
3232
import org.kilocraft.essentials.extensions.warps.serverwidewarps.ServerWarpManager;
3333
import org.kilocraft.essentials.user.ServerUserManager;
3434
import org.kilocraft.essentials.user.UserHomeHandler;
35-
import org.kilocraft.essentials.util.MutedPlayerList;
3635
import org.kilocraft.essentials.util.PermissionUtil;
3736
import org.kilocraft.essentials.util.StartupScript;
3837
import org.kilocraft.essentials.util.messages.MessageUtil;
3938
import org.kilocraft.essentials.util.messages.nodes.ExceptionMessageNode;
4039

41-
import java.io.File;
4240
import java.io.IOException;
4341
import java.util.List;
4442
import java.util.Optional;
@@ -57,66 +55,44 @@
5755
*/
5856

5957
public final class KiloEssentialsImpl implements KiloEssentials {
60-
private static boolean running = false;
58+
public static boolean running = false;
6159
private static final Logger LOGGER = LogManager.getLogger("KiloEssentials");
6260
private static KiloEssentialsImpl instance;
6361

64-
private final ConfigurableFeatures FEATURES;
65-
private final KiloCommands commands;
66-
67-
private PermissionUtil permUtil;
62+
private PermissionUtil permUtil;
6863
private StartupScript startupScript;
6964

7065
public static CommandDispatcher<ServerCommandSource> commandDispatcher;
7166

72-
public static void onServerSet(@NotNull final Server server) {
67+
public static void onServerSet(final Server server) {
7368
KiloDebugUtils.validateDebugMode(false);
74-
new KiloEssentialsImpl();
75-
}
76-
77-
KiloEssentialsImpl() {
78-
if (running) {
79-
throw new RuntimeException("KiloEssentialsImpl is already running!");
80-
} else {
81-
running = true;
82-
}
83-
84-
KiloEssentialsImpl.instance = this;
85-
KiloEssentialsImpl.LOGGER.info("Running KiloEssentials version " + ModConstants.getVersion());
86-
87-
KiloConfig.load();
8869
try {
8970
getServer().getUserManager().getMutedPlayerList().load();
9071
} catch (IOException e) {
9172
KiloEssentials.getLogger().error("An unexpected error occurred while loading the Muted Player List", e);
9273
}
9374
new KiloEvents();
94-
this.commands = new KiloCommands();
75+
}
76+
77+
78+
79+
public KiloEssentialsImpl() {
80+
if (running) {
81+
throw new RuntimeException("KiloEssentialsImpl is already running!");
82+
} else {
83+
running = true;
84+
}
85+
KiloEssentialsImpl.instance = this;
86+
KiloEssentialsImpl.LOGGER.info("Running KiloEssentials version " + ModConstants.getVersion());
9587

9688
if (SharedConstants.isDevelopment) {
9789
new KiloDebugUtils();
9890
}
99-
10091
ServerChat.load();
101-
102-
FEATURES = new ConfigurableFeatures();
103-
FEATURES.tryToRegister(new UserHomeHandler(), "playerHomes");
104-
FEATURES.tryToRegister(new ServerWarpManager(), "serverWideWarps");
105-
FEATURES.tryToRegister(new PlayerWarpsManager(), "playerWarps");
106-
FEATURES.tryToRegister(new SeatManager(), "betterChairs");
107-
FEATURES.tryToRegister(new CustomCommands(), "customCommands");
108-
FEATURES.tryToRegister(new ParticleAnimationManager(), "magicalParticles");
109-
FEATURES.tryToRegister(new DiscordCommand(), "discordCommand");
110-
FEATURES.tryToRegister(new VoteCommand(), "voteCommand");
111-
FEATURES.tryToRegister(new PlaytimeCommands(), "playtimeCommands");
112-
11392
if (KiloConfig.main().startupScript().enabled) {
11493
this.startupScript = new StartupScript();
11594
}
116-
11795
this.permUtil = new PermissionUtil();
118-
119-
12096
}
12197

12298
public static Logger getLogger() {
@@ -140,7 +116,6 @@ public static KiloEssentialsImpl getInstance() {
140116
if (KiloEssentialsImpl.instance != null) {
141117
return KiloEssentialsImpl.instance;
142118
}
143-
144119
throw new RuntimeException("Its too early to get a static instance of KiloEssentials!");
145120
}
146121

@@ -154,7 +129,8 @@ public static Server getServer() {
154129

155130
@Override
156131
public KiloCommands getCommandHandler() {
157-
return this.commands;
132+
return KiloCommands.getInstance();
133+
// return this.commands;
158134
}
159135

160136
@Override
@@ -317,7 +293,7 @@ public PermissionUtil getPermissionUtil() {
317293

318294
@Override
319295
public ConfigurableFeatures getFeatures() {
320-
return this.FEATURES;
296+
return ConfigurableFeatures.getInstance();
321297
}
322298

323299
public void onServerStop() {
@@ -327,6 +303,7 @@ public void onServerStop() {
327303
}
328304

329305
public void onServerLoad() {
306+
new KiloCommands();
330307
this.permUtil = new PermissionUtil();
331308
}
332309

src/main/java/org/kilocraft/essentials/api/KiloServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public class KiloServer {
2020
*/
2121
public static Server getServer() {
2222
if (server == null) {
23-
throw new RuntimeException("Server isn't set!");
23+
return null;
24+
// throw new RuntimeException("Server isn't set!");
2425
}
2526

2627
return server;
@@ -33,7 +34,6 @@ public static Server getServer() {
3334
* @param minecraftServer Server instance
3435
*/
3536
public static void setupServer(@NotNull final MinecraftServer minecraftServer) {
36-
new ModConstants().loadConstants();
3737
String brand = String.format(
3838
ModConstants.getProperties().getProperty("server.brand.full"),
3939
ModConstants.getMinecraftVersion(),

0 commit comments

Comments
 (0)