Fix DB updating and empty channel messages

This commit is contained in:
Draycia committed 2020-07-12 07:44:12 -07:00
1 parent 315b801e07
commit 3a949353c1
4 files changed
+20 -2

No files matched your search

@@ -129,7 +129,7 @@ public class SimpleChatChannel extends ChatChannel {
return;
}
ChatComponentEvent newEvent = new ChatComponentEvent(user, this, newFormat, formatEvent.getMessage(), Collections.singletonList(chatUser));
ChatComponentEvent newEvent = new ChatComponentEvent(user, this, newFormat, formatEvent.getMessage(), Collections.singletonList(chatUser), true);
Bukkit.getPluginManager().callEvent(newEvent);
@@ -20,8 +20,13 @@ public class ChatComponentEvent extends Event implements Cancellable {
private TextComponent component;
private String originalMessage;
private List<ChatUser> recipients;
private boolean customPlayerFormat;
public ChatComponentEvent(ChatUser user, ChatChannel chatChannel, TextComponent component, String originalMessage, List<ChatUser> recipients) {
this(user, chatChannel, component, originalMessage, recipients, false);
}
public ChatComponentEvent(ChatUser user, ChatChannel chatChannel, TextComponent component, String originalMessage, List<ChatUser> recipients, boolean customPlayerFormat) {
super(true);
this.user = user;
@@ -29,6 +34,7 @@ public class ChatComponentEvent extends Event implements Cancellable {
this.component = component;
this.originalMessage = originalMessage;
this.recipients = recipients;
this.customPlayerFormat = customPlayerFormat;
}
@Override
@@ -78,4 +84,8 @@ public class ChatComponentEvent extends Event implements Cancellable {
public String getOriginalMessage() {
return originalMessage;
}
public boolean isCustomPlayerFormat() {
return customPlayerFormat;
}
}
@@ -16,6 +16,10 @@ public class EmptyChatHandler implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onComponent(ChatComponentEvent event) {
if (event.isCustomPlayerFormat()) {
return;
}
if (event.getRecipients().size() == 1 && event.getUser().equals(event.getRecipients().get(0))) {
String message = simpleChat.getConfig().getString("language.empty-channel");
@@ -16,6 +16,7 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection;
import java.sql.SQLException;
import java.sql.SQLSyntaxErrorException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -52,7 +53,10 @@ public class MySQLUserService extends UserService {
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_users (uuid CHAR(36) PRIMARY KEY," +
"channel VARCHAR(16), muted BOOLEAN, shadowmuted BOOLEAN, spyingwhispers BOOLEAN)");
database.executeUpdate("ALTER TABLE sc_users ADD COLUMN spyingwhispers BOOLEAN DEFAULT false");
// Ignore the exception, it's just saying the column already exists
try {
database.executeUpdate("ALTER TABLE sc_users ADD COLUMN spyingwhispers BOOLEAN DEFAULT false");
} catch (SQLSyntaxErrorException syntaxErrorException) {}
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_channel_settings (uuid CHAR(36), channel CHAR(16), spying BOOLEAN, ignored BOOLEAN, color TINYTEXT, PRIMARY KEY (uuid, channel))");