Skip to content

Commit

Permalink
Fixed on friend join vanish bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Smudgge committed Jan 4, 2024
1 parent 6884c9b commit 0638a34
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.github.smuddgge</groupId>
<artifactId>Leaf</artifactId>
<name>Leaf</name>
<version>4.4.1</version>
<version>4.4.3</version>
<description>A velocity utility plugin</description>
<build>
<resources>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.smuddgge</groupId>
<artifactId>Leaf</artifactId>
<version>4.4.2</version>
<version>4.4.3</version>
<packaging>jar</packaging>

<name>Leaf</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,24 @@ public CommandStatus onPlayerRun(ConfigurationSection section, String[] argument
// Get who the message is being sent to.
User recipient = new User(optionalRecipient.get());

MessageManager.log("[DEBUG] Check if muted");
MessageManager.log("[DEBUG] Check if muted.");

// Check if this user is muted.
if (user.isMuted()) {
user.sendMessage(section.getString("you_are_muted", "&7You are muted."));
return new CommandStatus();
}

MessageManager.log("[DEBUG] Checked if the player is muted");
MessageManager.log("[DEBUG] Check if muted 2");
MessageManager.log("[DEBUG] Checked if the player is muted.");
MessageManager.log("[DEBUG] Check if muted 2.");

// Check if you cannot message muted players.
if (recipient.isMuted() && !section.getBoolean("message_muted_players", true)) {
user.sendMessage(section.getString("recipient_muted", "&7Cannot send a message to a muted player."));
return new CommandStatus();
}

MessageManager.log("[DEBUG] Checked if the player is muted 2");
MessageManager.log("[DEBUG] Checked if the player is muted 2.");

// Get if vanishable players can message vanishable players.
boolean allowVanishablePlayers = ConfigMain.getVanishableCanSeeVanishable();
Expand All @@ -122,7 +122,7 @@ public CommandStatus onPlayerRun(ConfigurationSection section, String[] argument
if ((allowVanishablePlayers && userIsVanishable)
|| recipientNotVanished) {

MessageManager.log("[DEBUG] Check ignoring and can message");
MessageManager.log("[DEBUG] Check ignoring and can message.");

// Check for ignoring.
if (user.isIgnoring(recipient.getUniqueId())) {
Expand All @@ -146,7 +146,7 @@ public CommandStatus onPlayerRun(ConfigurationSection section, String[] argument
return new CommandStatus();
}

MessageManager.log("[DEBUG] Checked if ignoring and can message");
MessageManager.log("[DEBUG] Checked if ignoring and can message.");

// Send messages and sounds.
recipient.sendMessage(PlaceholderManager.parse(section.getAdaptedString("from", "\n")
Expand All @@ -164,16 +164,20 @@ public CommandStatus onPlayerRun(ConfigurationSection section, String[] argument

// Spy sound.
for (Player player : Leaf.getServer().getAllPlayers()) {
User temp = new User(player);
if (Objects.equals(temp.getRecord().toggleSeeSpy, "true")) {
Sounds.play(section.getString("spy_sound"), temp.getUniqueId());
try {
User temp = new User(player);
if (Objects.equals(temp.getRecord().toggleSeeSpy, "true")) {
Sounds.play(section.getString("spy_sound"), temp.getUniqueId());
}
} catch (Exception exception) {
MessageManager.log("[DEBUG] Unable to send sound for a player on message.");
}
}

// Log message interaction.
MessageManager.setLastMessaged(user.getUniqueId(), recipient.getUniqueId());

MessageManager.log("[DEBUG] Save in database");
MessageManager.log("[DEBUG] Save in database.");

// Save to a database if enabled.
if (!Leaf.isDatabaseDisabled()
Expand All @@ -190,9 +194,11 @@ public CommandStatus onPlayerRun(ConfigurationSection section, String[] argument

// Limit old messages if the number of messages is over the limit.
messageTable.limitMessages(user.getUniqueId().toString(), limit);

MessageManager.log("[DEBUG] Saved in database.");
}

MessageManager.log("[DEBUG] Saved in database");
MessageManager.log("[DEBUG] Finished Debugging.");

return new CommandStatus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public static void onPlayerJoinCustomEvent(ServerConnectedEvent event) {
// Set the users connected server.
user.setConnectedServer(server);

// Check if vanished.
if (user.isVanished()) return;

// Run the events.
if (event.getPreviousServer().isEmpty()) {
EventManager.runEvent(EventType.PLAYER_JOIN, user);
Expand Down

0 comments on commit 0638a34

Please sign in to comment.