Implemented Lombok

This commit is contained in:
Venal 2017-07-11 23:04:56 -04:00
parent 25cd9f2b4c
commit 28055867e1
22 changed files with 644 additions and 725 deletions

View File

@ -1,22 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
<profile default="true" name="Default" enabled="true" />
</annotationProcessing>
<bytecodeTargetLevel>
<module name="Rixa_main" target="1.8" />

View File

@ -2,6 +2,7 @@
<library name="Gradle: commons-io:commons-io:2.5">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.5/2852e6e05fbb95076fc091f6d1780f1f8fe35e0f/commons-io-2.5.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/2.5/commons-io-2.5.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>

View File

@ -34,6 +34,7 @@
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.projectlombok:lombok:1.16.8" level="project" />
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpcore-nio:4.4.4" level="project" />
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-core:4.0.6" level="project" />
</component>

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,7 @@ dependencies {
compile 'com.sedmelluq:lavaplayer:1.2.42'
compile 'org.twitter4j:twitter4j-core:4.0.3'
compile 'org.twitter4j:twitter4j-stream:4.0.6'
compileOnly 'org.projectlombok:lombok:1.16.8'
}
compileJava.options.encoding = 'UTF-8'

View File

@ -1,5 +1,7 @@
package me.savvy.rixa;
import lombok.Getter;
import lombok.Setter;
import me.savvy.rixa.commands.admin.BatchMoveCommand;
import me.savvy.rixa.commands.admin.ConfigCommand;
import me.savvy.rixa.commands.general.*;
@ -37,13 +39,20 @@ import java.util.logging.Logger;
* Created by Timber on 5/7/2017.
*/
public class Rixa {
@Getter
private static Data data;
@Getter
private static long timeUp;
@Getter
private static Rixa instance;
@Getter
private static List<JDA> shardsList;
@Getter
private static ConfigManager config;
@Getter @Setter
private static DatabaseManager dbManager;
@Getter @Setter
private LanguageManager languageManager;
// String search = event.getMessage().getContent().substring(event.getMessage().getContent().indexOf(" ") + 1);
public static void main(String[] args) {
@ -92,27 +101,7 @@ public class Rixa {
register(new React[] {new HelpReaction(), new ConfigReaction()});
data = new Data(DataType.SQL);
}
public Data getData() {
return data;
}
public DatabaseManager getDbManager() {
return dbManager;
}
public void setDbManager(DatabaseManager dbManager) {
Rixa.dbManager = dbManager;
}
public LanguageManager getLanguageManager() {
return languageManager;
}
private void setLanguageManager(LanguageManager languageManager) {
this.languageManager = languageManager;
}
private static void register(CommandExec commandExecs[]) {
for (CommandExec command: commandExecs) {
CommandHandler.registerCommand(command);
@ -125,23 +114,8 @@ public class Rixa {
}
}
public static Rixa getInstance() {
return instance;
}
public long getTimeUp() {
return timeUp;
}
public Logger getLogger() {
return Logger.getLogger("Rixa");
}
public ConfigManager getConfig() {
return config;
}
public List<JDA> getShardsList() {
return shardsList;
}
}

View File

@ -1,5 +1,6 @@
package me.savvy.rixa.action;
import lombok.Getter;
import net.dv8tion.jda.core.entities.Guild;
import java.util.HashMap;
@ -9,8 +10,10 @@ import java.util.Map;
* Created by savit on 6/24/2017.
*/
public class ActionManager {
@Getter
private Guild guild;
@Getter
private Map<String, Action> actionMap;
public ActionManager(Guild guild) {
@ -18,14 +21,6 @@ public class ActionManager {
actionMap = new HashMap<>();
}
public Guild getGuild() {
return guild;
}
public Map<String, Action> getActionMap() {
return actionMap;
}
public Action getAction(String actionName) {
return actionMap.get(actionName);
}

View File

@ -1,14 +1,19 @@
package me.savvy.rixa.commands.handlers;
import lombok.Getter;
import java.lang.reflect.Method;
/**
* Created by Timber on 5/7/2017.
*/
public class CommandRegistrar {
@Getter
private final Command annotation;
@Getter
private final Method method;
@Getter
private final CommandExec executor;
CommandRegistrar(Command annotation, Method method, CommandExec executor) {
@ -16,16 +21,5 @@ public class CommandRegistrar {
this.method = method;
this.executor = executor;
}
public Command getCommandAnnotation() {
return annotation;
}
public Method getMethod() {
return method;
}
public CommandExec getExecutor() {
return executor;
}
}

View File

@ -1,5 +1,7 @@
package me.savvy.rixa.data.database.sql.mysql;
import lombok.Getter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -13,7 +15,8 @@ import java.sql.Statement;
* @author tips48
*/
public abstract class Database {
@Getter
protected Connection connection;
/**
@ -47,15 +50,7 @@ public abstract class Database {
return connection != null && !connection.isClosed();
}
/**
* Gets the connection with the database
*
* @return Connection with the database, null if none
*/
public Connection getConnection() {
return connection;
}
/**
* Closes the connection with the database
*

View File

@ -1,5 +1,7 @@
package me.savvy.rixa.data.locale;
import lombok.Getter;
/**
* Created by Timber on 5/31/2017.
*/
@ -7,20 +9,15 @@ public enum Language {
NO_PERMISSION("noPermission", "I do not have permission for this!"),
NO_PERMISSION_FOR("noPermissionFor", "Sorry I do not have permission for {0}");
@Getter
private final String key;
@Getter
private final String defaultValue;
Language(String key, String defaultValue) {
this.key = key;
this.defaultValue = defaultValue;
}
public String getDefaultValue() {
return defaultValue;
}
public String getKey() {
return key;
}
}

View File

@ -1,5 +1,6 @@
package me.savvy.rixa.data.thunderbolt.io;
import lombok.Getter;
import me.savvy.rixa.data.thunderbolt.json.JSONArray;
import me.savvy.rixa.data.thunderbolt.json.JSONObject;
import me.savvy.rixa.data.thunderbolt.utils.Validator;
@ -15,8 +16,10 @@ import java.util.*;
*/
public class ThunderFile {
@Getter
private final String name, path;
private JSONObject jo = new JSONObject();
@Getter
private File f;
/**
@ -52,24 +55,7 @@ public class ThunderFile {
this(name, path);
jo = new JSONObject(jsonData);
}
/**
* Get the name of the file
*
* @return The name of the File
*/
public String getName(){
return name;
}
/**
* Get the path to the file
*
* @return The path to the file
*/
public String getPath(){
return path;
}
/**
* Set an object in the file's map. This works like any old Map.
@ -391,8 +377,4 @@ public class ThunderFile {
}
return set;
}
public File getFile() {
return f;
}
}

View File

@ -1,15 +1,15 @@
package me.savvy.rixa.data.thunderbolt.io;
import lombok.Getter;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public abstract class ThunderboltThreadPool {
@Getter
private static ExecutorService pool = Executors.newCachedThreadPool();
private ThunderboltThreadPool(){}
public static ExecutorService getPool(){
return pool;
}
}

View File

@ -1,5 +1,7 @@
package me.savvy.rixa.extras.polls;
import lombok.Getter;
import lombok.Setter;
import me.savvy.rixa.utils.MessageBuilder;
import net.dv8tion.jda.core.EmbedBuilder;
@ -11,31 +13,17 @@ import java.util.List;
* Created by Timber on 5/23/2017.
*/
public class Poll {
@Getter @Setter
private String name, description;
@Getter
private List<String> options;
public Poll(String name) {
this.name = name;
options = new ArrayList<>();
}
public String getTitle() {
return name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<String> getOptions() {
return options;
}
public boolean addOption(String s) {
if(options.size() == 10) {
return false;

View File

@ -1,5 +1,7 @@
package me.savvy.rixa.guild;
import lombok.Getter;
import lombok.Setter;
import me.savvy.rixa.Rixa;
import me.savvy.rixa.commands.handlers.RixaPermission;
import me.savvy.rixa.data.database.sql.DatabaseManager;
@ -19,12 +21,17 @@ import java.util.List;
* Created by Timber on 5/23/2017.
*/
public class RixaGuild {
@Getter
private Guild guild;
private DatabaseManager db;
@Setter
private GuildSettings guildSettings;
@Getter @Setter
private MusicModule musicModule;
@Getter @Setter
private TwitterModule twitterModule;
@Getter
private List<String> mutedMembers = new ArrayList<>();
public RixaGuild(Guild guild) {
@ -49,20 +56,12 @@ public class RixaGuild {
public GuildSettings getGuildSettings() {
return (guildSettings == null) ? this.guildSettings = new GuildSettings(getGuild()) : guildSettings;
}
public void setGuildSettings(GuildSettings guildSettings) {
this.guildSettings = guildSettings;
}
private boolean checkExists() {
Result r = Rixa.getInstance().getDbManager().checkExists("SELECT `guild_name` FROM `core` WHERE `guild_id` = '" + guild.getId() + "';");
return r == Result.TRUE;
}
public Guild getGuild() {
return guild;
}
public boolean hasPermission(Member member, RixaPermission permission) {
if(Rixa.getInstance().getConfig().getConfig().getStringList("botAdmins").contains(member.getUser().getId()) ||
member.getUser().getId().equals(guild.getOwner().getUser().getId())) {
@ -136,20 +135,5 @@ public class RixaGuild {
if(!isUserMuted(user))
mutedMembers.add(user.getId());
}
public MusicModule getMusicModule() {
return musicModule;
}
public void setMusicModule(MusicModule musicModule) {
this.musicModule = musicModule;
}
public TwitterModule getTwitterModule() {
return twitterModule;
}
public void setTwitterModule(TwitterModule twitterModule) {
this.twitterModule = twitterModule;
}
}

View File

@ -1,5 +1,6 @@
package me.savvy.rixa.guild.management;
import lombok.Getter;
import me.savvy.rixa.Rixa;
import me.savvy.rixa.enums.Result;
import net.dv8tion.jda.core.entities.Guild;
@ -13,10 +14,13 @@ import java.sql.SQLException;
* Created by Timber on 5/23/2017.
*/
public class GuildSettings {
@Getter
private Guild guild;
@Getter
private boolean enlisted, joinVerification;
@Getter
private String prefix = "/", defaultRole, muteRole, joinMessage, quitMessage, joinPrivateMessage, description;
@Getter
private TextChannel joinMessageChannel, quitMessageChannel;
public GuildSettings(Guild guild) {
@ -69,104 +73,56 @@ public class GuildSettings {
}
public Guild getGuild() {
return guild;
}
public String getJoinMessage() {
return joinMessage;
}
public void setJoinMessage(String joinMessage) {
this.joinMessage = joinMessage;
Rixa.getInstance().getData().update("settings", "joinMessage", "guild_id", joinMessage, guild.getId());
}
public String getQuitMessage() {
return quitMessage;
}
public void setQuitMessage(String quitMessage) {
this.quitMessage = quitMessage;
Rixa.getInstance().getData().update("settings", "quitMessage", "guild_id", quitMessage, guild.getId());
}
public String getJoinPrivateMessage() {
return joinPrivateMessage;
}
public void setJoinPrivateMessage(String joinPrivateMessage) {
this.joinPrivateMessage = joinPrivateMessage;
Rixa.getInstance().getData().update("settings", "joinPM", "guild_id", joinPrivateMessage, guild.getId());
}
public TextChannel getJoinMessageChannel() {
return joinMessageChannel;
}
public void setJoinMessageChannel(TextChannel joinMessageChannel) {
this.joinMessageChannel = joinMessageChannel;
Rixa.getInstance().getData().update("settings", "greetings", "guild_id", joinMessageChannel.getId(), guild.getId());
}
public TextChannel getQuitMessageChannel() {
return quitMessageChannel;
}
public void setQuitMessageChannel(TextChannel quitMessageChannel) {
this.quitMessageChannel = quitMessageChannel;
Rixa.getInstance().getData().update("settings", "farewell", "guild_id", quitMessageChannel.getId(), guild.getId());
}
public String getDefaultRole() {
return defaultRole;
}
public void setDefaultRole(String defaultRole) {
this.defaultRole = defaultRole;
Rixa.getInstance().getData().update("settings", "defaultRole", "guild_id", defaultRole, guild.getId());
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
Rixa.getInstance().getData().update("settings", "prefix", "guild_id", prefix, guild.getId());
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
Rixa.getInstance().getData().update("core", "description", "guild_id", description, guild.getId());
}
public boolean isEnlisted() {
return enlisted;
}
public void setEnlisted(boolean enlisted) {
this.enlisted = enlisted;
Rixa.getInstance().getData().update("core", "enlisted", "guild_id", enlisted, guild.getId());
}
public String getMuteRole() {
return muteRole;
}
public void setMuteRole(String muteRole) {
this.muteRole = muteRole;
Rixa.getInstance().getData().update("settings", "muteRole", "guild_id", muteRole, guild.getId());
}
public boolean isJoinVerification() {
return joinVerification;
}
public void setJoinVerification(boolean joinVerification) {
this.joinVerification = joinVerification;
Rixa.getInstance().getData().update("settings", "joinVerification", "guild_id", joinVerification, guild.getId());

View File

@ -1,5 +1,6 @@
package me.savvy.rixa.modules.music;
import lombok.Getter;
import me.savvy.rixa.Rixa;
import me.savvy.rixa.data.database.sql.DatabaseManager;
import me.savvy.rixa.enums.Result;
@ -15,8 +16,11 @@ import java.sql.SQLException;
*/
public class MusicModule implements RixaModule {
private DatabaseManager db;
@Getter
private boolean enabled;
@Getter
private String musicRole;
@Getter
private Guild guild;
public MusicModule(Guild guild) {
@ -53,11 +57,7 @@ public class MusicModule implements RixaModule {
public String getDescription() {
return "Listen to music in your voice channel.";
}
@Override
public boolean isEnabled() {
return enabled;
}
public Result setEnabled(boolean val) {
this.enabled = val;
@ -67,20 +67,13 @@ public class MusicModule implements RixaModule {
public boolean isRoleRequired() {
return (!musicRole.equalsIgnoreCase("default_value"));
}
public String getMusicRole() {
return musicRole;
}
public Result setRole(String newRole) {
this.musicRole = newRole;
return Rixa.getInstance().getData().update("music", "music_role", "guild_id", newRole, guild.getId());
}
public Guild getGuild() {
return guild;
}
public boolean checkExists() {
Result r = Rixa.getInstance().getDbManager().checkExists("SELECT `guild_id` FROM `music` WHERE `guild_id` = '" +
guild.getId() + "';");

View File

@ -4,6 +4,8 @@ import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason;
import lombok.Getter;
import lombok.Setter;
import java.util.Collections;
import java.util.LinkedList;
@ -14,6 +16,7 @@ import java.util.Queue;
* Created by Timber on 6/13/2017.
*/
public class TrackScheduler extends AudioEventAdapter {
@Getter @Setter
private boolean repeating = false;
final AudioPlayer player;
public final Queue<AudioTrack> queue;
@ -68,15 +71,7 @@ public class TrackScheduler extends AudioEventAdapter {
}
}
public boolean isRepeating() {
return repeating;
}
public void setRepeating(boolean repeating) {
this.repeating = repeating;
}
public void shuffle() {
Collections.shuffle((List<?>) queue);
}

View File

@ -1,14 +1,19 @@
package me.savvy.rixa.modules.reactions.handlers;
import lombok.Getter;
import java.lang.reflect.Method;
/**
* Created by Timber on 5/7/2017.
*/
public class ReactRegistrar {
@Getter
private final ReactHandle annotation;
@Getter
private final Method method;
@Getter
private final React executor;
ReactRegistrar(ReactHandle annotation, Method method, React executor) {
@ -16,16 +21,4 @@ public class ReactRegistrar {
this.method = method;
this.executor = executor;
}
public ReactHandle getReactAnnotation() {
return annotation;
}
public Method getMethod() {
return method;
}
public React getExecutor() {
return executor;
}
}

View File

@ -1,5 +1,7 @@
package me.savvy.rixa.modules.reactions.handlers;
import lombok.Getter;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@ -8,7 +10,8 @@ import java.util.Map;
* Created by Timber on 5/7/2017.
*/
public class ReactionManager {
@Getter
private static final Map<String, ReactRegistrar> reactions = new HashMap<>();
public static void registerReaction(React react) {
@ -20,7 +23,4 @@ public class ReactionManager {
}
}
public static Map<String, ReactRegistrar> getReactions() {
return reactions;
}
}

View File

@ -1,5 +1,7 @@
package me.savvy.rixa.modules.twitter;
import lombok.Getter;
import lombok.Setter;
import me.savvy.rixa.guild.RixaGuild;
import twitter4j.*;
import twitter4j.conf.ConfigurationBuilder;
@ -8,11 +10,16 @@ import twitter4j.conf.ConfigurationBuilder;
* Created by savit on 7/9/2017.
*/
public class TwitterModule {
@Getter
private final TwitterStream twitterStream;
@Getter
private ConfigurationBuilder configurationBuilder;
@Getter
private Twitter twitter;
@Getter
private TwitterFactory twitterFactory;
@Getter @Setter
private String consumerKey, consumerSecret, accessToken, accessTokenSecret;
public TwitterModule(RixaGuild rixaGuild, String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret) {
@ -29,52 +36,5 @@ public class TwitterModule {
twitterStream = new TwitterStreamFactory().getInstance();
twitter = twitterFactory.getInstance();
}
public ConfigurationBuilder getConfigurationBuilder() {
return configurationBuilder;
}
public TwitterFactory getTwitterFactory() {
return twitterFactory;
}
public Twitter getTwitter() {
return twitter;
}
public String getConsumerKey() {
return consumerKey;
}
public void setConsumerKey(String consumerKey) {
this.consumerKey = consumerKey;
}
public String getConsumerSecret() {
return consumerSecret;
}
public void setConsumerSecret(String consumerSecret) {
this.consumerSecret = consumerSecret;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String getAccessTokenSecret() {
return accessTokenSecret;
}
public void setAccessTokenSecret(String accessTokenSecret) {
this.accessTokenSecret = accessTokenSecret;
}
public TwitterStream getTwitterStream() {
return twitterStream;
}
}

View File

@ -1,5 +1,6 @@
package me.savvy.rixa.utils;
import lombok.Getter;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.*;
@ -11,7 +12,8 @@ import java.awt.*;
public class MessageBuilder {
private Message message;
@Getter
private EmbedBuilder builder;
public MessageBuilder(String description) {
this.builder = new EmbedBuilder().setDescription(description);
@ -41,11 +43,7 @@ public class MessageBuilder {
builder.setThumbnail(url);
return this;
}
public EmbedBuilder getBuilder() {
return builder;
}
public void queue(TextChannel channel) {
channel.sendMessage(builder.build()).queue();
}

View File

@ -1,5 +1,6 @@
package me.savvy.rixa.utils;
import lombok.Getter;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -13,9 +14,12 @@ import java.util.Scanner;
* Created by savit on 6/24/2017.
*/
public class UrbanDictionary {
@Getter
private String wordToSearch;
@Getter
private String definition;
@Getter
private String permaLink;
public UrbanDictionary(String wordToSearch) {
this.wordToSearch = wordToSearch;
@ -42,16 +46,5 @@ public class UrbanDictionary {
return false;
}
}
public String getPermaLink() {
return permaLink;
}
public String getWordToSearch() {
return wordToSearch;
}
public String getDefinition() {
return definition;
}
}