Skip to content

Commit

Permalink
Add some more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgrandt committed Aug 5, 2017
1 parent 988c295 commit 7b8d0b0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/erigitic/sql/SQLManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ public DataSource getDataSource(String jdbcUrl) throws SQLException {
return sql.getDataSource(jdbcUrl);
}

/**
* Create a new table in the database
*
* @param tableName Name of the table to be created
* @param cols The columns that the table should have
* @return boolean Result of the query
*/
public boolean createTable(String tableName, String cols) {
try {
Connection conn = dataSource.getConnection();
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/erigitic/sql/SQLQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ public String getString(String def) {
return def;
}

/**
* Get the number of rows that were affected by a query
*
* @return int Number of rows that were affected by the query
*/
public int getRowsAffected() {
return rowsAffected;
}
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/com/erigitic/util/MessageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.ResourceBundle;

public class MessageManager {

Expand All @@ -54,7 +53,7 @@ public class MessageManager {

/**
* Grabs a message from the messages_[lang].conf file and converts it to a usable String/Text object ready for printing. Colors
* are changed, and aliases are changed to their corresponding values which are passed in.
* are changed, and value placeholders are changed to their corresponding values which are passed in.
*/
public MessageManager(TotalEconomy totalEconomy, Locale locale) {
this.totalEconomy = totalEconomy;
Expand All @@ -65,7 +64,7 @@ public MessageManager(TotalEconomy totalEconomy, Locale locale) {
}

/**
* Setup the config file that will contain the messages
* Setup the messages_[lang].conf file
*/
private void setupConfig(Locale locale) {
messagesFile = new File(totalEconomy.getConfigDir(), "messages_" + locale.getLanguage() + ".conf");
Expand All @@ -85,12 +84,25 @@ private void setupConfig(Locale locale) {
}
}

/**
* Get a message from the messages_[lang].conf file and deserialize it for printing
*
* @param messageKey The key to grab a value from
* @return Text The deserialized message
*/
public Text getMessage(String messageKey) {
String message = messagesConfig.getNode(messageKey).getString();

return TextSerializers.FORMATTING_CODE.deserialize(message);
}

/**
* Get a message from the messages_[lang].conf file, replace value placeholders, and deserialize it for printing
*
* @param messageKey The key to grab a value from
* @param values Map of values that will replace value placeholders (ex. {amount}, {name})
* @return Text The deserialized message
*/
public Text getMessage(String messageKey, Map<String, String> values) {
StrSubstitutor sub = new StrSubstitutor(values, "{", "}");
String message = sub.replace(messagesConfig.getNode(messageKey).getString());
Expand Down

0 comments on commit 7b8d0b0

Please sign in to comment.