Skip to content

Commit 7e5ffa6

Browse files
committed
update: optimize disk logger
1 parent e0b8616 commit 7e5ffa6

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/main/java/io/github/optijava/opt_carpet_addition/OptCarpetAddition.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class OptCarpetAddition implements CarpetExtension, ModInitializer {
3434
@Override
3535
public void onInitialize() {
3636
LOGGER.info("OptCarpetAddition is loading...");
37-
CarpetServer.manageExtension(new OptCarpetAddition());
37+
CarpetServer.manageExtension(this);
3838

3939
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register(new FixExperienceBug());
4040
}
@@ -178,6 +178,7 @@ public void registerLoggers() {
178178

179179
@Override
180180
public Map<String, String> canHasTranslations(String lang) {
181+
//add rule translator
181182
return RuleTranslator.getTranslationFromResourcePath(lang);
182183
}
183184
}

src/main/java/io/github/optijava/opt_carpet_addition/logger/disk/DiskHUDLogger.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.server.MinecraftServer;
77
//#if MC >= 11900
88
//$$ import net.minecraft.text.Text;
9+
//$$ import carpet.utils.Messenger;
910
//#else
1011
import net.minecraft.text.BaseText;
1112
import net.minecraft.text.LiteralText;
@@ -34,6 +35,8 @@ protected DiskHUDLogger(Field acceleratorField, String logName, String def, Stri
3435

3536
@Override
3637
public void updateHUD(MinecraftServer server) {
38+
long toGB = 1024*1024*1024;
39+
3740
if (LoggerRegister.__disk) {
3841
//#if MC >= 11900
3942
//$$ List<Text> list = new ArrayList<>();
@@ -44,18 +47,18 @@ public void updateHUD(MinecraftServer server) {
4447
//#if MC >= 11900
4548
//$$ for (File f : File.listRoots()) {
4649
//$$ if (f.getPath().equals("/")) {
47-
//$$ list.add(Text.of("%s %sGB/%sGB %n".formatted("RootFileSystem", (f.getTotalSpace() - f.getFreeSpace()) / 1024 / 1024 / 1024, f.getTotalSpace() / 1024 / 1024 / 1024)));
50+
//$$ list.add(Text.of(Messenger.c("g %s %sGB/%sGB".formatted("RootFileSystem", (f.getTotalSpace() - f.getFreeSpace()) / toGB, f.getTotalSpace() / toGB))));
4851
//$$ } else {
49-
//$$ list.add(Text.of("%s %sGB/%sGB %n".formatted(f.getPath(), (f.getTotalSpace() - f.getFreeSpace()) / 1024 / 1024 / 1024, f.getTotalSpace() / 1024 / 1024 / 1024)));
52+
//$$ list.add(Text.of(Messenger.c("g %s %sGB/%sGB".formatted(f.getPath(), (f.getTotalSpace() - f.getFreeSpace()) / toGB, f.getTotalSpace() / toGB))));
5053
//$$ }
5154
//$$ }
5255
//$$ LoggerRegistry.getLogger("disk").log(() -> list.toArray(new Text[0]));
5356
//#else
5457
for (File f : File.listRoots()) {
5558
if (f.getPath().equals("/")) {
56-
list.add(new LiteralText("%s %sGB/%sGB %n".formatted("RootFileSystem", (f.getTotalSpace() - f.getFreeSpace()) / 1024 / 1024 / 1024, f.getTotalSpace() / 1024 / 1024 / 1024)));
59+
list.add(new LiteralText("%s %sGB/%sGB".formatted("RootFileSystem", (f.getTotalSpace() - f.getFreeSpace()) / toGB, f.getTotalSpace() / toGB)));
5760
} else {
58-
list.add(new LiteralText("%s %sGB/%sGB %n".formatted(f.getPath(), (f.getTotalSpace() - f.getFreeSpace()) / 1024 / 1024 / 1024, f.getTotalSpace() / 1024 / 1024 / 1024)));
61+
list.add(new LiteralText("%s %sGB/%sGB".formatted(f.getPath(), (f.getTotalSpace() - f.getFreeSpace()) / toGB, f.getTotalSpace() / toGB)));
5962
}
6063
}
6164
LoggerRegistry.getLogger("disk").log(() -> list.toArray(new BaseText[0]));

0 commit comments

Comments
 (0)