Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lines and fix a bug #66

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/net/cytonic/cytosis/CytonicNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.Getter;
import net.cytonic.cytosis.data.RedisDatabase;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -31,4 +30,4 @@ public void removePlayer(String name, UUID uuid) {
networkPlayers.remove(name);
networkPlayerUUIDs.remove(uuid);
}
}
}
1 change: 0 additions & 1 deletion src/main/java/net/cytonic/cytosis/Cytosis.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import net.minestom.server.network.ConnectionManager;
import net.minestom.server.permission.Permission;
import org.jetbrains.annotations.Nullable;

import java.util.*;

@Getter
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/cytonic/cytosis/auditlog/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public enum Category {
UNMUTE,
IPBAN,
IPUNBAN
}
}
2 changes: 1 addition & 1 deletion src/main/java/net/cytonic/cytosis/auditlog/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
import java.util.UUID;

public record Entry(UUID uuid, UUID actor, Category category, String reason) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import net.cytonic.cytosis.Cytosis;
import net.cytonic.cytosis.auditlog.Category;
import net.cytonic.cytosis.auditlog.Entry;
import net.cytonic.cytosis.enums.BanReason;
import net.cytonic.cytosis.data.enums.BanReason;
import net.cytonic.cytosis.logging.Logger;
import net.cytonic.cytosis.messaging.KickReason;
import net.cytonic.cytosis.data.enums.KickReason;
import net.cytonic.cytosis.utils.BanData;
import net.cytonic.cytosis.utils.DurationParser;
import net.cytonic.cytosis.utils.MessageUtils;
Expand All @@ -15,9 +15,7 @@
import net.minestom.server.command.builder.arguments.ArgumentType;
import net.minestom.server.command.builder.suggestion.SuggestionEntry;
import net.minestom.server.entity.Player;

import java.time.Instant;

import static net.cytonic.cytosis.utils.MiniMessageTemplate.MM;

public class BanCommand extends Command {
Expand Down Expand Up @@ -98,4 +96,4 @@ public BanCommand() {
}
}, playerArg, durationArg, reasonArg);
}
}
}
Empty file.
4 changes: 1 addition & 3 deletions src/main/java/net/cytonic/cytosis/data/DatabaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public class DatabaseManager {
private MysqlDatabase mysqlDatabase;
private RedisDatabase redisDatabase;

public DatabaseManager() {
}
public DatabaseManager() {}

public void shutdown() {
mysqlDatabase.disconnect();
Expand All @@ -31,5 +30,4 @@ public void setupDatabases() {
}
Logger.info("All mysqlDatabases connected.");
}

}
4 changes: 2 additions & 2 deletions src/main/java/net/cytonic/cytosis/data/MysqlDatabase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.cytonic.cytosis.data;

import net.cytonic.cytosis.Cytosis;
import net.cytonic.cytosis.auditlog.Category;
import net.cytonic.cytosis.auditlog.Entry;
import net.cytonic.cytosis.config.CytosisSettings;
Expand All @@ -15,7 +16,6 @@
import net.minestom.server.coordinate.Pos;
import net.minestom.server.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.net.SocketAddress;
import java.sql.*;
import java.time.Instant;
Expand Down Expand Up @@ -60,13 +60,13 @@ public void connect() {
try {
connection = DriverManager.getConnection(STR."jdbc:mysql://\{host}:\{port}/\{database}?useSSL=\{ssl}&autoReconnect=true&allowPublicKeyRetrieval=true", username, password);
Logger.info("Successfully connected to the MySQL Database!");
Cytosis.loadWorld();
} catch (SQLException e) {
Logger.error("Invalid Database Credentials!", e);
MinecraftServer.stopCleanly();
}
}
});

}

