mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-11-13 18:46:15 +00:00
refactor: use LF line endings and use 4 spaces on all classes
This commit is contained in:
parent
43527d9e6e
commit
50db974497
25 changed files with 2298 additions and 2255 deletions
|
|
@ -81,6 +81,11 @@ public class CommandManager {
|
|||
return text;
|
||||
}
|
||||
|
||||
public static LiteralArgumentBuilder<FabricClientCommandSource> literal (String name) { return LiteralArgumentBuilder.literal(name); }
|
||||
public static <T> RequiredArgumentBuilder<FabricClientCommandSource, T> argument (String name, ArgumentType<T> type) { return RequiredArgumentBuilder.argument(name, type); }
|
||||
public static LiteralArgumentBuilder<FabricClientCommandSource> literal(String name) {
|
||||
return LiteralArgumentBuilder.literal(name);
|
||||
}
|
||||
|
||||
public static <T> RequiredArgumentBuilder<FabricClientCommandSource, T> argument(String name, ArgumentType<T> type) {
|
||||
return RequiredArgumentBuilder.argument(name, type);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ import land.chipmunk.chipmunkmod.util.TextUtilities;
|
|||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import land.chipmunk.chipmunkmod.modules.CommandCore;
|
||||
|
||||
public class CoreCommand {
|
||||
|
|
@ -99,7 +101,7 @@ public class CoreCommand {
|
|||
|
||||
CommandCore.INSTANCE.runFillCommand = bool;
|
||||
|
||||
source.sendFeedback(Text.literal("Running fill commands are now " + (bool ? "enabled" : "disabled")));
|
||||
source.sendFeedback(Text.literal("Running fill commands is now " + (bool ? "enabled" : "disabled")));
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@ import com.mojang.brigadier.Command;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
|
||||
import static net.minecraft.command.argument.ItemStackArgumentType.itemStack;
|
||||
import static net.minecraft.command.argument.ItemStackArgumentType.getItemStackArgument;
|
||||
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ package land.chipmunk.chipmunkmod.commands;
|
|||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ package land.chipmunk.chipmunkmod.commands;
|
|||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
|
|
@ -17,6 +19,7 @@ import net.minecraft.client.session.Session;
|
|||
import net.minecraft.text.Text;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,9 @@ public class Configuration {
|
|||
public @Nullable String authKey;
|
||||
public @Nullable String formatKey;
|
||||
|
||||
public ChomeNSBotInfo() {}
|
||||
public ChomeNSBotInfo() {
|
||||
}
|
||||
|
||||
public ChomeNSBotInfo(String prefix, @Nullable String key, @Nullable String authKey, @Nullable String formatKey) {
|
||||
this.prefix = prefix;
|
||||
this.key = key;
|
||||
|
|
@ -58,7 +60,9 @@ public class Configuration {
|
|||
public String prefix;
|
||||
public @Nullable String webhookUrl;
|
||||
|
||||
public TestBotInfo() {}
|
||||
public TestBotInfo() {
|
||||
}
|
||||
|
||||
public TestBotInfo(String prefix, @Nullable String webhookUrl) {
|
||||
this.prefix = prefix;
|
||||
this.webhookUrl = webhookUrl;
|
||||
|
|
@ -70,7 +74,9 @@ public class Configuration {
|
|||
public String prefix;
|
||||
public @Nullable String key;
|
||||
|
||||
public BotInfo() {}
|
||||
public BotInfo() {
|
||||
}
|
||||
|
||||
public BotInfo(String prefix, @Nullable String key) {
|
||||
this.prefix = prefix;
|
||||
this.key = key;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ public record ChomeNSBotCommand(String name, TrustLevel trustLevel, List<String>
|
|||
|
||||
try {
|
||||
return TrustLevel.valueOf(trustLevelString);
|
||||
} catch (final IllegalArgumentException ignored) {}
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ public class ChatInputSuggestorMixin {
|
|||
private CompletableFuture<Suggestions> pendingSuggestions;
|
||||
|
||||
@Shadow
|
||||
public void show (boolean narrateFirstSuggestion) {}
|
||||
public void show(boolean narrateFirstSuggestion) {
|
||||
}
|
||||
|
||||
@Shadow
|
||||
private static int getStartOfCurrentWord(String input) {
|
||||
|
|
|
|||
|
|
@ -28,15 +28,20 @@ import java.util.List;
|
|||
|
||||
@Mixin(value = net.minecraft.client.gui.screen.ChatScreen.class)
|
||||
public abstract class ChatScreenMixin extends Screen {
|
||||
@Shadow private String originalChatText;
|
||||
@Shadow
|
||||
private String originalChatText;
|
||||
|
||||
@Shadow private int messageHistoryIndex;
|
||||
@Shadow
|
||||
private int messageHistoryIndex;
|
||||
|
||||
@Shadow protected TextFieldWidget chatField;
|
||||
@Shadow
|
||||
protected TextFieldWidget chatField;
|
||||
|
||||
@Shadow ChatInputSuggestor chatInputSuggestor;
|
||||
@Shadow
|
||||
ChatInputSuggestor chatInputSuggestor;
|
||||
|
||||
@Shadow protected abstract void onChatFieldUpdate(String chatText);
|
||||
@Shadow
|
||||
protected abstract void onChatFieldUpdate(String chatText);
|
||||
|
||||
protected ChatScreenMixin(Text title) {
|
||||
super(title);
|
||||
|
|
@ -130,7 +135,8 @@ public abstract class ChatScreenMixin extends Screen {
|
|||
cir.cancel();
|
||||
|
||||
return;
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,12 +36,17 @@ import java.time.Instant;
|
|||
@Mixin(value = net.minecraft.client.network.ClientPlayNetworkHandler.class, priority = 1001)
|
||||
public class ClientPlayNetworkHandlerMixin {
|
||||
@Final
|
||||
@Shadow private FeatureSet enabledFeatures;
|
||||
@Shadow
|
||||
private FeatureSet enabledFeatures;
|
||||
@Final
|
||||
@Shadow private DynamicRegistryManager.Immutable combinedDynamicRegistries;
|
||||
@Shadow private LastSeenMessagesCollector lastSeenMessagesCollector;
|
||||
@Shadow private MessageChain.Packer messagePacker;
|
||||
@Shadow private CommandDispatcher<CommandSource> commandDispatcher;
|
||||
@Shadow
|
||||
private DynamicRegistryManager.Immutable combinedDynamicRegistries;
|
||||
@Shadow
|
||||
private LastSeenMessagesCollector lastSeenMessagesCollector;
|
||||
@Shadow
|
||||
private MessageChain.Packer messagePacker;
|
||||
@Shadow
|
||||
private CommandDispatcher<CommandSource> commandDispatcher;
|
||||
|
||||
@Inject(method = "onGameJoin", at = @At("TAIL"))
|
||||
private void onGameJoin(GameJoinS2CPacket packet, CallbackInfo ci) {
|
||||
|
|
@ -80,7 +85,8 @@ public class ClientPlayNetworkHandlerMixin {
|
|||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
} catch (ClassCastException ignored) {}
|
||||
} catch (ClassCastException ignored) {
|
||||
}
|
||||
|
||||
for (Listener listener : ListenerManager.listeners) {
|
||||
listener.chatMessageReceived(message);
|
||||
|
|
@ -93,8 +99,10 @@ public class ClientPlayNetworkHandlerMixin {
|
|||
if (suggestionId.equals(ChomeNSBotCommandSuggestions.ID) || authId.equals(ChomeNSAuth.INSTANCE.id)) {
|
||||
ci.cancel();
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ public class SelfCare implements Listener {
|
|||
ListenerManager.addListener(this);
|
||||
}
|
||||
|
||||
public void init () {}
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public void onJoin() {
|
||||
final TimerTask task = new TimerTask() {
|
||||
|
|
@ -111,16 +112,20 @@ public class SelfCare implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
if (player != null && !player.hasPermissionLevel(2) && opEnabled) { if (serverHasCommand("op")) networkHandler.sendChatCommand("op @s[type=player]"); }
|
||||
else if (gameMode != 1 && gamemodeEnabled) networkHandler.sendChatCommand("gamemode creative");
|
||||
if (player != null && !player.hasPermissionLevel(2) && opEnabled) {
|
||||
if (serverHasCommand("op")) networkHandler.sendChatCommand("op @s[type=player]");
|
||||
} else if (gameMode != 1 && gamemodeEnabled) networkHandler.sendChatCommand("gamemode creative");
|
||||
else if (positionPacketsPerSecond >= 10 && icuEnabled) CommandCore.INSTANCE.run("sudo * icu stop");
|
||||
}
|
||||
|
||||
public void chatTick() {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (!cspy && cspyEnabled) { if (serverHasCommand("c")) networkHandler.sendChatCommand("c on"); }
|
||||
else if (!hasSkin && !skin.equals("off")) { if (serverHasCommand("skin")) networkHandler.sendChatCommand("skin " + skin); }
|
||||
if (!cspy && cspyEnabled) {
|
||||
if (serverHasCommand("c")) networkHandler.sendChatCommand("c on");
|
||||
} else if (!hasSkin && !skin.equals("off")) {
|
||||
if (serverHasCommand("skin")) networkHandler.sendChatCommand("skin " + skin);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class Instrument {
|
|||
}
|
||||
|
||||
private static Instrument[] values = {HARP, BASEDRUM, SNARE, HAT, BASS, FLUTE, BELL, GUITAR, CHIME, XYLOPHONE, IRON_XYLOPHONE, COW_BELL, DIDGERIDOO, BIT, BANJO, PLING};
|
||||
|
||||
public static Instrument fromId(int id) {
|
||||
return values[id];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package land.chipmunk.chipmunkmod.song;
|
||||
|
||||
import land.chipmunk.chipmunkmod.util.DownloadUtilities;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.file.Paths;
|
||||
|
|
@ -82,8 +83,7 @@ public class MidiConverter {
|
|||
ShortMessage sm = (ShortMessage) message;
|
||||
if (sm.getCommand() == SET_INSTRUMENT) {
|
||||
ids[sm.getChannel()] = sm.getData1();
|
||||
}
|
||||
else if (sm.getCommand() == NOTE_ON) {
|
||||
} else if (sm.getCommand() == NOTE_ON) {
|
||||
if (sm.getData2() == 0) continue;
|
||||
int pitch = sm.getData1();
|
||||
int velocity = sm.getData2();
|
||||
|
|
@ -94,8 +94,7 @@ public class MidiConverter {
|
|||
Note note;
|
||||
if (sm.getChannel() == 9) {
|
||||
note = getMidiPercussionNote(pitch, velocity, microTime);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
note = getMidiInstrumentNote(ids[sm.getChannel()], pitch, velocity, microTime);
|
||||
}
|
||||
if (note != null) {
|
||||
|
|
@ -106,8 +105,7 @@ public class MidiConverter {
|
|||
if (time > song.length) {
|
||||
song.length = time;
|
||||
}
|
||||
}
|
||||
else if (sm.getCommand() == NOTE_OFF) {
|
||||
} else if (sm.getCommand() == NOTE_OFF) {
|
||||
long deltaTick = event.getTick() - prevTick;
|
||||
prevTick = event.getTick();
|
||||
microTime += (mpq / tpq) * deltaTick;
|
||||
|
|
@ -162,6 +160,7 @@ public class MidiConverter {
|
|||
}
|
||||
|
||||
public static HashMap<Integer, Instrument[]> instrumentMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
// Piano (HARP BASS BELL)
|
||||
instrumentMap.put(0, new Instrument[]{Instrument.HARP, Instrument.BASS, Instrument.BELL}); // Acoustic Grand Piano
|
||||
|
|
@ -315,6 +314,7 @@ public class MidiConverter {
|
|||
}
|
||||
|
||||
public static HashMap<Integer, Integer> percussionMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
percussionMap.put(35, 10 + 25 * Instrument.BASEDRUM.id);
|
||||
percussionMap.put(36, 6 + 25 * Instrument.BASEDRUM.id);
|
||||
|
|
|
|||
|
|
@ -18,11 +18,9 @@ public class Note implements Comparable<Note> {
|
|||
public int compareTo(Note other) {
|
||||
if (time < other.time) {
|
||||
return -1;
|
||||
}
|
||||
else if (time > other.time) {
|
||||
} else if (time > other.time) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package land.chipmunk.chipmunkmod.song;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@ public class DownloadUtilities {
|
|||
private static class DefaultTrustManager implements X509TrustManager {
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] arg0, String arg1) {}
|
||||
public void checkClientTrusted(X509Certificate[] arg0, String arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] arg0, String arg1) {}
|
||||
public void checkServerTrusted(X509Certificate[] arg0, String arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue