using proper logger now
This commit is contained in:
1 parent
d072ec90c3
commit
edca3fb131
4 files changed
+12
-13
No files matched your search
@@ -36,13 +36,10 @@ import net.fabricmc.loader.api.FabricLoader;
|
|||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
public class CarpetServer implements ClientModInitializer,DedicatedServerModInitializer // static for now - easier to handle all around the code, its one anyways
|
public class CarpetServer implements ClientModInitializer,DedicatedServerModInitializer // static for now - easier to handle all around the code, its one anyways
|
||||||
{
|
{
|
||||||
public static final Random rand = new Random();
|
public static final Random rand = new Random();
|
||||||
public static final Logger LOG = LogManager.getLogger("scarpet");
|
|
||||||
public static MinecraftServer minecraft_server;
|
public static MinecraftServer minecraft_server;
|
||||||
private static CommandDispatcher<ServerCommandSource> currentCommandDispatcher;
|
private static CommandDispatcher<ServerCommandSource> currentCommandDispatcher;
|
||||||
public static CarpetScriptServer scriptServer;
|
public static CarpetScriptServer scriptServer;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import net.minecraft.server.command.ServerCommandSource;
|
|||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.WorldSavePath;
|
import net.minecraft.util.WorldSavePath;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.FileVisitOption;
|
import java.nio.file.FileVisitOption;
|
||||||
@@ -43,6 +45,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 static final Logger LOG = LogManager.getLogger("scarpet");
|
||||||
public final MinecraftServer server;
|
public final MinecraftServer server;
|
||||||
public CarpetScriptHost globalHost;
|
public CarpetScriptHost globalHost;
|
||||||
public Map<String, CarpetScriptHost> modules;
|
public Map<String, CarpetScriptHost> modules;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package carpet.script.api;
|
package carpet.script.api;
|
||||||
|
|
||||||
import carpet.CarpetServer;
|
import carpet.CarpetServer;
|
||||||
import carpet.CarpetSettings;
|
|
||||||
import carpet.fakes.MinecraftServerInterface;
|
import carpet.fakes.MinecraftServerInterface;
|
||||||
import carpet.fakes.ServerWorldInterface;
|
import carpet.fakes.ServerWorldInterface;
|
||||||
import carpet.fakes.StatTypeInterface;
|
import carpet.fakes.StatTypeInterface;
|
||||||
@@ -628,7 +627,7 @@ public class Auxiliary {
|
|||||||
s.getMinecraftServer().getPlayerManager().saveAllPlayerData();
|
s.getMinecraftServer().getPlayerManager().saveAllPlayerData();
|
||||||
s.getMinecraftServer().save(true,true,true);
|
s.getMinecraftServer().save(true,true,true);
|
||||||
s.getWorld().getChunkManager().tick(() -> true);
|
s.getWorld().getChunkManager().tick(() -> true);
|
||||||
CarpetSettings.LOG.warn("Saved chunks");
|
CarpetScriptServer.LOG.warn("Saved chunks");
|
||||||
return Value.TRUE;
|
return Value.TRUE;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -797,24 +796,23 @@ public class Auxiliary {
|
|||||||
|
|
||||||
expression.addFunction("logger", lv ->
|
expression.addFunction("logger", lv ->
|
||||||
{
|
{
|
||||||
//CarpetSettings.LOG.error(Registry.ENTITY_TYPE.getIds().stream().sorted().map(ValueConversions::simplify).collect(Collectors.joining("`, `")));
|
|
||||||
Value res;
|
Value res;
|
||||||
|
|
||||||
if(lv.size()==1)
|
if(lv.size()==1)
|
||||||
{
|
{
|
||||||
res = lv.get(0);
|
res = lv.get(0);
|
||||||
CarpetSettings.LOG.info(res.getString());
|
CarpetScriptServer.LOG.info(res.getString());
|
||||||
}
|
}
|
||||||
else if(lv.size()==2)
|
else if(lv.size()==2)
|
||||||
{
|
{
|
||||||
String level = lv.get(0).getString().toLowerCase(Locale.ROOT);
|
String level = lv.get(0).getString().toLowerCase(Locale.ROOT);
|
||||||
res = lv.get(1);
|
res = lv.get(1);
|
||||||
switch(level){
|
switch(level){
|
||||||
case "error": CarpetSettings.LOG.error(res.getString()); break;
|
case "error": CarpetScriptServer.LOG.error(res.getString()); break;
|
||||||
case "warn": CarpetSettings.LOG.warn(res.getString()); break;
|
case "warn": CarpetScriptServer.LOG.warn(res.getString()); break;
|
||||||
case "debug": CarpetSettings.LOG.debug(res.getString()); break;
|
case "debug": CarpetScriptServer.LOG.debug(res.getString()); break;
|
||||||
case "fatal": CarpetSettings.LOG.fatal(res.getString()); break;
|
case "fatal": CarpetScriptServer.LOG.fatal(res.getString()); break;
|
||||||
case "info": CarpetSettings.LOG.info(res.getString()); break;
|
case "info": CarpetScriptServer.LOG.info(res.getString()); break;
|
||||||
default: throw new InternalExpressionException("Unknown log level for 'logger': "+level);
|
default: throw new InternalExpressionException("Unknown log level for 'logger': "+level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import carpet.helpers.Tracer;
|
|||||||
import carpet.network.ServerNetworkHandler;
|
import carpet.network.ServerNetworkHandler;
|
||||||
import carpet.patches.EntityPlayerMPFake;
|
import carpet.patches.EntityPlayerMPFake;
|
||||||
import carpet.script.CarpetContext;
|
import carpet.script.CarpetContext;
|
||||||
|
import carpet.script.CarpetScriptServer;
|
||||||
import carpet.script.EntityEventsGroup;
|
import carpet.script.EntityEventsGroup;
|
||||||
import carpet.script.argument.Vector3Argument;
|
import carpet.script.argument.Vector3Argument;
|
||||||
import carpet.script.exception.InternalExpressionException;
|
import carpet.script.exception.InternalExpressionException;
|
||||||
@@ -922,7 +923,7 @@ public class EntityValue extends Value
|
|||||||
{
|
{
|
||||||
e.velocityModified = true;
|
e.velocityModified = true;
|
||||||
if (Math.abs(scale) > 10000)
|
if (Math.abs(scale) > 10000)
|
||||||
CarpetServer.LOG.warn("Moved entity "+e.getEntityName()+" "+e.getName()+" at " +e.getPos()+" extremly fast: "+e.getVelocity());
|
CarpetScriptServer.LOG.warn("Moved entity "+e.getEntityName()+" "+e.getName()+" at " +e.getPos()+" extremly fast: "+e.getVelocity());
|
||||||
//((ServerWorld)e.getEntityWorld()).method_14178().sendToNearbyPlayers(e, new EntityVelocityUpdateS2CPacket(e));
|
//((ServerWorld)e.getEntityWorld()).method_14178().sendToNearbyPlayers(e, new EntityVelocityUpdateS2CPacket(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user