Small changes and added mixin to suppress coords in logs when a player joins.
Some checks are pending
build / build (push) Waiting to run
Some checks are pending
build / build (push) Waiting to run
This commit is contained in:
parent
57e0983109
commit
70f2952d84
4 changed files with 40 additions and 21 deletions
|
@ -8,13 +8,13 @@ import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
|
||||||
public final class Config {
|
public final class Config {
|
||||||
public static final Path MAIN_DIR = FabricLoader.getInstance().getConfigDir().resolve("mcadmintracker");
|
public static final Path MAIN_DIR = FabricLoader.getInstance().getConfigDir().resolve("mcadmintracker");
|
||||||
private static final Path FILE;
|
private static final Path FILE = MAIN_DIR.resolve("port.txt");
|
||||||
|
|
||||||
public static void createDir() {
|
public static void createDir() {
|
||||||
try {
|
try {
|
||||||
Files.createDirectories(FILE.getParent());
|
Files.createDirectories(FILE.getParent());
|
||||||
} catch (NumberFormatException | IOException e) {
|
} catch (NumberFormatException | IOException e) {
|
||||||
((Exception)e).printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,14 @@ public final class Config {
|
||||||
public static int port() {
|
public static int port() {
|
||||||
try {
|
try {
|
||||||
Files.createDirectories(FILE.getParent());
|
Files.createDirectories(FILE.getParent());
|
||||||
if (Files.notExists(FILE, new LinkOption[0])) {
|
if (Files.notExists(FILE)) {
|
||||||
write(8080);
|
write(8080);
|
||||||
return 8080;
|
return 8080;
|
||||||
} else {
|
} else {
|
||||||
return Integer.parseInt(Files.readString(FILE).trim());
|
return Integer.parseInt(Files.readString(FILE).trim());
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException | IOException e) {
|
} catch (NumberFormatException | IOException e) {
|
||||||
((Exception)e).printStackTrace();
|
e.printStackTrace();
|
||||||
return 8080;
|
return 8080;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,4 @@ public final class Config {
|
||||||
public static void write(int port) throws IOException {
|
public static void write(int port) throws IOException {
|
||||||
Files.writeString(FILE, String.valueOf(port));
|
Files.writeString(FILE, String.valueOf(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
|
||||||
FILE = MAIN_DIR.resolve("config.txt");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import tf.jsw.mcadmintracker.Db;
|
import tf.jsw.mcadmintracker.Db;
|
||||||
|
|
||||||
@Mixin({ServerPlayerInteractionManager.class})
|
@Mixin(ServerPlayerInteractionManager.class)
|
||||||
public abstract class GameModeMixin {
|
public abstract class GameModeMixin {
|
||||||
@Final
|
@Final
|
||||||
@Shadow
|
@Shadow
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package tf.jsw.mcadmintracker.mixin;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(value = net.minecraft.server.PlayerManager.class) // <-- fixed
|
||||||
|
public abstract class SuppressCoordsMixin {
|
||||||
|
|
||||||
|
@Redirect(method = "onPlayerConnect",
|
||||||
|
at = @At(value = "INVOKE",
|
||||||
|
target = "Lorg/slf4j/Logger;info(Ljava/lang/String;[Ljava/lang/Object;)V",
|
||||||
|
remap = false))
|
||||||
|
private void stripCoords(Logger logger, String format, Object[] args) {
|
||||||
|
String newFormat = format.substring(0, format.lastIndexOf(" at ("));
|
||||||
|
Object[] newArgs = new Object[args.length - 3];
|
||||||
|
System.arraycopy(args, 0, newArgs, 0, newArgs.length);
|
||||||
|
logger.info(newFormat + " at REDACTED", newArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"CommandMixin",
|
"CommandMixin",
|
||||||
"GameModeMixin"
|
"GameModeMixin",
|
||||||
|
"SuppressCoordsMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue