Add ALogger
This commit is contained in:
parent
f5066d4a9e
commit
47fd6bf2db
|
|
@ -2,6 +2,7 @@ package com.alttd.chat.database;
|
|||
|
||||
import com.alttd.chat.objects.Party;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.chat.util.ALogger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
|
@ -273,6 +274,7 @@ public class Queries {
|
|||
|
||||
if (party == null) {
|
||||
//TODO log this properly
|
||||
ALogger.error("INCORRECT LOGGING: party was empty, the party id stored in the database with user " + uuid + " was invalid.");
|
||||
System.out.println("INCORRECT LOGGING: party was empty, the party id stored in the database with user " + uuid + " was invalid.");
|
||||
continue;
|
||||
}
|
||||
|
|
@ -286,7 +288,7 @@ public class Queries {
|
|||
}
|
||||
|
||||
public static void addUser(ChatUser user) {
|
||||
String query = "INSERT INTO party_users (uuid, party_id, toggled_chat, force_tp, toggled_gc) VALUES (?, ?, ?, ?, ?)";
|
||||
String query = "INSERT INTO chat_users (uuid, party_id, toggled_chat, force_tp, toggled_gc) VALUES (?, ?, ?, ?, ?)";
|
||||
|
||||
try {
|
||||
Connection connection = DatabaseConnection.getConnection();
|
||||
|
|
@ -305,11 +307,11 @@ public class Queries {
|
|||
}
|
||||
|
||||
public static void setChatState(boolean toggledChat, UUID uuid) {
|
||||
setBitWhereId("UPDATE party_users set toggled_chat = ? WHERE uuid = ?", toggledChat, uuid);
|
||||
setBitWhereId("UPDATE chat_users set toggled_chat = ? WHERE uuid = ?", toggledChat, uuid);
|
||||
}
|
||||
|
||||
public static void setForceTpState(boolean forceTp, UUID uuid) {
|
||||
setBitWhereId("UPDATE party_users set force_tp = ? WHERE uuid = ?", forceTp, uuid);
|
||||
setBitWhereId("UPDATE chat_users set force_tp = ? WHERE uuid = ?", forceTp, uuid);
|
||||
}
|
||||
|
||||
private static void setBitWhereId(String query, boolean bool, UUID uuid) {
|
||||
|
|
@ -327,7 +329,7 @@ public class Queries {
|
|||
}
|
||||
|
||||
public static void removeUser(UUID uuid) {
|
||||
String query = "DELETE FROM party_users WHERE uuid = ?";
|
||||
String query = "DELETE FROM chat_users WHERE uuid = ?";
|
||||
|
||||
try {
|
||||
Connection connection = DatabaseConnection.getConnection();
|
||||
|
|
|
|||
26
api/src/main/java/com/alttd/chat/util/ALogger.java
Normal file
26
api/src/main/java/com/alttd/chat/util/ALogger.java
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package com.alttd.chat.util;
|
||||
|
||||
public class ALogger {
|
||||
// static abuse
|
||||
private static org.slf4j.Logger logger;
|
||||
|
||||
public ALogger(org.slf4j.Logger log) {
|
||||
logger = log;
|
||||
}
|
||||
|
||||
private void log(String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
public static void warn(String message) {
|
||||
logger.warn(message);
|
||||
}
|
||||
|
||||
public static void info(String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
public static void error(String message) {
|
||||
logger.error(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.alttd.chat.config.Config;
|
|||
import com.alttd.chat.handler.ChatHandler;
|
||||
import com.alttd.chat.listeners.PlayerListener;
|
||||
import com.alttd.chat.listeners.PluginMessage;
|
||||
import com.alttd.chat.util.ALogger;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
|
@ -21,6 +22,7 @@ public class ChatPlugin extends JavaPlugin {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
new ALogger(this.getSLF4JLogger());
|
||||
chatAPI = new ChatImplementation();
|
||||
chatHandler = new ChatHandler();
|
||||
registerListener(new PlayerListener());
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public class ChatHandler {
|
|||
}
|
||||
|
||||
public void globalChat(CommandSender source, String message) {
|
||||
// Check if the player has global chat enabled, if not warn them
|
||||
String senderName, prefix = "";
|
||||
|
||||
Player sender = (Player) source;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.alttd.chat.handlers.ServerHandler;
|
|||
import com.alttd.chat.listeners.ChatListener;
|
||||
import com.alttd.chat.listeners.ProxyPlayerListener;
|
||||
import com.alttd.chat.listeners.PluginMessageListener;
|
||||
import com.alttd.chat.util.ALogger;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
|
|
@ -50,6 +51,7 @@ public class VelocityChat {
|
|||
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
new ALogger(logger);
|
||||
chatAPI = new ChatImplementation();
|
||||
|
||||
serverHandler = new ServerHandler();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user