Skip to content

Commit

Permalink
refactor: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed May 9, 2024
1 parent 6aab779 commit 5479fa4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 52 deletions.
22 changes: 0 additions & 22 deletions core/src/main/java/io/th0rgal/oraxen/font/Font.java

This file was deleted.

29 changes: 0 additions & 29 deletions core/src/main/java/io/th0rgal/oraxen/font/FontManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.th0rgal.oraxen.font.packets.TitlePacketListener;
import io.th0rgal.oraxen.nms.GlyphHandlers;
import io.th0rgal.oraxen.nms.NMSHandlers;
import io.th0rgal.oraxen.utils.OraxenYaml;
import io.th0rgal.oraxen.utils.PluginUtils;
import io.th0rgal.oraxen.utils.VersionUtil;
import io.th0rgal.oraxen.utils.logs.Logs;
Expand All @@ -26,10 +25,6 @@
import team.unnamed.creative.font.BitMapFontProvider;
import team.unnamed.creative.font.FontProvider;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.*;
import java.util.stream.Stream;

Expand Down Expand Up @@ -111,30 +106,6 @@ private void loadGlyphs(Collection<Glyph> glyphs) {
}
}

private void checkYamlKeys(File file) {
File tempFile = new File(OraxenPlugin.get().getDataFolder() + "/glyphs/temp.yml");
try {
Files.copy(Objects.requireNonNull(OraxenPlugin.get().getResource("glyphs/" + file.getName())), tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
if (!file.exists()) {
OraxenPlugin.get().saveResource("glyphs/" + file.getName(), false);
}
// Check if file is equal to the resource
else if (!Settings.DISABLE_AUTOMATIC_GLYPH_CODE.toBool()) {
List<String> tempKeys = OraxenYaml.loadConfiguration(tempFile).getKeys(false).stream().toList();
List<String> requiredKeys = OraxenYaml.loadConfiguration(file).getKeys(false).stream().toList();
if (!new HashSet<>(requiredKeys).containsAll(tempKeys)) {
file.renameTo(new File(OraxenPlugin.get().getDataFolder() + "/glyphs/" + file.getName() + ".old"));
OraxenPlugin.get().saveResource("glyphs/" + file.getName(), true);
Logs.logWarning("glyphs/" + file.getName() + " was incorrect, renamed to .old and regenerated the default one");
}
}
} catch (IOException e) {
file.renameTo(new File(OraxenPlugin.get().getDataFolder() + "/glyphs/" + file.getName() + ".old"));
OraxenPlugin.get().saveResource("glyphs/" + file.getName(), true);
}
tempFile.delete();
}

public final Collection<Glyph> glyphs() {
return glyphMap.values();
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/io/th0rgal/oraxen/font/ShiftTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ShiftTag {
public static final TagResolver RESOLVER = TagResolver.resolver(Set.of(SHIFT, SHIFT_SHORT), (args, ctx) -> shiftTag(args));

private static Tag shiftTag(final ArgumentQueue args) {
return Tag.selfClosingInserting(Component.text(Shift.of(ParseUtils.parseInt(args.popOr("A shift value is required").value(), 0))));
int shift = ParseUtils.parseInt(args.popOr("A shift value is required").value(), 0);
return Tag.selfClosingInserting(Component.text(Shift.of(shift)));
}
}

0 comments on commit 5479fa4

Please sign in to comment.