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 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() {
|
||||
try {
|
||||
Files.createDirectories(FILE.getParent());
|
||||
} catch (NumberFormatException | IOException e) {
|
||||
((Exception)e).printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ public final class Config {
|
|||
public static int port() {
|
||||
try {
|
||||
Files.createDirectories(FILE.getParent());
|
||||
if (Files.notExists(FILE, new LinkOption[0])) {
|
||||
if (Files.notExists(FILE)) {
|
||||
write(8080);
|
||||
return 8080;
|
||||
} else {
|
||||
return Integer.parseInt(Files.readString(FILE).trim());
|
||||
}
|
||||
} catch (NumberFormatException | IOException e) {
|
||||
((Exception)e).printStackTrace();
|
||||
e.printStackTrace();
|
||||
return 8080;
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,4 @@ public final class Config {
|
|||
public static void write(int port) throws IOException {
|
||||
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 tf.jsw.mcadmintracker.Db;
|
||||
|
||||
@Mixin({ServerPlayerInteractionManager.class})
|
||||
@Mixin(ServerPlayerInteractionManager.class)
|
||||
public abstract class GameModeMixin {
|
||||
@Final
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,16 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "tf.jsw.mcadmintracker.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"CommandMixin",
|
||||
"GameModeMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"overwrites": {
|
||||
"requireAnnotations": true
|
||||
"required": true,
|
||||
"package": "tf.jsw.mcadmintracker.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"CommandMixin",
|
||||
"GameModeMixin",
|
||||
"SuppressCoordsMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"overwrites": {
|
||||
"requireAnnotations": true
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue