refactor: fix inspection errors for deprecated calls and concatenation
This commit is contained in:
1 parent
f6ed32b090
commit
5775493b2c
10 files changed
+21
-35
No files matched your search
@@ -66,7 +66,7 @@ public class CommandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Loaded " + commands.size() + " commands!");
|
logger.info("Loaded {} commands!", commands.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerSlashCommands() {
|
private static void registerSlashCommands() {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class GuildConfigManager {
|
|||||||
session.beginTransaction();
|
session.beginTransaction();
|
||||||
if (value == null || setting.getDefaultValue().equals(value)) {
|
if (value == null || setting.getDefaultValue().equals(value)) {
|
||||||
if (oGuildSetting != null) {
|
if (oGuildSetting != null) {
|
||||||
session.delete(oGuildSetting);
|
session.remove(oGuildSetting);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (oGuildSetting == null) {
|
if (oGuildSetting == null) {
|
||||||
@@ -67,11 +67,11 @@ public class GuildConfigManager {
|
|||||||
oGuildSetting.setName(setting.getName());
|
oGuildSetting.setName(setting.getName());
|
||||||
oGuildSetting.setValue(value);
|
oGuildSetting.setValue(value);
|
||||||
|
|
||||||
session.save(oGuildSetting);
|
session.persist(oGuildSetting);
|
||||||
} else {
|
} else {
|
||||||
oGuildSetting.setValue(value);
|
oGuildSetting.setValue(value);
|
||||||
|
|
||||||
session.update(oGuildSetting);
|
session.merge(oGuildSetting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ public class GuildConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reloadSettingsCache() {
|
public void reloadSettingsCache() {
|
||||||
logger.debug("Reloading settings cache for guild: " + guild.getId());
|
logger.debug("Reloading settings cache for guild: {}", guild.getId());
|
||||||
settingsCache.clear();
|
settingsCache.clear();
|
||||||
|
|
||||||
JpaUtils.getWithSession(guildEntity, session -> {
|
JpaUtils.getWithSession(guildEntity, session -> {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import me.bobert.netneutrality.db.entities.OBlacklist;
|
|||||||
import me.bobert.netneutrality.db.entities.OGuild;
|
import me.bobert.netneutrality.db.entities.OGuild;
|
||||||
import me.bobert.netneutrality.thread.ThreadManager;
|
import me.bobert.netneutrality.thread.ThreadManager;
|
||||||
import me.bobert.netneutrality.utils.JpaUtils;
|
import me.bobert.netneutrality.utils.JpaUtils;
|
||||||
import me.bobert.netneutrality.utils.MessageFunction;
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
@@ -113,7 +112,7 @@ public class GuildManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reloadBlacklistCache() {
|
public void reloadBlacklistCache() {
|
||||||
logger.debug("Reloading blacklist cache for guild: " + guild.getId());
|
logger.debug("Reloading blacklist cache for guild: {}", guild.getId());
|
||||||
blacklistCache.clear();
|
blacklistCache.clear();
|
||||||
|
|
||||||
JpaUtils.getWithSession(guildEntity, session -> {
|
JpaUtils.getWithSession(guildEntity, session -> {
|
||||||
@@ -127,16 +126,6 @@ public class GuildManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkAndLogMessage(Message message, Member member, MessageChannel channel) {
|
|
||||||
if (isLoggingEnabled()) {
|
|
||||||
ThreadManager.getExecutor().submit(() -> DBController.get(DBMessage.class).log(this, channel, member, message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkBlacklist(Message message, MessageChannel channel) {
|
|
||||||
MessageFunction.testMessageAgainstBlacklist(message, channel, blacklistCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
private OGuild loadGuildFromDb(String guildId) {
|
private OGuild loadGuildFromDb(String guildId) {
|
||||||
Session session = sessionFactory.openSession();
|
Session session = sessionFactory.openSession();
|
||||||
OGuild entity = session.get(OGuild.class, guildId);
|
OGuild entity = session.get(OGuild.class, guildId);
|
||||||
@@ -148,7 +137,7 @@ public class GuildManager {
|
|||||||
|
|
||||||
entity.setGuildId(guildId);
|
entity.setGuildId(guildId);
|
||||||
|
|
||||||
session.save(entity);
|
session.persist(entity);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
|
|
||||||
guild.getTextChannels()
|
guild.getTextChannels()
|
||||||
@@ -169,7 +158,7 @@ public class GuildManager {
|
|||||||
Session session = sessionFactory.openSession();
|
Session session = sessionFactory.openSession();
|
||||||
session.beginTransaction();
|
session.beginTransaction();
|
||||||
|
|
||||||
session.delete(guildEntity);
|
session.remove(guildEntity);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
session.close();
|
session.close();
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class DBBlacklist extends AbstractController {
|
|||||||
bl.setWord(word);
|
bl.setWord(word);
|
||||||
bl.setEnabled(true);
|
bl.setEnabled(true);
|
||||||
|
|
||||||
session.save(bl);
|
session.persist(bl);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
session.close();
|
session.close();
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public class DBBlacklist extends AbstractController {
|
|||||||
Session session = getSessionFactory().openSession();
|
Session session = getSessionFactory().openSession();
|
||||||
session.beginTransaction();
|
session.beginTransaction();
|
||||||
|
|
||||||
session.delete(bl);
|
session.remove(bl);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
session.close();
|
session.close();
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public class DBBlacklist extends AbstractController {
|
|||||||
|
|
||||||
bl.setEnabled(true);
|
bl.setEnabled(true);
|
||||||
|
|
||||||
session.update(bl);
|
session.merge(bl);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
session.close();
|
session.close();
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ public class DBBlacklist extends AbstractController {
|
|||||||
|
|
||||||
bl.setEnabled(false);
|
bl.setEnabled(false);
|
||||||
|
|
||||||
session.update(bl);
|
session.merge(bl);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
session.close();
|
session.close();
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class DBMessage extends AbstractController {
|
|||||||
logMessage.setUserId(author.getId());
|
logMessage.setUserId(author.getId());
|
||||||
logMessage.setDateSent(message.getTimeCreated().toInstant());
|
logMessage.setDateSent(message.getTimeCreated().toInstant());
|
||||||
|
|
||||||
session.save(logMessage);
|
session.persist(logMessage);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
session.close();
|
session.close();
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ public class DBMessage extends AbstractController {
|
|||||||
session.beginTransaction();
|
session.beginTransaction();
|
||||||
message.setEditedMessage(newMessage);
|
message.setEditedMessage(newMessage);
|
||||||
|
|
||||||
session.update(message);
|
session.merge(message);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ public class MessageReceivedHandler extends ListenerAdapter {
|
|||||||
|
|
||||||
MessageCommandContext context = MessageCommandContext.createContext(event);
|
MessageCommandContext context = MessageCommandContext.createContext(event);
|
||||||
|
|
||||||
GuildManager.getManager(context.getGuild()).checkAndLogMessage(message, context.getGuildUser(), context.getChannel());
|
|
||||||
|
|
||||||
String rawMessage = message.getContentDisplay().trim();
|
String rawMessage = message.getContentDisplay().trim();
|
||||||
String prefix = Settings.getInstance().get("NETNEUTRALITY_BOT_PREFIX", "$");
|
String prefix = Settings.getInstance().get("NETNEUTRALITY_BOT_PREFIX", "$");
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class WebModule {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebModule request(Map<String, String> headers) throws IOException {
|
public WebModule request(Map<String, String> headers) {
|
||||||
Sentry.addBreadcrumb(Breadcrumb.http(url, "get"));
|
Sentry.addBreadcrumb(Breadcrumb.http(url, "get"));
|
||||||
Request.Builder builder = new Request.Builder().url(this.url)
|
Request.Builder builder = new Request.Builder().url(this.url)
|
||||||
.addHeader("User-Agent", userAgent);
|
.addHeader("User-Agent", userAgent);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class WebApi {
|
|||||||
ExecutorService executor = Executors.newFixedThreadPool(10, new BaseThreadFactory("web-api"));
|
ExecutorService executor = Executors.newFixedThreadPool(10, new BaseThreadFactory("web-api"));
|
||||||
server.setExecutor(executor);
|
server.setExecutor(executor);
|
||||||
server.start();
|
server.start();
|
||||||
logger.info("Web server started at [" + server.getAddress() + "]");
|
logger.info("Web server started at [{}]", server.getAddress());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,12 +75,12 @@ public class UdioAudioSourceManager implements AudioSourceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encodeTrack(AudioTrack track, DataOutput output) throws IOException {
|
public void encodeTrack(AudioTrack track, DataOutput output) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AudioTrack decodeTrack(AudioTrackInfo trackInfo, DataInput input) throws IOException {
|
public AudioTrack decodeTrack(AudioTrackInfo trackInfo, DataInput input) {
|
||||||
return new UdioAudioTrack(trackInfo, this);
|
return new UdioAudioTrack(trackInfo, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ public class JpaUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to read the persistent state into the object.
|
* Tries to read the persistent state into the object.
|
||||||
*
|
* <p>
|
||||||
* If the object is not found in the database and is of type {@link OGuild}, tries to recreate entity and throws
|
* If the object is not found in the database and is of type {@link OGuild}, tries to recreate entity and throws
|
||||||
* an exception to block execution.
|
* an exception to block execution.
|
||||||
*
|
* <p>
|
||||||
* The session is not closed
|
* The session is not closed
|
||||||
*
|
*
|
||||||
* @param session The session in which to load the persistent object
|
* @param session The session in which to load the persistent object
|
||||||
@@ -62,7 +62,7 @@ public class JpaUtils {
|
|||||||
|
|
||||||
runnable.run();
|
runnable.run();
|
||||||
|
|
||||||
session.update(persistantEntity);
|
session.merge(persistantEntity);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
session.close();
|
session.close();
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,6 @@ public class JpaUtils {
|
|||||||
/**
|
/**
|
||||||
* @param persistantEntity The entity to load
|
* @param persistantEntity The entity to load
|
||||||
* @param id The identifier for the entity
|
* @param id The identifier for the entity
|
||||||
* @param close If the session should be closed after consumer is executed
|
|
||||||
* @param consumer The comsumer, which exposes the session
|
* @param consumer The comsumer, which exposes the session
|
||||||
*/
|
*/
|
||||||
public static void getWithSession(Object persistantEntity, Serializable id, Consumer<Session> consumer) {
|
public static void getWithSession(Object persistantEntity, Serializable id, Consumer<Session> consumer) {
|
||||||
|
|||||||
Reference in new issue
Block a user