fixed missing client side server references. fixes #311
This commit is contained in:
1 parent
7bbae714ea
commit
b3484fd012
10 files changed
+36
-27
No files matched your search
@@ -57,7 +57,7 @@ public class CarpetServer // static for now - easier to handle all around the co
|
|||||||
if (sm != null) sm.attachServer(server);
|
if (sm != null) sm.attachServer(server);
|
||||||
e.onServerLoaded(server);
|
e.onServerLoaded(server);
|
||||||
});
|
});
|
||||||
scriptServer = new CarpetScriptServer();
|
scriptServer = new CarpetScriptServer(server);
|
||||||
scriptServer.loadAllWorldScripts();
|
scriptServer.loadAllWorldScripts();
|
||||||
MobAI.resetTrackers();
|
MobAI.resetTrackers();
|
||||||
LoggerRegistry.initLoggers();
|
LoggerRegistry.initLoggers();
|
||||||
|
|||||||
@@ -501,8 +501,8 @@ public class CarpetSettings
|
|||||||
if (server.isDedicated())
|
if (server.isDedicated())
|
||||||
{
|
{
|
||||||
int vd = (newValue >= 2)?newValue:((DedicatedServer) server).getProperties().viewDistance;
|
int vd = (newValue >= 2)?newValue:((DedicatedServer) server).getProperties().viewDistance;
|
||||||
if (vd != CarpetServer.minecraft_server.getPlayerManager().getViewDistance())
|
if (vd != server.getPlayerManager().getViewDistance())
|
||||||
CarpetServer.minecraft_server.getPlayerManager().setViewDistance(vd);
|
server.getPlayerManager().setViewDistance(vd);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -549,6 +549,7 @@ public class CarpetSettings
|
|||||||
//must been some startup thing
|
//must been some startup thing
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
if (CarpetServer.minecraft_server == null) return newValue;
|
||||||
ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD);
|
ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD);
|
||||||
if (currentOverworld != null)
|
if (currentOverworld != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import net.minecraft.command.arguments.DimensionArgumentType;
|
|||||||
import net.minecraft.entity.EntityCategory;
|
import net.minecraft.entity.EntityCategory;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.DyeColor;
|
import net.minecraft.util.DyeColor;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
@@ -195,7 +196,7 @@ public class SpawnCommand
|
|||||||
TickSpeed.tickrate_advance(null, 0, null, null);
|
TickSpeed.tickrate_advance(null, 0, null, null);
|
||||||
// tick warp given player
|
// tick warp given player
|
||||||
ServerCommandSource csource = null;
|
ServerCommandSource csource = null;
|
||||||
PlayerEntity player = null;
|
ServerPlayerEntity player = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
player = source.getPlayer();
|
player = source.getPlayer();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.BaseText;
|
import net.minecraft.text.BaseText;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ public class TickCommand
|
|||||||
|
|
||||||
private static int setWarp(ServerCommandSource source, int advance, String tail_command)
|
private static int setWarp(ServerCommandSource source, int advance, String tail_command)
|
||||||
{
|
{
|
||||||
PlayerEntity player = null;
|
ServerPlayerEntity player = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
player = source.getPlayer();
|
player = source.getPlayer();
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import java.util.function.BiConsumer;
|
|||||||
import carpet.CarpetServer;
|
import carpet.CarpetServer;
|
||||||
import carpet.network.ServerNetworkHandler;
|
import carpet.network.ServerNetworkHandler;
|
||||||
import carpet.utils.Messenger;
|
import carpet.utils.Messenger;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.BaseText;
|
import net.minecraft.text.BaseText;
|
||||||
|
|
||||||
public class TickSpeed
|
public class TickSpeed
|
||||||
@@ -21,7 +21,7 @@ public class TickSpeed
|
|||||||
public static long time_bias = 0;
|
public static long time_bias = 0;
|
||||||
public static long time_warp_start_time = 0;
|
public static long time_warp_start_time = 0;
|
||||||
public static long time_warp_scheduled_ticks = 0;
|
public static long time_warp_scheduled_ticks = 0;
|
||||||
public static PlayerEntity time_advancerer = null;
|
public static ServerPlayerEntity time_advancerer = null;
|
||||||
public static String tick_warp_callback = null;
|
public static String tick_warp_callback = null;
|
||||||
public static ServerCommandSource tick_warp_sender = null;
|
public static ServerCommandSource tick_warp_sender = null;
|
||||||
public static int player_active_timeout = 0;
|
public static int player_active_timeout = 0;
|
||||||
@@ -68,13 +68,14 @@ public class TickSpeed
|
|||||||
player_active_timeout = PLAYER_GRACE+ticks;
|
player_active_timeout = PLAYER_GRACE+ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BaseText tickrate_advance(PlayerEntity player, int advance, String callback, ServerCommandSource source)
|
public static BaseText tickrate_advance(ServerPlayerEntity player, int advance, String callback, ServerCommandSource source)
|
||||||
{
|
{
|
||||||
if (0 == advance)
|
if (0 == advance)
|
||||||
{
|
{
|
||||||
tick_warp_callback = null;
|
tick_warp_callback = null;
|
||||||
tick_warp_sender = null;
|
if (source != tick_warp_sender) tick_warp_sender = null;
|
||||||
finish_time_warp();
|
finish_time_warp();
|
||||||
|
tick_warp_sender = null;
|
||||||
return Messenger.c("gi Warp interrupted");
|
return Messenger.c("gi Warp interrupted");
|
||||||
}
|
}
|
||||||
if (time_bias > 0)
|
if (time_bias > 0)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public abstract class PlayerEntity_antiCheatDisabled
|
|||||||
@Inject(method = "method_23668", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "method_23668", at = @At("HEAD"), cancellable = true)
|
||||||
private void allowDeploys(CallbackInfoReturnable<Boolean> cir)
|
private void allowDeploys(CallbackInfoReturnable<Boolean> cir)
|
||||||
{
|
{
|
||||||
if (CarpetSettings.antiCheatDisabled && CarpetServer.minecraft_server.isDedicated())
|
if (CarpetSettings.antiCheatDisabled && CarpetServer.minecraft_server != null && CarpetServer.minecraft_server.isDedicated())
|
||||||
{
|
{
|
||||||
ItemStack itemStack_1 = getEquippedStack(EquipmentSlot.CHEST);
|
ItemStack itemStack_1 = getEquippedStack(EquipmentSlot.CHEST);
|
||||||
if (itemStack_1.getItem() == Items.ELYTRA && ElytraItem.isUsable(itemStack_1)) {
|
if (itemStack_1.getItem() == Items.ELYTRA && ElytraItem.isUsable(itemStack_1)) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import carpet.script.value.Value;
|
|||||||
import carpet.utils.Messenger;
|
import carpet.utils.Messenger;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
@@ -51,6 +52,7 @@ import java.util.stream.Collectors;
|
|||||||
public class CarpetEventServer
|
public class CarpetEventServer
|
||||||
{
|
{
|
||||||
public final List<ScheduledCall> scheduledCalls = new LinkedList<>();
|
public final List<ScheduledCall> scheduledCalls = new LinkedList<>();
|
||||||
|
public final MinecraftServer server;
|
||||||
|
|
||||||
public static class Callback
|
public static class Callback
|
||||||
{
|
{
|
||||||
@@ -652,8 +654,9 @@ public class CarpetEventServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CarpetEventServer()
|
public CarpetEventServer(MinecraftServer server)
|
||||||
{
|
{
|
||||||
|
this.server = server;
|
||||||
for (Event e: Event.values())
|
for (Event e: Event.values())
|
||||||
e.handler.callList.clear();
|
e.handler.callList.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
callUDF(BlockPos.ORIGIN, CarpetServer.minecraft_server.getCommandSource(), closing, Collections.emptyList());
|
callUDF(BlockPos.ORIGIN, scriptServer.server.getCommandSource(), closing, Collections.emptyList());
|
||||||
}
|
}
|
||||||
catch (InvalidCallbackException ignored)
|
catch (InvalidCallbackException ignored)
|
||||||
{
|
{
|
||||||
@@ -334,8 +334,8 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
FunctionValue userClosing = value.getFunction("__on_close");
|
FunctionValue userClosing = value.getFunction("__on_close");
|
||||||
if (userClosing != null)
|
if (userClosing != null)
|
||||||
{
|
{
|
||||||
ServerPlayerEntity player = CarpetServer.minecraft_server.getPlayerManager().getPlayer(key);
|
ServerPlayerEntity player = scriptServer.server.getPlayerManager().getPlayer(key);
|
||||||
ServerCommandSource source = (player != null)?player.getCommandSource():CarpetServer.minecraft_server.getCommandSource();
|
ServerCommandSource source = (player != null)?player.getCommandSource():scriptServer.server.getCommandSource();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((CarpetScriptHost) value).callUDF(BlockPos.ORIGIN, source, userClosing, Collections.emptyList());
|
((CarpetScriptHost) value).callUDF(BlockPos.ORIGIN, source, userClosing, Collections.emptyList());
|
||||||
@@ -347,7 +347,7 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
});
|
});
|
||||||
|
|
||||||
String markerName = CarpetExpression.MARKER_STRING+"_"+((getName()==null)?"":getName());
|
String markerName = CarpetExpression.MARKER_STRING+"_"+((getName()==null)?"":getName());
|
||||||
for (ServerWorld world : CarpetServer.minecraft_server.getWorlds())
|
for (ServerWorld world : scriptServer.server.getWorlds())
|
||||||
{
|
{
|
||||||
for (Entity e : world.getEntities(EntityType.ARMOR_STAND, (as) -> as.getScoreboardTags().contains(markerName)))
|
for (Entity e : world.getEntities(EntityType.ARMOR_STAND, (as) -> as.getScoreboardTags().contains(markerName)))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import carpet.utils.Messenger;
|
|||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.tree.CommandNode;
|
import com.mojang.brigadier.tree.CommandNode;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ import static net.minecraft.server.command.CommandManager.literal;
|
|||||||
public class CarpetScriptServer
|
public class CarpetScriptServer
|
||||||
{
|
{
|
||||||
//make static for now, but will change that later:
|
//make static for now, but will change that later:
|
||||||
|
public final MinecraftServer server;
|
||||||
public final CarpetScriptHost globalHost;
|
public final CarpetScriptHost globalHost;
|
||||||
public final Map<String, CarpetScriptHost> modules;
|
public final Map<String, CarpetScriptHost> modules;
|
||||||
public long tickStart;
|
public long tickStart;
|
||||||
@@ -49,14 +51,15 @@ public class CarpetScriptServer
|
|||||||
add(new BundledModule("math", true));
|
add(new BundledModule("math", true));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
public CarpetScriptServer()
|
public CarpetScriptServer(MinecraftServer server)
|
||||||
{
|
{
|
||||||
|
this.server = server;
|
||||||
ScriptHost.systemGlobals.clear();
|
ScriptHost.systemGlobals.clear();
|
||||||
events = new CarpetEventServer();
|
events = new CarpetEventServer(server);
|
||||||
modules = new HashMap<>();
|
modules = new HashMap<>();
|
||||||
tickStart = 0L;
|
tickStart = 0L;
|
||||||
stopAll = false;
|
stopAll = false;
|
||||||
holyMoly = CarpetServer.minecraft_server.getCommandManager().getDispatcher().getRoot().getChildren().stream().map(CommandNode::getName).collect(Collectors.toSet());
|
holyMoly = server.getCommandManager().getDispatcher().getRoot().getChildren().stream().map(CommandNode::getName).collect(Collectors.toSet());
|
||||||
globalHost = CarpetScriptHost.create(this, null, false, null);
|
globalHost = CarpetScriptHost.create(this, null, false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,10 +67,10 @@ public class CarpetScriptServer
|
|||||||
{
|
{
|
||||||
if (CarpetSettings.scriptsAutoload)
|
if (CarpetSettings.scriptsAutoload)
|
||||||
{
|
{
|
||||||
Messenger.m(CarpetServer.minecraft_server.getCommandSource(), "Auto-loading world scarpet apps");
|
Messenger.m(server.getCommandSource(), "Auto-loading world scarpet apps");
|
||||||
for (String moduleName: listAvailableModules(false))
|
for (String moduleName: listAvailableModules(false))
|
||||||
{
|
{
|
||||||
addScriptHost(CarpetServer.minecraft_server.getCommandSource(), moduleName, true, true);
|
addScriptHost(server.getCommandSource(), moduleName, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,8 +78,8 @@ public class CarpetScriptServer
|
|||||||
|
|
||||||
public Module getModule(String name, boolean allowLibraries)
|
public Module getModule(String name, boolean allowLibraries)
|
||||||
{
|
{
|
||||||
File folder = CarpetServer.minecraft_server.getLevelStorage().resolveFile(
|
File folder = server.getLevelStorage().resolveFile(
|
||||||
CarpetServer.minecraft_server.getLevelName(), "scripts");
|
server.getLevelName(), "scripts");
|
||||||
File[] listOfFiles = folder.listFiles();
|
File[] listOfFiles = folder.listFiles();
|
||||||
if (listOfFiles != null)
|
if (listOfFiles != null)
|
||||||
for (File script : listOfFiles)
|
for (File script : listOfFiles)
|
||||||
@@ -110,8 +113,8 @@ public class CarpetScriptServer
|
|||||||
if (!mi.isLibrary()) moduleNames.add(mi.getName());
|
if (!mi.isLibrary()) moduleNames.add(mi.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File folder = CarpetServer.minecraft_server.getLevelStorage().resolveFile(
|
File folder = server.getLevelStorage().resolveFile(
|
||||||
CarpetServer.minecraft_server.getLevelName(), "scripts");
|
server.getLevelName(), "scripts");
|
||||||
File[] listOfFiles = folder.listFiles();
|
File[] listOfFiles = folder.listFiles();
|
||||||
if (listOfFiles == null)
|
if (listOfFiles == null)
|
||||||
return moduleNames;
|
return moduleNames;
|
||||||
@@ -223,7 +226,7 @@ public class CarpetScriptServer
|
|||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
Messenger.m(source, "gi "+hostName+" app loaded with /"+hostName+" command");
|
Messenger.m(source, "gi "+hostName+" app loaded with /"+hostName+" command");
|
||||||
CarpetServer.minecraft_server.getCommandManager().getDispatcher().register(command);
|
server.getCommandManager().getDispatcher().register(command);
|
||||||
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
|
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -362,8 +362,7 @@ public class SettingsManager
|
|||||||
{
|
{
|
||||||
if (dispatcher.getRoot().getChildren().stream().anyMatch(node -> node.getName().equalsIgnoreCase(identifier)))
|
if (dispatcher.getRoot().getChildren().stream().anyMatch(node -> node.getName().equalsIgnoreCase(identifier)))
|
||||||
{
|
{
|
||||||
Messenger.print_server_message(CarpetServer.minecraft_server,
|
CarpetSettings.LOG.error("Failed to add settings command for " + identifier + ". It is masking previous command.");
|
||||||
Messenger.c("rb Failed to add settings command for " + identifier + ". It is masking previous command."));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user