public void disconnect() {
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/net/cytonic/cytosis/data/RedisDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.cytonic.cytosis.config.CytosisSettings;
import net.cytonic.cytosis.logging.Logger;
import redis.clients.jedis.*;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -34,8 +33,6 @@ public RedisDatabase() {
JedisClientConfig config = DefaultJedisClientConfig.builder().password(CytosisSettings.REDIS_PASSWORD).build();
this.jedis = new Jedis(hostAndPort, config);
this.jedis.auth(CytosisSettings.REDIS_PASSWORD);


onlinePlayers = jedis.smembers(ONLINE_PLAYER_NAME_KEY);
Set<UUID> uuids = new HashSet<>();
jedis.smembers(ONLINE_PLAYER_UUID_KEY).forEach(s -> uuids.add(UUID.fromString(s)));
Expand All @@ -48,7 +45,6 @@ public void sendShutdownMessage() {
jedis.set(SERVER_SHUTDOWN_KEY, "");
}


/**
* Consumes messages on the redis pub/sub interface to determine the online players
*
Expand All @@ -72,4 +68,4 @@ public void onMessage(String channel, String message) {
public void disconnect() {
jedis.disconnect();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.cytonic.cytosis.enums;
package net.cytonic.cytosis.data.enums;

import lombok.Getter;

Expand All @@ -18,4 +18,4 @@ public enum BanReason {
BanReason(String reason) {
this.reason = reason;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.cytonic.cytosis.messaging;
package net.cytonic.cytosis.data.enums;

import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.cytonic.cytosis.config.CytosisSettings;
import net.cytonic.cytosis.data.enums.ChatChannel;
import net.cytonic.cytosis.logging.Logger;
import net.cytonic.cytosis.messaging.KickReason;
import net.cytonic.cytosis.data.enums.KickReason;
import net.cytonic.cytosis.utils.MessageUtils;
import net.kyori.adventure.text.Component;
import net.minestom.server.entity.Player;
Expand Down Expand Up @@ -34,7 +34,6 @@ public static void initServerEvents() {
player.kick(MM."<red>An error occured whilst initiating the login sequence!");
return;
}

if (data.isBanned()) {
Cytosis.getMessagingManager().getRabbitMQ().kickPlayer(player, KickReason.BANNED, MessageUtils.formatBanMessage(data));
return;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/cytonic/cytosis/messaging/RabbitMQ.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import net.cytonic.cytosis.Cytosis;
import net.cytonic.cytosis.config.CytosisSettings;
import net.cytonic.cytosis.data.enums.ChatChannel;
import net.cytonic.cytosis.data.enums.KickReason;
import net.cytonic.cytosis.logging.Logger;
import net.cytonic.cytosis.utils.OfflinePlayer;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.json.JSONComponentSerializer;
import net.minestom.server.entity.Player;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
Expand Down Expand Up @@ -48,18 +48,18 @@ public void initializeConnection() {
public void initializeQueues() {
Logger.info("Initializing RabbitMQ queues...");
try {
channel.queueDeclare(SERVER_DECLARE_QUEUE, false, false, true, null);
channel.queueDeclare(SERVER_DECLARE_QUEUE, false, false, false, null);
} catch (IOException e) {
Logger.error("An error occurred whilst initializing the 'SERVER_DECLARE_QUEUE'.", e);
}
try {
channel.queueDeclare(SHUTDOWN_QUEUE, false, false, true, null);
channel.queueDeclare(SHUTDOWN_QUEUE, false, false, false, null);
} catch (IOException e) {
Logger.error("An error occurred whilst initializing the 'SHUTDOWN_QUEUE'.", e);
}
try {
channel.exchangeDeclare(CHAT_CHANNEL_EXCHANGE, BuiltinExchangeType.FANOUT);
channel.queueDeclare(CHAT_CHANNEL_QUEUE, false, false, false, null);
channel.queueDeclare(CHAT_CHANNEL_QUEUE, false, false, true, null);
channel.queueBind(CHAT_CHANNEL_QUEUE, CHAT_CHANNEL_EXCHANGE, "");
} catch (IOException e) {
Logger.error("An error occurred whilst initializing the 'CHAT_CHANNEL_QUEUE'.", e);
Expand Down Expand Up @@ -183,4 +183,4 @@ public void receiveChatMessages() {
Logger.error("error", e);
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ enabled = false
host = "" # RabbitMQ host or IP address
port = 5672 # Default RabbitMQ port
username = "" # username login to RabbitMQ server
password = "" # password to login to RabbitMQ server
password = "" # password to login to RabbitMQ server