mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +00:00
Fix DB updating and empty channel messages
This commit is contained in:
1 parent
315b801e07
commit
3a949353c1
4 files changed
+19
-1
No files matched your search
+1
-1
@@ -129,7 +129,7 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
return;
|
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);
|
Bukkit.getPluginManager().callEvent(newEvent);
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,13 @@ public class ChatComponentEvent extends Event implements Cancellable {
|
|||||||
private TextComponent component;
|
private TextComponent component;
|
||||||
private String originalMessage;
|
private String originalMessage;
|
||||||
private List<ChatUser> recipients;
|
private List<ChatUser> recipients;
|
||||||
|
private boolean customPlayerFormat;
|
||||||
|
|
||||||
public ChatComponentEvent(ChatUser user, ChatChannel chatChannel, TextComponent component, String originalMessage, List<ChatUser> recipients) {
|
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);
|
super(true);
|
||||||
|
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@@ -29,6 +34,7 @@ public class ChatComponentEvent extends Event implements Cancellable {
|
|||||||
this.component = component;
|
this.component = component;
|
||||||
this.originalMessage = originalMessage;
|
this.originalMessage = originalMessage;
|
||||||
this.recipients = recipients;
|
this.recipients = recipients;
|
||||||
|
this.customPlayerFormat = customPlayerFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,4 +84,8 @@ public class ChatComponentEvent extends Event implements Cancellable {
|
|||||||
public String getOriginalMessage() {
|
public String getOriginalMessage() {
|
||||||
return originalMessage;
|
return originalMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCustomPlayerFormat() {
|
||||||
|
return customPlayerFormat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,10 @@ public class EmptyChatHandler implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onComponent(ChatComponentEvent event) {
|
public void onComponent(ChatComponentEvent event) {
|
||||||
|
if (event.isCustomPlayerFormat()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.getRecipients().size() == 1 && event.getUser().equals(event.getRecipients().get(0))) {
|
if (event.getRecipients().size() == 1 && event.getUser().equals(event.getRecipients().get(0))) {
|
||||||
String message = simpleChat.getConfig().getString("language.empty-channel");
|
String message = simpleChat.getConfig().getString("language.empty-channel");
|
||||||
|
|
||||||
|
|||||||
+4
@@ -16,6 +16,7 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.SQLSyntaxErrorException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
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," +
|
database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_users (uuid CHAR(36) PRIMARY KEY," +
|
||||||
"channel VARCHAR(16), muted BOOLEAN, shadowmuted BOOLEAN, spyingwhispers BOOLEAN)");
|
"channel VARCHAR(16), muted BOOLEAN, shadowmuted BOOLEAN, spyingwhispers BOOLEAN)");
|
||||||
|
|
||||||
|
// Ignore the exception, it's just saying the column already exists
|
||||||
|
try {
|
||||||
database.executeUpdate("ALTER TABLE sc_users ADD COLUMN spyingwhispers BOOLEAN DEFAULT false");
|
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))");
|
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))");
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user