aboutsummaryrefslogtreecommitdiff
path: root/spark-forge
diff options
context:
space:
mode:
Diffstat (limited to 'spark-forge')
-rw-r--r--spark-forge/build.gradle4
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java19
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java4
3 files changed, 14 insertions, 13 deletions
diff --git a/spark-forge/build.gradle b/spark-forge/build.gradle
index 6b55901..526778e 100644
--- a/spark-forge/build.gradle
+++ b/spark-forge/build.gradle
@@ -14,7 +14,7 @@ plugins {
apply plugin: 'net.minecraftforge.gradle'
minecraft {
- mappings channel: 'snapshot', version: '20190801-1.14.3'
+ mappings channel: 'snapshot', version: '20200112-1.14.3'
}
processResources {
@@ -37,7 +37,7 @@ configurations {
}
dependencies {
- minecraft 'net.minecraftforge:forge:1.14.4-28.0.45'
+ minecraft 'net.minecraftforge:forge:1.14.4-28.1.0'
shade project(':spark-common')
}
diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java
index 6db916c..2b6220a 100644
--- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java
+++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java
@@ -32,7 +32,6 @@ import me.lucko.spark.forge.ForgeCommandSender;
import me.lucko.spark.forge.ForgeSparkMod;
import me.lucko.spark.forge.ForgeTickCounter;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.network.play.ClientPlayNetHandler;
import net.minecraft.command.ICommandSource;
import net.minecraft.command.ISuggestionProvider;
@@ -43,6 +42,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import java.util.Arrays;
+import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
@@ -66,19 +66,20 @@ public class ForgeClientSparkPlugin extends ForgeSparkPlugin implements Suggesti
this.minecraft = minecraft;
}
- private void checkCommandRegistered() {
- ClientPlayerEntity player = this.minecraft.player;
- if (player == null) {
- return;
- }
+ private CommandDispatcher<ISuggestionProvider> getPlayerCommandDispatcher() {
+ return Optional.ofNullable(this.minecraft.player)
+ .map(player -> player.connection)
+ .map(ClientPlayNetHandler::getCommandDispatcher)
+ .orElse(null);
+ }
- ClientPlayNetHandler connection = player.connection;
- if (connection == null) {
+ private void checkCommandRegistered() {
+ CommandDispatcher<ISuggestionProvider> dispatcher = getPlayerCommandDispatcher();
+ if (dispatcher == null) {
return;
}
try {
- CommandDispatcher<ISuggestionProvider> dispatcher = connection.func_195515_i();
if (dispatcher != this.dispatcher) {
this.dispatcher = dispatcher;
registerCommands(this.dispatcher, context -> Command.SINGLE_SUCCESS, this, "sparkc", "sparkclient");
diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java
index 98404e0..a2aafb2 100644
--- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java
+++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java
@@ -49,9 +49,9 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command<
public static void register(ForgeSparkMod mod, FMLServerStartingEvent event) {
MinecraftServer server = event.getServer();
- CommandDispatcher<CommandSource> dispatcher = event.getCommandDispatcher();
-
ForgeServerSparkPlugin plugin = new ForgeServerSparkPlugin(mod, server);
+
+ CommandDispatcher<CommandSource> dispatcher = event.getCommandDispatcher();
registerCommands(dispatcher, plugin, plugin, "spark");
PermissionAPI.registerNode("spark", DefaultPermissionLevel.OP, "Access to the spark command");
}