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

Commit

Permalink
Merge pull request #101 from DrexHD/Beta
Browse files Browse the repository at this point in the history
1.16 Pre7 and Command reworks
  • Loading branch information
DrexHD authored Jun 16, 2020
2 parents 4a42a9b + fd11b07 commit 516ebea
Show file tree
Hide file tree
Showing 41 changed files with 179 additions and 180 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ org.gradle.jvmargs=-Xmx2G

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

# Mod Properties
mod_version = 1.9.8.6
mod_version_nick = NearTheEnd
mod_version = 1.9.9.0
mod_version_nick = TheFutureIsOurs
maven_group = org.kilocraft.essentials
archives_base_name = kilo_essentials
build = 0
Expand Down
37 changes: 35 additions & 2 deletions src/main/java/org/kilocraft/essentials/KiloCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.kilocraft.essentials.api.command.EssentialCommand;
import org.kilocraft.essentials.api.command.IEssentialCommand;
import org.kilocraft.essentials.api.event.commands.OnCommandExecutionEvent;
import org.kilocraft.essentials.api.feature.ConfigurableFeatures;
import org.kilocraft.essentials.api.server.Server;
import org.kilocraft.essentials.api.user.CommandSourceUser;
import org.kilocraft.essentials.chat.KiloChat;
import org.kilocraft.essentials.chat.LangText;
Expand Down Expand Up @@ -59,8 +61,15 @@
import org.kilocraft.essentials.commands.world.TimeCommand;
import org.kilocraft.essentials.config.KiloConfig;
import org.kilocraft.essentials.events.commands.OnCommandExecutionEventImpl;
import org.kilocraft.essentials.extensions.betterchairs.SeatManager;
import org.kilocraft.essentials.extensions.customcommands.CustomCommands;
import org.kilocraft.essentials.extensions.magicalparticles.ParticleAnimationManager;
import org.kilocraft.essentials.extensions.playtimecommands.PlaytimeCommands;
import org.kilocraft.essentials.extensions.warps.playerwarps.PlayerWarpsManager;
import org.kilocraft.essentials.extensions.warps.serverwidewarps.ServerWarpManager;
import org.kilocraft.essentials.simplecommand.SimpleCommand;
import org.kilocraft.essentials.simplecommand.SimpleCommandManager;
import org.kilocraft.essentials.user.UserHomeHandler;
import org.kilocraft.essentials.util.messages.nodes.ArgExceptionMessageNode;
import org.kilocraft.essentials.util.messages.nodes.ExceptionMessageNode;
import org.kilocraft.essentials.util.text.Texter;
Expand All @@ -79,15 +88,32 @@
public class KiloCommands {
private final List<IEssentialCommand> commands;
private final CommandDispatcher<ServerCommandSource> dispatcher;
private final SimpleCommandManager simpleCommandManager;
private SimpleCommandManager simpleCommandManager;
private static LiteralCommandNode<ServerCommandSource> rootNode;
private static KiloCommands instance;


public KiloCommands() {
KiloCommands.instance = this;
this.dispatcher = KiloEssentialsImpl.commandDispatcher;
this.simpleCommandManager = new SimpleCommandManager(KiloServer.getServer(), this.dispatcher);
this.commands = new ArrayList<>();
KiloCommands.rootNode = literal("essentials").executes(this::sendInfo).build();
this.simpleCommandManager = new SimpleCommandManager();
registerDefaults();
registerFeatures();
}

public void registerFeatures() {
ConfigurableFeatures FEATURES = new ConfigurableFeatures();
FEATURES.tryToRegister(new UserHomeHandler(), "playerHomes");
FEATURES.tryToRegister(new ServerWarpManager(), "serverWideWarps");
FEATURES.tryToRegister(new PlayerWarpsManager(), "playerWarps");
FEATURES.tryToRegister(new SeatManager(), "betterChairs");
FEATURES.tryToRegister(new CustomCommands(), "customCommands");
FEATURES.tryToRegister(new ParticleAnimationManager(), "magicalParticles");
FEATURES.tryToRegister(new DiscordCommand(), "discordCommand");
FEATURES.tryToRegister(new VoteCommand(), "voteCommand");
FEATURES.tryToRegister(new PlaytimeCommands(), "playtimeCommands");
}

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

public static KiloCommands getInstance() {
if (KiloCommands.instance != null) {
return KiloCommands.instance;
}
throw new RuntimeException("Its too early to get a static instance of KiloCommands!");
}

private boolean isCommand(final String literal) {
return this.dispatcher.getRoot().getChild(literal) != null;
}
Expand Down
63 changes: 20 additions & 43 deletions src/main/java/org/kilocraft/essentials/KiloEssentialsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import org.kilocraft.essentials.api.KiloEssentials;
import org.kilocraft.essentials.api.KiloServer;
import org.kilocraft.essentials.api.ModConstants;
import org.kilocraft.essentials.api.feature.ConfigurableFeature;
import org.kilocraft.essentials.api.feature.ConfigurableFeatures;
import org.kilocraft.essentials.api.server.Server;
import org.kilocraft.essentials.api.user.CommandSourceUser;
import org.kilocraft.essentials.api.user.NeverJoinedUser;
import org.kilocraft.essentials.api.user.OnlineUser;
import org.kilocraft.essentials.api.user.User;
import org.kilocraft.essentials.api.util.Litebans2Vanilla;
import org.kilocraft.essentials.chat.ServerChat;
import org.kilocraft.essentials.commands.CommandUtils;
import org.kilocraft.essentials.commands.misc.DiscordCommand;
Expand All @@ -32,13 +32,11 @@
import org.kilocraft.essentials.extensions.warps.serverwidewarps.ServerWarpManager;
import org.kilocraft.essentials.user.ServerUserManager;
import org.kilocraft.essentials.user.UserHomeHandler;
import org.kilocraft.essentials.util.MutedPlayerList;
import org.kilocraft.essentials.util.PermissionUtil;
import org.kilocraft.essentials.util.StartupScript;
import org.kilocraft.essentials.util.messages.MessageUtil;
import org.kilocraft.essentials.util.messages.nodes.ExceptionMessageNode;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
Expand All @@ -57,66 +55,44 @@
*/

public final class KiloEssentialsImpl implements KiloEssentials {
private static boolean running = false;
public static boolean running = false;
private static final Logger LOGGER = LogManager.getLogger("KiloEssentials");
private static KiloEssentialsImpl instance;

private final ConfigurableFeatures FEATURES;
private final KiloCommands commands;

private PermissionUtil permUtil;
private PermissionUtil permUtil;
private StartupScript startupScript;

public static CommandDispatcher<ServerCommandSource> commandDispatcher;

public static void onServerSet(@NotNull final Server server) {
public static void onServerSet(final Server server) {
KiloDebugUtils.validateDebugMode(false);
new KiloEssentialsImpl();
}

KiloEssentialsImpl() {
if (running) {
throw new RuntimeException("KiloEssentialsImpl is already running!");
} else {
running = true;
}

KiloEssentialsImpl.instance = this;
KiloEssentialsImpl.LOGGER.info("Running KiloEssentials version " + ModConstants.getVersion());

KiloConfig.load();
try {
getServer().getUserManager().getMutedPlayerList().load();
} catch (IOException e) {
KiloEssentials.getLogger().error("An unexpected error occurred while loading the Muted Player List", e);
}
new KiloEvents();
this.commands = new KiloCommands();
}



public KiloEssentialsImpl() {
if (running) {
throw new RuntimeException("KiloEssentialsImpl is already running!");
} else {
running = true;
}
KiloEssentialsImpl.instance = this;
KiloEssentialsImpl.LOGGER.info("Running KiloEssentials version " + ModConstants.getVersion());

if (SharedConstants.isDevelopment) {
new KiloDebugUtils();
}

ServerChat.load();

FEATURES = new ConfigurableFeatures();
FEATURES.tryToRegister(new UserHomeHandler(), "playerHomes");
FEATURES.tryToRegister(new ServerWarpManager(), "serverWideWarps");
FEATURES.tryToRegister(new PlayerWarpsManager(), "playerWarps");
FEATURES.tryToRegister(new SeatManager(), "betterChairs");
FEATURES.tryToRegister(new CustomCommands(), "customCommands");
FEATURES.tryToRegister(new ParticleAnimationManager(), "magicalParticles");
FEATURES.tryToRegister(new DiscordCommand(), "discordCommand");
FEATURES.tryToRegister(new VoteCommand(), "voteCommand");
FEATURES.tryToRegister(new PlaytimeCommands(), "playtimeCommands");

if (KiloConfig.main().startupScript().enabled) {
this.startupScript = new StartupScript();
}

this.permUtil = new PermissionUtil();


}

public static Logger getLogger() {
Expand All @@ -140,7 +116,6 @@ public static KiloEssentialsImpl getInstance() {
if (KiloEssentialsImpl.instance != null) {
return KiloEssentialsImpl.instance;
}

throw new RuntimeException("Its too early to get a static instance of KiloEssentials!");
}

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

@Override
public KiloCommands getCommandHandler() {
return this.commands;
return KiloCommands.getInstance();
// return this.commands;
}

@Override
Expand Down Expand Up @@ -317,7 +293,7 @@ public PermissionUtil getPermissionUtil() {

@Override
public ConfigurableFeatures getFeatures() {
return this.FEATURES;
return ConfigurableFeatures.getInstance();
}

public void onServerStop() {
Expand All @@ -327,6 +303,7 @@ public void onServerStop() {
}

public void onServerLoad() {
new KiloCommands();
this.permUtil = new PermissionUtil();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kilocraft/essentials/api/KiloServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class KiloServer {
*/
public static Server getServer() {
if (server == null) {
throw new RuntimeException("Server isn't set!");
return null;
// throw new RuntimeException("Server isn't set!");
}

return server;
Expand All @@ -33,7 +34,6 @@ public static Server getServer() {
* @param minecraftServer Server instance
*/
public static void setupServer(@NotNull final MinecraftServer minecraftServer) {
new ModConstants().loadConstants();
String brand = String.format(
ModConstants.getProperties().getProperty("server.brand.full"),
ModConstants.getMinecraftVersion(),
Expand Down
Loading

0 comments on commit 516ebea

Please sign in to comment.