diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Main.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Main.java index 3ec5506..9ddfb8a 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Main.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Main.java @@ -31,6 +31,9 @@ public class Main { if (!file.exists()) { // creates config file from default-config.yml InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("default-config.yml"); + + if (is == null) System.exit(1); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder stringBuilder = new StringBuilder(); while (reader.ready()) { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/KaboomChatParser.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/KaboomChatParser.java index 1dfbcb3..ac0081b 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/KaboomChatParser.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/KaboomChatParser.java @@ -11,9 +11,7 @@ import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.format.Style; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.UUID; public class KaboomChatParser implements ChatParser { @@ -47,8 +45,6 @@ public class KaboomChatParser implements ChatParser { if (!message.content().equals("") || !message.style().equals(empty) || children.size() < 3) return null; - final Map parameters = new HashMap<>(); - final Component prefix = children.get(0); Component displayName = Component.empty(); Component contents = Component.empty(); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CowsayCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CowsayCommand.java index e3c11e3..7d95bab 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CowsayCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CowsayCommand.java @@ -7,7 +7,6 @@ import land.chipmunk.chayapak.chomens_bot.command.TrustLevel; import net.kyori.adventure.text.Component; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class CowsayCommand implements Command { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java index a382056..76eb273 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java @@ -6,7 +6,6 @@ import land.chipmunk.chayapak.chomens_bot.command.CommandContext; import land.chipmunk.chayapak.chomens_bot.command.TrustLevel; import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java index 55a4946..d3db0f7 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java @@ -28,7 +28,7 @@ public class MusicCommand implements Command { public String name() { return "music"; } public String description() { - return "Plays music"; + return "Play musics"; } public List usage() { @@ -119,6 +119,8 @@ public class MusicCommand implements Command { } else { final String[] songs = root.toFile().list(); + if (songs == null) return null; + final String file = Arrays.stream(songs) .filter(song -> song.toLowerCase().contains(_path.toLowerCase())) .toArray(String[]::new)[0]; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RefillCoreCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RefillCoreCommand.java index 3dd370c..52d4072 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RefillCoreCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RefillCoreCommand.java @@ -13,7 +13,7 @@ public class RefillCoreCommand implements Command { public String name() { return "refillcore"; } public String description() { - return "Refills and resets the bot's command core"; + return "Refills and resets the bots command core"; } public List usage() { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java index 22bb30a..7c172e5 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java @@ -6,7 +6,6 @@ import land.chipmunk.chayapak.chomens_bot.command.CommandContext; import land.chipmunk.chayapak.chomens_bot.command.TrustLevel; import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; import java.io.IOException; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UptimeCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UptimeCommand.java index 6011ccd..bf473c6 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UptimeCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UptimeCommand.java @@ -17,7 +17,7 @@ public class UptimeCommand implements Command { public String name() { return "uptime"; } public String description() { - return "Shows the bot's uptime"; + return "Shows the bots uptime"; } public List usage() { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/data/CommandLoop.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/data/CommandLoop.java index fecdae7..0b548cf 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/data/CommandLoop.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/data/CommandLoop.java @@ -1,16 +1,11 @@ package land.chipmunk.chayapak.chomens_bot.data; +import lombok.AllArgsConstructor; import lombok.Getter; +@AllArgsConstructor public class CommandLoop { - @Getter - private String command; - @Getter - private int interval; - - public CommandLoop (String command, int interval) { - this.command = command; - this.interval = interval; - } + @Getter private String command; + @Getter private int interval; } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/data/Team.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/data/Team.java index a87cb05..bfc706d 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/data/Team.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/data/Team.java @@ -3,14 +3,11 @@ package land.chipmunk.chayapak.chomens_bot.data; import com.github.steveice10.mc.protocol.data.game.scoreboard.CollisionRule; import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility; import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor; -import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.Component; -import java.util.List; - @AllArgsConstructor public class Team { @Getter @Setter private String teamName; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/data/voiceChat/Codec.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/data/voiceChat/Codec.java index b00d579..1fb4fc0 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/data/voiceChat/Codec.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/data/voiceChat/Codec.java @@ -3,5 +3,5 @@ package land.chipmunk.chayapak.chomens_bot.data.voiceChat; public enum Codec { VOIP, AUDIO, - RESTRICTED_LOWDELAY; + RESTRICTED_LOWDELAY } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/BossbarManagerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/BossbarManagerPlugin.java index 0683ae9..d3cd6cf 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/BossbarManagerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/BossbarManagerPlugin.java @@ -55,7 +55,7 @@ public class BossbarManagerPlugin extends Bot.Listener { } // is there any way instead of using random? - bot.core().run("minecraft:data modify entity @e[tag=" + textDisplayPrefix + name + ",limit=1,sort=random] text set value '" + stringifiedComponent.replace("'", "\\\'") + "'"); + bot.core().run("minecraft:data modify entity @e[tag=" + textDisplayPrefix + name + ",limit=1,sort=random] text set value '" + stringifiedComponent.replace("'", "\\'") + "'"); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java index 8c25f60..aa690bc 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java @@ -8,6 +8,7 @@ import land.chipmunk.chayapak.chomens_bot.commands.*; import land.chipmunk.chayapak.chomens_bot.util.ExceptionUtilities; import lombok.Getter; import lombok.Setter; +import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.kyori.adventure.text.Component; @@ -118,7 +119,11 @@ public class CommandHandlerPlugin { if (command.trustLevel() != TrustLevel.PUBLIC && !console) { if (discord) { - final List roles = event.getMember().getRoles(); + final Member member = event.getMember(); + + if (member == null) return null; + + final List roles = member.getRoles(); final String trustedRoleName = bot.config().discord().trustedRoleName(); final String adminRoleName = bot.config().discord().adminRoleName(); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java index c1b900f..73bc212 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java @@ -311,6 +311,12 @@ public class DiscordPlugin { public void sendMessageInstantly (String message, String channelId) { if (jda == null) return; final TextChannel logChannel = jda.getTextChannelById(channelId); + + if (logChannel == null) { + System.out.println("Log channel for " + channelId + " is null"); + return; + } + logChannel.sendMessage(message).queue( (msg) -> doneSendingInLogs.put(channelId, true), (err) -> doneSendingInLogs.put(channelId, false) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java index 57df1db..03466b9 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java @@ -43,6 +43,8 @@ public class FilterPlugin extends PlayersPlugin.Listener { } } + if (pattern == null) break; + if (pattern.matcher(name).find()) { filteredPlayer = _filteredPlayer; break; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java index 25f9874..4ea43c0 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java @@ -27,9 +27,7 @@ public class MusicPlayerPlugin extends Bot.Listener { public static final String SELECTOR = "@a[tag=!nomusic,tag=!chomens_bot_nomusic]"; public static File SONG_DIR = new File("songs"); static { - if (!SONG_DIR.exists()) { - SONG_DIR.mkdir(); - } + if (!SONG_DIR.exists()) SONG_DIR.mkdir(); } @Getter @Setter private Song currentSong; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TeamPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TeamPlugin.java index c0d4edc..ad930f2 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TeamPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TeamPlugin.java @@ -74,8 +74,4 @@ public class TeamPlugin extends Bot.Listener { } } catch (Exception e) { e.printStackTrace(); } } - - public Team getTeamByUsername (String username) { - return teamsByPlayer.get(username); - } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java index 06330c3..eb06f62 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java @@ -53,10 +53,6 @@ public class TrustedPlugin extends PlayersPlugin.Listener { public void broadcast (Component message) { broadcast(message, null); } - // these can be used in servereval - public void broadcast (String message) { broadcast(Component.text(message), null); } - public void broadcast (String message, UUID exceptTarget) { broadcast(Component.text(message), exceptTarget); } - @Override public void playerJoined (MutablePlayerListEntry target) { if (!list.contains(target.profile().getName())) return; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java index 5ccb08e..2f82f47 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java @@ -23,7 +23,6 @@ public class VoiceChatPlugin extends Bot.Listener { private InitializationData initializationData; private ClientVoiceChatSocket socket; - private InetAddress address; private InetSocketAddress socketAddress; private boolean running = false; @@ -70,7 +69,7 @@ public class VoiceChatPlugin extends Bot.Listener { initializationData = new InitializationData(bot.options().host(), secretPacket); try { - address = InetAddress.getByName(bot.options().host()); + final InetAddress address = InetAddress.getByName(bot.options().host()); socketAddress = new InetSocketAddress(address, initializationData.serverPort()); } catch (UnknownHostException e) { throw new RuntimeException(e); @@ -115,7 +114,7 @@ public class VoiceChatPlugin extends Bot.Listener { } } - private class VoiceChatSocketBase { + private static class VoiceChatSocketBase { private final byte[] BUFFER = new byte[4096]; public RawUdpPacket read (DatagramSocket socket) { @@ -146,7 +145,7 @@ public class VoiceChatPlugin extends Bot.Listener { running = false; } - private class ClientVoiceChatSocket extends VoiceChatSocketBase { + private static class ClientVoiceChatSocket extends VoiceChatSocketBase { private DatagramSocket socket; public void open() throws SocketException { @@ -173,9 +172,5 @@ public class VoiceChatPlugin extends Bot.Listener { socket = null; } } - - public boolean isClosed() { - return socket == null; - } } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Instrument.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Instrument.java index ad19d65..00ab03d 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Instrument.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Instrument.java @@ -38,7 +38,7 @@ public class Instrument { return new Instrument(-1, null, 0, sound); } - private static Instrument[] values = {HARP, BASEDRUM, SNARE, HAT, BASS, FLUTE, BELL, GUITAR, CHIME, XYLOPHONE, IRON_XYLOPHONE, COW_BELL, DIDGERIDOO, BIT, BANJO, PLING}; + private static final 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]; } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java index ad8b508..97a0ffa 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java @@ -16,16 +16,6 @@ public class MidiConverter { public static final int NOTE_ON = 0x90; public static final int NOTE_OFF = 0x80; -// public static Song getSongFromUrl(URL url) throws IOException, InvalidMidiDataException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException { -// Sequence sequence = MidiSystem.getSequence(DownloadUtilities.DownloadToInputStream(url, 5*1024*1024)); -// return getSong(sequence, Paths.get(url.toURI().getPath()).getFileName().toString()); -// } -// -// public static Song getSongFromFile(File file) throws InvalidMidiDataException, IOException { -// Sequence sequence = MidiSystem.getSequence(file); -// return getSong(sequence, file.getName()); -// } - public static Song getSongFromBytes(byte[] bytes, String name, Bot bot) throws InvalidMidiDataException, IOException { Sequence sequence = MidiSystem.getSequence(new ByteArrayInputStream(bytes)); return getSong(sequence, name, bot); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Note.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Note.java index d36e436..e12d4b6 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Note.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Note.java @@ -14,18 +14,6 @@ public class Note implements Comparable { @Override public int compareTo(Note other) { - if (time < other.time) { - return -1; - } - else if (time > other.time) { - return 1; - } - else { - return 0; - } - } - - public int noteId () { - return pitch + instrument.id * 25; + return Long.compare(time, other.time); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/SongLoaderException.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/SongLoaderException.java index 8d9a150..6b6f040 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/SongLoaderException.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/SongLoaderException.java @@ -11,9 +11,4 @@ public class SongLoaderException extends Exception { super(); this.message = message; } - - public SongLoaderException (Component message, Throwable cause) { - super(null, cause); - this.message = message; - } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/SongLoaderRunnable.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/SongLoaderRunnable.java index 838c98e..440a9ae 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/SongLoaderRunnable.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/SongLoaderRunnable.java @@ -94,8 +94,4 @@ public class SongLoaderRunnable implements Runnable { private void showFailedMessage () { bot.chat().tellraw(Component.translatable("Failed to load song: %s", exception.message()).color(NamedTextColor.RED)); } - - private File getSongFile (String name) { - return new File(MusicPlayerPlugin.SONG_DIR, name); - } } \ No newline at end of file diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/AES.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/AES.java index cc04f7f..c6af9ab 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/AES.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/AES.java @@ -25,13 +25,6 @@ public class AES { return buffer.array(); } - public static UUID getUUIDFromBytes(byte[] bytes) { - ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); - long most = byteBuffer.getLong(); - long least = byteBuffer.getLong(); - return new UUID(most, least); - } - private static byte[] generateIV() { byte[] iv = new byte[16]; RANDOM.nextBytes(iv); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/DownloadUtilities.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/DownloadUtilities.java index 7dd6c70..9cf4467 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/DownloadUtilities.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/DownloadUtilities.java @@ -55,8 +55,4 @@ public class DownloadUtilities { } // Closing a ByteArrayInputStream has no effect, so I do not close it. } - - public static InputStream DownloadToInputStream(URL url, int maxSize) throws KeyManagementException, NoSuchAlgorithmException, IOException { - return new ByteArrayInputStream(DownloadToByteArray(url, maxSize)); - } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/FriendlyByteBuf.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/FriendlyByteBuf.java index 5b526a9..e4c607e 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/FriendlyByteBuf.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/FriendlyByteBuf.java @@ -29,14 +29,9 @@ public class FriendlyByteBuf extends ByteBuf { this(Unpooled.buffer()); } - public ByteBuf getUnderlyingByteBuf() { - return buf; - } - - public FriendlyByteBuf writeByteArray(byte[] bs) { + public void writeByteArray(byte[] bs) { writeVarInt(bs.length); writeBytes(bs); - return this; } public byte[] readByteArray() { @@ -70,24 +65,22 @@ public class FriendlyByteBuf extends ByteBuf { return i; } - public FriendlyByteBuf writeUUID(UUID uUID) { + public void writeUUID(UUID uUID) { writeLong(uUID.getMostSignificantBits()); writeLong(uUID.getLeastSignificantBits()); - return this; } public UUID readUUID() { return new UUID(readLong(), readLong()); } - public FriendlyByteBuf writeVarInt(int i) { + public void writeVarInt(int i) { while ((i & -128) != 0) { writeByte(i & 127 | 128); i >>>= 7; } writeByte(i); - return this; } public String readUtf(int i) { @@ -107,14 +100,13 @@ public class FriendlyByteBuf extends ByteBuf { } } - public FriendlyByteBuf writeUtf(String string, int i) { + public void writeUtf(String string, int i) { byte[] bs = string.getBytes(StandardCharsets.UTF_8); if (bs.length > i) { throw new EncoderException("String too big (was " + bs.length + " bytes encoded, max " + i + ')'); } else { writeVarInt(bs.length); writeBytes(bs); - return this; } } @@ -122,8 +114,8 @@ public class FriendlyByteBuf extends ByteBuf { return readUtf(32767); } - public FriendlyByteBuf writeUtf(String string) { - return writeUtf(string, 32767); + public void writeUtf(String string) { + writeUtf(string, 32767); } @Override diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/IllegalCharactersUtilities.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/IllegalCharactersUtilities.java index eb16c57..2246e6d 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/IllegalCharactersUtilities.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/IllegalCharactersUtilities.java @@ -3,7 +3,7 @@ package land.chipmunk.chayapak.chomens_bot.util; // Original code made by _ChipMC_ IIRC and I ported it to Java public class IllegalCharactersUtilities { public static boolean isAllowedCharacter (char character) { - return character != '\u00a7' && character != '\u007f'; + return character != 'ยง' && character != '\u007f'; } public static boolean containsIllegalCharacters (String string) { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/LoggerUtilities.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/LoggerUtilities.java index 6070b59..9f3a558 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/LoggerUtilities.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/LoggerUtilities.java @@ -106,11 +106,6 @@ public class LoggerUtilities { out.close(); } - public static synchronized BufferedReader getLogReader(File file) throws IOException { - GZIPInputStream in = new GZIPInputStream(new FileInputStream(file)); - return new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); - } - public static synchronized String getLogDate(File file) throws IOException { InputStreamReader isr = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); BufferedReader reader = new BufferedReader(isr); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/voiceChat/InitializationData.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/voiceChat/InitializationData.java index aea4a2c..36c0aca 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/voiceChat/InitializationData.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/voiceChat/InitializationData.java @@ -30,15 +30,4 @@ public class InitializationData { this.groupsEnabled = secretPacket.groupsEnabled(); this.allowRecording = secretPacket.allowRecording(); } - - private static class HostData { - private final String ip; - private final int port; - - public HostData(String ip, int port) { - this.ip = ip; - this.port = port; - } - } - } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/voiceChat/NetworkMessage.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/voiceChat/NetworkMessage.java index 7cabc50..3fa0d6a 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/voiceChat/NetworkMessage.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/voiceChat/NetworkMessage.java @@ -26,11 +26,6 @@ public class NetworkMessage { @Getter private Packet> packet; @Getter private SocketAddress address; - public NetworkMessage(long timestamp, Packet packet) { - this(timestamp); - this.packet = packet; - } - public NetworkMessage(Packet packet) { this(System.currentTimeMillis()); this.packet = packet;